pixivflow 2.29.0 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +2 -2
  3. package/dist/commands/WebUICommand.d.ts +2 -2
  4. package/dist/commands/WebUICommand.js +9 -7
  5. package/dist/config/types.d.ts +31 -0
  6. package/dist/config/validation.js +35 -0
  7. package/dist/download/handlers/IllustrationTargetHandler.d.ts +8 -0
  8. package/dist/download/handlers/IllustrationTargetHandler.js +74 -0
  9. package/dist/download/handlers/NovelTargetHandler.d.ts +7 -0
  10. package/dist/download/handlers/NovelTargetHandler.js +71 -0
  11. package/dist/download/inventory.d.ts +29 -0
  12. package/dist/download/inventory.js +80 -0
  13. package/dist/interfaces/IDatabase.d.ts +3 -0
  14. package/dist/package.json +1 -1
  15. package/dist/scheduler/TargetOutcome.d.ts +13 -0
  16. package/dist/scheduler/TargetOutcome.js +3 -1
  17. package/dist/storage/Database.d.ts +4 -0
  18. package/dist/storage/Database.js +7 -0
  19. package/dist/storage/DatabaseMigration.js +20 -0
  20. package/dist/storage/repositories/CandidateInventoryRepository.d.ts +51 -0
  21. package/dist/storage/repositories/CandidateInventoryRepository.js +129 -0
  22. package/dist/version.js +1 -1
  23. package/dist/webui/package.json +1 -1
  24. package/package.json +2 -1
  25. package/webui-frontend/dist/assets/CheckCircleOutlined-H3DnUyMO.js +2 -0
  26. package/webui-frontend/dist/assets/ClearOutlined-BpODq7I7.js +2 -0
  27. package/webui-frontend/dist/assets/CloseCircleOutlined-BFfS5iXd.js +2 -0
  28. package/webui-frontend/dist/assets/Config-DRElCeDC.js +16 -0
  29. package/webui-frontend/dist/assets/Dashboard-aqPMquSO.js +2 -0
  30. package/webui-frontend/dist/assets/DeleteOutlined-BFmW1oWe.js +2 -0
  31. package/webui-frontend/dist/assets/Download-DCKDU51K.js +2 -0
  32. package/webui-frontend/dist/assets/Files-nNoRY5tl.js +5 -0
  33. package/webui-frontend/dist/assets/PictureOutlined-U51jGr2U.js +2 -0
  34. package/webui-frontend/dist/assets/SortDescendingOutlined-CckVuL_b.js +2 -0
  35. package/webui-frontend/dist/assets/ThunderboltOutlined-ulcCd7ui.js +2 -0
  36. package/webui-frontend/dist/assets/UrlDownload-Bzs0AZN0.js +3 -0
  37. package/webui-frontend/dist/assets/dateUtils-gQt2uAjS.js +2 -0
  38. package/webui-frontend/dist/assets/errorCodeTranslator-BqIackMm.js +3 -0
  39. package/webui-frontend/dist/assets/index-B2ns27ii.js +2 -0
  40. package/webui-frontend/dist/assets/index-B7yYDv10.js +2 -0
  41. package/webui-frontend/dist/assets/index-Bbsa44oT.js +2 -0
  42. package/webui-frontend/dist/assets/index-C2ANILg9.js +19 -0
  43. package/webui-frontend/dist/assets/index-CDrp3NIf.js +8 -0
  44. package/webui-frontend/dist/assets/index-CFtP5lqo.js +22 -0
  45. package/webui-frontend/dist/assets/index-CJln3zA7.js +14 -0
  46. package/webui-frontend/dist/assets/index-CZhfhXvc.js +2 -0
  47. package/webui-frontend/dist/assets/index-CfHs6AUn.js +2 -0
  48. package/webui-frontend/dist/assets/index-DG6kGbYq.js +217 -0
  49. package/webui-frontend/dist/assets/index-DHwJxrFi.css +1 -0
  50. package/webui-frontend/dist/assets/index-DPigBPWX.js +2 -0
  51. package/webui-frontend/dist/assets/index-DarObP-C.js +2 -0
  52. package/webui-frontend/dist/assets/index-_EG4kaKN.js +47 -0
  53. package/webui-frontend/dist/assets/row-_c51T55h.js +20 -0
  54. package/webui-frontend/dist/assets/socket-oqYz9cKb.js +2 -0
  55. package/webui-frontend/dist/assets/useAuth-wCjAOx6S.js +9 -0
  56. package/webui-frontend/dist/assets/useConfig-Ds7RpIL1.js +9 -0
  57. package/webui-frontend/dist/assets/useDownload-BlxvZNEm.js +2 -0
  58. package/webui-frontend/dist/assets/useErrorHandler-BOvHue1w.js +84 -0
  59. package/webui-frontend/dist/index.html +15 -0
@@ -222,6 +222,25 @@ class DatabaseMigration {
222
222
  scope TEXT PRIMARY KEY,
223
223
  state TEXT NOT NULL,
224
224
  updated_at INTEGER NOT NULL
225
+ )`,
226
+ // Phase 5 CandidateInventory: durable 待发池 for sparse topics. Same
227
+ // database and transaction world as the Slot Ledger; never a second
228
+ // state authority. Only populated when target.topicProfile.inventory.enabled.
229
+ `CREATE TABLE IF NOT EXISTS candidate_inventory (
230
+ pixiv_id TEXT NOT NULL,
231
+ work_type TEXT NOT NULL,
232
+ topic TEXT NOT NULL,
233
+ target_id TEXT NOT NULL,
234
+ status TEXT NOT NULL DEFAULT 'pending',
235
+ snapshot_json TEXT NOT NULL,
236
+ first_seen_date TEXT NOT NULL,
237
+ last_seen_date TEXT NOT NULL,
238
+ seen_count INTEGER NOT NULL DEFAULT 1,
239
+ attempt_count INTEGER NOT NULL DEFAULT 0,
240
+ expires_at TEXT NOT NULL,
241
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
242
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
243
+ PRIMARY KEY (pixiv_id, work_type, topic, target_id)
225
244
  )`,
226
245
  // Durable error event ledger for observability (structured error
227
246
  // taxonomy; populated by download/system handlers and shown in the
@@ -244,6 +263,7 @@ class DatabaseMigration {
244
263
  resolved_at DATETIME
245
264
  )`,
246
265
  `CREATE INDEX IF NOT EXISTS idx_system_errors_bot_created ON system_errors(bot_id, created_at)`,
266
+ `CREATE INDEX IF NOT EXISTS idx_cinventory_pending ON candidate_inventory(status, first_seen_date, expires_at)`,
247
267
  ];
248
268
  // Phase 1: create tables (idempotent). Must run before any PRAGMA-based
249
269
  // column check, otherwise a fresh DB would report the table as missing and
@@ -0,0 +1,51 @@
1
+ import { BaseRepository } from './BaseRepository';
2
+ export type CandidateInventoryStatus = 'pending' | 'selected' | 'submitted' | 'filtered' | 'expired';
3
+ export interface CandidateInventoryRow {
4
+ pixivId: string;
5
+ workType: 'illustration' | 'novel';
6
+ topic: string;
7
+ targetId: string;
8
+ status: CandidateInventoryStatus;
9
+ snapshotJson: string;
10
+ firstSeenDate: string;
11
+ lastSeenDate: string;
12
+ seenCount: number;
13
+ attemptCount: number;
14
+ expiresAt: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }
18
+ export interface CandidateInventorySnapshot {
19
+ pixivId: string;
20
+ workType: 'illustration' | 'novel';
21
+ topic: string;
22
+ targetId: string;
23
+ snapshot: unknown;
24
+ date: string;
25
+ maxAgeDays: number;
26
+ }
27
+ /** Phase 5 durable 待发池 — same SQLite database as the Slot Ledger. */
28
+ export declare class CandidateInventoryRepository extends BaseRepository {
29
+ upsert(input: CandidateInventorySnapshot): void;
30
+ /** Marks a claimed candidate and returns its snapshot for the pipeline. */
31
+ claimNext(input: {
32
+ topic: string;
33
+ targetId: string;
34
+ reserveSize: number;
35
+ date: string;
36
+ }): CandidateInventoryRow | null;
37
+ markSubmitted(pixivId: string, workType: string, topic: string, targetId: string): void;
38
+ markFiltered(pixivId: string, workType: string, topic: string, targetId: string): void;
39
+ markSelectedBackToPending(pixivId: string, workType: string, topic: string, targetId: string): void;
40
+ countPending(topic: string, targetId: string): number;
41
+ pendingSummary(topic: string, targetId: string): {
42
+ count: number;
43
+ oldestSeenDate: string | null;
44
+ };
45
+ /** Sweep rows past maxAgeDays; idempotent per scheduled scan. */
46
+ evictExpired(topic: string, targetId: string): number;
47
+ private toRow;
48
+ private todayUtc;
49
+ private addDaysUtc;
50
+ }
51
+ //# sourceMappingURL=CandidateInventoryRepository.d.ts.map
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CandidateInventoryRepository = void 0;
4
+ const BaseRepository_1 = require("./BaseRepository");
5
+ /** Phase 5 durable 待发池 — same SQLite database as the Slot Ledger. */
6
+ class CandidateInventoryRepository extends BaseRepository_1.BaseRepository {
7
+ upsert(input) {
8
+ const expiresAt = this.addDaysUtc(input.date, input.maxAgeDays);
9
+ this.db
10
+ .prepare(`INSERT INTO candidate_inventory
11
+ (pixiv_id, work_type, topic, target_id, status, snapshot_json,
12
+ first_seen_date, last_seen_date, seen_count, attempt_count, expires_at)
13
+ VALUES
14
+ (@pixivId, @workType, @topic, @targetId, 'pending', @snapshot,
15
+ @date, @date, 1, 0, @expiresAt)
16
+ ON CONFLICT(pixiv_id, work_type, topic, target_id) DO UPDATE SET
17
+ snapshot_json = excluded.snapshot_json,
18
+ last_seen_date = excluded.last_seen_date,
19
+ seen_count = candidate_inventory.seen_count + 1,
20
+ status = CASE
21
+ WHEN candidate_inventory.status IN ('selected','submitted','filtered','expired')
22
+ THEN candidate_inventory.status
23
+ ELSE 'pending'
24
+ END,
25
+ expires_at = excluded.expires_at,
26
+ updated_at = CURRENT_TIMESTAMP`)
27
+ .run({
28
+ pixivId: input.pixivId,
29
+ workType: input.workType,
30
+ topic: input.topic,
31
+ targetId: input.targetId,
32
+ snapshot: JSON.stringify(input.snapshot),
33
+ date: input.date,
34
+ expiresAt,
35
+ });
36
+ }
37
+ /** Marks a claimed candidate and returns its snapshot for the pipeline. */
38
+ claimNext(input) {
39
+ const rows = this.db
40
+ .prepare(`SELECT * FROM candidate_inventory
41
+ WHERE topic = ? AND target_id = ?
42
+ AND status = 'pending'
43
+ AND expires_at >= ?
44
+ ORDER BY first_seen_date ASC, seen_count ASC
45
+ LIMIT ?`)
46
+ .all(input.topic, input.targetId, this.addDaysUtc(input.date, 0), input.reserveSize);
47
+ for (const row of rows) {
48
+ const updated = this.db
49
+ .prepare(`UPDATE candidate_inventory
50
+ SET status = 'selected', attempt_count = attempt_count + 1, updated_at = CURRENT_TIMESTAMP
51
+ WHERE pixiv_id = ? AND work_type = ? AND topic = ? AND target_id = ? AND status = 'pending'`)
52
+ .run(row.pixiv_id, row.work_type, row.topic, row.target_id);
53
+ if (updated.changes > 0)
54
+ return this.toRow(row);
55
+ }
56
+ return null;
57
+ }
58
+ markSubmitted(pixivId, workType, topic, targetId) {
59
+ this.db
60
+ .prepare(`UPDATE candidate_inventory
61
+ SET status = 'submitted', updated_at = CURRENT_TIMESTAMP
62
+ WHERE pixiv_id = ? AND work_type = ? AND topic = ? AND target_id = ?`)
63
+ .run(pixivId, workType, topic, targetId);
64
+ }
65
+ markFiltered(pixivId, workType, topic, targetId) {
66
+ this.db
67
+ .prepare(`UPDATE candidate_inventory
68
+ SET status = 'filtered', updated_at = CURRENT_TIMESTAMP
69
+ WHERE pixiv_id = ? AND work_type = ? AND topic = ? AND target_id = ?`)
70
+ .run(pixivId, workType, topic, targetId);
71
+ }
72
+ markSelectedBackToPending(pixivId, workType, topic, targetId) {
73
+ this.db
74
+ .prepare(`UPDATE candidate_inventory
75
+ SET status = 'pending', updated_at = CURRENT_TIMESTAMP
76
+ WHERE pixiv_id = ? AND work_type = ? AND topic = ? AND target_id = ? AND status = 'selected'`)
77
+ .run(pixivId, workType, topic, targetId);
78
+ }
79
+ countPending(topic, targetId) {
80
+ const rows = this.db
81
+ .prepare(`SELECT COUNT(*) AS n FROM candidate_inventory WHERE topic = ? AND target_id = ? AND status = 'pending' AND expires_at >= ?`)
82
+ .get(topic, targetId, this.todayUtc());
83
+ return Number(rows?.n ?? 0);
84
+ }
85
+ pendingSummary(topic, targetId) {
86
+ const row = this.db
87
+ .prepare(`SELECT COUNT(*) AS n, MIN(first_seen_date) AS oldest
88
+ FROM candidate_inventory
89
+ WHERE topic = ? AND target_id = ? AND status = 'pending' AND expires_at >= ?`)
90
+ .get(topic, targetId, this.todayUtc());
91
+ return { count: Number(row?.n ?? 0), oldestSeenDate: row?.oldest ?? null };
92
+ }
93
+ /** Sweep rows past maxAgeDays; idempotent per scheduled scan. */
94
+ evictExpired(topic, targetId) {
95
+ const info = this.db
96
+ .prepare(`UPDATE candidate_inventory
97
+ SET status = 'expired', updated_at = CURRENT_TIMESTAMP
98
+ WHERE topic = ? AND target_id = ? AND status IN ('pending','selected') AND expires_at < ?`)
99
+ .run(topic, targetId, this.todayUtc());
100
+ return info.changes;
101
+ }
102
+ toRow(row) {
103
+ return {
104
+ pixivId: String(row.pixiv_id),
105
+ workType: row.work_type,
106
+ topic: row.topic,
107
+ targetId: row.target_id,
108
+ status: row.status,
109
+ snapshotJson: row.snapshot_json,
110
+ firstSeenDate: row.first_seen_date,
111
+ lastSeenDate: row.last_seen_date,
112
+ seenCount: Number(row.seen_count ?? 1),
113
+ attemptCount: Number(row.attempt_count ?? 0),
114
+ expiresAt: row.expires_at,
115
+ createdAt: row.created_at,
116
+ updatedAt: row.updated_at,
117
+ };
118
+ }
119
+ todayUtc() {
120
+ return new Date().toISOString().slice(0, 10);
121
+ }
122
+ addDaysUtc(date, days) {
123
+ const d = new Date(`${date}T00:00:00.000Z`);
124
+ d.setUTCDate(d.getUTCDate() + days);
125
+ return d.toISOString().slice(0, 10);
126
+ }
127
+ }
128
+ exports.CandidateInventoryRepository = CandidateInventoryRepository;
129
+ //# sourceMappingURL=CandidateInventoryRepository.js.map
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BUILD = void 0;
4
4
  // GENERATED by scripts/write-version.js — do not edit manually.
5
- exports.BUILD = { version: '2.29.0', commit: '13e234a69cd2' };
5
+ exports.BUILD = { version: '2.31.0', commit: '4642dce0724a' };
6
6
  //# sourceMappingURL=version.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "commonjs",
3
3
  "name": "pixivflow-webui-backend",
4
- "version": "2.29.0",
4
+ "version": "2.31.0",
5
5
  "description": "PixivFlow WebUI Backend - CommonJS module"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixivflow",
3
- "version": "2.29.0",
3
+ "version": "2.31.0",
4
4
  "description": "🎨 Pixiv 下载、筛选与自动收集工具 - 批量下载插画和小说、按标签/热度/日期筛选、定时任务与可靠 HTTP 交付 | Pixiv downloader and automation toolkit with filtering, scheduling and reliable HTTP delivery",
