@laoyuehanni/dsh-token-usage 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +1 -1
  2. package/README.zh.md +1 -1
  3. package/docs/pricing.md +61 -4
  4. package/lib/client/CostPill.d.ts.map +1 -1
  5. package/lib/client/CostPill.js +18 -13
  6. package/lib/client/CostPill.js.map +1 -1
  7. package/lib/client/PricingAssociations.d.ts +38 -0
  8. package/lib/client/PricingAssociations.d.ts.map +1 -0
  9. package/lib/client/PricingAssociations.js +211 -0
  10. package/lib/client/PricingAssociations.js.map +1 -0
  11. package/lib/client/PricingOverviewDialog.d.ts +2 -13
  12. package/lib/client/PricingOverviewDialog.d.ts.map +1 -1
  13. package/lib/client/PricingOverviewDialog.js +12 -39
  14. package/lib/client/PricingOverviewDialog.js.map +1 -1
  15. package/lib/client/PricingStatus.d.ts +12 -0
  16. package/lib/client/PricingStatus.d.ts.map +1 -0
  17. package/lib/client/PricingStatus.js +13 -0
  18. package/lib/client/PricingStatus.js.map +1 -0
  19. package/lib/client/SessionTable.d.ts +3 -2
  20. package/lib/client/SessionTable.d.ts.map +1 -1
  21. package/lib/client/SessionTable.js +3 -2
  22. package/lib/client/SessionTable.js.map +1 -1
  23. package/lib/client/TokenUsageCard.d.ts.map +1 -1
  24. package/lib/client/TokenUsageCard.js +51 -3
  25. package/lib/client/TokenUsageCard.js.map +1 -1
  26. package/lib/client/TokenUsageSection.d.ts.map +1 -1
  27. package/lib/client/TokenUsageSection.js +45 -48
  28. package/lib/client/TokenUsageSection.js.map +1 -1
  29. package/lib/client/UsageView.d.ts.map +1 -1
  30. package/lib/client/UsageView.js +46 -42
  31. package/lib/client/UsageView.js.map +1 -1
  32. package/lib/client/locales.d.ts +57 -0
  33. package/lib/client/locales.d.ts.map +1 -1
  34. package/lib/client/locales.js +114 -0
  35. package/lib/client/locales.js.map +1 -1
  36. package/lib/client/pricing-associations.d.ts +13 -0
  37. package/lib/client/pricing-associations.d.ts.map +1 -0
  38. package/lib/client/pricing-associations.js +51 -0
  39. package/lib/client/pricing-associations.js.map +1 -0
  40. package/lib/client/pricing-search.d.ts +5 -0
  41. package/lib/client/pricing-search.d.ts.map +1 -0
  42. package/lib/client/pricing-search.js +27 -0
  43. package/lib/client/pricing-search.js.map +1 -0
  44. package/lib/client/use-cost-inflate.d.ts.map +1 -1
  45. package/lib/client/use-cost-inflate.js +6 -1
  46. package/lib/client/use-cost-inflate.js.map +1 -1
  47. package/lib/client.js +1986 -914
  48. package/lib/client.js.map +1 -1
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +63 -39
  51. package/lib/index.js.map +1 -1
  52. package/lib/migrate.d.ts +9 -7
  53. package/lib/migrate.d.ts.map +1 -1
  54. package/lib/migrate.js +43 -8
  55. package/lib/migrate.js.map +1 -1
  56. package/lib/model-resolution.d.ts +15 -0
  57. package/lib/model-resolution.d.ts.map +1 -0
  58. package/lib/model-resolution.js +124 -0
  59. package/lib/model-resolution.js.map +1 -0
  60. package/lib/pricing-association-service.d.ts +20 -0
  61. package/lib/pricing-association-service.d.ts.map +1 -0
  62. package/lib/pricing-association-service.js +104 -0
  63. package/lib/pricing-association-service.js.map +1 -0
  64. package/lib/pricing-associations-route.d.ts +6 -0
  65. package/lib/pricing-associations-route.d.ts.map +1 -0
  66. package/lib/pricing-associations-route.js +71 -0
  67. package/lib/pricing-associations-route.js.map +1 -0
  68. package/lib/pricing-associations.d.ts +42 -0
  69. package/lib/pricing-associations.d.ts.map +1 -0
  70. package/lib/pricing-associations.js +133 -0
  71. package/lib/pricing-associations.js.map +1 -0
  72. package/lib/pricing.d.ts +37 -32
  73. package/lib/pricing.d.ts.map +1 -1
  74. package/lib/pricing.js +197 -63
  75. package/lib/pricing.js.map +1 -1
  76. package/lib/record-cache.d.ts +5 -0
  77. package/lib/record-cache.d.ts.map +1 -1
  78. package/lib/record-cache.js +9 -1
  79. package/lib/record-cache.js.map +1 -1
  80. package/lib/rollup.d.ts +10 -5
  81. package/lib/rollup.d.ts.map +1 -1
  82. package/lib/rollup.js +7 -6
  83. package/lib/rollup.js.map +1 -1
  84. package/lib/stats-route.d.ts +4 -1
  85. package/lib/stats-route.d.ts.map +1 -1
  86. package/lib/stats-route.js +65 -21
  87. package/lib/stats-route.js.map +1 -1
  88. package/lib/stats.d.ts +22 -8
  89. package/lib/stats.d.ts.map +1 -1
  90. package/lib/stats.js +138 -41
  91. package/lib/stats.js.map +1 -1
  92. package/lib/wire.d.ts +70 -8
  93. package/lib/wire.d.ts.map +1 -1
  94. package/lib/wire.js +2 -0
  95. package/lib/wire.js.map +1 -1
  96. package/locale/en.json +3 -0
  97. package/locale/zh.json +6 -0
  98. package/package.json +44 -40
