@laoyuehanni/dsh-token-usage 0.3.12 → 0.4.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.
- package/README.md +21 -86
- package/README.zh.md +21 -90
- package/docs/pricing.md +79 -0
- package/lib/client/DateRangePicker.d.ts +39 -0
- package/lib/client/DateRangePicker.d.ts.map +1 -0
- package/lib/client/DateRangePicker.js +134 -0
- package/lib/client/DateRangePicker.js.map +1 -0
- package/lib/client/MenuSelect.d.ts +47 -0
- package/lib/client/MenuSelect.d.ts.map +1 -0
- package/lib/client/MenuSelect.js +152 -0
- package/lib/client/MenuSelect.js.map +1 -0
- package/lib/client/StatCard.d.ts +61 -5
- package/lib/client/StatCard.d.ts.map +1 -1
- package/lib/client/StatCard.js +39 -1
- package/lib/client/StatCard.js.map +1 -1
- package/lib/client/TokenUsageCard.d.ts.map +1 -1
- package/lib/client/TokenUsageCard.js +23 -12
- package/lib/client/TokenUsageCard.js.map +1 -1
- package/lib/client/TokenUsageSection.d.ts.map +1 -1
- package/lib/client/TokenUsageSection.js +31 -13
- package/lib/client/TokenUsageSection.js.map +1 -1
- package/lib/client/TrendChart.d.ts +12 -3
- package/lib/client/TrendChart.d.ts.map +1 -1
- package/lib/client/TrendChart.js +30 -19
- package/lib/client/TrendChart.js.map +1 -1
- package/lib/client/UsageView.d.ts +6 -5
- package/lib/client/UsageView.d.ts.map +1 -1
- package/lib/client/UsageView.js +19 -14
- package/lib/client/UsageView.js.map +1 -1
- package/lib/client/day.d.ts +22 -0
- package/lib/client/day.d.ts.map +1 -1
- package/lib/client/day.js +31 -0
- package/lib/client/day.js.map +1 -1
- package/lib/client/format.d.ts +18 -3
- package/lib/client/format.d.ts.map +1 -1
- package/lib/client/format.js +45 -3
- package/lib/client/format.js.map +1 -1
- package/lib/client/locales.d.ts +34 -3
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +68 -6
- package/lib/client/locales.js.map +1 -1
- package/lib/client/trend-chart/index.d.ts +1 -1
- package/lib/client/trend-chart/index.d.ts.map +1 -1
- package/lib/client/trend-chart/index.js +1 -1
- package/lib/client/trend-chart/index.js.map +1 -1
- package/lib/client/trend-chart/points.d.ts +11 -0
- package/lib/client/trend-chart/points.d.ts.map +1 -1
- package/lib/client/trend-chart/points.js +20 -0
- package/lib/client/trend-chart/points.js.map +1 -1
- package/lib/client.js +864 -145
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +117 -28
- package/lib/index.js.map +1 -1
- package/lib/log.d.ts +18 -0
- package/lib/log.d.ts.map +1 -0
- package/lib/log.js +16 -0
- package/lib/log.js.map +1 -0
- package/lib/migrate.d.ts +2 -1
- package/lib/migrate.d.ts.map +1 -1
- package/lib/migrate.js +3 -2
- package/lib/migrate.js.map +1 -1
- package/lib/pricing.d.ts +5 -2
- package/lib/pricing.d.ts.map +1 -1
- package/lib/pricing.js +15 -12
- package/lib/pricing.js.map +1 -1
- package/lib/record-cache.d.ts +11 -4
- package/lib/record-cache.d.ts.map +1 -1
- package/lib/record-cache.js +16 -9
- package/lib/record-cache.js.map +1 -1
- package/lib/rollup.d.ts +15 -8
- package/lib/rollup.d.ts.map +1 -1
- package/lib/rollup.js +14 -9
- package/lib/rollup.js.map +1 -1
- package/lib/stats-route.d.ts +3 -0
- package/lib/stats-route.d.ts.map +1 -1
- package/lib/stats-route.js +6 -4
- package/lib/stats-route.js.map +1 -1
- package/lib/stats.d.ts +8 -5
- package/lib/stats.d.ts.map +1 -1
- package/lib/stats.js +74 -26
- package/lib/stats.js.map +1 -1
- package/lib/sync-state.d.ts +2 -1
- package/lib/sync-state.d.ts.map +1 -1
- package/lib/sync-state.js +3 -2
- package/lib/sync-state.js.map +1 -1
- package/lib/sync.d.ts +24 -3
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +42 -10
- package/lib/sync.js.map +1 -1
- package/lib/usage-log.d.ts +23 -8
- package/lib/usage-log.d.ts.map +1 -1
- package/lib/usage-log.js +129 -17
- package/lib/usage-log.js.map +1 -1
- package/lib/usage-record.d.ts +88 -7
- package/lib/usage-record.d.ts.map +1 -1
- package/lib/usage-record.js +140 -4
- package/lib/usage-record.js.map +1 -1
- package/lib/wire.d.ts +19 -1
- package/lib/wire.d.ts.map +1 -1
- package/lib/wire.js.map +1 -1
- package/package.json +7 -1
package/lib/client.js
CHANGED
|
@@ -541,13 +541,13 @@ window.__ModuleLoader__.load({
|
|
|
541
541
|
}
|
|
542
542
|
//#endregion
|
|
543
543
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\QuotaButton.module.css.mjs
|
|
544
|
-
const css$
|
|
545
|
-
const tagId$
|
|
546
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
544
|
+
const css$9 = ".jYASuG_root{flex:none;display:inline-flex;position:relative}.jYASuG_trigger{width:28px;height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:999px;flex:none;place-items:center;padding:0;display:grid}.jYASuG_trigger svg{display:block}.jYASuG_trigger:hover,.jYASuG_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.jYASuG_trigger.jYASuG_icon-ok:hover,.jYASuG_trigger.jYASuG_icon-ok[aria-expanded=true]{color:var(--dsw-alias-state-success-primary)}.jYASuG_trigger.jYASuG_icon-warn:hover,.jYASuG_trigger.jYASuG_icon-warn[aria-expanded=true]{color:var(--dsw-alias-state-warn-primary)}.jYASuG_trigger.jYASuG_icon-exhausted:hover,.jYASuG_trigger.jYASuG_icon-exhausted[aria-expanded=true]{color:var(--dsw-alias-state-error-primary)}.jYASuG_icon-ok{color:var(--dsw-alias-state-success-primary)}.jYASuG_icon-warn{color:var(--dsw-alias-state-warn-primary)}.jYASuG_icon-exhausted{color:var(--dsw-alias-state-error-primary)}.jYASuG_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:320px;max-width:calc(100vw - 32px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:12px;font-size:12px;line-height:20px;position:absolute;bottom:calc(100% + 8px)}.jYASuG_header{justify-content:space-between;align-items:baseline;gap:8px;margin-bottom:10px;display:flex}.jYASuG_title{color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:500;overflow:hidden}.jYASuG_plan{color:var(--dsw-alias-label-tertiary);font-weight:400}.jYASuG_updated{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:11px}.jYASuG_grid{grid-template-columns:repeat(var(--cols,3), 1fr);gap:14px;display:grid}.jYASuG_col{min-width:0}.jYASuG_label{color:var(--dsw-alias-label-tertiary);white-space:nowrap;text-overflow:ellipsis;margin-bottom:2px;font-size:11px;line-height:16px;overflow:hidden}.jYASuG_value{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;white-space:nowrap;margin-bottom:6px;font-size:13px;font-weight:600;line-height:18px}.jYASuG_meta{color:var(--dsw-alias-label-tertiary);font-size:11px;font-weight:400}.jYASuG_bar{background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;height:4px;overflow:hidden}.jYASuG_fill{border-radius:999px;height:100%;transition:width .3s}.jYASuG_ok{background:var(--dsw-alias-state-success-primary)}.jYASuG_warn{background:var(--dsw-alias-state-warn-primary)}.jYASuG_exhausted{background:var(--dsw-alias-state-error-primary)}.jYASuG_aux{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;white-space:nowrap;margin-top:4px;font-size:11px;line-height:14px}.jYASuG_dot{vertical-align:middle;border-radius:50%;width:5px;height:5px;margin-right:3px;display:inline-block}.jYASuG_error{flex-direction:column;gap:8px;display:flex}.jYASuG_errorText{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;font-size:12px;line-height:18px}.jYASuG_retry{color:var(--dsw-alias-label-primary);cursor:pointer;text-underline-offset:2px;background:0 0;border:none;align-self:flex-start;padding:0;font-size:12px;text-decoration:underline}.jYASuG_retry:hover{color:var(--dsw-alias-brand-primary)}";
|
|
545
|
+
const tagId$9 = "@laoyuehanni/dsh-token-usage/QuotaButton.module.css";
|
|
546
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$9) + "]") === null) {
|
|
547
547
|
const tag = document.createElement("style");
|
|
548
548
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
549
|
-
tag.dataset.pluginCss = tagId$
|
|
550
|
-
tag.textContent = css$
|
|
549
|
+
tag.dataset.pluginCss = tagId$9;
|
|
550
|
+
tag.textContent = css$9;
|
|
551
551
|
document.head.appendChild(tag);
|
|
552
552
|
}
|
|
553
553
|
var QuotaButton_module_css_default = {
|
|
@@ -951,6 +951,42 @@ window.__ModuleLoader__.load({
|
|
|
951
951
|
date.setDate(date.getDate() + deltaDays);
|
|
952
952
|
return dayKeyOf(date);
|
|
953
953
|
}
|
|
954
|
+
/** The month view holding one day key. */
|
|
955
|
+
function monthViewOf(dayKey) {
|
|
956
|
+
return {
|
|
957
|
+
year: Number(dayKey.slice(0, 4)),
|
|
958
|
+
month: Number(dayKey.slice(5, 7)) - 1
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
/** The month view shifted by whole months (year overflow normalized). */
|
|
962
|
+
function shiftMonth(view, deltaMonths) {
|
|
963
|
+
const total = view.year * 12 + view.month + deltaMonths;
|
|
964
|
+
return {
|
|
965
|
+
year: Math.floor(total / 12),
|
|
966
|
+
month: (total % 12 + 12) % 12
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* The month grid of one month view: Monday-first whole weeks covering the
|
|
971
|
+
* month, so every column aligns under its weekday header. Days of the
|
|
972
|
+
* neighbouring months carry `inMonth: false` — the caller renders them as
|
|
973
|
+
* blank placeholders, keeping the shown month's date texts unique (for
|
|
974
|
+
* tests and screen readers).
|
|
975
|
+
*/
|
|
976
|
+
function monthGrid(view) {
|
|
977
|
+
const leading = (new Date(view.year, view.month, 1).getDay() + 6) % 7;
|
|
978
|
+
const daysInMonth = new Date(view.year, view.month + 1, 0).getDate();
|
|
979
|
+
const total = Math.ceil((leading + daysInMonth) / 7) * 7;
|
|
980
|
+
const cells = [];
|
|
981
|
+
for (let index = 0; index < total; index++) {
|
|
982
|
+
const cursor = new Date(view.year, view.month, 1 - leading + index);
|
|
983
|
+
cells.push({
|
|
984
|
+
day: dayKeyOf(cursor),
|
|
985
|
+
inMonth: cursor.getFullYear() === view.year && cursor.getMonth() === view.month
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
return cells;
|
|
989
|
+
}
|
|
954
990
|
/**
|
|
955
991
|
* The zero-filled daily token series over a day range: every calendar day of
|
|
956
992
|
* the range appears once (days without records plot as zero). Absent bounds
|
|
@@ -1014,6 +1050,19 @@ window.__ModuleLoader__.load({
|
|
|
1014
1050
|
}
|
|
1015
1051
|
//#endregion
|
|
1016
1052
|
//#region src/client/format.ts
|
|
1053
|
+
/** Known `LlmFailure.code`s that have a `fail.*` locale label. An unknown
|
|
1054
|
+
* future code is not in this map and the tooltip renders it verbatim. */
|
|
1055
|
+
const FAILURE_CODE_LABEL_KEYS = {
|
|
1056
|
+
RATE_LIMIT: "fail.RATE_LIMIT",
|
|
1057
|
+
SERVER: "fail.SERVER",
|
|
1058
|
+
TIMEOUT: "fail.TIMEOUT",
|
|
1059
|
+
TRANSPORT: "fail.TRANSPORT",
|
|
1060
|
+
EMPTY_RESPONSE: "fail.EMPTY_RESPONSE",
|
|
1061
|
+
QUOTA: "fail.QUOTA",
|
|
1062
|
+
CONTEXT_WINDOW_EXCEEDED: "fail.CONTEXT_WINDOW_EXCEEDED",
|
|
1063
|
+
INVALID_CREDENTIAL: "fail.INVALID_CREDENTIAL",
|
|
1064
|
+
UNKNOWN: "fail.UNKNOWN"
|
|
1065
|
+
};
|
|
1017
1066
|
/** One decimal below 10, integer otherwise, trailing `.0` stripped. */
|
|
1018
1067
|
function scale(value) {
|
|
1019
1068
|
if (value >= 10) return String(Math.round(value));
|
|
@@ -1155,15 +1204,36 @@ window.__ModuleLoader__.load({
|
|
|
1155
1204
|
const clamped = Math.max(0, tokensPerSecond);
|
|
1156
1205
|
return clamped >= 10 ? String(Math.round(clamped)) : String(Math.round(clamped * 10) / 10);
|
|
1157
1206
|
}
|
|
1207
|
+
/**
|
|
1208
|
+
* The failure pill's hover tooltip text: one `label ×count` line per failure
|
|
1209
|
+
* class, largest count first (code name ascending breaks ties), newline-joined —
|
|
1210
|
+
* the shell Tooltip renders `pre-line`, so each line lands on its own row.
|
|
1211
|
+
* Known `LlmFailure.code`s map through `fail.*` locale keys (限流 / Rate
|
|
1212
|
+
* limited); an unknown future code renders verbatim. A legacy shape without
|
|
1213
|
+
* the breakdown, or an empty map, yields '' and the caller suppresses the
|
|
1214
|
+
* tooltip.
|
|
1215
|
+
* @param byCode - the per-code failure counts from the totals (may be undefined).
|
|
1216
|
+
* @param t - locale lookup; codes without a `fail.*` key stay verbatim.
|
|
1217
|
+
* @returns the multi-line tooltip label, or '' when there is nothing to show.
|
|
1218
|
+
*/
|
|
1219
|
+
function failuresTooltip(byCode, t) {
|
|
1220
|
+
if (byCode === void 0) return "";
|
|
1221
|
+
return Object.entries(byCode).filter(([, count]) => count > 0).sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0])).map(([code, count]) => `${failureCodeLabel(code, t)} ×${count}`).join("\n");
|
|
1222
|
+
}
|
|
1223
|
+
/** Locale label for one failure code; unknown codes stay verbatim. */
|
|
1224
|
+
function failureCodeLabel(code, t) {
|
|
1225
|
+
if (Object.hasOwn(FAILURE_CODE_LABEL_KEYS, code)) return t(FAILURE_CODE_LABEL_KEYS[code]);
|
|
1226
|
+
return code;
|
|
1227
|
+
}
|
|
1158
1228
|
//#endregion
|
|
1159
1229
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\hit-rate-band.module.css.mjs
|
|
1160
|
-
const css$
|
|
1161
|
-
const tagId$
|
|
1162
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1230
|
+
const css$8 = ".t6JM8a_band_critical{color:var(--dsw-alias-state-error-primary,#dc2626)}.t6JM8a_band_amber{color:#f59e0b}.t6JM8a_band_lime{color:#84cc16}.t6JM8a_band_healthy{color:var(--dsw-alias-state-success-primary,#16a34a)}";
|
|
1231
|
+
const tagId$8 = "@laoyuehanni/dsh-token-usage/hit-rate-band.module.css";
|
|
1232
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$8) + "]") === null) {
|
|
1163
1233
|
const tag = document.createElement("style");
|
|
1164
1234
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1165
|
-
tag.dataset.pluginCss = tagId$
|
|
1166
|
-
tag.textContent = css$
|
|
1235
|
+
tag.dataset.pluginCss = tagId$8;
|
|
1236
|
+
tag.textContent = css$8;
|
|
1167
1237
|
document.head.appendChild(tag);
|
|
1168
1238
|
}
|
|
1169
1239
|
var hit_rate_band_module_css_default = {
|
|
@@ -1383,13 +1453,13 @@ window.__ModuleLoader__.load({
|
|
|
1383
1453
|
}
|
|
1384
1454
|
//#endregion
|
|
1385
1455
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\SessionStatsChip.module.css.mjs
|
|
1386
|
-
const css$
|
|
1387
|
-
const tagId$
|
|
1388
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1456
|
+
const css$7 = ".d5ISLa_strip{border:1px solid var(--dsw-alias-border-l2);font-variant-numeric:tabular-nums;background:0 0;border-radius:14px;flex:none;align-items:stretch;min-width:0;height:28px;font-size:12px;line-height:18px;display:inline-flex;overflow:hidden}.d5ISLa_stripFlyOverflow{z-index:2;position:relative;overflow:visible}.d5ISLa_cell{color:var(--dsw-alias-label-primary);white-space:nowrap;align-items:center;padding:0 10px;display:inline-flex}.d5ISLa_cell+.d5ISLa_cell{border-left:1px solid var(--dsw-alias-border-l1)}.d5ISLa_cellHit{font-weight:500}.d5ISLa_costCell{z-index:1;position:relative;overflow:visible}.d5ISLa_costInner{transform-origin:50%;z-index:2;justify-content:center;align-items:center;display:inline-flex;position:relative}.d5ISLa_deltaLayer{pointer-events:none;z-index:3;position:absolute;inset:0;overflow:visible}.d5ISLa_deltaFly{color:var(--dsw-alias-state-warn-primary);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;text-shadow:0 0 8px color-mix(in srgb, var(--dsw-alias-state-warn-primary) 35%, transparent);font-size:11px;font-weight:600;position:absolute;top:0;left:50%;transform:translate(-50%,-100%)}@media (prefers-reduced-motion:reduce){.d5ISLa_deltaFly{display:none}}@media (width<=560px){.d5ISLa_strip{font-size:11px}.d5ISLa_cell{padding:0 7px}}";
|
|
1457
|
+
const tagId$7 = "@laoyuehanni/dsh-token-usage/SessionStatsChip.module.css";
|
|
1458
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$7) + "]") === null) {
|
|
1389
1459
|
const tag = document.createElement("style");
|
|
1390
1460
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1391
|
-
tag.dataset.pluginCss = tagId$
|
|
1392
|
-
tag.textContent = css$
|
|
1461
|
+
tag.dataset.pluginCss = tagId$7;
|
|
1462
|
+
tag.textContent = css$7;
|
|
1393
1463
|
document.head.appendChild(tag);
|
|
1394
1464
|
}
|
|
1395
1465
|
var SessionStatsChip_module_css_default = {
|
|
@@ -1725,13 +1795,13 @@ window.__ModuleLoader__.load({
|
|
|
1725
1795
|
}
|
|
1726
1796
|
//#endregion
|
|
1727
1797
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageCard.module.css.mjs
|
|
1728
|
-
const css$
|
|
1729
|
-
const tagId$
|
|
1730
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1798
|
+
const css$6 = "._1bMeTa_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}._1bMeTa_card:hover{border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}._1bMeTa_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}._1bMeTa_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}._1bMeTa_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}._1bMeTa_description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}._1bMeTa_pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}._1bMeTa_chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}._1bMeTa_chevronOpen{transform:rotate(180deg)}._1bMeTa_body{border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:10px;margin:0 16px;padding:12px 0 8px;display:flex}._1bMeTa_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}._1bMeTa_field{flex-direction:column;gap:4px;display:flex}._1bMeTa_fieldLabel{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.5}._1bMeTa_input{box-sizing:border-box;width:100%;font:inherit;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);appearance:none;border-radius:6px;padding:4px 8px;font-size:13px;line-height:20px}._1bMeTa_input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-1px}._1bMeTa_input:disabled{opacity:.6}._1bMeTa_inputRow{align-items:center;gap:6px;display:flex}._1bMeTa_inputRow ._1bMeTa_input{flex:1;min-width:0}._1bMeTa_browse{appearance:none;border:1px solid var(--dsw-alias-border-l2);font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:6px;flex:none;padding:4px 10px;font-size:13px;line-height:20px}._1bMeTa_browse:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_browse:disabled{opacity:.4;cursor:default}._1bMeTa_browse:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}._1bMeTa_migration{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:6px;flex-direction:column;gap:4px;padding:8px 10px;display:flex}._1bMeTa_migrationLabel{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;font-size:12px;line-height:1.5}._1bMeTa_migrationBar{background:var(--dsw-alias-bg-multi-select);border-radius:2px;height:4px;display:block;overflow:hidden}._1bMeTa_migrationFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}._1bMeTa_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 4px;display:flex}._1bMeTa_failed{min-width:0;color:var(--dsw-alias-label-error);flex:1;margin:0;font-size:12px;line-height:1.5}._1bMeTa_discard,._1bMeTa_save{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}._1bMeTa_discard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}._1bMeTa_discard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}._1bMeTa_discard:disabled,._1bMeTa_save:disabled{opacity:.4;cursor:default}._1bMeTa_discard:focus-visible,._1bMeTa_save:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_fullSync{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:8px;flex-direction:column;gap:8px;padding:10px 12px;display:flex}._1bMeTa_fullSyncHeader{flex-direction:column;gap:2px;display:flex}._1bMeTa_fullSyncTitle{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:1.4}._1bMeTa_fullSyncHint{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5}._1bMeTa_fullSyncButton{appearance:none;border:1px solid var(--dsw-alias-border-l2);font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:6px;align-self:flex-start;padding:4px 12px;font-size:13px;line-height:20px}._1bMeTa_fullSyncButton:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_fullSyncButton:disabled{opacity:.5;cursor:default}._1bMeTa_fullSyncButton:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_fullSyncProgress{flex-direction:column;gap:4px;display:flex}._1bMeTa_fullSyncProgressLabel{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;font-size:12px;line-height:1.5}._1bMeTa_fullSyncBar{background:var(--dsw-alias-bg-multi-select);border-radius:2px;height:4px;display:block;overflow:hidden}._1bMeTa_fullSyncFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}._1bMeTa_fullSyncResult{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;margin:0;font-size:12px;line-height:1.5}._1bMeTa_fullSyncError{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}";
|
|
1799
|
+
const tagId$6 = "@laoyuehanni/dsh-token-usage/TokenUsageCard.module.css";
|
|
1800
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$6) + "]") === null) {
|
|
1731
1801
|
const tag = document.createElement("style");
|
|
1732
1802
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1733
|
-
tag.dataset.pluginCss = tagId$
|
|
1734
|
-
tag.textContent = css$
|
|
1803
|
+
tag.dataset.pluginCss = tagId$6;
|
|
1804
|
+
tag.textContent = css$6;
|
|
1735
1805
|
document.head.appendChild(tag);
|
|
1736
1806
|
}
|
|
1737
1807
|
var TokenUsageCard_module_css_default = {
|
|
@@ -1839,7 +1909,8 @@ window.__ModuleLoader__.load({
|
|
|
1839
1909
|
processed: body.processed,
|
|
1840
1910
|
total: body.total,
|
|
1841
1911
|
added: body.added,
|
|
1842
|
-
skipped: body.skipped
|
|
1912
|
+
skipped: body.skipped,
|
|
1913
|
+
failedSessions: typeof body.failedSessions === "number" ? body.failedSessions : 0
|
|
1843
1914
|
};
|
|
1844
1915
|
return null;
|
|
1845
1916
|
}
|
|
@@ -1884,7 +1955,8 @@ window.__ModuleLoader__.load({
|
|
|
1884
1955
|
processed: 0,
|
|
1885
1956
|
total: 0,
|
|
1886
1957
|
added: 0,
|
|
1887
|
-
skipped: 0
|
|
1958
|
+
skipped: 0,
|
|
1959
|
+
failedSessions: 0
|
|
1888
1960
|
});
|
|
1889
1961
|
return;
|
|
1890
1962
|
}
|
|
@@ -2035,14 +2107,14 @@ window.__ModuleLoader__.load({
|
|
|
2035
2107
|
fullSync.status === "running" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2036
2108
|
className: TokenUsageCard_module_css_default.fullSyncProgress,
|
|
2037
2109
|
role: "status",
|
|
2038
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2110
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2039
2111
|
className: TokenUsageCard_module_css_default.fullSyncProgressLabel,
|
|
2040
|
-
children: t("card.fullSync.progress", {
|
|
2112
|
+
children: [t("card.fullSync.progress", {
|
|
2041
2113
|
processed: String(fullSync.processed),
|
|
2042
2114
|
total: String(fullSync.total),
|
|
2043
2115
|
added: String(fullSync.added),
|
|
2044
2116
|
skipped: String(fullSync.skipped)
|
|
2045
|
-
})
|
|
2117
|
+
}), fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : ""]
|
|
2046
2118
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2047
2119
|
className: TokenUsageCard_module_css_default.fullSyncBar,
|
|
2048
2120
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -2051,13 +2123,13 @@ window.__ModuleLoader__.load({
|
|
|
2051
2123
|
})
|
|
2052
2124
|
})]
|
|
2053
2125
|
}) : null,
|
|
2054
|
-
fullSync.status === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
2126
|
+
fullSync.status === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2055
2127
|
className: TokenUsageCard_module_css_default.fullSyncResult,
|
|
2056
2128
|
role: "status",
|
|
2057
|
-
children: t("card.fullSync.done", {
|
|
2129
|
+
children: [t("card.fullSync.done", {
|
|
2058
2130
|
added: String(fullSync.added),
|
|
2059
2131
|
skipped: String(fullSync.skipped)
|
|
2060
|
-
})
|
|
2132
|
+
}), fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : ""]
|
|
2061
2133
|
}) : null,
|
|
2062
2134
|
fullSync.status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2063
2135
|
className: TokenUsageCard_module_css_default.fullSyncError,
|
|
@@ -2095,8 +2167,413 @@ window.__ModuleLoader__.load({
|
|
|
2095
2167
|
});
|
|
2096
2168
|
}
|
|
2097
2169
|
//#endregion
|
|
2170
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\DateRangePicker.module.css.mjs
|
|
2171
|
+
const css$5 = ".aSiNOq_wrapper{flex:none;display:inline-flex;position:relative}.aSiNOq_trigger{box-sizing:border-box;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;border-radius:6px;flex:none;padding:4px 10px;font-size:13px;line-height:20px}.aSiNOq_trigger:hover,.aSiNOq_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:266px;max-width:calc(100vw - 32px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:10px;font-size:12px;line-height:20px;position:absolute;top:calc(100% + 6px);left:0}.aSiNOq_head{justify-content:space-between;align-items:center;gap:4px;margin-bottom:6px;display:flex}.aSiNOq_nav{width:24px;height:24px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;flex:none;padding:0;font-size:14px;line-height:1}.aSiNOq_nav:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_monthTitle{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:13px;font-weight:500}.aSiNOq_weekdays,.aSiNOq_grid{grid-template-columns:repeat(7,1fr);gap:2px;display:grid}.aSiNOq_weekday{text-align:center;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.aSiNOq_blank{visibility:hidden;height:26px}.aSiNOq_day{font-variant-numeric:tabular-nums;text-align:center;height:26px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:0;font-size:12px;line-height:26px}.aSiNOq_day:hover{background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_dayToday{box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2)}.aSiNOq_dayAnchor,.aSiNOq_daySelected{color:var(--dsw-alias-brand-primary);box-shadow:inset 0 0 0 1px var(--dsw-alias-brand-primary);font-weight:600}.aSiNOq_dayInRange{background:var(--dsw-alias-interactive-bg-hover);border-radius:0}.aSiNOq_foot{border-top:1px solid var(--dsw-alias-border-l1);justify-content:flex-end;margin-top:8px;padding-top:8px;display:flex}.aSiNOq_clear{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:2px 8px;font-size:12px;line-height:18px}.aSiNOq_clear:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}";
|
|
2172
|
+
const tagId$5 = "@laoyuehanni/dsh-token-usage/DateRangePicker.module.css";
|
|
2173
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$5) + "]") === null) {
|
|
2174
|
+
const tag = document.createElement("style");
|
|
2175
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2176
|
+
tag.dataset.pluginCss = tagId$5;
|
|
2177
|
+
tag.textContent = css$5;
|
|
2178
|
+
document.head.appendChild(tag);
|
|
2179
|
+
}
|
|
2180
|
+
var DateRangePicker_module_css_default = {
|
|
2181
|
+
"blank": "aSiNOq_blank",
|
|
2182
|
+
"clear": "aSiNOq_clear",
|
|
2183
|
+
"day": "aSiNOq_day",
|
|
2184
|
+
"dayAnchor": "aSiNOq_dayAnchor",
|
|
2185
|
+
"dayInRange": "aSiNOq_dayInRange",
|
|
2186
|
+
"daySelected": "aSiNOq_daySelected",
|
|
2187
|
+
"dayToday": "aSiNOq_dayToday",
|
|
2188
|
+
"foot": "aSiNOq_foot",
|
|
2189
|
+
"grid": "aSiNOq_grid",
|
|
2190
|
+
"head": "aSiNOq_head",
|
|
2191
|
+
"monthTitle": "aSiNOq_monthTitle",
|
|
2192
|
+
"nav": "aSiNOq_nav",
|
|
2193
|
+
"panel": "aSiNOq_panel",
|
|
2194
|
+
"trigger": "aSiNOq_trigger",
|
|
2195
|
+
"weekday": "aSiNOq_weekday",
|
|
2196
|
+
"weekdays": "aSiNOq_weekdays",
|
|
2197
|
+
"wrapper": "aSiNOq_wrapper"
|
|
2198
|
+
};
|
|
2199
|
+
//#endregion
|
|
2200
|
+
//#region src/client/DateRangePicker.tsx
|
|
2201
|
+
/**
|
|
2202
|
+
* Range date picker (browser half): the filter bar's single date control —
|
|
2203
|
+
* one trigger showing the active day range plus a lightweight calendar
|
|
2204
|
+
* popover. The range is picked with two clicks: the first lands an anchor
|
|
2205
|
+
* (start or end, order does not matter), the second settles the range
|
|
2206
|
+
* (min/max sorted); month navigation keeps the anchor, so a range may span
|
|
2207
|
+
* months (navigate, click, navigate back, click). While an anchor is live,
|
|
2208
|
+
* hovering previews the pending range; Escape or an outside pointerdown
|
|
2209
|
+
* closes the popover and DISCARDS the unfinished anchor (the committed
|
|
2210
|
+
* filters never change on cancel). A clear affordance releases the range
|
|
2211
|
+
* back to unconstrained — the capability the two native date inputs it
|
|
2212
|
+
* replaces carried.
|
|
2213
|
+
*
|
|
2214
|
+
* The popover interaction copies QuotaButton's pattern verbatim (click
|
|
2215
|
+
* toggles, document pointerdown outside closes, Escape closes); the plate
|
|
2216
|
+
* styling mirrors its panel (menu background, inverted border, shadow,
|
|
2217
|
+
* z-index 100).
|
|
2218
|
+
*
|
|
2219
|
+
* @module token-usage/client/DateRangePicker
|
|
2220
|
+
*/
|
|
2221
|
+
/** Monday-first weekday header keys (index 0 = Monday). */
|
|
2222
|
+
const WEEKDAY_KEYS = [
|
|
2223
|
+
"calendar.weekday.0",
|
|
2224
|
+
"calendar.weekday.1",
|
|
2225
|
+
"calendar.weekday.2",
|
|
2226
|
+
"calendar.weekday.3",
|
|
2227
|
+
"calendar.weekday.4",
|
|
2228
|
+
"calendar.weekday.5",
|
|
2229
|
+
"calendar.weekday.6"
|
|
2230
|
+
];
|
|
2231
|
+
/** The month view the popover opens on: the range end, else its start, else today. */
|
|
2232
|
+
function initialView(from, to) {
|
|
2233
|
+
return monthViewOf(to !== "" ? to : from !== "" ? from : dayKeyOf(/* @__PURE__ */ new Date()));
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Render the trigger + calendar popover.
|
|
2237
|
+
* @param props - the committed range, the change lift, and the locale seat.
|
|
2238
|
+
* @returns the inline wrapper holding the trigger and, while open, the panel.
|
|
2239
|
+
*/
|
|
2240
|
+
function DateRangePicker({ from, to, onChange, t }) {
|
|
2241
|
+
const rootRef = (0, react.useRef)(null);
|
|
2242
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
2243
|
+
const [view, setView] = (0, react.useState)(() => initialView(from, to));
|
|
2244
|
+
const [anchor, setAnchor] = (0, react.useState)(null);
|
|
2245
|
+
const [hovered, setHovered] = (0, react.useState)(null);
|
|
2246
|
+
const closePanel = () => {
|
|
2247
|
+
setOpen(false);
|
|
2248
|
+
setAnchor(null);
|
|
2249
|
+
setHovered(null);
|
|
2250
|
+
};
|
|
2251
|
+
const openPanel = () => {
|
|
2252
|
+
setView(initialView(from, to));
|
|
2253
|
+
setAnchor(null);
|
|
2254
|
+
setHovered(null);
|
|
2255
|
+
setOpen(true);
|
|
2256
|
+
};
|
|
2257
|
+
(0, react.useEffect)(() => {
|
|
2258
|
+
if (!open) return;
|
|
2259
|
+
const onPointerDown = (event) => {
|
|
2260
|
+
if (event.target instanceof Node && rootRef.current?.contains(event.target) === true) return;
|
|
2261
|
+
closePanel();
|
|
2262
|
+
};
|
|
2263
|
+
const onKeyDown = (event) => {
|
|
2264
|
+
if (event.key === "Escape") closePanel();
|
|
2265
|
+
};
|
|
2266
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
2267
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2268
|
+
return () => {
|
|
2269
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
2270
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
2271
|
+
};
|
|
2272
|
+
}, [open]);
|
|
2273
|
+
const pickDay = (day) => {
|
|
2274
|
+
if (anchor === null) {
|
|
2275
|
+
setAnchor(day);
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
const lo = anchor < day ? anchor : day;
|
|
2279
|
+
const hi = anchor < day ? day : anchor;
|
|
2280
|
+
closePanel();
|
|
2281
|
+
onChange({
|
|
2282
|
+
from: lo,
|
|
2283
|
+
to: hi
|
|
2284
|
+
});
|
|
2285
|
+
};
|
|
2286
|
+
const clear = () => {
|
|
2287
|
+
closePanel();
|
|
2288
|
+
onChange({
|
|
2289
|
+
from: "",
|
|
2290
|
+
to: ""
|
|
2291
|
+
});
|
|
2292
|
+
};
|
|
2293
|
+
const shown = anchor !== null ? {
|
|
2294
|
+
from: hovered !== null && hovered < anchor ? hovered : anchor,
|
|
2295
|
+
to: hovered !== null && hovered > anchor ? hovered : anchor
|
|
2296
|
+
} : {
|
|
2297
|
+
from,
|
|
2298
|
+
to
|
|
2299
|
+
};
|
|
2300
|
+
const today = dayKeyOf(/* @__PURE__ */ new Date());
|
|
2301
|
+
const summary = from !== "" && to !== "" ? `${from} ${t("filter.separator")} ${to}` : from !== "" ? from : to !== "" ? to : t("filter.allDates");
|
|
2302
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2303
|
+
ref: rootRef,
|
|
2304
|
+
className: DateRangePicker_module_css_default["wrapper"],
|
|
2305
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2306
|
+
type: "button",
|
|
2307
|
+
className: DateRangePicker_module_css_default["trigger"],
|
|
2308
|
+
"aria-label": t("filter.dateRange"),
|
|
2309
|
+
"aria-expanded": open,
|
|
2310
|
+
onClick: () => {
|
|
2311
|
+
(open ? closePanel : openPanel)();
|
|
2312
|
+
},
|
|
2313
|
+
children: summary
|
|
2314
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2315
|
+
className: DateRangePicker_module_css_default["panel"],
|
|
2316
|
+
role: "dialog",
|
|
2317
|
+
"aria-label": t("filter.dateRange"),
|
|
2318
|
+
children: [
|
|
2319
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2320
|
+
className: DateRangePicker_module_css_default["head"],
|
|
2321
|
+
children: [
|
|
2322
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2323
|
+
type: "button",
|
|
2324
|
+
className: DateRangePicker_module_css_default["nav"],
|
|
2325
|
+
"aria-label": t("calendar.prevMonth"),
|
|
2326
|
+
onClick: () => {
|
|
2327
|
+
setView(shiftMonth(view, -1));
|
|
2328
|
+
},
|
|
2329
|
+
children: "‹"
|
|
2330
|
+
}),
|
|
2331
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2332
|
+
className: DateRangePicker_module_css_default["monthTitle"],
|
|
2333
|
+
children: t("calendar.monthTitle", {
|
|
2334
|
+
year: String(view.year),
|
|
2335
|
+
month: String(view.month + 1)
|
|
2336
|
+
})
|
|
2337
|
+
}),
|
|
2338
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2339
|
+
type: "button",
|
|
2340
|
+
className: DateRangePicker_module_css_default["nav"],
|
|
2341
|
+
"aria-label": t("calendar.nextMonth"),
|
|
2342
|
+
onClick: () => {
|
|
2343
|
+
setView(shiftMonth(view, 1));
|
|
2344
|
+
},
|
|
2345
|
+
children: "›"
|
|
2346
|
+
})
|
|
2347
|
+
]
|
|
2348
|
+
}),
|
|
2349
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2350
|
+
className: DateRangePicker_module_css_default["weekdays"],
|
|
2351
|
+
children: WEEKDAY_KEYS.map((key) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2352
|
+
className: DateRangePicker_module_css_default["weekday"],
|
|
2353
|
+
children: t(key)
|
|
2354
|
+
}, key))
|
|
2355
|
+
}),
|
|
2356
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2357
|
+
className: DateRangePicker_module_css_default["grid"],
|
|
2358
|
+
children: monthGrid(view).map((cell) => {
|
|
2359
|
+
if (!cell.inMonth) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2360
|
+
className: DateRangePicker_module_css_default["blank"],
|
|
2361
|
+
"aria-hidden": "true"
|
|
2362
|
+
}, `blank-${cell.day}`);
|
|
2363
|
+
const classes = [DateRangePicker_module_css_default["day"]];
|
|
2364
|
+
if (cell.day === shown.from || cell.day === shown.to) classes.push(DateRangePicker_module_css_default["daySelected"]);
|
|
2365
|
+
else if (shown.from !== "" && cell.day > shown.from && cell.day < shown.to) classes.push(DateRangePicker_module_css_default["dayInRange"]);
|
|
2366
|
+
if (cell.day === today) classes.push(DateRangePicker_module_css_default["dayToday"]);
|
|
2367
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2368
|
+
type: "button",
|
|
2369
|
+
className: classes.join(" "),
|
|
2370
|
+
"aria-label": cell.day,
|
|
2371
|
+
"aria-pressed": cell.day === shown.from || cell.day === shown.to,
|
|
2372
|
+
"aria-current": cell.day === today ? "date" : void 0,
|
|
2373
|
+
onMouseEnter: () => {
|
|
2374
|
+
setHovered(cell.day);
|
|
2375
|
+
},
|
|
2376
|
+
onMouseLeave: () => {
|
|
2377
|
+
setHovered(null);
|
|
2378
|
+
},
|
|
2379
|
+
onClick: () => {
|
|
2380
|
+
pickDay(cell.day);
|
|
2381
|
+
},
|
|
2382
|
+
children: Number(cell.day.slice(8))
|
|
2383
|
+
}, cell.day);
|
|
2384
|
+
})
|
|
2385
|
+
}),
|
|
2386
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2387
|
+
className: DateRangePicker_module_css_default["foot"],
|
|
2388
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2389
|
+
type: "button",
|
|
2390
|
+
className: DateRangePicker_module_css_default["clear"],
|
|
2391
|
+
onClick: clear,
|
|
2392
|
+
children: t("filter.clear")
|
|
2393
|
+
})
|
|
2394
|
+
})
|
|
2395
|
+
]
|
|
2396
|
+
}) : null]
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
//#endregion
|
|
2400
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\MenuSelect.module.css.mjs
|
|
2401
|
+
const css$4 = ".KUIXpG_wrapper{display:inline-flex;position:relative}.KUIXpG_trigger{box-sizing:border-box;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;text-overflow:ellipsis;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E/%3C/svg%3E\");background-position:right 6px center;background-repeat:no-repeat;background-size:12px 12px;border-radius:6px;flex:none;padding:4px 24px 4px 8px;font-size:13px;line-height:20px;overflow:hidden}.KUIXpG_trigger:hover,.KUIXpG_trigger[aria-expanded=true]{background-color:var(--dsw-alias-interactive-bg-hover)}.KUIXpG_grow{flex:0 auto;min-width:0;max-width:220px}.KUIXpG_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);min-width:100%;max-width:260px;max-height:240px;box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:6px;font-size:13px;line-height:20px;position:absolute;top:calc(100% + 6px);left:0;overflow-y:auto}.KUIXpG_option{width:100%;color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;justify-content:space-between;align-items:center;gap:12px;padding:4px 8px;font-size:13px;line-height:20px;display:flex}.KUIXpG_option:hover{background:var(--dsw-alias-interactive-bg-hover)}.KUIXpG_optionLabel{text-overflow:ellipsis;overflow:hidden}.KUIXpG_optionSelected{color:var(--dsw-alias-brand-primary)}.KUIXpG_check{color:var(--dsw-alias-brand-primary);flex:none}";
|
|
2402
|
+
const tagId$4 = "@laoyuehanni/dsh-token-usage/MenuSelect.module.css";
|
|
2403
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$4) + "]") === null) {
|
|
2404
|
+
const tag = document.createElement("style");
|
|
2405
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2406
|
+
tag.dataset.pluginCss = tagId$4;
|
|
2407
|
+
tag.textContent = css$4;
|
|
2408
|
+
document.head.appendChild(tag);
|
|
2409
|
+
}
|
|
2410
|
+
var MenuSelect_module_css_default = {
|
|
2411
|
+
"check": "KUIXpG_check",
|
|
2412
|
+
"grow": "KUIXpG_grow",
|
|
2413
|
+
"option": "KUIXpG_option",
|
|
2414
|
+
"optionLabel": "KUIXpG_optionLabel",
|
|
2415
|
+
"optionSelected": "KUIXpG_optionSelected",
|
|
2416
|
+
"panel": "KUIXpG_panel",
|
|
2417
|
+
"trigger": "KUIXpG_trigger",
|
|
2418
|
+
"wrapper": "KUIXpG_wrapper"
|
|
2419
|
+
};
|
|
2420
|
+
//#endregion
|
|
2421
|
+
//#region src/client/MenuSelect.tsx
|
|
2422
|
+
/**
|
|
2423
|
+
* Menu select (browser half): the filter bar's themed dropdown — one
|
|
2424
|
+
* trigger button plus a menu popover. It replaces the native `<select>`,
|
|
2425
|
+
* whose UA-painted option list ignores every design token (the shell sets
|
|
2426
|
+
* no color-scheme on plugin content, so it renders unthemed), and pairs
|
|
2427
|
+
* with the DateRangePicker so all three filter controls share one popover
|
|
2428
|
+
* language.
|
|
2429
|
+
*
|
|
2430
|
+
* Keyboard follows the listbox idiom: opening (trigger click, Enter, or
|
|
2431
|
+
* its arrow keys) lands focus on the SELECTED option — scrolled to the
|
|
2432
|
+
* center like the native select — or the first one; ArrowUp/Down and
|
|
2433
|
+
* Home/End roam (options are tabIndex -1, so Tab skips the list);
|
|
2434
|
+
* Enter/Space commits the focused row; Escape closes and returns focus
|
|
2435
|
+
* to the trigger; committing closes and refocuses the trigger too. An
|
|
2436
|
+
* outside pointerdown closes without stealing focus. The option list
|
|
2437
|
+
* carries listbox/option semantics with the selection marked
|
|
2438
|
+
* (aria-selected plus a check).
|
|
2439
|
+
*
|
|
2440
|
+
* The popover interaction copies QuotaButton's pattern verbatim (click
|
|
2441
|
+
* toggles, document pointerdown outside closes, Escape closes); the plate
|
|
2442
|
+
* styling mirrors the date-range picker's panel.
|
|
2443
|
+
*
|
|
2444
|
+
* @module token-usage/client/MenuSelect
|
|
2445
|
+
*/
|
|
2446
|
+
/**
|
|
2447
|
+
* Render the trigger + menu popover.
|
|
2448
|
+
* @param props - the committed value, options, name, and change lift.
|
|
2449
|
+
* @returns the inline wrapper holding the trigger and, while open, the list.
|
|
2450
|
+
*/
|
|
2451
|
+
function MenuSelect({ value, options, ariaLabel, onChange, grow = false }) {
|
|
2452
|
+
const rootRef = (0, react.useRef)(null);
|
|
2453
|
+
const triggerRef = (0, react.useRef)(null);
|
|
2454
|
+
const optionRefs = (0, react.useRef)([]);
|
|
2455
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
2456
|
+
const focusIndexRef = (0, react.useRef)(0);
|
|
2457
|
+
const close = () => {
|
|
2458
|
+
setOpen(false);
|
|
2459
|
+
triggerRef.current?.focus();
|
|
2460
|
+
};
|
|
2461
|
+
const openMenu = () => {
|
|
2462
|
+
const selected = options.findIndex((option) => option.value === value);
|
|
2463
|
+
focusIndexRef.current = selected >= 0 ? selected : 0;
|
|
2464
|
+
setOpen(true);
|
|
2465
|
+
};
|
|
2466
|
+
(0, react.useEffect)(() => {
|
|
2467
|
+
if (!open) return;
|
|
2468
|
+
const onPointerDown = (event) => {
|
|
2469
|
+
if (event.target instanceof Node && rootRef.current?.contains(event.target) === true) return;
|
|
2470
|
+
setOpen(false);
|
|
2471
|
+
};
|
|
2472
|
+
const onKeyDown = (event) => {
|
|
2473
|
+
if (event.key === "Escape") close();
|
|
2474
|
+
};
|
|
2475
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
2476
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2477
|
+
return () => {
|
|
2478
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
2479
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
2480
|
+
};
|
|
2481
|
+
}, [open]);
|
|
2482
|
+
(0, react.useEffect)(() => {
|
|
2483
|
+
if (!open) return;
|
|
2484
|
+
const button = optionRefs.current[focusIndexRef.current];
|
|
2485
|
+
if (button === void 0 || button === null) return;
|
|
2486
|
+
button.focus({ preventScroll: true });
|
|
2487
|
+
if (typeof button.scrollIntoView === "function") button.scrollIntoView({ block: "center" });
|
|
2488
|
+
}, [open]);
|
|
2489
|
+
const commit = (index) => {
|
|
2490
|
+
const option = options[index];
|
|
2491
|
+
if (option === void 0) return;
|
|
2492
|
+
close();
|
|
2493
|
+
onChange(option.value);
|
|
2494
|
+
};
|
|
2495
|
+
const moveFocus = (index) => {
|
|
2496
|
+
const next = Math.max(0, Math.min(options.length - 1, index));
|
|
2497
|
+
focusIndexRef.current = next;
|
|
2498
|
+
optionRefs.current[next]?.focus();
|
|
2499
|
+
};
|
|
2500
|
+
const onPanelKeyDown = (event) => {
|
|
2501
|
+
if (event.key === "ArrowDown") {
|
|
2502
|
+
event.preventDefault();
|
|
2503
|
+
moveFocus(focusIndexRef.current + 1);
|
|
2504
|
+
} else if (event.key === "ArrowUp") {
|
|
2505
|
+
event.preventDefault();
|
|
2506
|
+
moveFocus(focusIndexRef.current - 1);
|
|
2507
|
+
} else if (event.key === "Home") {
|
|
2508
|
+
event.preventDefault();
|
|
2509
|
+
moveFocus(0);
|
|
2510
|
+
} else if (event.key === "End") {
|
|
2511
|
+
event.preventDefault();
|
|
2512
|
+
moveFocus(options.length - 1);
|
|
2513
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
2514
|
+
event.preventDefault();
|
|
2515
|
+
commit(focusIndexRef.current);
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
const onTriggerKeyDown = (event) => {
|
|
2519
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
2520
|
+
event.preventDefault();
|
|
2521
|
+
if (!open) openMenu();
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
const selected = options.find((option) => option.value === value);
|
|
2525
|
+
const triggerClass = [MenuSelect_module_css_default["trigger"], grow === true ? MenuSelect_module_css_default["grow"] : ""].join(" ").trim();
|
|
2526
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2527
|
+
ref: rootRef,
|
|
2528
|
+
className: MenuSelect_module_css_default["wrapper"],
|
|
2529
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2530
|
+
type: "button",
|
|
2531
|
+
ref: triggerRef,
|
|
2532
|
+
className: triggerClass,
|
|
2533
|
+
"aria-label": ariaLabel,
|
|
2534
|
+
"aria-expanded": open,
|
|
2535
|
+
"aria-haspopup": "listbox",
|
|
2536
|
+
onClick: () => {
|
|
2537
|
+
open ? close() : openMenu();
|
|
2538
|
+
},
|
|
2539
|
+
onKeyDown: onTriggerKeyDown,
|
|
2540
|
+
children: selected?.label ?? value
|
|
2541
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2542
|
+
className: MenuSelect_module_css_default["panel"],
|
|
2543
|
+
role: "listbox",
|
|
2544
|
+
"aria-label": ariaLabel,
|
|
2545
|
+
onKeyDown: onPanelKeyDown,
|
|
2546
|
+
children: options.map((option, index) => {
|
|
2547
|
+
const isSelected = option.value === value;
|
|
2548
|
+
const optionClass = [MenuSelect_module_css_default["option"], isSelected ? MenuSelect_module_css_default["optionSelected"] : ""].join(" ").trim();
|
|
2549
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2550
|
+
type: "button",
|
|
2551
|
+
role: "option",
|
|
2552
|
+
tabIndex: -1,
|
|
2553
|
+
ref: (element) => {
|
|
2554
|
+
optionRefs.current[index] = element;
|
|
2555
|
+
},
|
|
2556
|
+
className: optionClass,
|
|
2557
|
+
"aria-selected": isSelected,
|
|
2558
|
+
onClick: () => {
|
|
2559
|
+
commit(index);
|
|
2560
|
+
},
|
|
2561
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2562
|
+
className: MenuSelect_module_css_default["optionLabel"],
|
|
2563
|
+
children: option.label
|
|
2564
|
+
}), isSelected ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2565
|
+
className: MenuSelect_module_css_default["check"],
|
|
2566
|
+
"aria-hidden": "true",
|
|
2567
|
+
children: "✓"
|
|
2568
|
+
}) : null]
|
|
2569
|
+
}, option.value);
|
|
2570
|
+
})
|
|
2571
|
+
}) : null]
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2574
|
+
//#endregion
|
|
2098
2575
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\StatCard.module.css.mjs
|
|
2099
|
-
const css$3 = ".F2LbNW_card{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;flex-direction:column;gap:2px;min-width:0;padding:10px 12px;display:flex}.F2LbNW_cardLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;font-size:11px;overflow:hidden}.F2LbNW_cardValue{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis;font-size:
|
|
2576
|
+
const css$3 = ".F2LbNW_card{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;flex-direction:column;gap:2px;min-width:0;padding:10px 12px;display:flex}.F2LbNW_cardLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;font-size:11px;overflow:hidden}.F2LbNW_cardValue{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);flex-wrap:wrap;align-items:baseline;gap:4px 8px;min-width:0;font-size:18px;font-weight:600;display:flex}.F2LbNW_cardValueMain{white-space:nowrap;text-overflow:ellipsis;min-width:0;overflow:hidden}.F2LbNW_pillWrap{flex-shrink:0;display:inline-flex}.F2LbNW_pillWrap [role=tooltip]{white-space:pre;width:max-content;min-width:max-content;max-width:none;font-size:12px;font-weight:400;line-height:1.4}.F2LbNW_split{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:baseline;column-gap:4px;width:100%;display:grid}.F2LbNW_splitOk{text-align:right;min-width:0}.F2LbNW_splitSep{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary))}.F2LbNW_splitFailHead{text-align:left;min-width:0}.F2LbNW_splitFail{text-align:left;min-width:0;color:var(--dsw-alias-state-error-primary);display:block}.F2LbNW_split>.F2LbNW_pillWrap{justify-self:stretch;min-width:0;display:block}.F2LbNW_pill{font-variant-numeric:tabular-nums;white-space:nowrap;color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 12%, transparent);border:1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary) 28%, transparent);border-radius:999px;flex-shrink:0;padding:1px 7px;font-size:12px;font-weight:400;line-height:1.4}";
|
|
2100
2577
|
const tagId$3 = "@laoyuehanni/dsh-token-usage/StatCard.module.css";
|
|
2101
2578
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$3) + "]") === null) {
|
|
2102
2579
|
const tag = document.createElement("style");
|
|
@@ -2108,7 +2585,15 @@ window.__ModuleLoader__.load({
|
|
|
2108
2585
|
var StatCard_module_css_default = {
|
|
2109
2586
|
"card": "F2LbNW_card",
|
|
2110
2587
|
"cardLabel": "F2LbNW_cardLabel",
|
|
2111
|
-
"cardValue": "F2LbNW_cardValue"
|
|
2588
|
+
"cardValue": "F2LbNW_cardValue",
|
|
2589
|
+
"cardValueMain": "F2LbNW_cardValueMain",
|
|
2590
|
+
"pill": "F2LbNW_pill",
|
|
2591
|
+
"pillWrap": "F2LbNW_pillWrap",
|
|
2592
|
+
"split": "F2LbNW_split",
|
|
2593
|
+
"splitFail": "F2LbNW_splitFail",
|
|
2594
|
+
"splitFailHead": "F2LbNW_splitFailHead",
|
|
2595
|
+
"splitOk": "F2LbNW_splitOk",
|
|
2596
|
+
"splitSep": "F2LbNW_splitSep"
|
|
2112
2597
|
};
|
|
2113
2598
|
//#endregion
|
|
2114
2599
|
//#region src/client/StatCard.tsx
|
|
@@ -2128,6 +2613,108 @@ window.__ModuleLoader__.load({
|
|
|
2128
2613
|
})]
|
|
2129
2614
|
});
|
|
2130
2615
|
}
|
|
2616
|
+
/**
|
|
2617
|
+
* Compact "失败 n" chip for the requests **card** only. Hovering or focusing
|
|
2618
|
+
* it lists `限流 ×count` per class. Zero failures render nothing. Per-model
|
|
2619
|
+
* tables do not use this — they print `A/B` via {@link RequestsCell}.
|
|
2620
|
+
*/
|
|
2621
|
+
function FailurePill({ failures, failuresByCode, t }) {
|
|
2622
|
+
if (failures === 0) return null;
|
|
2623
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2624
|
+
className: StatCard_module_css_default["pillWrap"],
|
|
2625
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
2626
|
+
label: failuresTooltip(failuresByCode, t),
|
|
2627
|
+
side: "bottom",
|
|
2628
|
+
delayMs: 200,
|
|
2629
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2630
|
+
className: StatCard_module_css_default["pill"],
|
|
2631
|
+
tabIndex: 0,
|
|
2632
|
+
children: t("stat.failuresPill", { count: failures.toLocaleString() })
|
|
2633
|
+
})
|
|
2634
|
+
})
|
|
2635
|
+
});
|
|
2636
|
+
}
|
|
2637
|
+
/**
|
|
2638
|
+
* The requests tile both dashboards share: hero figure is the successful
|
|
2639
|
+
* count; a compact pill to its right carries the failure count.
|
|
2640
|
+
*/
|
|
2641
|
+
function RequestsStatCard({ requests, failures, failuresByCode, t }) {
|
|
2642
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
|
|
2643
|
+
label: t("stat.requests"),
|
|
2644
|
+
value: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2645
|
+
className: StatCard_module_css_default["cardValueMain"],
|
|
2646
|
+
children: requests.toLocaleString()
|
|
2647
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailurePill, {
|
|
2648
|
+
failures,
|
|
2649
|
+
failuresByCode,
|
|
2650
|
+
t
|
|
2651
|
+
})] })
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
/** Column header for the per-model success/fail split: same 3-track
|
|
2655
|
+
* grid as {@link RequestsCell} so the slash sits on the column midline. */
|
|
2656
|
+
function RequestsSplitHead({ t }) {
|
|
2657
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2658
|
+
className: StatCard_module_css_default["split"],
|
|
2659
|
+
children: [
|
|
2660
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2661
|
+
className: StatCard_module_css_default["splitOk"],
|
|
2662
|
+
children: t("stat.ok")
|
|
2663
|
+
}),
|
|
2664
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2665
|
+
className: StatCard_module_css_default["splitSep"],
|
|
2666
|
+
"aria-hidden": true,
|
|
2667
|
+
children: "/"
|
|
2668
|
+
}),
|
|
2669
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2670
|
+
className: StatCard_module_css_default["splitFailHead"],
|
|
2671
|
+
children: t("stat.fail")
|
|
2672
|
+
})
|
|
2673
|
+
]
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
/** One table cell: successful count, and when failures > 0 a slash on
|
|
2677
|
+
* the column midline plus the failure count in the error color.
|
|
2678
|
+
* Zero failures print only A (same left track, so the figure still
|
|
2679
|
+
* lines up with rows that have a B). Hovering B lists the per-code
|
|
2680
|
+
* breakdown. */
|
|
2681
|
+
function RequestsCell({ requests, failures, failuresByCode, t }) {
|
|
2682
|
+
const ok = requests.toLocaleString();
|
|
2683
|
+
const okFigure = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2684
|
+
className: StatCard_module_css_default["splitOk"],
|
|
2685
|
+
children: ok
|
|
2686
|
+
});
|
|
2687
|
+
if (failures === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2688
|
+
className: StatCard_module_css_default["split"],
|
|
2689
|
+
children: okFigure
|
|
2690
|
+
});
|
|
2691
|
+
const fail = failures.toLocaleString();
|
|
2692
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2693
|
+
className: StatCard_module_css_default["split"],
|
|
2694
|
+
children: [
|
|
2695
|
+
okFigure,
|
|
2696
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2697
|
+
className: StatCard_module_css_default["splitSep"],
|
|
2698
|
+
"aria-hidden": true,
|
|
2699
|
+
children: "/"
|
|
2700
|
+
}),
|
|
2701
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2702
|
+
className: StatCard_module_css_default["pillWrap"],
|
|
2703
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
2704
|
+
label: failuresTooltip(failuresByCode, t),
|
|
2705
|
+
side: "bottom",
|
|
2706
|
+
delayMs: 200,
|
|
2707
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2708
|
+
className: StatCard_module_css_default["splitFail"],
|
|
2709
|
+
tabIndex: 0,
|
|
2710
|
+
"aria-label": t("stat.failuresPill", { count: fail }),
|
|
2711
|
+
children: fail
|
|
2712
|
+
})
|
|
2713
|
+
})
|
|
2714
|
+
})
|
|
2715
|
+
]
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2131
2718
|
//#endregion
|
|
2132
2719
|
//#region src/client/trend-chart/axis.ts
|
|
2133
2720
|
/**
|
|
@@ -2285,6 +2872,34 @@ window.__ModuleLoader__.load({
|
|
|
2285
2872
|
};
|
|
2286
2873
|
return null;
|
|
2287
2874
|
}
|
|
2875
|
+
/**
|
|
2876
|
+
* The cumulative view of a series: every point's `tokens` replaced by the
|
|
2877
|
+
* running total up to and including that point (a prefix sum), so the chart
|
|
2878
|
+
* reads as a monotonic rise. Orthogonal to the mode — all three input
|
|
2879
|
+
* shapes are time-ascending, so a plain forward fold is order-correct. The
|
|
2880
|
+
* input series is left untouched; each point is copied with only `tokens`
|
|
2881
|
+
* rewritten, so the renderer's shape probes (`'time' in point`) keep working.
|
|
2882
|
+
* @param series - the series from {@link buildChartPoints}.
|
|
2883
|
+
* @returns a new series of the same mode and shape.
|
|
2884
|
+
*/
|
|
2885
|
+
function cumulateSeries(series) {
|
|
2886
|
+
let running = 0;
|
|
2887
|
+
const fold = (points) => points.map((point) => {
|
|
2888
|
+
running += point.tokens;
|
|
2889
|
+
return {
|
|
2890
|
+
...point,
|
|
2891
|
+
tokens: running
|
|
2892
|
+
};
|
|
2893
|
+
});
|
|
2894
|
+
if (series.mode === "equidistant") return {
|
|
2895
|
+
mode: "equidistant",
|
|
2896
|
+
points: fold(series.points)
|
|
2897
|
+
};
|
|
2898
|
+
return {
|
|
2899
|
+
mode: "temporal",
|
|
2900
|
+
points: fold(series.points)
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2288
2903
|
/** A series that already carries `count` (the host's `fields=session`
|
|
2289
2904
|
* downsample) is plotted as-is; a raw per-request series is folded here. */
|
|
2290
2905
|
function bucketsOf(requests) {
|
|
@@ -2445,21 +3060,28 @@ window.__ModuleLoader__.load({
|
|
|
2445
3060
|
/**
|
|
2446
3061
|
* Apply the `t`-based localisation to a point's `full` tooltip. The pre-shape
|
|
2447
3062
|
* labels live in points.ts; the chart's aria-label and the floating tooltip
|
|
2448
|
-
* both use this single source so the two stay consistent.
|
|
3063
|
+
* both use this single source so the two stay consistent. Cumulative mode
|
|
3064
|
+
* swaps in its own phrasing so "total" never reads ambiguous next to a
|
|
3065
|
+
* running sum.
|
|
2449
3066
|
* @param t - the locale seat.
|
|
2450
3067
|
* @param point - the pre-shaped point.
|
|
3068
|
+
* @param mode - the active y-axis mode.
|
|
2451
3069
|
* @returns the tooltip / aria-label text.
|
|
2452
3070
|
*/
|
|
2453
|
-
function tipOf(t, point) {
|
|
2454
|
-
if (point.time !== void 0)
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
3071
|
+
function tipOf(t, point, mode) {
|
|
3072
|
+
if (point.time !== void 0) {
|
|
3073
|
+
const params = {
|
|
3074
|
+
window: point.full,
|
|
3075
|
+
count: String(point.count ?? 0),
|
|
3076
|
+
tokens: formatTokens(point.tokens)
|
|
3077
|
+
};
|
|
3078
|
+
return mode === "cumulative" ? t("chart.cumulativeBucket", params) : t("chart.bucket", params);
|
|
3079
|
+
}
|
|
3080
|
+
const params = {
|
|
2460
3081
|
day: point.full,
|
|
2461
3082
|
tokens: formatTokens(point.tokens)
|
|
2462
|
-
}
|
|
3083
|
+
};
|
|
3084
|
+
return mode === "cumulative" ? t("chart.cumulativePoint", params) : t("chart.pointLabel", params);
|
|
2463
3085
|
}
|
|
2464
3086
|
/**
|
|
2465
3087
|
* Render the daily / hourly / request-bucketed token line chart. Pure
|
|
@@ -2474,22 +3096,25 @@ window.__ModuleLoader__.load({
|
|
|
2474
3096
|
* @param props - the filtered per-day rows plus the optional per-hour rows
|
|
2475
3097
|
* (when present the chart plots hours instead of days), the optional
|
|
2476
3098
|
* per-request series (session-scoped reads), the active range bounds
|
|
2477
|
-
* (absent when unfiltered; the chart then spans first to last row),
|
|
3099
|
+
* (absent when unfiltered; the chart then spans first to last row), the
|
|
3100
|
+
* optional y-axis mode (interval totals, or their running cumulative sum),
|
|
3101
|
+
* and
|
|
2478
3102
|
* the `t` seat for the empty hint and chart aria-label.
|
|
2479
3103
|
* @returns the SVG chart, or a placeholder for an empty range.
|
|
2480
3104
|
*/
|
|
2481
|
-
function TrendChart({ rows, hours, requests, from, to, t }) {
|
|
2482
|
-
const
|
|
3105
|
+
function TrendChart({ rows, hours, requests, from, to, mode = "interval", t }) {
|
|
3106
|
+
const base = buildChartPoints({
|
|
2483
3107
|
rows,
|
|
2484
3108
|
hours,
|
|
2485
3109
|
requests,
|
|
2486
3110
|
from,
|
|
2487
3111
|
to
|
|
2488
3112
|
});
|
|
2489
|
-
if (
|
|
3113
|
+
if (base === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2490
3114
|
className: TrendChart_module_css_default.empty,
|
|
2491
3115
|
children: t("chart.empty")
|
|
2492
3116
|
});
|
|
3117
|
+
const series = mode === "cumulative" ? cumulateSeries(base) : base;
|
|
2493
3118
|
const points = series.points.map((point) => ({
|
|
2494
3119
|
key: point.key,
|
|
2495
3120
|
label: point.label,
|
|
@@ -2506,7 +3131,7 @@ window.__ModuleLoader__.load({
|
|
|
2506
3131
|
const activePoint = active === null ? null : points[active] ?? null;
|
|
2507
3132
|
const y = (tokens) => 152 - tokens / top * innerHeight;
|
|
2508
3133
|
const path = points.map((point, index) => `${index === 0 ? "M" : "L"}${xs[index].toFixed(1)},${y(point.tokens).toFixed(1)}`).join(" ");
|
|
2509
|
-
const chartAria = series.mode === "temporal" ? t("chart.ariaRequests") : hours !== void 0 ? t("chart.ariaHour") : t("chart.aria");
|
|
3134
|
+
const chartAria = mode === "cumulative" ? t("chart.ariaCumulative") : series.mode === "temporal" ? t("chart.ariaRequests") : hours !== void 0 ? t("chart.ariaHour") : t("chart.aria");
|
|
2510
3135
|
const hitExtent = (index) => {
|
|
2511
3136
|
if (points.length === 1) return {
|
|
2512
3137
|
start: LEFT,
|
|
@@ -2575,7 +3200,7 @@ window.__ModuleLoader__.load({
|
|
|
2575
3200
|
width: hit.width,
|
|
2576
3201
|
height: innerHeight,
|
|
2577
3202
|
fill: "transparent",
|
|
2578
|
-
"aria-label": tipOf(t, point),
|
|
3203
|
+
"aria-label": tipOf(t, point, mode),
|
|
2579
3204
|
role: "button",
|
|
2580
3205
|
tabIndex: 0,
|
|
2581
3206
|
className: TrendChart_module_css_default.hit,
|
|
@@ -2585,7 +3210,7 @@ window.__ModuleLoader__.load({
|
|
|
2585
3210
|
}, point.key);
|
|
2586
3211
|
}),
|
|
2587
3212
|
activePoint !== null ? (() => {
|
|
2588
|
-
const label = tipOf(t, activePoint);
|
|
3213
|
+
const label = tipOf(t, activePoint, mode);
|
|
2589
3214
|
const labelWidth = label.length * 6.2 + 12;
|
|
2590
3215
|
const center = xs[active];
|
|
2591
3216
|
const left = Math.min(Math.max(center - labelWidth / 2, LEFT), 784 - labelWidth);
|
|
@@ -2619,7 +3244,7 @@ window.__ModuleLoader__.load({
|
|
|
2619
3244
|
}
|
|
2620
3245
|
//#endregion
|
|
2621
3246
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageSection.module.css.mjs
|
|
2622
|
-
const css$1 = ".RbkiSa_section{flex-direction:column;gap:16px;width:100%;display:flex}.RbkiSa_head{justify-content:space-between;align-items:center;gap:12px;display:flex}.RbkiSa_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}.RbkiSa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.RbkiSa_rateNote{color:var(--dsw-alias-label-secondary);margin:6px 0 0;font-size:12px}.RbkiSa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}.RbkiSa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:14px;font-weight:600}.RbkiSa_tableWrap{
|
|
3247
|
+
const css$1 = ".RbkiSa_section{flex-direction:column;gap:16px;width:100%;display:flex}.RbkiSa_head{justify-content:space-between;align-items:center;gap:12px;display:flex}.RbkiSa_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}.RbkiSa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.RbkiSa_rateNote{color:var(--dsw-alias-label-secondary);margin:6px 0 0;font-size:12px}.RbkiSa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}.RbkiSa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:14px;font-weight:600}.RbkiSa_tableWrap{max-height:420px;overflow:auto}.RbkiSa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:500px;font-size:12px}.RbkiSa_table th,.RbkiSa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.RbkiSa_table th.RbkiSa_modelHead,.RbkiSa_table td.RbkiSa_modelCol{text-align:left;width:150px;max-width:150px}.RbkiSa_table th{color:var(--dsw-alias-label-secondary);z-index:1;background:var(--dsw-alias-bg-layer-2);font-weight:500;position:sticky;top:0}.RbkiSa_table td{color:var(--dsw-alias-label-primary)}.RbkiSa_empty{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}.RbkiSa_button{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:6px;padding:4px 12px;font-size:13px;line-height:20px}.RbkiSa_button:hover{background:var(--dsw-interactive-bg-hover)}.RbkiSa_filters{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}.RbkiSa_cards{grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:8px;display:grid}.RbkiSa_warning{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);border-radius:6px;margin:0;padding:6px 10px;font-size:12px}.RbkiSa_modelCell{align-items:center;gap:4px;max-width:138px;display:inline-flex;position:relative}.RbkiSa_modelName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.RbkiSa_unpricedTag{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.RbkiSa_pricingButton{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.RbkiSa_pricingButton:hover{color:var(--dsw-alias-state-warn-primary);background:var(--dsw-alias-state-warn-tertiary);border-color:var(--dsw-alias-state-warn-primary)}.RbkiSa_dialog{width:min(600px,100vw - 48px);max-height:calc(100vh - 48px);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:14px 16px;overflow-y:auto}.RbkiSa_dialog::backdrop{background:#0006}.RbkiSa_dialogHead{justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px;display:flex}.RbkiSa_dialogTitle{text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:14px;font-weight:600;overflow:hidden}.RbkiSa_dialogClose{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;flex:none;padding:2px 8px;font-size:12px;line-height:18px}.RbkiSa_dialogClose:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-interactive-bg-hover)}th.RbkiSa_conditionHead,td.RbkiSa_conditionCell{text-align:left;white-space:normal;min-width:200px}td.RbkiSa_conditionCell{color:var(--dsw-alias-label-secondary);padding-left:20px}.RbkiSa_groupRow>td{text-align:left;white-space:normal;color:var(--dsw-alias-label-secondary);border-bottom:none;padding-top:8px;font-size:11px;font-weight:600}.RbkiSa_groupRow:not(:first-child)>td{border-top:1px solid var(--dsw-alias-border-l1)}";
|
|
2623
3248
|
const tagId$1 = "@laoyuehanni/dsh-token-usage/TokenUsageSection.module.css";
|
|
2624
3249
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
2625
3250
|
const tag = document.createElement("style");
|
|
@@ -2633,8 +3258,6 @@ window.__ModuleLoader__.load({
|
|
|
2633
3258
|
"cards": "RbkiSa_cards",
|
|
2634
3259
|
"conditionCell": "RbkiSa_conditionCell",
|
|
2635
3260
|
"conditionHead": "RbkiSa_conditionHead",
|
|
2636
|
-
"control": "RbkiSa_control",
|
|
2637
|
-
"dateControl": "RbkiSa_dateControl",
|
|
2638
3261
|
"dialog": "RbkiSa_dialog",
|
|
2639
3262
|
"dialogClose": "RbkiSa_dialogClose",
|
|
2640
3263
|
"dialogHead": "RbkiSa_dialogHead",
|
|
@@ -2646,12 +3269,10 @@ window.__ModuleLoader__.load({
|
|
|
2646
3269
|
"head": "RbkiSa_head",
|
|
2647
3270
|
"modelCell": "RbkiSa_modelCell",
|
|
2648
3271
|
"modelCol": "RbkiSa_modelCol",
|
|
2649
|
-
"modelControl": "RbkiSa_modelControl",
|
|
2650
3272
|
"modelHead": "RbkiSa_modelHead",
|
|
2651
3273
|
"modelName": "RbkiSa_modelName",
|
|
2652
3274
|
"muted": "RbkiSa_muted",
|
|
2653
3275
|
"pricingButton": "RbkiSa_pricingButton",
|
|
2654
|
-
"rangeSeparator": "RbkiSa_rangeSeparator",
|
|
2655
3276
|
"rateNote": "RbkiSa_rateNote",
|
|
2656
3277
|
"section": "RbkiSa_section",
|
|
2657
3278
|
"subtitle": "RbkiSa_subtitle",
|
|
@@ -2703,12 +3324,6 @@ window.__ModuleLoader__.load({
|
|
|
2703
3324
|
if (filters.model !== "") params.set("model", filters.model);
|
|
2704
3325
|
return Array.from(params).length > 0 ? `?${params.toString()}` : "";
|
|
2705
3326
|
}
|
|
2706
|
-
/** Quick-range day span in days (1 = today only, inclusive on both ends). */
|
|
2707
|
-
const QUICK_DAYS = [
|
|
2708
|
-
1,
|
|
2709
|
-
7,
|
|
2710
|
-
30
|
|
2711
|
-
];
|
|
2712
3327
|
/** The day keys of one quick range: today minus (days - 1) through today. */
|
|
2713
3328
|
function quickRange(days) {
|
|
2714
3329
|
return {
|
|
@@ -2872,81 +3487,79 @@ window.__ModuleLoader__.load({
|
|
|
2872
3487
|
})]
|
|
2873
3488
|
});
|
|
2874
3489
|
}
|
|
2875
|
-
/**
|
|
3490
|
+
/** Quick-range menu entries (labels are locale-free day counts). */
|
|
3491
|
+
const QUICK_OPTIONS = [
|
|
3492
|
+
{
|
|
3493
|
+
value: "1",
|
|
3494
|
+
label: "1d"
|
|
3495
|
+
},
|
|
3496
|
+
{
|
|
3497
|
+
value: "7",
|
|
3498
|
+
label: "7d"
|
|
3499
|
+
},
|
|
3500
|
+
{
|
|
3501
|
+
value: "30",
|
|
3502
|
+
label: "30d"
|
|
3503
|
+
}
|
|
3504
|
+
];
|
|
3505
|
+
/** The filter bar: quick range menu, day-range picker popover, model
|
|
3506
|
+
* menu — one row, one popover language. */
|
|
2876
3507
|
function FilterBar({ filters, models, onChange, t }) {
|
|
2877
|
-
const quickValue =
|
|
3508
|
+
const quickValue = QUICK_OPTIONS.find((option) => isQuickActive(Number(option.value), filters))?.value ?? (filters.from === "" && filters.to === "" ? "all" : "custom");
|
|
2878
3509
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2879
3510
|
className: TokenUsageSection_module_css_default["filters"],
|
|
2880
3511
|
children: [
|
|
2881
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2882
|
-
|
|
2883
|
-
className: TokenUsageSection_module_css_default["control"],
|
|
3512
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuSelect, {
|
|
3513
|
+
ariaLabel: t("filter.quickRange"),
|
|
2884
3514
|
value: quickValue,
|
|
2885
|
-
|
|
2886
|
-
|
|
3515
|
+
options: [
|
|
3516
|
+
...QUICK_OPTIONS,
|
|
3517
|
+
{
|
|
3518
|
+
value: "all",
|
|
3519
|
+
label: t("filter.allDates")
|
|
3520
|
+
},
|
|
3521
|
+
{
|
|
3522
|
+
value: "custom",
|
|
3523
|
+
label: t("filter.custom")
|
|
3524
|
+
}
|
|
3525
|
+
],
|
|
3526
|
+
onChange: (value) => {
|
|
3527
|
+
if (value === "all") onChange({
|
|
3528
|
+
...filters,
|
|
3529
|
+
from: "",
|
|
3530
|
+
to: ""
|
|
3531
|
+
});
|
|
3532
|
+
const days = Number(value);
|
|
2887
3533
|
if (days > 0) onChange({
|
|
2888
3534
|
...filters,
|
|
2889
3535
|
...quickRange(days)
|
|
2890
3536
|
});
|
|
2891
|
-
}
|
|
2892
|
-
children: [
|
|
2893
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2894
|
-
value: "1",
|
|
2895
|
-
children: "1d"
|
|
2896
|
-
}),
|
|
2897
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2898
|
-
value: "7",
|
|
2899
|
-
children: "7d"
|
|
2900
|
-
}),
|
|
2901
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2902
|
-
value: "30",
|
|
2903
|
-
children: "30d"
|
|
2904
|
-
}),
|
|
2905
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2906
|
-
value: "custom",
|
|
2907
|
-
children: t("filter.custom")
|
|
2908
|
-
})
|
|
2909
|
-
]
|
|
2910
|
-
}),
|
|
2911
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2912
|
-
type: "date",
|
|
2913
|
-
"aria-label": t("filter.from"),
|
|
2914
|
-
className: TokenUsageSection_module_css_default["dateControl"],
|
|
2915
|
-
value: filters.from,
|
|
2916
|
-
onChange: (event) => onChange({
|
|
2917
|
-
...filters,
|
|
2918
|
-
from: event.target.value
|
|
2919
|
-
})
|
|
2920
|
-
}),
|
|
2921
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2922
|
-
className: TokenUsageSection_module_css_default["rangeSeparator"],
|
|
2923
|
-
children: t("filter.separator")
|
|
3537
|
+
}
|
|
2924
3538
|
}),
|
|
2925
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
value: filters.to,
|
|
2930
|
-
onChange: (event) => onChange({
|
|
3539
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRangePicker, {
|
|
3540
|
+
from: filters.from,
|
|
3541
|
+
to: filters.to,
|
|
3542
|
+
onChange: (next) => onChange({
|
|
2931
3543
|
...filters,
|
|
2932
|
-
|
|
2933
|
-
})
|
|
3544
|
+
...next
|
|
3545
|
+
}),
|
|
3546
|
+
t
|
|
2934
3547
|
}),
|
|
2935
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2936
|
-
|
|
2937
|
-
|
|
3548
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuSelect, {
|
|
3549
|
+
ariaLabel: t("filter.model"),
|
|
3550
|
+
grow: true,
|
|
2938
3551
|
value: filters.model,
|
|
2939
|
-
|
|
2940
|
-
...filters,
|
|
2941
|
-
model: event.target.value
|
|
2942
|
-
}),
|
|
2943
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
3552
|
+
options: [{
|
|
2944
3553
|
value: "",
|
|
2945
|
-
|
|
2946
|
-
}
|
|
3554
|
+
label: t("filter.allModels")
|
|
3555
|
+
}, ...models.map((model) => ({
|
|
2947
3556
|
value: model,
|
|
2948
|
-
|
|
2949
|
-
}
|
|
3557
|
+
label: model
|
|
3558
|
+
}))],
|
|
3559
|
+
onChange: (model) => onChange({
|
|
3560
|
+
...filters,
|
|
3561
|
+
model
|
|
3562
|
+
})
|
|
2950
3563
|
})
|
|
2951
3564
|
]
|
|
2952
3565
|
});
|
|
@@ -3040,16 +3653,18 @@ window.__ModuleLoader__.load({
|
|
|
3040
3653
|
onChange: setFilters,
|
|
3041
3654
|
t
|
|
3042
3655
|
}),
|
|
3043
|
-
total.requests === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3656
|
+
total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3044
3657
|
className: TokenUsageSection_module_css_default["empty"],
|
|
3045
3658
|
children: t("empty")
|
|
3046
3659
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3047
3660
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3048
3661
|
className: TokenUsageSection_module_css_default["cards"],
|
|
3049
3662
|
children: [
|
|
3050
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3051
|
-
|
|
3052
|
-
|
|
3663
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
|
|
3664
|
+
requests: total.requests,
|
|
3665
|
+
failures: total.failures ?? 0,
|
|
3666
|
+
failuresByCode: total.failuresByCode,
|
|
3667
|
+
t
|
|
3053
3668
|
}),
|
|
3054
3669
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
|
|
3055
3670
|
label: t("stat.cost"),
|
|
@@ -3115,7 +3730,10 @@ window.__ModuleLoader__.load({
|
|
|
3115
3730
|
className: TokenUsageSection_module_css_default["modelHead"],
|
|
3116
3731
|
children: t("filter.model")
|
|
3117
3732
|
}),
|
|
3118
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3733
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3734
|
+
"aria-label": t("stat.successFail"),
|
|
3735
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
|
|
3736
|
+
}),
|
|
3119
3737
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") }),
|
|
3120
3738
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.totalTokens") }),
|
|
3121
3739
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
|
|
@@ -3145,7 +3763,12 @@ window.__ModuleLoader__.load({
|
|
|
3145
3763
|
})]
|
|
3146
3764
|
})
|
|
3147
3765
|
}),
|
|
3148
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children:
|
|
3766
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
|
|
3767
|
+
requests: row.totals.requests,
|
|
3768
|
+
failures: row.totals.failures ?? 0,
|
|
3769
|
+
failuresByCode: row.totals.failuresByCode,
|
|
3770
|
+
t
|
|
3771
|
+
}) }),
|
|
3149
3772
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: rules !== void 0 ? formatCost(row.cost, view) : "—" }),
|
|
3150
3773
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(totalTokens(row.totals)) }),
|
|
3151
3774
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.inputTokens) }),
|
|
@@ -3170,7 +3793,7 @@ window.__ModuleLoader__.load({
|
|
|
3170
3793
|
}
|
|
3171
3794
|
//#endregion
|
|
3172
3795
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\UsageView.module.css.mjs
|
|
3173
|
-
const css = "._0MkXVa_root{box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;margin:0 auto;display:flex;overflow-y:auto}._0MkXVa_head{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}._0MkXVa_headRight{align-items:center;gap:10px;display:flex}._0MkXVa_back{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;padding:3px 10px;font-size:12px}._0MkXVa_back:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}._0MkXVa_segmented{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}._0MkXVa_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 12px;font-size:12px;font-weight:500}._0MkXVa_segBtn:hover:not(._0MkXVa_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._0MkXVa_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._0MkXVa_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._0MkXVa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._0MkXVa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._0MkXVa_empty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0 0;font-size:13px}._0MkXVa_button{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;align-self:flex-start;padding:3px 10px;font-size:12px}._0MkXVa_warning{color:var(--dsw-alias-state-warning-primary,var(--dsw-alias-label-secondary));margin:0;font-size:12px}._0MkXVa_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px}._0MkXVa_cards{grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;display:grid}._0MkXVa_tokenStrip{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:18px;padding:6px 2px 0;font-size:12px;display:flex}._0MkXVa_tokenStrip b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}._0MkXVa_mid{grid-template-columns:minmax(0,3fr) minmax(0,2fr);align-items:start;gap:14px;display:grid}._0MkXVa_chartCol,._0MkXVa_modelCol,._0MkXVa_subagents{flex-direction:column;gap:6px;min-width:0;display:flex}._0MkXVa_subagentsHead{align-items:center;gap:8px;display:flex}._0MkXVa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px;font-weight:600}._0MkXVa_tableWrap{overflow-x:auto}._0MkXVa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:480px;font-size:12px}._0MkXVa_table th,._0MkXVa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}._0MkXVa_table th:first-child,._0MkXVa_table td:first-child,._0MkXVa_modelHead{text-align:left}._0MkXVa_modelCell{font-variant-numeric:normal;text-overflow:ellipsis;max-width:180px;overflow:hidden}._0MkXVa_childLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;max-width:220px;padding:0;font-size:12px;overflow:hidden}._0MkXVa_childLink:hover{text-decoration:underline}._0MkXVa_nestedBadge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:6px;font-size:11px}@media (width<=900px){._0MkXVa_cards{grid-template-columns:repeat(3,minmax(0,1fr))}._0MkXVa_mid{grid-template-columns:1fr}}";
|
|
3796
|
+
const css = "._0MkXVa_root{box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;margin:0 auto;display:flex;overflow-y:auto}._0MkXVa_head{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}._0MkXVa_headRight{align-items:center;gap:10px;display:flex}._0MkXVa_back{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;padding:3px 10px;font-size:12px}._0MkXVa_back:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}._0MkXVa_segmented{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}._0MkXVa_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 12px;font-size:12px;font-weight:500}._0MkXVa_segBtn:hover:not(._0MkXVa_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._0MkXVa_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._0MkXVa_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._0MkXVa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._0MkXVa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._0MkXVa_empty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0 0;font-size:13px}._0MkXVa_button{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;align-self:flex-start;padding:3px 10px;font-size:12px}._0MkXVa_warning{color:var(--dsw-alias-state-warning-primary,var(--dsw-alias-label-secondary));margin:0;font-size:12px}._0MkXVa_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px}._0MkXVa_cards{grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;display:grid}._0MkXVa_tokenStrip{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:18px;padding:6px 2px 0;font-size:12px;display:flex}._0MkXVa_tokenStrip b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}._0MkXVa_mid{grid-template-columns:minmax(0,3fr) minmax(0,2fr);align-items:start;gap:14px;display:grid}._0MkXVa_chartCol,._0MkXVa_modelCol,._0MkXVa_subagents{flex-direction:column;gap:6px;min-width:0;display:flex}._0MkXVa_subagentsHead,._0MkXVa_chartHead{align-items:center;gap:8px;display:flex}._0MkXVa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px;font-weight:600}._0MkXVa_tableWrap{overflow-x:auto}._0MkXVa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:480px;font-size:12px}._0MkXVa_table th,._0MkXVa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}._0MkXVa_table th:first-child,._0MkXVa_table td:first-child,._0MkXVa_modelHead{text-align:left}._0MkXVa_modelCell{font-variant-numeric:normal;text-overflow:ellipsis;max-width:180px;overflow:hidden}._0MkXVa_childLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;max-width:220px;padding:0;font-size:12px;overflow:hidden}._0MkXVa_childLink:hover{text-decoration:underline}._0MkXVa_nestedBadge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:6px;font-size:11px}@media (width<=900px){._0MkXVa_cards{grid-template-columns:repeat(3,minmax(0,1fr))}._0MkXVa_mid{grid-template-columns:1fr}}";
|
|
3174
3797
|
const tagId = "@laoyuehanni/dsh-token-usage/UsageView.module.css";
|
|
3175
3798
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
3176
3799
|
const tag = document.createElement("style");
|
|
@@ -3184,6 +3807,7 @@ window.__ModuleLoader__.load({
|
|
|
3184
3807
|
"button": "_0MkXVa_button",
|
|
3185
3808
|
"cards": "_0MkXVa_cards",
|
|
3186
3809
|
"chartCol": "_0MkXVa_chartCol",
|
|
3810
|
+
"chartHead": "_0MkXVa_chartHead",
|
|
3187
3811
|
"childLink": "_0MkXVa_childLink",
|
|
3188
3812
|
"empty": "_0MkXVa_empty",
|
|
3189
3813
|
"error": "_0MkXVa_error",
|
|
@@ -3214,11 +3838,12 @@ window.__ModuleLoader__.load({
|
|
|
3214
3838
|
* The conversation view tab "Usage" (browser half): one entry of the
|
|
3215
3839
|
* `conversation.view` slot ring (beside Chat / Trajectory), rendering the
|
|
3216
3840
|
* per-session token & cost dashboard for the ACTIVE conversation. The tab
|
|
3217
|
-
* shows the focused session's totals (
|
|
3218
|
-
* TTFT average, decode throughput) with a
|
|
3219
|
-
* alone and its whole subagent subtree, a
|
|
3220
|
-
* per-model table from the host stats route
|
|
3221
|
-
* subagent table below — each row drill-in
|
|
3841
|
+
* shows the focused session's totals (successful requests with a failure
|
|
3842
|
+
* pill, 4 token buckets, cost, hit rate, TTFT average, decode throughput) with a
|
|
3843
|
+
* scope switch between the session alone and its whole subagent subtree, a
|
|
3844
|
+
* per-hour trend chart and the per-model table from the host stats route
|
|
3845
|
+
* (`sessionId`-scoped), and a subagent table below — each row drill-in
|
|
3846
|
+
* switches the focus to that child.
|
|
3222
3847
|
*
|
|
3223
3848
|
* Data sources: token/cost figures come from the host route (the pricing
|
|
3224
3849
|
* rule chain's authority); TTFT and throughput come from the framework's
|
|
@@ -3259,6 +3884,7 @@ window.__ModuleLoader__.load({
|
|
|
3259
3884
|
const rootRef = (0, react.useRef)(null);
|
|
3260
3885
|
useColorSchemeMirror(rootRef);
|
|
3261
3886
|
const [scope, setScope] = (0, react.useState)("session");
|
|
3887
|
+
const [chartMode, setChartMode] = (0, react.useState)("interval");
|
|
3262
3888
|
const [focusId, setFocusId] = (0, react.useState)(sessionId);
|
|
3263
3889
|
(0, react.useEffect)(() => {
|
|
3264
3890
|
setFocusId(sessionId);
|
|
@@ -3371,16 +3997,18 @@ window.__ModuleLoader__.load({
|
|
|
3371
3997
|
className: UsageView_module_css_default["root"],
|
|
3372
3998
|
children: [
|
|
3373
3999
|
header,
|
|
3374
|
-
total.requests === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4000
|
+
total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3375
4001
|
className: UsageView_module_css_default["empty"],
|
|
3376
4002
|
children: t("view.empty")
|
|
3377
4003
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3378
4004
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3379
4005
|
className: UsageView_module_css_default["cards"],
|
|
3380
4006
|
children: [
|
|
3381
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3382
|
-
|
|
3383
|
-
|
|
4007
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
|
|
4008
|
+
requests: total.requests,
|
|
4009
|
+
failures: total.failures ?? 0,
|
|
4010
|
+
failuresByCode: total.failuresByCode,
|
|
4011
|
+
t
|
|
3384
4012
|
}),
|
|
3385
4013
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
|
|
3386
4014
|
label: t("stat.cost"),
|
|
@@ -3442,11 +4070,32 @@ window.__ModuleLoader__.load({
|
|
|
3442
4070
|
className: UsageView_module_css_default["mid"],
|
|
3443
4071
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3444
4072
|
className: UsageView_module_css_default["chartCol"],
|
|
3445
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
3446
|
-
className: UsageView_module_css_default["
|
|
3447
|
-
children:
|
|
4073
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4074
|
+
className: UsageView_module_css_default["chartHead"],
|
|
4075
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
4076
|
+
className: UsageView_module_css_default["subtitle"],
|
|
4077
|
+
children: t("view.chart.title")
|
|
4078
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4079
|
+
className: UsageView_module_css_default["segmented"],
|
|
4080
|
+
role: "group",
|
|
4081
|
+
"aria-label": t("chart.mode.label"),
|
|
4082
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4083
|
+
type: "button",
|
|
4084
|
+
className: chartMode === "interval" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
|
|
4085
|
+
"aria-pressed": chartMode === "interval",
|
|
4086
|
+
onClick: () => setChartMode("interval"),
|
|
4087
|
+
children: t("chart.mode.interval")
|
|
4088
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4089
|
+
type: "button",
|
|
4090
|
+
className: chartMode === "cumulative" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
|
|
4091
|
+
"aria-pressed": chartMode === "cumulative",
|
|
4092
|
+
onClick: () => setChartMode("cumulative"),
|
|
4093
|
+
children: t("chart.mode.cumulative")
|
|
4094
|
+
})]
|
|
4095
|
+
})]
|
|
3448
4096
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
|
|
3449
4097
|
rows: summary.byDay,
|
|
4098
|
+
mode: chartMode,
|
|
3450
4099
|
t,
|
|
3451
4100
|
...summary.requestSeries !== void 0 ? { requests: summary.requestSeries } : {},
|
|
3452
4101
|
...summary.byDay.length === 1 ? { hours: summary.byHour } : {}
|
|
@@ -3466,7 +4115,10 @@ window.__ModuleLoader__.load({
|
|
|
3466
4115
|
className: UsageView_module_css_default["modelHead"],
|
|
3467
4116
|
children: t("filter.model")
|
|
3468
4117
|
}),
|
|
3469
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
4118
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
4119
|
+
"aria-label": t("stat.successFail"),
|
|
4120
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
|
|
4121
|
+
}),
|
|
3470
4122
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
|
|
3471
4123
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.output") }),
|
|
3472
4124
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheRead") }),
|
|
@@ -3478,7 +4130,12 @@ window.__ModuleLoader__.load({
|
|
|
3478
4130
|
className: UsageView_module_css_default["modelCell"],
|
|
3479
4131
|
children: row.model
|
|
3480
4132
|
}),
|
|
3481
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children:
|
|
4133
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
|
|
4134
|
+
requests: row.totals.requests,
|
|
4135
|
+
failures: row.totals.failures ?? 0,
|
|
4136
|
+
failuresByCode: row.totals.failuresByCode,
|
|
4137
|
+
t
|
|
4138
|
+
}) }),
|
|
3482
4139
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.inputTokens) }),
|
|
3483
4140
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.outputTokens) }),
|
|
3484
4141
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.cacheReadTokens) }),
|
|
@@ -3566,7 +4223,7 @@ window.__ModuleLoader__.load({
|
|
|
3566
4223
|
})
|
|
3567
4224
|
})]
|
|
3568
4225
|
}),
|
|
3569
|
-
total.requests > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4226
|
+
(total.requests > 0 || (total.failures ?? 0) > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3570
4227
|
className: UsageView_module_css_default["note"],
|
|
3571
4228
|
children: t("view.note")
|
|
3572
4229
|
})
|
|
@@ -3591,12 +4248,36 @@ window.__ModuleLoader__.load({
|
|
|
3591
4248
|
"nav.label": "Token 用量",
|
|
3592
4249
|
"filter.quickRange": "快捷区间",
|
|
3593
4250
|
"filter.custom": "自定义",
|
|
3594
|
-
"filter.
|
|
3595
|
-
"filter.
|
|
4251
|
+
"filter.dateRange": "日期范围",
|
|
4252
|
+
"filter.allDates": "全部日期",
|
|
4253
|
+
"filter.clear": "清除范围",
|
|
3596
4254
|
"filter.separator": "至",
|
|
3597
4255
|
"filter.model": "模型",
|
|
3598
4256
|
"filter.allModels": "全部模型",
|
|
3599
|
-
"
|
|
4257
|
+
"calendar.monthTitle": "{year}年{month}月",
|
|
4258
|
+
"calendar.prevMonth": "上个月",
|
|
4259
|
+
"calendar.nextMonth": "下个月",
|
|
4260
|
+
"calendar.weekday.0": "一",
|
|
4261
|
+
"calendar.weekday.1": "二",
|
|
4262
|
+
"calendar.weekday.2": "三",
|
|
4263
|
+
"calendar.weekday.3": "四",
|
|
4264
|
+
"calendar.weekday.4": "五",
|
|
4265
|
+
"calendar.weekday.5": "六",
|
|
4266
|
+
"calendar.weekday.6": "日",
|
|
4267
|
+
"stat.requests": "成功请求数",
|
|
4268
|
+
"stat.successFail": "成功/失败",
|
|
4269
|
+
"stat.ok": "成功",
|
|
4270
|
+
"stat.fail": "失败",
|
|
4271
|
+
"stat.failuresPill": "失败 {count}",
|
|
4272
|
+
"fail.RATE_LIMIT": "限流",
|
|
4273
|
+
"fail.SERVER": "服务异常",
|
|
4274
|
+
"fail.TIMEOUT": "超时",
|
|
4275
|
+
"fail.TRANSPORT": "网络异常",
|
|
4276
|
+
"fail.EMPTY_RESPONSE": "空响应",
|
|
4277
|
+
"fail.QUOTA": "配额耗尽",
|
|
4278
|
+
"fail.CONTEXT_WINDOW_EXCEEDED": "上下文超限",
|
|
4279
|
+
"fail.INVALID_CREDENTIAL": "凭证无效",
|
|
4280
|
+
"fail.UNKNOWN": "未知错误",
|
|
3600
4281
|
"stat.totalTokens": "总 token",
|
|
3601
4282
|
"stat.hitRate": "命中率",
|
|
3602
4283
|
"stat.cost": "费用",
|
|
@@ -3652,6 +4333,7 @@ window.__ModuleLoader__.load({
|
|
|
3652
4333
|
"card.fullSync.button": "开始扫描",
|
|
3653
4334
|
"card.fullSync.running": "扫描中…",
|
|
3654
4335
|
"card.fullSync.progress": "已处理 {processed}/{total} 个 session,新增 {added} 条,跳过 {skipped} 条",
|
|
4336
|
+
"card.fullSync.failuresNote": ",无法读取 {count} 个 session 已跳过",
|
|
3655
4337
|
"card.fullSync.done": "扫描完成:新增 {added} 条,跳过 {skipped} 条",
|
|
3656
4338
|
"card.fullSync.failed": "扫描失败:{error}",
|
|
3657
4339
|
"loadFailed": "统计加载失败:{message}",
|
|
@@ -3662,6 +4344,12 @@ window.__ModuleLoader__.load({
|
|
|
3662
4344
|
"chart.ariaRequests": "按时间分段的 token 曲线",
|
|
3663
4345
|
"chart.pointLabel": "{day} 总量 {tokens}",
|
|
3664
4346
|
"chart.bucket": "{window} · {count} 请求 · {tokens}",
|
|
4347
|
+
"chart.mode.label": "趋势模式",
|
|
4348
|
+
"chart.mode.interval": "分时",
|
|
4349
|
+
"chart.mode.cumulative": "累计",
|
|
4350
|
+
"chart.ariaCumulative": "累计 token 曲线",
|
|
4351
|
+
"chart.cumulativePoint": "{day} 累计 {tokens}",
|
|
4352
|
+
"chart.cumulativeBucket": "{window} · {count} 请求 · 累计 {tokens}",
|
|
3665
4353
|
"view.usage": "用量",
|
|
3666
4354
|
"view.scope.label": "统计范围",
|
|
3667
4355
|
"view.scope.session": "本会话",
|
|
@@ -3700,12 +4388,36 @@ window.__ModuleLoader__.load({
|
|
|
3700
4388
|
"nav.label": "Token Usage",
|
|
3701
4389
|
"filter.quickRange": "Quick range",
|
|
3702
4390
|
"filter.custom": "Custom",
|
|
3703
|
-
"filter.
|
|
3704
|
-
"filter.
|
|
4391
|
+
"filter.dateRange": "Date range",
|
|
4392
|
+
"filter.allDates": "All dates",
|
|
4393
|
+
"filter.clear": "Clear range",
|
|
3705
4394
|
"filter.separator": "to",
|
|
3706
4395
|
"filter.model": "Model",
|
|
3707
4396
|
"filter.allModels": "All models",
|
|
3708
|
-
"
|
|
4397
|
+
"calendar.monthTitle": "{month} {year}",
|
|
4398
|
+
"calendar.prevMonth": "Previous month",
|
|
4399
|
+
"calendar.nextMonth": "Next month",
|
|
4400
|
+
"calendar.weekday.0": "Mo",
|
|
4401
|
+
"calendar.weekday.1": "Tu",
|
|
4402
|
+
"calendar.weekday.2": "We",
|
|
4403
|
+
"calendar.weekday.3": "Th",
|
|
4404
|
+
"calendar.weekday.4": "Fr",
|
|
4405
|
+
"calendar.weekday.5": "Sa",
|
|
4406
|
+
"calendar.weekday.6": "Su",
|
|
4407
|
+
"stat.requests": "Successful requests",
|
|
4408
|
+
"stat.successFail": "OK/Fail",
|
|
4409
|
+
"stat.ok": "OK",
|
|
4410
|
+
"stat.fail": "Fail",
|
|
4411
|
+
"stat.failuresPill": "Failed {count}",
|
|
4412
|
+
"fail.RATE_LIMIT": "Rate limited",
|
|
4413
|
+
"fail.SERVER": "Server error",
|
|
4414
|
+
"fail.TIMEOUT": "Timed out",
|
|
4415
|
+
"fail.TRANSPORT": "Network error",
|
|
4416
|
+
"fail.EMPTY_RESPONSE": "Empty response",
|
|
4417
|
+
"fail.QUOTA": "Quota exceeded",
|
|
4418
|
+
"fail.CONTEXT_WINDOW_EXCEEDED": "Context exceeded",
|
|
4419
|
+
"fail.INVALID_CREDENTIAL": "Invalid credential",
|
|
4420
|
+
"fail.UNKNOWN": "Unknown error",
|
|
3709
4421
|
"stat.totalTokens": "Total",
|
|
3710
4422
|
"stat.hitRate": "Hit %",
|
|
3711
4423
|
"stat.cost": "Cost",
|
|
@@ -3761,6 +4473,7 @@ window.__ModuleLoader__.load({
|
|
|
3761
4473
|
"card.fullSync.button": "Start scan",
|
|
3762
4474
|
"card.fullSync.running": "Scanning…",
|
|
3763
4475
|
"card.fullSync.progress": "Processed {processed}/{total} sessions, added {added}, skipped {skipped}",
|
|
4476
|
+
"card.fullSync.failuresNote": ", {count} unreadable sessions skipped",
|
|
3764
4477
|
"card.fullSync.done": "Scan complete: added {added}, skipped {skipped}",
|
|
3765
4478
|
"card.fullSync.failed": "Scan failed: {error}",
|
|
3766
4479
|
"loadFailed": "Failed to load stats: {message}",
|
|
@@ -3771,6 +4484,12 @@ window.__ModuleLoader__.load({
|
|
|
3771
4484
|
"chart.ariaRequests": "Time-bucketed token trend",
|
|
3772
4485
|
"chart.pointLabel": "{day} total {tokens}",
|
|
3773
4486
|
"chart.bucket": "{window} · {count} requests · {tokens}",
|
|
4487
|
+
"chart.mode.label": "Trend mode",
|
|
4488
|
+
"chart.mode.interval": "Interval",
|
|
4489
|
+
"chart.mode.cumulative": "Cumulative",
|
|
4490
|
+
"chart.ariaCumulative": "Cumulative token trend",
|
|
4491
|
+
"chart.cumulativePoint": "{day} cumulative {tokens}",
|
|
4492
|
+
"chart.cumulativeBucket": "{window} · {count} requests · cumulative {tokens}",
|
|
3774
4493
|
"view.usage": "Usage",
|
|
3775
4494
|
"view.scope.label": "Scope",
|
|
3776
4495
|
"view.scope.session": "Session",
|