@kenz1117/dsh-ui-usage-billing 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -24,7 +24,7 @@ window.__ModuleLoader__.load({
24
24
  }
25
25
  //#endregion
26
26
  //#region \0dsh-css:/Users/ken/deepseek-harness/packages/client/ui-usage-billing/src/client/UsageBilling.module.css.mjs
27
- const css = ".VWh0dG_railButton{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);width:36px;height:36px;color:var(--dsw-static-blue-500);cursor:pointer;border-radius:10px;justify-content:center;align-items:center;padding:0;transition:background-color .14s,border-color .14s,color .14s;display:flex}.VWh0dG_railButton:hover,.VWh0dG_railButton:focus-visible{background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l3);color:var(--dsw-static-blue-400);outline:none}.VWh0dG_railButton svg{stroke-width:2px;width:18px;height:18px}.VWh0dG_trigger{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);width:100%;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:12px;padding:10px 14px;transition:border-color .14s,background-color .14s;display:flex}.VWh0dG_trigger:hover,.VWh0dG_trigger:focus-visible{border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-interactive-bg-hover);outline:none}.VWh0dG_triggerIcon{width:16px;height:16px;color:var(--dsw-alias-label-tertiary);flex:none;justify-content:center;align-items:center;display:inline-flex}.VWh0dG_triggerIcon svg{stroke-width:1.8px;width:15px;height:15px}.VWh0dG_triggerToday,.VWh0dG_triggerMonth{align-items:baseline;gap:4px;min-width:0;display:flex}.VWh0dG_triggerDivider{background:var(--dsw-alias-border-l1);align-self:stretch;width:1px}.VWh0dG_triggerAmount{color:var(--dsw-alias-label-primary);letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;font-size:17px;font-weight:600;line-height:22px}.VWh0dG_triggerAmountSub{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px;font-weight:600;line-height:18px}.VWh0dG_triggerMeta{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-size:10.5px;line-height:14px}.VWh0dG_dashboardModal{width:min(760px,100vw - 48px);max-height:min(760px,88vh)}.VWh0dG_dashboard{flex-direction:column;width:100%;max-height:min(760px,88vh);display:flex}.VWh0dG_dashboardHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:flex-start;gap:12px;padding:20px 24px 14px;display:flex}.VWh0dG_dashboardTitle{color:var(--dsw-alias-label-primary);margin:0;font-size:17px;font-weight:600;line-height:24px}.VWh0dG_dashboardSubtitle{color:var(--dsw-alias-label-caption);margin:3px 0 0;font-size:12px;line-height:17px}.VWh0dG_closeButton{width:30px;height:30px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:8px;flex:none;justify-content:center;align-items:center;transition:background-color .14s;display:inline-flex}.VWh0dG_closeButton:hover{background:var(--dsw-alias-interactive-bg-hover)}.VWh0dG_closeButton svg{stroke-width:2px;width:16px;height:16px}.VWh0dG_dashboardBody{flex-direction:column;gap:14px;padding:16px 24px 24px;display:flex;overflow-y:auto}.VWh0dG_hero{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:16px;justify-content:space-between;align-items:center;gap:24px;padding:20px 24px;display:flex}.VWh0dG_heroMain{flex-direction:column;gap:4px;min-width:0;display:flex}.VWh0dG_heroLabel{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_heroValue{letter-spacing:-.02em;color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:40px;font-weight:600;line-height:48px}.VWh0dG_heroMeta{color:var(--dsw-alias-label-caption);white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_heroSide{flex-direction:column;flex:none;gap:10px;display:flex}.VWh0dG_heroSideItem{align-items:baseline;gap:8px;display:flex}.VWh0dG_heroSideLabel{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_heroSideValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:16px;font-weight:600;line-height:22px}.VWh0dG_delta{align-items:center;gap:2px;margin-left:4px;font-size:11px;font-weight:600;line-height:17px;display:inline-flex}.VWh0dG_deltaUp{color:var(--dsw-static-green-500)}.VWh0dG_deltaDown{color:var(--dsw-static-red-500)}.VWh0dG_kpiGrid{grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;display:grid}.VWh0dG_kpiTile{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:14px;flex-direction:column;gap:3px;padding:14px 15px;transition:border-color .14s,background-color .14s;display:flex}.VWh0dG_kpiTile:hover{border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-interactive-bg-hover)}.VWh0dG_kpiLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:15px}.VWh0dG_kpiValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:21px;font-weight:600;line-height:27px}.VWh0dG_kpiGreen{color:var(--dsw-static-green-500)}.VWh0dG_kpiDetail{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;font-size:11px;line-height:15px;overflow:hidden}.VWh0dG_panel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:16px;flex-direction:column;gap:10px;padding:16px 18px;display:flex}.VWh0dG_panelHead{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.VWh0dG_panelTitle{color:var(--dsw-alias-label-primary);margin:0;font-size:14px;font-weight:600;line-height:20px}.VWh0dG_panelHint{color:var(--dsw-alias-label-caption);white-space:nowrap;font-size:11px;line-height:16px}.VWh0dG_rangeToggle{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:8px;gap:2px;padding:2px;display:inline-flex}.VWh0dG_rangeButton{color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:2px 8px;font-size:11px;line-height:16px;transition:background-color .14s,color .14s}.VWh0dG_rangeButtonActive{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);font-weight:600}.VWh0dG_budget{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:14px;flex-direction:column;gap:8px;padding:12px 16px;display:flex}.VWh0dG_budgetHead{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.VWh0dG_budgetLabel{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:17px}.VWh0dG_budgetValue{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_budgetControls{align-items:center;gap:8px;min-width:0;display:inline-flex}.VWh0dG_budgetInputWrap{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:6px;align-items:center;gap:2px;padding:2px 6px;display:inline-flex}.VWh0dG_budgetInputWrap:focus-within{border-color:var(--dsw-alias-border-l3)}.VWh0dG_budgetUnit{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.VWh0dG_budgetInput{width:64px;color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;text-align:right;background:0 0;border:none;padding:0;font-size:12px;line-height:16px}.VWh0dG_budgetInput:focus-visible{outline:none}.VWh0dG_switch{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);cursor:pointer;border-radius:999px;flex:none;width:30px;height:17px;padding:0;transition:background-color .16s,border-color .16s;position:relative}.VWh0dG_switchOn{border-color:var(--dsw-static-blue-500);background:var(--dsw-static-blue-500)}.VWh0dG_switchKnob{background:var(--dsw-static-neutral-bluish-00);border-radius:50%;width:11px;height:11px;transition:transform .16s;position:absolute;top:2px;left:2px}.VWh0dG_switchOn .VWh0dG_switchKnob{transform:translate(13px)}.VWh0dG_budgetTrack{background:var(--dsw-alias-bg-module-platform);border-radius:999px;height:6px;overflow:hidden}.VWh0dG_budgetFill{background:var(--dsw-static-blue-500);border-radius:999px;height:100%;transition:width .2s}.VWh0dG_budgetFillOver{background:var(--dsw-static-red-500);animation:1.6s ease-in-out infinite VWh0dG_budgetOverPulse}@keyframes VWh0dG_budgetOverPulse{50%{opacity:.55}}.VWh0dG_chartWrap{width:100%;position:relative}.VWh0dG_chartSvg{width:100%;height:auto;display:block}.VWh0dG_chartEmpty{height:140px;color:var(--dsw-alias-label-caption);justify-content:center;align-items:center;font-size:13px;display:flex}.VWh0dG_emptyRow{text-align:center;color:var(--dsw-alias-label-caption);padding:28px 0;font-size:13px}.VWh0dG_chartGrid{stroke:var(--dsw-alias-border-l1);stroke-width:1px}.VWh0dG_chartAxisLabel{fill:var(--dsw-alias-label-tertiary);font-size:10px}.VWh0dG_chartBar{fill:var(--dsw-static-blue-500);opacity:.35}.VWh0dG_chartBar:hover{opacity:.6}.VWh0dG_chartStack{stroke:var(--dsw-alias-bg-layer-1);stroke-width:.75px}.VWh0dG_chartStack:hover{opacity:.85}.VWh0dG_chartLine{stroke:var(--dsw-static-blue-500);stroke-width:2px;stroke-linecap:round;stroke-linejoin:round}.VWh0dG_chartCrosshair{stroke:var(--dsw-alias-label-dimmed);stroke-width:1px;stroke-dasharray:3 3}.VWh0dG_chartDot{fill:var(--dsw-static-neutral-bluish-00);stroke:var(--dsw-static-blue-500);stroke-width:2.5px}.VWh0dG_chartTooltip{pointer-events:none;z-index:2;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);box-shadow:var(--dsw-shadow-lv2);white-space:nowrap;border-radius:10px;padding:8px 10px;position:absolute;transform:translate(-50%,calc(-100% - 10px))}.VWh0dG_chartTooltipDate{color:var(--dsw-alias-label-primary);margin-bottom:3px;font-size:11px;font-weight:600}.VWh0dG_chartTooltipRow{color:var(--dsw-alias-label-secondary);align-items:center;gap:5px;font-size:11px;line-height:17px;display:flex}.VWh0dG_chartTooltipRow strong{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-weight:600}.VWh0dG_chartLegendLine{background:var(--dsw-static-blue-500);border-radius:2px;width:10px;height:3px;display:inline-block}.VWh0dG_chartLegendBar{background:var(--dsw-static-blue-500);opacity:.5;border-radius:2px;width:7px;height:7px;display:inline-block}.VWh0dG_chartTooltipSwatch{border-radius:3px;flex:none;width:8px;height:8px;display:inline-block}.VWh0dG_chartLegend{color:var(--dsw-alias-label-tertiary);justify-content:flex-end;gap:14px;margin-top:2px;font-size:11px;display:flex}.VWh0dG_chartLegend span{align-items:center;gap:5px;display:inline-flex}.VWh0dG_tableScroll{border:1px solid var(--dsw-alias-border-l1);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;overflow:auto}.VWh0dG_modelTable,.VWh0dG_pricingTable{border-collapse:collapse;width:100%;font-size:12.5px}.VWh0dG_modelTable th,.VWh0dG_modelTable td,.VWh0dG_pricingTable th,.VWh0dG_pricingTable td{border-bottom:1px solid var(--dsw-alias-border-l1);text-align:left;white-space:nowrap;padding:9px 12px}.VWh0dG_modelTable tbody tr:last-child td,.VWh0dG_pricingTable tbody tr:last-child td{border-bottom:0}.VWh0dG_modelTable thead th,.VWh0dG_pricingTable thead th{color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-module-platform);font-size:11px;font-weight:500}.VWh0dG_modelTable tbody tr,.VWh0dG_pricingTable tbody tr{transition:background-color .12s}.VWh0dG_modelTable tbody tr:hover,.VWh0dG_pricingTable tbody tr:hover{background:var(--dsw-alias-interactive-bg-hover)}.VWh0dG_numCol{text-align:right;font-variant-numeric:tabular-nums}.VWh0dG_costCol{color:var(--dsw-static-blue-500);font-weight:600}.VWh0dG_na{color:var(--dsw-alias-label-dimmed)}.VWh0dG_modelCell{align-items:center;gap:8px;display:inline-flex}.VWh0dG_modelDot{width:9px;height:9px;box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-alias-bg-layer-1) 60%, transparent);border-radius:50%;flex:none}.VWh0dG_modelName{color:var(--dsw-alias-label-primary);font-weight:500;line-height:16px;display:block}.VWh0dG_modelProvider{color:var(--dsw-alias-label-caption);font-size:10.5px;line-height:14px;display:block}.VWh0dG_pricingToggle{cursor:pointer;text-align:left;background:0 0;border:none;justify-content:space-between;align-items:center;gap:10px;width:100%;padding:0;display:flex}.VWh0dG_pricingToggle:hover .VWh0dG_panelTitle,.VWh0dG_pricingToggle:focus-visible .VWh0dG_panelTitle{color:var(--dsw-static-blue-500)}.VWh0dG_rateBadge{vertical-align:1px;white-space:nowrap;border-radius:999px;align-items:center;margin-left:6px;padding:1px 6px;font-size:10px;font-weight:500;line-height:14px;display:inline-flex}.VWh0dG_rateBadgeLive{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 10%, transparent)}.VWh0dG_rateBadgeBuiltin{color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-module-platform)}.VWh0dG_pricingToggleText{align-items:baseline;gap:10px;min-width:0;display:flex}.VWh0dG_pricingChevron{width:16px;height:16px;color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}.VWh0dG_pricingChevronOpen{transform:rotate(180deg)}.VWh0dG_bandPrice{align-items:baseline;gap:6px;display:inline-flex}.VWh0dG_bandPriceOff{color:var(--dsw-alias-label-caption)}.VWh0dG_bandPriceOff:before{content:\"/\";color:var(--dsw-alias-label-dimmed);margin-right:4px}.VWh0dG_bandTag{color:var(--dsw-alias-label-secondary);flex-direction:column;gap:1px;font-size:10.5px;line-height:14px;display:inline-flex}.VWh0dG_bandTagOff{color:var(--dsw-static-green-500);font-weight:600}.VWh0dG_flatTag{color:var(--dsw-alias-label-caption);font-size:10.5px;line-height:14px}.VWh0dG_healthDot{border-radius:50%;flex:none;width:8px;height:8px;display:inline-block}.VWh0dG_healthOk{background:var(--dsw-static-green-500);box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-static-green-500) 18%, transparent)}.VWh0dG_healthBad{background:var(--dsw-static-red-500);box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-static-red-500) 18%, transparent)}.VWh0dG_healthIdle{background:var(--dsw-static-neutral-bluish-400)}.VWh0dG_dashboardRight{align-items:center;gap:8px;min-width:0;display:flex}.VWh0dG_healthBadge{white-space:nowrap;border-radius:999px;align-items:center;gap:6px;padding:3px 9px;font-size:11px;line-height:16px;display:inline-flex}.VWh0dG_healthBadgeOk{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 10%, transparent)}.VWh0dG_healthBadgeBad{color:var(--dsw-static-red-500);background:color-mix(in srgb, var(--dsw-static-red-500) 10%, transparent)}.VWh0dG_planTag{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 12%, transparent);border-radius:999px;align-items:center;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px;display:inline-flex}.VWh0dG_uncataloguedTag{vertical-align:1px;color:var(--dsw-static-amber-500);background:color-mix(in srgb, var(--dsw-static-amber-500) 12%, transparent);border-radius:999px;margin-left:6px;padding:0 6px;font-size:10px;font-weight:600;line-height:16px;display:inline-block}.VWh0dG_balanceCell{flex-direction:column;align-items:flex-end;gap:2px;display:inline-flex}.VWh0dG_balanceDays{color:var(--dsw-alias-label-caption);white-space:nowrap;font-size:10.5px;line-height:14px}.VWh0dG_balanceDaysLow{color:var(--dsw-static-red-500);font-weight:600}body[data-zine-mode] .VWh0dG_trigger,body[data-zine-mode] .VWh0dG_railButton{display:none}body[data-zine-mode] .VWh0dG_dashboardHead{background:#000;border-bottom:2px solid #e8ff00}body[data-zine-mode] .VWh0dG_headTitleRow{align-items:center;gap:8px;margin-top:4px;display:flex}body[data-zine-mode] .VWh0dG_dashboardTitle{color:#e8ff00;letter-spacing:.04em;text-transform:uppercase;text-shadow:0 0 8px #e8ff0066;font-weight:900}body[data-zine-mode] .VWh0dG_dashboardSubtitle{color:#c9d98a;letter-spacing:.08em;text-transform:uppercase;font-size:10px}body[data-zine-mode] .VWh0dG_closeButton{color:#0a0a05;background:#ff2d95;border:1.5px solid #ff2d95;border-radius:0;box-shadow:0 0 10px #ff2d9573}body[data-zine-mode] .VWh0dG_hero{background:#000;border:2.5px solid #e8ff00;border-radius:0;position:relative;box-shadow:0 0 0 1px #0009,0 0 24px #e8ff002e}body[data-zine-mode] .VWh0dG_heroLabel{color:#c9d98a;letter-spacing:.12em;text-transform:uppercase;font-size:10px;font-weight:900}body[data-zine-mode] .VWh0dG_heroValue{color:#e8ff00;letter-spacing:-.02em;text-shadow:0 0 12px #e8ff0073;font-size:38px;font-weight:900}body[data-zine-mode] .VWh0dG_heroMeta{color:#c9d98a;letter-spacing:.06em;text-transform:uppercase;font-size:10.5px}body[data-zine-mode] .VWh0dG_heroSideLabel{color:#c9d98a;letter-spacing:.1em;text-transform:uppercase;font-size:10px;font-weight:900}body[data-zine-mode] .VWh0dG_heroSideValue{color:#e8ff00;text-shadow:0 0 6px #e8ff0059}body[data-zine-mode] .VWh0dG_delta{font-weight:900}body[data-zine-mode] .VWh0dG_deltaUp{color:#ff2d95}body[data-zine-mode] .VWh0dG_deltaDown{color:#c9d98a}body[data-zine-mode] .VWh0dG_panel{background:#000;border:2px solid #e8ff00;border-radius:0}body[data-zine-mode] .VWh0dG_trendPanel{position:relative}body[data-zine-mode] .VWh0dG_panelTitle{color:#e8ff00;letter-spacing:.06em;text-transform:uppercase;text-shadow:0 0 6px #e8ff0066;font-weight:900}body[data-zine-mode] .VWh0dG_panelHint{color:#c9d98a;letter-spacing:.08em;text-transform:uppercase;font-size:10px;font-weight:900}body[data-zine-mode] .VWh0dG_modelTableScroll{background:#000;border:1.5px solid #e8ff0080;border-radius:0}.VWh0dG_currencyToggle{border:1px solid var(--dsw-alias-border-muted,#3a4250);background:var(--dsw-alias-bg-layer-2,#232a33);border-radius:6px;align-items:center;gap:2px;margin-right:8px;padding:2px;display:inline-flex}.VWh0dG_currencyButton{color:var(--dsw-alias-text-secondary,#9aa5b1);cursor:pointer;background:0 0;border:0;border-radius:4px;padding:4px 7px;font-size:11px;font-weight:700;line-height:1}.VWh0dG_currencyButtonActive{background:var(--dsw-alias-accent-muted,#2f6fed);color:#fff}.VWh0dG_subscriptionGrid{grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px;margin-top:10px;display:grid}.VWh0dG_subscriptionCard{border:1px solid var(--dsw-alias-border-muted,#3a4250);background:var(--dsw-alias-bg-layer-2,#232a33);border-radius:8px;padding:10px 12px}.VWh0dG_subscriptionHead{align-items:baseline;gap:8px;margin-bottom:6px;display:flex}.VWh0dG_subscriptionName{font-size:13px;font-weight:700}.VWh0dG_subscriptionPlan{color:var(--dsw-alias-text-secondary,#9aa5b1);font-size:11px}.VWh0dG_subscriptionStatus{color:var(--dsw-alias-warning,#e0a63c);margin-bottom:6px;font-size:11px}.VWh0dG_subscriptionWindow{align-items:center;gap:8px;margin-top:6px;font-size:11px;display:flex}.VWh0dG_subscriptionWindowLabel{color:var(--dsw-alias-text-secondary,#9aa5b1);flex:0 0 44px}.VWh0dG_subscriptionTrack{background:var(--dsw-alias-bg-layer-3,#1a2028);border-radius:3px;flex:1;height:5px;overflow:hidden}.VWh0dG_subscriptionFill{background:var(--dsw-alias-accent,#3b82f6);border-radius:3px;height:100%;display:block}.VWh0dG_subscriptionPct{text-align:right;font-variant-numeric:tabular-nums;flex:none;min-width:52px}.VWh0dG_subscriptionReset{color:var(--dsw-alias-text-secondary,#9aa5b1);flex:none}.VWh0dG_providerGroupList{flex-direction:column;gap:10px;display:flex}.VWh0dG_providerGroup{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:12px;padding:12px 14px}.VWh0dG_providerGroupHead{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.VWh0dG_providerGroupTitle{align-items:center;gap:7px;min-width:0;display:inline-flex}.VWh0dG_providerGroupName{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:18px}.VWh0dG_providerGroupMeta{flex:none;align-items:center;gap:10px;display:inline-flex}.VWh0dG_providerGroupBadge{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 12%, transparent);border-radius:999px;align-items:center;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px;display:inline-flex}.VWh0dG_providerGroupBalance{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;align-items:baseline;gap:6px;font-size:12px;line-height:17px;display:inline-flex}.VWh0dG_providerGroupBalanceLabel{color:var(--dsw-alias-label-caption);font-size:11px;line-height:17px}.VWh0dG_roundsFlagBadge{color:#fff;background:#ef4444;border-radius:999px;margin-left:8px;padding:1px 7px;font-size:10px;font-weight:800}.VWh0dG_rounds{margin-top:10px}.VWh0dG_roundsBars{align-items:flex-end;gap:3px;height:110px;padding:4px 2px 0;display:flex;overflow-x:auto}.VWh0dG_roundsBarCol{flex-direction:column;flex:1 0 28px;justify-content:flex-end;align-items:stretch;height:100%;display:flex}.VWh0dG_roundsBarLabel{text-align:center;color:var(--dsw-alias-text-secondary,#9aa5b1);white-space:nowrap;text-overflow:ellipsis;max-width:100%;margin-bottom:2px;font-size:8px;line-height:1;overflow:hidden}.VWh0dG_roundsBarWrap{flex:1;align-items:flex-end;min-height:0;display:flex}.VWh0dG_roundsBar{background:var(--dsw-alias-accent,#3b82f6);border-radius:2px 2px 0 0;width:100%;min-height:2px;position:relative}.VWh0dG_roundsBarFlagged{outline-offset:1px;background:#ef4444;border-radius:2px 2px 0 0;outline:1.5px solid #ef4444;width:100%;min-height:2px;position:relative}.VWh0dG_roundsFlagMark{background:#ef4444;border-radius:50%;width:7px;height:7px;position:absolute;top:-3px;right:-3px;box-shadow:0 0 4px #ef4444}.VWh0dG_roundsAxis{color:var(--dsw-alias-text-secondary,#9aa5b1);justify-content:space-between;margin-top:6px;font-size:10px;display:flex}.VWh0dG_roundsEmpty{color:var(--dsw-alias-text-secondary,#9aa5b1);margin-top:10px;font-size:12px}.VWh0dG_heatmap{margin-top:10px}.VWh0dG_heatmapGrid{grid-template-columns:repeat(7,minmax(0,1fr));gap:8px;display:grid}.VWh0dG_heatmapCellEmpty{background:var(--dsw-alias-bg-layer-1);height:30px;color:var(--dsw-alias-label-dimmed,#6b7480);font-variant-numeric:tabular-nums;border-radius:8px;justify-content:center;align-items:center;font-size:11px;display:flex}.VWh0dG_heatmapCell{font-variant-numeric:tabular-nums;cursor:pointer;border:0;border-radius:8px;justify-content:center;align-items:center;height:30px;padding:0;font-size:11px;display:flex}.VWh0dG_heatmapCell[data-level=\"0\"],.VWh0dG_heatmapCell[data-level=\"1\"],.VWh0dG_heatmapCell[data-level=\"2\"]{color:var(--dsw-alias-label-primary)}.VWh0dG_heatmapCell[data-level=\"3\"],.VWh0dG_heatmapCell[data-level=\"4\"]{color:var(--dsw-static-neutral-bluish-00,#fff)}.VWh0dG_heatmapFooter{color:var(--dsw-alias-text-secondary,#9aa5b1);align-items:center;gap:8px;margin-top:10px;font-size:10px;display:flex}.VWh0dG_heatmapLegend{gap:3px;display:inline-flex}.VWh0dG_heatmapLegend i{border-radius:4px;width:14px;height:14px;display:block}.VWh0dG_heatmapHover{font-variant-numeric:tabular-nums;margin-left:auto}@media (width<=640px){.VWh0dG_kpiGrid{grid-template-columns:repeat(2,minmax(0,1fr))}.VWh0dG_hero{flex-direction:column;align-items:flex-start;gap:14px}.VWh0dG_heroSide{flex-direction:row;gap:20px}}";
27
+ const css = ".VWh0dG_railButton{border:1px solid color-mix(in srgb, var(--dsw-static-blue-500) 28%, var(--dsw-alias-border-l2));background:linear-gradient(135deg, color-mix(in srgb, var(--dsw-static-blue-500) 14%, var(--dsw-alias-bg-layer-1)), var(--dsw-alias-bg-layer-1));width:36px;height:36px;color:var(--dsw-static-blue-500);cursor:pointer;border-radius:10px;justify-content:center;align-items:center;padding:0;transition:border-color .16s,box-shadow .16s,transform .16s,color .16s;display:flex}.VWh0dG_railButton:hover,.VWh0dG_railButton:focus-visible{border-color:color-mix(in srgb, var(--dsw-static-blue-500) 48%, var(--dsw-alias-border-l2));box-shadow:0 4px 14px -6px color-mix(in srgb, var(--dsw-static-blue-500) 55%, transparent);color:var(--dsw-static-blue-400);outline:none;transform:translateY(-1px)}.VWh0dG_railButton svg{stroke-width:2px;width:18px;height:18px}.VWh0dG_trigger{border:1px solid color-mix(in srgb, var(--dsw-static-blue-500) 20%, var(--dsw-alias-border-l1));background:radial-gradient(130% 180% at 0% 0%, color-mix(in srgb, var(--dsw-static-blue-500) 12%, transparent), transparent 55%), radial-gradient(150% 200% at 100% 110%, color-mix(in srgb, var(--dsw-static-blue-400) 9%, transparent), transparent 60%), var(--dsw-alias-bg-layer-1);width:100%;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:12px;padding:10px 14px;transition:border-color .16s,box-shadow .16s,transform .16s;display:flex;position:relative;overflow:hidden}@supports (backdrop-filter:blur(1px)){.VWh0dG_trigger{background:radial-gradient(130% 180% at 0% 0%, color-mix(in srgb, var(--dsw-static-blue-500) 14%, transparent), transparent 55%), radial-gradient(150% 200% at 100% 110%, color-mix(in srgb, var(--dsw-static-blue-400) 10%, transparent), transparent 60%), color-mix(in srgb, var(--dsw-alias-bg-layer-1) 72%, transparent);backdrop-filter:blur(12px)}}.VWh0dG_trigger:hover,.VWh0dG_trigger:focus-visible{border-color:color-mix(in srgb, var(--dsw-static-blue-500) 42%, var(--dsw-alias-border-l1));box-shadow:0 8px 24px -10px color-mix(in srgb, var(--dsw-static-blue-500) 45%, transparent);outline:none;transform:translateY(-1px)}.VWh0dG_triggerIcon{background:linear-gradient(135deg, var(--dsw-static-blue-500), var(--dsw-static-blue-400));width:28px;height:28px;color:var(--dsw-static-neutral-bluish-00);box-shadow:0 2px 8px -2px color-mix(in srgb, var(--dsw-static-blue-500) 60%, transparent);border-radius:8px;flex:none;justify-content:center;align-items:center;display:inline-flex}.VWh0dG_triggerIcon svg{stroke-width:1.8px;width:15px;height:15px}.VWh0dG_triggerToday,.VWh0dG_triggerMonth{align-items:baseline;gap:4px;min-width:0;display:flex}.VWh0dG_triggerDivider{background:var(--dsw-alias-border-l1);align-self:stretch;width:1px}.VWh0dG_triggerAmount{color:var(--dsw-alias-label-primary);letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;font-size:18px;font-weight:600;line-height:22px}.VWh0dG_triggerAmountSub{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px;font-weight:600;line-height:18px}.VWh0dG_triggerMeta{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-size:10.5px;line-height:14px}.VWh0dG_triggerWrap{width:100%;display:block;position:relative}.VWh0dG_triggerPop{border:1px solid color-mix(in srgb, var(--dsw-static-blue-500) 22%, var(--dsw-alias-border-l1));background:radial-gradient(130% 180% at 0% 0%, color-mix(in srgb, var(--dsw-static-blue-500) 12%, transparent), transparent 55%), var(--dsw-alias-bg-layer-2);box-shadow:0 12px 32px -12px color-mix(in srgb, var(--dsw-alias-label-primary) 30%, transparent);opacity:0;pointer-events:none;z-index:10;border-radius:12px;flex-direction:column;gap:6px;padding:12px 14px;transition:opacity .16s,transform .16s;display:flex;position:absolute;bottom:calc(100% + 8px);left:0;right:0;transform:translateY(4px)}@supports (backdrop-filter:blur(1px)){.VWh0dG_triggerPop{background:radial-gradient(130% 180% at 0% 0%, color-mix(in srgb, var(--dsw-static-blue-500) 14%, transparent), transparent 55%), color-mix(in srgb, var(--dsw-alias-bg-layer-2) 82%, transparent);backdrop-filter:blur(14px)}}.VWh0dG_triggerWrap:hover .VWh0dG_triggerPop,.VWh0dG_triggerWrap:focus-within .VWh0dG_triggerPop{opacity:1;transform:translateY(0)}.VWh0dG_triggerPopRow{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.VWh0dG_triggerPopLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.VWh0dG_triggerPopValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:13px;font-weight:600;line-height:18px}.VWh0dG_triggerPopBars{border-top:1px solid var(--dsw-alias-border-l1);align-items:flex-end;gap:4px;height:22px;margin-top:4px;padding-top:8px;display:flex}.VWh0dG_triggerPopBar{background:linear-gradient(180deg, var(--dsw-static-blue-400), var(--dsw-static-blue-500));border-radius:2px;flex:1;transition:height .2s}.VWh0dG_dashboardModal{background:linear-gradient(var(--dsw-alias-bg-layer-2), var(--dsw-alias-bg-layer-2)) padding-box, linear-gradient(135deg, color-mix(in srgb, var(--dsw-static-blue-500) 55%, transparent), color-mix(in srgb, var(--dsw-static-blue-400) 22%, transparent) 45%, color-mix(in srgb, var(--dsw-static-blue-500) 38%, transparent)) border-box;width:min(760px,100vw - 48px);max-height:min(760px,88vh);box-shadow:var(--dsw-shadow-lv3), 0 24px 80px -24px color-mix(in srgb, var(--dsw-static-blue-500) 35%, transparent);border:1px solid #0000;animation:.18s ease-out VWh0dG_dashboardIn}@keyframes VWh0dG_dashboardIn{0%{opacity:0;transform:translateY(8px)scale(.98)}to{opacity:1;transform:none}}div[role=presentation]:has(>.dsh-billing-modal)>div[aria-hidden=true]:first-child{backdrop-filter:blur(8px)saturate(1.25)}.VWh0dG_dashboard{flex-direction:column;width:100%;max-height:min(760px,88vh);display:flex}.VWh0dG_dashboardHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:flex-start;gap:12px;padding:20px 24px 14px;display:flex}.VWh0dG_dashboardTitle{color:var(--dsw-alias-label-primary);margin:0;font-size:17px;font-weight:600;line-height:24px}.VWh0dG_dashboardSubtitle{color:var(--dsw-alias-label-caption);margin:3px 0 0;font-size:12px;line-height:17px}.VWh0dG_closeButton{width:30px;height:30px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:8px;flex:none;justify-content:center;align-items:center;transition:background-color .14s;display:inline-flex}.VWh0dG_closeButton:hover{background:var(--dsw-alias-interactive-bg-hover)}.VWh0dG_closeButton svg{stroke-width:2px;width:16px;height:16px}.VWh0dG_dashboardBody{flex-direction:column;gap:14px;padding:16px 24px 24px;display:flex;overflow-y:auto}.VWh0dG_tabNav{border-bottom:1px solid var(--dsw-alias-border-l1);align-items:center;gap:4px;padding:10px 24px;display:flex}.VWh0dG_tabButton{color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:999px;padding:5px 14px;font-size:12.5px;font-weight:500;line-height:18px;transition:background-color .16s,color .16s,box-shadow .16s}.VWh0dG_tabButton:hover,.VWh0dG_tabButton:focus-visible{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);outline:none}.VWh0dG_tabButtonActive,.VWh0dG_tabButtonActive:hover,.VWh0dG_tabButtonActive:focus-visible{background:linear-gradient(135deg, var(--dsw-static-blue-500), color-mix(in srgb, var(--dsw-static-blue-500) 72%, var(--dsw-static-blue-400)));color:var(--dsw-static-neutral-bluish-00);box-shadow:0 2px 10px -3px color-mix(in srgb, var(--dsw-static-blue-500) 55%, transparent);font-weight:600}.VWh0dG_tabPanel{flex-direction:column;gap:14px;animation:.14s ease-out VWh0dG_tabPanelIn;display:flex}@keyframes VWh0dG_tabPanelIn{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.VWh0dG_hero{border:1px solid color-mix(in srgb, var(--dsw-static-blue-500) 16%, var(--dsw-alias-border-l1));background:radial-gradient(90% 150% at 6% 0%, color-mix(in srgb, var(--dsw-static-blue-500) 10%, transparent), transparent 60%), radial-gradient(70% 130% at 96% 100%, color-mix(in srgb, var(--dsw-static-blue-400) 8%, transparent), transparent 55%), var(--dsw-alias-bg-layer-1);border-radius:16px;justify-content:space-between;align-items:center;gap:24px;padding:20px 24px;display:flex;position:relative;overflow:hidden}.VWh0dG_heroMain{flex-direction:column;gap:4px;min-width:0;display:flex}.VWh0dG_heroLabel{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_heroValue{letter-spacing:-.02em;font-variant-numeric:tabular-nums;white-space:nowrap;background:linear-gradient(120deg, var(--dsw-alias-label-primary) 25%, color-mix(in srgb, var(--dsw-static-blue-500) 85%, var(--dsw-alias-label-primary)));color:#0000;-webkit-text-fill-color:transparent;-webkit-background-clip:text;background-clip:text;font-size:44px;font-weight:600;line-height:52px}.VWh0dG_heroMeta{color:var(--dsw-alias-label-caption);white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_heroSide{border-left:1px solid var(--dsw-alias-border-l1);flex-direction:column;flex:none;gap:10px;padding-left:24px;display:flex}.VWh0dG_heroSideItem{align-items:baseline;gap:8px;display:flex}.VWh0dG_heroSideLabel{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_heroSideValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:16px;font-weight:600;line-height:22px}.VWh0dG_delta{align-items:center;gap:2px;margin-left:4px;font-size:11px;font-weight:600;line-height:17px;display:inline-flex}.VWh0dG_deltaUp{color:var(--dsw-static-green-500)}.VWh0dG_deltaDown{color:var(--dsw-static-red-500)}.VWh0dG_kpiGrid{grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;display:grid}.VWh0dG_kpiTile{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:14px;flex-direction:column;gap:3px;padding:14px 15px;transition:border-color .16s,background-color .16s,transform .16s,box-shadow .16s;display:flex;position:relative;overflow:hidden}.VWh0dG_kpiTile:before{content:\"\";background:linear-gradient(90deg, color-mix(in srgb, var(--dsw-static-blue-500) 70%, transparent), transparent);opacity:.7;height:2px;position:absolute;inset:0 0 auto}.VWh0dG_kpiTile:has(.VWh0dG_kpiGreen):before{background:linear-gradient(90deg, color-mix(in srgb, var(--dsw-static-green-500) 70%, transparent), transparent)}.VWh0dG_kpiTile:hover{border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-interactive-bg-hover);box-shadow:0 6px 16px -8px color-mix(in srgb, var(--dsw-alias-label-primary) 35%, transparent);transform:translateY(-1px)}.VWh0dG_kpiLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:15px}.VWh0dG_kpiValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:21px;font-weight:600;line-height:27px}.VWh0dG_kpiGreen{color:var(--dsw-static-green-500)}.VWh0dG_kpiDetail{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;font-size:11px;line-height:15px;overflow:hidden}.VWh0dG_panel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:16px;flex-direction:column;gap:10px;padding:16px 18px;display:flex}.VWh0dG_panelHead{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.VWh0dG_panelTitle{color:var(--dsw-alias-label-primary);margin:0;font-size:14px;font-weight:600;line-height:20px}.VWh0dG_panelHint{color:var(--dsw-alias-label-caption);white-space:nowrap;font-size:11px;line-height:16px}.VWh0dG_rangeToggle{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:8px;gap:2px;padding:2px;display:inline-flex}.VWh0dG_rangeButton{color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:2px 8px;font-size:11px;line-height:16px;transition:background-color .14s,color .14s}.VWh0dG_rangeButtonActive{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);font-weight:600}.VWh0dG_exportBar{justify-content:flex-end;align-items:center;gap:8px;display:flex}.VWh0dG_exportLabel{color:var(--dsw-alias-label-caption);font-size:11px;line-height:16px}.VWh0dG_exportButton{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);cursor:pointer;border-radius:999px;padding:4px 12px;font-size:11.5px;line-height:16px;transition:border-color .16s,color .16s,background-color .16s}.VWh0dG_exportButton:hover,.VWh0dG_exportButton:focus-visible{border-color:color-mix(in srgb, var(--dsw-static-blue-500) 40%, var(--dsw-alias-border-l1));color:var(--dsw-static-blue-500);outline:none}.VWh0dG_shareTrack{background:var(--dsw-alias-bg-module-platform);border-radius:999px;height:10px;display:flex;overflow:hidden}.VWh0dG_shareSeg{height:100%;transition:width .2s}.VWh0dG_shareSegPeak{background:linear-gradient(90deg, var(--dsw-static-blue-500), var(--dsw-static-blue-400))}.VWh0dG_shareSegOff{background:color-mix(in srgb, var(--dsw-static-blue-500) 30%, var(--dsw-alias-bg-module-platform))}.VWh0dG_shareSegUser{background:linear-gradient(90deg, var(--dsw-static-blue-500), var(--dsw-static-blue-400))}.VWh0dG_shareSegAssistant{background:linear-gradient(90deg, var(--dsw-static-green-500), color-mix(in srgb, var(--dsw-static-green-500) 70%, var(--dsw-static-blue-400)))}.VWh0dG_shareSegTool{background:color-mix(in srgb, var(--dsw-static-amber-500) 80%, var(--dsw-alias-bg-module-platform))}.VWh0dG_shareLegend{align-items:center;gap:16px;display:flex}.VWh0dG_shareItem{color:var(--dsw-alias-label-secondary);align-items:baseline;gap:6px;font-size:12px;line-height:17px;display:inline-flex}.VWh0dG_shareDot{border-radius:50%;flex:none;align-self:center;width:8px;height:8px}.VWh0dG_shareValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-weight:600}.VWh0dG_budget{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:14px;flex-direction:column;gap:8px;padding:12px 16px;display:flex}.VWh0dG_budgetHead{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.VWh0dG_budgetLabel{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:17px}.VWh0dG_budgetValue{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:12px;line-height:17px}.VWh0dG_budgetControls{align-items:center;gap:8px;min-width:0;display:inline-flex}.VWh0dG_budgetInputWrap{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:6px;align-items:center;gap:2px;padding:2px 6px;display:inline-flex}.VWh0dG_budgetInputWrap:focus-within{border-color:var(--dsw-alias-border-l3)}.VWh0dG_budgetUnit{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.VWh0dG_budgetInput{width:64px;color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;text-align:right;background:0 0;border:none;padding:0;font-size:12px;line-height:16px}.VWh0dG_budgetInput:focus-visible{outline:none}.VWh0dG_switch{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);cursor:pointer;border-radius:999px;flex:none;width:30px;height:17px;padding:0;transition:background-color .16s,border-color .16s;position:relative}.VWh0dG_switchOn{border-color:var(--dsw-static-blue-500);background:var(--dsw-static-blue-500)}.VWh0dG_switchKnob{background:var(--dsw-static-neutral-bluish-00);border-radius:50%;width:11px;height:11px;transition:transform .16s;position:absolute;top:2px;left:2px}.VWh0dG_switchOn .VWh0dG_switchKnob{transform:translate(13px)}.VWh0dG_budgetTrack{background:var(--dsw-alias-bg-module-platform);border-radius:999px;height:6px;overflow:hidden}.VWh0dG_budgetFill{background:var(--dsw-static-blue-500);border-radius:999px;height:100%;transition:width .2s}.VWh0dG_budgetFillWarn{background:var(--dsw-static-amber-500)}.VWh0dG_budgetFillOver{background:var(--dsw-static-red-500);animation:1.6s ease-in-out infinite VWh0dG_budgetOverPulse}@keyframes VWh0dG_budgetOverPulse{50%{opacity:.55}}.VWh0dG_chartWrap{width:100%;position:relative}.VWh0dG_chartSvg{width:100%;height:auto;display:block}.VWh0dG_chartEmpty{height:140px;color:var(--dsw-alias-label-caption);justify-content:center;align-items:center;font-size:13px;display:flex}.VWh0dG_emptyRow{text-align:center;color:var(--dsw-alias-label-caption);padding:28px 0;font-size:13px}.VWh0dG_chartGrid{stroke:var(--dsw-alias-border-l1);stroke-width:1px}.VWh0dG_chartAxisLabel{fill:var(--dsw-alias-label-tertiary);font-size:10px}.VWh0dG_chartBar{fill:var(--dsw-static-blue-500);opacity:.35}.VWh0dG_chartBar:hover{opacity:.6}.VWh0dG_chartStack{stroke:var(--dsw-alias-bg-layer-1);stroke-width:.75px}.VWh0dG_chartStack:hover{opacity:.85}.VWh0dG_chartLine{stroke:var(--dsw-static-blue-500);stroke-width:2px;stroke-linecap:round;stroke-linejoin:round}.VWh0dG_chartCrosshair{stroke:var(--dsw-alias-label-dimmed);stroke-width:1px;stroke-dasharray:3 3}.VWh0dG_chartDot{fill:var(--dsw-static-neutral-bluish-00);stroke:var(--dsw-static-blue-500);stroke-width:2.5px}.VWh0dG_chartTooltip{pointer-events:none;z-index:2;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);box-shadow:var(--dsw-shadow-lv2);white-space:nowrap;border-radius:10px;padding:8px 10px;position:absolute;transform:translate(-50%,calc(-100% - 10px))}.VWh0dG_chartTooltipDate{color:var(--dsw-alias-label-primary);margin-bottom:3px;font-size:11px;font-weight:600}.VWh0dG_chartTooltipRow{color:var(--dsw-alias-label-secondary);align-items:center;gap:5px;font-size:11px;line-height:17px;display:flex}.VWh0dG_chartTooltipRow strong{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-weight:600}.VWh0dG_chartLegendLine{background:var(--dsw-static-blue-500);border-radius:2px;width:10px;height:3px;display:inline-block}.VWh0dG_chartLegendBar{background:var(--dsw-static-blue-500);opacity:.5;border-radius:2px;width:7px;height:7px;display:inline-block}.VWh0dG_chartTooltipSwatch{border-radius:3px;flex:none;width:8px;height:8px;display:inline-block}.VWh0dG_chartLegend{color:var(--dsw-alias-label-tertiary);justify-content:flex-end;gap:14px;margin-top:2px;font-size:11px;display:flex}.VWh0dG_chartLegend span{align-items:center;gap:5px;display:inline-flex}.VWh0dG_tableScroll{border:1px solid var(--dsw-alias-border-l1);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;overflow:auto}.VWh0dG_modelTable,.VWh0dG_pricingTable{border-collapse:collapse;width:100%;font-size:12.5px}.VWh0dG_modelTable th,.VWh0dG_modelTable td,.VWh0dG_pricingTable th,.VWh0dG_pricingTable td{border-bottom:1px solid var(--dsw-alias-border-l1);text-align:left;white-space:nowrap;padding:9px 12px}.VWh0dG_modelTable tbody tr:last-child td,.VWh0dG_pricingTable tbody tr:last-child td{border-bottom:0}.VWh0dG_modelTable thead th,.VWh0dG_pricingTable thead th{color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-module-platform);font-size:11px;font-weight:500}.VWh0dG_modelTable tbody tr,.VWh0dG_pricingTable tbody tr{transition:background-color .12s}.VWh0dG_modelTable tbody tr:hover,.VWh0dG_pricingTable tbody tr:hover{background:var(--dsw-alias-interactive-bg-hover)}.VWh0dG_numCol{text-align:right;font-variant-numeric:tabular-nums}.VWh0dG_costCol{color:var(--dsw-static-blue-500);font-weight:600}.VWh0dG_na{color:var(--dsw-alias-label-dimmed)}.VWh0dG_modelCell{align-items:center;gap:8px;display:inline-flex}.VWh0dG_modelDot{width:9px;height:9px;box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-alias-bg-layer-1) 60%, transparent);border-radius:50%;flex:none}.VWh0dG_modelName{color:var(--dsw-alias-label-primary);font-weight:500;line-height:16px;display:block}.VWh0dG_modelProvider{color:var(--dsw-alias-label-caption);font-size:10.5px;line-height:14px;display:block}.VWh0dG_pricingToggle{cursor:pointer;text-align:left;background:0 0;border:none;justify-content:space-between;align-items:center;gap:10px;width:100%;padding:0;display:flex}.VWh0dG_pricingToggle:hover .VWh0dG_panelTitle,.VWh0dG_pricingToggle:focus-visible .VWh0dG_panelTitle{color:var(--dsw-static-blue-500)}.VWh0dG_rateBadge{vertical-align:1px;white-space:nowrap;border-radius:999px;align-items:center;margin-left:6px;padding:1px 6px;font-size:10px;font-weight:500;line-height:14px;display:inline-flex}.VWh0dG_rateBadgeLive{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 10%, transparent)}.VWh0dG_rateBadgeBuiltin{color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-module-platform)}.VWh0dG_pricingToggleText{align-items:baseline;gap:10px;min-width:0;display:flex}.VWh0dG_pricingChevron{width:16px;height:16px;color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}.VWh0dG_pricingChevronOpen{transform:rotate(180deg)}.VWh0dG_bandPrice{align-items:baseline;gap:6px;display:inline-flex}.VWh0dG_bandPriceOff{color:var(--dsw-alias-label-caption)}.VWh0dG_bandPriceOff:before{content:\"/\";color:var(--dsw-alias-label-dimmed);margin-right:4px}.VWh0dG_bandTag{color:var(--dsw-alias-label-secondary);flex-direction:column;gap:1px;font-size:10.5px;line-height:14px;display:inline-flex}.VWh0dG_bandTagOff{color:var(--dsw-static-green-500);font-weight:600}.VWh0dG_flatTag{color:var(--dsw-alias-label-caption);font-size:10.5px;line-height:14px}.VWh0dG_healthDot{border-radius:50%;flex:none;width:8px;height:8px;display:inline-block}.VWh0dG_healthOk{background:var(--dsw-static-green-500);box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-static-green-500) 18%, transparent)}.VWh0dG_healthBad{background:var(--dsw-static-red-500);box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-static-red-500) 18%, transparent)}.VWh0dG_healthIdle{background:var(--dsw-static-neutral-bluish-400)}.VWh0dG_dashboardRight{align-items:center;gap:8px;min-width:0;display:flex}.VWh0dG_healthBadge{white-space:nowrap;border-radius:999px;align-items:center;gap:6px;padding:3px 9px;font-size:11px;line-height:16px;display:inline-flex}.VWh0dG_healthBadgeOk{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 10%, transparent)}.VWh0dG_healthBadgeBad{color:var(--dsw-static-red-500);background:color-mix(in srgb, var(--dsw-static-red-500) 10%, transparent)}.VWh0dG_planTag{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 12%, transparent);border-radius:999px;align-items:center;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px;display:inline-flex}.VWh0dG_uncataloguedTag{vertical-align:1px;color:var(--dsw-static-amber-500);background:color-mix(in srgb, var(--dsw-static-amber-500) 12%, transparent);border-radius:999px;margin-left:6px;padding:0 6px;font-size:10px;font-weight:600;line-height:16px;display:inline-block}.VWh0dG_estimatedTag{vertical-align:1px;color:var(--dsw-static-blue-500);background:color-mix(in srgb, var(--dsw-static-blue-500) 12%, transparent);border-radius:999px;margin-left:6px;padding:0 6px;font-size:10px;font-weight:600;line-height:16px;display:inline-block}.VWh0dG_liveCostBar{color:var(--dsw-static-neutral-400);font-variant-numeric:tabular-nums;align-items:center;gap:6px;font-size:11px;line-height:16px;display:inline-flex}.VWh0dG_liveCostItem{white-space:nowrap}.VWh0dG_liveCostSep{color:var(--dsw-static-neutral-300)}.VWh0dG_balanceCell{flex-direction:column;align-items:flex-end;gap:2px;display:inline-flex}.VWh0dG_balanceDays{color:var(--dsw-alias-label-caption);white-space:nowrap;font-size:10.5px;line-height:14px}.VWh0dG_balanceDaysLow{color:var(--dsw-static-red-500);font-weight:600}body[data-zine-mode] .VWh0dG_trigger,body[data-zine-mode] .VWh0dG_triggerPop,body[data-zine-mode] .VWh0dG_railButton{display:none}body[data-zine-mode] .VWh0dG_dashboardHead{background:#000;border-bottom:2px solid #e8ff00}body[data-zine-mode] .VWh0dG_headTitleRow{align-items:center;gap:8px;margin-top:4px;display:flex}body[data-zine-mode] .VWh0dG_dashboardTitle{color:#e8ff00;letter-spacing:.04em;text-transform:uppercase;text-shadow:0 0 8px #e8ff0066;font-weight:900}body[data-zine-mode] .VWh0dG_dashboardSubtitle{color:#c9d98a;letter-spacing:.08em;text-transform:uppercase;font-size:10px}body[data-zine-mode] .VWh0dG_closeButton{color:#0a0a05;background:#ff2d95;border:1.5px solid #ff2d95;border-radius:0;box-shadow:0 0 10px #ff2d9573}body[data-zine-mode] .VWh0dG_hero{background:#000;border:2.5px solid #e8ff00;border-radius:0;position:relative;box-shadow:0 0 0 1px #0009,0 0 24px #e8ff002e}body[data-zine-mode] .VWh0dG_heroLabel{color:#c9d98a;letter-spacing:.12em;text-transform:uppercase;font-size:10px;font-weight:900}body[data-zine-mode] .VWh0dG_heroValue{color:#e8ff00;letter-spacing:-.02em;text-shadow:0 0 12px #e8ff0073;-webkit-text-fill-color:#e8ff00;background:0 0;font-size:38px;font-weight:900}body[data-zine-mode] .VWh0dG_heroMeta{color:#c9d98a;letter-spacing:.06em;text-transform:uppercase;font-size:10.5px}body[data-zine-mode] .VWh0dG_heroSideLabel{color:#c9d98a;letter-spacing:.1em;text-transform:uppercase;font-size:10px;font-weight:900}body[data-zine-mode] .VWh0dG_heroSideValue{color:#e8ff00;text-shadow:0 0 6px #e8ff0059}body[data-zine-mode] .VWh0dG_delta{font-weight:900}body[data-zine-mode] .VWh0dG_deltaUp{color:#ff2d95}body[data-zine-mode] .VWh0dG_deltaDown{color:#c9d98a}body[data-zine-mode] .VWh0dG_tabNav{background:#000;border-bottom:2px solid #e8ff00}body[data-zine-mode] .VWh0dG_tabButton{color:#c9d98a;letter-spacing:.08em;text-transform:uppercase;border-radius:0;font-size:10.5px;font-weight:900}body[data-zine-mode] .VWh0dG_tabButton:hover,body[data-zine-mode] .VWh0dG_tabButton:focus-visible{color:#e8ff00;background:#e8ff001f}body[data-zine-mode] .VWh0dG_tabButtonActive,body[data-zine-mode] .VWh0dG_tabButtonActive:hover,body[data-zine-mode] .VWh0dG_tabButtonActive:focus-visible{color:#0a0a05;background:#e8ff00;box-shadow:0 0 10px #e8ff0073}body[data-zine-mode] .VWh0dG_panel{background:#000;border:2px solid #e8ff00;border-radius:0}body[data-zine-mode] .VWh0dG_trendPanel{position:relative}body[data-zine-mode] .VWh0dG_panelTitle{color:#e8ff00;letter-spacing:.06em;text-transform:uppercase;text-shadow:0 0 6px #e8ff0066;font-weight:900}body[data-zine-mode] .VWh0dG_panelHint{color:#c9d98a;letter-spacing:.08em;text-transform:uppercase;font-size:10px;font-weight:900}body[data-zine-mode] .VWh0dG_modelTableScroll{background:#000;border:1.5px solid #e8ff0080;border-radius:0}.VWh0dG_currencyToggle{border:1px solid var(--dsw-alias-border-muted,#3a4250);background:var(--dsw-alias-bg-layer-2,#232a33);border-radius:6px;align-items:center;gap:2px;margin-right:8px;padding:2px;display:inline-flex}.VWh0dG_currencyButton{color:var(--dsw-alias-text-secondary,#9aa5b1);cursor:pointer;background:0 0;border:0;border-radius:4px;padding:4px 7px;font-size:11px;font-weight:700;line-height:1}.VWh0dG_currencyButtonActive{background:var(--dsw-alias-accent-muted,#2f6fed);color:#fff}.VWh0dG_subscriptionGrid{grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px;margin-top:10px;display:grid}.VWh0dG_subscriptionCard{border:1px solid var(--dsw-alias-border-muted,#3a4250);background:var(--dsw-alias-bg-layer-2,#232a33);border-radius:8px;padding:10px 12px}.VWh0dG_subscriptionHead{align-items:baseline;gap:8px;margin-bottom:6px;display:flex}.VWh0dG_subscriptionName{font-size:13px;font-weight:700}.VWh0dG_subscriptionPlan{color:var(--dsw-alias-text-secondary,#9aa5b1);font-size:11px}.VWh0dG_subscriptionStatus{color:var(--dsw-alias-warning,#e0a63c);margin-bottom:6px;font-size:11px}.VWh0dG_subscriptionWindow{align-items:center;gap:8px;margin-top:6px;font-size:11px;display:flex}.VWh0dG_subscriptionWindowLabel{color:var(--dsw-alias-text-secondary,#9aa5b1);flex:0 0 44px}.VWh0dG_subscriptionTrack{background:var(--dsw-alias-bg-layer-3,#1a2028);border-radius:3px;flex:1;height:5px;overflow:hidden}.VWh0dG_subscriptionFill{background:var(--dsw-alias-accent,#3b82f6);border-radius:3px;height:100%;display:block}.VWh0dG_subscriptionPct{text-align:right;font-variant-numeric:tabular-nums;flex:none;min-width:52px}.VWh0dG_subscriptionReset{color:var(--dsw-alias-text-secondary,#9aa5b1);flex:none}.VWh0dG_providerGroupList{flex-direction:column;gap:10px;display:flex}.VWh0dG_providerGroup{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:12px;padding:12px 14px}.VWh0dG_providerGroupHead{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.VWh0dG_providerGroupTitle{align-items:center;gap:7px;min-width:0;display:inline-flex}.VWh0dG_providerGroupName{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:18px}.VWh0dG_providerGroupMeta{flex:none;align-items:center;gap:10px;display:inline-flex}.VWh0dG_providerGroupBadge{color:var(--dsw-static-green-500);background:color-mix(in srgb, var(--dsw-static-green-500) 12%, transparent);border-radius:999px;align-items:center;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px;display:inline-flex}.VWh0dG_providerGroupBalance{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;align-items:baseline;gap:6px;font-size:12px;line-height:17px;display:inline-flex}.VWh0dG_providerGroupBalanceLabel{color:var(--dsw-alias-label-caption);font-size:11px;line-height:17px}.VWh0dG_roundsFlagBadge{color:#fff;background:#ef4444;border-radius:999px;margin-left:8px;padding:1px 7px;font-size:10px;font-weight:800}.VWh0dG_rounds{margin-top:10px}.VWh0dG_roundsBars{align-items:flex-end;gap:3px;height:110px;padding:4px 2px 0;display:flex;overflow-x:auto}.VWh0dG_roundsBarCol{flex-direction:column;flex:1 0 28px;justify-content:flex-end;align-items:stretch;height:100%;display:flex}.VWh0dG_roundsBarLabel{text-align:center;color:var(--dsw-alias-text-secondary,#9aa5b1);white-space:nowrap;text-overflow:ellipsis;max-width:100%;margin-bottom:2px;font-size:8px;line-height:1;overflow:hidden}.VWh0dG_roundsBarWrap{flex:1;align-items:flex-end;min-height:0;display:flex}.VWh0dG_roundsBar{background:var(--dsw-alias-accent,#3b82f6);border-radius:2px 2px 0 0;width:100%;min-height:2px;position:relative}.VWh0dG_roundsBarFlagged{outline-offset:1px;background:#ef4444;border-radius:2px 2px 0 0;outline:1.5px solid #ef4444;width:100%;min-height:2px;position:relative}.VWh0dG_roundsFlagMark{background:#ef4444;border-radius:50%;width:7px;height:7px;position:absolute;top:-3px;right:-3px;box-shadow:0 0 4px #ef4444}.VWh0dG_roundsAxis{color:var(--dsw-alias-text-secondary,#9aa5b1);justify-content:space-between;margin-top:6px;font-size:10px;display:flex}.VWh0dG_roundsEmpty{color:var(--dsw-alias-text-secondary,#9aa5b1);margin-top:10px;font-size:12px}.VWh0dG_heatmap{margin-top:10px}.VWh0dG_heatmapGrid{grid-template-columns:repeat(7,minmax(0,1fr));gap:8px;display:grid}.VWh0dG_heatmapCellEmpty{background:var(--dsw-alias-bg-layer-1);height:30px;color:var(--dsw-alias-label-dimmed,#6b7480);font-variant-numeric:tabular-nums;border-radius:8px;justify-content:center;align-items:center;font-size:11px;display:flex}.VWh0dG_heatmapCell{font-variant-numeric:tabular-nums;cursor:pointer;border:0;border-radius:8px;justify-content:center;align-items:center;height:30px;padding:0;font-size:11px;display:flex}.VWh0dG_heatmapCell[data-level=\"0\"],.VWh0dG_heatmapCell[data-level=\"1\"],.VWh0dG_heatmapCell[data-level=\"2\"]{color:var(--dsw-alias-label-primary)}.VWh0dG_heatmapCell[data-level=\"3\"],.VWh0dG_heatmapCell[data-level=\"4\"]{color:var(--dsw-static-neutral-bluish-00,#fff)}.VWh0dG_heatmapFooter{color:var(--dsw-alias-text-secondary,#9aa5b1);align-items:center;gap:8px;margin-top:10px;font-size:10px;display:flex}.VWh0dG_heatmapLegend{gap:3px;display:inline-flex}.VWh0dG_heatmapLegend i{border-radius:4px;width:14px;height:14px;display:block}.VWh0dG_heatmapHover{font-variant-numeric:tabular-nums;margin-left:auto}@media (width<=640px){.VWh0dG_kpiGrid{grid-template-columns:repeat(2,minmax(0,1fr))}.VWh0dG_hero{flex-direction:column;align-items:flex-start;gap:14px}.VWh0dG_heroSide{border-left:none;border-top:1px solid var(--dsw-alias-border-l1);flex-direction:row;align-self:stretch;gap:20px;padding-top:14px;padding-left:0}}";
28
28
  const tagId = "@kenz1117/dsh-ui-usage-billing/UsageBilling.module.css";
29
29
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
30
30
  const tag = document.createElement("style");
@@ -34,160 +34,192 @@ window.__ModuleLoader__.load({
34
34
  document.head.appendChild(tag);
35
35
  }
36
36
  var UsageBilling_module_css_default = {
37
- "rateBadge": "VWh0dG_rateBadge",
38
- "balanceCell": "VWh0dG_balanceCell",
39
- "healthOk": "VWh0dG_healthOk",
40
- "railButton": "VWh0dG_railButton",
37
+ "subscriptionGrid": "VWh0dG_subscriptionGrid",
38
+ "roundsBarLabel": "VWh0dG_roundsBarLabel",
39
+ "heatmapLegend": "VWh0dG_heatmapLegend",
41
40
  "trendPanel": "VWh0dG_trendPanel",
42
- "pricingChevron": "VWh0dG_pricingChevron",
43
- "dashboardTitle": "VWh0dG_dashboardTitle",
44
- "modelProvider": "VWh0dG_modelProvider",
45
- "bandPrice": "VWh0dG_bandPrice",
46
- "triggerToday": "VWh0dG_triggerToday",
47
- "panelTitle": "VWh0dG_panelTitle",
48
- "modelName": "VWh0dG_modelName",
49
- "triggerDivider": "VWh0dG_triggerDivider",
50
- "kpiGreen": "VWh0dG_kpiGreen",
51
- "switchOn": "VWh0dG_switchOn",
52
- "chartEmpty": "VWh0dG_chartEmpty",
53
- "subscriptionReset": "VWh0dG_subscriptionReset",
54
- "costCol": "VWh0dG_costCol",
55
- "budgetLabel": "VWh0dG_budgetLabel",
56
- "roundsFlagBadge": "VWh0dG_roundsFlagBadge",
41
+ "chartGrid": "VWh0dG_chartGrid",
42
+ "chartLegend": "VWh0dG_chartLegend",
43
+ "triggerIcon": "VWh0dG_triggerIcon",
44
+ "chartSvg": "VWh0dG_chartSvg",
57
45
  "budgetUnit": "VWh0dG_budgetUnit",
58
- "budgetInput": "VWh0dG_budgetInput",
59
- "subscriptionWindow": "VWh0dG_subscriptionWindow",
60
- "heroSideItem": "VWh0dG_heroSideItem",
61
- "subscriptionHead": "VWh0dG_subscriptionHead",
62
- "roundsBarFlagged": "VWh0dG_roundsBarFlagged",
63
- "currencyButton": "VWh0dG_currencyButton",
64
- "rangeButtonActive": "VWh0dG_rangeButtonActive",
46
+ "shareDot": "VWh0dG_shareDot",
47
+ "healthBad": "VWh0dG_healthBad",
48
+ "pricingToggleText": "VWh0dG_pricingToggleText",
49
+ "rangeButton": "VWh0dG_rangeButton",
50
+ "planTag": "VWh0dG_planTag",
51
+ "chartWrap": "VWh0dG_chartWrap",
65
52
  "heatmapCell": "VWh0dG_heatmapCell",
66
- "chartSvg": "VWh0dG_chartSvg",
67
- "roundsBarWrap": "VWh0dG_roundsBarWrap",
68
- "providerGroupTitle": "VWh0dG_providerGroupTitle",
69
- "chartTooltipSwatch": "VWh0dG_chartTooltipSwatch",
70
- "budgetFill": "VWh0dG_budgetFill",
53
+ "budgetControls": "VWh0dG_budgetControls",
54
+ "kpiLabel": "VWh0dG_kpiLabel",
55
+ "triggerAmountSub": "VWh0dG_triggerAmountSub",
56
+ "budgetLabel": "VWh0dG_budgetLabel",
57
+ "rangeButtonActive": "VWh0dG_rangeButtonActive",
58
+ "numCol": "VWh0dG_numCol",
59
+ "panel": "VWh0dG_panel",
60
+ "chartAxisLabel": "VWh0dG_chartAxisLabel",
61
+ "budgetInputWrap": "VWh0dG_budgetInputWrap",
62
+ "shareSeg": "VWh0dG_shareSeg",
63
+ "chartTooltipDate": "VWh0dG_chartTooltipDate",
64
+ "subscriptionHead": "VWh0dG_subscriptionHead",
65
+ "emptyRow": "VWh0dG_emptyRow",
66
+ "uncataloguedTag": "VWh0dG_uncataloguedTag",
67
+ "shareSegPeak": "VWh0dG_shareSegPeak",
68
+ "subscriptionFill": "VWh0dG_subscriptionFill",
69
+ "chartDot": "VWh0dG_chartDot",
70
+ "panelHint": "VWh0dG_panelHint",
71
+ "tableScroll": "VWh0dG_tableScroll",
72
+ "estimatedTag": "VWh0dG_estimatedTag",
73
+ "budget": "VWh0dG_budget",
71
74
  "chartStack": "VWh0dG_chartStack",
72
- "currencyToggle": "VWh0dG_currencyToggle",
73
- "subscriptionGrid": "VWh0dG_subscriptionGrid",
74
- "pricingToggle": "VWh0dG_pricingToggle",
75
- "chartLegendBar": "VWh0dG_chartLegendBar",
76
- "balanceDaysLow": "VWh0dG_balanceDaysLow",
77
- "modelTable": "VWh0dG_modelTable",
78
- "dashboardBody": "VWh0dG_dashboardBody",
79
- "roundsAxis": "VWh0dG_roundsAxis",
80
- "dashboardSubtitle": "VWh0dG_dashboardSubtitle",
81
- "trigger": "VWh0dG_trigger",
82
- "chartBar": "VWh0dG_chartBar",
83
- "chartLine": "VWh0dG_chartLine",
84
- "roundsFlagMark": "VWh0dG_roundsFlagMark",
85
- "kpiGrid": "VWh0dG_kpiGrid",
86
- "modelTableScroll": "VWh0dG_modelTableScroll",
87
- "bandTagOff": "VWh0dG_bandTagOff",
88
- "closeButton": "VWh0dG_closeButton",
89
- "headTitleRow": "VWh0dG_headTitleRow",
90
- "chartWrap": "VWh0dG_chartWrap",
91
- "chartGrid": "VWh0dG_chartGrid",
75
+ "tabNav": "VWh0dG_tabNav",
76
+ "budgetOverPulse": "VWh0dG_budgetOverPulse",
77
+ "healthBadgeBad": "VWh0dG_healthBadgeBad",
78
+ "providerGroupBadge": "VWh0dG_providerGroupBadge",
92
79
  "rateBadgeBuiltin": "VWh0dG_rateBadgeBuiltin",
93
- "uncataloguedTag": "VWh0dG_uncataloguedTag",
80
+ "exportLabel": "VWh0dG_exportLabel",
81
+ "exportBar": "VWh0dG_exportBar",
82
+ "heroSide": "VWh0dG_heroSide",
83
+ "triggerPopValue": "VWh0dG_triggerPopValue",
84
+ "healthOk": "VWh0dG_healthOk",
85
+ "subscriptionCard": "VWh0dG_subscriptionCard",
86
+ "chartLine": "VWh0dG_chartLine",
87
+ "providerGroupName": "VWh0dG_providerGroupName",
88
+ "bandPrice": "VWh0dG_bandPrice",
89
+ "dashboardModal": "VWh0dG_dashboardModal",
90
+ "pricingToggle": "VWh0dG_pricingToggle",
91
+ "shareSegOff": "VWh0dG_shareSegOff",
92
+ "triggerAmount": "VWh0dG_triggerAmount",
93
+ "dashboardHead": "VWh0dG_dashboardHead",
94
+ "heatmapCellEmpty": "VWh0dG_heatmapCellEmpty",
94
95
  "subscriptionPct": "VWh0dG_subscriptionPct",
95
- "hero": "VWh0dG_hero",
96
- "providerGroupBalanceLabel": "VWh0dG_providerGroupBalanceLabel",
96
+ "triggerPopBar": "VWh0dG_triggerPopBar",
97
+ "chartCrosshair": "VWh0dG_chartCrosshair",
97
98
  "heroMeta": "VWh0dG_heroMeta",
98
- "balanceDays": "VWh0dG_balanceDays",
99
- "emptyRow": "VWh0dG_emptyRow",
100
- "subscriptionWindowLabel": "VWh0dG_subscriptionWindowLabel",
101
- "subscriptionTrack": "VWh0dG_subscriptionTrack",
102
- "panel": "VWh0dG_panel",
103
- "heatmapLegend": "VWh0dG_heatmapLegend",
104
- "heroSide": "VWh0dG_heroSide",
105
- "roundsBarLabel": "VWh0dG_roundsBarLabel",
99
+ "shareSegUser": "VWh0dG_shareSegUser",
100
+ "switchOn": "VWh0dG_switchOn",
101
+ "budgetValue": "VWh0dG_budgetValue",
102
+ "liveCostItem": "VWh0dG_liveCostItem",
103
+ "heroMain": "VWh0dG_heroMain",
104
+ "currencyButton": "VWh0dG_currencyButton",
105
+ "chartBar": "VWh0dG_chartBar",
106
+ "modelTable": "VWh0dG_modelTable",
106
107
  "budgetFillOver": "VWh0dG_budgetFillOver",
107
- "budgetInputWrap": "VWh0dG_budgetInputWrap",
108
- "triggerMonth": "VWh0dG_triggerMonth",
109
- "rateBadgeLive": "VWh0dG_rateBadgeLive",
110
- "heatmapHover": "VWh0dG_heatmapHover",
111
- "healthBadgeOk": "VWh0dG_healthBadgeOk",
112
- "healthBad": "VWh0dG_healthBad",
108
+ "modelTableScroll": "VWh0dG_modelTableScroll",
109
+ "providerGroup": "VWh0dG_providerGroup",
113
110
  "bandTag": "VWh0dG_bandTag",
114
- "heatmapGrid": "VWh0dG_heatmapGrid",
115
- "chartLegend": "VWh0dG_chartLegend",
116
- "modelDot": "VWh0dG_modelDot",
117
- "budgetControls": "VWh0dG_budgetControls",
118
- "panelHint": "VWh0dG_panelHint",
119
- "dashboard": "VWh0dG_dashboard",
120
- "currencyButtonActive": "VWh0dG_currencyButtonActive",
121
- "tableScroll": "VWh0dG_tableScroll",
111
+ "dashboardTitle": "VWh0dG_dashboardTitle",
122
112
  "bandPriceOff": "VWh0dG_bandPriceOff",
123
- "pricingToggleText": "VWh0dG_pricingToggleText",
124
- "modelCell": "VWh0dG_modelCell",
125
- "pricingChevronOpen": "VWh0dG_pricingChevronOpen",
126
- "providerGroupBalance": "VWh0dG_providerGroupBalance",
127
- "roundsBars": "VWh0dG_roundsBars",
128
- "heroSideLabel": "VWh0dG_heroSideLabel",
129
- "roundsEmpty": "VWh0dG_roundsEmpty",
130
- "deltaDown": "VWh0dG_deltaDown",
131
- "subscriptionFill": "VWh0dG_subscriptionFill",
132
- "rangeToggle": "VWh0dG_rangeToggle",
133
- "chartCrosshair": "VWh0dG_chartCrosshair",
134
- "chartTooltipRow": "VWh0dG_chartTooltipRow",
135
- "numCol": "VWh0dG_numCol",
136
- "kpiValue": "VWh0dG_kpiValue",
137
- "chartTooltipDate": "VWh0dG_chartTooltipDate",
138
- "triggerAmountSub": "VWh0dG_triggerAmountSub",
139
- "providerGroupMeta": "VWh0dG_providerGroupMeta",
140
- "triggerAmount": "VWh0dG_triggerAmount",
141
- "dashboardModal": "VWh0dG_dashboardModal",
142
- "kpiDetail": "VWh0dG_kpiDetail",
113
+ "healthIdle": "VWh0dG_healthIdle",
114
+ "balanceCell": "VWh0dG_balanceCell",
115
+ "subscriptionTrack": "VWh0dG_subscriptionTrack",
116
+ "roundsBar": "VWh0dG_roundsBar",
117
+ "panelTitle": "VWh0dG_panelTitle",
143
118
  "kpiTile": "VWh0dG_kpiTile",
144
- "subscriptionStatus": "VWh0dG_subscriptionStatus",
145
- "budgetOverPulse": "VWh0dG_budgetOverPulse",
119
+ "rateBadge": "VWh0dG_rateBadge",
120
+ "delta": "VWh0dG_delta",
121
+ "chartEmpty": "VWh0dG_chartEmpty",
122
+ "flatTag": "VWh0dG_flatTag",
123
+ "liveCostBar": "VWh0dG_liveCostBar",
124
+ "currencyButtonActive": "VWh0dG_currencyButtonActive",
125
+ "pricingChevron": "VWh0dG_pricingChevron",
126
+ "shareSegAssistant": "VWh0dG_shareSegAssistant",
127
+ "providerGroupTitle": "VWh0dG_providerGroupTitle",
128
+ "dashboardIn": "VWh0dG_dashboardIn",
129
+ "heatmap": "VWh0dG_heatmap",
130
+ "healthDot": "VWh0dG_healthDot",
131
+ "providerGroupHead": "VWh0dG_providerGroupHead",
132
+ "subscriptionPlan": "VWh0dG_subscriptionPlan",
133
+ "providerGroupList": "VWh0dG_providerGroupList",
134
+ "triggerMonth": "VWh0dG_triggerMonth",
135
+ "dashboard": "VWh0dG_dashboard",
136
+ "hero": "VWh0dG_hero",
137
+ "chartTooltipSwatch": "VWh0dG_chartTooltipSwatch",
146
138
  "subscriptionName": "VWh0dG_subscriptionName",
147
- "roundsBar": "VWh0dG_roundsBar",
148
- "budgetTrack": "VWh0dG_budgetTrack",
149
- "switch": "VWh0dG_switch",
150
- "roundsBarCol": "VWh0dG_roundsBarCol",
139
+ "tabPanelIn": "VWh0dG_tabPanelIn",
140
+ "heroSideValue": "VWh0dG_heroSideValue",
141
+ "healthBadgeOk": "VWh0dG_healthBadgeOk",
142
+ "triggerPop": "VWh0dG_triggerPop",
143
+ "shareItem": "VWh0dG_shareItem",
144
+ "subscriptionReset": "VWh0dG_subscriptionReset",
151
145
  "chartLegendLine": "VWh0dG_chartLegendLine",
152
- "healthIdle": "VWh0dG_healthIdle",
153
- "deltaUp": "VWh0dG_deltaUp",
154
- "panelHead": "VWh0dG_panelHead",
146
+ "budgetFill": "VWh0dG_budgetFill",
147
+ "providerGroupMeta": "VWh0dG_providerGroupMeta",
148
+ "providerGroupBalance": "VWh0dG_providerGroupBalance",
149
+ "providerGroupBalanceLabel": "VWh0dG_providerGroupBalanceLabel",
155
150
  "dashboardRight": "VWh0dG_dashboardRight",
156
- "providerGroupBadge": "VWh0dG_providerGroupBadge",
157
- "pricingTable": "VWh0dG_pricingTable",
151
+ "subscriptionStatus": "VWh0dG_subscriptionStatus",
152
+ "closeButton": "VWh0dG_closeButton",
153
+ "modelName": "VWh0dG_modelName",
154
+ "triggerPopBars": "VWh0dG_triggerPopBars",
155
+ "dashboardBody": "VWh0dG_dashboardBody",
156
+ "triggerDivider": "VWh0dG_triggerDivider",
158
157
  "triggerMeta": "VWh0dG_triggerMeta",
159
- "chartAxisLabel": "VWh0dG_chartAxisLabel",
158
+ "deltaUp": "VWh0dG_deltaUp",
159
+ "budgetInput": "VWh0dG_budgetInput",
160
+ "chartTooltipRow": "VWh0dG_chartTooltipRow",
161
+ "roundsFlagBadge": "VWh0dG_roundsFlagBadge",
162
+ "modelProvider": "VWh0dG_modelProvider",
163
+ "budgetFillWarn": "VWh0dG_budgetFillWarn",
164
+ "rateBadgeLive": "VWh0dG_rateBadgeLive",
165
+ "liveCostSep": "VWh0dG_liveCostSep",
166
+ "subscriptionWindowLabel": "VWh0dG_subscriptionWindowLabel",
167
+ "roundsBarCol": "VWh0dG_roundsBarCol",
168
+ "heatmapHover": "VWh0dG_heatmapHover",
169
+ "subscriptionWindow": "VWh0dG_subscriptionWindow",
170
+ "heroSideLabel": "VWh0dG_heroSideLabel",
171
+ "switchKnob": "VWh0dG_switchKnob",
172
+ "shareTrack": "VWh0dG_shareTrack",
173
+ "shareLegend": "VWh0dG_shareLegend",
174
+ "kpiDetail": "VWh0dG_kpiDetail",
175
+ "kpiGreen": "VWh0dG_kpiGreen",
176
+ "dashboardSubtitle": "VWh0dG_dashboardSubtitle",
177
+ "shareSegTool": "VWh0dG_shareSegTool",
178
+ "modelDot": "VWh0dG_modelDot",
160
179
  "rounds": "VWh0dG_rounds",
161
- "na": "VWh0dG_na",
162
- "heroValue": "VWh0dG_heroValue",
163
- "chartDot": "VWh0dG_chartDot",
164
- "healthBadge": "VWh0dG_healthBadge",
165
- "rangeButton": "VWh0dG_rangeButton",
166
- "heatmapCellEmpty": "VWh0dG_heatmapCellEmpty",
167
- "heatmapFooter": "VWh0dG_heatmapFooter",
168
- "providerGroupHead": "VWh0dG_providerGroupHead",
180
+ "roundsBarFlagged": "VWh0dG_roundsBarFlagged",
181
+ "roundsEmpty": "VWh0dG_roundsEmpty",
182
+ "roundsBars": "VWh0dG_roundsBars",
183
+ "trigger": "VWh0dG_trigger",
184
+ "balanceDaysLow": "VWh0dG_balanceDaysLow",
169
185
  "chartTooltip": "VWh0dG_chartTooltip",
170
- "healthBadgeBad": "VWh0dG_healthBadgeBad",
171
- "delta": "VWh0dG_delta",
172
- "providerGroup": "VWh0dG_providerGroup",
173
- "heatmap": "VWh0dG_heatmap",
174
- "triggerIcon": "VWh0dG_triggerIcon",
175
- "dashboardHead": "VWh0dG_dashboardHead",
176
- "heroSideValue": "VWh0dG_heroSideValue",
177
- "heroMain": "VWh0dG_heroMain",
178
- "budgetValue": "VWh0dG_budgetValue",
179
- "healthDot": "VWh0dG_healthDot",
180
- "subscriptionCard": "VWh0dG_subscriptionCard",
181
- "budgetHead": "VWh0dG_budgetHead",
182
- "planTag": "VWh0dG_planTag",
186
+ "balanceDays": "VWh0dG_balanceDays",
187
+ "headTitleRow": "VWh0dG_headTitleRow",
183
188
  "heroLabel": "VWh0dG_heroLabel",
184
- "budget": "VWh0dG_budget",
185
- "kpiLabel": "VWh0dG_kpiLabel",
186
- "switchKnob": "VWh0dG_switchKnob",
187
- "subscriptionPlan": "VWh0dG_subscriptionPlan",
188
- "flatTag": "VWh0dG_flatTag",
189
- "providerGroupName": "VWh0dG_providerGroupName",
190
- "providerGroupList": "VWh0dG_providerGroupList"
189
+ "healthBadge": "VWh0dG_healthBadge",
190
+ "deltaDown": "VWh0dG_deltaDown",
191
+ "roundsFlagMark": "VWh0dG_roundsFlagMark",
192
+ "roundsAxis": "VWh0dG_roundsAxis",
193
+ "bandTagOff": "VWh0dG_bandTagOff",
194
+ "kpiValue": "VWh0dG_kpiValue",
195
+ "tabButtonActive": "VWh0dG_tabButtonActive",
196
+ "triggerToday": "VWh0dG_triggerToday",
197
+ "costCol": "VWh0dG_costCol",
198
+ "triggerPopRow": "VWh0dG_triggerPopRow",
199
+ "triggerWrap": "VWh0dG_triggerWrap",
200
+ "roundsBarWrap": "VWh0dG_roundsBarWrap",
201
+ "budgetHead": "VWh0dG_budgetHead",
202
+ "triggerPopLabel": "VWh0dG_triggerPopLabel",
203
+ "railButton": "VWh0dG_railButton",
204
+ "na": "VWh0dG_na",
205
+ "budgetTrack": "VWh0dG_budgetTrack",
206
+ "heatmapFooter": "VWh0dG_heatmapFooter",
207
+ "pricingTable": "VWh0dG_pricingTable",
208
+ "exportButton": "VWh0dG_exportButton",
209
+ "heroValue": "VWh0dG_heroValue",
210
+ "switch": "VWh0dG_switch",
211
+ "heroSideItem": "VWh0dG_heroSideItem",
212
+ "heatmapGrid": "VWh0dG_heatmapGrid",
213
+ "shareValue": "VWh0dG_shareValue",
214
+ "chartLegendBar": "VWh0dG_chartLegendBar",
215
+ "pricingChevronOpen": "VWh0dG_pricingChevronOpen",
216
+ "currencyToggle": "VWh0dG_currencyToggle",
217
+ "rangeToggle": "VWh0dG_rangeToggle",
218
+ "tabPanel": "VWh0dG_tabPanel",
219
+ "panelHead": "VWh0dG_panelHead",
220
+ "kpiGrid": "VWh0dG_kpiGrid",
221
+ "tabButton": "VWh0dG_tabButton",
222
+ "modelCell": "VWh0dG_modelCell"
191
223
  };
192
224
  //#endregion
193
225
  //#region src/client/pricing.ts
@@ -228,6 +260,22 @@ window.__ModuleLoader__.load({
228
260
  /** Default share of traffic assumed to fall in the peak band (0..1). */
229
261
  const DEFAULT_PEAK_SHARE = .5;
230
262
  /**
263
+ * 高峰时段判定(北京时间,UTC+8,无夏令时):09:00–12:00、14:00–18:00。
264
+ * @param beijingHour - 北京时间的小时数(0–23)。
265
+ */
266
+ function isPeakHour(beijingHour) {
267
+ return beijingHour >= 9 && beijingHour < 12 || beijingHour >= 14 && beijingHour < 18;
268
+ }
269
+ /**
270
+ * 由时刻(epoch 毫秒)推断计费时段;时刻未知/非法时按高峰计(保守:未知
271
+ * 时刻不低估成本,与社区 dsh-usage-chart 的 tierAt 语义一致)。
272
+ * @param timeMs - Unix epoch 毫秒;null/undefined/NaN 视为未知。
273
+ */
274
+ function tierAt(timeMs) {
275
+ if (timeMs === null || timeMs === void 0 || !Number.isFinite(timeMs)) return "peak";
276
+ return isPeakHour((new Date(timeMs).getUTCHours() + 8) % 24) ? "peak" : "offPeak";
277
+ }
278
+ /**
231
279
  * Built-in catalog of current mainstream models as of 2026-08-16, priced from
232
280
  * each provider's official price page. Domestic providers are OpenAI-API
233
281
  * compatible and publish RMB prices directly; overseas providers publish USD
@@ -475,7 +523,8 @@ window.__ModuleLoader__.load({
475
523
  input: 4,
476
524
  cacheHit: .4,
477
525
  output: 12
478
- }
526
+ },
527
+ estimated: true
479
528
  },
480
529
  {
481
530
  key: "minimax",
@@ -559,7 +608,8 @@ window.__ModuleLoader__.load({
559
608
  input: 5,
560
609
  cacheHit: .5,
561
610
  output: 10
562
- }
611
+ },
612
+ estimated: true
563
613
  },
564
614
  {
565
615
  key: "sensenova",
@@ -571,7 +621,8 @@ window.__ModuleLoader__.load({
571
621
  input: 4.5,
572
622
  cacheHit: .45,
573
623
  output: 9
574
- }
624
+ },
625
+ estimated: true
575
626
  },
576
627
  {
577
628
  key: "baichuan",
@@ -1416,6 +1467,64 @@ window.__ModuleLoader__.load({
1416
1467
  return flags;
1417
1468
  }
1418
1469
  //#endregion
1470
+ //#region src/client/export.ts
1471
+ /** CSV 单元格转义:含逗号 / 引号 / 换行的值加双引号并内层引号双写。 */
1472
+ function csvCell(value) {
1473
+ return /[",\n]/.test(value) ? `"${value.replace(/"/g, "\"\"")}"` : value;
1474
+ }
1475
+ /** 金额保留两位小数字符串(导出对账用,不做千分位)。 */
1476
+ function money(value) {
1477
+ return value.toFixed(2);
1478
+ }
1479
+ /** 按日 CSV:日期,调用,输入,输出,缓存命中,缓存未命中,费用(元)。 */
1480
+ function dayRowsCsv(byDay) {
1481
+ return ["date,calls,input,output,cache_hit,cache_miss,cost_cny", ...Object.keys(byDay).sort().map((date) => {
1482
+ const day = byDay[date];
1483
+ if (day === void 0) return "";
1484
+ return [
1485
+ date,
1486
+ day.calls,
1487
+ day.input,
1488
+ day.output,
1489
+ day.cacheHit,
1490
+ day.cacheMiss,
1491
+ money(day.cost)
1492
+ ].join(",");
1493
+ })].join("\n");
1494
+ }
1495
+ /** 项目名取 cwd 末级目录(与统计 Tab 的会话明细同口径)。 */
1496
+ function projectOf(cwd) {
1497
+ if (cwd === void 0) return "";
1498
+ return cwd.split(/[\\/]/).filter(Boolean).pop() ?? cwd;
1499
+ }
1500
+ /** 按会话 CSV:会话 id,标题,项目,调用,费用(元),最后活跃(ISO)。 */
1501
+ function sessionRowsCsv(rows) {
1502
+ return ["session_id,title,project,calls,cost_cny,last_active", ...rows.map((row) => [
1503
+ csvCell(row.id),
1504
+ csvCell(row.title ?? ""),
1505
+ csvCell(projectOf(row.cwd)),
1506
+ row.calls,
1507
+ money(row.cost),
1508
+ row.lastActive > 0 ? new Date(row.lastActive).toISOString() : ""
1509
+ ].join(","))].join("\n");
1510
+ }
1511
+ /** 导出文件名:带日期范围(usage-2026-08-01_2026-08-22.csv);无日期时只带前缀。 */
1512
+ function exportFileName(prefix, ext, dates) {
1513
+ const sorted = [...dates].sort();
1514
+ const first = sorted[0];
1515
+ const last = sorted.at(-1);
1516
+ return `${prefix}${first !== void 0 && last !== void 0 ? `-${first}_${last}` : ""}.${ext}`;
1517
+ }
1518
+ /** 触发浏览器下载(唯一 DOM 副作用;调用方在 click 手势里使用)。 */
1519
+ function downloadText(filename, text, mime) {
1520
+ const url = URL.createObjectURL(new Blob([text], { type: mime }));
1521
+ const anchor = document.createElement("a");
1522
+ anchor.href = url;
1523
+ anchor.download = filename;
1524
+ anchor.click();
1525
+ URL.revokeObjectURL(url);
1526
+ }
1527
+ //#endregion
1419
1528
  //#region src/client/UsageBilling.tsx
1420
1529
  /**
1421
1530
  * UsageBilling: sidebar footer trigger + full billing dashboard modal.
@@ -1430,11 +1539,44 @@ window.__ModuleLoader__.load({
1430
1539
  */
1431
1540
  /** 会话明细面板最多展示的行数(完整长尾在服务端另有一层封顶)。 */
1432
1541
  const SESSION_DISPLAY_LIMIT = 20;
1542
+ /**
1543
+ * Tab 定义(顺序即渲染顺序):概览=主数字/预算/KPI/热力图,趋势=趋势图/每轮费用,
1544
+ * 明细=厂商计费与订阅,统计=工作区/会话明细,费率=模型单价表。导出供测试断言
1545
+ * tab 与文案 key 对齐、decor 锚点落在正确分区。
1546
+ */
1547
+ const DASHBOARD_TABS = [
1548
+ {
1549
+ id: "overview",
1550
+ labelKey: "billing.tabOverview"
1551
+ },
1552
+ {
1553
+ id: "trends",
1554
+ labelKey: "billing.tabTrends"
1555
+ },
1556
+ {
1557
+ id: "providers",
1558
+ labelKey: "billing.tabProviders"
1559
+ },
1560
+ {
1561
+ id: "details",
1562
+ labelKey: "billing.tabDetails"
1563
+ },
1564
+ {
1565
+ id: "pricing",
1566
+ labelKey: "billing.tabPricing"
1567
+ }
1568
+ ];
1433
1569
  /** 项目名取 cwd 的末级目录;无 cwd 时由调用方回退为 em dash。 */
1434
1570
  function projectName(cwd) {
1435
1571
  if (cwd === void 0) return void 0;
1436
1572
  return cwd.split(/[\\/]/).filter(Boolean).pop() ?? cwd;
1437
1573
  }
1574
+ /** 预算提醒档位(百分比):跨档时桌面通知,每档每天最多一次。 */
1575
+ const BUDGET_ALERT_TIERS = [
1576
+ 50,
1577
+ 80,
1578
+ 100
1579
+ ];
1438
1580
  /** Idle health state before the probe settles. */
1439
1581
  const IDLE_HEALTH = {
1440
1582
  checked: false,
@@ -1589,6 +1731,57 @@ window.__ModuleLoader__.load({
1589
1731
  if (dates.length === 0) return 0;
1590
1732
  return dates.reduce((sum, d) => sum + (byDay[d]?.cost ?? 0), 0) / dates.length;
1591
1733
  }
1734
+ /**
1735
+ * 本月预计总花费:按本月已有记录的平均日消耗 × 本月天数外推;无本月记录时
1736
+ * 回退为最近 7 天日均 × 本月天数;无任何记录时返回 0(调用方不展示)。
1737
+ * 导出供测试:纯函数,不依赖组件。
1738
+ * @param byDay - 按日费用表。
1739
+ * @param monthPrefix - 本月前缀(YYYY-MM)。
1740
+ * @param today - 今日日期戳(YYYY-MM-DD)。
1741
+ * @returns 本月预计花费(人民币元);无数据时为 0。
1742
+ */
1743
+ function projectMonthCost(byDay, monthPrefix, today) {
1744
+ const dates = Object.keys(byDay).filter((d) => d.startsWith(monthPrefix));
1745
+ const monthLen = new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 0).getDate();
1746
+ const avg = dates.length > 0 ? dates.reduce((sum, d) => sum + (byDay[d]?.cost ?? 0), 0) / dates.length : dailyBurnRate(byDay, today);
1747
+ if (avg <= 0) return 0;
1748
+ return avg * monthLen;
1749
+ }
1750
+ /**
1751
+ * 峰谷时段费用分摊:按每轮的起始时刻(北京时间高峰 9-12 / 14-18)把费用
1752
+ * 归入高峰 / 空闲两档。导出供测试:纯函数。
1753
+ * @param turns - 每轮费用行(需带 startedAt 与 cost)。
1754
+ * @returns 两档费用合计(人民币元)。
1755
+ */
1756
+ function peakOffpeakCost(turns) {
1757
+ let peak = 0;
1758
+ let offPeak = 0;
1759
+ for (const turn of turns) if (tierAt(turn.startedAt) === "peak") peak += turn.cost;
1760
+ else offPeak += turn.cost;
1761
+ return {
1762
+ peak,
1763
+ offPeak
1764
+ };
1765
+ }
1766
+ /**
1767
+ * 近 7 天费用序列(含今天,缺日补 0):触发卡 hover 速览的迷你柱数据源。
1768
+ * 导出供测试:纯函数(日期取本地时区)。
1769
+ * @param byDay - 按日费用表。
1770
+ * @returns 7 个 `{ date, cost }`,最旧在前。
1771
+ */
1772
+ function lastSevenDays(byDay) {
1773
+ const out = [];
1774
+ for (let offset = 6; offset >= 0; offset -= 1) {
1775
+ const day = /* @__PURE__ */ new Date();
1776
+ day.setDate(day.getDate() - offset);
1777
+ const stamp = localDayStamp(day.getTime());
1778
+ out.push({
1779
+ date: stamp,
1780
+ cost: byDay[stamp]?.cost ?? 0
1781
+ });
1782
+ }
1783
+ return out;
1784
+ }
1592
1785
  /** Resolve one provider's dot state: green when live, red when failed, gray when unknown. */
1593
1786
  function providerDot(health, provider) {
1594
1787
  if (!health.checked) return UsageBilling_module_css_default.healthIdle;
@@ -1617,7 +1810,7 @@ window.__ModuleLoader__.load({
1617
1810
  }
1618
1811
  }
1619
1812
  /** Path to the usage-stats endpoint served by this plugin's node half. */
1620
- const USAGE_STATS_PATH = "/api/billing/usage-stats";
1813
+ const USAGE_STATS_PATH$1 = "/api/billing/usage-stats";
1621
1814
  /** Path to the live-pricing endpoint served by this plugin's node half. */
1622
1815
  const PRICING_PATH = "/api/billing/pricing";
1623
1816
  /** Path to the account-balance endpoint served by this plugin's node half. */
@@ -1674,7 +1867,7 @@ window.__ModuleLoader__.load({
1674
1867
  /** Try to load stats from the server; returns null when no valid JSON stats are served. */
1675
1868
  async function loadUsageStats() {
1676
1869
  try {
1677
- const response = await fetch(USAGE_STATS_PATH);
1870
+ const response = await fetch(USAGE_STATS_PATH$1);
1678
1871
  if (!response.ok) return null;
1679
1872
  const text = await response.text();
1680
1873
  const parsed = JSON.parse(text);
@@ -1690,7 +1883,8 @@ window.__ModuleLoader__.load({
1690
1883
  ...typeof candidate.lowBalanceThreshold === "number" ? { lowBalanceThreshold: candidate.lowBalanceThreshold } : {},
1691
1884
  ...Array.isArray(candidate.bySession) ? { bySession: candidate.bySession } : {},
1692
1885
  ...Array.isArray(candidate.byTurn) ? { byTurn: candidate.byTurn } : {},
1693
- ...Array.isArray(candidate.byWorkspace) ? { byWorkspace: candidate.byWorkspace } : {}
1886
+ ...Array.isArray(candidate.byWorkspace) ? { byWorkspace: candidate.byWorkspace } : {},
1887
+ ...candidate.byRole !== null && typeof candidate.byRole === "object" ? { byRole: candidate.byRole } : {}
1694
1888
  };
1695
1889
  } catch {
1696
1890
  return null;
@@ -1761,7 +1955,7 @@ window.__ModuleLoader__.load({
1761
1955
  * @param props - framework props plus `wide` column state.
1762
1956
  */
1763
1957
  function UsageBillingTrigger(props) {
1764
- const { wide, t, onOpen, monthCost, todayCost } = props;
1958
+ const { wide, t, onOpen, monthCost, todayCost, weekCost, days } = props;
1765
1959
  const cardIcon = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1766
1960
  viewBox: "0 0 24 24",
1767
1961
  fill: "none",
@@ -1793,42 +1987,91 @@ window.__ModuleLoader__.load({
1793
1987
  title: `${t("billing.title")} · ${formatMoney(monthCost)}`,
1794
1988
  children: cardIcon
1795
1989
  });
1796
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1797
- type: "button",
1798
- className: UsageBilling_module_css_default.trigger,
1799
- "data-testid": "billing-trigger",
1800
- onClick: onOpen,
1801
- title: `${t("billing.title")} · 本月 ${formatMoney(monthCost)}`,
1802
- children: [
1803
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1804
- className: UsageBilling_module_css_default.triggerIcon,
1805
- "data-testid": "billing-trigger-icon",
1806
- children: cardIcon
1807
- }),
1808
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1809
- className: UsageBilling_module_css_default.triggerToday,
1810
- "data-testid": "billing-trigger-today",
1811
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1812
- className: UsageBilling_module_css_default.triggerMeta,
1813
- children: "今日"
1814
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1815
- className: UsageBilling_module_css_default.triggerAmount,
1816
- children: formatMoney(todayCost)
1817
- })]
1818
- }),
1819
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: UsageBilling_module_css_default.triggerDivider }),
1820
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1821
- className: UsageBilling_module_css_default.triggerMonth,
1822
- "data-testid": "billing-trigger-month",
1823
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1824
- className: UsageBilling_module_css_default.triggerMeta,
1825
- children: "当月"
1826
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1827
- className: UsageBilling_module_css_default.triggerAmountSub,
1828
- children: formatMoney(monthCost)
1829
- })]
1830
- })
1831
- ]
1990
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1991
+ className: UsageBilling_module_css_default.triggerWrap,
1992
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1993
+ type: "button",
1994
+ className: UsageBilling_module_css_default.trigger,
1995
+ "data-testid": "billing-trigger",
1996
+ onClick: onOpen,
1997
+ title: `${t("billing.title")} · 本月 ${formatMoney(monthCost)}`,
1998
+ children: [
1999
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2000
+ className: UsageBilling_module_css_default.triggerIcon,
2001
+ "data-testid": "billing-trigger-icon",
2002
+ children: cardIcon
2003
+ }),
2004
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2005
+ className: UsageBilling_module_css_default.triggerToday,
2006
+ "data-testid": "billing-trigger-today",
2007
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2008
+ className: UsageBilling_module_css_default.triggerMeta,
2009
+ children: "今日"
2010
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2011
+ className: UsageBilling_module_css_default.triggerAmount,
2012
+ children: formatMoney(todayCost)
2013
+ })]
2014
+ }),
2015
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: UsageBilling_module_css_default.triggerDivider }),
2016
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2017
+ className: UsageBilling_module_css_default.triggerMonth,
2018
+ "data-testid": "billing-trigger-month",
2019
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2020
+ className: UsageBilling_module_css_default.triggerMeta,
2021
+ children: "当月"
2022
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2023
+ className: UsageBilling_module_css_default.triggerAmountSub,
2024
+ children: formatMoney(monthCost)
2025
+ })]
2026
+ })
2027
+ ]
2028
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2029
+ className: UsageBilling_module_css_default.triggerPop,
2030
+ "data-testid": "billing-trigger-pop",
2031
+ "aria-hidden": "true",
2032
+ children: [
2033
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2034
+ className: UsageBilling_module_css_default.triggerPopRow,
2035
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2036
+ className: UsageBilling_module_css_default.triggerPopLabel,
2037
+ children: t("billing.todayCost")
2038
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2039
+ className: UsageBilling_module_css_default.triggerPopValue,
2040
+ children: formatMoney(todayCost)
2041
+ })]
2042
+ }),
2043
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2044
+ className: UsageBilling_module_css_default.triggerPopRow,
2045
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2046
+ className: UsageBilling_module_css_default.triggerPopLabel,
2047
+ children: t("billing.weekCost")
2048
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2049
+ className: UsageBilling_module_css_default.triggerPopValue,
2050
+ children: formatMoney(weekCost)
2051
+ })]
2052
+ }),
2053
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2054
+ className: UsageBilling_module_css_default.triggerPopRow,
2055
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2056
+ className: UsageBilling_module_css_default.triggerPopLabel,
2057
+ children: t("billing.monthCost")
2058
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2059
+ className: UsageBilling_module_css_default.triggerPopValue,
2060
+ children: formatMoney(monthCost)
2061
+ })]
2062
+ }),
2063
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2064
+ className: UsageBilling_module_css_default.triggerPopBars,
2065
+ children: (() => {
2066
+ const max = Math.max(...days.map((d) => d.cost), 0);
2067
+ return days.map((d) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2068
+ className: UsageBilling_module_css_default.triggerPopBar,
2069
+ style: { height: `${max > 0 ? 4 + d.cost / max * 18 : 4}px` }
2070
+ }, d.date));
2071
+ })()
2072
+ })
2073
+ ]
2074
+ })]
1832
2075
  });