package/lib/client.js CHANGED
@@ -13,6 +13,8 @@ window.__ModuleLoader__.load({
13
13
  /** The pricing-overview endpoint path: the full cloud-mirror model list,
14
14
  * filter-free by design — the overview is not a filtered usage view. */
15
15
  const PRICING_PATH = "/token-usage/pricing";
16
+ const PRICING_SYNC_PATH = "/token-usage/pricing-sync";
17
+ const ASSOCIATIONS_PATH = "/token-usage/pricing-associations";
16
18
  /** Encode one repeated query key (`sessionId=a&sessionId=b`). Empty list yields ''. */
17
19
  function encodeRepeatedParam(key, values) {
18
20
  return values.map((value) => `${key}=${encodeURIComponent(value)}`).join("&");
@@ -706,6 +708,934 @@ window.__ModuleLoader__.load({
706
708
  return code;
707
709
  }
708
710
  //#endregion
711
+ //#region src/client/PricingStatus.tsx
712
+ function costsAvailable(state) {
713
+ return state === void 0 || state === "ready";
714
+ }
715
+ /** Shared failure reasons; matching and prices remain entirely on the host. */
716
+ function PricingStatus({ costState, pricingUnavailableReason, associationStorageError, t }) {
717
+ const storageWarning = associationStorageError !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
718
+ role: "status",
719
+ children: t("pricing.associationStorageUnavailable")
720
+ }) : null;
721
+ const costWarning = !costsAvailable(costState) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
722
+ role: "status",
723
+ children: [t(costState === "history-incomplete" ? "pricing.historyIncomplete" : "pricing.unavailable"), costState === "pricing-unavailable" && pricingUnavailableReason !== void 0 ? ` ${t(`pricing.reason.${pricingUnavailableReason}`)}` : ""]
724
+ }) : null;
725
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [storageWarning, costWarning] });
726
+ }
727
+ //#endregion
728
+ //#region src/model-resolution.ts
729
+ /** Full-name comparison only: spelling remains intact in records and displays. */
730
+ const modelKey = (name) => name.toLowerCase();
731
+ /** Parse the upstream portable subset rather than accepting arbitrary JS regex. */
732
+ function compileAliasPattern(pattern) {
733
+ if (!pattern.startsWith("^") || !pattern.endsWith("$")) throw new Error("alias pattern requires ^ and $");
734
+ const body = pattern.slice(1, -1);
735
+ let offset = 0;
736
+ function expression(depth) {
737
+ if (depth > 32) throw new Error("alias pattern nesting is too deep");
738
+ let atoms = 0;
739
+ while (offset < body.length && body[offset] !== ")") {
740
+ const char = body[offset++];
741
+ if (char === "|") {
742
+ if (atoms === 0) throw new Error("empty alias pattern branch");
743
+ atoms = 0;
744
+ continue;
745
+ }
746
+ if (char === "(") {
747
+ expression(depth + 1);
748
+ if (body[offset++] !== ")") throw new Error("unclosed alias pattern group");
749
+ } else if (char === "\\") {
750
+ const literal = body[offset++];
751
+ if (literal === void 0 || /[A-Za-z0-9\s]/.test(literal)) throw new Error("alias patterns allow escaped punctuation only");
752
+ } else if (!/[A-Za-z0-9_/:\-]/.test(char)) throw new Error("unsupported alias pattern syntax");
753
+ atoms++;
754
+ if (body[offset] === "?") offset++;
755
+ }
756
+ if (atoms === 0) throw new Error("empty alias pattern branch");
757
+ }
758
+ expression(0);
759
+ if (offset !== body.length) throw new Error("unbalanced alias pattern group");
760
+ return new RegExp(pattern, "i");
761
+ }
762
+ /** `$` also accepts a trailing newline in JS; require a full-span match. */
763
+ function matchesAliasPattern(regex, name) {
764
+ const match = regex.exec(name);
765
+ return match !== null && match.index === 0 && match[0].length === name.length;
766
+ }
767
+ //#endregion
768
+ //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingDialog.module.css.mjs
769
+ const css$13 = ".gh1SLa_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}.gh1SLa_dialog::backdrop{background:#0006}.gh1SLa_dialogHead{justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px;display:flex}.gh1SLa_dialogTitle{text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:14px;font-weight:600;overflow:hidden}.gh1SLa_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}.gh1SLa_dialogClose:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-interactive-bg-hover)}.gh1SLa_rateNote{color:var(--dsw-alias-label-secondary);margin:6px 0 0;font-size:12px}.gh1SLa_tableWrap{max-height:420px;overflow:auto}.gh1SLa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:420px;font-size:12px}.gh1SLa_table th,.gh1SLa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.gh1SLa_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}.gh1SLa_table td{color:var(--dsw-alias-label-primary)}th.gh1SLa_conditionHead,td.gh1SLa_conditionCell{text-align:left;white-space:normal;min-width:200px}td.gh1SLa_conditionCell{color:var(--dsw-alias-label-secondary);padding-left:20px}.gh1SLa_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}.gh1SLa_groupRow:not(:first-child)>td{border-top:1px solid var(--dsw-alias-border-l1)}";
770
+ const tagId$13 = "@laoyuehanni/dsh-token-usage/PricingDialog.module.css";
771
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$13) + "]") === null) {
772
+ const tag = document.createElement("style");
773
+ tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
774
+ tag.dataset.pluginCss = tagId$13;
775
+ tag.textContent = css$13;
776
+ document.head.appendChild(tag);
777
+ }
778
+ var PricingDialog_module_css_default = {
779
+ "conditionCell": "gh1SLa_conditionCell",
780
+ "conditionHead": "gh1SLa_conditionHead",
781
+ "dialog": "gh1SLa_dialog",
782
+ "dialogClose": "gh1SLa_dialogClose",
783
+ "dialogHead": "gh1SLa_dialogHead",
784
+ "dialogTitle": "gh1SLa_dialogTitle",
785
+ "groupRow": "gh1SLa_groupRow",
786
+ "rateNote": "gh1SLa_rateNote",
787
+ "table": "gh1SLa_table",
788
+ "tableWrap": "gh1SLa_tableWrap"
789
+ };
790
+ //#endregion
791
+ //#region src/client/PricingDialog.tsx
792
+ /**
793
+ * The pricing dialog of one model: a native `<dialog>` (Esc closes, focus
794
+ * is trapped, the backdrop dims, and the top layer renders it above the
795
+ * table's scroll shell) holding that model's full price table — billing
796
+ * conditions (default / context tiers / peak slots / time rules) × the four
797
+ * per-million rates, converted for a USD view. Shared by the settings
798
+ * page's per-model “定价” affordance and the pricing-overview dialog's
799
+ * drill-in rows; a native showModal naturally stacks a second instance
800
+ * above the overview.
801
+ *
802
+ * @module token-usage/client/PricingDialog
803
+ */
804
+ /** The four base rates of one model as display text (symbol included,
805
+ * converted for a USD view); a missing cache rate bills at the input rate. */
806
+ function billedRates(rates, view) {
807
+ return {
808
+ input: formatRateWithSymbol(rates.inputPerMillion, view),
809
+ output: formatRateWithSymbol(rates.outputPerMillion, view),
810
+ cacheRead: formatRateWithSymbol(rates.cacheReadPerMillion ?? rates.inputPerMillion, view),
811
+ cacheWrite: formatRateWithSymbol(rates.cacheWritePerMillion ?? rates.inputPerMillion, view)
812
+ };
813
+ }
814
+ /** `HH:MM-HH:MM` of one peak window (half-open, local minutes). */
815
+ function windowText(window) {
816
+ const clock = (minute) => `${String(Math.floor(minute / 60)).padStart(2, "0")}:${String(minute % 60).padStart(2, "0")}`;
817
+ return `${clock(window.startMinute)}-${clock(window.endMinute)}`;
818
+ }
819
+ /** The when-it-applies text of one peak slot: its label plus its windows. */
820
+ function slotCondition(slot, t) {
821
+ return `${slot.label ?? t("pricing.peak")} ${slot.windows.map(windowText).join(t("pricing.windowSep"))}`;
822
+ }
823
+ /**
824
+ * The price rows of one rate node (a time rule's or the model root's): the
825
+ * node's own base rates, then its peak slots, then its context tiers
826
+ * (ascending), each tier followed by the peak slots hanging on that tier —
827
+ * mirroring {@link resolveRate}'s node chain, where a matching tier's slots
828
+ * replace the node's and peak rates replace the node's rates wholesale.
829
+ */
830
+ function nodePriceRows(node, t) {
831
+ const rows = [{
832
+ condition: t("pricing.default"),
833
+ rates: node.rates
834
+ }];
835
+ const tiers = [...node.tiers ?? []].sort((a, b) => a.threshold - b.threshold);
836
+ for (const tier of tiers) {
837
+ const tierCondition = t("pricing.tier", { threshold: formatTokens(tier.threshold) });
838
+ rows.push({
839
+ condition: tierCondition,
840
+ rates: tier.rates
841
+ });
842
+ for (const slot of tier.dailySlots ?? []) rows.push({
843
+ condition: `${tierCondition} · ${slotCondition(slot, t)}`,
844
+ rates: slot.rates
845
+ });
846
+ }
847
+ for (const slot of node.slots ?? []) rows.push({
848
+ condition: slotCondition(slot, t),
849
+ rates: slot.rates
850
+ });
851
+ return rows;
852
+ }
853
+ /**
854
+ * One model's price table: rows are billing conditions — grouped into the
855
+ * model root (“常规”, omitted when it is the only group) and one group per
856
+ * time rule with its date window — so tier, peak, and time-rule pricing
857
+ * each show when they apply and what they bill. The structure mirrors
858
+ * {@link resolveRate}'s node chain.
859
+ */
860
+ function ModelPriceTable({ rules, view, t }) {
861
+ const groups = [{
862
+ title: rules.timeRules.length > 0 ? t("pricing.regular") : null,
863
+ rows: nodePriceRows({
864
+ rates: rules.base,
865
+ tiers: rules.contextTiers,
866
+ slots: rules.dailySlots
867
+ }, t)
868
+ }, ...[...rules.timeRules].sort((a, b) => b.endTime - a.endTime).map((rule) => ({
869
+ title: `${rule.label !== void 0 ? `${rule.label} ` : ""}${rule.startTime > 0 ? `${dayKeyOf(/* @__PURE__ */ new Date(rule.startTime * 1e3))} ~ ` : "~ "}${dayKeyOf(/* @__PURE__ */ new Date(rule.endTime * 1e3))}`,
870
+ rows: nodePriceRows({
871
+ rates: rule.rates,
872
+ tiers: rule.contextTiers,
873
+ slots: rule.dailySlots
874
+ }, t)
875
+ }))];
876
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
877
+ className: PricingDialog_module_css_default["tableWrap"],
878
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
879
+ className: PricingDialog_module_css_default["table"],
880
+ "aria-label": t("pricing.title"),
881
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
882
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
883
+ className: PricingDialog_module_css_default["conditionHead"],
884
+ children: t("pricing.condition")
885
+ }),
886
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
887
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
888
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
889
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] })
890
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: groups.flatMap((group) => [...group.title !== null ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
891
+ className: PricingDialog_module_css_default["groupRow"],
892
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
893
+ colSpan: 5,
894
+ children: group.title
895
+ })
896
+ }, group.title)] : [], ...group.rows.map((row, index) => {
897
+ const billed = billedRates(row.rates, view);
898
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
899
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
900
+ className: PricingDialog_module_css_default["conditionCell"],
901
+ children: row.condition
902
+ }),
903
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
904
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
905
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
906
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite })
907
+ ] }, `${group.title ?? ""}-${index}-${row.condition}`);
908
+ })]) })]
909
+ }), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
910
+ className: PricingDialog_module_css_default["rateNote"],
911
+ children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
912
+ }) : null]
913
+ });
914
+ }
915
+ /**
916
+ * The pricing dialog of one model. Mounts only while a model is selected;
917
+ * every close path funnels through the dialog's `close` event, which clears
918
+ * the selection and unmounts it.
919
+ */
920
+ function PricingDialog({ model, rules, view, onClose, t }) {
921
+ const dialogRef = (0, react.useRef)(null);
922
+ const backdropPress = (0, react.useRef)(false);
923
+ (0, react.useEffect)(() => {
924
+ const dialog = dialogRef.current;
925
+ if (dialog !== null && !dialog.open) dialog.showModal();
926
+ }, []);
927
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
928
+ ref: dialogRef,
929
+ className: PricingDialog_module_css_default["dialog"],
930
+ "aria-label": t("pricing.title"),
931
+ onClose,
932
+ onMouseDown: (event) => {
933
+ backdropPress.current = event.target === dialogRef.current;
934
+ },
935
+ onClick: (event) => {
936
+ if (event.target === dialogRef.current && backdropPress.current) dialogRef.current?.close();
937
+ },
938
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
939
+ className: PricingDialog_module_css_default["dialogHead"],
940
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
941
+ className: PricingDialog_module_css_default["dialogTitle"],
942
+ children: model
943
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
944
+ type: "button",
945
+ className: PricingDialog_module_css_default["dialogClose"],
946
+ "aria-label": t("pricing.close"),
947
+ onClick: () => dialogRef.current?.close(),
948
+ children: "✕"
949
+ })]
950
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPriceTable, {
951
+ rules,
952
+ view,
953
+ t
954
+ })]
955
+ });
956
+ }
957
+ //#endregion
958
+ //#region src/client/pricing-associations.ts
959
+ const CHANGED_EVENT = "token-usage:pricing-associations-changed";
960
+ const TABLE_CHANGED_EVENT = "token-usage:pricing-table-changed";
961
+ /** All mounted usage views refresh their existing query after a real commit. */
962
+ function pricingAssociationsChanged() {
963
+ window.dispatchEvent(new Event(CHANGED_EVENT));
964
+ }
965
+ function pricingTableChanged() {
966
+ window.dispatchEvent(new Event(TABLE_CHANGED_EVENT));
967
+ }
968
+ function usePricingAssociationRefresh(refresh) {
969
+ const latest = (0, react.useRef)(refresh);
970
+ latest.current = refresh;
971
+ (0, react.useEffect)(() => {
972
+ const changed = () => {
973
+ latest.current();
974
+ };
975
+ window.addEventListener(CHANGED_EVENT, changed);
976
+ window.addEventListener(TABLE_CHANGED_EVENT, changed);
977
+ return () => {
978
+ window.removeEventListener(CHANGED_EVENT, changed);
979
+ window.removeEventListener(TABLE_CHANGED_EVENT, changed);
980
+ };
981
+ }, []);
982
+ }
983
+ var AssociationRequestError = class extends Error {
984
+ code;
985
+ current;
986
+ constructor(code, current) {
987
+ super(code);
988
+ this.code = code;
989
+ this.current = current;
990
+ }
991
+ };
992
+ /** Optional pricing references and the current feed version; no usage or credentials. */
993
+ function pricingIssueUrl(resolution, version) {
994
+ const lines = [
995
+ "1. Pricing reference (optional)",
996
+ " - Currency:",
997
+ " - Input price per 1 million tokens:",
998
+ " - Output price per 1 million tokens:",
999
+ " - Cache read price per 1 million tokens:",
1000
+ " - Cache write price per 1 million tokens:",
1001
+ " - Context window (tokens):",
1002
+ "",
1003
+ "2. Official pricing URL (optional)",
1004
+ " - URL:",
1005
+ "",
1006
+ "3. Current pricing table version",
1007
+ ` - ${version ?? "Unknown"}`
1008
+ ];
1009
+ const url = new URL("https://github.com/LaoYueHanNi/model-price-table/issues/new");
1010
+ url.searchParams.set("title", `Add model pricing: ${resolution.rawName}`);
1011
+ url.searchParams.set("body", lines.join("\n"));
1012
+ return url.href;
1013
+ }
1014
+ //#endregion
1015
+ //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingAssociations.module.css.mjs
1016
+ const css$12 = "._0UUrKq_actions{flex-wrap:wrap;align-items:center;gap:8px;margin:8px 0;display:flex}._0UUrKq_button,._0UUrKq_link{font:inherit;color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;background:0 0;border-radius:6px;padding:4px 8px;font-size:12px}._0UUrKq_button:hover,._0UUrKq_link:hover{background:var(--dsw-interactive-bg-hover)}._0UUrKq_button:disabled{opacity:.5;cursor:default}._0UUrKq_badgeWrap{vertical-align:middle;flex:none;display:inline-flex}._0UUrKq_badgeWrap [role=tooltip]{white-space:normal;overflow-wrap:anywhere;max-width:min(360px,100vw - 24px);font-size:12px;font-style:normal;font-weight:400;line-height:1.4;animation:none}._0UUrKq_badge{color:var(--dsw-alias-label-secondary);cursor:default;flex:none;align-items:center;display:inline-flex}._0UUrKq_badge:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px;border-radius:50%}._0UUrKq_link{border:none;padding:2px 4px}._0UUrKq_dialog{box-sizing:border-box;width:min(480px,100vw - 48px);font-size:13px;line-height:1.5}._0UUrKq_dialog p,._0UUrKq_unpricedDialog p{margin:8px 0;font-size:12px;line-height:1.5}._0UUrKq_dialog h2,._0UUrKq_unpricedDialog h2{margin:0;font-size:14px;line-height:1.5}._0UUrKq_dialog ._0UUrKq_source{margin:12px 0 8px;font-size:13px;font-weight:500}._0UUrKq_unpricedDialog{box-sizing:border-box;width:min(400px,100vw - 48px);font-size:13px;line-height:1.5}._0UUrKq_unpricedTag{appearance:none;font:inherit;color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);cursor:pointer;white-space:nowrap;border:none;border-radius:8px;flex:none;margin:0;padding:0 6px;font-size:10px;line-height:16px}._0UUrKq_unpricedTag:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}._0UUrKq_name{overflow-wrap:anywhere;white-space:normal}._0UUrKq_label{color:var(--dsw-alias-label-secondary);margin:10px 0 4px;font-size:12px;display:block}._0UUrKq_search{box-sizing:border-box;width:100%;font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:6px 8px;font-size:12px}._0UUrKq_candidates{border:1px solid var(--dsw-alias-border-l1);border-radius:6px;max-height:180px;margin:8px 0;overflow-y:auto}._0UUrKq_candidate{cursor:pointer;overflow-wrap:anywhere;align-items:center;gap:8px;padding:6px 8px;font-size:12px;display:flex}._0UUrKq_candidate:hover{background:var(--dsw-interactive-bg-hover)}._0UUrKq_candidate small{color:var(--dsw-alias-label-secondary);margin-inline-start:auto}._0UUrKq_entry{border-bottom:1px solid var(--dsw-alias-border-l1);padding:10px 0}._0UUrKq_mappingRow{grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px 12px;padding:8px 0;display:grid}._0UUrKq_mappingRow>._0UUrKq_name{min-width:0}._0UUrKq_mappingRow>._0UUrKq_button{white-space:nowrap}._0UUrKq_revokeConfirmation{grid-column:1/-1;margin:0}._0UUrKq_selection{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:6px;margin:8px 0;font-size:12px;display:flex}._0UUrKq_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}._0UUrKq_save:hover:not(:disabled){background:var(--dsw-alias-label-primary);opacity:.9}._0UUrKq_note{color:var(--dsw-alias-label-secondary);white-space:normal;font-size:12px}._0UUrKq_error{color:var(--dsw-alias-label-primary);white-space:normal;font-size:12px}";
1017
+ const tagId$12 = "@laoyuehanni/dsh-token-usage/PricingAssociations.module.css";
1018
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$12) + "]") === null) {
1019
+ const tag = document.createElement("style");
1020
+ tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
1021
+ tag.dataset.pluginCss = tagId$12;
1022
+ tag.textContent = css$12;
1023
+ document.head.appendChild(tag);
1024
+ }
1025
+ var PricingAssociations_module_css_default = {
1026
+ "actions": "_0UUrKq_actions",
1027
+ "badge": "_0UUrKq_badge",
1028
+ "badgeWrap": "_0UUrKq_badgeWrap",
1029
+ "button": "_0UUrKq_button",
1030
+ "candidate": "_0UUrKq_candidate",
1031
+ "candidates": "_0UUrKq_candidates",
1032
+ "dialog": "_0UUrKq_dialog",
1033
+ "entry": "_0UUrKq_entry",
1034
+ "error": "_0UUrKq_error",
1035
+ "label": "_0UUrKq_label",
1036
+ "link": "_0UUrKq_link",
1037
+ "mappingRow": "_0UUrKq_mappingRow",
1038
+ "name": "_0UUrKq_name",
1039
+ "note": "_0UUrKq_note",
1040
+ "revokeConfirmation": "_0UUrKq_revokeConfirmation",
1041
+ "save": "_0UUrKq_save",
1042
+ "search": "_0UUrKq_search",
1043
+ "selection": "_0UUrKq_selection",
1044
+ "source": "_0UUrKq_source",
1045
+ "unpricedDialog": "_0UUrKq_unpricedDialog",
1046
+ "unpricedTag": "_0UUrKq_unpricedTag"
1047
+ };
1048
+ //#endregion
1049
+ //#region src/client/PricingAssociations.tsx
1050
+ const AssociationUiContext = (0, react.createContext)(null);
1051
+ function PricingAssociationProvider({ resolutions = [], feedVersion, view, t, children }) {
1052
+ const [source, setSource] = (0, react.useState)(void 0);
1053
+ const [unpriced, setUnpriced] = (0, react.useState)(null);
1054
+ const opener = (0, react.useRef)(null);
1055
+ const rememberOpener = () => {
1056
+ opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
1057
+ };
1058
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(AssociationUiContext.Provider, {
1059
+ value: {
1060
+ open: (name) => {
1061
+ rememberOpener();
1062
+ setSource(name ?? null);
1063
+ },
1064
+ showUnpriced: (resolution) => {
1065
+ rememberOpener();
1066
+ setUnpriced(resolution);
1067
+ },
1068
+ resolutions,
1069
+ ...feedVersion !== void 0 ? { feedVersion } : {}
1070
+ },
1071
+ children: [
1072
+ children,
1073
+ unpriced !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnpricedModelDialog, {
1074
+ resolution: unpriced,
1075
+ version: feedVersion,
1076
+ t,
1077
+ onClose: () => setUnpriced(null),
1078
+ onAssociate: () => {
1079
+ setUnpriced(null);
1080
+ setSource(unpriced.rawName);
1081
+ }
1082
+ }),
1083
+ source !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingAssociationDialog, {
1084
+ initialSource: source,
1085
+ returnFocus: opener.current,
1086
+ view,
1087
+ t,
1088
+ onClose: () => setSource(void 0)
1089
+ })
1090
+ ]
1091
+ });
1092
+ }
1093
+ /** Entry remains available even when the usage filter has no rows. */
1094
+ function PricingAssociationManagerButton({ t, onOpen }) {
1095
+ const ui = (0, react.useContext)(AssociationUiContext);
1096
+ const open = onOpen ?? (ui === null ? void 0 : () => ui.open());
1097
+ return open === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1098
+ type: "button",
1099
+ "data-pricing-association-manager": true,
1100
+ className: PricingAssociations_module_css_default.button,
1101
+ onClick: open,
1102
+ children: t("association.manage")
1103
+ });
1104
+ }
1105
+ function PricingIssueLink({ resolution, version, t }) {
1106
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1107
+ className: PricingAssociations_module_css_default.link,
1108
+ href: pricingIssueUrl(resolution, version),
1109
+ target: "_blank",
1110
+ rel: "noopener noreferrer",
1111
+ children: t("association.issue")
1112
+ });
1113
+ }
1114
+ function UnpricedModelTag({ model, t }) {
1115
+ const ui = (0, react.useContext)(AssociationUiContext);
1116
+ const resolution = ui?.resolutions.find((row) => modelKey(row.rawName) === modelKey(model)) ?? {
1117
+ rawName: model,
1118
+ status: "unmatched",
1119
+ strippedPrefix: false,
1120
+ candidates: []
1121
+ };
1122
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1123
+ type: "button",
1124
+ className: PricingAssociations_module_css_default.unpricedTag,
1125
+ "aria-haspopup": "dialog",
1126
+ disabled: ui === null || model === "",
1127
+ onClick: () => ui?.showUnpriced(resolution),
1128
+ children: t("pricing.unpriced")
1129
+ });
1130
+ }
1131
+ function UnpricedModelDialog({ resolution, version, t, onClose, onAssociate }) {
1132
+ const dialogRef = (0, react.useRef)(null);
1133
+ const backdropPress = (0, react.useRef)(false);
1134
+ const opener = (0, react.useRef)(document.activeElement instanceof HTMLElement ? document.activeElement : null);
1135
+ (0, react.useEffect)(() => {
1136
+ dialogRef.current?.showModal();
1137
+ return () => {
1138
+ if (opener.current?.isConnected) opener.current.focus();
1139
+ };
1140
+ }, []);
1141
+ const automatic = resolution.automatic ?? resolution;
1142
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
1143
+ ref: dialogRef,
1144
+ className: `${PricingDialog_module_css_default.dialog} ${PricingAssociations_module_css_default.unpricedDialog}`,
1145
+ "aria-label": t("association.unpricedTitle"),
1146
+ onClose: (event) => {
1147
+ if (event.target === dialogRef.current) onClose();
1148
+ },
1149
+ onMouseDown: (event) => {
1150
+ backdropPress.current = event.target === dialogRef.current;
1151
+ },
1152
+ onClick: (event) => {
1153
+ if (event.target === dialogRef.current && backdropPress.current) dialogRef.current?.close();
1154
+ },
1155
+ onKeyDown: (event) => {
1156
+ if (event.key === "Escape") event.stopPropagation();
1157
+ },
1158
+ children: [
1159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1160
+ className: PricingDialog_module_css_default.dialogHead,
1161
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
1162
+ className: PricingDialog_module_css_default.dialogTitle,
1163
+ children: t("association.unpricedTitle")
1164
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1165
+ type: "button",
1166
+ className: PricingDialog_module_css_default.dialogClose,
1167
+ "aria-label": t("association.close"),
1168
+ onClick: () => dialogRef.current?.close(),
1169
+ children: "✕"
1170
+ })]
1171
+ }),
1172
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1173
+ className: PricingAssociations_module_css_default.name,
1174
+ children: resolution.rawName
1175
+ }),
1176
+ automatic.status === "ambiguous" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1177
+ className: PricingAssociations_module_css_default.note,
1178
+ children: t("pricing.ambiguous", { models: automatic.candidates.join(", ") })
1179
+ }),
1180
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1181
+ className: PricingAssociations_module_css_default.actions,
1182
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1183
+ type: "button",
1184
+ className: PricingAssociations_module_css_default.button,
1185
+ onClick: onAssociate,
1186
+ children: t("association.choose")
1187
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingIssueLink, {
1188
+ resolution,
1189
+ version,
1190
+ t
1191
+ })]
1192
+ })
1193
+ ]
1194
+ });
1195
+ }
1196
+ /** Show original associated IDs on hover without expanding the statistics row. */
1197
+ function ModelAssociationBadge({ model, t }) {
1198
+ const ui = (0, react.useContext)(AssociationUiContext);
1199
+ if (ui === null || model === "") return null;
1200
+ const associated = ui.resolutions.filter((row) => modelKey(row.modelId ?? row.rawName) === modelKey(model)).filter((row) => row.association !== void 0);
1201
+ if (associated.length === 0) return null;
1202
+ const label = t("association.tooltip", { models: associated.map((row) => row.rawName).join(", ") });
1203
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1204
+ className: PricingAssociations_module_css_default.badgeWrap,
1205
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
1206
+ label,
1207
+ side: "top",
1208
+ delayMs: 100,
1209
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1210
+ className: PricingAssociations_module_css_default.badge,
1211
+ role: "img",
1212
+ "aria-label": label,
1213
+ tabIndex: 0,
1214
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1215
+ width: "14",
1216
+ height: "14",
1217
+ viewBox: "0 0 16 16",
1218
+ fill: "none",
1219
+ "aria-hidden": "true",
1220
+ children: [
1221
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1222
+ cx: "8",
1223
+ cy: "8",
1224
+ r: "6",
1225
+ stroke: "currentColor"
1226
+ }),
1227
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1228
+ d: "M6.5 6a1.5 1.5 0 0 1 3 0c0 1-1.5 1-1.5 2.5",
1229
+ stroke: "currentColor",
1230
+ strokeLinecap: "round"
1231
+ }),
1232
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1233
+ cx: "8",
1234
+ cy: "10.5",
1235
+ r: ".7",
1236
+ fill: "currentColor"
1237
+ })
1238
+ ]
1239
+ })
1240
+ })
1241
+ })
1242
+ });
1243
+ }
1244
+ function AssociationStatus({ row, t }) {
1245
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1246
+ className: PricingAssociations_module_css_default.note,
1247
+ children: [t(`association.state.${row.state}`), row.state === "automatic-takeover" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1248
+ " ",
1249
+ t("association.automaticTarget", { model: row.automaticModelId ?? "" }),
1250
+ row.targetDiffers && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [" ", t("association.targetDiffers", { model: row.targetModelId })] }),
1251
+ " ",
1252
+ t("association.reactivate")
1253
+ ] })]
1254
+ });
1255
+ }
1256
+ async function readJson(url, signal) {
1257
+ const response = await fetch(url, {
1258
+ signal,
1259
+ cache: "no-store"
1260
+ });
1261
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
1262
+ return response.json();
1263
+ }
1264
+ function checkAssociations(value) {
1265
+ if (value === null || typeof value !== "object" || typeof value.directoryToken !== "string" || !["ready", "unavailable"].includes(value.storageState) || !Array.isArray(value.associations) || typeof value.pricingAvailable !== "boolean" || typeof value.writesPaused !== "boolean" || value.storageState === "ready" && (!Number.isSafeInteger(value.revision) || value.revision < 0) || value.associations.some((row) => row === null || typeof row.sourceModel !== "string" || typeof row.targetModelId !== "string")) throw new Error("unexpected association response");
1266
+ return value;
1267
+ }
1268
+ function checkPricing(value) {
1269
+ if (value === null || typeof value !== "object" || !Array.isArray(value.models) || value.models.some((row) => row === null || typeof row.modelId !== "string" || !Array.isArray(row.aliasPatterns) || !row.aliasPatterns.every((pattern) => typeof pattern === "string") || row.rules?.base === void 0)) throw new Error("unexpected pricing response");
1270
+ return value;
1271
+ }
1272
+ function requestMessage(error, t) {
1273
+ if (!(error instanceof AssociationRequestError)) return t("association.writeFailed");
1274
+ switch (error.code) {
1275
+ case "revision-conflict":
1276
+ case "directory-conflict": return t("association.conflict");
1277
+ case "migration-in-progress": return t("association.migrating");
1278
+ case "source-automatically-priced": return t("association.automaticOnly");
1279
+ case "target-unavailable": return t("association.targetUnavailable");
1280
+ case "pricing-unavailable": return t("pricing.unavailable");
1281
+ case "association-storage-unavailable": return t("pricing.associationStorageUnavailable");
1282
+ default: return t("association.writeFailed");
1283
+ }
1284
+ }
1285
+ function PricingAssociationDialog({ initialSource, view, t, onClose, returnFocus }) {
1286
+ const dialogRef = (0, react.useRef)(null);
1287
+ const searchId = (0, react.useId)();
1288
+ const backdropPress = (0, react.useRef)(false);
1289
+ const mounted = (0, react.useRef)(true);
1290
+ const writing = (0, react.useRef)(false);
1291
+ const opener = (0, react.useRef)(returnFocus ?? (document.activeElement instanceof HTMLElement ? document.activeElement : null));
1292
+ const source = initialSource;
1293
+ const [query, setQuery] = (0, react.useState)("");
1294
+ const [target, setTarget] = (0, react.useState)(null);
1295
+ const [detail, setDetail] = (0, react.useState)(null);
1296
+ const [pending, setPending] = (0, react.useState)(false);
1297
+ const [error, setError] = (0, react.useState)(null);
1298
+ const [notice, setNotice] = (0, react.useState)(null);
1299
+ const [confirmRevoke, setConfirmRevoke] = (0, react.useState)(null);
1300
+ const [override, setOverride] = (0, react.useState)(null);
1301
+ const [state, retry] = useAsyncResource(async (signal) => {
1302
+ const [associations, pricing] = await Promise.all([readJson(ASSOCIATIONS_PATH + (source !== null ? `?sourceModel=${encodeURIComponent(source)}` : ""), signal).then(checkAssociations), readJson(PRICING_PATH, signal).then(checkPricing).catch(() => null)]);
1303
+ return {
1304
+ associations,
1305
+ pricing,
1306
+ source
1307
+ };
1308
+ }, [source], { retryToken: 0 });
1309
+ (0, react.useEffect)(() => {
1310
+ const dialog = dialogRef.current;
1311
+ dialog?.showModal();
1312
+ const parent = dialog?.parentElement;
1313
+ mounted.current = true;
1314
+ return () => {
1315
+ mounted.current = false;
1316
+ if (opener.current?.isConnected) opener.current.focus();
1317
+ else (parent?.querySelector("[data-pricing-association-manager]") ?? parent?.querySelector("[data-pricing-overview-trigger]") ?? parent?.querySelector("button"))?.focus();
1318
+ };
1319
+ }, []);
1320
+ const ready = state.status === "ready" && state.value.source === source;
1321
+ const snapshot = override ?? (ready ? state.value.associations : null);
1322
+ const models = ready ? state.value.pricing?.models ?? [] : [];
1323
+ const candidateView = ready && state.value.pricing !== null ? currencyViewOf(state.value.pricing) : view;
1324
+ const selected = models.find((model) => modelKey(model.modelId) === modelKey(target ?? ""));
1325
+ const currentChoice = snapshot?.associations.find((row) => modelKey(row.sourceModel) === modelKey(source ?? ""));
1326
+ const savedTarget = models.find((model) => modelKey(model.modelId) === modelKey(currentChoice?.targetModelId ?? ""));
1327
+ const automatic = snapshot?.resolution?.automatic ?? snapshot?.resolution;
1328
+ const writable = ready && snapshot?.storageState === "ready" && !snapshot.writesPaused && !pending;
1329
+ const canSave = writable && snapshot?.pricingAvailable && ready && state.value.pricing !== null && state.value.pricing.costState !== "pricing-unavailable" && automatic !== void 0 && automatic.status !== "matched" && selected !== void 0 && source !== null;
1330
+ const searchModelId = modelKey(query.trim());
1331
+ const candidates = searchModelId === "" ? [] : models.filter((model) => modelKey(model.modelId).includes(searchModelId));
1332
+ const reload = () => {
1333
+ setOverride(null);
1334
+ setError(null);
1335
+ retry();
1336
+ };
1337
+ const mutate = async (operation, name) => {
1338
+ if (writing.current || snapshot === null || snapshot.revision === null) return;
1339
+ writing.current = true;
1340
+ setPending(true);
1341
+ setError(null);
1342
+ setNotice(null);
1343
+ try {
1344
+ const response = await fetch(ASSOCIATIONS_PATH, {
1345
+ method: operation === "save" ? "POST" : "DELETE",
1346
+ cache: "no-store",
1347
+ headers: { "content-type": "application/json" },
1348
+ body: JSON.stringify({
1349
+ sourceModel: name,
1350
+ ...operation === "save" ? { targetModelId: selected?.modelId } : {},
1351
+ revision: snapshot.revision,
1352
+ directoryToken: snapshot.directoryToken
1353
+ })
1354
+ });
1355
+ const result = await response.json();
1356
+ if (!response.ok) throw new AssociationRequestError(result.error ?? "write-failed", result.current);
1357
+ checkAssociations(result);
1358
+ pricingAssociationsChanged();
1359
+ if (!mounted.current) return;
1360
+ if (operation === "save") {
1361
+ dialogRef.current?.close();
1362
+ return;
1363
+ }
1364
+ setOverride(result);
1365
+ setConfirmRevoke(null);
1366
+ setNotice(t("association.revoked"));
1367
+ } catch (failure) {
1368
+ if (!mounted.current) return;
1369
+ if (failure instanceof AssociationRequestError && failure.current !== void 0) {
1370
+ setOverride(failure.current);
1371
+ if (failure.code === "directory-conflict") {
1372
+ setTarget(null);
1373
+ setDetail(null);
1374
+ setOverride(null);
1375
+ retry();
1376
+ pricingAssociationsChanged();
1377
+ }
1378
+ }
1379
+ setError(requestMessage(failure, t));
1380
+ } finally {
1381
+ writing.current = false;
1382
+ if (mounted.current) setPending(false);
1383
+ }
1384
+ };
1385
+ const revokeButtons = (name) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: confirmRevoke === name ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1386
+ className: `${PricingAssociations_module_css_default.actions} ${PricingAssociations_module_css_default.revokeConfirmation}`,
1387
+ children: [
1388
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1389
+ className: PricingAssociations_module_css_default.note,
1390
+ children: t("association.revokeImpact")
1391
+ }),
1392
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1393
+ type: "button",
1394
+ className: PricingAssociations_module_css_default.button,
1395
+ disabled: !writable,
1396
+ onClick: () => {
1397
+ mutate("delete", name);
1398
+ },
1399
+ children: t("association.confirmRevoke")
1400
+ }),
1401
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1402
+ type: "button",
1403
+ className: PricingAssociations_module_css_default.button,
1404
+ disabled: pending,
1405
+ onClick: () => setConfirmRevoke(null),
1406
+ children: t("association.cancel")
1407
+ })
1408
+ ]
1409
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1410
+ type: "button",
1411
+ className: PricingAssociations_module_css_default.button,
1412
+ disabled: !writable,
1413
+ onClick: () => setConfirmRevoke(name),
1414
+ children: t("association.revoke")
1415
+ }) });
1416
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
1417
+ ref: dialogRef,
1418
+ className: `${PricingDialog_module_css_default.dialog} ${PricingAssociations_module_css_default.dialog}`,
1419
+ "aria-label": t("association.title"),
1420
+ onClose: (event) => {
1421
+ if (event.target === dialogRef.current) onClose();
1422
+ },
1423
+ onCancel: (event) => {
1424
+ if (event.target === dialogRef.current && writing.current) event.preventDefault();
1425
+ },
1426
+ onMouseDown: (event) => {
1427
+ backdropPress.current = event.target === dialogRef.current;
1428
+ },
1429
+ onClick: (event) => {
1430
+ if (event.target === dialogRef.current && backdropPress.current && !writing.current) dialogRef.current?.close();
1431
+ },
1432
+ onKeyDown: (event) => {
1433
+ if (event.key === "Escape") event.stopPropagation();
1434
+ },
1435
+ children: [
1436
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1437
+ className: PricingDialog_module_css_default.dialogHead,
1438
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
1439
+ className: PricingDialog_module_css_default.dialogTitle,
1440
+ children: t("association.title")
1441
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1442
+ type: "button",
1443
+ className: PricingDialog_module_css_default.dialogClose,
1444
+ "aria-label": t("association.close"),
1445
+ disabled: pending,
1446
+ onClick: () => dialogRef.current?.close(),
1447
+ children: "✕"
1448
+ })]
1449
+ }),
1450
+ state.status === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("loading") }),
1451
+ state.status === "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1452
+ role: "alert",
1453
+ children: t("association.loadFailed")
1454
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1455
+ type: "button",
1456
+ className: PricingAssociations_module_css_default.button,
1457
+ onClick: reload,
1458
+ children: t("retry")
1459
+ })] }),
1460
+ source !== null && ready && state.value.pricing === null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1461
+ role: "alert",
1462
+ children: t("association.candidatesUnavailable")
1463
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1464
+ type: "button",
1465
+ className: PricingAssociations_module_css_default.button,
1466
+ disabled: pending,
1467
+ onClick: reload,
1468
+ children: t("retry")
1469
+ })] }),
1470
+ error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1471
+ role: "alert",
1472
+ className: PricingAssociations_module_css_default.error,
1473
+ children: [
1474
+ error,
1475
+ " ",
1476
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1477
+ type: "button",
1478
+ className: PricingAssociations_module_css_default.button,
1479
+ disabled: pending,
1480
+ onClick: reload,
1481
+ children: t("association.refresh")
1482
+ })
1483
+ ]
1484
+ }),
1485
+ notice !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1486
+ role: "status",
1487
+ children: notice
1488
+ }),
1489
+ snapshot !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1490
+ snapshot.storageState !== "ready" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1491
+ role: "alert",
1492
+ children: t("pricing.associationStorageUnavailable")
1493
+ }),
1494
+ snapshot.writesPaused && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1495
+ role: "status",
1496
+ children: t("association.migrating")
1497
+ }),
1498
+ !snapshot.pricingAvailable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1499
+ role: "status",
1500
+ children: t("pricing.unavailable")
1501
+ }),
1502
+ source === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1503
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1504
+ className: PricingAssociations_module_css_default.note,
1505
+ children: t("association.allHint")
1506
+ }),
1507
+ snapshot.associations.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1508
+ className: PricingAssociations_module_css_default.note,
1509
+ children: t("association.empty")
1510
+ }),
1511
+ snapshot.associations.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
1512
+ className: `${PricingAssociations_module_css_default.entry} ${PricingAssociations_module_css_default.mappingRow}`,
1513
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1514
+ className: PricingAssociations_module_css_default.name,
1515
+ children: [
1516
+ row.sourceModel,
1517
+ " → ",
1518
+ row.resolvedTargetModelId ?? row.targetModelId
1519
+ ]
1520
+ }), revokeButtons(row.sourceModel)]
1521
+ }, modelKey(row.sourceModel)))
1522
+ ] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1523
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1524
+ className: `${PricingAssociations_module_css_default.name} ${PricingAssociations_module_css_default.source}`,
1525
+ children: source
1526
+ }),
1527
+ automatic?.status === "ambiguous" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("pricing.ambiguous", { models: automatic.candidates.join(", ") }) }),
1528
+ currentChoice !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
1529
+ className: PricingAssociations_module_css_default.entry,
1530
+ children: [
1531
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1532
+ className: PricingAssociations_module_css_default.name,
1533
+ children: [
1534
+ source,
1535
+ " → ",
1536
+ currentChoice.resolvedTargetModelId ?? currentChoice.targetModelId
1537
+ ]
1538
+ }),
1539
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AssociationStatus, {
1540
+ row: currentChoice,
1541
+ t
1542
+ }),
1543
+ savedTarget !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1544
+ type: "button",
1545
+ className: PricingAssociations_module_css_default.button,
1546
+ onClick: () => setDetail(savedTarget),
1547
+ children: t("association.preview")
1548
+ }),
1549
+ revokeButtons(source)
1550
+ ]
1551
+ }),
1552
+ automatic?.status === "matched" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { children: [
1553
+ t("association.automaticOnly"),
1554
+ " ",
1555
+ automatic.modelId
1556
+ ] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1557
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1558
+ className: PricingAssociations_module_css_default.label,
1559
+ htmlFor: searchId,
1560
+ children: t("association.search")
1561
+ }),
1562
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1563
+ id: searchId,
1564
+ className: PricingAssociations_module_css_default.search,
1565
+ type: "search",
1566
+ placeholder: t("association.searchHint"),
1567
+ value: query,
1568
+ disabled: pending,
1569
+ onChange: (event) => {
1570
+ setQuery(event.target.value);
1571
+ setTarget(null);
1572
+ }
1573
+ }),
1574
+ candidates.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1575
+ className: PricingAssociations_module_css_default.candidates,
1576
+ role: "group",
1577
+ "aria-label": t("association.candidates"),
1578
+ children: candidates.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1579
+ className: PricingAssociations_module_css_default.candidate,
1580
+ children: [
1581
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1582
+ type: "radio",
1583
+ name: searchId + "-target",
1584
+ checked: target !== null && modelKey(target) === modelKey(model.modelId),
1585
+ disabled: !writable || !snapshot.pricingAvailable,
1586
+ onChange: () => {
1587
+ setTarget(model.modelId);
1588
+ setNotice(null);
1589
+ }
1590
+ }),
1591
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: model.modelId }),
1592
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: model.family })
1593
+ ]
1594
+ }, model.modelId))
1595
+ }),
1596
+ query.trim() !== "" && candidates.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1597
+ className: PricingAssociations_module_css_default.note,
1598
+ children: t("association.noResults")
1599
+ }),
1600
+ selected !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1601
+ className: PricingAssociations_module_css_default.selection,
1602
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1603
+ className: PricingAssociations_module_css_default.name,
1604
+ children: t("association.target", { model: selected.modelId })
1605
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1606
+ type: "button",
1607
+ className: PricingAssociations_module_css_default.button,
1608
+ onClick: () => setDetail(selected),
1609
+ children: t("association.preview")
1610
+ })]
1611
+ }),
1612
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1613
+ className: PricingAssociations_module_css_default.note,
1614
+ children: t("association.impact")
1615
+ }),
1616
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1617
+ type: "button",
1618
+ className: `${PricingAssociations_module_css_default.button} ${PricingAssociations_module_css_default.save}`,
1619
+ disabled: !canSave,
1620
+ onClick: () => {
1621
+ mutate("save", source);
1622
+ },
1623
+ children: t(pending ? "association.saving" : "association.save")
1624
+ })
1625
+ ] })
1626
+ ] })
1627
+ ] }),
1628
+ detail !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingDialog, {
1629
+ model: detail.modelId,
1630
+ rules: detail.rules,
1631
+ view: candidateView,
1632
+ t,
1633
+ onClose: () => setDetail(null)
1634
+ })
1635
+ ]
1636
+ });
1637
+ }
1638
+ //#endregion
709
1639
  //#region src/client/session-stats.ts
