dsh-xdpool 3.0.5 → 3.0.7

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.
package/lib/client.js CHANGED
@@ -78,7 +78,6 @@ window.__ModuleLoader__.load({
78
78
  const POOL_AUTOCLAW_CN_SESSION_PATH = "/plugins/dsh-xdpool/autoclaw-cn/session";
79
79
  const POOL_AUTOCLAW_CN_WALLET_PATH = "/plugins/dsh-xdpool/autoclaw-cn/wallet";
80
80
  const POOL_UPDATE_INSTALL_PATH = "/plugins/dsh-xdpool/update/install";
81
- const POOL_CREDIT_RESERVE_PATH = "/plugins/dsh-xdpool/accounts/credit-reserve";
82
81
  const POOL_CREDITS_SPEND_PATH = "/plugins/dsh-xdpool/credits/spend";
83
82
  const POOL_ACCOUNT_PREFER_PATH = "/plugins/dsh-xdpool/accounts/preferred";
84
83
  const POOL_AGGREGATE_PATH = "/plugins/dsh-xdpool/aggregate";
@@ -117,6 +116,136 @@ window.__ModuleLoader__.load({
117
116
  //#endregion
118
117
  //#region src/client/avatar.ts
119
118
  const POOL_CARD_AVATAR = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAQDAwQDAwQEAwQFBAQFBgoHBgYGBg0JCggKDw0QEA8NDw4RExgUERIXEg4PFRwVFxkZGxsbEBQdHx0aHxgaGxr/2wBDAQQFBQYFBgwHBwwaEQ8RGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhr/wAARCACAAIADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjp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PrXn1tJHZRfunmXiSSTS9U8gqNtrdHGT/A3I/Q4/CsrxXZ22r6dIssavHIuGUgEEGrP7QsTafpZ16Cf7KbTDTPzt2Z7+3+NcJ4e8Uvq9pCJI0y6gqwckEeopSfNFMuK5ZNHzp8avg3f+EJ5td0S3Nx4eugJHMS/8echHzKwHRCc4bpzg9OfFYWOGVVznv6V9j+PPj1o/h/T7zTNKlTVtXIaNoUGYkJBGGboR6gZ9K+Tl8mJSsmCzHLkDqa6qLk4+8ctVRUtCpbxNNOAAyqBhWHYVoLC8Y43/APAjmqht13s0B/dkdFPQ0ixsHwXlwfRjxXQYt6GrEVwMqRjrxUcsgKk9F7E1UCOBjzXx9eaJEDEb2J2njJ60EMrXV0BwB1rO6mprly0nzLtx0FQ0FpWCtDRtGudcvUtrNev33b7qD1NZ9ejfDDT/ADZJ5jJksdqpngf7R96Bnq/wu00+G0FpE7TW6yZLtwd5xu4HavpvwvrsjKkCMFOBjdXzr4VkNje/ZpkUsTu3lsd+v8q9i0d3jmiNvKuwkZye9Te4juPHUhm8J6mkoIk8gsDnOCvI/lVr4a+IFutLs5CeSgVhmom2anp8ltdsGSRChOR3H/1682+F+qPZ+dYSPh7eVosZ7q2D/KuOuup1UHuj2f4i6JF4o8N6jptygkhvLZ4WB9GUivzCude8R6cJ9Fn1i4S2sXe22RvjIVsY3DnHHrX6hx3w1CzaJpArMpUNnpnjNflXrdnPpWs6np96Ct1a3UsMobqGVyD/ACqcPrJplYh2s0VbgCQl4vvKMDHYjtShxOik8kiqkshjl3Rn7w5HaliuVACsu0e3Negcdkwkja2O+JsrViOdnjVgx3d+aaJVOMEGoARFJlHAB6igltFovLj79QF8ACRufU01rkYOOarFi3Uk0xctx0r72z6cCmUUUjQ//9k=";
119
+ //#endregion
120
+ //#region src/client/account-card.tsx
121
+ const CREDITS = new Intl.NumberFormat();
122
+ function formatExpiry(value) {
123
+ if (value === void 0) return void 0;
124
+ const at = Date.parse(value);
125
+ if (!Number.isFinite(at)) return void 0;
126
+ return new Intl.DateTimeFormat(void 0, {
127
+ month: "2-digit",
128
+ day: "2-digit",
129
+ hour: "2-digit",
130
+ minute: "2-digit",
131
+ hour12: false
132
+ }).format(new Date(at));
133
+ }
134
+ function AccountCard({ account, serving = false, busy = false, claiming = false, t, onClaim, onToggle, onPrefer, onIgnore }) {
135
+ const total = account.credits?.total;
136
+ const expiry = formatExpiry(account.expiresAt);
137
+ const checkin = account.checkin;
138
+ const claimed = checkin?.todayCheckedIn === true;
139
+ return (0, react_jsx_runtime.jsxs)("article", {
140
+ className: "xdp-acct",
141
+ "data-serving": serving ? "true" : void 0,
142
+ children: [
143
+ (0, react_jsx_runtime.jsx)("header", {
144
+ className: "xdp-acct-head",
145
+ children: (0, react_jsx_runtime.jsx)("span", {
146
+ className: "xdp-acct-name",
147
+ title: account.nickname ?? account.label,
148
+ children: account.nickname ?? account.label
149
+ })
150
+ }),
151
+ !serving && !account.disabled && !account.cooling ? null : (0, react_jsx_runtime.jsxs)("div", {
152
+ className: "xdp-acct-badges",
153
+ children: [
154
+ serving ? (0, react_jsx_runtime.jsx)("span", {
155
+ className: "xdp-acct-badge",
156
+ children: t?.("row.currentAccount") ?? "当前使用"
157
+ }) : null,
158
+ account.disabled ? (0, react_jsx_runtime.jsx)("span", {
159
+ className: "xdp-acct-badge is-off",
160
+ children: "已停用"
161
+ }) : null,
162
+ account.cooling ? (0, react_jsx_runtime.jsx)("span", {
163
+ className: "xdp-acct-badge is-warn",
164
+ children: "冷却中"
165
+ }) : null
166
+ ]
167
+ }),
168
+ (0, react_jsx_runtime.jsxs)("p", {
169
+ className: "xdp-acct-meta",
170
+ children: [expiry === void 0 ? "令牌有效期未知" : `令牌到期 ${expiry}`, account.lastUsedAt === void 0 ? "" : ` · 上次使用 ${formatExpiry(account.lastUsedAt) ?? ""}`]
171
+ }),
172
+ (0, react_jsx_runtime.jsxs)("div", {
173
+ className: "xdp-acct-credits",
174
+ children: [
175
+ (0, react_jsx_runtime.jsx)("strong", { children: total === void 0 ? "—" : CREDITS.format(total) }),
176
+ (0, react_jsx_runtime.jsx)("span", { children: t?.("row.creditsTotal") ?? "积分" }),
177
+ checkinError(account)
178
+ ]
179
+ }),
180
+ (0, react_jsx_runtime.jsxs)("footer", {
181
+ className: "xdp-acct-actions",
182
+ children: [
183
+ (0, react_jsx_runtime.jsx)("button", {
184
+ type: "button",
185
+ className: account.preferred ? "tiny is-on" : "tiny",
186
+ "aria-pressed": account.preferred,
187
+ disabled: busy,
188
+ title: account.preferred ? t?.("row.accountPreferClearHint") ?? "取消优先,交回按使用方式选号" : t?.("row.accountPreferHint") ?? "让它排在前面,仍然健康时才用",
189
+ onClick: () => {
190
+ onPrefer(account.preferred ? null : account.id);
191
+ },
192
+ children: account.preferred ? t?.("row.accountPreferOn") ?? "优先" : t?.("row.accountPrefer") ?? "优先"
193
+ }),
194
+ (0, react_jsx_runtime.jsx)("button", {
195
+ type: "button",
196
+ className: "tiny",
197
+ disabled: busy,
198
+ onClick: () => {
199
+ onToggle(!account.disabled);
200
+ },
201
+ children: account.disabled ? "启用" : "停用"
202
+ }),
203
+ checkin === void 0 ? null : (0, react_jsx_runtime.jsx)("button", {
204
+ type: "button",
205
+ className: "tiny",
206
+ disabled: claiming || claimed || checkin.active !== true,
207
+ title: checkin.active === true ? void 0 : "这个账号当前没有签到活动",
208
+ onClick: onClaim,
209
+ children: claimed ? t?.("row.checkinClaimed") ?? "今日已签" : claiming ? t?.("row.checkinClaiming") ?? "签到中…" : t?.("row.checkinClaim") ?? "签到"
210
+ }),
211
+ (0, react_jsx_runtime.jsx)("button", {
212
+ type: "button",
213
+ className: "tiny",
214
+ disabled: busy,
215
+ title: "把这个账号从池子里永久移除(可在「已忽略」里恢复)",
216
+ onClick: onIgnore,
217
+ children: "移出池子"
218
+ })
219
+ ]
220
+ })
221
+ ]
222
+ });
223
+ }
224
+ function checkinError(account) {
225
+ if (account.checkinError === void 0) return null;
226
+ return (0, react_jsx_runtime.jsx)("span", {
227
+ className: "xdp-acct-warn",
228
+ title: account.checkinError,
229
+ children: "签到不可用"
230
+ });
231
+ }
232
+ const ACCOUNT_CARD_CSS = `
233
+ .xdp-accts{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:var(--s3)}
234
+ .xdp-acct{display:flex;flex-direction:column;gap:var(--s2);min-width:0;padding:var(--s3);border:1px solid var(--line);border-radius:var(--r-lg);background:var(--surface)}
235
+ .xdp-acct[data-serving="true"]{border-color:var(--accent-line)}
236
+ .xdp-acct .xdp-acct-head{display:block;min-width:0}
237
+ .xdp-acct .xdp-acct-name{display:block;max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--fs-sm);font-weight:600;color:var(--text)}
238
+ .xdp-acct .xdp-acct-badges{display:flex;flex-wrap:wrap;gap:var(--s1)}
239
+ .xdp-acct .xdp-acct-badge{flex:0 0 auto;padding:0 6px;border:1px solid var(--accent-line);border-radius:var(--r-pill);background:var(--accent-dim);color:var(--accent);font-size:var(--fs-xs);line-height:16px;white-space:nowrap}
240
+ .xdp-acct-badge.is-off{border-color:var(--line-2);background:transparent;color:var(--faint)}
241
+ .xdp-acct-badge.is-warn{border-color:color-mix(in oklch, var(--warn) 40%, transparent);background:color-mix(in oklch, var(--warn) 10%, transparent);color:var(--warn)}
242
+ .xdp-acct-meta{margin:0;font-size:var(--fs-xs);line-height:1.5;color:var(--faint);font-variant-numeric:tabular-nums;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
243
+ .xdp-acct-credits{display:flex;align-items:baseline;gap:var(--s2);min-width:0;flex-wrap:wrap}
244
+ .xdp-acct-credits strong{font-size:var(--fs-lg);font-weight:600;color:var(--text);font-variant-numeric:tabular-nums}
245
+ .xdp-acct-credits > span{font-size:var(--fs-xs);color:var(--faint)}
246
+ .xdp-acct-warn{font-size:var(--fs-xs);color:var(--warn)}
247
+ .xdp-acct-actions{display:flex;flex-wrap:wrap;gap:var(--s1);padding-top:2px}
248
+ `;
120
249
  //#endregion
121
250
  //#region src/client/nav-icon.ts
122
251
  const POOL_NAV_ICON_PATHS = [{
@@ -140,7 +269,7 @@ window.__ModuleLoader__.load({
140
269
  const POOL_NAV_ICON_MASK_URL = `data:image/svg+xml;utf8,${encodeURIComponent(POOL_NAV_ICON_SVG)}`;
141
270
  //#endregion
142
271
  //#region src/version.ts
143
- const POOL_VERSION = "3.0.5";
272
+ const POOL_VERSION = "3.0.7";
144
273
  function compareVersions(left, right) {
145
274
  const parse = (value) => {
146
275
  const [core, ...rest] = value.trim().replace(/^v/u, "").split("-");
@@ -934,18 +1063,6 @@ window.__ModuleLoader__.load({
934
1063
  select,
935
1064
  tabs
936
1065
  ]);
937
- const closeHostDialog = (0, react.useCallback)(() => {
938
- if (typeof document === "undefined") return;
939
- const candidate = document.querySelector("[role=\"dialog\"]")?.querySelector("[aria-label*=\"lose\" i], [aria-label*=\"关闭\"], [aria-label*=\"ismiss\" i], [data-dismiss]");
940
- if (candidate !== void 0 && candidate !== null) {
941
- candidate.click();
942
- return;
943
- }
944
- window.dispatchEvent(new KeyboardEvent("keydown", {
945
- key: "Escape",
946
- bubbles: true
947
- }));
948
- }, []);
949
1066
  return (0, react_jsx_runtime.jsxs)("div", {
950
1067
  ref: appRef,
951
1068
  className: wide ? "app app-wide" : "app",
@@ -1008,23 +1125,6 @@ window.__ModuleLoader__.load({
1008
1125
  })
1009
1126
  ]
1010
1127
  }),
1011
- (0, react_jsx_runtime.jsx)("button", {
1012
- type: "button",
1013
- className: "app-close",
1014
- "data-testid": "xdpool-close",
1015
- title: t?.("shell.close") ?? "关闭",
1016
- "aria-label": t?.("shell.close") ?? "关闭",
1017
- onClick: closeHostDialog,
1018
- children: (0, react_jsx_runtime.jsx)("svg", {
1019
- viewBox: "0 0 24 24",
1020
- fill: "none",
1021
- stroke: "currentColor",
1022
- strokeWidth: "1.8",
1023
- strokeLinecap: "round",
1024
- "aria-hidden": "true",
1025
- children: (0, react_jsx_runtime.jsx)("path", { d: "M6 6l12 12M18 6L6 18" })
1026
- })
1027
- }),
1028
1128
  pop !== "update" ? null : (0, react_jsx_runtime.jsxs)("div", {
1029
1129
  ref: popRef,
1030
1130
  className: "pop",
@@ -10214,7 +10314,7 @@ window.__ModuleLoader__.load({
10214
10314
  return "签到失败";
10215
10315
  }
10216
10316
  }
10217
- function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, banner }) {
10317
+ function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, banner, regionCards }) {
10218
10318
  const [ownActive, setOwnActive] = (0, react.useState)("");
10219
10319
  const [loginState, setLoginState] = (0, react.useState)(void 0);
10220
10320
  const loginAbort = (0, react.useRef)(void 0);
@@ -10983,16 +11083,18 @@ window.__ModuleLoader__.load({
10983
11083
  }
10984
11084
  };
10985
11085
  if (entries.length === 0 && error === void 0) {
10986
- if (!loading) return (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {});
10987
- return (0, react_jsx_runtime.jsx)("section", {
10988
- className: "dsm-xdpool-cpool",
10989
- "aria-label": t?.("channelpool.title") ?? "Channels",
10990
- children: (0, react_jsx_runtime.jsx)("p", {
10991
- className: "note",
10992
- role: "status",
10993
- children: t?.("channelpool.loading") ?? "Reading scan channels…"
10994
- })
10995
- });
11086
+ if (!(regionCards !== void 0 && !loading)) {
11087
+ if (!loading) return (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {});
11088
+ return (0, react_jsx_runtime.jsx)("section", {
11089
+ className: "dsm-xdpool-cpool",
11090
+ "aria-label": t?.("channelpool.title") ?? "Channels",
11091
+ children: (0, react_jsx_runtime.jsx)("p", {
11092
+ className: "note",
11093
+ role: "status",
11094
+ children: t?.("channelpool.loading") ?? "Reading scan channels…"
11095
+ })
11096
+ });
11097
+ }
10996
11098
  }
10997
11099
  const chosenEntry = entries.find((entry) => entry.channel.id === chosen) ?? entries[0];
10998
11100
  const totalAccounts = entries.reduce((sum, entry) => sum + entry.accounts.length, 0);
@@ -11124,19 +11226,23 @@ window.__ModuleLoader__.load({
11124
11226
  children: (0, react_jsx_runtime.jsxs)("div", {
11125
11227
  className: "mbody",
11126
11228
  style: { paddingTop: "var(--s5)" },
11127
- children: [banner, error === void 0 ? null : (0, react_jsx_runtime.jsxs)("p", {
11128
- className: "hint",
11129
- children: [t?.("channelpool.loadError", { message: error }) ?? `Could not load channels: ${error}`, (0, react_jsx_runtime.jsx)("button", {
11130
- type: "button",
11131
- className: "tiny",
11132
- style: { marginLeft: "auto" },
11133
- onClick: () => {
11134
- setEnabled(new Map());
11135
- load();
11136
- },
11137
- children: t?.("channelpool.retry") ?? "重试"
11138
- })]
11139
- })]
11229
+ children: [
11230
+ banner,
11231
+ regionCards,
11232
+ error === void 0 ? null : (0, react_jsx_runtime.jsxs)("p", {
11233
+ className: "hint",
11234
+ children: [t?.("channelpool.loadError", { message: error }) ?? `Could not load channels: ${error}`, (0, react_jsx_runtime.jsx)("button", {
11235
+ type: "button",
11236
+ className: "tiny",
11237
+ style: { marginLeft: "auto" },
11238
+ onClick: () => {
11239
+ setEnabled(new Map());
11240
+ load();
11241
+ },
11242
+ children: t?.("channelpool.retry") ?? "重试"
11243
+ })]
11244
+ })
11245
+ ]
11140
11246
  })
11141
11247
  })] });
11142
11248
  const { channel, accounts, models, facts, balances, statuses, status } = chosenEntry;
@@ -11243,6 +11349,7 @@ window.__ModuleLoader__.load({
11243
11349
  className: "mbody",
11244
11350
  children: [
11245
11351
  banner,
11352
+ regionCards,
11246
11353
  loginState !== void 0 && loginState.channelId === channel.id && (loginState.phase === "paste" ? (0, react_jsx_runtime.jsxs)("div", {
11247
11354
  className: "banner",
11248
11355
  children: [
@@ -15179,7 +15286,9 @@ window.__ModuleLoader__.load({
15179
15286
  })]
15180
15287
  });
15181
15288
  }
15182
- Object.freeze({
15289
+ //#endregion
15290
+ //#region src/client/region-card.tsx
15291
+ const REGION_CHANNEL_BY_REGION = Object.freeze({
15183
15292
  cn: "buddy",
15184
15293
  global: "workbuddy"
15185
15294
  });
@@ -15200,27 +15309,6 @@ window.__ModuleLoader__.load({
15200
15309
  })
15201
15310
  });
15202
15311
  //#endregion
15203
- //#region src/siblings.ts
15204
- function paidSiblingOf(model, models) {
15205
- let best;
15206
- for (const candidate of models) {
15207
- if (candidate.id === model.id) continue;
15208
- if (candidate.name !== model.name) continue;
15209
- const multiplier = candidate.multiplier;
15210
- if (multiplier === void 0 || multiplier <= 0) continue;
15211
- if (best === void 0 || multiplier < best.multiplier) best = {
15212
- id: candidate.id,
15213
- name: candidate.name,
15214
- multiplier
15215
- };
15216
- }
15217
- return best;
15218
- }
15219
- function paidAlternativeFor(model, models) {
15220
- if (model.multiplier !== 0) return void 0;
15221
- return paidSiblingOf(model, models);
15222
- }
15223
- //#endregion
15224
15312
  //#region src/client/backup-crypto.ts
15225
15313
  const ENCRYPTED_FORMAT = "dsh-xdpool/backup-encrypted";
15226
15314
  const ITERATIONS = 31e4;
@@ -16052,50 +16140,12 @@ window.__ModuleLoader__.load({
16052
16140
  if (value === void 0) return "–";
16053
16141
  return new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(value);
16054
16142
  }
16055
- function formatTime(value) {
16056
- return new Intl.DateTimeFormat(void 0, {
16057
- month: "2-digit",
16058
- day: "2-digit",
16059
- hour: "2-digit",
16060
- minute: "2-digit"
16061
- }).format(new Date(value));
16062
- }
16063
- function formatDateTime(value) {
16064
- if (value === void 0) return "";
16065
- const ms = Date.parse(value);
16066
- if (Number.isNaN(ms)) return value;
16067
- return new Intl.DateTimeFormat(void 0, {
16068
- month: "2-digit",
16069
- day: "2-digit",
16070
- hour: "2-digit",
16071
- minute: "2-digit"
16072
- }).format(new Date(ms));
16073
- }
16074
16143
  const AUTOMATION_POLL_MS = 2e3;
16075
16144
  const AUTOMATION_POLL_ATTEMPTS = 90;
16076
16145
  function hoursOrDefault(configured, fallback) {
16077
16146
  return configured !== void 0 && configured.length > 0 ? [...configured] : [...fallback];
16078
16147
  }
16079
16148
  const REGION_CARDS = ["cn", "global"];
16080
- function formatExpiry(ms) {
16081
- if (ms === void 0 || !Number.isFinite(ms)) return "";
16082
- return new Intl.DateTimeFormat(void 0, {
16083
- month: "2-digit",
16084
- day: "2-digit",
16085
- hour: "2-digit",
16086
- minute: "2-digit",
16087
- hour12: false
16088
- }).format(new Date(ms));
16089
- }
16090
- function daysUntil(ms) {
16091
- if (ms === void 0 || !Number.isFinite(ms)) return void 0;
16092
- return Math.max(0, Math.floor((ms - Date.now()) / 864e5));
16093
- }
16094
- function isExpiringSoon(pack) {
16095
- if (pack.monthly === true) return false;
16096
- const days = daysUntil(pack.expiresAtMs);
16097
- return days !== void 0 && days <= 3;
16098
- }
16099
16149
  function PoolCard({ t, settingsScope }) {
16100
16150
  const settingsWritable = settingsScope?.getSnapshot().writable === true;
16101
16151
  const [sidebarRow, setSidebarRowState] = (0, react.useState)(() => readSidebarRow(settingsScope));
@@ -16460,36 +16510,9 @@ window.__ModuleLoader__.load({
16460
16510
  }
16461
16511
  }
16462
16512
  };
16463
- const saveCreditReserve = async (region, accountId, reserve) => {
16464
- setReserveBusy(accountId);
16465
- setFlash(void 0);
16466
- try {
16467
- const response = await fetch(POOL_CREDIT_RESERVE_PATH, {
16468
- method: "POST",
16469
- headers: {
16470
- "accept": "application/json",
16471
- "content-type": "application/json"
16472
- },
16473
- credentials: "same-origin",
16474
- body: JSON.stringify({
16475
- accountId,
16476
- reserve
16477
- })
16478
- });
16479
- const body = await response.json();
16480
- if (!response.ok) throw new Error(body.error ?? `HTTP ${response.status}`);
16481
- await refresh(region);
16482
- if (mounted.current) setFlash(reserve > 0 ? t?.("row.reserveSaved", { credits: reserve }) ?? `Keeping ${reserve} credits` : t?.("row.reserveCleared") ?? "Reserve cleared");
16483
- return true;
16484
- } catch (cause) {
16485
- if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
16486
- return false;
16487
- } finally {
16488
- if (mounted.current) setReserveBusy(void 0);
16489
- }
16490
- };
16491
16513
  t?.("row.title");
16492
16514
  t?.("row.desc");
16515
+ const showPoolAccounts = selectedChannel === REGION_CHANNEL_BY_REGION.cn || selectedChannel === REGION_CHANNEL_BY_REGION.global;
16493
16516
  return (0, react_jsx_runtime.jsx)(PoolShell, {
16494
16517
  t,
16495
16518
  version: POOL_VERSION,
@@ -16525,49 +16548,47 @@ window.__ModuleLoader__.load({
16525
16548
  children: page === "aggregate" ? (0, react_jsx_runtime.jsx)(AggregatePage, { t }) : page === "channels" ? (0, react_jsx_runtime.jsx)(ChannelsPage, { t }) : page === "ledger" ? (0, react_jsx_runtime.jsx)(LedgerPage, {
16526
16549
  t,
16527
16550
  usage
16528
- }) : page === "routing" ? (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "gateway" ? (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: (0, react_jsx_runtime.jsxs)("div", {
16551
+ }) : page === "routing" ? (0, react_jsx_runtime.jsx)(RoutingPage, { t }) : page === "gateway" ? (0, react_jsx_runtime.jsx)(GatewayPage, { t }) : page === "backup" ? (0, react_jsx_runtime.jsx)(BackupPanel, { t }) : (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: (0, react_jsx_runtime.jsx)("div", {
16529
16552
  className: "dsm-xdpool-regions dsm-xdpool-region-grid",
16530
16553
  style: { display: "contents" },
16531
- children: [["cn", "global"].map((region) => {
16532
- const here = statusOf(region);
16533
- const rows = here?.accounts ?? [];
16534
- if (rows.length === 0) return null;
16535
- return (0, react_jsx_runtime.jsxs)("section", {
16536
- className: "sec dsm-xdpool-accounts",
16537
- children: [(0, react_jsx_runtime.jsx)("div", {
16538
- className: "sec-head",
16539
- children: (0, react_jsx_runtime.jsxs)("span", {
16540
- className: "sec-title",
16541
- children: [region === "cn" ? t?.("row.tabCn") ?? "CN" : t?.("row.tabGlobal") ?? "Global", ` · ${String(rows.length)}`]
16542
- })
16543
- }), (0, react_jsx_runtime.jsx)("div", {
16544
- className: "accts",
16545
- children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountBlock, {
16546
- account,
16547
- models: here?.models ?? [],
16548
- t,
16549
- ...checkinBusyId === void 0 ? {} : { checkinBusyId },
16550
- onClaimCheckin: (id) => {
16551
- claimCheckin(region, id);
16552
- },
16553
- ...accountBusyId === void 0 ? {} : { accountBusyId },
16554
- onToggleDisabled: (id, disabled) => {
16555
- toggleAccountDisabled(region, id, disabled);
16556
- },
16557
- onIgnoreAccount: (id) => {
16558
- setAccountIgnored(region, id, true);
16559
- },
16560
- onPreferAccount: (id) => {
16561
- setPreferredAccount(region, id);
16562
- },
16563
- onSaveCreditReserve: (id, reserve) => saveCreditReserve(region, id, reserve),
16564
- ...reserveBusy === void 0 ? {} : { reserveBusyId: reserveBusy },
16565
- serving: here?.activeAccountId === account.id
16566
- }, account.id))
16567
- })]
16568
- }, region);
16569
- }), (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
16554
+ children: (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
16570
16555
  t,
16556
+ regionCards: showPoolAccounts ? ["cn", "global"].map((region) => {
16557
+ const here = statusOf(region);
16558
+ const rows = here?.accounts ?? [];
16559
+ if (rows.length === 0) return null;
16560
+ return (0, react_jsx_runtime.jsxs)("section", {
16561
+ className: "sec",
16562
+ children: [(0, react_jsx_runtime.jsx)("div", {
16563
+ className: "sec-head",
16564
+ children: (0, react_jsx_runtime.jsxs)("span", {
16565
+ className: "sec-title",
16566
+ children: [region === "cn" ? t?.("row.tabCn") ?? "CN" : t?.("row.tabGlobal") ?? "Global", ` · ${String(rows.length)}`]
16567
+ })
16568
+ }), (0, react_jsx_runtime.jsx)("div", {
16569
+ className: "accts",
16570
+ children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountCard, {
16571
+ account,
16572
+ t,
16573
+ serving: here?.activeAccountId === account.id,
16574
+ ...checkinBusyId === account.id ? { claiming: true } : {},
16575
+ ...accountBusyId === account.id ? { busy: true } : {},
16576
+ onClaim: () => {
16577
+ claimCheckin(region, account.id);
16578
+ },
16579
+ onToggle: (disabled) => {
16580
+ toggleAccountDisabled(region, account.id, disabled);
16581
+ },
16582
+ onPrefer: (id) => {
16583
+ setPreferredAccount(region, id);
16584
+ },
16585
+ onIgnore: () => {
16586
+ setAccountIgnored(region, account.id, true);
16587
+ }
16588
+ }, account.id))
16589
+ })]
16590
+ }, region);
16591
+ }) : void 0,
16571
16592
  active: selectedChannel,
16572
16593
  onAddAccount: () => {
16573
16594
  setPage("channels");
@@ -16588,350 +16609,10 @@ window.__ModuleLoader__.load({
16588
16609
  className: "hint",
16589
16610
  children: t?.("row.error", { message: error }) ?? `Pool status unavailable: ${error}`
16590
16611
  })] })
16591
- })]
16612
+ })
16592
16613
  }) })
16593
16614
  });
16594
16615
  }
16595
- function AccountBlock({ account, models, t, checkinBusyId, onClaimCheckin, accountBusyId, onToggleDisabled, onIgnoreAccount, onPreferAccount, onSaveCreditReserve, reserveBusyId, serving }) {
16596
- const isDisabled = account.disabled === true;
16597
- const isPreferred = account.preferred === true;
16598
- const isCooling = account.cooling === true;
16599
- const isDead = account.credentialDead === true;
16600
- const cooldownUntil = account.cooldownUntil !== void 0 ? Date.parse(account.cooldownUntil) : void 0;
16601
- const modelCooldowns = account.modelCooldowns ?? [];
16602
- const tag = isDead ? {
16603
- text: t?.("row.credentialDeadTag") ?? "Sign-in rejected",
16604
- cls: "pill"
16605
- } : isCooling ? {
16606
- text: t?.("row.cooling") ?? "Cooling",
16607
- cls: "pill"
16608
- } : null;
16609
- return (0, react_jsx_runtime.jsxs)("div", {
16610
- className: isDisabled ? "is-off" : "ch",
16611
- "data-serving": serving === true ? "true" : void 0,
16612
- children: [(0, react_jsx_runtime.jsxs)("div", {
16613
- className: "ch-head",
16614
- children: [
16615
- (0, react_jsx_runtime.jsx)("span", {
16616
- className: "ch-title",
16617
- children: account.label
16618
- }),
16619
- serving === true ? (0, react_jsx_runtime.jsxs)("span", {
16620
- className: "acct-head",
16621
- children: [(0, react_jsx_runtime.jsx)("span", { className: "acct-dot" }), (0, react_jsx_runtime.jsx)("span", {
16622
- className: "acct-name",
16623
- children: t?.("row.currentAccount") ?? "In use now"
16624
- })]
16625
- }) : null,
16626
- tag === null ? null : (0, react_jsx_runtime.jsx)("span", {
16627
- className: tag.cls,
16628
- children: tag.text
16629
- }),
16630
- (0, react_jsx_runtime.jsxs)("button", {
16631
- type: "button",
16632
- className: isPreferred ? "is-on" : "tiny",
16633
- "aria-pressed": isPreferred,
16634
- title: isPreferred ? t?.("row.accountPreferClearHint") ?? "Stop preferring this account; the distribution strategy decides again" : t?.("row.accountPreferHint") ?? "Try this account first while it stays healthy",
16635
- disabled: accountBusyId === account.id || accountBusyId === "none",
16636
- onClick: () => {
16637
- onPreferAccount(isPreferred ? null : account.id);
16638
- },
16639
- children: [(0, react_jsx_runtime.jsx)("span", {
16640
- className: "tiny",
16641
- "aria-hidden": "true",
16642
- children: "★"
16643
- }), isPreferred ? t?.("row.accountPreferOn") ?? "Preferred" : t?.("row.accountPrefer") ?? "Prefer"]
16644
- }),
16645
- (0, react_jsx_runtime.jsxs)("button", {
16646
- type: "button",
16647
- role: "switch",
16648
- "aria-checked": !isDisabled,
16649
- className: isDisabled ? "sw" : "is-on",
16650
- title: t?.("row.accountToggleHint") ?? "Enable this account (uncheck to keep it out of the pool)",
16651
- disabled: accountBusyId === account.id,
16652
- onClick: () => {
16653
- onToggleDisabled(account.id, !isDisabled);
16654
- },
16655
- children: [(0, react_jsx_runtime.jsx)("span", { className: "acct-dot" }), isDisabled ? t?.("row.accountOff") ?? "Disabled" : t?.("row.accountInRotation") ?? "Enabled"]
16656
- }),
16657
- (0, react_jsx_runtime.jsx)("button", {
16658
- type: "button",
16659
- className: "ch-count",
16660
- title: t?.("row.accountIgnoreHint") ?? "Remove this account from the pool for good",
16661
- disabled: accountBusyId === account.id,
16662
- onClick: () => {
16663
- onIgnoreAccount(account.id);
16664
- },
16665
- children: t?.("row.accountIgnore") ?? "Remove"
16666
- })
16667
- ]
16668
- }), (0, react_jsx_runtime.jsxs)("div", {
16669
- className: "ch-titles",
16670
- children: [
16671
- (0, react_jsx_runtime.jsxs)("div", {
16672
- className: "ch-titles",
16673
- children: [
16674
- account.expiresAt !== void 0 ? (0, react_jsx_runtime.jsx)("span", {
16675
- className: "ch-org",
16676
- children: t?.("row.tokenExpiry", { time: formatDateTime(account.expiresAt) }) ?? `token ${formatDateTime(account.expiresAt)}`
16677
- }) : null,
16678
- isCooling && cooldownUntil !== void 0 && !Number.isNaN(cooldownUntil) ? (0, react_jsx_runtime.jsxs)("span", {
16679
- className: "ch-org",
16680
- children: [
16681
- t?.("row.cooldownUntil", { time: formatTime(cooldownUntil) }) ?? `until ${formatTime(cooldownUntil)}`,
16682
- " · ",
16683
- t?.("row.cooldownHits", { hits: account.rateLimitHits ?? 0 }) ?? `${account.rateLimitHits ?? 0} hit(s)`
16684
- ]
16685
- }) : null,
16686
- isDead ? (0, react_jsx_runtime.jsx)("span", {
16687
- className: "ch-org",
16688
- children: t?.("row.credentialDeadHint") ?? "Sign in again in the WorkBuddy desktop app to restore it"
16689
- }) : null,
16690
- modelCooldowns.length > 0 ? (0, react_jsx_runtime.jsx)("div", {
16691
- className: "ch-note",
16692
- children: modelCooldowns.map((mc) => {
16693
- const coolingModel = models.find((model) => model.id === mc.modelId);
16694
- const twin = coolingModel === void 0 ? void 0 : paidAlternativeFor(coolingModel, models);
16695
- return (0, react_jsx_runtime.jsxs)("span", {
16696
- className: "badge",
16697
- children: [t?.("row.modelCooling", {
16698
- model: mc.modelId,
16699
- time: formatDateTime(mc.until)
16700
- }) ?? `${mc.modelId} cooling to ${formatDateTime(mc.until)}`, twin === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
16701
- className: "badge",
16702
- title: t?.("row.paidTwinHint") ?? "Same model, paid row",
16703
- children: t?.("row.rateLimitedPaidTwin", {
16704
- id: twin.id,
16705
- rate: twin.multiplier.toFixed(2)
16706
- }) ?? `→ ${twin.id} (${twin.multiplier.toFixed(2)}x) still works`
16707
- })]
16708
- }, mc.modelId);
16709
- })
16710
- }) : null
16711
- ]
16712
- }),
16713
- (0, react_jsx_runtime.jsx)(AccountStats, {
16714
- account,
16715
- t,
16716
- checkinBusy: checkinBusyId === account.id,
16717
- onClaim: onClaimCheckin
16718
- }),
16719
- (0, react_jsx_runtime.jsx)(CreditReserveRow, {
16720
- account,
16721
- t,
16722
- busy: reserveBusyId === account.id,
16723
- onSave: onSaveCreditReserve
16724
- }),
16725
- account.automationToday === void 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
16726
- className: "fact",
16727
- children: [(0, react_jsx_runtime.jsx)("span", {
16728
- className: "td-name",
16729
- children: t?.("row.autoEarned") ?? "Automation today"
16730
- }), (0, react_jsx_runtime.jsxs)("span", {
16731
- className: "facts",
16732
- children: [
16733
- account.automationToday.credit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16734
- className: "fact",
16735
- children: t?.("row.autoFromTasks", {
16736
- credit: account.automationToday.credit,
16737
- energy: account.automationToday.energy,
16738
- count: account.automationToday.claimed
16739
- }) ?? `Tasks +${account.automationToday.credit}`
16740
- }) : null,
16741
- account.automationToday.checkinCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16742
- className: "fact",
16743
- children: t?.("row.autoFromCheckin", { credit: account.automationToday.checkinCredit }) ?? `Check-in +${account.automationToday.checkinCredit}`
16744
- }) : null,
16745
- account.automationToday.bonusCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16746
- className: "fact",
16747
- children: t?.("row.autoFromBonus", { credit: account.automationToday.bonusCredit }) ?? `Streak +${account.automationToday.bonusCredit}`
16748
- }) : null,
16749
- account.automationToday.travelCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16750
- className: "fact",
16751
- children: t?.("row.autoFromTravel", { credit: account.automationToday.travelCredit }) ?? `Buddy +${account.automationToday.travelCredit}`
16752
- }) : null,
16753
- account.automationToday.compensationCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16754
- className: "fact",
16755
- children: t?.("row.autoFromCompensation", { credit: account.automationToday.compensationCredit }) ?? `Compensation +${account.automationToday.compensationCredit}`
16756
- }) : null
16757
- ]
16758
- })]
16759
- })
16760
- ]
16761
- })]
16762
- });
16763
- }
16764
- function CreditReserveRow({ account, t, busy, onSave }) {
16765
- const saved = account.creditReserve ?? 0;
16766
- const [draft, setDraft] = (0, react.useState)(String(saved));
16767
- const [settled, setSettled] = (0, react.useState)(saved);
16768
- const [note, setNote] = (0, react.useState)(void 0);
16769
- (0, react.useEffect)(() => {
16770
- setSettled(saved);
16771
- setDraft((current) => current === String(saved) ? current : String(saved));
16772
- }, [saved]);
16773
- const parsed = Number.parseInt(draft, 10);
16774
- const next = Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : 0;
16775
- const dirty = next !== settled;
16776
- const commit = async () => {
16777
- if (busy || !dirty) return;
16778
- setNote(void 0);
16779
- if (await onSave(account.id, next)) {
16780
- setSettled(next);
16781
- setDraft(String(next));
16782
- setNote("saved");
16783
- } else setNote("failed");
16784
- };
16785
- return (0, react_jsx_runtime.jsxs)("div", {
16786
- className: "row",
16787
- children: [
16788
- (0, react_jsx_runtime.jsx)("span", {
16789
- className: "field",
16790
- children: t?.("row.reserveTitle") ?? "Keep at least"
16791
- }),
16792
- (0, react_jsx_runtime.jsx)("input", {
16793
- type: "number",
16794
- min: 0,
16795
- step: 1,
16796
- value: draft,
16797
- disabled: busy,
16798
- className: "input",
16799
- "aria-label": t?.("row.reserveTitle") ?? "Keep at least",
16800
- onChange: (event) => {
16801
- setDraft(event.target.value);
16802
- setNote(void 0);
16803
- },
16804
- onKeyDown: (event) => {
16805
- if (event.key === "Enter") commit();
16806
- }
16807
- }),
16808
- (0, react_jsx_runtime.jsx)("span", {
16809
- className: "kpi-u",
16810
- children: t?.("row.reserveUnit") ?? "credits"
16811
- }),
16812
- (0, react_jsx_runtime.jsx)("button", {
16813
- type: "button",
16814
- className: "tiny",
16815
- disabled: busy || !dirty,
16816
- onClick: () => {
16817
- commit();
16818
- },
16819
- children: busy ? t?.("row.reserveSaving") ?? "Saving…" : t?.("row.reserveSave") ?? "Save"
16820
- }),
16821
- note === "saved" ? (0, react_jsx_runtime.jsx)("span", {
16822
- className: "hint",
16823
- children: next > 0 ? t?.("row.reserveSaved", { credits: next }) ?? `Keeping ${next} credits` : t?.("row.reserveCleared") ?? "Reserve cleared"
16824
- }) : null,
16825
- note === "failed" ? (0, react_jsx_runtime.jsx)("span", {
16826
- className: "hint",
16827
- children: t?.("row.reserveFailed") ?? "Not saved — try again"
16828
- }) : null,
16829
- account.reserved === true ? (0, react_jsx_runtime.jsx)("span", {
16830
- className: "pill",
16831
- children: t?.("row.reserveHolding") ?? "Reserved: skipped"
16832
- }) : null
16833
- ]
16834
- });
16835
- }
16836
- function AccountStats({ account, t, checkinBusy, onClaim }) {
16837
- const credits = account.credits;
16838
- const checkin = account.checkin;
16839
- const hasCredits = credits !== void 0 || account.creditsError !== void 0;
16840
- const hasCheckin = checkin !== void 0 || account.checkinError !== void 0;
16841
- if (!hasCredits && !hasCheckin) return null;
16842
- const packages = (credits?.packages ?? []).filter((p) => (p.size ?? 0) > 0).slice(0, 6);
16843
- return (0, react_jsx_runtime.jsxs)("div", {
16844
- className: "kpis",
16845
- children: [
16846
- (0, react_jsx_runtime.jsxs)("span", {
16847
- className: "sec kpi-v",
16848
- children: [(0, react_jsx_runtime.jsx)("span", {
16849
- className: "sec-title",
16850
- children: t?.("row.creditsTotal") ?? "Total"
16851
- }), (0, react_jsx_runtime.jsx)("span", {
16852
- className: "kpi-v",
16853
- children: formatNumber(credits?.total)
16854
- })]
16855
- }),
16856
- hasCheckin ? (0, react_jsx_runtime.jsx)("div", {
16857
- className: "sec",
16858
- children: account.checkinError !== void 0 ? (0, react_jsx_runtime.jsx)("span", {
16859
- className: "hint",
16860
- title: account.checkinError,
16861
- children: t?.("row.checkinUnavailable") ?? "check-in unavailable"
16862
- }) : checkin === void 0 ? null : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
16863
- (0, react_jsx_runtime.jsxs)("div", {
16864
- className: "hint",
16865
- children: [(0, react_jsx_runtime.jsx)("span", {
16866
- className: "pill",
16867
- children: t?.("row.checkinStreak", { days: checkin.streakDays }) ?? `${checkin.streakDays}-day streak`
16868
- }), checkin.dailyCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16869
- className: "fact",
16870
- children: t?.("row.checkinDaily", { credit: formatNumber(checkin.dailyCredit) }) ?? `+${formatNumber(checkin.dailyCredit)}/day`
16871
- }) : null]
16872
- }),
16873
- checkin.isStreakDay && checkin.streakBonusCredit > 0 ? (0, react_jsx_runtime.jsx)("span", {
16874
- className: "fact",
16875
- children: t?.("row.checkinStreakBonus", {
16876
- days: formatNumber(checkin.nextStreakDay),
16877
- credit: formatNumber(checkin.streakBonusCredit)
16878
- }) ?? `bonus +${formatNumber(checkin.streakBonusCredit)}`
16879
- }) : null,
16880
- (0, react_jsx_runtime.jsx)("button", {
16881
- type: "button",
16882
- className: "tiny",
16883
- disabled: !checkin.active || checkin.todayCheckedIn || checkinBusy,
16884
- onClick: () => {
16885
- onClaim(account.id);
16886
- },
16887
- children: !checkin.active ? t?.("row.checkinInactive") ?? "Unavailable" : checkin.todayCheckedIn ? t?.("row.checkinClaimed") ?? "Checked in" : checkinBusy ? t?.("row.checkinClaiming") ?? "Checking in…" : t?.("row.checkinClaim") ?? "Check in"
16888
- })
16889
- ] })
16890
- }) : null,
16891
- hasCredits ? (0, react_jsx_runtime.jsxs)("ul", {
16892
- className: "facts sec",
16893
- children: [account.creditsError !== void 0 ? (0, react_jsx_runtime.jsx)("li", { children: (0, react_jsx_runtime.jsx)("span", {
16894
- className: `hint${account.credentialDead === true ? " is-bad" : ""}`,
16895
- title: account.creditsError,
16896
- children: account.credentialDead === true ? t?.("row.credentialDead") ?? "Sign-in rejected" : t?.("row.creditsError") ?? "credits unavailable"
16897
- }) }) : packages.length === 0 ? (0, react_jsx_runtime.jsx)("li", {
16898
- className: "hint",
16899
- children: "–"
16900
- }) : packages.map((pack, index) => {
16901
- const expiry = formatExpiry(pack.expiresAtMs);
16902
- const refresh = formatExpiry(pack.cycleRefreshMs);
16903
- const soon = isExpiringSoon(pack);
16904
- const when = pack.monthly === true ? refresh === "" ? null : t?.("row.creditsRefreshAt", { time: refresh }) ?? `Refreshes ${refresh}` : expiry === "" ? null : t?.("row.creditsExpiresAt", { time: expiry }) ?? `Expires ${expiry}`;
16905
- return (0, react_jsx_runtime.jsxs)("li", { children: [
16906
- (0, react_jsx_runtime.jsx)("span", {
16907
- className: "td-name",
16908
- children: pack.packageName
16909
- }),
16910
- (0, react_jsx_runtime.jsx)("span", {
16911
- className: "td-num",
16912
- children: t?.("row.creditsPackage", {
16913
- remain: formatNumber(pack.remain),
16914
- size: formatNumber(pack.size)
16915
- }) ?? `${formatNumber(pack.remain)} / ${formatNumber(pack.size)}`
16916
- }),
16917
- when === null ? null : (0, react_jsx_runtime.jsx)("span", {
16918
- className: `hint${soon ? " hint" : ""}`,
16919
- title: t?.("row.creditsExpiresSoonTitle") ?? "Expiring within 3 days",
16920
- children: when
16921
- })
16922
- ] }, `${pack.packageName}-${String(index)}`);
16923
- }), credits?.expiringSoon !== void 0 && credits.expiringSoon > 0 ? (0, react_jsx_runtime.jsxs)("li", {
16924
- className: "hint",
16925
- children: [
16926
- t?.("row.creditsSoon") ?? "Expiring in 3 days",
16927
- " ",
16928
- formatNumber(credits.expiringSoon)
16929
- ]
16930
- }) : null]
16931
- }) : null
16932
- ]
16933
- });
16934
- }
16935
16616
  //#endregion