1833
2076
  }
1834
2077
  /**
@@ -1837,15 +2080,38 @@ window.__ModuleLoader__.load({
1837
2080
  */
1838
2081
  function BillingDashboard({ stats, t, onClose, health, balances, quotas, currency, onCurrency, turns, renderSlot, budgetEnabled, budgetAmount, onToggleBudget, onBudgetAmount }) {
1839
2082
  const { total, byModel, byDay } = stats;
1840
- const [pricingOpen, setPricingOpen] = (0, react.useState)(false);
1841
- const [sessionsOpen, setSessionsOpen] = (0, react.useState)(false);
1842
- const [roundsOpen, setRoundsOpen] = (0, react.useState)(false);
1843
- const [heatmapOpen, setHeatmapOpen] = (0, react.useState)(true);
1844
- const [workspacesOpen, setWorkspacesOpen] = (0, react.useState)(false);
2083
+ const [tab, setTab] = (0, react.useState)("overview");
1845
2084
  const [trendDays, setTrendDays] = (0, react.useState)(7);
1846
2085
  const rateInfo = getRateInfo();
1847
2086
  const money = (cny) => formatMoney(currency === "usd" ? cnyToUsd(cny) : cny, currency);
1848
2087
  const roundFlags = (0, react.useMemo)(() => flagAnomalies([...turns].reverse()), [turns]);
2088
+ const peakShare = (0, react.useMemo)(() => peakOffpeakCost(turns), [turns]);
2089
+ const roleRows = (0, react.useMemo)(() => {
2090
+ const role = stats.byRole;
2091
+ if (role === void 0) return [];
2092
+ const total = role.user + role.assistant + role.tool;
2093
+ if (total <= 0) return [];
2094
+ return [
2095
+ {
2096
+ label: t("billing.roleUser"),
2097
+ value: role.user,
2098
+ seg: UsageBilling_module_css_default.shareSegUser
2099
+ },
2100
+ {
2101
+ label: t("billing.roleAssistant"),
2102
+ value: role.assistant,
2103
+ seg: UsageBilling_module_css_default.shareSegAssistant
2104
+ },
2105
+ {
2106
+ label: t("billing.roleTool"),
2107
+ value: role.tool,
2108
+ seg: UsageBilling_module_css_default.shareSegTool
2109
+ }
2110
+ ].map((row) => ({
2111
+ ...row,
2112
+ pct: row.value / total * 100
2113
+ }));
2114
+ }, [stats.byRole, t]);
1849
2115
  const dailyBurn = dailyBurnRate(byDay, localDayStamp());
1850
2116
  const balanceFor = (provider) => balances.find((balance) => normalizeProvider(balance.provider) === normalizeProvider(provider));
1851
2117
  const renderBalance = (balance) => {
@@ -1882,6 +2148,11 @@ window.__ModuleLoader__.load({
1882
2148
  const monthCost = dates.reduce((sum, d) => sum + (d.startsWith(monthPrefix) ? byDay[d]?.cost ?? 0 : 0), 0);
1883
2149
  const monthCalls = dates.reduce((sum, d) => sum + (d.startsWith(monthPrefix) ? byDay[d]?.calls ?? 0 : 0), 0);
1884
2150
  const yearCost = dates.reduce((sum, d) => sum + (d.startsWith(yearPrefix) ? byDay[d]?.cost ?? 0 : 0), 0);
2151
+ const monthCostProjected = (0, react.useMemo)(() => projectMonthCost(byDay, monthPrefix, today), [
2152
+ byDay,
2153
+ monthPrefix,
2154
+ today
2155
+ ]);
1885
2156
  const trendDates = (0, react.useMemo)(() => {
1886
2157
  const out = [];
1887
2158
  for (let offset = trendDays - 1; offset >= 0; offset -= 1) {
@@ -1935,7 +2206,8 @@ window.__ModuleLoader__.load({
1935
2206
  estimated: computeCost(entry, buckets),
1936
2207
  plan: data.plan === true,
1937
2208
  ...data.cost > 0 ? { actual: data.cost } : {},
1938
- uncatalogued
2209
+ uncatalogued,
2210
+ estimatedPricing: entry.estimated === true
1939
2211
  };
1940
2212
  }).sort((a, b) => (b.actual ?? b.estimated) - (a.actual ?? a.estimated)).map((row, index) => ({
1941
2213
  ...row,
@@ -1992,873 +2264,1013 @@ window.__ModuleLoader__.load({
1992
2264
  onClose,
1993
2265
  title: t("billing.title"),
1994
2266
  headless: true,
1995
- className: UsageBilling_module_css_default.dashboardModal ?? "",
2267
+ className: clsx(UsageBilling_module_css_default.dashboardModal, "dsh-billing-modal"),
1996
2268
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1997
2269
  className: UsageBilling_module_css_default.dashboard,
1998
2270
  "data-testid": "billing-dashboard",
1999
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2000
- className: UsageBilling_module_css_default.dashboardHead,
2001
- "data-testid": "billing-dashboard-head",
2002
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
2003
- renderSlot("billing.dashboard.decor", { position: "head" }),
2004
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2005
- className: UsageBilling_module_css_default.headTitleRow,
2006
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
2007
- className: UsageBilling_module_css_default.dashboardTitle,
2008
- children: t("billing.title")
2009
- }), renderSlot("billing.dashboard.decor", { position: "headTitle" })]
2010
- }),
2011
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2012
- className: UsageBilling_module_css_default.dashboardSubtitle,
2013
- children: [
2014
- t("billing.lastUpdated"),
2015
- " ",
2016
- latestDate
2017
- ]
2018
- })
2019
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2020
- className: UsageBilling_module_css_default.dashboardRight,
2021
- children: [
2022
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2023
- className: UsageBilling_module_css_default.currencyToggle,
2024
- role: "group",
2025
- "aria-label": t("billing.currency"),
2026
- children: ["cny", "usd"].map((unit) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2027
- type: "button",
2028
- className: clsx(UsageBilling_module_css_default.currencyButton, currency === unit && UsageBilling_module_css_default.currencyButtonActive),
2029
- "aria-pressed": currency === unit,
2030
- "data-testid": `billing-currency-${unit}`,
2031
- title: unit === "cny" ? t("billing.currencyCny") : t("billing.currencyUsd"),
2032
- onClick: () => {
2033
- onCurrency(unit);
2034
- },
2035
- children: unit === "cny" ? "¥" : "$"
2036
- }, unit))
2037
- }),
2038
- health.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2039
- className: clsx(UsageBilling_module_css_default.healthBadge, health.available ? UsageBilling_module_css_default.healthBadgeOk : UsageBilling_module_css_default.healthBadgeBad),
2040
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2041
- className: clsx(UsageBilling_module_css_default.healthDot, health.available ? UsageBilling_module_css_default.healthOk : UsageBilling_module_css_default.healthBad),
2042
- "aria-hidden": "true"
2043
- }), health.available ? `${health.models} 模型可用${health.failures > 0 ? ` · ${health.failures} 厂商失效` : ""}` : `${health.failures} 厂商不可用`]
2271
+ children: [
2272
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2273
+ className: UsageBilling_module_css_default.dashboardHead,
2274
+ "data-testid": "billing-dashboard-head",
2275
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
2276
+ renderSlot("billing.dashboard.decor", { position: "head" }),
2277
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2278
+ className: UsageBilling_module_css_default.headTitleRow,
2279
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
2280
+ className: UsageBilling_module_css_default.dashboardTitle,
2281
+ children: t("billing.title")
2282
+ }), renderSlot("billing.dashboard.decor", { position: "headTitle" })]
2044
2283
  }),