710
1640
  /** Build a session-parent → direct-subagent-children index in one O(n) pass:
711
1641
  * every session whose `origin === 'subagent'` lands in its `parentId`'s
@@ -976,13 +1906,13 @@ window.__ModuleLoader__.load({
976
1906
  }
977
1907
  //#endregion
978
1908
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\CostPill.module.css.mjs
979
- const css$12 = ".RmjJ5q_root{min-width:0;display:inline-flex;position:relative}.RmjJ5q_pill{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.RmjJ5q_glyph{flex:none;width:14px;height:14px}button.RmjJ5q_pill{cursor:pointer}button.RmjJ5q_pill:hover,button.RmjJ5q_pill[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.RmjJ5q_cost{transform-origin:50%;z-index:2;display:inline-flex;position:relative}.RmjJ5q_deltaLayer{pointer-events:none;z-index:3;position:absolute;inset:0;overflow:visible}.RmjJ5q_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);margin-top:2px;font-size:11px;font-weight:600;position:absolute;top:100%;left:50%}@media (prefers-reduced-motion:reduce){.RmjJ5q_deltaFly{display:none}}.RmjJ5q_panel{background:var(--dsw-specific-menu);width:300px;backdrop-filter:var(--dsw-menu-backdrop-filter);border:1px solid var(--dsw-alias-border-inverted);box-shadow:var(--dsw-shadow-lv3);z-index:30;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);color:var(--dsw-alias-label-primary);border-radius:12px;padding:12px 14px;position:absolute;bottom:calc(100% + 8px)}.RmjJ5q_panelHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:baseline;padding-bottom:8px;display:flex}.RmjJ5q_panelTitle{align-items:center;gap:6px;font-weight:600;display:inline-flex}.RmjJ5q_scopeTag{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:1px 5px;font-size:10px;font-weight:400}.RmjJ5q_panelTotal{font-variant-numeric:tabular-nums;font-size:14px;font-weight:600}.RmjJ5q_usageLine{font-variant-numeric:tabular-nums;align-items:center;gap:6px;margin-top:8px;display:flex}.RmjJ5q_dot{color:var(--dsw-alias-separator-primary)}.RmjJ5q_rows{flex-direction:column;margin-top:8px;display:flex}.RmjJ5q_row{font-variant-numeric:tabular-nums;justify-content:space-between;padding:4px 0;display:flex}.RmjJ5q_rowLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;display:inline-flex}.RmjJ5q_rowValue{color:var(--dsw-alias-label-primary)}.RmjJ5q_rowSub .RmjJ5q_rowValue{color:var(--dsw-alias-label-secondary)}.RmjJ5q_tok{color:var(--dsw-alias-label-tertiary);margin-left:6px;font-size:11px}.RmjJ5q_groupLabel{color:var(--dsw-alias-label-tertiary);letter-spacing:.06em;margin-top:10px;font-size:10px}.RmjJ5q_requests{color:var(--dsw-alias-label-tertiary);font-size:11px}.RmjJ5q_unpriced .RmjJ5q_rowLabel,.RmjJ5q_unpriced .RmjJ5q_rowValue{color:var(--dsw-alias-label-tertiary);font-style:italic}.RmjJ5q_pending{color:var(--dsw-alias-label-tertiary)}";
980
- const tagId$12 = "@laoyuehanni/dsh-token-usage/CostPill.module.css";
981
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$12) + "]") === null) {
1909
+ const css$11 = ".RmjJ5q_root{min-width:0;display:inline-flex;position:relative}.RmjJ5q_pill{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.RmjJ5q_glyph{flex:none;width:14px;height:14px}button.RmjJ5q_pill{cursor:pointer}button.RmjJ5q_pill:hover,button.RmjJ5q_pill[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.RmjJ5q_cost{transform-origin:50%;z-index:2;display:inline-flex;position:relative}.RmjJ5q_deltaLayer{pointer-events:none;z-index:3;position:absolute;inset:0;overflow:visible}.RmjJ5q_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);margin-top:2px;font-size:11px;font-weight:600;position:absolute;top:100%;left:50%}@media (prefers-reduced-motion:reduce){.RmjJ5q_deltaFly{display:none}}.RmjJ5q_panel{background:var(--dsw-specific-menu);width:300px;backdrop-filter:var(--dsw-menu-backdrop-filter);border:1px solid var(--dsw-alias-border-inverted);box-shadow:var(--dsw-shadow-lv3);z-index:30;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);color:var(--dsw-alias-label-primary);border-radius:12px;padding:12px 14px;position:absolute;bottom:calc(100% + 8px)}.RmjJ5q_panelHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:baseline;padding-bottom:8px;display:flex}.RmjJ5q_panelTitle{align-items:center;gap:6px;font-weight:600;display:inline-flex}.RmjJ5q_scopeTag{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:1px 5px;font-size:10px;font-weight:400}.RmjJ5q_panelTotal{font-variant-numeric:tabular-nums;font-size:14px;font-weight:600}.RmjJ5q_usageLine{font-variant-numeric:tabular-nums;align-items:center;gap:6px;margin-top:8px;display:flex}.RmjJ5q_dot{color:var(--dsw-alias-separator-primary)}.RmjJ5q_rows{flex-direction:column;margin-top:8px;display:flex}.RmjJ5q_row{font-variant-numeric:tabular-nums;justify-content:space-between;padding:4px 0;display:flex}.RmjJ5q_rowLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;display:inline-flex}.RmjJ5q_rowValue{color:var(--dsw-alias-label-primary)}.RmjJ5q_rowSub .RmjJ5q_rowValue{color:var(--dsw-alias-label-secondary)}.RmjJ5q_tok{color:var(--dsw-alias-label-tertiary);margin-left:6px;font-size:11px}.RmjJ5q_groupLabel{color:var(--dsw-alias-label-tertiary);letter-spacing:.06em;margin-top:10px;font-size:10px}.RmjJ5q_requests{color:var(--dsw-alias-label-tertiary);font-size:11px}.RmjJ5q_unpriced .RmjJ5q_rowLabel,.RmjJ5q_unpriced .RmjJ5q_rowValue{color:var(--dsw-alias-label-tertiary);font-style:italic}.RmjJ5q_pending{color:var(--dsw-alias-label-tertiary)}";
1910
+ const tagId$11 = "@laoyuehanni/dsh-token-usage/CostPill.module.css";
1911
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$11) + "]") === null) {
982
1912
  const tag = document.createElement("style");
983
1913
  tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
984
- tag.dataset.pluginCss = tagId$12;
985
- tag.textContent = css$12;
1914
+ tag.dataset.pluginCss = tagId$11;
1915
+ tag.textContent = css$11;
986
1916
  document.head.appendChild(tag);
987
1917
  }
988
1918
  var CostPill_module_css_default = {
@@ -1140,6 +2070,10 @@ window.__ModuleLoader__.load({
1140
2070
  flies,
1141
2071
  flyOverflow,
1142
2072
  onSummary: (0, react.useCallback)((summary) => {
2073
+ if (!costsAvailable(summary.costState)) {
2074
+ reset();
2075
+ return;
2076
+ }
1143
2077
  const nextSnapshot = {
1144
2078
  totals: summary.total,
1145
2079
  totalCost: summary.totalCost
@@ -1174,7 +2108,8 @@ window.__ModuleLoader__.load({
1174
2108
  }, [
1175
2109
  maybeClearOverflow,
1176
2110
  playCostPop,
1177
- schedule
2111
+ schedule,
2112
+ reset
1178
2113
  ]),
1179
2114
  reset
1180
2115
  };
@@ -1253,6 +2188,8 @@ window.__ModuleLoader__.load({
1253
2188
  const costRef = (0, react.useRef)(null);
1254
2189
  useColorSchemeMirror(rootRef);
1255
2190
  const [open, setOpen] = (0, react.useState)(false);
2191
+ const [associationTick, setAssociationTick] = (0, react.useState)(0);
2192
+ usePricingAssociationRefresh(() => setAssociationTick((tick) => tick + 1));
1256
2193
  const byId = useSessions((state) => state.byId);
1257
2194
  const childIndex = (0, react.useMemo)(() => buildChildIndex(byId), [byId]);
1258
2195
  const scopeIds = (0, react.useMemo)(() => sessionId === "" ? [] : subtreeIds(byId, sessionId, childIndex), [
@@ -1271,7 +2208,7 @@ window.__ModuleLoader__.load({
1271
2208
  const [treeRes, retryTree] = useAsyncResource((signal) => {
1272
2209
  const [idsPart] = debouncedKey.split("\n ");
1273
2210
  return fetchSummary$1((idsPart ?? "").split("\n").filter((id) => id !== ""), "chip", signal);
1274
- }, [debouncedKey], {
2211
+ }, [debouncedKey, associationTick], {
1275
2212
  silentAfterFirst: true,
1276
2213
  retryToken: 0
1277
2214
  });
@@ -1290,7 +2227,11 @@ window.__ModuleLoader__.load({
1290
2227
  if (!open) return Promise.resolve(null);
1291
2228
  const [idsPart] = debouncedKey.split("\n ");
1292
2229
  return fetchSummary$1((idsPart ?? "").split("\n").filter((id) => id !== ""), "session", signal);
1293
- }, [open, debouncedKey], {
2230
+ }, [
2231
+ open,
2232
+ debouncedKey,
2233
+ associationTick
2234
+ ], {
1294
2235
  silentAfterFirst: true,
1295
2236
  retryToken: 0
1296
2237
  });
@@ -1300,7 +2241,8 @@ window.__ModuleLoader__.load({
1300
2241
  }, [
1301
2242
  open,
1302
2243
  sessionId,
1303
- debouncedKey
2244
+ debouncedKey,
2245
+ associationTick
1304
2246
  ], {
1305
2247
  silentAfterFirst: true,
1306
2248
  retryToken: 0
@@ -1345,7 +2287,7 @@ window.__ModuleLoader__.load({
1345
2287
  }, [open, measurePanelLeft]);
1346
2288
  if (summary === null || summary.total.requests === 0) return null;
1347
2289
  const view = currencyViewOf(summary);
1348
- const costText = formatCost(summary.totalCost, view);
2290
+ const costText = costsAvailable(summary.costState) ? formatCost(summary.totalCost, view) : "—";
1349
2291
  const tokensValue = formatTokens(totalTokens(summary.total));
1350
2292
  const hit = hitRateDisplay(summary.total);
1351
2293
  const ariaLabel = hasSubs ? t("pill.costWithSubs", { value: costText }) : t("pill.cost", { value: costText });
@@ -1353,160 +2295,189 @@ window.__ModuleLoader__.load({
1353
2295
  const detail = detailRes.status === "ready" ? detailRes.value : null;
1354
2296
  const split = selfSummary !== null ? splitUsage(summary, selfSummary) : null;
1355
2297
  const subCount = scopeIds.length - 1;
1356
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2298
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1357
2299
  ref: rootRef,
1358
2300
  className: CostPill_module_css_default.root,
1359
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1360
- type: "button",
1361
- className: CostPill_module_css_default.pill,
1362
- "aria-haspopup": "dialog",
1363
- "aria-expanded": open,
1364
- "aria-label": `${ariaLabel},${t("panel.openHint")}`,
1365
- onClick: () => {
1366
- setOpen(!open);
1367
- },
1368
- children: [
1369
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1370
- className: CostPill_module_css_default.glyph,
1371
- viewBox: "0 0 14 14",
1372
- width: "14",
1373
- height: "14",
1374
- "aria-hidden": true,
1375
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1376
- cx: "7",
1377
- cy: "7",
1378
- r: "5.5",
1379
- fill: "none",
1380
- stroke: "currentColor",
1381
- strokeWidth: "1.2"
1382
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1383
- d: "M4.8 4.5 L7 7.2 L9.2 4.5 M7 7.2 V10 M5.2 8 H8.8 M5.2 9.4 H8.8",
1384
- fill: "none",
1385
- stroke: "currentColor",
1386
- strokeWidth: "1.2"
1387
- })]
1388
- }),
1389
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1390
- ref: costRef,
1391
- className: CostPill_module_css_default.cost,
1392
- children: costText
1393
- }),
1394
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1395
- className: CostPill_module_css_default.deltaLayer,
1396
- "aria-hidden": "true",
1397
- children: flies.map((fly) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostDeltaFlyLabel, {
1398
- text: fly.text,
1399
- vars: fly.vars
1400
- }, fly.id))
1401
- })
1402
- ]
1403
- }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1404
- className: CostPill_module_css_default.panel,
1405
- role: "dialog",
1406
- "aria-label": t("panel.title"),
1407
- style: { left: panelLeft },
1408
- children: [
1409
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1410
- className: CostPill_module_css_default.panelHead,
1411
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1412
- className: CostPill_module_css_default.panelTitle,
1413
- children: [t("panel.title"), hasSubs && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1414
- className: CostPill_module_css_default.scopeTag,
1415
- children: t("pill.scopeTag")
2301
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PricingAssociationProvider, {
2302
+ resolutions: detail?.modelResolutions,
2303
+ feedVersion: summary.feedVersion,
2304
+ view,
2305
+ t,
2306
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2307
+ type: "button",
2308
+ className: CostPill_module_css_default.pill,
2309
+ "aria-haspopup": "dialog",
2310
+ "aria-expanded": open,
2311
+ "aria-label": `${ariaLabel},${t("panel.openHint")}`,
2312
+ onClick: () => {
2313
+ setOpen(!open);
2314
+ },
2315
+ children: [
2316
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
2317
+ className: CostPill_module_css_default.glyph,
2318
+ viewBox: "0 0 14 14",
2319
+ width: "14",
2320
+ height: "14",
2321
+ "aria-hidden": true,
2322
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
2323
+ cx: "7",
2324
+ cy: "7",
2325
+ r: "5.5",
2326
+ fill: "none",
2327
+ stroke: "currentColor",
2328
+ strokeWidth: "1.2"
2329
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
2330
+ d: "M4.8 4.5 L7 7.2 L9.2 4.5 M7 7.2 V10 M5.2 8 H8.8 M5.2 9.4 H8.8",
2331
+ fill: "none",
2332
+ stroke: "currentColor",
2333
+ strokeWidth: "1.2"
1416
2334
  })]
1417
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1418
- className: CostPill_module_css_default.panelTotal,
2335
+ }),
2336
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2337
+ ref: costRef,
2338
+ className: CostPill_module_css_default.cost,
1419
2339
  children: costText
1420
- })]
1421
- }),
1422
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1423
- className: CostPill_module_css_default.usageLine,
1424
- children: [
1425
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.tokens", { value: tokensValue }) }),
1426
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1427
- className: CostPill_module_css_default.dot,
1428
- children: "·"
1429
- }),
1430
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.hitRate", { value: hit.text }) })
1431
- ]
1432
- }),
1433
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1434
- className: CostPill_module_css_default.rows,
1435
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1436
- className: CostPill_module_css_default.row,
1437
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1438
- className: CostPill_module_css_default.rowLabel,
1439
- children: t("panel.self")
2340
+ }),
2341
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2342
+ className: CostPill_module_css_default.deltaLayer,
2343
+ "aria-hidden": "true",
2344
+ children: flies.map((fly) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostDeltaFlyLabel, {
2345
+ text: fly.text,
2346
+ vars: fly.vars
2347
+ }, fly.id))
2348
+ })
2349
+ ]
2350
+ }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2351
+ className: CostPill_module_css_default.panel,
2352
+ role: "dialog",
2353
+ "aria-label": t("panel.title"),
2354
+ style: { left: panelLeft },
2355
+ children: [
2356
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2357
+ className: CostPill_module_css_default.panelHead,
2358
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2359
+ className: CostPill_module_css_default.panelTitle,
2360
+ children: [t("panel.title"), hasSubs && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2361
+ className: CostPill_module_css_default.scopeTag,
2362
+ children: t("pill.scopeTag")
2363
+ })]
1440
2364
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1441
- className: CostPill_module_css_default.rowValue,
1442
- children: split === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1443
- className: CostPill_module_css_default.pending,
1444
- children: "…"
1445
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [formatCost(split.selfCost, view), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1446
- className: CostPill_module_css_default.tok,
1447
- children: t("panel.tokens", { value: formatTokens(split.selfTokens) })
1448
- })] })
2365
+ className: CostPill_module_css_default.panelTotal,
2366
+ children: costText
1449
2367
  })]
1450
- }), hasSubs && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1451
- className: `${CostPill_module_css_default.row} ${CostPill_module_css_default.rowSub}`,
1452
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1453
- className: CostPill_module_css_default.rowLabel,
1454
- children: t("panel.subs", { count: subCount })
1455
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1456
- className: CostPill_module_css_default.rowValue,
1457
- children: split === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2368
+ }),
2369
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2370
+ className: CostPill_module_css_default.usageLine,
2371
+ children: [
2372
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.tokens", { value: tokensValue }) }),
2373
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2374
+ className: CostPill_module_css_default.dot,
2375
+ children: "·"
2376
+ }),
2377
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.hitRate", { value: hit.text }) })
2378
+ ]
2379
+ }),
2380
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2381
+ className: CostPill_module_css_default.rows,
2382
+ children: [
2383
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingStatus, {
2384
+ costState: summary.costState,
2385
+ pricingUnavailableReason: summary.pricingUnavailableReason,
2386
+ associationStorageError: summary.associationStorageError,
2387
+ t
2388
+ }),
2389
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2390
+ className: CostPill_module_css_default.row,
2391
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2392
+ className: CostPill_module_css_default.rowLabel,
2393
+ children: t("panel.self")
2394
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2395
+ className: CostPill_module_css_default.rowValue,
2396
+ children: split === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2397
+ className: CostPill_module_css_default.pending,
2398
+ children: "…"
2399
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [costsAvailable(summary.costState) && costsAvailable(selfSummary?.costState) ? formatCost(split.selfCost, view) : "—", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2400
+ className: CostPill_module_css_default.tok,
2401
+ children: t("panel.tokens", { value: formatTokens(split.selfTokens) })
2402
+ })] })
2403
+ })]
2404
+ }),
2405
+ hasSubs && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2406
+ className: `${CostPill_module_css_default.row} ${CostPill_module_css_default.rowSub}`,
2407
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2408
+ className: CostPill_module_css_default.rowLabel,
2409
+ children: t("panel.subs", { count: subCount })
2410
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2411
+ className: CostPill_module_css_default.rowValue,
2412
+ children: split === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2413
+ className: CostPill_module_css_default.pending,
2414
+ children: "…"
2415
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [costsAvailable(summary.costState) && costsAvailable(selfSummary?.costState) ? formatCost(split.subsCost, view) : "—", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2416
+ className: CostPill_module_css_default.tok,
2417
+ children: t("panel.tokens", { value: formatTokens(split.subsTokens) })
2418
+ })] })
2419
+ })]
2420
+ })
2421
+ ]
2422
+ }),
2423
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2424
+ className: CostPill_module_css_default.groupLabel,
2425
+ children: t("panel.byModel")
2426
+ }),
2427
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2428
+ className: CostPill_module_css_default.rows,
2429
+ children: detail === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2430
+ className: CostPill_module_css_default.row,
2431
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1458
2432
  className: CostPill_module_css_default.pending,
1459
2433
  children: "…"
1460
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [formatCost(split.subsCost, view), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1461
- className: CostPill_module_css_default.tok,
1462
- children: t("panel.tokens", { value: formatTokens(split.subsTokens) })
1463
- })] })
1464
- })]
1465
- })]
1466
- }),
1467
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1468
- className: CostPill_module_css_default.groupLabel,
1469
- children: t("panel.byModel")
1470
- }),
1471
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1472
- className: CostPill_module_css_default.rows,
1473
- children: detail === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1474
- className: CostPill_module_css_default.row,
1475
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1476
- className: CostPill_module_css_default.pending,
1477
- children: "…"
1478
- })
1479
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [detail.byModel.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
1480
- row,
1481
- view
1482
- }, row.model)), detail.unpricedModels.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1483
- className: `${CostPill_module_css_default.row} ${CostPill_module_css_default.unpriced}`,
1484
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1485
- className: CostPill_module_css_default.rowLabel,
1486
- children: t("panel.unpriced", { count: detail.unpricedModels.length })
1487
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1488
- className: CostPill_module_css_default.rowValue,
1489
- children: t("panel.unpricedNote")
1490
- })]
1491
- })] })
1492
- })
1493
- ]
1494
- })]
2434
+ })
2435
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [detail.byModel.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
2436
+ row,
2437
+ view,
2438
+ t,
2439
+ unpriced: detail.unpricedModels.includes(row.model),
2440
+ available: costsAvailable(detail.costState) && !detail.unpricedModels.includes(row.model)
2441
+ }, row.model)), costsAvailable(detail.costState) && detail.unpricedModels.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2442
+ className: `${CostPill_module_css_default.row} ${CostPill_module_css_default.unpriced}`,
2443
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2444
+ className: CostPill_module_css_default.rowLabel,
2445
+ children: t("panel.unpriced", { count: detail.unpricedModels.length })
2446
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2447
+ className: CostPill_module_css_default.rowValue,
2448
+ children: t("panel.unpricedNote")
2449
+ })]
2450
+ })] })
2451
+ })
2452
+ ]
2453
+ })]
2454
+ })
1495
2455
  });
1496
2456
  }
1497
2457
  /** One per-model breakdown row: model id + request count, billed cost, tokens. */