5
5
  "repository": {
6
6
  "type": "git",
@@ -135,6 +135,7 @@
135
135
  },
136
136
  "files": [
137
137
  "dist/",
138
+ "webui-frontend/dist/",
138
139
  "!dist/**/*.map",
139
140
  "config/examples/",
140
141
  "config/fly-two-bots.example.json",
@@ -0,0 +1,2 @@
1
+ import{r as e,I as a,_ as r}from"./index-DG6kGbYq.js";var l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M699 353h-46.9c-10.2 0-19.9 4.9-25.9 13.3L469 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H325c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8a31.8 31.8 0 0051.7 0l210.6-292c3.9-5.3.1-12.7-6.4-12.7z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"check-circle",theme:"outlined"},n=function(t,c){return e.createElement(a,r({},t,{ref:c,icon:l}))},o=e.forwardRef(n);export{o as R};
2
+ //# sourceMappingURL=CheckCircleOutlined-H3DnUyMO.js.map
@@ -0,0 +1,2 @@
1
+ import{r as e,I as r,_ as c}from"./index-DG6kGbYq.js";var l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M899.1 869.6l-53-305.6H864c14.4 0 26-11.6 26-26V346c0-14.4-11.6-26-26-26H618V138c0-14.4-11.6-26-26-26H432c-14.4 0-26 11.6-26 26v182H160c-14.4 0-26 11.6-26 26v192c0 14.4 11.6 26 26 26h17.9l-53 305.6a25.95 25.95 0 0025.6 30.4h723c1.5 0 3-.1 4.4-.4a25.88 25.88 0 0021.2-30zM204 390h272V182h72v208h272v104H204V390zm468 440V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H416V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H202.8l45.1-260H776l45.1 260H672z"}}]},name:"clear",theme:"outlined"},n=function(a,t){return e.createElement(r,c({},a,{ref:t,icon:l}))},h=e.forwardRef(n);export{h as R};
2
+ //# sourceMappingURL=ClearOutlined-BpODq7I7.js.map
@@ -0,0 +1,2 @@
1
+ import{r as e,I as l,_ as r}from"./index-DG6kGbYq.js";var t={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm0 76c-205.4 0-372 166.6-372 372s166.6 372 372 372 372-166.6 372-372-166.6-372-372-372zm128.01 198.83c.03 0 .05.01.09.06l45.02 45.01a.2.2 0 01.05.09.12.12 0 010 .07c0 .02-.01.04-.05.08L557.25 512l127.87 127.86a.27.27 0 01.05.06v.02a.12.12 0 010 .07c0 .03-.01.05-.05.09l-45.02 45.02a.2.2 0 01-.09.05.12.12 0 01-.07 0c-.02 0-.04-.01-.08-.05L512 557.25 384.14 685.12c-.04.04-.06.05-.08.05a.12.12 0 01-.07 0c-.03 0-.05-.01-.09-.05l-45.02-45.02a.2.2 0 01-.05-.09.12.12 0 010-.07c0-.02.01-.04.06-.08L466.75 512 338.88 384.14a.27.27 0 01-.05-.06l-.01-.02a.12.12 0 010-.07c0-.03.01-.05.05-.09l45.02-45.02a.2.2 0 01.09-.05.12.12 0 01.07 0c.02 0 .04.01.08.06L512 466.75l127.86-127.86c.04-.05.06-.06.08-.06a.12.12 0 01.07 0z"}}]},name:"close-circle",theme:"outlined"},o=function(a,c){return e.createElement(l,r({},a,{ref:c,icon:t}))},i=e.forwardRef(o);export{i as R};
2
+ //# sourceMappingURL=CloseCircleOutlined-BFfS5iXd.js.map
@@ -0,0 +1,16 @@
1
+ import{r as o,I as rn,_ as de,f as Rn,g as An,h as G,w as st,i as Se,k as lt,l as ct,m as Me,n as ie,o as _n,p as dt,q as Xe,t as ut,F as ft,v as gt,x as ht,y as mt,z as Ye,A as X,C as pt,D as xt,E as yt,G as vt,H as jt,J as bt,K as wt,L as St,M as Sn,N as Cn,O as Ct,P as It,T as kt,b as H,U as Be,Q as ue,V as In,s as V,j as e,W as T,X as U,a as _e,B as R,c as on,e as On,d as Et,Y as W,Z as Ce,$ as Nt,S as Dt,a0 as Tt,a1 as $t}from"./index-DG6kGbYq.js";import{u as Ft,a as Ve,c as Ze,C as Pe,R as Mn,b as Rt}from"./useConfig-Ds7RpIL1.js";import{t as ye,e as ze}from"./errorCodeTranslator-BqIackMm.js";import{u as ke,F as sn}from"./useErrorHandler-BOvHue1w.js";import{F as w,u as At,R as q}from"./useAuth-wCjAOx6S.js";import{B as _t,t as Ot,i as Mt,a as zt,g as zn,b as Bt,c as Vt,d as Pt,e as Lt,f as Ht,h as Wt,j as Gt,k as qt,T as oe,R as ln,l as Bn}from"./index-_EG4kaKN.js";import{T as Ie}from"./index-CJln3zA7.js";import{R as Ut}from"./CheckCircleOutlined-H3DnUyMO.js";import{a as Ee,T as Kt}from"./row-_c51T55h.js";import{D as Jt}from"./index-B2ns27ii.js";import{S as Vn}from"./index-B7yYDv10.js";import{I as Q}from"./index-DPigBPWX.js";import{M as cn}from"./index-CDrp3NIf.js";import{S as Pn,R as Ln}from"./ThunderboltOutlined-ulcCd7ui.js";import{P as dn}from"./index-CfHs6AUn.js";import{R as un}from"./DeleteOutlined-BFmW1oWe.js";var Qt={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"}}]},name:"up",theme:"outlined"},Xt=function(t,a){return o.createElement(rn,de({},t,{ref:a,icon:Qt}))},Yt=o.forwardRef(Xt);function an(){return typeof BigInt=="function"}function Hn(n){return!n&&n!==0&&!Number.isNaN(n)||!String(n).trim()}function ce(n){var t=n.trim(),a=t.startsWith("-");a&&(t=t.slice(1)),t=t.replace(/(\.\d*[^0])0*$/,"$1").replace(/\.0*$/,"").replace(/^0+/,""),t.startsWith(".")&&(t="0".concat(t));var r=t||"0",i=r.split("."),s=i[0]||"0",c=i[1]||"0";s==="0"&&c==="0"&&(a=!1);var l=a?"-":"";return{negative:a,negativeStr:l,trimStr:r,integerStr:s,decimalStr:c,fullStr:"".concat(l).concat(r)}}function fn(n){var t=String(n);return!Number.isNaN(Number(t))&&t.includes("e")}function le(n){var t=String(n);if(fn(n)){var a=Number(t.slice(t.indexOf("e-")+2)),r=t.match(/\.(\d+)/);return r!=null&&r[1]&&(a+=r[1].length),a}return t.includes(".")&&gn(t)?t.length-t.indexOf(".")-1:0}function Le(n){var t=String(n);if(fn(n)){if(n>Number.MAX_SAFE_INTEGER)return String(an()?BigInt(n).toString():Number.MAX_SAFE_INTEGER);if(n<Number.MIN_SAFE_INTEGER)return String(an()?BigInt(n).toString():Number.MIN_SAFE_INTEGER);t=n.toFixed(le(t))}return ce(t).fullStr}function gn(n){return typeof n=="number"?!Number.isNaN(n):n?/^\s*-?\d+(\.\d+)?\s*$/.test(n)||/^\s*-?\d+\.\s*$/.test(n)||/^\s*-?\.\d+\s*$/.test(n):!1}var Zt=(function(){function n(t){if(An(this,n),G(this,"origin",""),G(this,"negative",void 0),G(this,"integer",void 0),G(this,"decimal",void 0),G(this,"decimalLen",void 0),G(this,"empty",void 0),G(this,"nan",void 0),Hn(t)){this.empty=!0;return}if(this.origin=String(t),t==="-"||Number.isNaN(t)){this.nan=!0;return}var a=t;if(fn(a)&&(a=Number(a)),a=typeof a=="string"?a:Le(a),gn(a)){var r=ce(a);this.negative=r.negative;var i=r.trimStr.split(".");this.integer=BigInt(i[0]);var s=i[1]||"0";this.decimal=BigInt(s),this.decimalLen=s.length}else this.nan=!0}return Rn(n,[{key:"getMark",value:function(){return this.negative?"-":""}},{key:"getIntegerStr",value:function(){return this.integer.toString()}},{key:"getDecimalStr",value:function(){return this.decimal.toString().padStart(this.decimalLen,"0")}},{key:"alignDecimal",value:function(a){var r="".concat(this.getMark()).concat(this.getIntegerStr()).concat(this.getDecimalStr().padEnd(a,"0"));return BigInt(r)}},{key:"negate",value:function(){var a=new n(this.toString());return a.negative=!a.negative,a}},{key:"cal",value:function(a,r,i){var s=Math.max(this.getDecimalStr().length,a.getDecimalStr().length),c=this.alignDecimal(s),l=a.alignDecimal(s),u=r(c,l).toString(),m=i(s),d=ce(u),g=d.negativeStr,f=d.trimStr,v="".concat(g).concat(f.padStart(m+1,"0"));return new n("".concat(v.slice(0,-m),".").concat(v.slice(-m)))}},{key:"add",value:function(a){if(this.isInvalidate())return new n(a);var r=new n(a);return r.isInvalidate()?this:this.cal(r,function(i,s){return i+s},function(i){return i})}},{key:"multi",value:function(a){var r=new n(a);return this.isInvalidate()||r.isInvalidate()?new n(NaN):this.cal(r,function(i,s){return i*s},function(i){return i*2})}},{key:"isEmpty",value:function(){return this.empty}},{key:"isNaN",value:function(){return this.nan}},{key:"isInvalidate",value:function(){return this.isEmpty()||this.isNaN()}},{key:"equals",value:function(a){return this.toString()===a?.toString()}},{key:"lessEquals",value:function(a){return this.add(a.negate().toString()).toNumber()<=0}},{key:"toNumber",value:function(){return this.isNaN()?NaN:Number(this.toString())}},{key:"toString",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return a?this.isInvalidate()?"":ce("".concat(this.getMark()).concat(this.getIntegerStr(),".").concat(this.getDecimalStr())).fullStr:this.origin}}]),n})(),ei=(function(){function n(t){if(An(this,n),G(this,"origin",""),G(this,"number",void 0),G(this,"empty",void 0),Hn(t)){this.empty=!0;return}this.origin=String(t),this.number=Number(t)}return Rn(n,[{key:"negate",value:function(){return new n(-this.toNumber())}},{key:"add",value:function(a){if(this.isInvalidate())return new n(a);var r=Number(a);if(Number.isNaN(r))return this;var i=this.number+r;if(i>Number.MAX_SAFE_INTEGER)return new n(Number.MAX_SAFE_INTEGER);if(i<Number.MIN_SAFE_INTEGER)return new n(Number.MIN_SAFE_INTEGER);var s=Math.max(le(this.number),le(r));return new n(i.toFixed(s))}},{key:"multi",value:function(a){var r=Number(a);if(this.isInvalidate()||Number.isNaN(r))return new n(NaN);var i=this.number*r;if(i>Number.MAX_SAFE_INTEGER)return new n(Number.MAX_SAFE_INTEGER);if(i<Number.MIN_SAFE_INTEGER)return new n(Number.MIN_SAFE_INTEGER);var s=Math.max(le(this.number),le(r));return new n(i.toFixed(s))}},{key:"isEmpty",value:function(){return this.empty}},{key:"isNaN",value:function(){return Number.isNaN(this.number)}},{key:"isInvalidate",value:function(){return this.isEmpty()||this.isNaN()}},{key:"equals",value:function(a){return this.toNumber()===a?.toNumber()}},{key:"lessEquals",value:function(a){return this.add(a.negate().toString()).toNumber()<=0}},{key:"toNumber",value:function(){return this.number}},{key:"toString",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return a?this.isInvalidate()?"":Le(this.number):this.origin}}]),n})();function ee(n){return an()?new Zt(n):new ei(n)}function Oe(n,t,a){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(n==="")return"";var i=ce(n),s=i.negativeStr,c=i.integerStr,l=i.decimalStr,u="".concat(t).concat(l),m="".concat(s).concat(c);if(a>=0){var d=Number(l[a]);if(d>=5&&!r){var g=ee(n).add("".concat(s,"0.").concat("0".repeat(a)).concat(10-d));return Oe(g.toString(),t,a,r)}return a===0?m:"".concat(m).concat(t).concat(l.padEnd(a,"0").slice(0,a))}return u===".0"?m:"".concat(m).concat(u)}function ni(n,t){return typeof Proxy<"u"&&n?new Proxy(n,{get:function(r,i){if(t[i])return t[i];var s=r[i];return typeof s=="function"?s.bind(r):s}}):n}function ti(n,t){var a=o.useRef(null);function r(){try{var s=n.selectionStart,c=n.selectionEnd,l=n.value,u=l.substring(0,s),m=l.substring(c);a.current={start:s,end:c,value:l,beforeTxt:u,afterTxt:m}}catch{}}function i(){if(n&&a.current&&t)try{var s=n.value,c=a.current,l=c.beforeTxt,u=c.afterTxt,m=c.start,d=s.length;if(s.startsWith(l))d=l.length;else if(s.endsWith(u))d=s.length-a.current.afterTxt.length;else{var g=l[m-1],f=s.indexOf(g,m-1);f!==-1&&(d=f+1)}n.setSelectionRange(d,d)}catch(v){st(!1,"Something warning of cursor restore. Please fire issue about this: ".concat(v.message))}}return[r,i]}var ii=function(){var t=o.useState(!1),a=Se(t,2),r=a[0],i=a[1];return lt(function(){i(ct())},[]),r},ai=200,ri=600;function oi(n){var t=n.prefixCls,a=n.upNode,r=n.downNode,i=n.upDisabled,s=n.downDisabled,c=n.onStep,l=o.useRef(),u=o.useRef([]),m=o.useRef();m.current=c;var d=function(){clearTimeout(l.current)},g=function(E,p){E.preventDefault(),d(),m.current(p);function _(){m.current(p),l.current=setTimeout(_,ai)}l.current=setTimeout(_,ri)};o.useEffect(function(){return function(){d(),u.current.forEach(function(y){return Me.cancel(y)})}},[]);var f=ii();if(f)return null;var v="".concat(t,"-handler"),j=ie(v,"".concat(v,"-up"),G({},"".concat(v,"-up-disabled"),i)),x=ie(v,"".concat(v,"-down"),G({},"".concat(v,"-down-disabled"),s)),S=function(){return u.current.push(Me(d))},h={unselectable:"on",role:"button",onMouseUp:S,onMouseLeave:S};return o.createElement("div",{className:"".concat(v,"-wrap")},o.createElement("span",de({},h,{onMouseDown:function(E){g(E,!0)},"aria-label":"Increase Value","aria-disabled":i,className:j}),a||o.createElement("span",{unselectable:"on",className:"".concat(t,"-handler-up-inner")})),o.createElement("span",de({},h,{onMouseDown:function(E){g(E,!1)},"aria-label":"Decrease Value","aria-disabled":s,className:x}),r||o.createElement("span",{unselectable:"on",className:"".concat(t,"-handler-down-inner")})))}function kn(n){var t=typeof n=="number"?Le(n):ce(n).fullStr,a=t.includes(".");return a?ce(t.replace(/(\d)\.(\d)/g,"$1$2.")).fullStr:n+"0"}const si=(function(){var n=o.useRef(0),t=function(){Me.cancel(n.current)};return o.useEffect(function(){return t},[]),function(a){t(),n.current=Me(function(){a()})}});var li=["prefixCls","className","style","min","max","step","defaultValue","value","disabled","readOnly","upHandler","downHandler","keyboard","changeOnWheel","controls","classNames","stringMode","parser","formatter","precision","decimalSeparator","onChange","onInput","onPressEnter","onStep","changeOnBlur","domRef"],ci=["disabled","style","prefixCls","value","prefix","suffix","addonBefore","addonAfter","className","classNames"],En=function(t,a){return t||a.isEmpty()?a.toString():a.toNumber()},Nn=function(t){var a=ee(t);return a.isInvalidate()?null:a},di=o.forwardRef(function(n,t){var a=n.prefixCls,r=n.className,i=n.style,s=n.min,c=n.max,l=n.step,u=l===void 0?1:l,m=n.defaultValue,d=n.value,g=n.disabled,f=n.readOnly,v=n.upHandler,j=n.downHandler,x=n.keyboard,S=n.changeOnWheel,h=S===void 0?!1:S,y=n.controls,E=y===void 0?!0:y;n.classNames;var p=n.stringMode,_=n.parser,O=n.formatter,$=n.precision,P=n.decimalSeparator,C=n.onChange,k=n.onInput,D=n.onPressEnter,A=n.onStep,B=n.changeOnBlur,J=B===void 0?!0:B,te=n.domRef,He=_n(n,li),De="".concat(a,"-input"),ae=o.useRef(null),re=o.useState(!1),Te=Se(re,2),fe=Te[0],ve=Te[1],Y=o.useRef(!1),se=o.useRef(!1),ge=o.useRef(!1),We=o.useState(function(){return ee(d??m)}),$e=Se(We,2),M=$e[0],he=$e[1];function Kn(I){d===void 0&&he(I)}var Ge=o.useCallback(function(I,b){if(!b)return $>=0?$:Math.max(le(I),le(u))},[$,u]),qe=o.useCallback(function(I){var b=String(I);if(_)return _(b);var F=b;return P&&(F=F.replace(P,".")),F.replace(/[^\w.-]+/g,"")},[_,P]),Ue=o.useRef(""),hn=o.useCallback(function(I,b){if(O)return O(I,{userTyping:b,input:String(Ue.current)});var F=typeof I=="number"?Le(I):I;if(!b){var N=Ge(F,b);if(gn(F)&&(P||N>=0)){var ne=P||".";F=Oe(F,ne,N)}}return F},[O,Ge,P]),Jn=o.useState(function(){var I=m??d;return M.isInvalidate()&&["string","number"].includes(dt(I))?Number.isNaN(I)?"":I:hn(M.toString(),!1)}),mn=Se(Jn,2),je=mn[0],pn=mn[1];Ue.current=je;function be(I,b){pn(hn(I.isInvalidate()?I.toString(!1):I.toString(!b),b))}var me=o.useMemo(function(){return Nn(c)},[c,$]),pe=o.useMemo(function(){return Nn(s)},[s,$]),xn=o.useMemo(function(){return!me||!M||M.isInvalidate()?!1:me.lessEquals(M)},[me,M]),yn=o.useMemo(function(){return!pe||!M||M.isInvalidate()?!1:M.lessEquals(pe)},[pe,M]),Qn=ti(ae.current,fe),vn=Se(Qn,2),Xn=vn[0],Yn=vn[1],jn=function(b){return me&&!b.lessEquals(me)?me:pe&&!pe.lessEquals(b)?pe:null},Ke=function(b){return!jn(b)},Fe=function(b,F){var N=b,ne=Ke(N)||N.isEmpty();if(!N.isEmpty()&&!F&&(N=jn(N)||N,ne=!0),!f&&!g&&ne){var we=N.toString(),Qe=Ge(we,F);return Qe>=0&&(N=ee(Oe(we,".",Qe)),Ke(N)||(N=ee(Oe(we,".",Qe,!0)))),N.equals(M)||(Kn(N),C?.(N.isEmpty()?null:En(p,N)),d===void 0&&be(N,F)),N}return M},Zn=si(),bn=function I(b){if(Xn(),Ue.current=b,pn(b),!se.current){var F=qe(b),N=ee(F);N.isNaN()||Fe(N,!0)}k?.(b),Zn(function(){var ne=b;_||(ne=b.replace(/。/g,".")),ne!==b&&I(ne)})},et=function(){se.current=!0},nt=function(){se.current=!1,bn(ae.current.value)},tt=function(b){bn(b.target.value)},Je=function(b){var F;if(!(b&&xn||!b&&yn)){Y.current=!1;var N=ee(ge.current?kn(u):u);b||(N=N.negate());var ne=(M||ee(0)).add(N.toString()),we=Fe(ne,!1);A?.(En(p,we),{offset:ge.current?kn(u):u,type:b?"up":"down"}),(F=ae.current)===null||F===void 0||F.focus()}},wn=function(b){var F=ee(qe(je)),N;F.isNaN()?N=Fe(M,b):N=Fe(F,b),d!==void 0?be(M,!1):N.isNaN()||be(N,!1)},it=function(){Y.current=!0},at=function(b){var F=b.key,N=b["shiftKey"];Y.current=!0,ge.current=N,F==="Enter"&&(se.current||(Y.current=!1),wn(!1),D?.(b)),x!==!1&&!se.current&&["Up","ArrowUp","Down","ArrowDown"].includes(F)&&(Je(F==="Up"||F==="ArrowUp"),b.preventDefault())},rt=function(){Y.current=!1,ge.current=!1};o.useEffect(function(){if(h&&fe){var I=function(N){Je(N.deltaY<0),N.preventDefault()},b=ae.current;if(b)return b.addEventListener("wheel",I,{passive:!1}),function(){return b.removeEventListener("wheel",I)}}});var ot=function(){J&&wn(!1),ve(!1),Y.current=!1};return Xe(function(){M.isInvalidate()||be(M,!1)},[$,O]),Xe(function(){var I=ee(d);he(I);var b=ee(qe(je));(!I.equals(b)||!Y.current||O)&&be(I,Y.current)},[d]),Xe(function(){O&&Yn()},[je]),o.createElement("div",{ref:te,className:ie(a,r,G(G(G(G(G({},"".concat(a,"-focused"),fe),"".concat(a,"-disabled"),g),"".concat(a,"-readonly"),f),"".concat(a,"-not-a-number"),M.isNaN()),"".concat(a,"-out-of-range"),!M.isInvalidate()&&!Ke(M))),style:i,onFocus:function(){ve(!0)},onBlur:ot,onKeyDown:at,onKeyUp:rt,onCompositionStart:et,onCompositionEnd:nt,onBeforeInput:it},E&&o.createElement(oi,{prefixCls:a,upNode:v,downNode:j,upDisabled:xn,downDisabled:yn,onStep:Je}),o.createElement("div",{className:"".concat(De,"-wrap")},o.createElement("input",de({autoComplete:"off",role:"spinbutton","aria-valuemin":s,"aria-valuemax":c,"aria-valuenow":M.isInvalidate()?null:M.toString(),step:u},He,{ref:ut(ae,t),className:De,value:je,onChange:tt,disabled:g,readOnly:f}))))}),ui=o.forwardRef(function(n,t){var a=n.disabled,r=n.style,i=n.prefixCls,s=i===void 0?"rc-input-number":i,c=n.value,l=n.prefix,u=n.suffix,m=n.addonBefore,d=n.addonAfter,g=n.className,f=n.classNames,v=_n(n,ci),j=o.useRef(null),x=o.useRef(null),S=o.useRef(null),h=function(E){S.current&&Ot(S.current,E)};return o.useImperativeHandle(t,function(){return ni(S.current,{focus:h,nativeElement:j.current.nativeElement||x.current})}),o.createElement(_t,{className:g,triggerFocus:h,prefixCls:s,value:c,disabled:a,style:r,prefix:l,suffix:u,addonAfter:d,addonBefore:m,classNames:f,components:{affixWrapper:"div",groupWrapper:"div",wrapper:"div",groupAddon:"div"},ref:j},o.createElement(di,de({prefixCls:s,disabled:a,ref:S,domRef:x,className:f?.input},v)))});const fi=n=>{var t;const a=(t=n.handleVisible)!==null&&t!==void 0?t:"auto",r=n.controlHeightSM-n.lineWidth*2;return Object.assign(Object.assign({},Mt(n)),{controlWidth:90,handleWidth:r,handleFontSize:n.fontSize/2,handleVisible:a,handleActiveBg:n.colorFillAlter,handleBg:n.colorBgContainer,filledHandleBg:new ft(n.colorFillSecondary).onBackground(n.colorBgContainer).toHexString(),handleHoverColor:n.colorPrimary,handleBorderColor:n.colorBorder,handleOpacity:a===!0?1:0,handleVisibleWidth:a===!0?r:0})},Dn=({componentCls:n,borderRadiusSM:t,borderRadiusLG:a},r)=>{const i=r==="lg"?a:t;return{[`&-${r}`]:{[`${n}-handler-wrap`]:{borderStartEndRadius:i,borderEndEndRadius:i},[`${n}-handler-up`]:{borderStartEndRadius:i},[`${n}-handler-down`]:{borderEndEndRadius:i}}}},gi=n=>{const{componentCls:t,lineWidth:a,lineType:r,borderRadius:i,inputFontSizeSM:s,inputFontSizeLG:c,controlHeightLG:l,controlHeightSM:u,colorError:m,paddingInlineSM:d,paddingBlockSM:g,paddingBlockLG:f,paddingInlineLG:v,colorIcon:j,motionDurationMid:x,handleHoverColor:S,handleOpacity:h,paddingInline:y,paddingBlock:E,handleBg:p,handleActiveBg:_,colorTextDisabled:O,borderRadiusSM:$,borderRadiusLG:P,controlWidth:C,handleBorderColor:k,filledHandleBg:D,lineHeightLG:A,calc:B}=n;return[{[t]:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Ye(n)),zn(n)),{display:"inline-block",width:C,margin:0,padding:0,borderRadius:i}),Bt(n,{[`${t}-handler-wrap`]:{background:p,[`${t}-handler-down`]:{borderBlockStart:`${X(a)} ${r} ${k}`}}})),Vt(n,{[`${t}-handler-wrap`]:{background:D,[`${t}-handler-down`]:{borderBlockStart:`${X(a)} ${r} ${k}`}},"&:focus-within":{[`${t}-handler-wrap`]:{background:p}}})),Pt(n,{[`${t}-handler-wrap`]:{background:p,[`${t}-handler-down`]:{borderBlockStart:`${X(a)} ${r} ${k}`}}})),Lt(n)),{"&-rtl":{direction:"rtl",[`${t}-input`]:{direction:"rtl"}},"&-lg":{padding:0,fontSize:c,lineHeight:A,borderRadius:P,[`input${t}-input`]:{height:B(l).sub(B(a).mul(2)).equal(),padding:`${X(f)} ${X(v)}`}},"&-sm":{padding:0,fontSize:s,borderRadius:$,[`input${t}-input`]:{height:B(u).sub(B(a).mul(2)).equal(),padding:`${X(g)} ${X(d)}`}},"&-out-of-range":{[`${t}-input-wrap`]:{input:{color:m}}},"&-group":Object.assign(Object.assign(Object.assign({},Ye(n)),Wt(n)),{"&-wrapper":Object.assign(Object.assign(Object.assign({display:"inline-block",textAlign:"start",verticalAlign:"top",[`${t}-affix-wrapper`]:{width:"100%"},"&-lg":{[`${t}-group-addon`]:{borderRadius:P,fontSize:n.fontSizeLG}},"&-sm":{[`${t}-group-addon`]:{borderRadius:$}}},Gt(n)),qt(n)),{[`&:not(${t}-compact-first-item):not(${t}-compact-last-item)${t}-compact-item`]:{[`${t}, ${t}-group-addon`]:{borderRadius:0}},[`&:not(${t}-compact-last-item)${t}-compact-first-item`]:{[`${t}, ${t}-group-addon`]:{borderStartEndRadius:0,borderEndEndRadius:0}},[`&:not(${t}-compact-first-item)${t}-compact-last-item`]:{[`${t}, ${t}-group-addon`]:{borderStartStartRadius:0,borderEndStartRadius:0}}})}),[`&-disabled ${t}-input`]:{cursor:"not-allowed"},[t]:{"&-input":Object.assign(Object.assign(Object.assign(Object.assign({},Ye(n)),{width:"100%",padding:`${X(E)} ${X(y)}`,textAlign:"start",backgroundColor:"transparent",border:0,borderRadius:i,outline:0,transition:`all ${x} linear`,appearance:"textfield",fontSize:"inherit"}),Ht(n.colorTextPlaceholder)),{'&[type="number"]::-webkit-inner-spin-button, &[type="number"]::-webkit-outer-spin-button':{margin:0,appearance:"none"}})},[`&:hover ${t}-handler-wrap, &-focused ${t}-handler-wrap`]:{width:n.handleWidth,opacity:1}})},{[t]:Object.assign(Object.assign(Object.assign({[`${t}-handler-wrap`]:{position:"absolute",insetBlockStart:0,insetInlineEnd:0,width:n.handleVisibleWidth,opacity:h,height:"100%",borderStartStartRadius:0,borderStartEndRadius:i,borderEndEndRadius:i,borderEndStartRadius:0,display:"flex",flexDirection:"column",alignItems:"stretch",transition:`all ${x}`,overflow:"hidden",[`${t}-handler`]:{display:"flex",alignItems:"center",justifyContent:"center",flex:"auto",height:"40%",[`
2
+ ${t}-handler-up-inner,
3
+ ${t}-handler-down-inner
4
+ `]:{marginInlineEnd:0,fontSize:n.handleFontSize}}},[`${t}-handler`]:{height:"50%",overflow:"hidden",color:j,fontWeight:"bold",lineHeight:0,textAlign:"center",cursor:"pointer",borderInlineStart:`${X(a)} ${r} ${k}`,transition:`all ${x} linear`,"&:active":{background:_},"&:hover":{height:"60%",[`
5
+ ${t}-handler-up-inner,
6
+ ${t}-handler-down-inner
7
+ `]:{color:S}},"&-up-inner, &-down-inner":Object.assign(Object.assign({},pt()),{color:j,transition:`all ${x} linear`,userSelect:"none"})},[`${t}-handler-up`]:{borderStartEndRadius:i},[`${t}-handler-down`]:{borderEndEndRadius:i}},Dn(n,"lg")),Dn(n,"sm")),{"&-disabled, &-readonly":{[`${t}-handler-wrap`]:{display:"none"},[`${t}-input`]:{color:"inherit"}},[`
8
+ ${t}-handler-up-disabled,
9
+ ${t}-handler-down-disabled
10
+ `]:{cursor:"not-allowed"},[`
11
+ ${t}-handler-up-disabled:hover &-handler-up-inner,
12
+ ${t}-handler-down-disabled:hover &-handler-down-inner
13
+ `]:{color:O}})}]},hi=n=>{const{componentCls:t,paddingBlock:a,paddingInline:r,inputAffixPadding:i,controlWidth:s,borderRadiusLG:c,borderRadiusSM:l,paddingInlineLG:u,paddingInlineSM:m,paddingBlockLG:d,paddingBlockSM:g,motionDurationMid:f}=n;return{[`${t}-affix-wrapper`]:Object.assign(Object.assign({[`input${t}-input`]:{padding:`${X(a)} 0`}},zn(n)),{position:"relative",display:"inline-flex",alignItems:"center",width:s,padding:0,paddingInlineStart:r,"&-lg":{borderRadius:c,paddingInlineStart:u,[`input${t}-input`]:{padding:`${X(d)} 0`}},"&-sm":{borderRadius:l,paddingInlineStart:m,[`input${t}-input`]:{padding:`${X(g)} 0`}},[`&:not(${t}-disabled):hover`]:{zIndex:1},"&-focused, &:focus":{zIndex:1},[`&-disabled > ${t}-disabled`]:{background:"transparent"},[`> div${t}`]:{width:"100%",border:"none",outline:"none",[`&${t}-focused`]:{boxShadow:"none !important"}},"&::before":{display:"inline-block",width:0,visibility:"hidden",content:'"\\a0"'},[`${t}-handler-wrap`]:{zIndex:2},[t]:{position:"static",color:"inherit","&-prefix, &-suffix":{display:"flex",flex:"none",alignItems:"center",pointerEvents:"none"},"&-prefix":{marginInlineEnd:i},"&-suffix":{insetBlockStart:0,insetInlineEnd:0,height:"100%",marginInlineEnd:r,marginInlineStart:i,transition:`margin ${f}`}},[`&:hover ${t}-handler-wrap, &-focused ${t}-handler-wrap`]:{width:n.handleWidth,opacity:1},[`&:not(${t}-affix-wrapper-without-controls):hover ${t}-suffix`]:{marginInlineEnd:n.calc(n.handleWidth).add(r).equal()}}),[`${t}-underlined`]:{borderRadius:0}}},mi=gt("InputNumber",n=>{const t=ht(n,zt(n));return[gi(t),hi(t),mt(t)]},fi,{unitless:{handleOpacity:!0},resetFont:!1});var pi=function(n,t){var a={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(a[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(a[r[i]]=n[r[i]]);return a};const Wn=o.forwardRef((n,t)=>{const{getPrefixCls:a,direction:r}=o.useContext(xt),i=o.useRef(null);o.useImperativeHandle(t,()=>i.current);const{className:s,rootClassName:c,size:l,disabled:u,prefixCls:m,addonBefore:d,addonAfter:g,prefix:f,suffix:v,bordered:j,readOnly:x,status:S,controls:h,variant:y}=n,E=pi(n,["className","rootClassName","size","disabled","prefixCls","addonBefore","addonAfter","prefix","suffix","bordered","readOnly","status","controls","variant"]),p=a("input-number",m),_=yt(p),[O,$,P]=mi(p,_),{compactSize:C,compactItemClassnames:k}=vt(p,r);let D=o.createElement(Yt,{className:`${p}-handler-up-inner`}),A=o.createElement(Ct,{className:`${p}-handler-down-inner`});const B=typeof h=="boolean"?h:void 0;typeof h=="object"&&(D=typeof h.upIcon>"u"?D:o.createElement("span",{className:`${p}-handler-up-inner`},h.upIcon),A=typeof h.downIcon>"u"?A:o.createElement("span",{className:`${p}-handler-down-inner`},h.downIcon));const{hasFeedback:J,status:te,isFormItemInput:He,feedbackIcon:De}=o.useContext(jt),ae=It(te,S),re=bt(M=>{var he;return(he=l??C)!==null&&he!==void 0?he:M}),Te=o.useContext(wt),fe=u??Te,[ve,Y]=St("inputNumber",y,j),se=J&&o.createElement(o.Fragment,null,De),ge=ie({[`${p}-lg`]:re==="large",[`${p}-sm`]:re==="small",[`${p}-rtl`]:r==="rtl",[`${p}-in-form-item`]:He},$),We=`${p}-group`,$e=o.createElement(ui,Object.assign({ref:i,disabled:fe,className:ie(P,_,s,c,k),upHandler:D,downHandler:A,prefixCls:p,readOnly:x,controls:B,prefix:f,suffix:se||v,addonBefore:d&&o.createElement(Cn,{form:!0,space:!0},d),addonAfter:g&&o.createElement(Cn,{form:!0,space:!0},g),classNames:{input:ge,variant:ie({[`${p}-${ve}`]:Y},Sn(p,ae,J)),affixWrapper:ie({[`${p}-affix-wrapper-sm`]:re==="small",[`${p}-affix-wrapper-lg`]:re==="large",[`${p}-affix-wrapper-rtl`]:r==="rtl",[`${p}-affix-wrapper-without-controls`]:h===!1||fe||x},$),wrapper:ie({[`${We}-rtl`]:r==="rtl"},$),groupWrapper:ie({[`${p}-group-wrapper-sm`]:re==="small",[`${p}-group-wrapper-lg`]:re==="large",[`${p}-group-wrapper-rtl`]:r==="rtl",[`${p}-group-wrapper-${ve}`]:Y},Sn(`${p}-group-wrapper`,ae,J),$)}},E));return O($e)}),K=Wn,xi=n=>o.createElement(kt,{theme:{components:{InputNumber:{handleVisible:!0}}}},o.createElement(Wn,Object.assign({},n)));K._InternalPanelDoNotUseOrYouWillBeFired=xi;var yi={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M893.3 293.3L730.7 130.7c-7.5-7.5-16.7-13-26.7-16V112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V338.5c0-17-6.7-33.2-18.7-45.2zM384 184h256v104H384V184zm456 656H184V184h136v136c0 17.7 14.3 32 32 32h320c17.7 0 32-14.3 32-32V205.8l136 136V840zM512 442c-79.5 0-144 64.5-144 144s64.5 144 144 144 144-64.5 144-144-64.5-144-144-144zm0 224c-44.2 0-80-35.8-80-80s35.8-80 80-80 80 35.8 80 80-35.8 80-80 80z"}}]},name:"save",theme:"outlined"},vi=function(t,a){return o.createElement(rn,de({},t,{ref:a,icon:yi}))},Gn=o.forwardRef(vi),ji={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"},bi=function(t,a){return o.createElement(rn,de({},t,{ref:a,icon:ji}))},wi=o.forwardRef(bi);function Si(){const{t:n}=H(),t=Be(),[a]=w.useForm(),{config:r,isLoading:i,updateAsync:s,validate:c,isUpdating:l,isValidating:u}=Ft(),{handleError:m,handleSuccess:d}=ke();return o.useEffect(()=>{if(r){const x=Ci(r);a.setFieldsValue(x)}},[r,a]),{form:a,config:r,isLoading:i,isUpdating:l,isValidating:u,handleSave:async()=>{try{const x=a.getFieldsValue();await s(x),d(n("config.saveSuccess"))}catch(x){const S=In(x),h=ki(S,n);m(S,h)}},handleValidate:()=>{a.validateFields().then(x=>{c(x)})},handleTargetChange:async()=>{try{const x=a.getFieldsValue(),S={...Ii(r),...x,targets:x.targets};await s(S)}catch(x){const S=In(x),h=ye(S.code,n,S.params,n("config.saveFailed"))??n("config.saveFailed");m(S,h)}},getConfigPreview:()=>JSON.stringify(a.getFieldsValue(),null,2),refreshConfig:()=>t.invalidateQueries({queryKey:ue.CONFIG})}}const Ci=n=>{const{_meta:t,_validation:a,...r}=n;return{...r,targets:Array.isArray(r.targets)?r.targets:[]}},Ii=n=>{if(!n)return{};const{_meta:t,_validation:a,...r}=n;return r},ki=(n,t)=>{if(n.code==="CONFIG_INVALID"&&Array.isArray(n.details)){const a=n.details.map(r=>{if(typeof r=="object"&&r&&"code"in r){const{code:i,params:s}=r;return ye(i,t,s)}return String(r)});return`${ye(n.code,t)}: ${a.join(", ")}`}return ye(n.code,t,n.params,n.message)||n.message||t("config.saveFailed")};function Ei(n=!1){const[t,a]=o.useState(n),[r,i]=o.useState(void 0),[s,c]=o.useState(void 0),[l,u]=o.useState(void 0),m=o.useCallback((j,x)=>{a(!0),j&&(i(j),x&&(u(x),V.loading({content:j,key:x,duration:0})))},[]),d=o.useCallback(j=>{a(!1),i(void 0),c(void 0),l&&(V.destroy(l),j&&V.success({content:j,key:l,duration:2}),u(void 0))},[l]),g=o.useCallback(j=>{c(Math.max(0,Math.min(100,j)))},[]),f=o.useCallback(j=>{i(j),l&&V.loading({content:j,key:l,duration:0})},[l]);return{...o.useMemo(()=>({loading:t,message:r,progress:s}),[t,r,s]),startLoading:m,stopLoading:d,updateProgress:g,updateMessage:f,setLoading:a}}const Ni="config-import";function Di(n){const{t}=H(),a=Be(),{refetch:r}=Ve(),{handleWarning:i,handleSuccess:s,handleError:c}=ke(),{loading:l,startLoading:u,stopLoading:m}=Ei(),d=o.useMemo(()=>{if(!n)return null;const{_meta:h,_validation:y,...E}=n;return E},[n]),g=o.useCallback(()=>{if(!d){i(t("config.configNotLoaded"));return}const h=JSON.stringify(d,null,2),y=new Blob([h],{type:"application/json"}),E=URL.createObjectURL(y),p=document.createElement("a");p.href=E,p.download=`config-${new Date().toISOString().split("T")[0]}.json`,p.click(),URL.revokeObjectURL(E),s(t("config.configExported"))},[d,s,i,t]),f=o.useCallback(async h=>{const y=await new Promise(($,P)=>{const C=new FileReader;C.onload=k=>$(k.target?.result??""),C.onerror=()=>P(new Error(t("config.configReadFailed",{defaultValue:"Failed to read config file"}))),C.readAsText(h)}),E=JSON.parse(y);if(typeof E!="object"||E===null)throw new Error(t("config.configFormatError"));const{_meta:p,_validation:_,...O}=E;return O},[t]),v=o.useCallback(()=>{const h=document.createElement("input");h.type="file",h.accept=".json",h.multiple=!0,h.onchange=async y=>{const E=y.target,p=Array.from(E.files??[]);if(p.length===0)return;u(void 0,Ni);let _=0,O=0;const $=[];let P=null;try{for(const C of p){let k;try{k=await f(C)}catch(D){O++,$.push(`${C.name}: ${D instanceof Error?D.message:t("config.configFormatError")}`);continue}try{const D=await Ze.validateConfig(k);if(!D.valid){const A=Array.isArray(D.errors)&&D.errors.length>0?D.errors.join(", "):t("config.validationFailed");O++,$.push(`${C.name}: ${A}`);continue}}catch(D){console.warn("[Config Import] Validation error:",D)}try{const D=C.name.replace(/\.json$/i,"").replace(/^standalone\.config\./i,""),A=new Date().toISOString().split("T")[0],B=D?`${D}-${A}`:`imported-${A}`;P=(await Ze.importConfigFile(k,B)).path,_++}catch(D){const{message:A}=ze(D);O++,$.push(`${C.name}: ${A||(D instanceof Error?D.message:t("config.unknownError"))}`)}}if(P)try{await Ze.switchConfigFile(P)}catch(C){c(C)}if(await a.invalidateQueries({queryKey:ue.CONFIG}),await a.invalidateQueries({queryKey:ue.CONFIG_FILES}),r(),_>0&&O===0)s(p.length===1?t("config.configImportedAndSaved"):t("config.configBatchImportedSuccess",{count:_}));else if(_>0&&O>0)V.warning(t("config.configBatchImportedPartial",{success:_,total:p.length,failed:O})),console.warn(`[Config Import] Failed files:
14
+ `,$.join(`
15
+ `));else{const C=p.length===1?`${t("config.configImportFailed")}: ${$[0]||t("config.unknownError")}`:t("config.configBatchImportedFailed",{count:O});V.error(C)}}finally{m()}},h.click()},[c,s,f,a,r,u,m,t]),j=o.useCallback(async h=>{try{await navigator.clipboard.writeText(h),s(t("config.configCopied"))}catch(y){c(y,t("config.clipboardCopyFailed",{defaultValue:"Failed to copy config to clipboard"}))}},[c,s,t]),x=o.useCallback(()=>{setTimeout(()=>{window.location.reload()},1e3)},[]),S=o.useCallback(()=>{setTimeout(()=>{window.location.reload()},1e3)},[]);return{handleExportConfig:g,handleImportConfig:v,handleCopyConfig:j,handleConfigFileSwitch:x,handleConfigApplied:S,isImporting:l}}function Ti(){const[n,t]=o.useState(!1),[a,r]=o.useState(!1),[i,s]=o.useState(null),c=o.useCallback(()=>{t(!0)},[]),l=o.useCallback(()=>{t(!1)},[]),u=o.useCallback(d=>{s(d),r(!0)},[]),m=o.useCallback(()=>{r(!1),s(null)},[]);return{previewVisible:n,jsonEditorVisible:a,editingConfigFile:i,openPreview:c,closePreview:l,openJsonEditor:u,closeJsonEditor:m}}function $i(){const[n,t]=o.useState("files"),a=o.useCallback(r=>{t(r)},[]);return{activeTab:n,setActiveTab:a}}const{Title:Fi,Text:Ri}=oe,{Option:Ai}=U;function _i({currentConfigPath:n,configFiles:t,onConfigFileSwitch:a,refetchConfigFiles:r}){const{t:i}=H(),s=Be(),{handleError:c,handleSuccess:l}=ke(),u=t?.find(d=>d.isActive),m=async d=>{const g=t.find(f=>f.filename===d);if(g&&!g.isActive)try{await _e.switchConfigFile(g.path),l(i("config.configSwitched")),await s.invalidateQueries({queryKey:ue.CONFIG}),await s.invalidateQueries({queryKey:ue.CONFIG_FILES}),await Promise.resolve(r()),await Promise.resolve(a())}catch(f){c(f,i("config.configSwitchFailed"))}};return e.jsxs("div",{style:{flex:"1 1 auto",minWidth:200},children:[e.jsx(Fi,{level:2,style:{margin:0,whiteSpace:"normal",wordBreak:"normal"},children:i("config.title")}),e.jsxs(T,{direction:"vertical",size:"small",style:{marginTop:8},children:[e.jsxs(Ri,{type:"secondary",style:{fontSize:12},children:[i("config.currentConfigFile"),": ",n]}),t&&t.length>0&&e.jsx(U,{value:u?.filename||void 0,onChange:m,style:{width:300,fontSize:12},placeholder:i("config.selectConfigFile"),size:"small",children:t.map(d=>e.jsxs(Ai,{value:d.filename,children:[d.isActive&&e.jsx(Ie,{color:"green",style:{marginRight:8},children:i("config.activeConfig")}),d.filename]},d.filename))})]})]})}function Oi({onRefresh:n,onPreview:t,onExport:a,onImport:r,onCopy:i,onValidate:s,onSave:c,isValidating:l,isUpdating:u,isImporting:m=!1}){const{t:d}=H(),{authenticated:g}=At(),f=!g,v=d("common.loginRequired");return e.jsxs(T,{wrap:!0,children:[e.jsx(R,{icon:e.jsx(on,{}),onClick:n,children:d("common.refresh")}),e.jsx(R,{icon:e.jsx(On,{}),onClick:t,children:d("config.previewConfig")}),e.jsx(R,{icon:e.jsx(Et,{}),onClick:a,children:d("config.exportConfig")}),e.jsx(W,{title:f?v:void 0,children:e.jsx(R,{icon:e.jsx(wi,{}),onClick:r,loading:m,disabled:m||f,children:d("config.importConfig")})}),e.jsx(R,{icon:e.jsx(ln,{}),onClick:i,children:d("config.copyConfig")}),e.jsx(R,{icon:e.jsx(Ut,{}),onClick:s,loading:l,children:d("config.validateConfig")}),e.jsx(W,{title:f?v:void 0,children:e.jsx(R,{type:"primary",icon:e.jsx(Gn,{}),onClick:c,loading:u,disabled:f,children:d("config.saveConfig")})})]})}const{Panel:Mi}=Pe,{Title:en,Text:nn}=oe,Ne=({title:n,description:t,children:a,collapsible:r=!1,defaultCollapsed:i=!1,card:s=!0,extra:c,style:l,className:u})=>r?e.jsx(Pe,{defaultActiveKey:i?[]:["1"],style:l,className:u,children:e.jsx(Mi,{header:e.jsxs(T,{direction:"vertical",size:0,children:[e.jsx(en,{level:5,style:{margin:0},children:n}),t&&e.jsx(nn,{type:"secondary",style:{fontSize:12},children:t})]}),extra:c,children:a},"1")}):s?e.jsx(Ee,{title:e.jsxs(T,{direction:"vertical",size:0,children:[e.jsx(en,{level:5,style:{margin:0},children:n}),t&&e.jsx(nn,{type:"secondary",style:{fontSize:12},children:t})]}),extra:c,style:l,className:u,children:a}):e.jsx("div",{style:l,className:u,children:e.jsxs(T,{direction:"vertical",size:8,style:{width:"100%"},children:[e.jsx(en,{level:5,style:{margin:0},children:n}),t&&e.jsx(nn,{type:"secondary",style:{fontSize:12},children:t}),a]})}),{Option:Re}=U,zi=()=>{const{t:n}=H();return e.jsxs(Ne,{title:n("config.tabBasic"),children:[e.jsx(w.Item,{label:e.jsxs(T,{children:[n("config.logLevel"),e.jsx(W,{title:n("config.logLevelTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"logLevel",children:e.jsxs(U,{children:[e.jsx(Re,{value:"debug",children:n("config.logLevelDebug")}),e.jsx(Re,{value:"info",children:n("config.logLevelInfo")}),e.jsx(Re,{value:"warn",children:n("config.logLevelWarn")}),e.jsx(Re,{value:"error",children:n("config.logLevelError")})]})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[n("config.initialDelay"),e.jsx(W,{title:n("config.initialDelayTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"initialDelay",children:e.jsx(K,{min:0,style:{width:"100%"},placeholder:n("config.initialDelayPlaceholder")})})]})},{Option:Ae}=U,Bi=()=>{const{t:n}=H();return e.jsxs(Ne,{title:n("config.tabNetwork"),children:[e.jsx(w.Item,{label:n("config.networkTimeout"),name:["network","timeoutMs"],children:e.jsx(K,{min:1e3,style:{width:"100%"}})}),e.jsx(w.Item,{label:n("config.networkRetries"),name:["network","retries"],children:e.jsx(K,{min:0,max:10,style:{width:"100%"}})}),e.jsx(w.Item,{label:n("config.networkRetryDelay"),name:["network","retryDelay"],children:e.jsx(K,{min:0,style:{width:"100%"}})}),e.jsx(Jt,{children:n("config.proxySettings")}),e.jsx(w.Item,{label:n("config.proxyEnabled"),name:["network","proxy","enabled"],valuePropName:"checked",children:e.jsx(Vn,{})}),e.jsx(w.Item,{noStyle:!0,shouldUpdate:(t,a)=>t.network?.proxy?.enabled!==a.network?.proxy?.enabled,children:({getFieldValue:t})=>t(["network","proxy","enabled"])?e.jsxs(e.Fragment,{children:[e.jsx(w.Item,{label:n("config.proxyHost"),name:["network","proxy","host"],children:e.jsx(Q,{})}),e.jsx(w.Item,{label:n("config.proxyPort"),name:["network","proxy","port"],children:e.jsx(K,{min:1,max:65535,style:{width:"100%"}})}),e.jsx(w.Item,{label:n("config.proxyProtocol"),name:["network","proxy","protocol"],children:e.jsxs(U,{children:[e.jsx(Ae,{value:"http",children:"HTTP"}),e.jsx(Ae,{value:"https",children:"HTTPS"}),e.jsx(Ae,{value:"socks4",children:"SOCKS4"}),e.jsx(Ae,{value:"socks5",children:"SOCKS5"})]})}),e.jsx(w.Item,{label:n("config.proxyUsername"),name:["network","proxy","username"],children:e.jsx(Q,{})}),e.jsx(w.Item,{label:n("config.proxyPassword"),name:["network","proxy","password"],children:e.jsx(Q.Password,{})})]}):null})]})},{Option:z,OptGroup:xe}=U,Vi=()=>{const{t:n}=H();return e.jsxs(Ne,{title:n("config.tabStorage"),children:[e.jsx(w.Item,{label:n("config.storageDatabasePath"),name:["storage","databasePath"],children:e.jsx(Q,{})}),e.jsx(w.Item,{label:n("config.storageDownloadDirectory"),name:["storage","downloadDirectory"],children:e.jsx(Q,{})}),e.jsx(w.Item,{label:n("config.storageIllustrationDirectory"),name:["storage","illustrationDirectory"],children:e.jsx(Q,{})}),e.jsx(w.Item,{label:n("config.storageNovelDirectory"),name:["storage","novelDirectory"],children:e.jsx(Q,{})}),e.jsx(w.Item,{label:n("config.storageIllustrationOrganization"),name:["storage","illustrationOrganization"],tooltip:n("config.storageIllustrationOrganizationTooltip"),children:e.jsxs(U,{children:[e.jsxs(xe,{label:n("config.organizationGroupSimple"),children:[e.jsx(z,{value:"flat",children:n("config.organizationFlat")}),e.jsx(z,{value:"byAuthor",children:n("config.organizationByAuthor")}),e.jsx(z,{value:"byTag",children:n("config.organizationByTag")})]}),e.jsxs(xe,{label:n("config.organizationGroupDate"),children:[e.jsx(z,{value:"byDate",children:n("config.organizationByDate")}),e.jsx(z,{value:"byDay",children:n("config.organizationByDay")}),e.jsx(z,{value:"byDownloadDate",children:n("config.organizationByDownloadDate")}),e.jsx(z,{value:"byDownloadDay",children:n("config.organizationByDownloadDay")})]}),e.jsxs(xe,{label:n("config.organizationGroupCombined"),children:[e.jsx(z,{value:"byAuthorAndTag",children:n("config.organizationByAuthorAndTag")}),e.jsx(z,{value:"byDateAndAuthor",children:n("config.organizationByDateAndAuthor")}),e.jsx(z,{value:"byDayAndAuthor",children:n("config.organizationByDayAndAuthor")}),e.jsx(z,{value:"byDownloadDateAndAuthor",children:n("config.organizationByDownloadDateAndAuthor")}),e.jsx(z,{value:"byDownloadDayAndAuthor",children:n("config.organizationByDownloadDayAndAuthor")})]})]})}),e.jsx(w.Item,{label:n("config.storageNovelOrganization"),name:["storage","novelOrganization"],tooltip:n("config.storageNovelOrganizationTooltip"),children:e.jsxs(U,{children:[e.jsxs(xe,{label:n("config.organizationGroupSimple"),children:[e.jsx(z,{value:"flat",children:n("config.organizationFlat")}),e.jsx(z,{value:"byAuthor",children:n("config.organizationByAuthor")}),e.jsx(z,{value:"byTag",children:n("config.organizationByTag")})]}),e.jsxs(xe,{label:n("config.organizationGroupDate"),children:[e.jsx(z,{value:"byDate",children:n("config.organizationByDate")}),e.jsx(z,{value:"byDay",children:n("config.organizationByDay")}),e.jsx(z,{value:"byDownloadDate",children:n("config.organizationByDownloadDate")}),e.jsx(z,{value:"byDownloadDay",children:n("config.organizationByDownloadDay")})]}),e.jsxs(xe,{label:n("config.organizationGroupCombined"),children:[e.jsx(z,{value:"byAuthorAndTag",children:n("config.organizationByAuthorAndTag")}),e.jsx(z,{value:"byDateAndAuthor",children:n("config.organizationByDateAndAuthor")}),e.jsx(z,{value:"byDayAndAuthor",children:n("config.organizationByDayAndAuthor")}),e.jsx(z,{value:"byDownloadDateAndAuthor",children:n("config.organizationByDownloadDateAndAuthor")}),e.jsx(z,{value:"byDownloadDayAndAuthor",children:n("config.organizationByDownloadDayAndAuthor")})]})]})})]})},Pi=()=>{const{t:n}=H();return e.jsxs(Ne,{title:n("config.tabScheduler"),children:[e.jsx(w.Item,{label:n("config.schedulerEnabled"),name:["scheduler","enabled"],valuePropName:"checked",children:e.jsx(Vn,{})}),e.jsx(w.Item,{label:n("config.schedulerCron"),name:["scheduler","cron"],children:e.jsx(Q,{placeholder:n("config.schedulerCronPlaceholder")})}),e.jsx(w.Item,{label:n("config.schedulerTimezone"),name:["scheduler","timezone"],children:e.jsx(Q,{placeholder:n("config.schedulerTimezonePlaceholder")})}),e.jsx(w.Item,{label:n("config.schedulerMaxExecutions"),name:["scheduler","maxExecutions"],children:e.jsx(K,{min:1,style:{width:"100%"},placeholder:n("config.schedulerMaxExecutionsPlaceholder")})}),e.jsx(w.Item,{label:n("config.schedulerMinInterval"),name:["scheduler","minInterval"],children:e.jsx(K,{min:0,style:{width:"100%"}})}),e.jsx(w.Item,{label:n("config.schedulerTimeout"),name:["scheduler","timeout"],children:e.jsx(K,{min:1e3,style:{width:"100%"},placeholder:n("config.schedulerTimeoutPlaceholder")})})]})},Li=()=>{const{t:n}=H();return e.jsxs(Ne,{title:n("config.tabDownload"),children:[e.jsx(w.Item,{label:n("config.downloadConcurrency"),name:["download","concurrency"],children:e.jsx(K,{min:1,max:10,style:{width:"100%"}})}),e.jsx(w.Item,{label:n("config.downloadMaxRetries"),name:["download","maxRetries"],children:e.jsx(K,{min:0,max:10,style:{width:"100%"}})}),e.jsx(w.Item,{label:n("config.downloadRetryDelay"),name:["download","retryDelay"],children:e.jsx(K,{min:0,style:{width:"100%"}})}),e.jsx(w.Item,{label:n("config.downloadTimeout"),name:["download","timeout"],children:e.jsx(K,{min:1e3,style:{width:"100%"}})})]})},{Option:L}=U,{Panel:tn}=Pe,{Step:Tn}=Pn,{Text:Hi,Paragraph:Wi}=oe,Gi=({visible:n,editingTarget:t,onSave:a,onCancel:r})=>{const{t:i}=H(),[s]=w.useForm(),[c,l]=o.useState(0),u={tagSearch:{name:i("config.templateTagSearch"),description:i("config.templateTagSearchDesc"),config:{type:"illustration",mode:"search",tag:"",limit:20,searchTarget:"partial_match_for_tags",sort:"date_desc"}},ranking:{name:i("config.templateRanking"),description:i("config.templateRankingDesc"),config:{type:"illustration",mode:"ranking",rankingMode:"day",limit:30}},multiTag:{name:i("config.templateMultiTag"),description:i("config.templateMultiTagDesc"),config:{type:"illustration",mode:"search",tag:"",limit:30,searchTarget:"partial_match_for_tags"}},highQuality:{name:i("config.templateHighQuality"),description:i("config.templateHighQualityDesc"),config:{type:"illustration",mode:"search",tag:"",limit:20,minBookmarks:1e3,sort:"popular_desc"}},novel:{name:i("config.templateNovel"),description:i("config.templateNovelDesc"),config:{type:"novel",mode:"search",tag:"",limit:10}}};o.useEffect(()=>{n&&(t?(s.setFieldsValue(t),l(1)):(s.resetFields(),l(0)))},[n,t,s]);const m=f=>{s.setFieldsValue(f.config),l(1)},d=async()=>{try{const f=await s.validateFields();a(f),s.resetFields(),l(0)}catch{}},g=()=>{s.resetFields(),l(0),r()};return e.jsxs(cn,{title:e.jsxs(T,{children:[i(t?"config.editTarget":"config.addTarget"),!t&&e.jsx(W,{title:i("config.templateTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),open:n,onOk:d,onCancel:g,width:800,okText:i("common.save"),cancelText:i("common.cancel"),children:[e.jsxs(Pn,{current:c,style:{marginBottom:24},children:[e.jsx(Tn,{title:i("config.stepSelectTemplate"),description:i("config.stepSelectTemplateDesc")}),e.jsx(Tn,{title:i("config.stepConfigure"),description:i("config.stepConfigureDesc")})]}),c===0&&!t&&e.jsxs("div",{children:[e.jsx(Wi,{type:"secondary",style:{marginBottom:16},children:i("config.templateSelectDescription")}),e.jsxs(T,{direction:"vertical",style:{width:"100%"},size:"middle",children:[Object.entries(u).map(([f,v])=>e.jsx(Ee,{hoverable:!0,style:{cursor:"pointer"},onClick:()=>m(v),children:e.jsxs(T,{style:{width:"100%",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(oe.Title,{level:5,style:{margin:0},children:v.name}),e.jsx(Hi,{type:"secondary",children:v.description})]}),e.jsx(R,{type:"primary",icon:e.jsx(Ln,{}),children:i("config.useTemplate")})]})},f)),e.jsx(R,{block:!0,type:"dashed",onClick:()=>l(1),style:{marginTop:8},children:i("config.skipTemplate")})]})]}),c===1&&e.jsx(w,{form:s,layout:"vertical",children:e.jsxs(Pe,{defaultActiveKey:["basic"],ghost:!0,children:[e.jsxs(tn,{header:i("config.targetBasicSettings"),children:[e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.targetType"),e.jsx(W,{title:i("config.targetTypeTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"type",rules:[{required:!0,message:i("config.targetTypeRequired")}],children:e.jsxs(U,{children:[e.jsx(L,{value:"illustration",children:i("config.typeIllustration")}),e.jsx(L,{value:"novel",children:i("config.typeNovel")})]})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.targetMode"),e.jsx(W,{title:i("config.targetModeTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"mode",initialValue:"search",children:e.jsxs(U,{children:[e.jsx(L,{value:"search",children:i("config.modeSearch")}),e.jsx(L,{value:"ranking",children:i("config.modeRanking")})]})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.targetLimit"),e.jsx(W,{title:i("config.targetLimitTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"limit",rules:[{type:"number",min:1,max:1e3,message:i("config.targetLimitRange")}],children:e.jsx(K,{min:1,max:1e3,style:{width:"100%"},placeholder:i("config.targetLimitPlaceholder")})})]},"basic"),e.jsx(tn,{header:i("config.targetModeSettings"),children:e.jsx(w.Item,{noStyle:!0,shouldUpdate:(f,v)=>f.mode!==v.mode,children:({getFieldValue:f})=>(f("mode")||"search")==="search"?e.jsxs(e.Fragment,{children:[e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.targetTag"),e.jsx(W,{title:i("config.targetTagTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"tag",rules:[{validator:(j,x)=>!x||x.trim()===""?Promise.reject(new Error(i("config.targetTagRequired"))):Promise.resolve()}],children:e.jsx(Q,{placeholder:i("config.targetTagPlaceholder")})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.searchTarget"),e.jsx(W,{title:i("config.searchTargetTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"searchTarget",initialValue:"partial_match_for_tags",children:e.jsxs(U,{children:[e.jsxs(L,{value:"partial_match_for_tags",children:[i("config.searchTargetPartial")," (",i("common.recommended"),")"]}),e.jsx(L,{value:"exact_match_for_tags",children:i("config.searchTargetExact")}),e.jsx(L,{value:"title_and_caption",children:i("config.searchTargetTitle")})]})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.sort"),e.jsx(W,{title:i("config.sortTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"sort",initialValue:"date_desc",children:e.jsxs(U,{children:[e.jsx(L,{value:"date_desc",children:i("config.sortDateDesc")}),e.jsx(L,{value:"date_asc",children:i("config.sortDateAsc")}),e.jsx(L,{value:"popular_desc",children:i("config.sortPopularDesc")})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.rankingMode"),e.jsx(W,{title:i("config.rankingModeTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"rankingMode",initialValue:"day",children:e.jsxs(U,{children:[e.jsx(L,{value:"day",children:i("config.rankingDay")}),e.jsx(L,{value:"week",children:i("config.rankingWeek")}),e.jsx(L,{value:"month",children:i("config.rankingMonth")}),e.jsx(L,{value:"day_male",children:i("config.rankingDayMale")}),e.jsx(L,{value:"day_female",children:i("config.rankingDayFemale")}),e.jsx(L,{value:"day_ai",children:i("config.rankingDayAI")}),e.jsx(L,{value:"week_original",children:i("config.rankingWeekOriginal")}),e.jsx(L,{value:"week_rookie",children:i("config.rankingWeekRookie")})]})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.rankingDate"),e.jsx(W,{title:i("config.rankingDateTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"rankingDate",children:e.jsx(Q,{placeholder:i("config.rankingDatePlaceholder")})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.filterTag"),e.jsx(W,{title:i("config.filterTagTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"filterTag",children:e.jsx(Q,{placeholder:i("config.filterTagPlaceholder")})})]})})},"mode"),e.jsxs(tn,{header:i("config.targetAdvancedFilters"),children:[e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.minBookmarks"),e.jsx(W,{title:i("config.minBookmarksTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"minBookmarks",children:e.jsx(K,{min:0,style:{width:"100%"},placeholder:i("config.minBookmarksPlaceholder")})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.startDate"),e.jsx(W,{title:i("config.startDateTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"startDate",children:e.jsx(Q,{placeholder:i("config.startDatePlaceholder")})}),e.jsx(w.Item,{label:e.jsxs(T,{children:[i("config.endDate"),e.jsx(W,{title:i("config.endDateTooltip"),children:e.jsx(q,{style:{color:"#999"}})})]}),name:"endDate",children:e.jsx(Q,{placeholder:i("config.endDatePlaceholder")})})]},"advanced")]})})]})};function qi(){const{t:n}=H();return e.jsx(Ce,{message:n("config.targetsTitle"),description:n("config.targetsDescription"),type:"info",showIcon:!0})}const{Text:Z}=oe;function Ui({targets:n,onAdd:t,onEdit:a,onDelete:r}){const{t:i}=H(),s=o.useMemo(()=>[{title:i("config.targetType"),dataIndex:"type",key:"type",width:100,render:c=>e.jsx(Ie,{color:c==="illustration"?"blue":"green",children:i(c==="illustration"?"config.typeIllustration":"config.typeNovel")})},{title:i("config.targetMode"),dataIndex:"mode",key:"mode",width:100,render:c=>c?e.jsx(Ie,{color:c==="ranking"?"purple":"cyan",children:i(c==="ranking"?"config.modeRanking":"config.modeSearch")}):"-"},{title:i("config.targetConfig"),key:"config",render:(c,l)=>{if(l.mode==="ranking"){const u={day:i("config.rankingDay"),week:i("config.rankingWeek"),month:i("config.rankingMonth"),day_male:i("config.rankingDayMale"),day_female:i("config.rankingDayFemale"),day_ai:i("config.rankingDayAI"),week_original:i("config.rankingWeekOriginal"),week_rookie:i("config.rankingWeekRookie")};return e.jsxs(T,{direction:"vertical",size:"small",style:{fontSize:12},children:[e.jsx(Z,{strong:!0,children:u[l.rankingMode||"day"]||l.rankingMode}),l.filterTag&&e.jsxs(Z,{type:"secondary",children:[i("config.filterTag"),": ",l.filterTag]}),l.rankingDate&&e.jsxs(Z,{type:"secondary",children:[i("config.rankingDate"),": ",l.rankingDate]})]})}return l.seriesId?e.jsxs(Z,{children:[i("config.seriesId"),": ",l.seriesId]}):l.novelId?e.jsxs(Z,{children:[i("config.novelId"),": ",l.novelId]}):e.jsxs(T,{direction:"vertical",size:"small",style:{fontSize:12},children:[e.jsx(Z,{strong:!0,children:l.tag||"-"}),l.searchTarget&&e.jsx(Z,{type:"secondary",children:l.searchTarget==="partial_match_for_tags"?i("config.searchTargetPartial"):l.searchTarget==="exact_match_for_tags"?i("config.searchTargetExact"):i("config.searchTargetTitle")}),l.sort&&e.jsx(Z,{type:"secondary",children:l.sort==="date_desc"?i("config.sortDateDesc"):l.sort==="date_asc"?i("config.sortDateAsc"):i("config.sortPopularDesc")})]})}},{title:i("config.targetFilters"),key:"filters",width:150,render:(c,l)=>e.jsxs(T,{direction:"vertical",size:"small",style:{fontSize:12},children:[l.limit&&e.jsxs(Z,{children:[i("config.limit"),": ",l.limit]}),l.minBookmarks&&e.jsxs(Z,{type:"secondary",children:[i("config.minBookmarks")," ≥ ",l.minBookmarks]}),(l.startDate||l.endDate)&&e.jsxs(Z,{type:"secondary",children:[l.startDate&&`${i("config.from")} ${l.startDate}`,l.endDate&&` ${i("config.to")} ${l.endDate}`]})]})},{title:i("common.actions"),key:"action",width:150,render:(c,l,u)=>e.jsxs(T,{children:[e.jsx(R,{type:"link",icon:e.jsx(Bn,{}),onClick:()=>a(l,u),size:"small",children:i("common.edit")}),e.jsx(dn,{title:i("config.deleteTargetConfirm"),onConfirm:()=>r(u),okText:i("common.ok"),cancelText:i("common.cancel"),children:e.jsx(R,{type:"link",danger:!0,icon:e.jsx(un,{}),size:"small",children:i("common.delete")})})]})}],[r,a,i]);return e.jsx(Ee,{title:i("config.targetsList"),extra:e.jsx(R,{icon:e.jsx(Ln,{}),onClick:t,children:i("config.addTarget")}),children:e.jsx(sn,{columns:s,dataSource:n,rowKey:c=>c._rowKey?c._rowKey:String(c._index??c.tag??c.mode??"target"),pagination:!1,locale:{emptyText:i("config.targetsEmpty")}})})}const Ki=({form:n,onTargetChange:t})=>{const[a,r]=o.useState(!1),[i,s]=o.useState(null);o.useEffect(()=>{const j=n.getFieldValue("targets");Array.isArray(j)||n.setFieldsValue({targets:[]})},[n]);const c=w.useWatch("targets",n)||n.getFieldValue("targets")||[],l=o.useCallback(()=>{t&&t()},[t]),u=o.useCallback(()=>{s(null),r(!0)},[]),m=o.useCallback((j,x)=>{s({...j,_index:x}),r(!0)},[]),d=o.useCallback(j=>{const S=(n.getFieldValue("targets")||[]).filter((h,y)=>y!==j);n.setFieldsValue({targets:S}),l()},[n,l]),g=o.useCallback(j=>{const S=[...n.getFieldValue("targets")||[]];i&&typeof i._index=="number"?S[i._index]=j:S.push(j),n.setFieldsValue({targets:S}),r(!1),s(null),l()},[i,n,l]),f=o.useCallback(()=>{r(!1),s(null)},[]),v=o.useMemo(()=>c.map((j,x)=>({...j,_index:x,_rowKey:`${j.type||"target"}-${x}`})),[c]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Item,{name:"targets",hidden:!0,children:e.jsx("input",{type:"hidden"})}),e.jsxs(T,{direction:"vertical",style:{width:"100%"},size:"large",children:[e.jsx(qi,{}),e.jsx(Ui,{targets:v,onAdd:u,onEdit:m,onDelete:d})]}),e.jsx(Gi,{visible:a,editingTarget:i,onSave:g,onCancel:f})]})},qn=({value:n,onChange:t,language:a="text",readOnly:r=!1,placeholder:i="Enter code...",minHeight:s=200,maxHeight:c=600,showCopyButton:l=!0,style:u,className:m})=>{const d=o.useRef(null),[g,f]=o.useState(!1),v=h=>{t&&t(h.target.value)},j=async()=>{try{await navigator.clipboard.writeText(n),f(!0),V.success("Copied to clipboard"),setTimeout(()=>f(!1),2e3)}catch{V.error("Failed to copy")}},x=h=>{if(a==="json"&&!r){const y=h.clipboardData.getData("text");try{const E=JSON.parse(y),p=JSON.stringify(E,null,2);h.preventDefault(),t&&t(p)}catch{}}},S={fontFamily:'Monaco, Menlo, "Ubuntu Mono", Consolas, "source-code-pro", monospace',fontSize:"14px",lineHeight:"1.6",padding:"12px",border:"1px solid #d9d9d9",borderRadius:"4px",backgroundColor:a==="json"?"#1f1f1f":"#fff",color:a==="json"?"#fff":"#000",minHeight:`${s}px`,maxHeight:`${c}px`,overflow:"auto",resize:"vertical",width:"100%",...u};return e.jsxs("div",{className:m,children:[l&&e.jsx(T,{style:{marginBottom:8,justifyContent:"flex-end",width:"100%"},children:e.jsx(R,{size:"small",icon:g?e.jsx(Nt,{}):e.jsx(ln,{}),onClick:j,disabled:!n,children:g?"Copied":"Copy"})}),e.jsx("textarea",{ref:d,value:n,onChange:v,onPaste:x,readOnly:r,placeholder:i,style:S,spellCheck:!1})]})},Un=({visible:n,filename:t,onClose:a,onConfigFileSwitch:r})=>{const{t:i}=H(),s=Be(),{configFiles:c,refetch:l}=Ve(),[u,m]=o.useState(""),[d,g]=o.useState(!1),[f,v]=o.useState(""),[j,x]=o.useState(!1),[S,h]=o.useState(!1),y=o.useRef(""),E=o.useRef(""),p=o.useRef(!1);o.useEffect(()=>{n&&t?_():(m(""),v(""),x(!1),y.current="",E.current="")},[n,t]),o.useEffect(()=>{if(!n||!t||p.current)return;let C,k=!0;const D=async()=>{if(!(!k||!t||p.current))try{const B=(await _e.getConfigFileContent(t)).data.data.content,J=y.current,te=E.current;B!==J&&B!==te&&!p.current?(x(!0),v(B),y.current=B):B===te?(x(!1),v(B),y.current=B):p.current||(v(B),y.current=B)}catch(A){console.warn("Failed to poll config file content:",A)}};return D(),C=setInterval(()=>{p.current||D()},5e3),()=>{k=!1,C&&clearInterval(C)}},[n,t,S]),o.useEffect(()=>{y.current=f},[f]),o.useEffect(()=>{E.current=u},[u]),o.useEffect(()=>{p.current=S},[S]);const _=async()=>{try{g(!0);const k=(await _e.getConfigFileContent(t)).data.data.content;m(k),v(k),y.current=k,E.current=k,x(!1)}catch(C){const{message:k}=ze(C),D=C instanceof Error?C.message:void 0;V.error(`${i("config.configFileReadFailed")}: ${k||D||i("config.unknownError")}`)}finally{g(!1)}},O=async()=>{await _(),V.success(i("config.jsonEditorRefreshed"))},$=async()=>{if(t)try{g(!0);try{JSON.parse(u)}catch{V.error(i("config.jsonFormatError"));return}await _e.updateConfigFileContent(t,u),V.success(i("config.configSaved")),v(u),y.current=u,E.current=u,x(!1),h(!1),p.current=!1,await s.invalidateQueries({queryKey:ue.CONFIG}),await s.invalidateQueries({queryKey:ue.CONFIG_FILES}),l(),c?.find(k=>k.filename===t&&k.isActive)?r?r():setTimeout(()=>{window.location.reload()},1e3):a()}catch(C){const{errorCode:k,message:D,details:A}=ze(C);if(k==="CONFIG_INVALID"&&A&&Array.isArray(A)){const B=A.map(J=>{if(typeof J=="object"&&J!==null&&"code"in J){const te=J;return ye(te.code,i,te.params)}return String(J)});V.error(`${ye(k,i)}: ${B.join(", ")}`)}else V.error(D||i("config.configSaveFailed"))}finally{g(!1)}},P=()=>{try{const C=JSON.parse(u),k=JSON.stringify(C,null,2);m(k),V.success(i("config.jsonFormatted"))}catch{V.error(i("config.jsonFormatError"))}};return e.jsx(cn,{title:e.jsxs(T,{children:[i("config.editJson"),e.jsxs("span",{style:{color:"#999",fontSize:14},children:["(",t,")"]})]}),open:n,onCancel:a,width:900,footer:[e.jsx(R,{onClick:P,children:i("config.formatJson")},"format"),e.jsx(R,{onClick:a,children:i("common.cancel")},"cancel"),e.jsx(R,{type:"primary",icon:e.jsx(Gn,{}),loading:d,onClick:$,children:i("config.saveConfig")},"save")],children:e.jsxs(Dt,{spinning:d&&!u,children:[j&&e.jsx(Ce,{message:i("config.jsonEditorExternalChanges"),description:i("config.jsonEditorExternalChangesDesc"),type:"warning",showIcon:!0,style:{marginBottom:16},action:e.jsx(R,{size:"small",onClick:O,children:i("config.refresh")})}),e.jsx(qn,{value:u,onChange:C=>{m(C),h(!0),p.current=!0,j&&C!==f&&x(!1)},language:"json",minHeight:400,maxHeight:600,placeholder:i("config.jsonEditorPlaceholder")}),e.jsx(Ce,{message:i("config.jsonEditorWarning"),type:"warning",showIcon:!0,style:{marginTop:16}})]})})},{Text:$n}=oe,Ji=({onConfigFileSwitch:n,onJsonEditorOpen:t})=>{const{t:a}=H(),{configFiles:r,isLoading:i,refetch:s,switchFileAsync:c,deleteFileAsync:l}=Ve(),{handleError:u}=ke(),[m,d]=o.useState(!1),[g,f]=o.useState(null),v=async h=>{if(t){t(h);return}try{f(h),d(!0)}catch(y){const{message:E}=ze(y),p=y instanceof Error?y:null;V.error(`${a("config.configFileReadFailed")}: ${E||p?.message||a("config.unknownError")}`)}},j=async h=>{if(!h.isActive)try{await c(h.path),V.success(a("config.configSwitched")),n&&n()}catch(y){u(y)}},x=async h=>{try{await l(h),V.success(a("config.configFileDeleted")),s()}catch(y){u(y)}},S=[{title:a("config.fileName"),dataIndex:"filename",key:"filename",render:(h,y)=>e.jsxs(T,{children:[e.jsx($n,{strong:y.isActive,children:h}),y.isActive&&e.jsx(Ie,{color:"green",children:a("config.activeConfig")})]})},{title:a("config.filePath"),dataIndex:"pathRelative",key:"pathRelative",render:h=>e.jsx($n,{type:"secondary",style:{fontSize:12},children:h})},{title:a("config.fileModified"),dataIndex:"modifiedTime",key:"modifiedTime",render:h=>new Date(h).toLocaleString()},{title:a("config.fileSize"),dataIndex:"size",key:"size",render:h=>`${(h/1024).toFixed(2)} KB`},{title:a("common.actions"),key:"action",width:250,render:(h,y)=>e.jsxs(T,{children:[e.jsx(R,{type:"link",icon:e.jsx(Bn,{}),onClick:()=>v(y.filename),size:"small",children:a("config.editJson")}),!y.isActive&&e.jsx(R,{type:"link",icon:e.jsx(Mn,{}),onClick:()=>j(y),size:"small",children:a("config.switch")}),e.jsx(dn,{title:a("config.deleteConfigFileConfirm"),onConfirm:()=>x(y.filename),okText:a("common.ok"),cancelText:a("common.cancel"),children:e.jsx(R,{type:"link",danger:!0,icon:e.jsx(un,{}),size:"small",children:a("common.delete")})})]})}];return e.jsxs(e.Fragment,{children:[e.jsx(Ee,{title:a("config.configFiles"),extra:e.jsx(R,{icon:e.jsx(on,{}),onClick:()=>s(),children:a("common.refresh")}),children:r&&r.length>0?e.jsx(sn,{columns:S,dataSource:r,rowKey:"filename",loading:i,pagination:{pageSize:10},locale:{emptyText:a("config.configFilesEmpty")}}):e.jsx(Ce,{message:a("config.configFilesEmpty"),description:a("config.configFilesEmptyDesc"),type:"info",showIcon:!0})}),m&&g&&e.jsx(Un,{visible:m,filename:g,onClose:()=>{d(!1),f(null)},onConfigFileSwitch:n})]})},{Text:Fn}=oe,Qi=({onConfigApplied:n})=>{const{t}=H(),{history:a,isLoading:r,refetch:i,applyAsync:s,deleteAsync:c}=Rt(),{handleError:l}=ke(),u=async g=>{try{await s(g),V.success(t("config.configApplied")),n&&n()}catch(f){l(f)}},m=async g=>{try{await c(g),V.success(t("config.historyDeleted")),i()}catch(f){l(f)}},d=[{title:t("config.historyName"),dataIndex:"name",key:"name",render:(g,f)=>e.jsxs(T,{children:[e.jsx(Fn,{strong:f.is_active===1,children:g}),f.is_active===1&&e.jsx(Ie,{color:"green",children:t("config.activeConfig")})]})},{title:t("config.historyDescription"),dataIndex:"description",key:"description",render:g=>g||e.jsx(Fn,{type:"secondary",children:"-"})},{title:t("config.historyCreatedAt"),dataIndex:"created_at",key:"created_at",render:g=>new Date(g).toLocaleString()},{title:t("config.historyUpdatedAt"),dataIndex:"updated_at",key:"updated_at",render:g=>new Date(g).toLocaleString()},{title:t("common.actions"),key:"action",width:200,render:(g,f)=>e.jsxs(T,{children:[e.jsx(R,{type:"link",icon:e.jsx(Mn,{}),onClick:()=>u(f.id),size:"small",children:t("config.apply")}),e.jsx(dn,{title:t("config.deleteHistoryConfirm"),onConfirm:()=>m(f.id),okText:t("common.ok"),cancelText:t("common.cancel"),children:e.jsx(R,{type:"link",danger:!0,icon:e.jsx(un,{}),size:"small",children:t("common.delete")})})]})}];return e.jsx(Ee,{title:t("config.configHistory"),extra:e.jsx(R,{icon:e.jsx(on,{}),onClick:()=>i(),children:t("common.refresh")}),children:a&&a.length>0?e.jsx(sn,{columns:d,dataSource:a,rowKey:"id",loading:r,pagination:{pageSize:10},locale:{emptyText:t("config.historyEmpty")}}):e.jsx(Ce,{message:t("config.historyEmpty"),description:t("config.historyEmptyDesc"),type:"info",showIcon:!0})})},{Text:Xi}=oe;function Yi({form:n,onConfigFileSwitch:t,onJsonEditorOpen:a,onConfigApplied:r,onTargetChange:i}){const{t:s}=H(),c=o.useMemo(()=>[{key:"files",label:e.jsxs(e.Fragment,{children:[e.jsx(On,{})," ",s("config.tabConfigFiles")]}),children:e.jsx(Ji,{onConfigFileSwitch:t,onJsonEditorOpen:a})},{key:"history",label:e.jsxs(e.Fragment,{children:[e.jsx(Tt,{})," ",s("config.tabHistory")]}),children:e.jsx(Qi,{onConfigApplied:r})}],[r,t,a,s]),l=o.useMemo(()=>[{key:"basic",label:s("config.tabBasic"),children:e.jsx(zi,{})},{key:"pixiv",label:s("config.tabPixiv"),children:e.jsx("div",{children:e.jsx(Xi,{type:"secondary",children:s("config.pixivCredentialsHidden")})})},{key:"network",label:s("config.tabNetwork"),children:e.jsx(Bi,{})},{key:"storage",label:s("config.tabStorage"),children:e.jsx(Vi,{})},{key:"scheduler",label:s("config.tabScheduler"),children:e.jsx(Pi,{})},{key:"download",label:s("config.tabDownload"),children:e.jsx(Li,{})},{key:"targets",label:s("config.tabTargets"),children:e.jsx(Ki,{form:n,onTargetChange:i})}],[n,i,s]),u=o.useMemo(()=>[...c||[],...l||[]],[l,c]);return{managementTabItems:c,formTabItems:l,tabItems:u}}function Zi({form:n,activeTab:t,onTabChange:a,onConfigFileSwitch:r,onJsonEditorOpen:i,onConfigApplied:s,onTargetChange:c}){const{tabItems:l}=Yi({form:n,onConfigFileSwitch:r,onJsonEditorOpen:i,onConfigApplied:s,onTargetChange:c});return e.jsx(w,{form:n,layout:"vertical",children:e.jsx(Kt,{activeKey:t,onChange:a,items:l})})}function ea({visible:n,configPreview:t,onClose:a}){const{t:r}=H(),i=()=>{navigator.clipboard.writeText(t),V.success(r("config.configCopied"))};return e.jsx(cn,{title:r("config.previewConfig"),open:n,onCancel:a,footer:[e.jsx(R,{icon:e.jsx(ln,{}),onClick:i,children:r("common.copy")},"copy"),e.jsx(R,{onClick:a,children:r("common.close")},"close")],width:800,children:e.jsx(qn,{value:t,readOnly:!0,language:"json",minHeight:400,maxHeight:600})})}function xa(){const{t:n}=H(),{activeTab:t,setActiveTab:a}=$i(),{previewVisible:r,jsonEditorVisible:i,editingConfigFile:s,openPreview:c,closePreview:l,openJsonEditor:u,closeJsonEditor:m}=Ti(),{form:d,config:g,isLoading:f,isUpdating:v,isValidating:j,handleSave:x,handleValidate:S,handleTargetChange:h,getConfigPreview:y,refreshConfig:E}=Si(),{handleExportConfig:p,handleImportConfig:_,handleCopyConfig:O,handleConfigFileSwitch:$,handleConfigApplied:P,isImporting:C}=Di(g),{configFiles:k,refetch:D}=Ve();if(f)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"48px 0"},children:e.jsx($t,{})});const A=g?._meta?.configPathRelative??g?._meta?.configPath??n("config.unknown");return e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:16,width:"100%",display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:16,flexWrap:"wrap"},children:[e.jsx(_i,{currentConfigPath:A,configFiles:k,onConfigFileSwitch:$,refetchConfigFiles:D}),e.jsx(Oi,{onRefresh:E,onPreview:c,onExport:p,onImport:_,onCopy:()=>O(y()),onValidate:S,onSave:x,isValidating:j,isUpdating:v,isImporting:C})]}),e.jsx(Zi,{form:d,activeTab:t,onTabChange:a,onConfigFileSwitch:$,onJsonEditorOpen:u,onConfigApplied:P,onTargetChange:h}),e.jsx(ea,{visible:r,configPreview:y(),onClose:l}),i&&s&&e.jsx(Un,{visible:i,filename:s,onClose:m,onConfigFileSwitch:$})]})}export{xa as default};
16
+ //# sourceMappingURL=Config-DRElCeDC.js.map
@@ -0,0 +1,2 @@
1
+ import{a as o,R as x,u as p,Q as f,b as S,r as g,s as c,j as s,S as j,B as y,c as w,d as v,e as R}from"./index-DG6kGbYq.js";import{R as u,C as i,a as d}from"./row-_c51T55h.js";import{S as h}from"./index-DarObP-C.js";import{R as m}from"./PictureOutlined-U51jGr2U.js";const b={async getStatsOverview(){return(await o.getStatsOverview()).data.data},async getDownloadStats(t){return(await o.getDownloadStats(t)).data.data},async getTagStats(t){return(await o.getTagStats(t)).data.data},async getAuthorStats(t){return(await o.getAuthorStats(t)).data.data}};function D(t=x.STATS_OVERVIEW){const{data:a,isLoading:e,error:r,refetch:l}=p({queryKey:f.STATS_OVERVIEW,queryFn:()=>b.getStatsOverview(),refetchInterval:t});return{stats:a,isLoading:e,error:r,refetch:l}}function C(){const{t}=S(),{stats:a,isLoading:e,refetch:r}=D(),l=g.useCallback(async()=>{c.loading({content:t("dashboard.refreshingStats"),key:"refresh-stats"});try{await r(),c.success({content:t("dashboard.statsRefreshed"),key:"refresh-stats",duration:2})}catch{c.error({content:t("dashboard.refreshStatsFailed"),key:"refresh-stats",duration:2})}},[r,t]);if(e)return s.jsx(j,{size:"large",style:{display:"block",textAlign:"center",marginTop:50}});const n=a||{totalDownloads:0,illustrations:0,novels:0,recentDownloads:0};return s.jsxs("div",{children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[s.jsx("h2",{style:{margin:0},children:t("dashboard.title")}),s.jsx(y,{icon:s.jsx(w,{}),onClick:l,loading:e,children:t("dashboard.refreshStats")})]}),s.jsxs(u,{gutter:16,style:{marginTop:24},children:[s.jsx(i,{span:8,children:s.jsx(d,{children:s.jsx(h,{title:t("dashboard.totalDownloads"),value:n.totalDownloads,prefix:s.jsx(v,{})})})}),s.jsx(i,{span:8,children:s.jsx(d,{children:s.jsx(h,{title:t("dashboard.illustrations"),value:n.illustrations,prefix:s.jsx(m,{})})})}),s.jsx(i,{span:8,children:s.jsx(d,{children:s.jsx(h,{title:t("dashboard.novels"),value:n.novels,prefix:s.jsx(R,{})})})})]}),s.jsx(u,{gutter:16,style:{marginTop:16},children:s.jsx(i,{span:24,children:s.jsx(d,{title:t("dashboard.recentDownloads"),children:s.jsx("p",{children:t("dashboard.recentDownloadsDesc",{count:n.recentDownloads})})})})})]})}export{C as default};
2
+ //# sourceMappingURL=Dashboard-aqPMquSO.js.map
@@ -0,0 +1,2 @@
1
+ import{r as e,I as a,_ as r}from"./index-DG6kGbYq.js";var l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"}}]},name:"delete",theme:"outlined"},n=function(t,c){return e.createElement(a,r({},t,{ref:c,icon:l}))},h=e.forwardRef(n);export{h as R};
2
+ //# sourceMappingURL=DeleteOutlined-BFmW1oWe.js.map
@@ -0,0 +1,2 @@
1
+ import{r as g,I as G,_ as X,b as C,j as e,d as fe,W as y,Y as oe,B as k,c as Q,Z as D,U as je,S as ye,s as f,Q as U,X as K,a as ae,u as Te}from"./index-DG6kGbYq.js";import{R as W,d as se,u as ke,a as Ce,b as Ie,c as ve}from"./useDownload-BlxvZNEm.js";import{R as re,C as Se,u as De}from"./useConfig-Ds7RpIL1.js";import{a as O,R as be,C as H}from"./row-_c51T55h.js";import{S as B}from"./index-DarObP-C.js";import{R as Z}from"./CheckCircleOutlined-H3DnUyMO.js";import{R as J}from"./CloseCircleOutlined-BFfS5iXd.js";import{u as Re,P as Ae,F as E}from"./useAuth-wCjAOx6S.js";import{T as R}from"./index-_EG4kaKN.js";import{f as b}from"./dateUtils-gQt2uAjS.js";import{D as I}from"./index-Bbsa44oT.js";import{T as F}from"./index-CJln3zA7.js";import{M as Y}from"./index-CDrp3NIf.js";import{R as V}from"./DeleteOutlined-BFmW1oWe.js";import{F as de}from"./useErrorHandler-BOvHue1w.js";import{P as ne}from"./index-CfHs6AUn.js";import{R as $e}from"./ClearOutlined-BpODq7I7.js";import{e as v,t as S}from"./errorCodeTranslator-BqIackMm.js";import"./socket-oqYz9cKb.js";var Me={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"}}]},name:"info-circle",theme:"outlined"},Fe=function(p,m){return g.createElement(G,X({},p,{ref:m,icon:Me}))},q=g.forwardRef(Fe),ze={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"}}]},name:"redo",theme:"outlined"},Oe=function(p,m){return g.createElement(G,X({},p,{ref:m,icon:ze}))},Le=g.forwardRef(Oe),Pe={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372 0-89 31.3-170.8 83.5-234.8l523.3 523.3C682.8 852.7 601 884 512 884zm288.5-137.2L277.2 223.5C341.2 171.3 423 140 512 140c205.4 0 372 166.6 372 372 0 89-31.3 170.8-83.5 234.8z"}}]},name:"stop",theme:"outlined"},He=function(p,m){return g.createElement(G,X({},p,{ref:m,icon:Pe}))},z=g.forwardRef(He);const Be=({total:o,completed:p,failed:m,stopped:n})=>{const{t:l}=C();return e.jsx(O,{style:{marginBottom:16},children:e.jsxs(be,{gutter:16,children:[e.jsx(H,{span:6,children:e.jsx(B,{title:l("download.totalTasks"),value:o,prefix:e.jsx(fe,{})})}),e.jsx(H,{span:6,children:e.jsx(B,{title:l("download.completed"),value:p,valueStyle:{color:"#3f8600"},prefix:e.jsx(Z,{})})}),e.jsx(H,{span:6,children:e.jsx(B,{title:l("download.failed"),value:m,valueStyle:{color:"#cf1322"},prefix:e.jsx(J,{})})}),e.jsx(H,{span:6,children:e.jsx(B,{title:l("download.stopped"),value:n,valueStyle:{color:"#8c8c8c"},prefix:e.jsx(z,{})})})]})})},{Text:$}=R,Ee=({hasActiveTask:o,onStartClick:p,onRunAllClick:m,onStopClick:n,isStarting:l,isRunningAll:s,isStopping:d,storage:i,onRefreshConfig:u})=>{const{t}=C(),{authenticated:w}=Re(),r=!w,h=t("common.loginRequired"),a=i?.illustrationDirectory||(i?.downloadDirectory?`${i.downloadDirectory}/illustrations`:"./downloads/illustrations"),c=i?.novelDirectory||(i?.downloadDirectory?`${i.downloadDirectory}/novels`:"./downloads/novels");return e.jsxs(O,{title:e.jsxs(y,{children:[e.jsx(q,{}),e.jsx("span",{children:t("download.taskOperations")})]}),style:{marginBottom:16},children:[e.jsxs(y,{wrap:!0,children:[e.jsx(oe,{title:r?h:void 0,children:e.jsx(k,{type:"primary",size:"large",icon:e.jsx(re,{}),onClick:p,disabled:o||r,loading:l,children:t("download.startDownload")})}),e.jsx(oe,{title:r?h:void 0,children:e.jsx(k,{size:"large",icon:e.jsx(Q,{}),onClick:m,disabled:o||r,loading:s,children:t("download.downloadAll")})}),e.jsx(k,{danger:!0,size:"large",icon:e.jsx(z,{}),onClick:n,disabled:!o,loading:d,children:t("download.stopCurrent")})]}),o&&e.jsx(D,{message:t("download.hasActiveTask"),description:t("download.hasActiveTaskDesc"),type:"info",showIcon:!0,style:{marginTop:16}}),i&&e.jsx(D,{message:e.jsxs(y,{children:[e.jsx("span",{children:t("download.fileSavePath")}),u&&e.jsx(k,{type:"text",size:"small",icon:e.jsx(Q,{}),onClick:u,title:t("download.refreshPath")})]}),description:e.jsxs(y,{direction:"vertical",size:"small",style:{width:"100%"},children:[e.jsxs($,{children:[e.jsx($,{strong:!0,children:t("download.illustrationPath")}),a]}),e.jsxs($,{children:[e.jsx($,{strong:!0,children:t("download.novelPath")}),c]}),e.jsx($,{type:"secondary",style:{fontSize:"12px"},children:t("download.pathTip")})]}),type:"info",showIcon:!0,style:{marginTop:16}})]})},_e=({logs:o,isRunning:p=!1})=>{const{t:m}=C(),n=g.useRef(null);if(g.useEffect(()=>{n.current&&o.length>0&&n.current.scrollIntoView({behavior:"smooth"})},[o]),!o||o.length===0)return null;const l={error:"#ff4d4f",warn:"#faad14",info:"#1890ff",debug:"#8c8c8c"};return e.jsx("div",{style:{marginTop:16},children:e.jsx(Se,{items:[{key:"logs",label:e.jsxs(y,{children:[e.jsx(q,{}),e.jsxs("span",{children:[m("download.realtimeLogs")," (",o.length," ",m("download.entries"),")"]})]}),children:e.jsxs("div",{style:{maxHeight:"400px",overflowY:"auto",backgroundColor:"#1f1f1f",padding:"12px",borderRadius:"4px",fontFamily:"monospace",fontSize:"12px",lineHeight:"1.6"},children:[o.map((s,d)=>{const i=b(s.timestamp,{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsxs("div",{style:{marginBottom:"4px",color:l[s.level]||"#ffffff"},children:[e.jsxs("span",{style:{color:"#8c8c8c",marginRight:"8px"},children:["[",i,"]"]}),e.jsxs("span",{style:{color:l[s.level]||"#ffffff",marginRight:"8px",fontWeight:"bold"},children:["[",s.level.toUpperCase(),"]"]}),e.jsx("span",{children:s.message})]},d)}),e.jsx("div",{ref:n})]})}],defaultActiveKey:p?["logs"]:[]})})},{Text:N}=R,qe=({task:o,logs:p,onStop:m,isStopping:n})=>{const{t:l}=C(),s=i=>{const u={running:{color:"processing",icon:e.jsx(W,{}),text:l("download.statusRunning")},completed:{color:"success",icon:e.jsx(Z,{}),text:l("download.statusCompleted")},failed:{color:"error",icon:e.jsx(J,{}),text:l("download.statusFailed")},stopped:{color:"default",icon:e.jsx(z,{}),text:l("download.statusStopped")}},t=u[i]||u.running;return t?e.jsx(F,{color:t.color,icon:t.icon,children:t.text}):null},d=(i,u)=>{const t=new Date(i).getTime(),w=u?new Date(u).getTime():Date.now(),r=Math.floor((w-t)/1e3);if(r<60)return`${r} ${l("download.seconds")}`;if(r<3600){const h=Math.floor(r/60),a=r%60;return`${h} ${l("download.minutes")} ${a} ${l("download.seconds")}`}else{const h=Math.floor(r/3600),a=Math.floor(r%3600/60);return`${h} ${l("download.hours")} ${a} ${l("download.minutes")}`}};return e.jsxs(O,{title:e.jsxs(y,{children:[e.jsx(W,{}),e.jsx("span",{children:l("download.currentTask")})]}),style:{marginBottom:16},extra:e.jsx(k,{danger:!0,icon:e.jsx(z,{}),onClick:m,loading:n,children:l("download.stopTask")}),children:[e.jsxs(I,{column:2,bordered:!0,children:[e.jsx(I.Item,{label:l("download.taskId"),span:1,children:e.jsx(N,{code:!0,children:o.taskId})}),e.jsx(I.Item,{label:l("download.status"),span:1,children:s(o.status)}),e.jsx(I.Item,{label:l("download.startTime"),span:1,children:b(o.startTime)}),e.jsx(I.Item,{label:l("download.duration"),span:1,children:e.jsx(N,{strong:!0,children:d(new Date(o.startTime),o.endTime?new Date(o.endTime):void 0)})}),o.progress&&e.jsxs(I.Item,{label:l("download.progress"),span:2,children:[e.jsx(Ae,{percent:Math.round(o.progress.current/o.progress.total*100),status:o.status==="running"?"active":"success",format:()=>`${o.progress?.current||0} / ${o.progress?.total||0}`}),o.progress.message&&e.jsx(N,{type:"secondary",style:{display:"block",marginTop:8},children:o.progress.message})]}),o.endTime&&e.jsx(I.Item,{label:l("download.endTime"),span:2,children:b(o.endTime)}),o.error&&e.jsx(I.Item,{label:l("download.errorInfo"),span:2,children:e.jsx(D,{message:o.error,type:"error",showIcon:!0})})]}),p&&p.length>0&&e.jsx(_e,{logs:p,isRunning:o.status==="running"})]})},{Text:_}=R,Ke=({tasks:o,hasActiveTask:p,onRefresh:m,onResume:n,onDelete:l,onDeleteAll:s,isResuming:d,isDeleting:i,isDeletingAll:u})=>{const{t}=C();if(!o||o.length===0)return null;const w=[{title:t("download.tag"),dataIndex:"tag",key:"tag",width:150,render:r=>e.jsx(_,{strong:!0,children:r})},{title:t("download.type"),dataIndex:"type",key:"type",width:100,render:r=>e.jsx(F,{color:r==="illustration"?"blue":"purple",children:t(r==="illustration"?"download.typeIllustration":"download.typeNovel")})},{title:t("download.incompleteStatus"),dataIndex:"status",key:"status",width:120,render:r=>{const a={failed:{color:"error",text:t("download.statusFailed")},partial:{color:"warning",text:t("download.statusPartial")}}[r]||{color:"default",text:r};return e.jsx(F,{color:a.color,children:a.text})}},{title:t("download.errorMessage"),dataIndex:"message",key:"message",ellipsis:{showTitle:!1},width:300,render:r=>{if(!r)return e.jsx(_,{type:"secondary",children:"-"});const h=r.toLowerCase();let a=null;return h.includes("401")||h.includes("unauthorized")?a=t("download.error401"):h.includes("403")||h.includes("forbidden")?a=t("download.error403"):h.includes("timeout")||h.includes("timed out")?a=t("download.errorTimeout"):h.includes("failed after")&&(a=t("download.errorRetries")),e.jsxs("div",{children:[e.jsx(_,{type:"danger",ellipsis:{tooltip:r},children:r}),a&&e.jsx("div",{style:{marginTop:4},children:e.jsxs(_,{type:"secondary",style:{fontSize:"12px"},children:["💡 ",a]})})]})}},{title:t("download.executedAt"),dataIndex:"executedAt",key:"executedAt",width:180,render:r=>b(r)},{title:t("download.actions"),key:"action",width:150,fixed:"right",render:(r,h)=>e.jsxs(y,{children:[e.jsx(k,{type:"link",icon:e.jsx(Le,{}),onClick:()=>n(h.tag,h.type),disabled:p||d,loading:d,children:t("download.resumeDownload")}),e.jsx(k,{type:"link",danger:!0,icon:e.jsx(V,{}),onClick:()=>{Y.confirm({title:t("download.confirmDelete"),content:t("download.confirmDeleteDesc",{tag:h.tag,type:h.type==="illustration"?t("download.typeIllustration"):t("download.typeNovel")}),okText:t("common.delete"),okType:"danger",cancelText:t("common.cancel"),onOk:()=>l(h.id)})},disabled:i,loading:i,children:t("download.deleteTask")})]})}];return e.jsxs(O,{title:e.jsxs(y,{children:[e.jsx(q,{}),e.jsx("span",{children:t("download.incompleteTasks")})]}),style:{marginBottom:16},extra:e.jsxs(y,{children:[e.jsx(k,{size:"small",icon:e.jsx(Q,{}),onClick:m,children:t("download.refreshList")}),e.jsx(k,{size:"small",danger:!0,icon:e.jsx(V,{}),onClick:()=>{Y.confirm({title:t("download.confirmDeleteAll"),content:t("download.confirmDeleteAllDesc",{count:o.length}),okText:t("common.delete"),okType:"danger",cancelText:t("common.cancel"),onOk:s})},loading:u,disabled:u,children:t("download.deleteAll")})]}),children:[e.jsx(D,{message:t("download.incompleteTasksFound",{count:o.length}),description:t("download.incompleteTasksDesc"),type:"warning",showIcon:!0,style:{marginBottom:16}}),e.jsx(de,{columns:w,dataSource:o,rowKey:"id",pagination:{pageSize:10,showSizeChanger:!0,showTotal:r=>t("download.totalEntries",{total:r})},size:"small",scroll:{x:800}})]})},{Text:M}=R,Ne=({tasks:o,isLoading:p,calculateDuration:m})=>{const{t:n}=C(),l=je(),[s,d]=g.useState(null),[i,u]=g.useState(!1),t=async a=>{try{d(a),await se.deleteTaskHistory(a),f.success(n("download.deleteTaskHistorySuccess")),l.invalidateQueries({queryKey:U.DOWNLOAD_STATUS()})}catch(c){const x=c?.response?.data?.data?.message||c?.message||n("download.deleteTaskHistoryFailed");f.error(x)}finally{d(null)}},w=async()=>{try{u(!0);const a=await se.deleteAllTaskHistory();f.success(n("download.deleteAllTaskHistorySuccess",{count:a.deletedCount})),l.invalidateQueries({queryKey:U.DOWNLOAD_STATUS()})}catch(a){const c=a?.response?.data?.data?.message||a?.message||n("download.deleteAllTaskHistoryFailed");f.error(c)}finally{u(!1)}},r=a=>{const c={running:{color:"processing",icon:e.jsx(W,{}),text:n("download.statusRunning")},completed:{color:"success",icon:e.jsx(Z,{}),text:n("download.statusCompleted")},failed:{color:"error",icon:e.jsx(J,{}),text:n("download.statusFailed")},stopped:{color:"default",icon:e.jsx(z,{}),text:n("download.statusStopped")}},x=c[a]||c.running;return x?e.jsx(F,{color:x.color,icon:x.icon,children:x.text}):null},h=[{title:n("download.taskId"),dataIndex:"taskId",key:"taskId",width:120,render:a=>e.jsxs(M,{code:!0,children:[a.slice(0,8),"..."]})},{title:n("download.status"),dataIndex:"status",key:"status",width:100,render:a=>r(a)},{title:n("download.duration"),key:"duration",width:120,render:(a,c)=>m(new Date(c.startTime),c.endTime?new Date(c.endTime):void 0)},{title:n("download.startTime"),dataIndex:"startTime",key:"startTime",width:180,render:a=>b(a)},{title:n("download.endTime"),dataIndex:"endTime",key:"endTime",width:180,render:a=>b(a)},{title:n("download.errorInfo"),dataIndex:"error",key:"error",ellipsis:!0,render:a=>a?e.jsx(M,{type:"danger",ellipsis:{tooltip:a},children:a}):e.jsx(M,{type:"secondary",children:"-"})},{title:n("download.actions"),key:"actions",width:100,fixed:"right",render:(a,c)=>e.jsx(ne,{title:n("download.deleteTaskHistoryConfirm"),description:n("download.deleteTaskHistoryConfirmDesc",{taskId:c.taskId.slice(0,8)}),onConfirm:()=>t(c.taskId),okText:n("common.confirm"),cancelText:n("common.cancel"),okButtonProps:{danger:!0},children:e.jsx(k,{type:"link",danger:!0,size:"small",icon:e.jsx(V,{}),loading:s===c.taskId,disabled:c.status==="running",children:n("common.delete")})})}];return e.jsx(O,{title:e.jsxs(y,{children:[e.jsx(q,{}),e.jsx("span",{children:n("download.taskHistory")})]}),extra:o&&o.length>0?e.jsx(ne,{title:n("download.deleteAllTaskHistoryConfirm"),description:n("download.deleteAllTaskHistoryConfirmDesc",{count:o.length}),onConfirm:w,okText:n("common.confirm"),cancelText:n("common.cancel"),okButtonProps:{danger:!0},children:e.jsx(k,{danger:!0,size:"small",icon:e.jsx($e,{}),loading:i,children:n("download.deleteAll")})}):null,children:p?e.jsxs("div",{style:{textAlign:"center",padding:"40px 0"},children:[e.jsx(ye,{size:"large"}),e.jsx("div",{style:{marginTop:16},children:e.jsx(M,{type:"secondary",children:n("download.loadingHistory")})})]}):o&&o.length>0?e.jsx(de,{columns:h,dataSource:o,rowKey:"taskId",pagination:{pageSize:10,showSizeChanger:!0,showTotal:a=>n("download.taskRecords",{total:a}),pageSizeOptions:["10","20","50","100"]},size:"middle",scroll:{x:1e3}}):e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:e.jsx(M,{type:"secondary",children:n("download.noHistory")})})})},{Text:le}=R,Qe=({open:o,onCancel:p,onFinish:m,isSubmitting:n,configFiles:l=[],targets:s=[]})=>{const{t:d}=C(),[i]=E.useForm(),u=()=>{i.resetFields(),p()};return e.jsxs(Y,{title:e.jsxs(y,{children:[e.jsx(re,{}),e.jsx("span",{children:d("download.startDownloadModal")})]}),open:o,onCancel:u,onOk:()=>i.submit(),confirmLoading:n,okText:d("common.start"),cancelText:d("common.cancel"),width:600,children:[e.jsx(D,{message:d("download.startDownloadTip"),description:d("download.startDownloadTipDesc"),type:"info",showIcon:!0,style:{marginBottom:24}}),e.jsxs(E,{form:i,onFinish:m,layout:"vertical",children:[e.jsx(E.Item,{name:"configPaths",label:d("download.selectConfigFiles"),tooltip:d("download.selectConfigFilesTooltip"),extra:d("download.selectConfigFilesExtra"),children:e.jsx(K,{mode:"multiple",placeholder:d("download.selectConfigFilesPlaceholder"),allowClear:!0,size:"large",showSearch:!0,filterOption:(t,w)=>w?.label?.toLowerCase().includes(t.toLowerCase())||!1,options:l.map(t=>({label:`${t.filename}${t.isActive?` (${d("config.activeConfig")})`:""}`,value:t.path}))})}),e.jsx(E.Item,{name:"targetId",label:d("download.selectTarget"),tooltip:d("download.selectTargetTooltip"),extra:d("download.selectTargetExtra"),children:e.jsx(K,{placeholder:d("download.selectTargetPlaceholder"),allowClear:!0,size:"large",showSearch:!0,filterOption:(t,w)=>{const r=w?.children;return(typeof r=="string"?r:String(r||"")).toLowerCase().includes(t.toLowerCase())},children:s.map((t,w)=>e.jsx(K.Option,{value:w.toString(),children:e.jsxs(y,{children:[e.jsx(F,{color:t.type==="illustration"?"blue":"purple",children:t.type==="illustration"?d("download.typeIllustration"):d("download.typeNovel")}),e.jsx(le,{strong:!0,children:t.tag||`Target ${w+1}`}),t.limit&&e.jsxs(le,{type:"secondary",children:["(",d("download.limit"),": ",t.limit," ",d("download.entries"),")"]})]})},w))})}),s.length===0&&e.jsx(D,{message:d("download.noTargetsFound"),description:d("download.noTargetsFoundDesc"),type:"warning",showIcon:!0})]})]})};function Ue(o,p,m,n,l){const{t:s}=C(),[d,i]=g.useState(!1),u=g.useCallback(async c=>{try{await o({targetId:c.targetId,configPaths:c.configPaths}),f.success(s("download.taskStarted")),i(!1)}catch(x){const{errorCode:j,message:T}=v(x);f.error(S(j,s,void 0,T||s("download.startFailed")))}},[o,s]),t=g.useCallback(async c=>{try{await p(c),f.success(s("download.taskStopped"))}catch(x){const{errorCode:j,message:T}=v(x);f.error(S(j,s,void 0,T||s("download.stopFailed")))}},[p,s]),w=g.useCallback(()=>{ae.runAllDownloads().then(()=>{f.success(s("download.allTargetsStarted"))}).catch(c=>{const{errorCode:x,message:j}=v(c);f.error(S(x,s,void 0,j||s("download.startFailed")))})},[s]),r=g.useCallback(async(c,x)=>{try{await m({tag:c,type:x}),f.success(s("download.taskResumedWithTag",{tag:c,type:s(x==="illustration"?"download.typeIllustration":"download.typeNovel")}))}catch(j){const{errorCode:T,message:A,params:L}=v(j);f.error(S(T,s,L,A||s("download.resumeFailed")))}},[m,s]),h=g.useCallback(async c=>{try{await n(c),f.success(s("download.incompleteTaskDeleted"))}catch(x){const{errorCode:j,message:T,params:A}=v(x);f.error(S(j,s,A,T||s("download.deleteFailed")))}},[n,s]),a=g.useCallback(async()=>{try{const x=(await l())?.deletedCount||0;x===0?f.info(s("download.noIncompleteTasks")):f.success(s("download.allIncompleteTasksDeleted",{count:x}))}catch(c){const{errorCode:x,message:j,params:T}=v(c);x?f.error(S(x,s,T,j||s("download.deleteAllFailed"))):f.error(j||s("download.deleteAllFailed")),console.error("Delete all incomplete tasks error:",c)}},[l,s]);return{showStartModal:d,setShowStartModal:i,handleStart:u,handleStop:t,handleRunAll:w,handleResume:r,handleDelete:h,handleDeleteAll:a}}function We(o){const{t:p}=C(),m=g.useMemo(()=>{const l=o||[],s=l.filter(u=>u.status==="completed").length,d=l.filter(u=>u.status==="failed").length,i=l.filter(u=>u.status==="stopped").length;return{total:l.length,completed:s,failed:d,stopped:i}},[o]),n=g.useCallback((l,s)=>{const d=new Date(l).getTime(),i=s?new Date(s).getTime():Date.now(),u=Math.floor((i-d)/1e3);if(u<60)return`${u} ${p("download.seconds")}`;if(u<3600){const t=Math.floor(u/60),w=u%60;return`${t} ${p("download.minutes")} ${w} ${p("download.seconds")}`}else{const t=Math.floor(u/3600),w=Math.floor(u%3600/60);return`${t} ${p("download.hours")} ${w} ${p("download.minutes")}`}},[p]);return{taskStats:m,calculateDuration:n}}const{Title:Ye,Paragraph:Ve}=R;function xt(){const{t:o}=C(),{startAsync:p,isStarting:m,stopAsync:n,isStopping:l}=ke(),{isLoading:s,hasActiveTask:d,activeTask:i,allTasks:u}=Ce(void 0,2e3),t=i?.taskId,{logs:w}=Ie(t,void 0,2e3),{tasks:r,refetch:h,resumeAsync:a,deleteAsync:c,deleteAllAsync:x,isResuming:j,isDeleting:T,isDeletingAll:A}=ve(),{config:L,refetch:ie}=De(),{data:ce}=Te({queryKey:U.CONFIG_FILES,queryFn:()=>ae.listConfigFiles()}),{showStartModal:ue,setShowStartModal:ee,handleStart:pe,handleStop:te,handleRunAll:me,handleResume:he,handleDelete:xe,handleDeleteAll:we}=Ue(p,n,a,c,x),{taskStats:P,calculateDuration:ge}=We(u);return e.jsxs("div",{children:[e.jsx(Ye,{level:2,children:o("download.title")}),e.jsx(Ve,{type:"secondary",style:{marginBottom:24},children:o("download.description")}),e.jsx(Be,{total:P.total,completed:P.completed,failed:P.failed,stopped:P.stopped}),e.jsx(Ee,{hasActiveTask:d,onStartClick:()=>ee(!0),onRunAllClick:me,onStopClick:()=>i?.taskId&&te(i.taskId),isStarting:m,isRunningAll:!1,isStopping:l,storage:L?.storage,onRefreshConfig:ie}),i&&e.jsx(qe,{task:i,logs:w,onStop:()=>i.taskId&&te(i.taskId),isStopping:l}),r&&r.length>0&&e.jsx(Ke,{tasks:r,hasActiveTask:d,onRefresh:h,onResume:he,onDelete:xe,onDeleteAll:we,isResuming:j,isDeleting:T,isDeletingAll:A}),e.jsx(Ne,{tasks:u||[],isLoading:s,calculateDuration:ge}),e.jsx(Qe,{open:ue,onCancel:()=>ee(!1),onFinish:pe,isSubmitting:m,configFiles:ce?.data?.data||[],targets:L?.targets||[]})]})}export{xt as default};
2
+ //# sourceMappingURL=Download-DCKDU51K.js.map