2045
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2046
- type: "button",
2047
- className: UsageBilling_module_css_default.closeButton,
2048
- "aria-label": t("billing.close"),
2049
- "data-testid": "billing-close",
2050
- onClick: onClose,
2051
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
2052
- viewBox: "0 0 24 24",
2053
- fill: "none",
2054
- stroke: "currentColor",
2055
- "aria-hidden": "true",
2056
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 6 12 12" })]
2057
- })
2284
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2285
+ className: UsageBilling_module_css_default.dashboardSubtitle,
2286
+ children: [
2287
+ t("billing.lastUpdated"),
2288
+ " ",
2289
+ latestDate
2290
+ ]
2058
2291
  })
2059
- ]
2060
- })]
2061
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2062
- className: UsageBilling_module_css_default.dashboardBody,
2063
- children: [
2064
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2065
- className: UsageBilling_module_css_default.hero,
2066
- "data-testid": "billing-hero",
2292
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2293
+ className: UsageBilling_module_css_default.dashboardRight,
2067
2294
  children: [
2068
- renderSlot("billing.dashboard.decor", { position: "hero" }),
2069
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2070
- className: UsageBilling_module_css_default.heroMain,
2071
- children: [
2072
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2073
- className: UsageBilling_module_css_default.heroLabel,
2074
- children: t("billing.monthCost")
2075
- }),
2076
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2077
- className: UsageBilling_module_css_default.heroValue,
2078
- children: money(monthCost)
2079
- }),
2080
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2081
- className: UsageBilling_module_css_default.heroMeta,
2082
- children: [
2083
- monthCalls.toLocaleString(),
2084
- " ",
2085
- t("billing.calls")
2086
- ]
2087
- })
2088
- ]
2295
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2296
+ className: UsageBilling_module_css_default.currencyToggle,
2297
+ role: "group",
2298
+ "aria-label": t("billing.currency"),
2299
+ children: ["cny", "usd"].map((unit) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2300
+ type: "button",
2301
+ className: clsx(UsageBilling_module_css_default.currencyButton, currency === unit && UsageBilling_module_css_default.currencyButtonActive),
2302
+ "aria-pressed": currency === unit,
2303
+ "data-testid": `billing-currency-${unit}`,
2304
+ title: unit === "cny" ? t("billing.currencyCny") : t("billing.currencyUsd"),
2305
+ onClick: () => {
2306
+ onCurrency(unit);
2307
+ },
2308
+ children: unit === "cny" ? "¥" : "$"
2309
+ }, unit))
2089
2310
  }),