1498
- function ModelRow({ row, view }) {
2458
+ function ModelRow({ row, view, available, unpriced, t }) {
1499
2459
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1500
2460
  className: CostPill_module_css_default.row,
1501
2461
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1502
2462
  className: CostPill_module_css_default.rowLabel,
1503
- children: [row.model, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1504
- className: CostPill_module_css_default.requests,
1505
- children: ["× ", row.totals.requests]
1506
- })]
2463
+ children: [
2464
+ row.model,
2465
+ unpriced && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnpricedModelTag, {
2466
+ model: row.model,
2467
+ t
2468
+ }),
2469
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelAssociationBadge, {
2470
+ model: row.model,
2471
+ t
2472
+ }),
2473
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2474
+ className: CostPill_module_css_default.requests,
2475
+ children: ["× ", row.totals.requests]
2476
+ })
2477
+ ]
1507
2478
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1508
2479
  className: CostPill_module_css_default.rowValue,
1509
- children: [formatCost(row.cost, view), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2480
+ children: [available ? formatCost(row.cost, view) : "—", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1510
2481
  className: CostPill_module_css_default.tok,
1511
2482
  children: formatTokens(totalTokens(row.totals))
1512
2483
  })]
@@ -1662,13 +2633,13 @@ window.__ModuleLoader__.load({
1662
2633
  }
1663
2634
  //#endregion
1664
2635
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\QuotaButton.module.css.mjs
1665
- const css$11 = ".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);backdrop-filter:var(--dsw-menu-backdrop-filter);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)}";
1666
- const tagId$11 = "@laoyuehanni/dsh-token-usage/QuotaButton.module.css";
1667
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$11) + "]") === null) {
2636
+ const css$10 = ".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);backdrop-filter:var(--dsw-menu-backdrop-filter);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)}";
2637
+ const tagId$10 = "@laoyuehanni/dsh-token-usage/QuotaButton.module.css";
2638
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$10) + "]") === null) {
1668
2639
  const tag = document.createElement("style");
1669
2640
  tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
1670
- tag.dataset.pluginCss = tagId$11;
1671
- tag.textContent = css$11;
2641
+ tag.dataset.pluginCss = tagId$10;
2642
+ tag.textContent = css$10;
1672
2643
  document.head.appendChild(tag);
1673
2644
  }
1674
2645
  var QuotaButton_module_css_default = {
@@ -2056,13 +3027,13 @@ window.__ModuleLoader__.load({
2056
3027
  }
2057
3028
  //#endregion
2058
3029
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageCard.module.css.mjs
2059
- const css$10 = "._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}";
2060
- const tagId$10 = "@laoyuehanni/dsh-token-usage/TokenUsageCard.module.css";
2061
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$10) + "]") === null) {
3030
+ const css$9 = "._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_regionRow{grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:6px;display:grid}._1bMeTa_syncFeedback{grid-column:1/-1}._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}";
3031
+ const tagId$9 = "@laoyuehanni/dsh-token-usage/TokenUsageCard.module.css";
3032
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$9) + "]") === null) {
2062
3033
  const tag = document.createElement("style");
2063
3034
  tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
2064
- tag.dataset.pluginCss = tagId$10;
2065
- tag.textContent = css$10;
3035
+ tag.dataset.pluginCss = tagId$9;
3036
+ tag.textContent = css$9;
2066
3037
  document.head.appendChild(tag);
2067
3038
  }
2068
3039
  var TokenUsageCard_module_css_default = {
@@ -2101,7 +3072,9 @@ window.__ModuleLoader__.load({
2101
3072
  "name": "_1bMeTa_name",
2102
3073
  "note": "_1bMeTa_note",
2103
3074
  "pending": "_1bMeTa_pending",
2104
- "save": "_1bMeTa_save"
3075
+ "regionRow": "_1bMeTa_regionRow",
3076
+ "save": "_1bMeTa_save",
3077
+ "syncFeedback": "_1bMeTa_syncFeedback"
2105
3078
  };
2106
3079
  //#endregion
2107
3080
  //#region src/client/TokenUsageCard.tsx
@@ -2306,34 +3279,41 @@ window.__ModuleLoader__.load({
2306
3279
  className: TokenUsageCard_module_css_default.hint,
2307
3280
  children: t("card.pathHint")
2308
3281
  }),
2309
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3282
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2310
3283
  className: TokenUsageCard_module_css_default.field,
2311
- htmlFor: "token-usage-card-region",
2312
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3284
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
2313
3285
  className: TokenUsageCard_module_css_default.fieldLabel,
3286
+ htmlFor: "token-usage-card-region",
2314
3287
  children: t("card.regionLabel")
2315
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
2316
- id: "token-usage-card-region",
2317
- className: TokenUsageCard_module_css_default.input,
2318
- value: state.fields.pricingRegion,
2319
- disabled: lockInput,
2320
- onChange: (event) => {
2321
- props.editField("pricingRegion", event.target.value);
2322
- },
2323
- children: [
2324
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2325
- value: "",
2326
- children: t("card.regionDefault")
2327
- }),
2328
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2329
- value: "domestic",
2330
- children: t("card.region.domestic")
2331
- }),
2332
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2333
- value: "overseas",
2334
- children: t("card.region.overseas")
2335
- })
2336
- ]
3288
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3289
+ className: TokenUsageCard_module_css_default.regionRow,
3290
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3291
+ id: "token-usage-card-region",
3292
+ className: TokenUsageCard_module_css_default.input,
3293
+ value: state.fields.pricingRegion,
3294
+ disabled: lockInput,
3295
+ onChange: (event) => {
3296
+ props.editField("pricingRegion", event.target.value);
3297
+ },
3298
+ children: [
3299
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3300
+ value: "",
3301
+ children: t("card.regionDefault")
3302
+ }),
3303
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3304
+ value: "domestic",
3305
+ children: t("card.region.domestic")
3306
+ }),
3307
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3308
+ value: "overseas",
3309
+ children: t("card.region.overseas")
3310
+ })
3311
+ ]
3312
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingSyncButton, {
3313
+ disabled: lockInput || state.saving,
3314
+ dirty: state.dirty,
3315
+ t
3316
+ })]
2337
3317
  })]
2338
3318
  }),
2339
3319
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
@@ -2440,15 +3420,84 @@ window.__ModuleLoader__.load({
2440
3420
  }) : null]
2441
3421
  });
2442
3422
  }
3423
+ function PricingSyncButton({ disabled, dirty, t }) {
3424
+ const [status, setStatus] = (0, react.useState)("idle");
3425
+ const [result, setResult] = (0, react.useState)(null);
3426
+ const running = (0, react.useRef)(false);
3427
+ const mounted = (0, react.useRef)(true);
3428
+ (0, react.useEffect)(() => {
3429
+ mounted.current = true;
3430
+ return () => {
3431
+ mounted.current = false;
3432
+ };
3433
+ }, []);
3434
+ const sync = async () => {
3435
+ if (running.current || disabled || dirty) return;
3436
+ running.current = true;
3437
+ setStatus("running");
3438
+ setResult(null);
3439
+ try {
3440
+ const response = await fetch(PRICING_SYNC_PATH, {
3441
+ method: "POST",
3442
+ cache: "no-store"
3443
+ });
3444
+ if (!response.ok) {
3445
+ const body = await response.json();
3446
+ if (mounted.current) setStatus(body.error === "migration-in-progress" ? "migrating" : body.error === "directory-conflict" || body.error === "pricing-source-changed" ? "changed" : "failed");
3447
+ return;
3448
+ }
3449
+ const body = await response.json();
3450
+ if (body === null || typeof body !== "object" || ![
3451
+ body.version,
3452
+ body.updatedAt,
3453
+ body.models,
3454
+ body.aliasPatterns,
3455
+ body.usdExchangeRate
3456
+ ].every((value) => typeof value === "number" && Number.isFinite(value))) throw new Error("unexpected pricing sync response");
3457
+ pricingTableChanged();
3458
+ if (mounted.current) {
3459
+ setResult(body);
3460
+ setStatus("done");
3461
+ }
3462
+ } catch {
3463
+ if (mounted.current) setStatus("failed");
3464
+ } finally {
3465
+ running.current = false;
3466
+ }
3467
+ };
3468
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3469
+ type: "button",
3470
+ className: TokenUsageCard_module_css_default.browse,
3471
+ disabled: disabled || dirty || status === "running",
3472
+ onClick: () => {
3473
+ sync();
3474
+ },
3475
+ children: t(status === "running" ? "card.pricingSync.running" : "card.pricingSync.button")
3476
+ }), dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3477
+ className: `${TokenUsageCard_module_css_default.hint} ${TokenUsageCard_module_css_default.syncFeedback}`,
3478
+ children: t("card.pricingSync.unsaved")
3479
+ }) : status === "done" && result !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3480
+ className: `${TokenUsageCard_module_css_default.note} ${TokenUsageCard_module_css_default.syncFeedback}`,
3481
+ role: "status",
3482
+ children: t("card.pricingSync.done", {
3483
+ version: String(result.version),
3484
+ models: String(result.models)
3485
+ })
3486
+ }) : status === "failed" || status === "changed" || status === "migrating" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3487
+ className: `${TokenUsageCard_module_css_default.failed} ${TokenUsageCard_module_css_default.syncFeedback}`,
3488
+ role: "alert",
3489
+ children: t(`card.pricingSync.${status}`)
3490
+ }) : null] });
3491
+ }
2443
3492
  //#endregion
2444
3493
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\DateRangePicker.module.css.mjs
2445
- const css$9 = ".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-l2);background:var(--dsw-alias-bg-layer-2);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)}";
2446
- const tagId$9 = "@laoyuehanni/dsh-token-usage/DateRangePicker.module.css";
2447
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$9) + "]") === null) {
3494
+ const css$8 = ".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-l2);background:var(--dsw-alias-bg-layer-2);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)}";
3495
+ const tagId$8 = "@laoyuehanni/dsh-token-usage/DateRangePicker.module.css";
3496
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$8) + "]") === null) {
2448
3497
  const tag = document.createElement("style");
2449
3498
  tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
2450
- tag.dataset.pluginCss = tagId$9;
2451
- tag.textContent = css$9;
3499
+ tag.dataset.pluginCss = tagId$8;
3500
+ tag.textContent = css$8;
2452
3501
  document.head.appendChild(tag);
2453
3502
  }
2454
3503
  var DateRangePicker_module_css_default = {
@@ -2672,13 +3721,13 @@ window.__ModuleLoader__.load({
2672
3721
  }
2673
3722
  //#endregion
2674
3723
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\hit-rate-band.module.css.mjs
2675
- 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)}";
2676
- const tagId$8 = "@laoyuehanni/dsh-token-usage/hit-rate-band.module.css";
2677
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$8) + "]") === null) {
3724
+ const css$7 = ".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)}";
3725
+ const tagId$7 = "@laoyuehanni/dsh-token-usage/hit-rate-band.module.css";
3726
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$7) + "]") === null) {
2678
3727
  const tag = document.createElement("style");
2679
3728
  tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
2680
- tag.dataset.pluginCss = tagId$8;
2681
- tag.textContent = css$8;
3729
+ tag.dataset.pluginCss = tagId$7;
3730
+ tag.textContent = css$7;
2682
3731
  document.head.appendChild(tag);
2683
3732
  }