16936
16617
  //#region src/client/CreditDot.tsx
16937
16618
  const POLL_MS = 45e3;
@@ -19962,26 +19643,6 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19962
19643
  .app[data-w="phone"] .sec-actions{margin-left:0;width:100%}
19963
19644
  .app[data-w="phone"] .vendors{grid-template-columns:minmax(0,1fr)}
19964
19645
  .app[data-w="phone"] .kpis .kpi:last-child:nth-child(odd){grid-column:1 / -1}
19965
- /* ============================================================
19966
- 插件自己加的:右上角关闭
19967
- ------------------------------------------------------------
19968
- 不属于设计稿。设置对话框撑满整个插件页面,宿主的关闭按钮在它自己的
19969
- 标题栏里、位置随宿主管;这里给一个就地入口,点击的落点见 shell.tsx
19970
- 的 closeHostDialog。样式跟随设计变量,两套主题都不用另写。
19971
- ============================================================ */
19972
- .app-close{
19973
- position:absolute;top:8px;right:8px;z-index:70;
19974
- width:28px;height:28px;display:grid;place-items:center;
19975
- border:1px solid var(--line-2);border-radius:var(--r-sm);
19976
- background:color-mix(in oklch, var(--surface) 88%, transparent);
19977
- color:var(--muted);cursor:pointer;
19978
- transition:color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
19979
- }
19980
- .app-close svg{width:14px;height:14px}
19981
- .app-close:hover{color:var(--text);background:var(--surface-2);border-color:var(--line-3)}
19982
- .app-close:active{transform:translateY(1px)}
19983
- .app[data-w="phone"] .app-close{top:6px;right:6px;width:24px;height:24px}
19984
-
19985
19646
  `;
19986
19647
  //#endregion
19987
19648
  //#region src/client/credit-dot-css.ts
@@ -20184,7 +19845,7 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20184
19845
  //#endregion
20185
19846
  //#region src/client/design-style.ts
20186
19847
  const STYLE_ID = "dsh-xdpool/design.css";
20187
- const FULL_CSS = `${DESIGN_TOKENS_CSS}\n${DESIGN_DETAIL_CSS}\n${RESPONSIVE_CSS}\n${CREDIT_DOT_CSS}\n${LIGHT_THEME_CSS}`;
19848
+ const FULL_CSS = `${DESIGN_TOKENS_CSS}\n${DESIGN_DETAIL_CSS}\n${RESPONSIVE_CSS}\n${CREDIT_DOT_CSS}\n${ACCOUNT_CARD_CSS}\n${LIGHT_THEME_CSS}`;
20188
19849
  function installDesignCss() {
20189
19850
  if (typeof document === "undefined") return;
20190
19851
  const head = document.head;
@@ -20601,7 +20262,6 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20601
20262
  "chan.ownedElsewhereRow": "Sign in on the “Our Free Model” page",
20602
20263
  "chan.empty": "No channel is connected yet.",
20603
20264
  "shell.brand": "XD Pool",
20604
- "shell.close": "Close",
20605
20265
  "shell.themeLight": "Eye-care green",
20606
20266
  "shell.themeDark": "Dark",
20607
20267
  "shell.themeToLight": "Switch to the eye-care green (light) theme",
@@ -21325,7 +20985,6 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
21325
20985
  "chan.ownedElsewhereRow": "在「我们的免费模型」里登录",
21326
20986
  "chan.empty": "还没有任何渠道连上来。",
21327
20987
  "shell.brand": "XD Pool",
21328
- "shell.close": "关闭",
21329
20988
  "shell.themeLight": "护眼绿",
21330
20989
  "shell.themeDark": "暗色",
21331
20990
  "shell.themeToLight": "切换到护眼绿(亮色)主题",