2090
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2091
- className: UsageBilling_module_css_default.heroSide,
2092
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2093
- className: UsageBilling_module_css_default.heroSideItem,
2094
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2095
- className: UsageBilling_module_css_default.heroSideLabel,
2096
- children: t("billing.yearCost")
2097
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2098
- className: UsageBilling_module_css_default.heroSideValue,
2099
- children: money(yearCost)
2100
- })]
2101
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2102
- className: UsageBilling_module_css_default.heroSideItem,
2103
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2104
- className: UsageBilling_module_css_default.heroSideLabel,
2105
- children: t("billing.todayCost")
2106
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2107
- className: UsageBilling_module_css_default.heroSideValue,
2108
- children: [money(todayCost), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2109
- className: clsx(UsageBilling_module_css_default.delta, deltaPct >= 0 ? UsageBilling_module_css_default.deltaUp : UsageBilling_module_css_default.deltaDown),
2311
+ health.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2312
+ className: clsx(UsageBilling_module_css_default.healthBadge, health.available ? UsageBilling_module_css_default.healthBadgeOk : UsageBilling_module_css_default.healthBadgeBad),
2313
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2314
+ className: clsx(UsageBilling_module_css_default.healthDot, health.available ? UsageBilling_module_css_default.healthOk : UsageBilling_module_css_default.healthBad),
2315
+ "aria-hidden": "true"
2316
+ }), health.available ? `${health.models} 模型可用${health.failures > 0 ? ` · ${health.failures} 厂商失效` : ""}` : `${health.failures} 厂商不可用`]
2317
+ }),
2318
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2319
+ type: "button",
2320
+ className: UsageBilling_module_css_default.closeButton,
2321
+ "aria-label": t("billing.close"),
2322
+ "data-testid": "billing-close",
2323
+ onClick: onClose,
2324
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
2325
+ viewBox: "0 0 24 24",
2326
+ fill: "none",
2327
+ stroke: "currentColor",
2328
+ "aria-hidden": "true",
2329
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 6 12 12" })]
2330
+ })
2331
+ })
2332
+ ]
2333
+ })]
2334
+ }),
2335
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
2336
+ className: UsageBilling_module_css_default.tabNav,
2337
+ "data-testid": "billing-tab-nav",
2338
+ role: "tablist",
2339
+ "aria-label": t("billing.title"),
2340
+ children: DASHBOARD_TABS.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2341
+ type: "button",
2342
+ role: "tab",
2343
+ "aria-selected": tab === item.id,
2344
+ className: clsx(UsageBilling_module_css_default.tabButton, tab === item.id && UsageBilling_module_css_default.tabButtonActive),
2345
+ "data-testid": `billing-tab-${item.id}`,
2346
+ onClick: () => {
2347
+ setTab(item.id);
2348
+ },
2349
+ children: t(item.labelKey)
2350
+ }, item.id))
2351
+ }),
2352
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2353
+ className: UsageBilling_module_css_default.dashboardBody,
2354
+ children: [
2355
+ tab === "overview" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2356
+ className: UsageBilling_module_css_default.tabPanel,
2357
+ "data-testid": "billing-tab-panel-overview",
2358
+ children: [
2359
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2360
+ className: UsageBilling_module_css_default.hero,
2361
+ "data-testid": "billing-hero",
2362
+ children: [
2363
+ renderSlot("billing.dashboard.decor", { position: "hero" }),
2364
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2365
+ className: UsageBilling_module_css_default.heroMain,
2366
+ children: [
2367
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2368
+ className: UsageBilling_module_css_default.heroLabel,
2369
+ children: t("billing.monthCost")
2370
+ }),
2371
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2372
+ className: UsageBilling_module_css_default.heroValue,
2373
+ children: money(monthCost)
2374
+ }),
2375
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2376
+ className: UsageBilling_module_css_default.heroMeta,
2377
+ children: [
2378
+ monthCalls.toLocaleString(),
2379
+ " ",
2380
+ t("billing.calls")
2381
+ ]
2382
+ })
2383
+ ]
2384
+ }),
2385
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2386
+ className: UsageBilling_module_css_default.heroSide,
2110
2387
  children: [
2111
- deltaPct >= 0 ? "" : "▼",
2112
- " ",
2113
- Math.abs(deltaPct).toFixed(1),
2114
- "%"
2388
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2389
+ className: UsageBilling_module_css_default.heroSideItem,
2390
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2391
+ className: UsageBilling_module_css_default.heroSideLabel,
2392
+ children: t("billing.yearCost")
2393
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2394
+ className: UsageBilling_module_css_default.heroSideValue,
2395
+ children: money(yearCost)
2396
+ })]
2397
+ }),
2398
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2399
+ className: UsageBilling_module_css_default.heroSideItem,
2400
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2401
+ className: UsageBilling_module_css_default.heroSideLabel,
2402
+ children: t("billing.todayCost")
2403
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2404
+ className: UsageBilling_module_css_default.heroSideValue,
2405
+ children: [money(todayCost), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2406
+ className: clsx(UsageBilling_module_css_default.delta, deltaPct >= 0 ? UsageBilling_module_css_default.deltaUp : UsageBilling_module_css_default.deltaDown),
2407
+ children: [
2408
+ deltaPct >= 0 ? "▲" : "▼",
2409
+ " ",
2410
+ Math.abs(deltaPct).toFixed(1),
2411
+ "%"
2412
+ ]
2413
+ })]
2414
+ })]
2415
+ }),
2416
+ monthCostProjected > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2417
+ className: UsageBilling_module_css_default.heroSideItem,
2418
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2419
+ className: UsageBilling_module_css_default.heroSideLabel,
2420
+ children: t("billing.monthProjected")
2421
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2422
+ className: UsageBilling_module_css_default.heroSideValue,
2423
+ children: money(monthCostProjected)
2424
+ })]
2425
+ })
2115
2426
  ]