2684
3733
  var hit_rate_band_module_css_default = {
@@ -2706,13 +3755,13 @@ window.__ModuleLoader__.load({
2706
3755
  }
2707
3756
  //#endregion
2708
3757
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\MenuSelect.module.css.mjs
2709
- const css$7 = ".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-l2);background:var(--dsw-alias-bg-layer-2);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}";
2710
- const tagId$7 = "@laoyuehanni/dsh-token-usage/MenuSelect.module.css";
2711
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$7) + "]") === null) {
3758
+ const css$6 = ".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-l2);background:var(--dsw-alias-bg-layer-2);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}";
3759
+ const tagId$6 = "@laoyuehanni/dsh-token-usage/MenuSelect.module.css";
3760
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$6) + "]") === null) {
2712
3761
  const tag = document.createElement("style");
2713
3762
  tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
2714
- tag.dataset.pluginCss = tagId$7;
2715
- tag.textContent = css$7;
3763
+ tag.dataset.pluginCss = tagId$6;
3764
+ tag.textContent = css$6;
2716
3765
  document.head.appendChild(tag);
2717
3766
  }
2718
3767
  var MenuSelect_module_css_default = {
@@ -2880,198 +3929,8 @@ window.__ModuleLoader__.load({
2880
3929
  });
2881
3930
  }
2882
3931
  //#endregion
2883
- //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingDialog.module.css.mjs
2884
- const css$6 = ".gh1SLa_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}.gh1SLa_dialog::backdrop{background:#0006}.gh1SLa_dialogHead{justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px;display:flex}.gh1SLa_dialogTitle{text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:14px;font-weight:600;overflow:hidden}.gh1SLa_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}.gh1SLa_dialogClose:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-interactive-bg-hover)}.gh1SLa_rateNote{color:var(--dsw-alias-label-secondary);margin:6px 0 0;font-size:12px}.gh1SLa_tableWrap{max-height:420px;overflow:auto}.gh1SLa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:420px;font-size:12px}.gh1SLa_table th,.gh1SLa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.gh1SLa_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}.gh1SLa_table td{color:var(--dsw-alias-label-primary)}th.gh1SLa_conditionHead,td.gh1SLa_conditionCell{text-align:left;white-space:normal;min-width:200px}td.gh1SLa_conditionCell{color:var(--dsw-alias-label-secondary);padding-left:20px}.gh1SLa_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}.gh1SLa_groupRow:not(:first-child)>td{border-top:1px solid var(--dsw-alias-border-l1)}";
2885
- const tagId$6 = "@laoyuehanni/dsh-token-usage/PricingDialog.module.css";
2886
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$6) + "]") === null) {
2887
- const tag = document.createElement("style");
2888
- tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
2889
- tag.dataset.pluginCss = tagId$6;
2890
- tag.textContent = css$6;
2891
- document.head.appendChild(tag);
2892
- }
2893
- var PricingDialog_module_css_default = {
2894
- "conditionCell": "gh1SLa_conditionCell",
2895
- "conditionHead": "gh1SLa_conditionHead",
2896
- "dialog": "gh1SLa_dialog",
2897
- "dialogClose": "gh1SLa_dialogClose",
2898
- "dialogHead": "gh1SLa_dialogHead",
2899
- "dialogTitle": "gh1SLa_dialogTitle",
2900
- "groupRow": "gh1SLa_groupRow",
2901
- "rateNote": "gh1SLa_rateNote",
2902
- "table": "gh1SLa_table",
2903
- "tableWrap": "gh1SLa_tableWrap"
2904
- };
2905
- //#endregion
2906
- //#region src/client/PricingDialog.tsx
2907
- /**
2908
- * The pricing dialog of one model: a native `<dialog>` (Esc closes, focus
2909
- * is trapped, the backdrop dims, and the top layer renders it above the
2910
- * table's scroll shell) holding that model's full price table — billing
2911
- * conditions (default / context tiers / peak slots / time rules) × the four
2912
- * per-million rates, converted for a USD view. Shared by the settings
2913
- * page's per-model “定价” affordance and the pricing-overview dialog's
2914
- * drill-in rows; a native showModal naturally stacks a second instance
2915
- * above the overview.
2916
- *
2917
- * @module token-usage/client/PricingDialog
2918
- */
2919
- /** The four base rates of one model as display text (symbol included,
2920
- * converted for a USD view); a missing cache rate bills at the input rate. */
2921
- function billedRates(rates, view) {
2922
- return {
2923
- input: formatRateWithSymbol(rates.inputPerMillion, view),
2924
- output: formatRateWithSymbol(rates.outputPerMillion, view),
2925
- cacheRead: formatRateWithSymbol(rates.cacheReadPerMillion ?? rates.inputPerMillion, view),
2926
- cacheWrite: formatRateWithSymbol(rates.cacheWritePerMillion ?? rates.inputPerMillion, view)
2927
- };
2928
- }
2929
- /** `HH:MM-HH:MM` of one peak window (half-open, local minutes). */
2930
- function windowText(window) {
2931
- const clock = (minute) => `${String(Math.floor(minute / 60)).padStart(2, "0")}:${String(minute % 60).padStart(2, "0")}`;
2932
- return `${clock(window.startMinute)}-${clock(window.endMinute)}`;
2933
- }
2934
- /** The when-it-applies text of one peak slot: its label plus its windows. */
2935
- function slotCondition(slot, t) {
2936
- return `${slot.label ?? t("pricing.peak")} ${slot.windows.map(windowText).join(t("pricing.windowSep"))}`;
2937
- }
2938
- /**
2939
- * The price rows of one rate node (a time rule's or the model root's): the
2940
- * node's own base rates, then its peak slots, then its context tiers
2941
- * (ascending), each tier followed by the peak slots hanging on that tier —
2942
- * mirroring {@link resolveRate}'s node chain, where a matching tier's slots
2943
- * replace the node's and peak rates replace the node's rates wholesale.
2944
- */
2945
- function nodePriceRows(node, t) {
2946
- const rows = [{
2947
- condition: t("pricing.default"),
2948
- rates: node.rates
2949
- }];
2950
- const tiers = [...node.tiers ?? []].sort((a, b) => a.threshold - b.threshold);
2951
- for (const tier of tiers) {
2952
- const tierCondition = t("pricing.tier", { threshold: formatTokens(tier.threshold) });
2953
- rows.push({
2954
- condition: tierCondition,
2955
- rates: tier.rates
2956
- });
2957
- for (const slot of tier.dailySlots ?? []) rows.push({
2958
- condition: `${tierCondition} · ${slotCondition(slot, t)}`,
2959
- rates: slot.rates
2960
- });
2961
- }
2962
- for (const slot of node.slots ?? []) rows.push({
2963
- condition: slotCondition(slot, t),
2964
- rates: slot.rates
2965
- });
2966
- return rows;
2967
- }
2968
- /**
2969
- * One model's price table: rows are billing conditions — grouped into the
2970
- * model root (“常规”, omitted when it is the only group) and one group per
2971
- * time rule with its date window — so tier, peak, and time-rule pricing
2972
- * each show when they apply and what they bill. The structure mirrors
2973
- * {@link resolveRate}'s node chain.
2974
- */
2975
- function ModelPriceTable({ rules, view, t }) {
2976
- const groups = [{
2977
- title: rules.timeRules.length > 0 ? t("pricing.regular") : null,
2978
- rows: nodePriceRows({
2979
- rates: rules.base,
2980
- tiers: rules.contextTiers,
2981
- slots: rules.dailySlots
2982
- }, t)
2983
- }, ...[...rules.timeRules].sort((a, b) => b.endTime - a.endTime).map((rule) => ({
2984
- title: `${rule.label !== void 0 ? `${rule.label} ` : ""}${rule.startTime > 0 ? `${dayKeyOf(/* @__PURE__ */ new Date(rule.startTime * 1e3))} ~ ` : "~ "}${dayKeyOf(/* @__PURE__ */ new Date(rule.endTime * 1e3))}`,
2985
- rows: nodePriceRows({
2986
- rates: rule.rates,
2987
- tiers: rule.contextTiers,
2988
- slots: rule.dailySlots
2989
- }, t)
2990
- }))];
2991
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2992
- className: PricingDialog_module_css_default["tableWrap"],
2993
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2994
- className: PricingDialog_module_css_default["table"],
2995
- "aria-label": t("pricing.title"),
2996
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2997
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2998
- className: PricingDialog_module_css_default["conditionHead"],
2999
- children: t("pricing.condition")
3000
- }),
3001
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
3002
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
3003
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
3004
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] })
3005
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: groups.flatMap((group) => [...group.title !== null ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
3006
- className: PricingDialog_module_css_default["groupRow"],
3007
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3008
- colSpan: 5,
3009
- children: group.title
3010
- })
3011
- }, group.title)] : [], ...group.rows.map((row, index) => {
3012
- const billed = billedRates(row.rates, view);
3013
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3014
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3015
- className: PricingDialog_module_css_default["conditionCell"],
3016
- children: row.condition
3017
- }),
3018
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
3019
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
3020
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
3021
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite })
3022
- ] }, `${group.title ?? ""}-${index}-${row.condition}`);
3023
- })]) })]
3024
- }), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3025
- className: PricingDialog_module_css_default["rateNote"],
3026
- children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
3027
- }) : null]
3028
- });
3029
- }
3030
- /**
3031
- * The pricing dialog of one model. Mounts only while a model is selected;
3032
- * every close path funnels through the dialog's `close` event, which clears
3033
- * the selection and unmounts it.
3034
- */
3035
- function PricingDialog({ model, rules, view, onClose, t }) {
3036
- const dialogRef = (0, react.useRef)(null);
3037
- const backdropPress = (0, react.useRef)(false);
3038
- (0, react.useEffect)(() => {
3039
- const dialog = dialogRef.current;
3040
- if (dialog !== null && !dialog.open) dialog.showModal();
3041
- }, []);
3042
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
3043
- ref: dialogRef,
3044
- className: PricingDialog_module_css_default["dialog"],
3045
- "aria-label": t("pricing.title"),
3046
- onClose,
3047
- onMouseDown: (event) => {
3048
- backdropPress.current = event.target === dialogRef.current;
3049
- },
3050
- onClick: (event) => {
3051
- if (event.target === dialogRef.current && backdropPress.current) dialogRef.current?.close();
3052
- },
3053
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3054
- className: PricingDialog_module_css_default["dialogHead"],
3055
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3056
- className: PricingDialog_module_css_default["dialogTitle"],
3057
- children: model
3058
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3059
- type: "button",
3060
- className: PricingDialog_module_css_default["dialogClose"],
3061
- "aria-label": t("pricing.close"),
3062
- onClick: () => dialogRef.current?.close(),
3063
- children: "✕"
3064
- })]
3065
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPriceTable, {
3066
- rules,
3067
- view,
3068
- t
3069
- })]
3070
- });
3071
- }
3072
- //#endregion
3073
3932
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingOverviewDialog.module.css.mjs
3074
- const css$5 = ".bVRC-q_overview{width:min(720px,100vw - 48px)}.bVRC-q_note{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}.bVRC-q_failRow{align-items:center;gap:8px;display:flex}.bVRC-q_retryButton{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;flex:none;padding:2px 12px;font-size:12px;line-height:18px}.bVRC-q_retryButton:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_search{width:100%;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:6px;margin-bottom:8px;padding:4px 8px;font-size:13px}.bVRC-q_buckets{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:6px;flex-wrap:nowrap;align-items:stretch;margin-bottom:8px;padding:4px;display:flex}.bVRC-q_bucket{flex:1 1 0;align-items:center;gap:4px;min-width:0;padding:0 10px;display:flex}.bVRC-q_bucket+.bVRC-q_bucket{border-left:1px solid var(--dsw-alias-border-l1)}.bVRC-q_bucketLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;flex:none;font-size:11px;line-height:14px}.bVRC-q_unitGroup{flex:none;display:flex}.bVRC-q_unit{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;background:0 0;padding:0 5px;font-size:10px;line-height:14px}.bVRC-q_unit:first-child{border-radius:3px 0 0 3px}.bVRC-q_unit:last-child{border-radius:0 3px 3px 0}.bVRC-q_unit+.bVRC-q_unit{border-left:none}.bVRC-q_unit:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_unit[aria-pressed=true]{color:var(--dsw-alias-label-primary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);font-weight:600}.bVRC-q_bucketInput{width:100%;min-width:0;color:var(--dsw-alias-label-primary);box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2);font-variant-numeric:tabular-nums;background:0 0;border:none;border-radius:4px;flex:1 1 0;padding:2px 18px 2px 6px;font-size:12px}.bVRC-q_bucketInput::-webkit-outer-spin-button,.bVRC-q_bucketInput::-webkit-inner-spin-button{opacity:1;cursor:pointer;height:100%}.bVRC-q_bucketInput:focus{background:var(--dsw-alias-bg-layer-3);outline:none}.bVRC-q_scenarios{flex-wrap:wrap;gap:6px;margin-bottom:8px;display:flex}.bVRC-q_scenario{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:12px;line-height:18px}.bVRC-q_scenario:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_scenario[aria-pressed=true]{border-color:var(--dsw-alias-label-primary)}.bVRC-q_tableWrap{height:min(60vh,520px);overflow:auto}.bVRC-q_table{table-layout:fixed;border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:560px;font-size:12px}.bVRC-q_table th,.bVRC-q_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.bVRC-q_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}.bVRC-q_table td{color:var(--dsw-alias-label-primary)}th.bVRC-q_modelHead,td.bVRC-q_modelCell{text-align:left}th.bVRC-q_modelHead{width:40%}.bVRC-q_sortHead{font:inherit;font-weight:inherit;color:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:none;padding:0}.bVRC-q_sortHead:hover{text-decoration:underline}.bVRC-q_sortArrow{font-size:10px}.bVRC-q_sortArrowIdle{opacity:.5}.bVRC-q_modelRow{cursor:pointer}.bVRC-q_modelRow:hover>td{background:var(--dsw-interactive-bg-hover)}.bVRC-q_cellInner{align-items:center;gap:6px;max-width:100%;display:inline-flex}.bVRC-q_modelName{text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;font-weight:500;overflow:hidden}.bVRC-q_usedTag{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-3);border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.bVRC-q_expandArrow{width:16px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-size:10px;line-height:16px}.bVRC-q_expandArrow:hover{color:var(--dsw-alias-label-primary)}.bVRC-q_arrowGap{flex:none;width:16px}.bVRC-q_expansionRow>td{padding:0 6px 4px}.bVRC-q_specialRows{flex-direction:column;gap:2px;display:flex}.bVRC-q_specialRow{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;grid-template-columns:3.2fr 1fr 1fr 1fr 1fr 1fr;gap:4px;padding:1px 0 1px 28px;font-size:11px;display:grid}.bVRC-q_specialLabel{color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;text-align:left;overflow:hidden}.bVRC-q_specialRate{text-align:right;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}";
3933
+ const css$5 = ".bVRC-q_overview{width:min(720px,100vw - 48px)}.bVRC-q_titleActions{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.bVRC-q_note{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}.bVRC-q_failRow{align-items:center;gap:8px;display:flex}.bVRC-q_retryButton{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;flex:none;padding:2px 12px;font-size:12px;line-height:18px}.bVRC-q_retryButton:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_search{width:100%;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:6px;margin-bottom:8px;padding:4px 8px;font-size:13px}.bVRC-q_buckets{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:6px;flex-wrap:nowrap;align-items:stretch;margin-bottom:8px;padding:4px;display:flex}.bVRC-q_bucket{flex:1 1 0;align-items:center;gap:4px;min-width:0;padding:0 10px;display:flex}.bVRC-q_bucket+.bVRC-q_bucket{border-left:1px solid var(--dsw-alias-border-l1)}.bVRC-q_bucketLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;flex:none;font-size:11px;line-height:14px}.bVRC-q_unitGroup{flex:none;display:flex}.bVRC-q_unit{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;background:0 0;padding:0 5px;font-size:10px;line-height:14px}.bVRC-q_unit:first-child{border-radius:3px 0 0 3px}.bVRC-q_unit:last-child{border-radius:0 3px 3px 0}.bVRC-q_unit+.bVRC-q_unit{border-left:none}.bVRC-q_unit:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_unit[aria-pressed=true]{color:var(--dsw-alias-label-primary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);font-weight:600}.bVRC-q_bucketInput{width:100%;min-width:0;color:var(--dsw-alias-label-primary);box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2);font-variant-numeric:tabular-nums;background:0 0;border:none;border-radius:4px;flex:1 1 0;padding:2px 18px 2px 6px;font-size:12px}.bVRC-q_bucketInput::-webkit-outer-spin-button,.bVRC-q_bucketInput::-webkit-inner-spin-button{opacity:1;cursor:pointer;height:100%}.bVRC-q_bucketInput:focus{background:var(--dsw-alias-bg-layer-3);outline:none}.bVRC-q_scenarios{flex-wrap:wrap;gap:6px;margin-bottom:8px;display:flex}.bVRC-q_scenario{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:12px;line-height:18px}.bVRC-q_scenario:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_scenario[aria-pressed=true]{border-color:var(--dsw-alias-label-primary)}.bVRC-q_tableWrap{height:min(60vh,520px);overflow:auto}.bVRC-q_table{table-layout:fixed;border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:560px;font-size:12px}.bVRC-q_table th,.bVRC-q_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.bVRC-q_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}.bVRC-q_table td{color:var(--dsw-alias-label-primary)}th.bVRC-q_modelHead,td.bVRC-q_modelCell{text-align:left}th.bVRC-q_modelHead{width:40%}.bVRC-q_sortHead{font:inherit;font-weight:inherit;color:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:none;padding:0}.bVRC-q_sortHead:hover{text-decoration:underline}.bVRC-q_sortArrow{font-size:10px}.bVRC-q_sortArrowIdle{opacity:.5}.bVRC-q_modelRow{cursor:pointer}.bVRC-q_modelRow:hover>td{background:var(--dsw-interactive-bg-hover)}.bVRC-q_cellInner{align-items:center;gap:6px;max-width:100%;display:inline-flex}.bVRC-q_modelName{text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;font-weight:500;overflow:hidden}.bVRC-q_usedTag{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-3);border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.bVRC-q_expandArrow{width:16px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-size:10px;line-height:16px}.bVRC-q_expandArrow:hover{color:var(--dsw-alias-label-primary)}.bVRC-q_arrowGap{flex:none;width:16px}.bVRC-q_expansionRow>td{padding:0 6px 4px}.bVRC-q_specialRows{flex-direction:column;gap:2px;display:flex}.bVRC-q_specialRow{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;grid-template-columns:3.2fr 1fr 1fr 1fr 1fr 1fr;gap:4px;padding:1px 0 1px 28px;font-size:11px;display:grid}.bVRC-q_specialLabel{color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;text-align:left;overflow:hidden}.bVRC-q_specialRate{text-align:right;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}";
3075
3934
  const tagId$5 = "@laoyuehanni/dsh-token-usage/PricingOverviewDialog.module.css";
3076
3935
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$5) + "]") === null) {
3077
3936
  const tag = document.createElement("style");
@@ -3109,11 +3968,36 @@ window.__ModuleLoader__.load({
3109
3968
  "specialRows": "bVRC-q_specialRows",
3110
3969
  "table": "bVRC-q_table",
3111
3970
  "tableWrap": "bVRC-q_tableWrap",
3971
+ "titleActions": "bVRC-q_titleActions",
3112
3972
  "unit": "bVRC-q_unit",
3113
3973
  "unitGroup": "bVRC-q_unitGroup",
3114
3974
  "usedTag": "bVRC-q_usedTag"
3115
3975
  };
3116
3976
  //#endregion
3977
+ //#region src/client/pricing-search.ts
3978
+ const patternCache = /* @__PURE__ */ new WeakMap();
3979
+ function patternsOf(model) {
3980
+ let patterns = patternCache.get(model);
3981
+ if (patterns === void 0) {
3982
+ patterns = model.aliasPatterns.map(compileAliasPattern);
3983
+ patternCache.set(model, patterns);
3984
+ }
3985
+ return patterns;
3986
+ }
3987
+ function sortPricingModels(models) {
3988
+ return [...models].sort((a, b) => {
3989
+ const familyA = a.family ?? "other", familyB = b.family ?? "other";
3990
+ if (familyA !== familyB) return familyA < familyB ? -1 : 1;
3991
+ return a.modelId < b.modelId ? -1 : a.modelId > b.modelId ? 1 : 0;
3992
+ });
3993
+ }
3994
+ /** Substrings are a search aid only; server resolution determines identity. */
3995
+ function matchesPricingSearch(model, query) {
3996
+ if (query === "") return true;
3997
+ const needle = query.toLowerCase();
3998
+ return model.modelId.toLowerCase().includes(needle) || (model.family ?? "other").toLowerCase().includes(needle) || patternsOf(model).some((regex) => matchesAliasPattern(regex, query));
3999
+ }
4000
+ //#endregion
3117
4001
  //#region src/client/PricingOverviewDialog.tsx
3118
4002
  /**
3119
4003
  * The pricing-overview dialog of the settings page: the full cloud-mirror
@@ -3141,39 +4025,6 @@ window.__ModuleLoader__.load({
3141
4025
  *
3142
4026
  * @module token-usage/client/PricingOverviewDialog
3143
4027
  */
3144
- /** The family a model row without a feed `family` lands in; the feed
3145
- * itself already uses this value for uncategorized rows. */
3146
- const OTHER_FAMILY = "other";
3147
- /** The family of one row (absent → `other`): the sort key's first half
3148
- * and one of the search dimensions. */
3149
- function familyOf(model) {
3150
- return model.family ?? OTHER_FAMILY;
3151
- }
3152
- /**
3153
- * Sort models by family (alphabetical, absent → `other`), then by modelId —
3154
- * the feed's own classification drives the browsing order so same-family
3155
- * models stay adjacent, with zero client-side mapping.
3156
- */
3157
- function sortPricingModels(models) {
3158
- return [...models].sort((a, b) => {
3159
- const familyA = familyOf(a);
3160
- const familyB = familyOf(b);
3161
- if (familyA !== familyB) return familyA < familyB ? -1 : 1;
3162
- return a.modelId < b.modelId ? -1 : a.modelId > b.modelId ? 1 : 0;
3163
- });
3164
- }
3165
- /**
3166
- * Whether one model row matches the search: a case-insensitive substring
3167
- * hit on the modelId, any alias, or the family. An empty query
3168
- * matches everything.
3169
- */
3170
- function matchesPricingSearch(model, query) {
3171
- if (query === "") return true;
3172
- const needle = query.toLowerCase();
3173
- if (model.modelId.toLowerCase().includes(needle)) return true;
3174
- if (familyOf(model).toLowerCase().includes(needle)) return true;
3175
- return model.aliases.some((alias) => alias.toLowerCase().includes(needle));
3176
- }
3177
4028
  /** The preset cases the buttons fill the inputs with (maintainer-curated
3178
4029
  * classic workloads). The first prefills the inputs on open. */
3179
4030
  const SIM_SCENARIOS = [
@@ -3324,6 +4175,7 @@ window.__ModuleLoader__.load({
3324
4175
  return response.json();
3325
4176
  }).then((value) => {
3326
4177
  if (typeof value !== "object" || value === null || !Array.isArray(value.models)) throw new Error("unexpected pricing response");
4178
+ if (value.costState === "pricing-unavailable") return value;
3327
4179
  if (value.models.length === 0) throw new Error("pricing mirror is empty");
3328
4180
  return value;
3329
4181
  });
@@ -3343,10 +4195,12 @@ window.__ModuleLoader__.load({
3343
4195
  if (dialog !== null && !dialog.open) dialog.showModal();
3344
4196
  }, []);
3345
4197
  const [state, retry] = useAsyncResource(fetchPricingOverview, [], { retryToken: 0 });
4198
+ usePricingAssociationRefresh(retry);
3346
4199
  const [search, setSearch] = (0, react.useState)("");
3347
4200
  const [buckets, setBuckets] = (0, react.useState)(() => bucketsOfCase(SIM_SCENARIOS[0]));
3348
4201
  const [sortMode, setSortMode] = (0, react.useState)("family");
3349
4202
  const [detail, setDetail] = (0, react.useState)(null);
4203
+ const [associationsOpen, setAssociationsOpen] = (0, react.useState)(false);
3350
4204
  const [nowMs] = (0, react.useState)(() => Date.now());
3351
4205
  const [expandedId, setExpandedId] = (0, react.useState)(null);
3352
4206
  const sorted = (0, react.useMemo)(() => sortPricingModels(state.status === "ready" ? state.value.models : []), [state]);
@@ -3405,9 +4259,15 @@ window.__ModuleLoader__.load({
3405
4259
  children: [
3406
4260
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3407
4261
  className: PricingDialog_module_css_default["dialogHead"],
3408
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3409
- className: PricingDialog_module_css_default["dialogTitle"],
3410
- children: t("pricing.table")
4262
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4263
+ className: PricingOverviewDialog_module_css_default.titleActions,
4264
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4265
+ className: PricingDialog_module_css_default["dialogTitle"],
4266
+ children: t("pricing.table")
4267
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingAssociationManagerButton, {
4268
+ t,
4269
+ onOpen: () => setAssociationsOpen(true)
4270
+ })]
3411
4271
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3412
4272
  type: "button",
3413
4273
  className: PricingDialog_module_css_default["dialogClose"],
@@ -3416,6 +4276,12 @@ window.__ModuleLoader__.load({
3416
4276
  children: "✕"
3417
4277
  })]
3418
4278
  }),
4279
+ associationsOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingAssociationDialog, {
4280
+ initialSource: null,
4281
+ view,
4282
+ t,
4283
+ onClose: () => setAssociationsOpen(false)
4284
+ }),
3419
4285
  state.status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3420
4286
  className: PricingOverviewDialog_module_css_default["note"],
3421
4287
  children: t("loading")
@@ -3432,7 +4298,20 @@ window.__ModuleLoader__.load({
3432
4298
  children: t("retry")
3433
4299
  })]
3434
4300
  }) : null,
3435
- state.status === "ready" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
4301
+ state.status === "ready" && !costsAvailable(state.value.costState) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4302
+ className: PricingOverviewDialog_module_css_default["failRow"],
4303
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingStatus, {
4304
+ costState: state.value.costState,
4305
+ ...state.value.pricingUnavailableReason !== void 0 ? { pricingUnavailableReason: state.value.pricingUnavailableReason } : {},
4306
+ t
4307
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4308
+ type: "button",
4309
+ className: PricingOverviewDialog_module_css_default["retryButton"],
4310
+ onClick: retry,
4311
+ children: t("retry")
4312
+ })]
4313
+ }) : null,
4314
+ state.status === "ready" && costsAvailable(state.value.costState) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3436
4315
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3437
4316
  type: "search",
3438
4317
  className: PricingOverviewDialog_module_css_default["search"],
@@ -3993,7 +4872,7 @@ window.__ModuleLoader__.load({
3993
4872
  * @param props - the served rows, the currency view, the session jump
3994
4873
  * seats (absent on tests / hosts without the controller), locale.
3995
4874
  */
3996
- function SessionTable({ rows, view, t, sessionListed, openSession }) {
4875
+ function SessionTable({ rows, view, t, sessionListed, openSession, costState }) {
3997
4876
  const [grouped, setGrouped] = (0, react.useState)(readGroupedPreference);
3998
4877
  const toggleGrouped = (next) => {
3999
4878
  setGrouped(next);
@@ -4142,7 +5021,7 @@ window.__ModuleLoader__.load({
4142
5021
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(totalTokens(row.totals)) }),
4143
5022
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
4144
5023
  className: SessionTable_module_css_default["costCol"],
4145
- children: formatCost(row.cost, view)
5024
+ children: costsAvailable(costState) ? formatCost(row.cost, view) : "—"
4146
5025
  }),
4147
5026
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: dayKeyOf(new Date(row.lastTime)) })
4148
5027
  ] }, row.sessionId);
@@ -4935,7 +5814,7 @@ window.__ModuleLoader__.load({
4935
5814
  }
4936
5815
  //#endregion
4937
5816
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageSection.module.css.mjs
4938
- 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_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_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}.RbkiSa_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}.RbkiSa_segBtn:hover:not(.RbkiSa_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}.RbkiSa_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}.RbkiSa_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);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);border-bottom:1.5px solid var(--dsw-alias-border-l2);font-weight:600;position:sticky;top:0}.RbkiSa_table tbody tr{transition:background-color .12s}.RbkiSa_table tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}.RbkiSa_costCol{font-weight:600}.RbkiSa_zeroDim{color:var(--dsw-alias-label-tertiary);opacity:.55}.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}button.RbkiSa_modelName{max-width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;margin:0;padding:0}button.RbkiSa_modelName:hover{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary))}.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_pricingLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;flex:none;margin-left:auto;padding:4px 8px;font-size:13px;line-height:20px}.RbkiSa_pricingLink:hover{background:var(--dsw-interactive-bg-hover)}";
5817
+ 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_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_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}.RbkiSa_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}.RbkiSa_segBtn:hover:not(.RbkiSa_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}.RbkiSa_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}.RbkiSa_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);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);border-bottom:1.5px solid var(--dsw-alias-border-l2);font-weight:600;position:sticky;top:0}.RbkiSa_table tbody tr{transition:background-color .12s}.RbkiSa_table tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}.RbkiSa_costCol{font-weight:600}.RbkiSa_zeroDim{color:var(--dsw-alias-label-tertiary);opacity:.55}.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_modelCell{align-items:center;gap:4px;max-width:138px;display:inline-flex;position:relative}.RbkiSa_modelName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}button.RbkiSa_modelName{max-width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;margin:0;padding:0}button.RbkiSa_modelName:hover{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary))}.RbkiSa_pricingLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;flex:none;margin-left:auto;padding:4px 8px;font-size:13px;line-height:20px}.RbkiSa_pricingLink:hover{background:var(--dsw-interactive-bg-hover)}";
4939
5818
  const tagId$1 = "@laoyuehanni/dsh-token-usage/TokenUsageSection.module.css";
4940
5819
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
4941
5820
  const tag = document.createElement("style");
@@ -4966,8 +5845,6 @@ window.__ModuleLoader__.load({
4966
5845
  "table": "RbkiSa_table",
4967
5846
  "tableWrap": "RbkiSa_tableWrap",
4968
5847
  "title": "RbkiSa_title",
4969
- "unpricedTag": "RbkiSa_unpricedTag",
4970
- "warning": "RbkiSa_warning",
4971
5848
  "zeroDim": "RbkiSa_zeroDim"
4972
5849
  };
4973
5850
  //#endregion
@@ -5103,6 +5980,7 @@ window.__ModuleLoader__.load({
5103
5980
  }),
5104
5981
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5105
5982
  type: "button",
5983
+ "data-pricing-overview-trigger": true,
5106
5984
  className: TokenUsageSection_module_css_default["pricingLink"],
5107
5985
  onClick: onPricingTable,
5108
5986
  children: t("pricing.table")
@@ -5158,9 +6036,11 @@ window.__ModuleLoader__.load({
5158
6036
  const [pricingTableOpen, setPricingTableOpen] = (0, react.useState)(false);
5159
6037
  const [usedSnapshot, setUsedSnapshot] = (0, react.useState)(() => /* @__PURE__ */ new Set());
5160
6038
  const [retryToken, setRetryToken] = (0, react.useState)(0);
6039
+ const lastSummary = (0, react.useRef)(null);
5161
6040
  const retry = (0, react.useCallback)(() => {
5162
6041
  setRetryToken((previous) => previous + 1);
5163
6042
  }, []);
6043
+ usePricingAssociationRefresh(retry);
5164
6044
  const query = filterQuery(filters);
5165
6045
  const lastValidQueryRef = (0, react.useRef)(query ?? "");
5166
6046
  if (query !== null) lastValidQueryRef.current = query;
@@ -5180,252 +6060,285 @@ window.__ModuleLoader__.load({
5180
6060
  filters.model,
5181
6061
  models
5182
6062
  ]);
5183
- if (state.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6063
+ if (state.status === "ready") lastSummary.current = state.value;
6064
+ const retainedView = lastSummary.current !== null ? currencyViewOf(lastSummary.current) : {
6065
+ symbol: "¥",
6066
+ rate: 1
6067
+ };
6068
+ const pricingOverview = pricingTableOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingOverviewDialog, {
6069
+ usedModels: usedSnapshot,
6070
+ view: retainedView,
6071
+ onClose: () => setPricingTableOpen(false),
6072
+ t
6073
+ }) : null;
6074
+ if (state.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5184
6075
  ref: rootRef,
5185
6076
  className: TokenUsageSection_module_css_default["section"],
5186
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
5187
- className: TokenUsageSection_module_css_default["title"],
5188
- children: t("nav.label")
5189
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5190
- className: TokenUsageSection_module_css_default["muted"],
5191
- children: t("loading")
5192
- })]
6077
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PricingAssociationProvider, {
6078
+ resolutions: lastSummary.current?.modelResolutions,
6079
+ feedVersion: lastSummary.current?.feedVersion,
6080
+ view: retainedView,
6081
+ t,
6082
+ children: [
6083
+ pricingOverview,
6084
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
6085
+ className: TokenUsageSection_module_css_default["title"],
6086
+ children: t("nav.label")
6087
+ }),
6088
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6089
+ className: TokenUsageSection_module_css_default["muted"],
6090
+ children: t("loading")
6091
+ })
6092
+ ]
6093
+ })
5193
6094
  });
5194
- if (state.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6095
+ if (state.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5195
6096
  ref: rootRef,
5196
6097
  className: TokenUsageSection_module_css_default["section"],
5197
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5198
- className: TokenUsageSection_module_css_default["head"],
5199
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
5200
- className: TokenUsageSection_module_css_default["title"],
5201
- children: t("nav.label")
5202
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5203
- type: "button",
5204
- className: TokenUsageSection_module_css_default["button"],
5205
- onClick: retry,
5206
- children: t("retry")
5207
- })]
5208
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5209
- className: TokenUsageSection_module_css_default["error"],
5210
- children: t("loadFailed", { message: state.message })
5211
- })]
6098
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PricingAssociationProvider, {
6099
+ resolutions: lastSummary.current?.modelResolutions,
6100
+ feedVersion: lastSummary.current?.feedVersion,
6101
+ view: retainedView,
6102
+ t,
6103
+ children: [
6104
+ pricingOverview,
6105
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6106
+ className: TokenUsageSection_module_css_default["head"],
6107
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
6108
+ className: TokenUsageSection_module_css_default["title"],
6109
+ children: t("nav.label")
6110
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6111
+ type: "button",
6112
+ className: TokenUsageSection_module_css_default["button"],
6113
+ onClick: retry,
6114
+ children: t("retry")
6115
+ })]
6116
+ }),
6117
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6118
+ className: TokenUsageSection_module_css_default["error"],
6119
+ children: t("loadFailed", { message: state.message })
6120
+ })
6121
+ ]
6122
+ })
5212
6123
  });
5213
6124
  const { total } = state.value;
5214
6125
  const view = currencyViewOf(state.value);
5215
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6126
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5216
6127
  ref: rootRef,
5217
6128
  className: TokenUsageSection_module_css_default["section"],
5218
- children: [
5219
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
5220
- className: TokenUsageSection_module_css_default["title"],
5221
- children: t("nav.label")
5222
- }),
5223
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5224
- className: TokenUsageSection_module_css_default["muted"],
5225
- children: t("dataDir", { path: state.value.dataDir })
5226
- }),
5227
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterBar, {
5228
- filters,
5229
- models,
5230
- onChange: setFilters,
5231
- onPricingTable: () => {
5232
- setUsedSnapshot(new Set(state.value.byModel.map((row) => row.model)));
5233
- setPricingTableOpen(true);
5234
- },
5235
- t
5236
- }),
5237
- pricingTableOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingOverviewDialog, {
5238
- usedModels: usedSnapshot,
5239
- view,
5240
- onClose: () => setPricingTableOpen(false),
5241
- t
5242
- }) : null,
5243
- total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5244
- className: TokenUsageSection_module_css_default["empty"],
5245
- children: t("empty")
5246
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
5247
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5248
- className: TokenUsageSection_module_css_default["cards"],
5249
- children: [
5250
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
5251
- requests: total.requests,
5252
- failures: total.failures ?? 0,
5253
- failuresByCode: total.failuresByCode,
5254
- t
5255
- }),
5256
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5257
- label: t("stat.cost"),
5258
- value: formatCost(state.value.totalCost, view)
5259
- }),
5260
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5261
- label: t("stat.totalTokens"),
5262
- value: formatTokens(totalTokens(total))
5263
- }),
5264
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5265
- label: t("stat.hitRate"),
5266
- value: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: total })
5267
- })
5268
- ]
6129
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PricingAssociationProvider, {
6130
+ resolutions: state.value.modelResolutions,
6131
+ feedVersion: state.value.feedVersion,
6132
+ view,
6133
+ t,
6134
+ children: [
6135
+ pricingOverview,
6136
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
6137
+ className: TokenUsageSection_module_css_default["title"],
6138
+ children: t("nav.label")
5269
6139
  }),
5270
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5271
- className: TokenUsageSection_module_css_default["cards"],
5272
- children: [
5273
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5274
- label: t("stat.input"),
5275
- value: formatTokens(total.inputTokens)
5276
- }),
5277
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5278
- label: t("stat.output"),
5279
- value: formatTokens(total.outputTokens)
5280
- }),
5281
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5282
- label: t("stat.cacheRead"),
5283
- value: formatTokens(total.cacheReadTokens)
5284
- }),
5285
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5286
- label: t("stat.cacheWrite"),
5287
- value: formatTokens(total.cacheWriteTokens)
5288
- })
5289
- ]
6140
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6141
+ className: TokenUsageSection_module_css_default["muted"],
6142
+ children: t("dataDir", { path: state.value.dataDir })
5290
6143
  }),
5291
- state.value.unpricedModels.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5292
- className: TokenUsageSection_module_css_default["warning"],
5293
- role: "status",
5294
- children: t("unpriced.warning", {
5295
- count: String(state.value.unpricedModels.length),
5296
- models: state.value.unpricedModels.join(", "),
5297
- zero: formatCost(0, view)
5298
- })
5299
- }) : null,
5300
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
5301
- rows: state.value.byDay,
5302
- t,
5303
- ...filters.from !== "" ? { from: filters.from } : {},
5304
- ...filters.to !== "" ? { to: filters.to } : {},
5305
- ...filters.from !== "" && filters.from === filters.to ? { hours: state.value.byHour } : {}
6144
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterBar, {
6145
+ filters,
6146
+ models,
6147
+ onChange: setFilters,
6148
+ onPricingTable: () => {
6149
+ setUsedSnapshot(new Set(state.value.byModel.map((row) => row.model)));
6150
+ setPricingTableOpen(true);
6151
+ },
6152
+ t
5306
6153
  }),
5307
- state.value.byModel.length > 0 || (state.value.sessionRows?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5308
- className: TokenUsageSection_module_css_default["segmented"],
5309
- role: "group",
5310
- "aria-label": t("detail.switch.label"),
5311
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5312
- type: "button",
5313
- className: detailMode === "model" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
5314
- "aria-pressed": detailMode === "model",
5315
- onClick: () => setDetailMode("model"),
5316
- children: t("byModel.title")
5317
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5318
- type: "button",
5319
- className: detailMode === "session" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
5320
- "aria-pressed": detailMode === "session",
5321
- onClick: () => setDetailMode("session"),
5322
- children: t("bySession.title")
5323
- })]
5324
- }), detailMode === "model" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5325
- className: TokenUsageSection_module_css_default["tableWrap"],
5326
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
5327
- className: TokenUsageSection_module_css_default["table"],
5328
- "aria-label": t("byModel.title"),
5329
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
5330
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
5331
- className: TokenUsageSection_module_css_default["modelHead"],
5332
- children: t("filter.model")
6154
+ total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6155
+ className: TokenUsageSection_module_css_default["empty"],
6156
+ children: t("empty")
6157
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
6158
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6159
+ className: TokenUsageSection_module_css_default["cards"],
6160
+ children: [
6161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
6162
+ requests: total.requests,
6163
+ failures: total.failures ?? 0,
6164
+ failuresByCode: total.failuresByCode,
6165
+ t
5333
6166
  }),
5334
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
5335
- "aria-label": t("stat.successFail"),
5336
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
6167
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6168
+ label: t("stat.cost"),
6169
+ value: costsAvailable(state.value.costState) ? formatCost(state.value.totalCost, view) : "—"
5337
6170
  }),