2116
- })]
2117
- })]
2118
- })]
2119
- })
2120
- ]
2121
- }),
2122
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2123
- className: UsageBilling_module_css_default.budget,
2124
- "data-testid": "billing-budget",
2125
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2126
- className: UsageBilling_module_css_default.budgetHead,
2127
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2128
- className: UsageBilling_module_css_default.budgetLabel,
2129
- children: t("billing.budget")
2130
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2131
- className: UsageBilling_module_css_default.budgetControls,
2132
- children: [
2133
- budgetEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2134
- className: UsageBilling_module_css_default.budgetInputWrap,
2135
- "data-testid": "billing-budget-input-wrap",
2427
+ })
2428
+ ]
2429
+ }),
2430
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2431
+ className: UsageBilling_module_css_default.budget,
2432
+ "data-testid": "billing-budget",
2433
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2434
+ className: UsageBilling_module_css_default.budgetHead,
2136
2435
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2137
- className: UsageBilling_module_css_default.budgetUnit,
2138
- "aria-hidden": "true",
2139
- children: "¥"
2140
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2141
- className: UsageBilling_module_css_default.budgetInput,
2142
- "data-testid": "billing-budget-input",
2143
- type: "number",
2144
- min: 0,
2145
- step: 1,
2146
- value: budgetAmount === 0 ? "" : budgetAmount,
2147
- placeholder: stats.budget !== void 0 ? String(stats.budget) : "0",
2148
- "aria-label": `${t("billing.budget")}(元)`,
2149
- title: `${t("billing.budget")}(元)`,
2150
- onChange: (e) => {
2151
- onBudgetAmount(e.target.valueAsNumber);
2152
- }
2436
+ className: UsageBilling_module_css_default.budgetLabel,
2437
+ children: t("billing.budget")
2438
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2439
+ className: UsageBilling_module_css_default.budgetControls,
2440
+ children: [
2441
+ budgetEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2442
+ className: UsageBilling_module_css_default.budgetInputWrap,
2443
+ "data-testid": "billing-budget-input-wrap",
2444
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2445
+ className: UsageBilling_module_css_default.budgetUnit,
2446
+ "aria-hidden": "true",
2447
+ children: "¥"
2448
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2449
+ className: UsageBilling_module_css_default.budgetInput,
2450
+ "data-testid": "billing-budget-input",
2451
+ type: "number",
2452
+ min: 0,
2453
+ step: 1,
2454
+ value: budgetAmount === 0 ? "" : budgetAmount,
2455
+ placeholder: stats.budget !== void 0 ? String(stats.budget) : "0",
2456
+ "aria-label": `${t("billing.budget")}(元)`,
2457
+ title: `${t("billing.budget")}(元)`,
2458
+ onChange: (e) => {
2459
+ onBudgetAmount(e.target.valueAsNumber);
2460
+ }
2461
+ })]
2462
+ }),
2463
+ budgetEnabled && budgetAmount > 0 && (() => {
2464
+ const pct = monthCost / budgetAmount * 100;
2465
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2466
+ className: UsageBilling_module_css_default.budgetValue,
2467
+ "data-testid": "billing-budget-value",
2468
+ children: [
2469
+ money(monthCost),
2470
+ " / ",
2471
+ money(budgetAmount),
2472
+ " · ",
2473
+ pct.toFixed(1),
2474
+ "%"
2475
+ ]
2476
+ });
2477
+ })(),
2478
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2479
+ type: "button",
2480
+ role: "switch",
2481
+ "aria-checked": budgetEnabled,
2482
+ "aria-label": t("billing.budget"),
2483
+ "data-testid": "billing-budget-toggle",
2484
+ className: clsx(UsageBilling_module_css_default.switch, budgetEnabled && UsageBilling_module_css_default.switchOn),
2485
+ onClick: onToggleBudget,
2486
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: UsageBilling_module_css_default.switchKnob })
2487
+ })
2488
+ ]
2153
2489
  })]
2154
- }),
2155
- budgetEnabled && budgetAmount > 0 && (() => {
2490
+ }), budgetEnabled && budgetAmount > 0 && (() => {
2156
2491
  const pct = monthCost / budgetAmount * 100;
2157
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2158
- className: UsageBilling_module_css_default.budgetValue,
2159
- "data-testid": "billing-budget-value",
2492
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2493
+ className: UsageBilling_module_css_default.budgetTrack,
2494
+ "data-testid": "billing-budget-track",
2495
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2496
+ className: clsx(UsageBilling_module_css_default.budgetFill, pct >= 100 && UsageBilling_module_css_default.budgetFillOver, pct >= 80 && pct < 100 && UsageBilling_module_css_default.budgetFillWarn),
2497
+ style: { width: `${Math.min(pct, 100)}%` }
2498
+ })
2499
+ });
2500
+ })()]
2501
+ }),
2502
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2503
+ className: UsageBilling_module_css_default.kpiGrid,
2504
+ "data-testid": "billing-kpi-grid",
2505
+ children: [
2506
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2507
+ className: UsageBilling_module_css_default.kpiTile,
2508
+ "data-testid": "billing-kpi-tile",
2160
2509
  children: [
2161
- money(monthCost),
2162
- " / ",
2163
- money(budgetAmount),
2164
- " · ",
2165
- pct.toFixed(1),
2166
- "%"
2510
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2511
+ className: UsageBilling_module_css_default.kpiLabel,
2512
+ children: t("billing.cacheHitRate")
2513
+ }),
2514
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2515
+ className: clsx(UsageBilling_module_css_default.kpiValue, UsageBilling_module_css_default.kpiGreen),
2516
+ children: formatPercent(cacheHitRate)
2517
+ }),
2518
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2519
+ className: UsageBilling_module_css_default.kpiDetail,
2520
+ children: [
2521
+ formatTokens(total.cacheHit),
2522
+ " / ",
2523
+ formatTokens(total.cacheHit + total.cacheMiss)
2524
+ ]
2525
+ })
2167
2526
  ]