5338
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") }),
5339
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.totalTokens") }),
5340
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
5341
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.output") }),
5342
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheRead") }),
5343
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheWrite") }),
5344
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.hitRate") })
5345
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: state.value.byModel.map((row) => {
5346
- const rules = state.value.pricing[row.model];
5347
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
5348
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5349
- className: TokenUsageSection_module_css_default["modelCol"],
5350
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5351
- className: TokenUsageSection_module_css_default["modelCell"],
5352
- children: rules !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5353
- type: "button",
5354
- className: TokenUsageSection_module_css_default["modelName"],
5355
- "aria-label": t("pricing.view", { model: row.model }),
5356
- onClick: () => setDetailModel(row.model),
5357
- children: row.model
5358
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5359
- className: TokenUsageSection_module_css_default["modelName"],
5360
- children: row.model
5361
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5362
- className: TokenUsageSection_module_css_default["unpricedTag"],
5363
- children: t("pricing.unpriced")
5364
- })] })
5365
- })
5366
- }),
5367
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
5368
- requests: row.totals.requests,
5369
- failures: row.totals.failures ?? 0,
5370
- failuresByCode: row.totals.failuresByCode,
5371
- t
5372
- }) }),
5373
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5374
- className: TokenUsageSection_module_css_default["costCol"],
5375
- children: rules !== void 0 ? formatCost(row.cost, view) : "—"
5376
- }),
5377
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(totalTokens(row.totals)) }),
5378
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5379
- className: row.totals.inputTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
5380
- children: formatTokens(row.totals.inputTokens)
5381
- }),
5382
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5383
- className: row.totals.outputTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
5384
- children: formatTokens(row.totals.outputTokens)
5385
- }),
5386
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5387
- className: row.totals.cacheReadTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
5388
- children: formatTokens(row.totals.cacheReadTokens)
6171
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6172
+ label: t("stat.totalTokens"),
6173
+ value: formatTokens(totalTokens(total))
6174
+ }),
6175
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6176
+ label: t("stat.hitRate"),
6177
+ value: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: total })
6178
+ })
6179
+ ]
6180
+ }),
6181
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6182
+ className: TokenUsageSection_module_css_default["cards"],
6183
+ children: [
6184
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6185
+ label: t("stat.input"),
6186
+ value: formatTokens(total.inputTokens)
6187
+ }),
6188
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6189
+ label: t("stat.output"),
6190
+ value: formatTokens(total.outputTokens)
6191
+ }),
6192
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6193
+ label: t("stat.cacheRead"),
6194
+ value: formatTokens(total.cacheReadTokens)
6195
+ }),
6196
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6197
+ label: t("stat.cacheWrite"),
6198
+ value: formatTokens(total.cacheWriteTokens)
6199
+ })
6200
+ ]
6201
+ }),
6202
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingStatus, {
6203
+ costState: state.value.costState,
6204
+ pricingUnavailableReason: state.value.pricingUnavailableReason,
6205
+ associationStorageError: state.value.associationStorageError,
6206
+ t
6207
+ }),
6208
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
6209
+ rows: state.value.byDay,
6210
+ t,
6211
+ ...filters.from !== "" ? { from: filters.from } : {},
6212
+ ...filters.to !== "" ? { to: filters.to } : {},
6213
+ ...filters.from !== "" && filters.from === filters.to ? { hours: state.value.byHour } : {}
6214
+ }),
6215
+ state.value.byModel.length > 0 || (state.value.sessionRows?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6216
+ className: TokenUsageSection_module_css_default["segmented"],
6217
+ role: "group",
6218
+ "aria-label": t("detail.switch.label"),
6219
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6220
+ type: "button",
6221
+ className: detailMode === "model" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
6222
+ "aria-pressed": detailMode === "model",
6223
+ onClick: () => setDetailMode("model"),
6224
+ children: t("byModel.title")
6225
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6226
+ type: "button",
6227
+ className: detailMode === "session" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
6228
+ "aria-pressed": detailMode === "session",
6229
+ onClick: () => setDetailMode("session"),
6230
+ children: t("bySession.title")
6231
+ })]
6232
+ }), detailMode === "model" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6233
+ className: TokenUsageSection_module_css_default["tableWrap"],
6234
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
6235
+ className: TokenUsageSection_module_css_default["table"],
6236
+ "aria-label": t("byModel.title"),
6237
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
6238
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
6239
+ className: TokenUsageSection_module_css_default["modelHead"],
6240
+ children: t("filter.model")
5389
6241
  }),
5390
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5391
- className: row.totals.cacheWriteTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
5392
- children: formatTokens(row.totals.cacheWriteTokens)
6242
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
6243
+ "aria-label": t("stat.successFail"),
6244
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
5393
6245
  }),
5394
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: row.totals }) })
5395
- ] }, row.model);
5396
- }) })]
5397
- })
5398
- }) : (state.value.sessionRows?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionTable, {
5399
- rows: state.value.sessionRows ?? [],
5400
- view,
5401
- t,
5402
- ...sessionListed !== void 0 && openSession !== void 0 ? {
5403
- sessionListed,
5404
- openSession: handleOpenSession
5405
- } : {}
5406
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5407
- className: TokenUsageSection_module_css_default["muted"],
5408
- children: t("chart.empty")
5409
- })] }) : null,
5410
- detailModel !== null && state.value.pricing[detailModel] !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingDialog, {
5411
- model: detailModel,
5412
- rules: state.value.pricing[detailModel],
5413
- view,
5414
- onClose: () => setDetailModel(null),
5415
- t
5416
- }) : null
5417
- ] }),
5418
- toastText !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
5419
- text: toastText,
5420
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, {}),
5421
- onDone: dismissToast
5422
- }, toastSeq)
5423
- ]
6246
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") }),
6247
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.totalTokens") }),
6248
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
6249
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.output") }),
6250
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheRead") }),
6251
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheWrite") }),
6252
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.hitRate") })
6253
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: state.value.byModel.map((row) => {
6254
+ const rules = state.value.pricing[row.model];
6255
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
6256
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6257
+ className: TokenUsageSection_module_css_default["modelCol"],
6258
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6259
+ className: TokenUsageSection_module_css_default["modelCell"],
6260
+ children: [rules !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6261
+ type: "button",
6262
+ className: TokenUsageSection_module_css_default["modelName"],
6263
+ "aria-label": t("pricing.view", { model: row.model }),
6264
+ onClick: () => setDetailModel(row.model),
6265
+ children: row.model
6266
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6267
+ className: TokenUsageSection_module_css_default["modelName"],
6268
+ children: row.model
6269
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnpricedModelTag, {
6270
+ model: row.model,
6271
+ t
6272
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelAssociationBadge, {
6273
+ model: row.model,
6274
+ t
6275
+ })]
6276
+ })
6277
+ }),
6278
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
6279
+ requests: row.totals.requests,
6280
+ failures: row.totals.failures ?? 0,
6281
+ failuresByCode: row.totals.failuresByCode,
6282
+ t
6283
+ }) }),
6284
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6285
+ className: TokenUsageSection_module_css_default["costCol"],
6286
+ children: costsAvailable(state.value.costState) && rules !== void 0 ? formatCost(row.cost, view) : "—"
6287
+ }),
6288
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(totalTokens(row.totals)) }),
6289
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6290
+ className: row.totals.inputTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
6291
+ children: formatTokens(row.totals.inputTokens)
6292
+ }),
6293
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6294
+ className: row.totals.outputTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
6295
+ children: formatTokens(row.totals.outputTokens)
6296
+ }),
6297
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6298
+ className: row.totals.cacheReadTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
6299
+ children: formatTokens(row.totals.cacheReadTokens)
6300
+ }),
6301
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6302
+ className: row.totals.cacheWriteTokens === 0 ? TokenUsageSection_module_css_default["zeroDim"] : void 0,
6303
+ children: formatTokens(row.totals.cacheWriteTokens)
6304
+ }),
6305
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: row.totals }) })
6306
+ ] }, row.model);
6307
+ }) })]
6308
+ })
6309
+ }) : (state.value.sessionRows?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionTable, {
6310
+ rows: state.value.sessionRows ?? [],
6311
+ costState: state.value.costState,
6312
+ view,
6313
+ t,
6314
+ ...sessionListed !== void 0 && openSession !== void 0 ? {
6315
+ sessionListed,
6316
+ openSession: handleOpenSession
6317
+ } : {}
6318
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6319
+ className: TokenUsageSection_module_css_default["muted"],
6320
+ children: t("chart.empty")
6321
+ })] }) : null,
6322
+ detailModel !== null && state.value.pricing[detailModel] !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingDialog, {
6323
+ model: detailModel,
6324
+ rules: state.value.pricing[detailModel],
6325
+ view,
6326
+ onClose: () => setDetailModel(null),
6327
+ t
6328
+ }) : null
6329
+ ] }),
6330
+ toastText !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
6331
+ text: toastText,
6332
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, {}),
6333
+ onDone: dismissToast
6334
+ }, toastSeq)
6335
+ ]
6336
+ })
5424
6337
  });
5425
6338
  }
5426
6339
  //#endregion
5427
6340
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\UsageView.module.css.mjs
5428
- const css = "._0MkXVa_root{box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);padding-bottom:calc(var(--dsh-composer-height,152px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;min-height:0;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 tbody tr{transition:background-color .12s}._0MkXVa_table tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}._0MkXVa_table th{border-bottom:1.5px solid var(--dsw-alias-border-l2);font-weight:600}._0MkXVa_costCol{font-weight:600}._0MkXVa_zeroDim{color:var(--dsw-alias-label-tertiary);opacity:.55}._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}}";
6341
+ const css = "._0MkXVa_root{box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);padding-bottom:calc(var(--dsh-composer-height,152px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;min-height:0;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 tbody tr{transition:background-color .12s}._0MkXVa_table tbody tr:hover{background-color:var(--dsw-interactive-bg-hover)}._0MkXVa_table th{border-bottom:1.5px solid var(--dsw-alias-border-l2);font-weight:600}._0MkXVa_costCol{font-weight:600}._0MkXVa_zeroDim{color:var(--dsw-alias-label-tertiary);opacity:.55}._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_modelIdentity{align-items:center;gap:4px;max-width:180px;display:inline-flex}._0MkXVa_modelName{text-overflow:ellipsis;min-width:0;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}}";
5429
6342
  const tagId = "@laoyuehanni/dsh-token-usage/UsageView.module.css";
5430
6343
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
5431
6344
  const tag = document.createElement("style");
@@ -5450,6 +6363,8 @@ window.__ModuleLoader__.load({
5450
6363
  "modelCell": "_0MkXVa_modelCell",
5451
6364
  "modelCol": "_0MkXVa_modelCol",
5452
6365
  "modelHead": "_0MkXVa_modelHead",
6366
+ "modelIdentity": "_0MkXVa_modelIdentity",
6367
+ "modelName": "_0MkXVa_modelName",
5453
6368
  "muted": "_0MkXVa_muted",
5454
6369
  "nestedBadge": "_0MkXVa_nestedBadge",
5455
6370
  "note": "_0MkXVa_note",
@@ -5536,6 +6451,7 @@ window.__ModuleLoader__.load({
5536
6451
  const retry = () => {
5537
6452
  setRetryToken((token) => token + 1);
5538
6453
  };
6454
+ usePricingAssociationRefresh(retry);
5539
6455
  const byId = useSessions((state) => state.byId);
5540
6456
  const childIndex = (0, react.useMemo)(() => buildChildIndex(byId), [byId]);
5541
6457
  const scopeIds = (0, react.useMemo)(() => scope === "tree" ? subtreeIds(byId, focusId, childIndex) : [focusId], [
@@ -5607,291 +6523,333 @@ window.__ModuleLoader__.load({
5607
6523
  })
5608
6524
  })
5609
6525
  });
5610
- if (summaryState.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6526
+ if (summaryState.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5611
6527
  ref: rootRef,
5612
6528
  className: UsageView_module_css_default["root"],
5613
6529
  ...COMPOSER_OVERLAY,
5614
- children: [header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5615
- className: UsageView_module_css_default["muted"],
5616
- children: t("loading")
5617
- })]
6530
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PricingAssociationProvider, {
6531
+ view: {
6532
+ symbol: "¥",
6533
+ rate: 1
6534
+ },
6535
+ t,
6536
+ children: [header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6537
+ className: UsageView_module_css_default["muted"],
6538
+ children: t("loading")
6539
+ })]
6540
+ })
5618
6541
  });
5619
- if (summaryState.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6542
+ if (summaryState.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5620
6543
  ref: rootRef,
5621
6544
  className: UsageView_module_css_default["root"],
5622
6545
  ...COMPOSER_OVERLAY,
5623
- children: [
5624
- header,
5625
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5626
- className: UsageView_module_css_default["error"],
5627
- children: t("loadFailed", { message: summaryState.message })
5628
- }),
5629
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5630
- type: "button",
5631
- className: UsageView_module_css_default["button"],
5632
- onClick: retry,
5633
- children: t("retry")
5634
- })
5635
- ]
6546
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PricingAssociationProvider, {
6547
+ view: {
6548
+ symbol: "¥",
6549
+ rate: 1
6550
+ },
6551
+ t,
6552
+ children: [
6553
+ header,
6554
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6555
+ className: UsageView_module_css_default["error"],
6556
+ children: t("loadFailed", { message: summaryState.message })
6557
+ }),
6558
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6559
+ type: "button",
6560
+ className: UsageView_module_css_default["button"],
6561
+ onClick: retry,
6562
+ children: t("retry")
6563
+ })
6564
+ ]
6565
+ })
5636
6566
  });
5637
6567
  const summary = summaryState.value;
5638
6568
  const view = currencyViewOf(summary);
5639
6569
  const { total } = summary;
5640
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6570
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5641
6571
  ref: rootRef,
5642
6572
  className: UsageView_module_css_default["root"],
5643
6573
  ...COMPOSER_OVERLAY,
5644
- children: [
5645
- header,
5646
- total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5647
- className: UsageView_module_css_default["empty"],
5648
- children: t("view.empty")
5649
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
5650
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5651
- className: UsageView_module_css_default["cards"],
5652
- children: [
5653
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
5654
- requests: total.requests,
5655
- failures: total.failures ?? 0,
5656
- failuresByCode: total.failuresByCode,
5657
- t
5658
- }),
5659
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5660
- label: t("stat.cost"),
5661
- value: formatCost(summary.totalCost, view)
5662
- }),
5663
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5664
- label: t("stat.totalTokens"),
5665
- value: formatTokens(totalTokens(total))
5666
- }),
5667
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5668
- label: t("stat.hitRate"),
5669
- value: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: total })
5670
- }),
5671
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5672
- label: t("view.ttft"),
5673
- value: ttftText
5674
- }),
5675
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
5676
- label: t("view.speed"),
5677
- value: `${speedText} tok/s`
6574
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PricingAssociationProvider, {
6575
+ resolutions: summary.modelResolutions,
6576
+ feedVersion: summary.feedVersion,
6577
+ view,
6578
+ t,
6579
+ children: [
6580
+ header,
6581
+ total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6582
+ className: UsageView_module_css_default["empty"],
6583
+ children: t("view.empty")
6584
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
6585
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6586
+ className: UsageView_module_css_default["cards"],
6587
+ children: [
6588
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
6589
+ requests: total.requests,
6590
+ failures: total.failures ?? 0,
6591
+ failuresByCode: total.failuresByCode,
6592
+ t
6593
+ }),
6594
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6595
+ label: t("stat.cost"),
6596
+ value: costsAvailable(summary.costState) ? formatCost(summary.totalCost, view) : "—"
6597
+ }),
6598
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6599
+ label: t("stat.totalTokens"),
6600
+ value: formatTokens(totalTokens(total))
6601
+ }),
6602
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6603
+ label: t("stat.hitRate"),
6604
+ value: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: total })
6605
+ }),
6606
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6607
+ label: t("view.ttft"),
6608
+ value: ttftText
6609
+ }),
6610
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
6611
+ label: t("view.speed"),
6612
+ value: `${speedText} tok/s`
6613
+ })
6614
+ ]
6615
+ }),
6616
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6617
+ className: UsageView_module_css_default["tokenStrip"],
6618
+ children: [
6619
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
6620
+ t("stat.input"),
6621
+ " ",
6622
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.inputTokens) })
6623
+ ] }),
6624
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
6625
+ t("stat.output"),
6626
+ " ",
6627
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.outputTokens) })
6628
+ ] }),
6629
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
6630
+ t("stat.cacheRead"),
6631
+ " ",
6632
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.cacheReadTokens) })
6633
+ ] }),
6634
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
6635
+ t("stat.cacheWrite"),
6636
+ " ",
6637
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.cacheWriteTokens) })
6638
+ ] })
6639
+ ]
6640
+ }),
6641
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingStatus, {
6642
+ costState: summary.costState,
6643
+ pricingUnavailableReason: summary.pricingUnavailableReason,
6644
+ associationStorageError: summary.associationStorageError,
6645
+ t
6646
+ }),
6647
+ costsAvailable(summary.costState) && summary.unpricedModels.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6648
+ className: UsageView_module_css_default["warning"],
6649
+ role: "status",
6650
+ children: t("unpriced.warning", {
6651
+ count: String(summary.unpricedModels.length),
6652
+ models: summary.unpricedModels.join(", "),
6653
+ zero: formatCost(0, view)
5678
6654
  })
5679
- ]
5680
- }),
5681
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5682
- className: UsageView_module_css_default["tokenStrip"],
5683
- children: [
5684
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
5685
- t("stat.input"),
5686
- " ",
5687
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.inputTokens) })
5688
- ] }),
5689
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
5690
- t("stat.output"),
5691
- " ",
5692
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.outputTokens) })
5693
- ] }),
5694
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
5695
- t("stat.cacheRead"),
5696
- " ",
5697
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.cacheReadTokens) })
5698
- ] }),
5699
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
5700
- t("stat.cacheWrite"),
5701
- " ",
5702
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(total.cacheWriteTokens) })
5703
- ] })
5704
- ]
5705
- }),
5706
- summary.unpricedModels.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5707
- className: UsageView_module_css_default["warning"],
5708
- role: "status",
5709
- children: t("unpriced.warning", {
5710
- count: String(summary.unpricedModels.length),
5711
- models: summary.unpricedModels.join(", "),
5712
- zero: formatCost(0, view)
5713
- })
5714
- }) : null,
5715
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5716
- className: UsageView_module_css_default["mid"],
5717
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
5718
- className: UsageView_module_css_default["chartCol"],
5719
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5720
- className: UsageView_module_css_default["chartHead"],
6655
+ }) : null,
6656
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6657
+ className: UsageView_module_css_default["mid"],
6658
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
6659
+ className: UsageView_module_css_default["chartCol"],
6660
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6661
+ className: UsageView_module_css_default["chartHead"],
6662
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
6663
+ className: UsageView_module_css_default["subtitle"],
6664
+ children: t("view.chart.title")
6665
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6666
+ className: UsageView_module_css_default["segmented"],
6667
+ role: "group",
6668
+ "aria-label": t("chart.mode.label"),
6669
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6670
+ type: "button",
6671
+ className: chartMode === "interval" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
6672
+ "aria-pressed": chartMode === "interval",
6673
+ onClick: () => setChartMode("interval"),
6674
+ children: t("chart.mode.interval")
6675
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6676
+ type: "button",
6677
+ className: chartMode === "cumulative" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
6678
+ "aria-pressed": chartMode === "cumulative",
6679
+ onClick: () => setChartMode("cumulative"),
6680
+ children: t("chart.mode.cumulative")
6681
+ })]
6682
+ })]
6683
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
6684
+ rows: summary.byDay,
6685
+ mode: chartMode,
6686
+ t,
6687
+ ...summary.requestSeries !== void 0 ? { requests: summary.requestSeries } : {},
6688
+ ...summary.byDay.length === 1 ? { hours: summary.byHour } : {}
6689
+ })]
6690
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
6691
+ className: UsageView_module_css_default["modelCol"],
5721
6692
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
5722
6693
  className: UsageView_module_css_default["subtitle"],
5723
- children: t("view.chart.title")
5724
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5725
- className: UsageView_module_css_default["segmented"],
5726
- role: "group",
5727
- "aria-label": t("chart.mode.label"),
5728
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5729
- type: "button",
5730
- className: chartMode === "interval" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
5731
- "aria-pressed": chartMode === "interval",
5732
- onClick: () => setChartMode("interval"),
5733
- children: t("chart.mode.interval")
5734
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5735
- type: "button",
5736
- className: chartMode === "cumulative" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
5737
- "aria-pressed": chartMode === "cumulative",
5738
- onClick: () => setChartMode("cumulative"),
5739
- children: t("chart.mode.cumulative")
5740
- })]
6694
+ children: t("byModel.title")
6695
+ }), summary.byModel.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6696
+ className: UsageView_module_css_default["tableWrap"],
6697
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
6698
+ className: UsageView_module_css_default["table"],
6699
+ "aria-label": t("byModel.title"),
6700
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
6701
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
6702
+ className: UsageView_module_css_default["modelHead"],
6703
+ children: t("filter.model")
6704
+ }),
6705
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
6706
+ "aria-label": t("stat.successFail"),
6707
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
6708
+ }),
6709
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
6710
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.output") }),
6711
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheRead") }),
6712
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheWrite") }),
6713
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.hitRate") }),
6714
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") })
6715
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: summary.byModel.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
6716
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6717
+ className: UsageView_module_css_default["modelCell"],
6718
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6719
+ className: UsageView_module_css_default.modelIdentity,
6720
+ children: [
6721
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6722
+ className: UsageView_module_css_default.modelName,
6723
+ children: row.model
6724
+ }),
6725
+ summary.unpricedModels.includes(row.model) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnpricedModelTag, {
6726
+ model: row.model,
6727
+ t
6728
+ }),
6729
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelAssociationBadge, {
6730
+ model: row.model,
6731
+ t
6732
+ })
6733
+ ]
6734
+ })
6735
+ }),
6736
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
6737
+ requests: row.totals.requests,
6738
+ failures: row.totals.failures ?? 0,
6739
+ failuresByCode: row.totals.failuresByCode,
6740
+ t
6741
+ }) }),
6742
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6743
+ className: row.totals.inputTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
6744
+ children: formatTokens(row.totals.inputTokens)
6745
+ }),
6746
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6747
+ className: row.totals.outputTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
6748
+ children: formatTokens(row.totals.outputTokens)
6749
+ }),
6750
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6751
+ className: row.totals.cacheReadTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
6752
+ children: formatTokens(row.totals.cacheReadTokens)
6753
+ }),
6754
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6755
+ className: row.totals.cacheWriteTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
6756
+ children: formatTokens(row.totals.cacheWriteTokens)
6757
+ }),
6758
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: row.totals }) }),
6759
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6760
+ className: UsageView_module_css_default["costCol"],
6761
+ children: costsAvailable(summary.costState) && !summary.unpricedModels.includes(row.model) ? formatCost(row.cost, view) : "—"
6762
+ })
6763
+ ] }, row.model)) })]
6764
+ })
6765
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6766
+ className: UsageView_module_css_default["muted"],
6767
+ children: t("chart.empty")
5741
6768
  })]