2168
- });
2169
- })(),
2170
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2171
- type: "button",
2172
- role: "switch",
2173
- "aria-checked": budgetEnabled,
2174
- "aria-label": t("billing.budget"),
2175
- "data-testid": "billing-budget-toggle",
2176
- className: clsx(UsageBilling_module_css_default.switch, budgetEnabled && UsageBilling_module_css_default.switchOn),
2177
- onClick: onToggleBudget,
2178
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: UsageBilling_module_css_default.switchKnob })
2179
- })
2180
- ]
2181
- })]
2182
- }), budgetEnabled && budgetAmount > 0 && (() => {
2183
- const pct = monthCost / budgetAmount * 100;
2184
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2185
- className: UsageBilling_module_css_default.budgetTrack,
2186
- "data-testid": "billing-budget-track",
2187
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2188
- className: clsx(UsageBilling_module_css_default.budgetFill, pct >= 100 && UsageBilling_module_css_default.budgetFillOver),
2189
- style: { width: `${Math.min(pct, 100)}%` }
2527
+ }),
2528
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2529
+ className: UsageBilling_module_css_default.kpiTile,
2530
+ children: [
2531
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2532
+ className: UsageBilling_module_css_default.kpiLabel,
2533
+ children: t("billing.tokens")
2534
+ }),
2535
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2536
+ className: UsageBilling_module_css_default.kpiValue,
2537
+ children: formatTokens(total.input + total.output)
2538
+ }),
2539
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2540
+ className: UsageBilling_module_css_default.kpiDetail,
2541
+ children: [
2542
+ t("billing.inputTokens"),
2543
+ " ",
2544
+ formatTokens(total.input),
2545
+ " · ",
2546
+ t("billing.outputTokens"),
2547
+ " ",
2548
+ formatTokens(total.output)
2549
+ ]
2550
+ })
2551
+ ]
2552
+ }),
2553
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2554
+ className: UsageBilling_module_css_default.kpiTile,
2555
+ children: [
2556
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2557
+ className: UsageBilling_module_css_default.kpiLabel,
2558
+ children: t("billing.avgCost")
2559
+ }),
2560
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2561
+ className: UsageBilling_module_css_default.kpiValue,
2562
+ children: money(avgPerCall)
2563
+ }),
2564
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2565
+ className: UsageBilling_module_css_default.kpiDetail,
2566
+ children: [
2567
+ t("billing.calls"),
2568
+ " ",
2569
+ total.calls.toLocaleString()
2570
+ ]
2571
+ })
2572
+ ]
2573
+ }),
2574
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2575
+ className: UsageBilling_module_css_default.kpiTile,
2576
+ children: [
2577
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2578
+ className: UsageBilling_module_css_default.kpiLabel,
2579
+ children: t("billing.calls")
2580
+ }),
2581
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2582
+ className: UsageBilling_module_css_default.kpiValue,
2583
+ children: total.calls.toLocaleString()
2584
+ }),
2585
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2586
+ className: UsageBilling_module_css_default.kpiDetail,
2587
+ children: [
2588
+ modelRows.length,
2589
+ " ",
2590
+ t("billing.models")
2591
+ ]
2592
+ })
2593
+ ]
2594
+ })
2595
+ ]
2596
+ }),
2597
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2598
+ className: UsageBilling_module_css_default.panel,
2599
+ "data-testid": "billing-panel-heatmap",
2600
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2601
+ className: UsageBilling_module_css_default.panelHead,
2602
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2603
+ className: UsageBilling_module_css_default.panelTitle,
2604
+ children: t("billing.heatmap")
2605
+ })
2606
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageHeatmap, {
2607
+ days: heatmapDays,
2608
+ currency,
2609
+ t
2610
+ })]
2190
2611
  })
2191
- });
2192
- })()]
2193
- }),
2194
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2195
- className: UsageBilling_module_css_default.kpiGrid,
2196
- "data-testid": "billing-kpi-grid",
2197
- children: [
2198
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2199
- className: UsageBilling_module_css_default.kpiTile,
2200
- "data-testid": "billing-kpi-tile",
2201
- children: [
2202
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2203
- className: UsageBilling_module_css_default.kpiLabel,
2204
- children: t("billing.cacheHitRate")
2205
- }),
2206
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2207
- className: clsx(UsageBilling_module_css_default.kpiValue, UsageBilling_module_css_default.kpiGreen),
2208
- children: formatPercent(cacheHitRate)
2209
- }),
2210
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2211
- className: UsageBilling_module_css_default.kpiDetail,
2212
- children: [
2213
- formatTokens(total.cacheHit),
2214
- " / ",
2215
- formatTokens(total.cacheHit + total.cacheMiss)
2216
- ]
2217
- })
2218
- ]
2219
- }),
2220
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2221
- className: UsageBilling_module_css_default.kpiTile,
2222
- children: [
2223
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2224
- className: UsageBilling_module_css_default.kpiLabel,
2225
- children: t("billing.tokens")
2226
- }),
2227
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2228
- className: UsageBilling_module_css_default.kpiValue,
2229
- children: formatTokens(total.input + total.output)
2230
- }),
2231
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2232
- className: UsageBilling_module_css_default.kpiDetail,
2233
- children: [
2234
- t("billing.inputTokens"),
2235
- " ",
2236
- formatTokens(total.input),
2237
- " · ",
2238
- t("billing.outputTokens"),
2239
- " ",
2240
- formatTokens(total.output)
2241
- ]
2242
- })
2243
- ]
2244
- }),
2245
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2246
- className: UsageBilling_module_css_default.kpiTile,
2247
- children: [
2248
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2249
- className: UsageBilling_module_css_default.kpiLabel,
2250
- children: t("billing.avgCost")
2251
- }),
2252
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2253
- className: UsageBilling_module_css_default.kpiValue,
2254
- children: money(avgPerCall)
2255
- }),
2256
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2257
- className: UsageBilling_module_css_default.kpiDetail,
2258
- children: [
2259
- t("billing.calls"),
2260
- " ",
2261
- total.calls.toLocaleString()
2262
- ]
2263
- })
2264
- ]
2265
- }),
2266
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2267
- className: UsageBilling_module_css_default.kpiTile,
2268
- children: [
2269
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2270
- className: UsageBilling_module_css_default.kpiLabel,
2271
- children: t("billing.calls")
2272
- }),
2273
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2274
- className: UsageBilling_module_css_default.kpiValue,
2275
- children: total.calls.toLocaleString()
2276
- }),
2277
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2278
- className: UsageBilling_module_css_default.kpiDetail,
2612
+ ]
2613
+ }),
2614
+ tab === "trends" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2615
+ className: UsageBilling_module_css_default.tabPanel,
2616
+ "data-testid": "billing-tab-panel-trends",
2617
+ children: [
2618
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2619
+ className: clsx(UsageBilling_module_css_default.panel, UsageBilling_module_css_default.trendPanel),
2620
+ "data-testid": "billing-panel-trend",
2621
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2622
+ className: UsageBilling_module_css_default.panelHead,
2279
2623
  children: [
2280
- modelRows.length,
2281
- " ",
2282
- t("billing.models")
2624
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2625
+ className: UsageBilling_module_css_default.panelTitle,
2626
+ children: t("billing.trend")
2627
+ }),
2628
+ renderSlot("billing.dashboard.decor", { position: "trend" }),
2629
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2630
+ className: UsageBilling_module_css_default.rangeToggle,
2631
+ role: "group",
2632
+ "aria-label": t("billing.trend"),
2633
+ children: [7, 30].map((days) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2634
+ type: "button",
2635
+ className: clsx(UsageBilling_module_css_default.rangeButton, trendDays === days && UsageBilling_module_css_default.rangeButtonActive),
2636
+ "aria-pressed": trendDays === days,
2637
+ "data-testid": `billing-trend-${days}d`,
2638
+ onClick: () => {
2639
+ setTrendDays(days);
2640
+ },
2641
+ children: days === 7 ? t("billing.trend7d") : t("billing.trend30d")
2642
+ }, days))
2643
+ }),
2644
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2645
+ className: UsageBilling_module_css_default.panelHint,
2646
+ children: latestDate
2647
+ })
2283
2648
  ]
2284
- })
2285
- ]
2286
- })
2287
- ]
2288
- }),
2289
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2290
- className: clsx(UsageBilling_module_css_default.panel, UsageBilling_module_css_default.trendPanel),
2291
- "data-testid": "billing-panel-trend",
2292
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2293
- className: UsageBilling_module_css_default.panelHead,
2294
- children: [
2295
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2296
- className: UsageBilling_module_css_default.panelTitle,
2297
- children: t("billing.trend")
2649
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
2650
+ data: trend,
2651
+ models: chartModels,
2652
+ currency
2653
+ })]
2298
2654
  }),
2299
- renderSlot("billing.dashboard.decor", { position: "trend" }),
2300
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2301
- className: UsageBilling_module_css_default.rangeToggle,
2302
- role: "group",
2303
- "aria-label": t("billing.trend"),
2304
- children: [7, 30].map((days) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2305
- type: "button",
2306
- className: clsx(UsageBilling_module_css_default.rangeButton, trendDays === days && UsageBilling_module_css_default.rangeButtonActive),
2307
- "aria-pressed": trendDays === days,
2308
- "data-testid": `billing-trend-${days}d`,
2309
- onClick: () => {
2310
- setTrendDays(days);
2311
- },
2312
- children: days === 7 ? t("billing.trend7d") : t("billing.trend30d")
2313
- }, days))
2655
+ turns.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2656
+ className: UsageBilling_module_css_default.panel,
2657
+ "data-testid": "billing-panel-rounds",
2658
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2659
+ className: UsageBilling_module_css_default.panelHead,
2660
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2661
+ className: UsageBilling_module_css_default.panelTitle,
2662
+ children: t("billing.rounds")
2663
+ }), roundFlags.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2664
+ className: UsageBilling_module_css_default.roundsFlagBadge,
2665
+ "data-testid": "billing-rounds-flag-count",
2666
+ children: [
2667
+ roundFlags.length,
2668
+ " ",
2669
+ t("billing.anomaly")
2670
+ ]
2671
+ })]
2672
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RoundCostChart, {
2673
+ rounds: turns,
2674
+ flags: roundFlags,
2675
+ currency,
2676
+ t
2677
+ })]
2314
2678
  }),
2315
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2316
- className: UsageBilling_module_css_default.panelHint,
2317
- children: latestDate
2318
- })
2319
- ]
2320
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
2321
- data: trend,
2322
- models: chartModels,
2323
- currency
2324
- })]
2325
- }),
2326
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2327
- className: UsageBilling_module_css_default.panel,
2328
- "data-testid": "billing-panel-providers",
2329
- children: [
2330
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2331
- className: UsageBilling_module_css_default.panelHead,
2332
- children: [
2333
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2334
- className: UsageBilling_module_css_default.panelTitle,
2335
- children: t("billing.providerBilling")
2336
- }),
2337
- renderSlot("billing.dashboard.decor", { position: "models" }),
2338
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2339
- className: UsageBilling_module_css_default.panelHint,
2340
- children: stats.updatedAt !== void 0 ? `${t("billing.lastUpdated")} ${formatClock(stats.updatedAt)}` : ""
2341
- })
2342
- ]
2343
- }),
2344
- providerGroups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2345
- className: UsageBilling_module_css_default.emptyRow,
2346
- "data-testid": "billing-provider-empty",
2347
- children: t("billing.noData")
2348
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2349
- className: UsageBilling_module_css_default.providerGroupList,
2350
- "data-testid": "billing-provider-groups",
2351
- children: providerGroups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2352
- className: UsageBilling_module_css_default.providerGroup,
2353
- "data-testid": "billing-provider-group",
2354
- children: [
2355
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2356
- className: UsageBilling_module_css_default.providerGroupHead,
2357
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2358
- className: UsageBilling_module_css_default.providerGroupTitle,
2359
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2360
- className: clsx(UsageBilling_module_css_default.healthDot, group.dot),
2361
- "aria-hidden": "true"
2679
+ turns.length > 0 && (() => {
2680
+ const shareTotal = peakShare.peak + peakShare.offPeak;
2681
+ if (shareTotal <= 0) return null;
2682
+ const peakPct = peakShare.peak / shareTotal * 100;
2683
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2684
+ className: UsageBilling_module_css_default.panel,
2685
+ "data-testid": "billing-panel-share",
2686
+ children: [
2687
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2688
+ className: UsageBilling_module_css_default.panelHead,
2689
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2690
+ className: UsageBilling_module_css_default.panelTitle,
2691
+ children: t("billing.peakShare")
2362
2692
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2363
- className: UsageBilling_module_css_default.providerGroupName,
2364
- children: group.name
2693
+ className: UsageBilling_module_css_default.panelHint,
2694
+ children: t("billing.peakShareHint").replace("{count}", String(turns.length))
2365
2695
  })]
2366
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2367
- className: UsageBilling_module_css_default.providerGroupMeta,
2368
- children: [group.subscriptions.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2369
- className: UsageBilling_module_css_default.providerGroupBadge,
2370
- "data-testid": "billing-provider-sub-count",
2371
- children: [group.subscriptions.length, " 套餐"]
2372
- }), group.balance !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2373
- className: UsageBilling_module_css_default.providerGroupBalance,
2374
- "data-testid": "billing-provider-balance",
2375
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2376
- className: UsageBilling_module_css_default.providerGroupBalanceLabel,
2377
- children: t("billing.balance")
2378
- }), renderBalance(group.balance)]
2696
+ }),
2697
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2698
+ className: UsageBilling_module_css_default.shareTrack,
2699
+ "data-testid": "billing-share-track",
2700
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2701
+ className: clsx(UsageBilling_module_css_default.shareSeg, UsageBilling_module_css_default.shareSegPeak),
2702
+ style: { width: `${peakPct}%` }
2703
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2704
+ className: clsx(UsageBilling_module_css_default.shareSeg, UsageBilling_module_css_default.shareSegOff),
2705
+ style: { width: `${100 - peakPct}%` }
2379
2706
  })]
2380
- })]
2381
- }),
2382
- group.models.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2383
- className: clsx(UsageBilling_module_css_default.tableScroll, UsageBilling_module_css_default.modelTableScroll),
2384
- "data-testid": "billing-table-scroll",
2385
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2386
- className: UsageBilling_module_css_default.modelTable,
2387
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2388
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.model") }),
2389
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2390
- className: UsageBilling_module_css_default.numCol,
2391
- children: t("billing.calls")
2392
- }),
2393
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2394
- className: UsageBilling_module_css_default.numCol,
2395
- children: t("billing.inputTokens")
2396
- }),
2397
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2398
- className: UsageBilling_module_css_default.numCol,
2399
- children: t("billing.outputTokens")
2400
- }),
2401
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2402
- className: UsageBilling_module_css_default.numCol,
2403
- children: t("billing.cacheHitRate")
2404
- }),
2405
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2406
- className: UsageBilling_module_css_default.numCol,
2407
- children: t("billing.actual")
2408
- })
2409
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: group.models.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2410
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2411
- className: UsageBilling_module_css_default.modelCell,
2412
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2413
- className: UsageBilling_module_css_default.modelName,
2414
- children: [row.name, row.uncatalogued && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2415
- className: UsageBilling_module_css_default.uncataloguedTag,
2416
- "data-testid": "billing-uncatalogued-tag",
2417
- children: t("billing.uncatalogued")
2418
- })]
2419
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2420
- className: UsageBilling_module_css_default.modelProvider,
2421
- children: row.provider
2422
- })] })
2423
- }) }),
2424
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2425
- className: UsageBilling_module_css_default.numCol,
2426
- children: row.calls.toLocaleString()
2427
- }),
2428
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2429
- className: UsageBilling_module_css_default.numCol,
2430
- children: formatTokens(row.input)
2431
- }),
2432
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2433
- className: UsageBilling_module_css_default.numCol,
2434
- children: formatTokens(row.output)
2435
- }),
2436
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2437
- className: UsageBilling_module_css_default.numCol,
2438
- children: formatPercent(row.cacheHitRate)
2439
- }),
2440
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2441
- className: UsageBilling_module_css_default.numCol,
2442
- children: row.plan ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2443
- className: UsageBilling_module_css_default.planTag,
2444
- children: "订阅包含"
2445
- }) : row.actual !== void 0 ? money(row.actual) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2446
- className: UsageBilling_module_css_default.na,
2447
- children: "—"
2448
- })
2449
- })
2450
- ] }, row.key)) })]
2451
- })
2452
- }),
2453
- group.subscriptions.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2454
- className: UsageBilling_module_css_default.subscriptionGrid,
2455
- "data-testid": "billing-subscriptions-grid",
2456
- children: group.subscriptions.map((quota) => {
2457
- const statusText = subscriptionStatusText(quota.status, t);
2458
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2459
- className: UsageBilling_module_css_default.subscriptionCard,
2460
- "data-testid": "billing-subscription-card",
2707
+ }),
2708
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2709
+ className: UsageBilling_module_css_default.shareLegend,
2710
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2711
+ className: UsageBilling_module_css_default.shareItem,
2461
2712
  children: [
2462
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2463
- className: UsageBilling_module_css_default.subscriptionHead,
2464
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2465
- className: UsageBilling_module_css_default.subscriptionName,
2466
- children: quota.displayName
2467
- }), quota.plan !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2468
- className: UsageBilling_module_css_default.subscriptionPlan,
2469
- children: quota.plan
2470
- })]
2713
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2714
+ className: UsageBilling_module_css_default.shareDot,
2715
+ style: { background: "var(--dsw-static-blue-500)" }
2471
2716
  }),
2472
- statusText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2473
- className: UsageBilling_module_css_default.subscriptionStatus,
2474
- children: statusText
2475
- }),
2476
- quota.windows.length === 0 && statusText === "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2477
- className: UsageBilling_module_css_default.subscriptionStatus,
2478
- children: t("billing.subscriptionNoApi")
2717
+ t("billing.peak"),
2718
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2719
+ className: UsageBilling_module_css_default.shareValue,
2720
+ "data-testid": "billing-share-peak",
2721
+ children: [
2722
+ money(peakShare.peak),
2723
+ " · ",
2724
+ peakPct.toFixed(1),
2725
+ "%"
2726
+ ]
2727
+ })
2728
+ ]
2729
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2730
+ className: UsageBilling_module_css_default.shareItem,
2731
+ children: [
2732
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2733
+ className: UsageBilling_module_css_default.shareDot,
2734
+ style: { background: "color-mix(in srgb, var(--dsw-static-blue-500) 30%, var(--dsw-alias-bg-module-platform))" }
2479
2735
  }),
2480
- quota.windows.map((window) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2481
- className: UsageBilling_module_css_default.subscriptionWindow,
2736
+ t("billing.offPeak"),
2737
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2738
+ className: UsageBilling_module_css_default.shareValue,
2739
+ "data-testid": "billing-share-offpeak",
2482
2740
  children: [
2483
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2484
- className: UsageBilling_module_css_default.subscriptionWindowLabel,
2485
- children: subscriptionWindowLabel(window.kind, t)
2486
- }),
2487
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2488
- className: UsageBilling_module_css_default.subscriptionTrack,
2489
- "aria-hidden": "true",
2490
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2491
- className: UsageBilling_module_css_default.subscriptionFill,
2492
- style: { width: `${Math.min(100, Math.max(0, window.remainingPercent))}%` }
2493
- })
2494
- }),
2495
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2496
- className: UsageBilling_module_css_default.subscriptionPct,
2497
- children: t("billing.subscriptionRemaining").replace("{pct}", String(window.remainingPercent))
2498
- }),
2499
- window.resetsAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2500
- className: UsageBilling_module_css_default.subscriptionReset,
2501
- children: t("billing.subscriptionReset").replace("{date}", window.resetsAt.slice(0, 10))
2502
- })
2741
+ money(peakShare.offPeak),
2742
+ " · ",
2743
+ (100 - peakPct).toFixed(1),
2744
+ "%"
2503
2745
  ]
2504
- }, window.kind))
2746
+ })
2505
2747
  ]
2506
- }, quota.provider);
2748
+ })]
2507
2749
  })
2508
- })
2509
- ]
2510
- }, group.name))
2511
- }),
2512
- renderSlot("billing.dashboard.decor", { position: "footer" })
2513
- ]
2514
- }),
2515
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2516
- className: UsageBilling_module_css_default.panel,
2517
- "data-testid": "billing-panel-heatmap",
2518
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2519
- type: "button",
2520
- className: UsageBilling_module_css_default.pricingToggle,
2521
- "data-testid": "billing-heatmap-toggle",
2522
- onClick: () => {
2523
- setHeatmapOpen((prev) => !prev);
2524
- },
2525
- "aria-expanded": heatmapOpen,
2526
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2527
- className: UsageBilling_module_css_default.pricingToggleText,
2528
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2529
- className: UsageBilling_module_css_default.panelTitle,
2530
- children: t("billing.heatmap")
2531
- })
2532
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
2533
- className: clsx(UsageBilling_module_css_default.pricingChevron, heatmapOpen && UsageBilling_module_css_default.pricingChevronOpen),
2534
- viewBox: "0 0 24 24",
2535
- fill: "none",
2536
- stroke: "currentColor",
2537
- "aria-hidden": "true",
2538
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
2539
- })]
2540
- }), heatmapOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageHeatmap, {
2541
- days: heatmapDays,
2542
- currency,
2543
- t
2544
- })]
2545
- }),
2546
- turns.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2547
- className: UsageBilling_module_css_default.panel,
2548
- "data-testid": "billing-panel-rounds",
2549
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2550
- type: "button",
2551
- className: UsageBilling_module_css_default.pricingToggle,
2552
- "data-testid": "billing-rounds-toggle",
2553
- onClick: () => {
2554
- setRoundsOpen((prev) => !prev);
2555
- },
2556
- "aria-expanded": roundsOpen,
2557
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2558
- className: UsageBilling_module_css_default.pricingToggleText,
2559
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2560
- className: UsageBilling_module_css_default.panelTitle,
2561
- children: t("billing.rounds")
2562
- }), roundFlags.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2563
- className: UsageBilling_module_css_default.roundsFlagBadge,
2564
- "data-testid": "billing-rounds-flag-count",
2750
+ ]
2751
+ });
2752
+ })()
2753
+ ]
2754
+ }),
2755
+ tab === "providers" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2756
+ className: UsageBilling_module_css_default.tabPanel,
2757
+ "data-testid": "billing-tab-panel-providers",
2758
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2759
+ className: UsageBilling_module_css_default.panel,
2760
+ "data-testid": "billing-panel-providers",
2761
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2762
+ className: UsageBilling_module_css_default.panelHead,
2565
2763
  children: [
2566
- roundFlags.length,
2567
- " ",
2568
- t("billing.anomaly")
2764
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2765
+ className: UsageBilling_module_css_default.panelTitle,
2766
+ children: t("billing.providerBilling")
2767
+ }),
2768
+ renderSlot("billing.dashboard.decor", { position: "models" }),
2769
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2770
+ className: UsageBilling_module_css_default.panelHint,
2771
+ children: stats.updatedAt !== void 0 ? `${t("billing.lastUpdated")} ${formatClock(stats.updatedAt)}` : ""
2772
+ })
2569
2773
  ]
2570
- })]
2571
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
2572
- className: clsx(UsageBilling_module_css_default.pricingChevron, roundsOpen && UsageBilling_module_css_default.pricingChevronOpen),
2573
- viewBox: "0 0 24 24",
2574
- fill: "none",
2575
- stroke: "currentColor",
2576
- "aria-hidden": "true",
2577
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
2578
- })]
2579
- }), roundsOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RoundCostChart, {
2580
- rounds: turns,
2581
- flags: roundFlags,
2582
- currency,
2583
- t
2584
- })]
2585
- }),
2586
- stats.byWorkspace !== void 0 && stats.byWorkspace.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2587
- className: UsageBilling_module_css_default.panel,
2588
- "data-testid": "billing-panel-workspaces",
2589
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2590
- type: "button",
2591
- className: UsageBilling_module_css_default.pricingToggle,
2592
- "data-testid": "billing-workspaces-toggle",
2593
- onClick: () => {
2594
- setWorkspacesOpen((prev) => !prev);
2595
- },
2596
- "aria-expanded": workspacesOpen,
2597
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2598
- className: UsageBilling_module_css_default.pricingToggleText,
2599
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2600
- className: UsageBilling_module_css_default.panelTitle,
2601
- children: t("billing.workspaces")
2602
- })
2603
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
2604
- className: clsx(UsageBilling_module_css_default.pricingChevron, workspacesOpen && UsageBilling_module_css_default.pricingChevronOpen),
2605
- viewBox: "0 0 24 24",
2606
- fill: "none",
2607
- stroke: "currentColor",
2608
- "aria-hidden": "true",
2609
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
2610
- })]
2611
- }), workspacesOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2612
- className: UsageBilling_module_css_default.tableScroll,
2613
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2614
- className: UsageBilling_module_css_default.modelTable,
2615
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2616
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.project") }),
2617
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2618
- className: UsageBilling_module_css_default.numCol,
2619
- children: t("billing.calls")
2620
- }),
2621
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2622
- className: UsageBilling_module_css_default.numCol,
2623
- children: t("billing.inputTokens")
2624
- }),
2625
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2626
- className: UsageBilling_module_css_default.numCol,
2627
- children: t("billing.outputTokens")
2628
- }),
2629
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2630
- className: UsageBilling_module_css_default.numCol,
2631
- children: t("billing.actual")
2632
- }),
2633
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2634
- className: UsageBilling_module_css_default.numCol,
2635
- children: t("billing.lastActive")
2636
- })
2637
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: stats.byWorkspace.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2638
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2639
- className: UsageBilling_module_css_default.modelName,
2640
- children: row.name
2641
- }) }),
2642
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2643
- className: UsageBilling_module_css_default.numCol,
2644
- children: row.calls.toLocaleString()
2645
- }),
2646
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2647
- className: UsageBilling_module_css_default.numCol,
2648
- children: formatTokens(row.input)
2649
- }),
2650
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2651
- className: UsageBilling_module_css_default.numCol,
2652
- children: formatTokens(row.output)
2653
- }),
2654
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2655
- className: UsageBilling_module_css_default.numCol,
2656
- children: money(row.cost)
2657
- }),
2658
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2659
- className: UsageBilling_module_css_default.numCol,
2660
- children: row.lastActive > 0 ? `${localDayStamp(row.lastActive)}` : "—"
2661
- })
2662
- ] }, row.name)) })]
2663
- })
2664
- })]
2665
- }),
2666
- stats.bySession !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2667
- className: UsageBilling_module_css_default.panel,
2668
- "data-testid": "billing-panel-sessions",
2669
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2670
- type: "button",
2671
- className: UsageBilling_module_css_default.pricingToggle,
2672
- "data-testid": "billing-sessions-toggle",
2673
- onClick: () => {
2674
- setSessionsOpen((prev) => !prev);
2675
- },
2676
- "aria-expanded": sessionsOpen,
2677
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2678
- className: UsageBilling_module_css_default.pricingToggleText,
2679
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2680
- className: UsageBilling_module_css_default.panelTitle,
2681
- children: t("billing.sessions")
2682
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2683
- className: UsageBilling_module_css_default.panelHint,
2684
- children: stats.bySession.length > SESSION_DISPLAY_LIMIT ? t("billing.sessionOverflow").replace("{limit}", String(SESSION_DISPLAY_LIMIT)).replace("{total}", String(stats.bySession.length)) : `${stats.bySession.length}`
2685
- })]
2686
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
2687
- className: clsx(UsageBilling_module_css_default.pricingChevron, sessionsOpen && UsageBilling_module_css_default.pricingChevronOpen),
2688
- viewBox: "0 0 24 24",
2689
- fill: "none",
2690
- stroke: "currentColor",
2691
- "aria-hidden": "true",
2692
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
2693
- })]
2694
- }), sessionsOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2695
- className: UsageBilling_module_css_default.tableScroll,
2696
- "data-testid": "billing-sessions-table",
2697
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2698
- className: UsageBilling_module_css_default.modelTable,
2699
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2700
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.sessions") }),
2701
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.project") }),
2702
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2703
- className: UsageBilling_module_css_default.numCol,
2704
- children: t("billing.calls")
2705
- }),
2706
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2707
- className: UsageBilling_module_css_default.numCol,
2708
- children: t("billing.actual")
2709
- }),
2710
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2711
- className: UsageBilling_module_css_default.numCol,
2712
- children: t("billing.lastActive")
2713
- })
2714
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tbody", { children: [stats.bySession.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2715
- colSpan: 5,
2774
+ }), providerGroups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2716
2775
  className: UsageBilling_module_css_default.emptyRow,
2776
+ "data-testid": "billing-provider-empty",
2717
2777
  children: t("billing.noData")
2718
- }) }), stats.bySession.slice(0, SESSION_DISPLAY_LIMIT).map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2719
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2720
- className: UsageBilling_module_css_default.modelName,
2721
- children: row.title ?? row.id.slice(0, 8)
2722
- }) }),
2723
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2724
- className: UsageBilling_module_css_default.modelProvider,
2725
- children: projectName(row.cwd) ?? ""
2726
- }) }),
2727
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2728
- className: UsageBilling_module_css_default.numCol,
2729
- children: row.calls.toLocaleString()
2730
- }),
2731
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2732
- className: UsageBilling_module_css_default.numCol,
2733
- children: money(row.cost)
2734
- }),
2735
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2736
- className: UsageBilling_module_css_default.numCol,
2737
- children: row.lastActive > 0 ? `${localDayStamp(row.lastActive)} ${formatClock(row.lastActive)}` : "—"
2738
- })
2739
- ] }, row.id))] })]
2778
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2779
+ className: UsageBilling_module_css_default.providerGroupList,
2780
+ "data-testid": "billing-provider-groups",
2781
+ children: providerGroups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2782
+ className: UsageBilling_module_css_default.providerGroup,
2783
+ "data-testid": "billing-provider-group",
2784
+ children: [
2785
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2786
+ className: UsageBilling_module_css_default.providerGroupHead,
2787
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2788
+ className: UsageBilling_module_css_default.providerGroupTitle,
2789
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2790
+ className: clsx(UsageBilling_module_css_default.healthDot, group.dot),
2791
+ "aria-hidden": "true"
2792
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2793
+ className: UsageBilling_module_css_default.providerGroupName,
2794
+ children: group.name
2795
+ })]
2796
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2797
+ className: UsageBilling_module_css_default.providerGroupMeta,
2798
+ children: [group.subscriptions.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2799
+ className: UsageBilling_module_css_default.providerGroupBadge,
2800
+ "data-testid": "billing-provider-sub-count",
2801
+ children: [group.subscriptions.length, " 套餐"]
2802
+ }), group.balance !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2803
+ className: UsageBilling_module_css_default.providerGroupBalance,
2804
+ "data-testid": "billing-provider-balance",
2805
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2806
+ className: UsageBilling_module_css_default.providerGroupBalanceLabel,
2807
+ children: t("billing.balance")
2808
+ }), renderBalance(group.balance)]
2809
+ })]
2810
+ })]
2811
+ }),
2812
+ group.models.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2813
+ className: clsx(UsageBilling_module_css_default.tableScroll, UsageBilling_module_css_default.modelTableScroll),
2814
+ "data-testid": "billing-table-scroll",
2815
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2816
+ className: UsageBilling_module_css_default.modelTable,
2817
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2818
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.model") }),
2819
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2820
+ className: UsageBilling_module_css_default.numCol,
2821
+ children: t("billing.calls")
2822
+ }),
2823
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2824
+ className: UsageBilling_module_css_default.numCol,
2825
+ children: t("billing.inputTokens")
2826
+ }),
2827
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2828
+ className: UsageBilling_module_css_default.numCol,
2829
+ children: t("billing.outputTokens")
2830
+ }),
2831
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2832
+ className: UsageBilling_module_css_default.numCol,
2833
+ children: t("billing.cacheHitRate")
2834
+ }),
2835
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2836
+ className: UsageBilling_module_css_default.numCol,
2837
+ children: t("billing.actual")
2838
+ })
2839
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: group.models.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2840
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2841
+ className: UsageBilling_module_css_default.modelCell,
2842
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2843
+ className: UsageBilling_module_css_default.modelName,
2844
+ children: [
2845
+ row.name,
2846
+ row.uncatalogued && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2847
+ className: UsageBilling_module_css_default.uncataloguedTag,
2848
+ "data-testid": "billing-uncatalogued-tag",
2849
+ children: t("billing.uncatalogued")
2850
+ }),
2851
+ row.estimatedPricing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2852
+ className: UsageBilling_module_css_default.estimatedTag,
2853
+ "data-testid": "billing-estimated-tag",
2854
+ children: t("billing.estimatedPricing")
2855
+ })
2856
+ ]
2857
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2858
+ className: UsageBilling_module_css_default.modelProvider,
2859
+ children: row.provider
2860
+ })] })
2861
+ }) }),
2862
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2863
+ className: UsageBilling_module_css_default.numCol,
2864
+ children: row.calls.toLocaleString()
2865
+ }),
2866
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2867
+ className: UsageBilling_module_css_default.numCol,
2868
+ children: formatTokens(row.input)
2869
+ }),
2870
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2871
+ className: UsageBilling_module_css_default.numCol,
2872
+ children: formatTokens(row.output)
2873
+ }),
2874
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2875
+ className: UsageBilling_module_css_default.numCol,
2876
+ children: formatPercent(row.cacheHitRate)
2877
+ }),
2878
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2879
+ className: UsageBilling_module_css_default.numCol,
2880
+ children: row.plan ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2881
+ className: UsageBilling_module_css_default.planTag,
2882
+ children: "订阅包含"
2883
+ }) : row.actual !== void 0 ? money(row.actual) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2884
+ className: UsageBilling_module_css_default.na,
2885
+ children: "—"
2886
+ })
2887
+ })
2888
+ ] }, row.key)) })]
2889
+ })
2890
+ }),
2891
+ group.subscriptions.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2892
+ className: UsageBilling_module_css_default.subscriptionGrid,
2893
+ "data-testid": "billing-subscriptions-grid",
2894
+ children: group.subscriptions.map((quota) => {
2895
+ const statusText = subscriptionStatusText(quota.status, t);
2896
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2897
+ className: UsageBilling_module_css_default.subscriptionCard,
2898
+ "data-testid": "billing-subscription-card",
2899
+ children: [
2900
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2901
+ className: UsageBilling_module_css_default.subscriptionHead,
2902
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2903
+ className: UsageBilling_module_css_default.subscriptionName,
2904
+ children: quota.displayName
2905
+ }), quota.plan !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2906
+ className: UsageBilling_module_css_default.subscriptionPlan,
2907
+ children: quota.plan
2908
+ })]
2909
+ }),
2910
+ statusText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2911
+ className: UsageBilling_module_css_default.subscriptionStatus,
2912
+ children: statusText
2913
+ }),
2914
+ quota.windows.length === 0 && statusText === "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2915
+ className: UsageBilling_module_css_default.subscriptionStatus,
2916
+ children: t("billing.subscriptionNoApi")
2917
+ }),
2918
+ quota.windows.map((window) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2919
+ className: UsageBilling_module_css_default.subscriptionWindow,
2920
+ children: [
2921
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2922
+ className: UsageBilling_module_css_default.subscriptionWindowLabel,
2923
+ children: subscriptionWindowLabel(window.kind, t)
2924
+ }),
2925
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2926
+ className: UsageBilling_module_css_default.subscriptionTrack,
2927
+ "aria-hidden": "true",
2928
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2929
+ className: UsageBilling_module_css_default.subscriptionFill,
2930
+ style: { width: `${Math.min(100, Math.max(0, window.remainingPercent))}%` }
2931
+ })
2932
+ }),
2933
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2934
+ className: UsageBilling_module_css_default.subscriptionPct,
2935
+ children: t("billing.subscriptionRemaining").replace("{pct}", String(window.remainingPercent))
2936
+ }),
2937
+ window.resetsAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2938
+ className: UsageBilling_module_css_default.subscriptionReset,
2939
+ children: t("billing.subscriptionReset").replace("{date}", window.resetsAt.slice(0, 10))
2940
+ })
2941
+ ]
2942
+ }, window.kind))
2943
+ ]
2944
+ }, quota.provider);
2945
+ })
2946
+ })
2947
+ ]
2948
+ }, group.name))
2949
+ })]
2740
2950
  })
2741
- })]
2742
- }),
2743
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2744
- className: UsageBilling_module_css_default.panel,
2745
- "data-testid": "billing-panel-pricing",
2746
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2747
- type: "button",
2748
- className: UsageBilling_module_css_default.pricingToggle,
2749
- "data-testid": "billing-pricing-toggle",
2750
- onClick: () => {
2751
- setPricingOpen((prev) => !prev);
2752
- },
2753
- "aria-expanded": pricingOpen,
2754
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2755
- className: UsageBilling_module_css_default.pricingToggleText,
2756
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2757
- className: UsageBilling_module_css_default.panelTitle,
2758
- children: t("billing.pricing")
2759
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2760
- className: UsageBilling_module_css_default.panelHint,
2951
+ }),
2952
+ tab === "details" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2953
+ className: UsageBilling_module_css_default.tabPanel,
2954
+ "data-testid": "billing-tab-panel-details",
2955
+ children: [
2956
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2957
+ className: UsageBilling_module_css_default.exportBar,
2958
+ "data-testid": "billing-export-bar",
2959
+ role: "group",
2960
+ "aria-label": t("billing.export"),
2761
2961
  children: [
2762
- t("billing.todayRate"),
2763
- " 1 USD = ",
2764
- formatMoney(rateInfo.rate),
2765
2962
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2766
- className: clsx(UsageBilling_module_css_default.rateBadge, rateInfo.live ? UsageBilling_module_css_default.rateBadgeLive : UsageBilling_module_css_default.rateBadgeBuiltin),
2767
- children: rateInfo.live ? t("billing.rateLive") : t("billing.rateBuiltin")
2963
+ className: UsageBilling_module_css_default.exportLabel,
2964
+ children: t("billing.export")
2965
+ }),
2966
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2967
+ type: "button",
2968
+ className: UsageBilling_module_css_default.exportButton,
2969
+ "data-testid": "billing-export-day",
2970
+ onClick: () => {
2971
+ downloadText(exportFileName("usage-daily", "csv", Object.keys(byDay)), dayRowsCsv(byDay), "text/csv");
2972
+ },
2973
+ children: t("billing.exportCsvDay")
2974
+ }),
2975
+ stats.bySession !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2976
+ type: "button",
2977
+ className: UsageBilling_module_css_default.exportButton,
2978
+ "data-testid": "billing-export-sessions",
2979
+ onClick: () => {
2980
+ downloadText(exportFileName("usage-sessions", "csv", Object.keys(byDay)), sessionRowsCsv(stats.bySession ?? []), "text/csv");
2981
+ },
2982
+ children: t("billing.exportCsvSession")
2983
+ }),
2984
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2985
+ type: "button",
2986
+ className: UsageBilling_module_css_default.exportButton,
2987
+ "data-testid": "billing-export-json",
2988
+ onClick: () => {
2989
+ downloadText(exportFileName("usage-stats", "json", Object.keys(byDay)), JSON.stringify(stats, null, 2), "application/json");
2990
+ },
2991
+ children: t("billing.exportJson")
2768
2992
  })
2769
2993
  ]
2770
- })]
2771
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
2772
- className: clsx(UsageBilling_module_css_default.pricingChevron, pricingOpen && UsageBilling_module_css_default.pricingChevronOpen),
2773
- viewBox: "0 0 24 24",
2774
- fill: "none",
2775
- stroke: "currentColor",
2776
- "aria-hidden": "true",
2777
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
2778
- })]
2779
- }), pricingOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2780
- className: UsageBilling_module_css_default.tableScroll,
2781
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2782
- className: UsageBilling_module_css_default.pricingTable,
2783
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2784
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: "Model" }),
2785
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2786
- className: UsageBilling_module_css_default.numCol,
2787
- children: t("billing.input")
2788
- }),
2789
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2790
- className: UsageBilling_module_css_default.numCol,
2791
- children: t("billing.cacheHit")
2792
- }),
2793
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2794
- className: UsageBilling_module_css_default.numCol,
2795
- children: t("billing.output")
2796
- }),
2797
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.band") })
2798
- ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: MODEL_CATALOG.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
2799
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2800
- className: UsageBilling_module_css_default.modelCell,
2801
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2802
- className: UsageBilling_module_css_default.modelDot,
2803
- style: { background: resolveToken(entry.colorVar) }
2804
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2805
- className: UsageBilling_module_css_default.modelName,
2806
- children: entry.name
2807
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2808
- className: UsageBilling_module_css_default.modelProvider,
2809
- children: entry.provider
2810
- })] })]
2811
- }) }),
2812
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2813
- className: UsageBilling_module_css_default.numCol,
2814
- children: entry.price.offPeak !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2815
- className: UsageBilling_module_css_default.bandPrice,
2816
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatUnitPrice(entry.price.input, entry.price.currency) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2817
- className: UsageBilling_module_css_default.bandPriceOff,
2818
- children: formatUnitPrice(entry.price.offPeak.input, entry.price.currency)
2819
- })]
2820
- }) : formatUnitPrice(entry.price.input, entry.price.currency)
2821
- }),
2822
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2823
- className: UsageBilling_module_css_default.numCol,
2824
- children: entry.price.offPeak !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2825
- className: UsageBilling_module_css_default.bandPrice,
2826
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatUnitPrice(entry.price.cacheHit, entry.price.currency) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2827
- className: UsageBilling_module_css_default.bandPriceOff,
2828
- children: formatUnitPrice(entry.price.offPeak.cacheHit, entry.price.currency)
2829
- })]
2830
- }) : formatUnitPrice(entry.price.cacheHit, entry.price.currency)
2831
- }),
2832
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2833
- className: UsageBilling_module_css_default.numCol,
2834
- children: entry.price.offPeak !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2835
- className: UsageBilling_module_css_default.bandPrice,
2836
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatUnitPrice(entry.price.output, entry.price.currency) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2837
- className: UsageBilling_module_css_default.bandPriceOff,
2838
- children: formatUnitPrice(entry.price.offPeak.output, entry.price.currency)
2994
+ }),
2995
+ roleRows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2996
+ className: UsageBilling_module_css_default.panel,
2997
+ "data-testid": "billing-panel-roles",
2998
+ children: [
2999
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3000
+ className: UsageBilling_module_css_default.panelHead,
3001
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3002
+ className: UsageBilling_module_css_default.panelTitle,
3003
+ children: t("billing.roleCost")
3004
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3005
+ className: UsageBilling_module_css_default.panelHint,
3006
+ children: t("billing.roleHint")
2839
3007
  })]
2840
- }) : formatUnitPrice(entry.price.output, entry.price.currency)
2841
- }),
2842
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: entry.price.offPeak !== void 0 && entry.peakHours !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2843
- className: UsageBilling_module_css_default.bandTag,
2844
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
2845
- t("billing.peak"),
2846
- " ",
2847
- entry.peakHours
2848
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2849
- className: UsageBilling_module_css_default.bandTagOff,
2850
- children: [t("billing.offPeak"), " 50%"]
3008
+ }),
3009
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3010
+ className: UsageBilling_module_css_default.shareTrack,
3011
+ "data-testid": "billing-role-track",
3012
+ children: roleRows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3013
+ className: clsx(UsageBilling_module_css_default.shareSeg, row.seg),
3014
+ style: { width: `${row.pct}%` }
3015
+ }, row.label))
3016
+ }),
3017
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3018
+ className: UsageBilling_module_css_default.shareLegend,
3019
+ children: roleRows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3020
+ className: UsageBilling_module_css_default.shareItem,
3021
+ children: [
3022
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: clsx(UsageBilling_module_css_default.shareDot, row.seg) }),
3023
+ row.label,
3024
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3025
+ className: UsageBilling_module_css_default.shareValue,
3026
+ children: [
3027
+ money(row.value),
3028
+ " · ",
3029
+ row.pct.toFixed(1),
3030
+ "%"
3031
+ ]
3032
+ })
3033
+ ]
3034
+ }, row.label))
3035
+ })
3036
+ ]
3037
+ }),
3038
+ stats.byWorkspace !== void 0 && stats.byWorkspace.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3039
+ className: UsageBilling_module_css_default.panel,
3040
+ "data-testid": "billing-panel-workspaces",
3041
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3042
+ className: UsageBilling_module_css_default.panelHead,
3043
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3044
+ className: UsageBilling_module_css_default.panelTitle,
3045
+ children: t("billing.workspaces")
3046
+ })
3047
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3048
+ className: UsageBilling_module_css_default.tableScroll,
3049
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
3050
+ className: UsageBilling_module_css_default.modelTable,
3051
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3052
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.project") }),
3053
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3054
+ className: UsageBilling_module_css_default.numCol,
3055
+ children: t("billing.calls")
3056
+ }),
3057
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3058
+ className: UsageBilling_module_css_default.numCol,
3059
+ children: t("billing.inputTokens")
3060
+ }),
3061
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3062
+ className: UsageBilling_module_css_default.numCol,
3063
+ children: t("billing.outputTokens")
3064
+ }),
3065
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3066
+ className: UsageBilling_module_css_default.numCol,
3067
+ children: t("billing.actual")
3068
+ }),
3069
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3070
+ className: UsageBilling_module_css_default.numCol,
3071
+ children: t("billing.lastActive")
3072
+ })
3073
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: stats.byWorkspace.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3074
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3075
+ className: UsageBilling_module_css_default.modelName,
3076
+ children: row.name
3077
+ }) }),
3078
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3079
+ className: UsageBilling_module_css_default.numCol,
3080
+ children: row.calls.toLocaleString()
3081
+ }),
3082
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3083
+ className: UsageBilling_module_css_default.numCol,
3084
+ children: formatTokens(row.input)
3085
+ }),
3086
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3087
+ className: UsageBilling_module_css_default.numCol,
3088
+ children: formatTokens(row.output)
3089
+ }),
3090
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3091
+ className: UsageBilling_module_css_default.numCol,
3092
+ children: money(row.cost)
3093
+ }),
3094
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3095
+ className: UsageBilling_module_css_default.numCol,
3096
+ children: row.lastActive > 0 ? `${localDayStamp(row.lastActive)}` : "—"
3097
+ })
3098
+ ] }, row.name)) })]
3099
+ })
3100
+ })]
3101
+ }),
3102
+ stats.bySession !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3103
+ className: UsageBilling_module_css_default.panel,
3104
+ "data-testid": "billing-panel-sessions",
3105
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3106
+ className: UsageBilling_module_css_default.panelHead,
3107
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3108
+ className: UsageBilling_module_css_default.panelTitle,
3109
+ children: t("billing.sessions")
3110
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3111
+ className: UsageBilling_module_css_default.panelHint,
3112
+ children: stats.bySession.length > SESSION_DISPLAY_LIMIT ? t("billing.sessionOverflow").replace("{limit}", String(SESSION_DISPLAY_LIMIT)).replace("{total}", String(stats.bySession.length)) : `${stats.bySession.length}`
2851
3113
  })]