5742
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
5743
- rows: summary.byDay,
5744
- mode: chartMode,
5745
- t,
5746
- ...summary.requestSeries !== void 0 ? { requests: summary.requestSeries } : {},
5747
- ...summary.byDay.length === 1 ? { hours: summary.byHour } : {}
5748
6769
  })]
5749
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
5750
- className: UsageView_module_css_default["modelCol"],
6770
+ })
6771
+ ] }),
6772
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
6773
+ className: UsageView_module_css_default["subagents"],
6774
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6775
+ className: UsageView_module_css_default["subagentsHead"],
5751
6776
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
5752
6777
  className: UsageView_module_css_default["subtitle"],
5753
- children: t("byModel.title")
5754
- }), summary.byModel.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5755
- className: UsageView_module_css_default["tableWrap"],
5756
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
5757
- className: UsageView_module_css_default["table"],
5758
- "aria-label": t("byModel.title"),
5759
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
5760
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
5761
- className: UsageView_module_css_default["modelHead"],
5762
- children: t("filter.model")
5763
- }),
5764
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
5765
- "aria-label": t("stat.successFail"),
5766
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
5767
- }),
5768
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
5769
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.output") }),
5770
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheRead") }),
5771
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheWrite") }),
5772
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.hitRate") }),
5773
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") })
5774
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: summary.byModel.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
5775
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
6778
+ children: t("view.subagents.title", { count: String(children.length) })
6779
+ }), (() => {
6780
+ if (backParent === void 0) return null;
6781
+ const parentSummary = byId[backParent];
6782
+ if (parentSummary === void 0) return null;
6783
+ const parentId = backParent;
6784
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6785
+ type: "button",
6786
+ className: UsageView_module_css_default["back"],
6787
+ onClick: () => setFocusId(parentId),
6788
+ children: t("view.back", { title: parentSummary.displayTitle ?? parentId })
6789
+ });
6790
+ })()]
6791
+ }), children.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6792
+ className: UsageView_module_css_default["muted"],
6793
+ children: t("view.subagents.none")
6794
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6795
+ className: UsageView_module_css_default["tableWrap"],
6796
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
6797
+ className: UsageView_module_css_default["table"],
6798
+ "aria-label": t("view.subagents.title", { count: String(children.length) }),
6799
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
6800
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
6801
+ className: UsageView_module_css_default["modelHead"],
6802
+ children: t("view.subagents.titleCol")
6803
+ }),
6804
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.requests") }),
6805
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.totalTokens") }),
6806
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") }),
6807
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.hitRate") }),
6808
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("view.ttft") }),
6809
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("view.speed") })
6810
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: children.map((id) => {
6811
+ const child = byId[id];
6812
+ const row = summary.children?.[id];
6813
+ const childStats = aggregateProjections([byId[id]?.projectionValues?.sessionStats]);
6814
+ const nestedCount = directSubagentIds(byId, id, childIndex).length;
6815
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
6816
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
5776
6817
  className: UsageView_module_css_default["modelCell"],
5777
- children: row.model
5778
- }),
5779
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
5780
- requests: row.totals.requests,
5781
- failures: row.totals.failures ?? 0,
5782
- failuresByCode: row.totals.failuresByCode,
5783
- t
5784
- }) }),
5785
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5786
- className: row.totals.inputTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
5787
- children: formatTokens(row.totals.inputTokens)
5788
- }),
5789
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5790
- className: row.totals.outputTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
5791
- children: formatTokens(row.totals.outputTokens)
5792
- }),
5793
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5794
- className: row.totals.cacheReadTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
5795
- children: formatTokens(row.totals.cacheReadTokens)
5796
- }),
5797
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5798
- className: row.totals.cacheWriteTokens === 0 ? UsageView_module_css_default["zeroDim"] : void 0,
5799
- children: formatTokens(row.totals.cacheWriteTokens)
6818
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6819
+ type: "button",
6820
+ className: UsageView_module_css_default["childLink"],
6821
+ onClick: () => setFocusId(id),
6822
+ children: child?.displayTitle ?? id
6823
+ }), nestedCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6824
+ className: UsageView_module_css_default["nestedBadge"],
6825
+ "aria-label": t("view.subagents.nested", { count: String(nestedCount) }),
6826
+ children: [
6827
+ "(",
6828
+ nestedCount,
6829
+ ")"
6830
+ ]
6831
+ }) : null]
5800
6832
  }),
5801
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: row.totals }) }),
6833
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row?.total.requests.toLocaleString() ?? "—" }),
6834
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row !== void 0 ? formatTokens(totalTokens(row.total)) : "—" }),
5802
6835
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5803
6836
  className: UsageView_module_css_default["costCol"],
5804
- children: formatCost(row.cost, view)
5805
- })
5806
- ] }, row.model)) })]
5807
- })
5808
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5809
- className: UsageView_module_css_default["muted"],
5810
- children: t("chart.empty")
5811
- })]
6837
+ children: row !== void 0 && costsAvailable(summary.costState) && costsAvailable(row.costState) ? formatCost(row.totalCost, view) : "—"
6838
+ }),
6839
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: row.total }) : "—" }),
6840
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: childStats !== void 0 && childStats.ttftSteps > 0 ? formatTtft(childStats.ttftMs / childStats.ttftSteps) : "—" }),
6841
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: childStats !== void 0 && childStats.decodeMs > 0 ? `${formatSpeed(childStats.decodeTokens / (childStats.decodeMs / 1e3))} tok/s` : "—" })
6842
+ ] }, id);
6843
+ }) })]
6844
+ })
5812
6845
  })]
6846
+ }),
6847
+ (total.requests > 0 || (total.failures ?? 0) > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6848
+ className: UsageView_module_css_default["note"],
6849
+ children: t("view.note")
5813
6850
  })
5814
- ] }),
5815
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
5816
- className: UsageView_module_css_default["subagents"],
5817
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5818
- className: UsageView_module_css_default["subagentsHead"],
5819
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
5820
- className: UsageView_module_css_default["subtitle"],
5821
- children: t("view.subagents.title", { count: String(children.length) })
5822
- }), (() => {
5823
- if (backParent === void 0) return null;
5824
- const parentSummary = byId[backParent];
5825
- if (parentSummary === void 0) return null;
5826
- const parentId = backParent;
5827
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5828
- type: "button",
5829
- className: UsageView_module_css_default["back"],
5830
- onClick: () => setFocusId(parentId),
5831
- children: t("view.back", { title: parentSummary.displayTitle ?? parentId })
5832
- });
5833
- })()]
5834
- }), children.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5835
- className: UsageView_module_css_default["muted"],
5836
- children: t("view.subagents.none")
5837
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5838
- className: UsageView_module_css_default["tableWrap"],
5839
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
5840
- className: UsageView_module_css_default["table"],
5841
- "aria-label": t("view.subagents.title", { count: String(children.length) }),
5842
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
5843
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
5844
- className: UsageView_module_css_default["modelHead"],
5845
- children: t("view.subagents.titleCol")
5846
- }),
5847
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.requests") }),
5848
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.totalTokens") }),
5849
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") }),
5850
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.hitRate") }),
5851
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("view.ttft") }),
5852
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("view.speed") })
5853
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: children.map((id) => {
5854
- const child = byId[id];
5855
- const row = summary.children?.[id];
5856
- const childStats = aggregateProjections([byId[id]?.projectionValues?.sessionStats]);
5857
- const nestedCount = directSubagentIds(byId, id, childIndex).length;
5858
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
5859
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
5860
- className: UsageView_module_css_default["modelCell"],
5861
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5862
- type: "button",
5863
- className: UsageView_module_css_default["childLink"],
5864
- onClick: () => setFocusId(id),
5865
- children: child?.displayTitle ?? id
5866
- }), nestedCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5867
- className: UsageView_module_css_default["nestedBadge"],
5868
- "aria-label": t("view.subagents.nested", { count: String(nestedCount) }),
5869
- children: [
5870
- "(",
5871
- nestedCount,
5872
- ")"
5873
- ]
5874
- }) : null]
5875
- }),
5876
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row?.total.requests.toLocaleString() ?? "—" }),
5877
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row !== void 0 ? formatTokens(totalTokens(row.total)) : "—" }),
5878
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
5879
- className: UsageView_module_css_default["costCol"],
5880
- children: row !== void 0 ? formatCost(row.totalCost, view) : "—"
5881
- }),
5882
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitRateText, { totals: row.total }) : "—" }),
5883
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: childStats !== void 0 && childStats.ttftSteps > 0 ? formatTtft(childStats.ttftMs / childStats.ttftSteps) : "—" }),
5884
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: childStats !== void 0 && childStats.decodeMs > 0 ? `${formatSpeed(childStats.decodeTokens / (childStats.decodeMs / 1e3))} tok/s` : "—" })
5885
- ] }, id);
5886
- }) })]
5887
- })
5888
- })]
5889
- }),
5890
- (total.requests > 0 || (total.failures ?? 0) > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5891
- className: UsageView_module_css_default["note"],
5892
- children: t("view.note")
5893
- })
5894
- ]
6851
+ ]
6852
+ })
5895
6853
  });
5896
6854
  }
5897
6855
  //#endregion
@@ -5909,6 +6867,56 @@ window.__ModuleLoader__.load({
5909
6867
  const NS = "token-usage";
5910
6868
  /** Simplified Chinese dictionary (the key-set source of truth). */
5911
6869
  const zh = {
6870
+ "association.manage": "模型别名关联",
6871
+ "association.title": "模型别名关联",
6872
+ "association.unpricedTitle": "模型未定价",
6873
+ "association.close": "关闭模型关联",
6874
+ "association.choose": "关联现有模型",
6875
+ "association.issue": "增加模型定价",
6876
+ "association.tooltip": "此模型含手动关联:[{models}]",
6877
+ "association.allHint": "模型别名与模型的本地映射",
6878
+ "association.empty": "无数据",
6879
+ "association.details": "查看/修改",
6880
+ "association.state.active": "手动关联正在生效。",
6881
+ "association.state.automatic-takeover": "已由自动识别接管,保存的关联未生效。",
6882
+ "association.state.target-missing": "关联目标已失效,可重新选择或撤销。",
6883
+ "association.state.pricing-unavailable": "定价表不可用,关联暂未生效。",
6884
+ "association.automaticTarget": "自动目标:{model}。",
6885
+ "association.targetDiffers": "与保存的目标 {model} 不同。",
6886
+ "association.reactivate": "以后自动识别失败且原目标仍有效时,保存的关联会重新生效;可撤销以停止此行为。",
6887
+ "association.automaticOnly": "该名称已有唯一自动识别结果,不能用手动关联覆盖。",
6888
+ "association.search": "搜索模型",
6889
+ "association.searchHint": "搜索模型 ID",
6890
+ "association.candidates": "定价模型候选",
6891
+ "association.noResults": "未找到模型,请调整搜索词",
6892
+ "association.target": "所选目标:{model}",
6893
+ "association.preview": "查看定价",
6894
+ "association.impact": "绑定后,此别名的历史及后续用量将按所选模型计费。",
6895
+ "association.save": "绑定模型",
6896
+ "association.saving": "正在保存…",
6897
+ "association.saved": "关联已保存,正在刷新用量与费用。",
6898
+ "association.revoke": "撤销关联",
6899
+ "association.confirmRevoke": "确认撤销",
6900
+ "association.revokeImpact": "撤销将重新计算全部历史与后续用量;仍有自动匹配时继续定价,否则恢复未定价。",
6901
+ "association.cancel": "取消",
6902
+ "association.revoked": "关联已撤销,正在刷新用量与费用。",
6903
+ "association.loadFailed": "无法加载模型关联与定价候选,请重试。",
6904
+ "association.candidatesUnavailable": "定价候选加载失败,请重试;已保存的关联仍可查看和撤销。",
6905
+ "association.writeFailed": "操作失败,尚未确认生效;请刷新真实状态后重试。",
6906
+ "association.conflict": "关联或数据目录已变化,已读取当前状态;请核对后重新选择并提交。",
6907
+ "association.migrating": "数据目录正在迁移,暂时不能修改关联。",
6908
+ "association.targetUnavailable": "所选目标已不在当前定价表中,请刷新并重新选择。",
6909
+ "association.refresh": "刷新当前状态",
6910
+ "pricing.unavailable": "定价表不可用,费用暂不可计算;用量统计仍可查看。",
6911
+ "pricing.reason.missing": "本机尚无定价镜像,请重试定价同步。",
6912
+ "pricing.reason.unreadable": "本机定价镜像无法读取。",
6913
+ "pricing.reason.invalid-json": "本机定价镜像不是有效 JSON。",
6914
+ "pricing.reason.invalid-feed": "本机定价镜像未通过格式、模型 ID 或别名正则校验。",
6915
+ "pricing.historyIncomplete": "历史源记录不完整,无法可靠重算费用;已保留可用用量统计。",
6916
+ "pricing.associationStorageUnavailable": "本地模型关联文件无法读取或格式损坏,手动关联暂不生效;自动识别仍可使用。请先检查数据目录中的 pricing-associations.json。",
6917
+ "pricing.identificationDetails": "查看模型识别详情",
6918
+ "pricing.ambiguous": "模型识别存在歧义:{models}",
6919
+ "pricing.unmatched": "未找到对应定价模型",
5912
6920
  "nav.label": "Token 用量",
5913
6921
  "filter.quickRange": "快捷区间",
5914
6922
  "filter.custom": "自定义",
@@ -6019,6 +7027,13 @@ window.__ModuleLoader__.load({
6019
7027
  "card.regionDefault": "默认(国内 Gitee)",
6020
7028
  "card.region.domestic": "国内(Gitee)",
6021
7029
  "card.region.overseas": "全球(GitHub)",
7030
+ "card.pricingSync.button": "同步定价表",
7031
+ "card.pricingSync.running": "同步中…",
7032
+ "card.pricingSync.done": "定价表已同步:版本 {version},共 {models} 个模型。",
7033
+ "card.pricingSync.failed": "定价表同步失败,已保留原有定价表,请重试。",
7034
+ "card.pricingSync.changed": "定价区域或数据目录已变更,请重新同步。",
7035
+ "card.pricingSync.migrating": "数据目录正在迁移,请稍后再同步。",
7036
+ "card.pricingSync.unsaved": "请先保存或放弃设置修改,再同步定价表。",
6022
7037
  "card.hint": "切换到「全球」后从 GitHub 镜像拉取定价表,费用按美元展示(RMB ÷ 汇率);保存后立即重新同步,失败沿用旧镜像。",
6023
7038
  "card.overridden": "已覆盖默认值",
6024
7039
  "card.save": "保存",
@@ -6092,6 +7107,56 @@ window.__ModuleLoader__.load({
6092
7107
  };
6093
7108
  /** English dictionary (same key set). */
6094
7109
  const en = {
7110
+ "association.manage": "Model alias associations",
7111
+ "association.title": "Model alias associations",
7112
+ "association.unpricedTitle": "Unpriced model",
7113
+ "association.close": "Close model associations",
7114
+ "association.choose": "Associate an existing model",
7115
+ "association.issue": "Add model pricing",
7116
+ "association.tooltip": "This model includes manual associations: [{models}]",
7117
+ "association.allHint": "Local mappings between model aliases and models",
7118
+ "association.empty": "No data",
7119
+ "association.details": "View / edit",
7120
+ "association.state.active": "Manual association is active.",
7121
+ "association.state.automatic-takeover": "Automatic identification takes priority; the saved choice is inactive.",
7122
+ "association.state.target-missing": "The target is no longer available. Choose another model or revoke.",
7123
+ "association.state.pricing-unavailable": "Pricing is unavailable; the association is inactive.",
7124
+ "association.automaticTarget": "Automatic target: {model}.",
7125
+ "association.targetDiffers": "It differs from the saved target {model}.",
7126
+ "association.reactivate": "The saved choice will reactivate if automatic identification fails and the original target is still valid. Revoke to stop this behavior.",
7127
+ "association.automaticOnly": "This name has a unique automatic match. Manual associations cannot override it.",
7128
+ "association.search": "Search models",
7129
+ "association.searchHint": "Search model IDs",
7130
+ "association.candidates": "Pricing model candidates",
7131
+ "association.noResults": "No models found. Try another search.",
7132
+ "association.target": "Selected target: {model}",
7133
+ "association.preview": "View pricing",
7134
+ "association.impact": "Past and future usage of this alias will use the selected model’s pricing.",
7135
+ "association.save": "Bind model",
7136
+ "association.saving": "Saving…",
7137
+ "association.saved": "Association saved. Refreshing usage and costs.",
7138
+ "association.revoke": "Revoke association",
7139
+ "association.confirmRevoke": "Confirm revocation",
7140
+ "association.revokeImpact": "Recalculates all past and future usage. Automatic matches remain priced; otherwise the name becomes unpriced.",
7141
+ "association.cancel": "Cancel",
7142
+ "association.revoked": "Association revoked. Refreshing usage and costs.",
7143
+ "association.loadFailed": "Could not load associations and pricing candidates. Please retry.",
7144
+ "association.candidatesUnavailable": "Pricing candidates could not be loaded. Retry; saved associations can still be viewed and revoked.",
7145
+ "association.writeFailed": "The operation was not confirmed. Refresh the actual state before retrying.",
7146
+ "association.conflict": "Associations or the data directory changed. Current state was retrieved; review, choose again and submit.",
7147
+ "association.migrating": "The data directory is migrating. Associations cannot be changed yet.",
7148
+ "association.targetUnavailable": "The selected target is no longer in the current pricing table. Refresh and choose again.",
7149
+ "association.refresh": "Refresh current state",
7150
+ "pricing.unavailable": "Pricing is unavailable. Costs cannot be calculated; usage remains available.",
7151
+ "pricing.reason.missing": "No local pricing mirror exists yet. Retry pricing sync.",
7152
+ "pricing.reason.unreadable": "The local pricing mirror cannot be read.",
7153
+ "pricing.reason.invalid-json": "The local pricing mirror is not valid JSON.",
7154
+ "pricing.reason.invalid-feed": "The local mirror failed schema, model ID, or alias pattern validation.",
7155
+ "pricing.historyIncomplete": "Historical source records are incomplete. Reliable costs cannot be recalculated; available usage is retained.",
7156
+ "pricing.associationStorageUnavailable": "Local model associations are unreadable or malformed. Manual choices are inactive; automatic identification remains available. Check pricing-associations.json in the data directory.",
7157
+ "pricing.identificationDetails": "Model identification details",
7158
+ "pricing.ambiguous": "Ambiguous model identification: {models}",
7159
+ "pricing.unmatched": "No matching pricing model",
6095
7160
  "nav.label": "Token Usage",
6096
7161
  "filter.quickRange": "Quick range",
6097
7162
  "filter.custom": "Custom",
@@ -6202,6 +7267,13 @@ window.__ModuleLoader__.load({
6202
7267
  "card.regionDefault": "Default (Gitee)",
6203
7268
  "card.region.domestic": "CN (Gitee)",
6204
7269
  "card.region.overseas": "Global (GitHub)",
7270
+ "card.pricingSync.button": "Sync pricing table",
7271
+ "card.pricingSync.running": "Syncing…",
7272
+ "card.pricingSync.done": "Pricing synced: version {version}, {models} models.",
7273
+ "card.pricingSync.failed": "Pricing sync failed. The previous table is retained; try again.",
7274
+ "card.pricingSync.changed": "The pricing region or data directory changed. Sync again.",
7275
+ "card.pricingSync.migrating": "The data directory is moving. Try syncing later.",
7276
+ "card.pricingSync.unsaved": "Save or discard your settings changes before syncing pricing.",
6205
7277
  "card.hint": "Switching to Global pulls the pricing table from the GitHub mirror and shows costs in USD (RMB ÷ rate); saving re-syncs immediately, falling back to the previous mirror on failure.",
6206
7278
  "card.overridden": "Overriding the default",
6207
7279
  "card.save": "Save",