2852
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2853
- className: UsageBilling_module_css_default.flatTag,
2854
- children: t("billing.flat")
2855
- }) })
2856
- ] }, entry.key)) })]
3114
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3115
+ className: UsageBilling_module_css_default.tableScroll,
3116
+ "data-testid": "billing-sessions-table",
3117
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
3118
+ className: UsageBilling_module_css_default.modelTable,
3119
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3120
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.sessions") }),
3121
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.project") }),
3122
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3123
+ className: UsageBilling_module_css_default.numCol,
3124
+ children: t("billing.calls")
3125
+ }),
3126
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3127
+ className: UsageBilling_module_css_default.numCol,
3128
+ children: t("billing.actual")
3129
+ }),
3130
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3131
+ className: UsageBilling_module_css_default.numCol,
3132
+ children: t("billing.lastActive")
3133
+ })
3134
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tbody", { children: [stats.bySession.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3135
+ colSpan: 5,
3136
+ className: UsageBilling_module_css_default.emptyRow,
3137
+ children: t("billing.noData")
3138
+ }) }), stats.bySession.slice(0, SESSION_DISPLAY_LIMIT).map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3139
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3140
+ className: UsageBilling_module_css_default.modelName,
3141
+ children: row.title ?? row.id.slice(0, 8)
3142
+ }) }),
3143
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3144
+ className: UsageBilling_module_css_default.modelProvider,
3145
+ children: projectName(row.cwd) ?? "—"
3146
+ }) }),
3147
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3148
+ className: UsageBilling_module_css_default.numCol,
3149
+ children: row.calls.toLocaleString()
3150
+ }),
3151
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3152
+ className: UsageBilling_module_css_default.numCol,
3153
+ children: money(row.cost)
3154
+ }),
3155
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3156
+ className: UsageBilling_module_css_default.numCol,
3157
+ children: row.lastActive > 0 ? `${localDayStamp(row.lastActive)} ${formatClock(row.lastActive)}` : "—"
3158
+ })
3159
+ ] }, row.id))] })]
3160
+ })
3161
+ })]
3162
+ })
3163
+ ]
3164
+ }),
3165
+ tab === "pricing" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3166
+ className: UsageBilling_module_css_default.tabPanel,
3167
+ "data-testid": "billing-tab-panel-pricing",
3168
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3169
+ className: UsageBilling_module_css_default.panel,
3170
+ "data-testid": "billing-panel-pricing",
3171
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3172
+ className: UsageBilling_module_css_default.panelHead,
3173
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3174
+ className: UsageBilling_module_css_default.panelTitle,
3175
+ children: t("billing.pricing")
3176
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3177
+ className: UsageBilling_module_css_default.panelHint,
3178
+ children: [
3179
+ t("billing.todayRate"),
3180
+ " 1 USD = ",
3181
+ formatMoney(rateInfo.rate),
3182
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3183
+ className: clsx(UsageBilling_module_css_default.rateBadge, rateInfo.live ? UsageBilling_module_css_default.rateBadgeLive : UsageBilling_module_css_default.rateBadgeBuiltin),
3184
+ children: rateInfo.live ? t("billing.rateLive") : t("billing.rateBuiltin")
3185
+ })
3186
+ ]
3187
+ })]
3188
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3189
+ className: UsageBilling_module_css_default.tableScroll,
3190
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
3191
+ className: UsageBilling_module_css_default.pricingTable,
3192
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3193
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: "Model" }),
3194
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3195
+ className: UsageBilling_module_css_default.numCol,
3196
+ children: t("billing.input")
3197
+ }),
3198
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3199
+ className: UsageBilling_module_css_default.numCol,
3200
+ children: t("billing.cacheHit")
3201
+ }),
3202
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3203
+ className: UsageBilling_module_css_default.numCol,
3204
+ children: t("billing.output")
3205
+ }),
3206
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("billing.band") })
3207
+ ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: MODEL_CATALOG.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
3208
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3209
+ className: UsageBilling_module_css_default.modelCell,
3210
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3211
+ className: UsageBilling_module_css_default.modelDot,
3212
+ style: { background: resolveToken(entry.colorVar) }
3213
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3214
+ className: UsageBilling_module_css_default.modelName,
3215
+ children: entry.name
3216
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3217
+ className: UsageBilling_module_css_default.modelProvider,
3218
+ children: entry.provider
3219
+ })] })]
3220
+ }) }),
3221
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3222
+ className: UsageBilling_module_css_default.numCol,
3223
+ children: entry.price.offPeak !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3224
+ className: UsageBilling_module_css_default.bandPrice,
3225
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatUnitPrice(entry.price.input, entry.price.currency) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3226
+ className: UsageBilling_module_css_default.bandPriceOff,
3227
+ children: formatUnitPrice(entry.price.offPeak.input, entry.price.currency)
3228
+ })]
3229
+ }) : formatUnitPrice(entry.price.input, entry.price.currency)
3230
+ }),
3231
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3232
+ className: UsageBilling_module_css_default.numCol,
3233
+ children: entry.price.offPeak !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3234
+ className: UsageBilling_module_css_default.bandPrice,
3235
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatUnitPrice(entry.price.cacheHit, entry.price.currency) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3236
+ className: UsageBilling_module_css_default.bandPriceOff,
3237
+ children: formatUnitPrice(entry.price.offPeak.cacheHit, entry.price.currency)
3238
+ })]
3239
+ }) : formatUnitPrice(entry.price.cacheHit, entry.price.currency)
3240
+ }),
3241
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3242
+ className: UsageBilling_module_css_default.numCol,
3243
+ children: entry.price.offPeak !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3244
+ className: UsageBilling_module_css_default.bandPrice,
3245
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatUnitPrice(entry.price.output, entry.price.currency) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3246
+ className: UsageBilling_module_css_default.bandPriceOff,
3247
+ children: formatUnitPrice(entry.price.offPeak.output, entry.price.currency)
3248
+ })]
3249
+ }) : formatUnitPrice(entry.price.output, entry.price.currency)
3250
+ }),
3251
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: entry.price.offPeak !== void 0 && entry.peakHours !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3252
+ className: UsageBilling_module_css_default.bandTag,
3253
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
3254
+ t("billing.peak"),
3255
+ " ",
3256
+ entry.peakHours
3257
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3258
+ className: UsageBilling_module_css_default.bandTagOff,
3259
+ children: [t("billing.offPeak"), " 50%"]
3260
+ })]
3261
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3262
+ className: UsageBilling_module_css_default.flatTag,
3263
+ children: t("billing.flat")
3264
+ }) })
3265
+ ] }, entry.key)) })]
3266
+ })
3267
+ })]
2857
3268
  })
2858
- })]
2859
- })
2860
- ]
2861
- })]
3269
+ }),
3270
+ renderSlot("billing.dashboard.decor", { position: "footer" })
3271
+ ]
3272
+ })
3273
+ ]
2862
3274
  })
2863
3275
  });
2864
3276
  }
@@ -2918,9 +3330,11 @@ window.__ModuleLoader__.load({
2918
3330
  const today = localDayStamp();
2919
3331
  const monthCost = Object.entries(stats.byDay).filter(([date]) => date.startsWith(today.slice(0, 7))).reduce((sum, [, day]) => sum + day.cost, 0);
2920
3332
  const todayCost = stats.byDay[today]?.cost ?? 0;
3333
+ const weekCost = lastSevenDays(stats.byDay).reduce((sum, d) => sum + d.cost, 0);
3334
+ const last7 = (0, react.useMemo)(() => lastSevenDays(stats.byDay), [stats.byDay]);
2921
3335
  const budgetEnabled = useStore((s) => s.enabled);
2922
3336
  const budgetAmount = useStore((s) => s.amount);
2923
- const budgetAlertedDay = useStore((s) => s.lastAlertDay);
3337
+ const tierAlertDays = useStore((s) => s.tierAlertDays);
2924
3338
  const effectiveBudget = budgetAmount > 0 ? budgetAmount : stats.budget ?? 0;
2925
3339
  const toggleBudget = (0, react.useCallback)(() => {
2926
3340
  const next = !budgetEnabled;
@@ -2930,12 +3344,13 @@ window.__ModuleLoader__.load({
2930
3344
  (0, react.useEffect)(() => {
2931
3345
  if (!budgetEnabled || effectiveBudget <= 0) return;
2932
3346
  const pct = monthCost / effectiveBudget * 100;
2933
- if (pct < 100) return;
2934
3347
  const day = localDayStamp();
2935
- if (budgetAlertedDay === day) return;
2936
- actions.markAlerted(day);
3348
+ const crossed = BUDGET_ALERT_TIERS.filter((tier) => pct >= tier && tierAlertDays?.[String(tier)] !== day);
3349
+ if (crossed.length === 0) return;
3350
+ const top = crossed[crossed.length - 1] ?? 100;
3351
+ actions.markTierAlerted(crossed, day);
2937
3352
  if (typeof Notification === "undefined" || Notification.permission !== "granted") return;
2938
- const body = t("billing.budgetOverBody").replace("{cost}", formatMoney(monthCost)).replace("{budget}", formatMoney(effectiveBudget)).replace("{pct}", pct.toFixed(0));
3353
+ const body = t("billing.budgetTierBody").replace("{cost}", formatMoney(monthCost)).replace("{budget}", formatMoney(effectiveBudget)).replace("{pct}", String(top));
2939
3354
  try {
2940
3355
  new Notification(t("billing.budget"), { body });
2941
3356
  } catch {}
@@ -2943,7 +3358,7 @@ window.__ModuleLoader__.load({
2943
3358
  budgetEnabled,
2944
3359
  effectiveBudget,
2945
3360
  monthCost,
2946
- budgetAlertedDay,
3361
+ tierAlertDays,
2947
3362
  actions,
2948
3363
  t
2949
3364
  ]);
@@ -3002,7 +3417,9 @@ window.__ModuleLoader__.load({
3002
3417
  ...props,
3003
3418
  onOpen: openDashboard,
3004
3419
  monthCost,
3005
- todayCost
3420
+ todayCost,
3421
+ weekCost,
3422
+ days: last7
3006
3423
  }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BillingDashboard, {
3007
3424
  stats,
3008
3425
  t,
@@ -3021,6 +3438,128 @@ window.__ModuleLoader__.load({
3021
3438
  })] });
3022
3439
  }
3023
3440
  //#endregion
3441
+ //#region src/client/live-cost.tsx
3442
+ /**
3443
+ * LiveCostBar: the session-scope cost ticker mounted on the composer's dock,
3444
+ * showing the current session's accumulated spend and the latest turn's cost.
3445
+ *
3446
+ * It rides `conversation.composer.dock` (the stats-line family seat under the
3447
+ * composer card, same posture as ui-conversation's own StatsLine), so it stays
3448
+ * visible while working without opening the full dashboard. Data comes from the
3449
+ * same `/api/billing/usage-stats` endpoint the dashboard polls; the bar reads
3450
+ * the current session id off the framework snapshot (`useSession` parent of
3451
+ * `sessionId`) and matches `bySession` (session total) and `byTurn` (latest
3452
+ * turn cost). Rendering is a pure function of the snapshot, never a side effect.
3453
+ */
3454
+ /**
3455
+ * 当前会话累计费用:bySession 里会话 id 匹配的那行;缺省为 0。
3456
+ * 导出供测试:纯函数。
3457
+ * @param stats - 薄统计切片。
3458
+ * @param sessionId - 当前会话 id。
3459
+ * @returns 该会话累计费用(人民币元)。
3460
+ */
3461
+ function sessionCostOf(stats, sessionId) {
3462
+ if (sessionId === void 0 || stats?.bySession === void 0) return 0;
3463
+ return stats.bySession.find((item) => item.id === sessionId)?.cost ?? 0;
3464
+ }
3465
+ /**
3466
+ * 当前轮费用:byTurn 里该会话最新一轮的 cost;缺省为 0。
3467
+ * byTurn 服务端按起始时间倒序下发,但求 max(turn) 更稳健(不依赖顺序)。
3468
+ * 导出供测试:纯函数。
3469
+ * @param stats - 薄统计切片。
3470
+ * @param sessionId - 当前会话 id。
3471
+ * @returns 最新一轮费用(人民币元)。
3472
+ */
3473
+ function turnCostOf(stats, sessionId) {
3474
+ if (sessionId === void 0 || stats?.byTurn === void 0) return 0;
3475
+ let latest = 0;
3476
+ let latestTurn = -1;
3477
+ for (const item of stats.byTurn) {
3478
+ if (item.sessionId !== sessionId) continue;
3479
+ if (latestTurn === -1 || item.turn > latestTurn) {
3480
+ latestTurn = item.turn;
3481
+ latest = item.cost;
3482
+ }
3483
+ }
3484
+ return latest;
3485
+ }
3486
+ /** Endpoint the node half serves (same constant the dashboard uses). */
3487
+ const USAGE_STATS_PATH = "/api/billing/usage-stats";
3488
+ /** Refresh cadence (ms): matching the dashboard so the bar stays current. */
3489
+ const REFRESH_INTERVAL_MS = 3e4;
3490
+ /** Load the thin stats slice; null when the endpoint does not answer valid JSON. */
3491
+ async function loadLiveStats() {
3492
+ try {
3493
+ const response = await fetch(USAGE_STATS_PATH);
3494
+ if (!response.ok) return null;
3495
+ const text = await response.text();
3496
+ const parsed = JSON.parse(text);
3497
+ if (parsed === null || typeof parsed !== "object") return null;
3498
+ const doc = parsed;
3499
+ return {
3500
+ ...Array.isArray(doc.bySession) ? { bySession: doc.bySession } : {},
3501
+ ...Array.isArray(doc.byTurn) ? { byTurn: doc.byTurn } : {}
3502
+ };
3503
+ } catch {
3504
+ return null;
3505
+ }
3506
+ }
3507
+ /**
3508
+ * Render the live cost ticker for the current session.
3509
+ * @param props - framework session snapshot hook and locale.
3510
+ */
3511
+ function LiveCostBar({ useSession, t }) {
3512
+ const sessionId = useSession((s) => s.sessionId);
3513
+ const [stats, setStats] = (0, react.useState)(null);
3514
+ (0, react.useEffect)(() => {
3515
+ let cancelled = false;
3516
+ const load = () => {
3517
+ loadLiveStats().then((data) => {
3518
+ if (!cancelled && data !== null) setStats(data);
3519
+ });
3520
+ };
3521
+ load();
3522
+ const timer = setInterval(load, REFRESH_INTERVAL_MS);
3523
+ return () => {
3524
+ cancelled = true;
3525
+ clearInterval(timer);
3526
+ };
3527
+ }, [sessionId]);
3528
+ const sessionCost = (0, react.useMemo)(() => sessionCostOf(stats, sessionId), [stats, sessionId]);
3529
+ const turnCost = (0, react.useMemo)(() => turnCostOf(stats, sessionId), [stats, sessionId]);
3530
+ const money = (cny) => formatMoney(cny, "cny");
3531
+ if (sessionId === void 0 || sessionCost <= 0 && turnCost <= 0) return null;
3532
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3533
+ className: UsageBilling_module_css_default.liveCostBar,
3534
+ "data-testid": "billing-live-cost-bar",
3535
+ children: [
3536
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3537
+ className: UsageBilling_module_css_default.liveCostItem,
3538
+ "data-testid": "billing-live-turn",
3539
+ children: [
3540
+ t("billing.liveTurn"),
3541
+ " ",
3542
+ money(turnCost)
3543
+ ]
3544
+ }),
3545
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3546
+ className: UsageBilling_module_css_default.liveCostSep,
3547
+ "aria-hidden": "true",
3548
+ children: "·"
3549
+ }),
3550
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3551
+ className: UsageBilling_module_css_default.liveCostItem,
3552
+ "data-testid": "billing-live-session",
3553
+ children: [
3554
+ t("billing.liveSession"),
3555
+ " ",
3556
+ money(sessionCost)
3557
+ ]
3558
+ })
3559
+ ]
3560
+ });
3561
+ }
3562
+ //#endregion
3024
3563
  //#region src/client/locales.ts
3025
3564
  const NS = "usageBilling";
3026
3565
  const zh = {
@@ -3030,6 +3569,9 @@ window.__ModuleLoader__.load({
3030
3569
  "billing.todayCost": "今日费用",
3031
3570
  "billing.monthCost": "本月费用",
3032
3571
  "billing.yearCost": "本年费用",
3572
+ "billing.monthProjected": "本月预计",
3573
+ "billing.liveTurn": "本轮",
3574
+ "billing.liveSession": "会话",
3033
3575
  "billing.totalCost": "总费用",
3034
3576
  "billing.calls": "调用",
3035
3577
  "billing.cacheHitRate": "缓存命中率",
@@ -3046,7 +3588,7 @@ window.__ModuleLoader__.load({
3046
3588
  "billing.project": "项目",
3047
3589
  "billing.lastActive": "最后活跃",
3048
3590
  "billing.sessionOverflow": "仅显示花费前 {limit} 个,共 {total} 个会话",
3049
- "billing.budgetOverBody": "本月花费 {cost} 已超过预算 {budget}{pct}%)",
3591
+ "billing.budgetTierBody": "本月花费 {cost} 已达预算 {budget}{pct}%",
3050
3592
  "billing.models": "模型计费明细",
3051
3593
  "billing.providerBilling": "厂商计费与订阅",
3052
3594
  "billing.estimated": "估算",
@@ -3075,6 +3617,7 @@ window.__ModuleLoader__.load({
3075
3617
  "billing.balanceUnauthorized": "密钥无效",
3076
3618
  "billing.balanceUnreachable": "查询失败",
3077
3619
  "billing.uncatalogued": "未收录",
3620
+ "billing.estimatedPricing": "估算价",
3078
3621
  "billing.balanceDays": "约可撑 {days} 天",
3079
3622
  "billing.balanceLowBody": "{name} 余额 {balance},约可撑 {days} 天,请及时充值",
3080
3623
  "billing.subscriptions": "订阅套餐",
@@ -3104,7 +3647,24 @@ window.__ModuleLoader__.load({
3104
3647
  "billing.unknownModel": "未定价",
3105
3648
  "billing.model": "模型",
3106
3649
  "billing.currentRound": "当前",
3107
- "billing.costAbbr": "费用"
3650
+ "billing.costAbbr": "费用",
3651
+ "billing.tabOverview": "概览",
3652
+ "billing.tabTrends": "趋势",
3653
+ "billing.tabProviders": "明细",
3654
+ "billing.tabDetails": "统计",
3655
+ "billing.tabPricing": "费率",
3656
+ "billing.export": "导出",
3657
+ "billing.exportCsvDay": "按日 CSV",
3658
+ "billing.exportCsvSession": "按会话 CSV",
3659
+ "billing.exportJson": "全量 JSON",
3660
+ "billing.peakShare": "峰谷时段占比",
3661
+ "billing.peakShareHint": "近 {count} 轮",
3662
+ "billing.weekCost": "本周",
3663
+ "billing.roleCost": "费用构成",
3664
+ "billing.roleUser": "用户输入",
3665
+ "billing.roleAssistant": "助手输出",
3666
+ "billing.roleTool": "工具结果",
3667
+ "billing.roleHint": "估算:输出按实测计价,输入按消息长度摊分"
3108
3668
  };
3109
3669
  const en = {
3110
3670
  "billing.title": "Usage",
@@ -3113,6 +3673,9 @@ window.__ModuleLoader__.load({
3113
3673
  "billing.todayCost": "Today",
3114
3674
  "billing.monthCost": "This month",
3115
3675
  "billing.yearCost": "This year",
3676
+ "billing.monthProjected": "Projected",
3677
+ "billing.liveTurn": "Turn",
3678
+ "billing.liveSession": "Session",
3116
3679
  "billing.totalCost": "Total",
3117
3680
  "billing.calls": "Calls",
3118
3681
  "billing.cacheHitRate": "Cache Hit",
@@ -3129,7 +3692,7 @@ window.__ModuleLoader__.load({
3129
3692
  "billing.project": "Project",
3130
3693
  "billing.lastActive": "Last active",
3131
3694
  "billing.sessionOverflow": "Top {limit} of {total} sessions by cost",
3132
- "billing.budgetOverBody": "This month {cost} exceeded the budget {budget} ({pct}%)",
3695
+ "billing.budgetTierBody": "This month {cost} reached {pct}% of the budget {budget}",
3133
3696
  "billing.models": "Model billing",
3134
3697
  "billing.providerBilling": "Provider billing & subscriptions",
3135
3698
  "billing.estimated": "Est.",
@@ -3158,6 +3721,7 @@ window.__ModuleLoader__.load({
3158
3721
  "billing.balanceUnauthorized": "Bad key",
3159
3722
  "billing.balanceUnreachable": "Unavailable",
3160
3723
  "billing.uncatalogued": "Not catalogued",
3724
+ "billing.estimatedPricing": "Estimated",
3161
3725
  "billing.balanceDays": "~{days} days left",
3162
3726
  "billing.balanceLowBody": "{name} balance {balance}, ~{days} days left, please top up",
3163
3727
  "billing.subscriptions": "Subscriptions",
@@ -3187,7 +3751,24 @@ window.__ModuleLoader__.load({
3187
3751
  "billing.unknownModel": "Unpriced",
3188
3752
  "billing.model": "Model",
3189
3753
  "billing.currentRound": "current",
3190
- "billing.costAbbr": "cost"
3754
+ "billing.costAbbr": "cost",
3755
+ "billing.tabOverview": "Overview",
3756
+ "billing.tabTrends": "Trends",
3757
+ "billing.tabProviders": "Details",
3758
+ "billing.tabDetails": "Stats",
3759
+ "billing.tabPricing": "Rates",
3760
+ "billing.export": "Export",
3761
+ "billing.exportCsvDay": "Daily CSV",
3762
+ "billing.exportCsvSession": "Sessions CSV",
3763
+ "billing.exportJson": "Full JSON",
3764
+ "billing.peakShare": "Peak vs off-peak",
3765
+ "billing.peakShareHint": "last {count} turns",
3766
+ "billing.weekCost": "This week",
3767
+ "billing.roleCost": "Cost breakdown",
3768
+ "billing.roleUser": "User input",
3769
+ "billing.roleAssistant": "Assistant output",
3770
+ "billing.roleTool": "Tool results",
3771
+ "billing.roleHint": "Estimated: output priced exactly, input split by message size"
3191
3772
  };
3192
3773
  //#endregion
3193
3774
  //#region src/client/billing-service.ts
@@ -3238,7 +3819,7 @@ window.__ModuleLoader__.load({
3238
3819
  init: () => ({
3239
3820
  enabled: false,
3240
3821
  amount: 0,
3241
- lastAlertDay: "",
3822
+ tierAlertDays: {},
3242
3823
  lastBalanceAlertDay: ""
3243
3824
  }),
3244
3825
  persist: "dsh.ui-usage-billing.budget",
@@ -3249,8 +3830,9 @@ window.__ModuleLoader__.load({
3249
3830
  setAmount: (d, value) => {
3250
3831
  d.amount = Number.isFinite(value) && value > 0 ? value : 0;
3251
3832
  },
3252
- markAlerted: (d, day) => {
3253
- d.lastAlertDay = day;
3833
+ markTierAlerted: (d, tiers, day) => {
3834
+ d.tierAlertDays ??= {};
3835
+ for (const tier of tiers) d.tierAlertDays[String(tier)] = day;
3254
3836
  },
3255
3837
  markBalanceAlerted: (d, day) => {
3256
3838
  d.lastBalanceAlertDay = day;
@@ -3325,6 +3907,12 @@ window.__ModuleLoader__.load({
3325
3907
  registerOpen: (handler) => metrics.registerOpen(handler)
3326
3908
  })
3327
3909
  }, UsageBilling));
3910
+ ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
3911
+ name: "conversation.composer.dock",
3912
+ id: "usage-billing-cost",
3913
+ order: 0,
3914
+ locale: NS
3915
+ }, LiveCostBar));
3328
3916
  }
3329
3917
  //#endregion
3330
3918
  exports.UsageBilling = UsageBilling;