@carlonicora/nextjs-jsonapi 4.0.5 → 4.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/{BlockNoteEditor-H6EXQD46.js → BlockNoteEditor-J7EF7BRX.js} +9 -9
  2. package/dist/{BlockNoteEditor-H6EXQD46.js.map → BlockNoteEditor-J7EF7BRX.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-L3STMBP2.mjs → BlockNoteEditor-KOHN3SSR.mjs} +2 -2
  4. package/dist/billing/index.js +335 -335
  5. package/dist/billing/index.mjs +1 -1
  6. package/dist/{chunk-3JET3LL7.js → chunk-3M7D6NXU.js} +20 -13
  7. package/dist/chunk-3M7D6NXU.js.map +1 -0
  8. package/dist/{chunk-KX2776OK.mjs → chunk-3W3VVX2N.mjs} +322 -315
  9. package/dist/chunk-3W3VVX2N.mjs.map +1 -0
  10. package/dist/client/index.js +2 -2
  11. package/dist/client/index.mjs +1 -1
  12. package/dist/components/index.js +2 -2
  13. package/dist/components/index.mjs +1 -1
  14. package/dist/contexts/index.js +2 -2
  15. package/dist/contexts/index.mjs +1 -1
  16. package/dist/features/analytics/index.js +88 -88
  17. package/dist/features/analytics/index.mjs +1 -1
  18. package/dist/features/help/index.js +31 -31
  19. package/dist/features/help/index.mjs +1 -1
  20. package/dist/features/tokenusage/index.js +75 -75
  21. package/dist/features/tokenusage/index.mjs +1 -1
  22. package/package.json +1 -1
  23. package/src/components/navigations/RecentPagesNavigator.tsx +11 -1
  24. package/src/components/navigations/__tests__/RecentPagesNavigator.spec.tsx +19 -0
  25. package/src/shadcnui/ui/__tests__/sidebar.session.test.tsx +136 -0
  26. package/src/shadcnui/ui/sidebar.tsx +21 -13
  27. package/dist/chunk-3JET3LL7.js.map +0 -1
  28. package/dist/chunk-KX2776OK.mjs.map +0 -1
  29. /package/dist/{BlockNoteEditor-L3STMBP2.mjs.map → BlockNoteEditor-KOHN3SSR.mjs.map} +0 -0
@@ -37,7 +37,7 @@ var _chunkC2WQXUL5js = require('../../chunk-C2WQXUL5.js');
37
37
 
38
38
 
39
39
 
40
- var _chunk3JET3LL7js = require('../../chunk-3JET3LL7.js');
40
+ var _chunk3M7D6NXUjs = require('../../chunk-3M7D6NXU.js');
41
41
  require('../../chunk-7ZRQOLSV.js');
42
42
  require('../../chunk-G4JR3SFV.js');
43
43
 
@@ -82,7 +82,7 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
82
82
  };
83
83
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap items-center gap-2", children: [
84
84
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "max-md:w-full max-md:[&_#date]:w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
85
- _chunk3JET3LL7js.DateRangeSelector,
85
+ _chunk3M7D6NXUjs.DateRangeSelector,
86
86
  {
87
87
  onDateChange: (range) => {
88
88
  if (!_optionalChain([range, 'optionalAccess', _ => _.from]) || !_optionalChain([range, 'optionalAccess', _2 => _2.to])) return;
@@ -117,16 +117,16 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
117
117
  }
118
118
  ),
119
119
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
120
- _chunk3JET3LL7js.Select,
120
+ _chunk3M7D6NXUjs.Select,
121
121
  {
122
122
  items: companyItems,
123
123
  value: _nullishCoalesce(companyId, () => ( ALL_COMPANIES)),
124
124
  onValueChange: (value) => onChange({ companyId: !value || value === ALL_COMPANIES ? void 0 : value }),
125
125
  children: [
126
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectTrigger, { className: "w-56", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectValue, { placeholder: t("token_usage.admin.all_companies") }) }),
127
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.SelectContent, { children: [
128
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectItem, { value: ALL_COMPANIES, children: t("token_usage.admin.all_companies") }),
129
- companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectItem, { value: company.id, children: company.label }, company.id))
126
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectTrigger, { className: "w-56", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectValue, { placeholder: t("token_usage.admin.all_companies") }) }),
127
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.SelectContent, { children: [
128
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectItem, { value: ALL_COMPANIES, children: t("token_usage.admin.all_companies") }),
129
+ companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectItem, { value: company.id, children: company.label }, company.id))
130
130
  ] })
131
131
  ]
132
132
  }
@@ -149,7 +149,7 @@ function Segmented({
149
149
  children: options.map((option) => {
150
150
  const selected = option.value === value;
151
151
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
152
- _chunk3JET3LL7js.Button,
152
+ _chunk3M7D6NXUjs.Button,
153
153
  {
154
154
  type: "button",
155
155
  size: "sm",
@@ -231,7 +231,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
231
231
  pageUrl = TOKEN_USAGE_ADMIN_PAGE_URL
232
232
  }) => {
233
233
  const t = _nextintl.useTranslations.call(void 0, );
234
- const generateUrl = _chunk3JET3LL7js.usePageUrlGenerator.call(void 0, );
234
+ const generateUrl = _chunk3M7D6NXUjs.usePageUrlGenerator.call(void 0, );
235
235
  const [filters, setFilterState] = _react.useState.call(void 0, () => {
236
236
  const range = defaultRange();
237
237
  return {
@@ -349,7 +349,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
349
349
  error
350
350
  ]
351
351
  );
352
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminContext.Provider, { value: contextValue, children }) });
352
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminContext.Provider, { value: contextValue, children }) });
353
353
  }, "TokenUsageAdminProvider");
354
354
  var useTokenUsageAdmin = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
355
355
  const ctx = _react.useContext.call(void 0, TokenUsageAdminContext);
@@ -446,7 +446,7 @@ function LeadTile({
446
446
  previousLabel,
447
447
  decimal
448
448
  }) {
449
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.CardContent, { className: "grid gap-1", children: [
449
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
450
450
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
451
451
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: value }),
452
452
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
@@ -463,7 +463,7 @@ function SupportingTile({
463
463
  delta,
464
464
  decimal
465
465
  }) {
466
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { "data-testid": testId, size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.CardContent, { className: "grid gap-1", children: [
466
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": testId, size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
467
467
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
468
468
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-2", children: [
469
469
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: value }),
@@ -560,8 +560,8 @@ function TokenUsageBreakdownTable({ rows, metric }) {
560
560
  // The package's <Table> wraps itself in an `overflow-x-clip` container, which
561
561
  // would swallow the overflow before this scroller ever saw it — hence the
562
562
  // child override. Wide metric tables must scroll, never widen the page.
563
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-x-auto [&_[data-slot=table-container]]:overflow-x-visible", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Table, { children: [
564
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableHead, { className: _chunk5PNDDYGLjs.cn.call(void 0, column.numeric && "text-end"), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
563
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-x-auto [&_[data-slot=table-container]]:overflow-x-visible", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Table, { children: [
564
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableHead, { className: _chunk5PNDDYGLjs.cn.call(void 0, column.numeric && "text-end"), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
565
565
  "button",
566
566
  {
567
567
  type: "button",
@@ -576,20 +576,20 @@ function TokenUsageBreakdownTable({ rows, metric }) {
576
576
  ]
577
577
  }
578
578
  ) }, column.key)) }) }),
579
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableBody, { children: sortedRows.map((row) => {
579
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableBody, { children: sortedRows.map((row) => {
580
580
  const value = _chunkC2WQXUL5js.metricValue.call(void 0, row, metric);
581
581
  const share = total > 0 ? value / total * 100 : 0;
582
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.TableRow, { "data-testid": `breakdown-row-${row.id}`, children: [
583
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-xs", children: row.id === "other" ? t("token_usage.admin.other") : row.label }),
584
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-muted-foreground text-xs", children: _nullishCoalesce(row.sublabel, () => ( "")) }),
585
- showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: row.activeUsers === void 0 ? "" : decimal(row.activeUsers, 0) }),
586
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.calls, 0) }),
587
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensIn, 0) }),
588
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensOut, 0) }),
589
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: percent(_chunkC2WQXUL5js.cacheHitPercentage.call(void 0, row.cached, row.tokensIn)) }),
590
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.cost, "cost") }),
591
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.credits, "credits") }),
592
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.TableCell, { className: "text-end text-xs tabular-nums", children: percent(share) })
582
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.TableRow, { "data-testid": `breakdown-row-${row.id}`, children: [
583
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-xs", children: row.id === "other" ? t("token_usage.admin.other") : row.label }),
584
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-muted-foreground text-xs", children: _nullishCoalesce(row.sublabel, () => ( "")) }),
585
+ showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: row.activeUsers === void 0 ? "" : decimal(row.activeUsers, 0) }),
586
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.calls, 0) }),
587
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensIn, 0) }),
588
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensOut, 0) }),
589
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(_chunkC2WQXUL5js.cacheHitPercentage.call(void 0, row.cached, row.tokensIn)) }),
590
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.cost, "cost") }),
591
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.credits, "credits") }),
592
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(share) })
593
593
  ] }, row.id);
594
594
  }) })
595
595
  ] }) })
@@ -757,7 +757,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
757
757
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className, dir: "ltr", children: [
758
758
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-data", children: JSON.stringify(chartData) }),
759
759
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-series", children: JSON.stringify(seriesKeys) }),
760
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.ChartContainer, { config: chartConfig, className: "aspect-auto h-72 w-full", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _recharts.BarChart, { accessibilityLayer: true, data: chartData, margin: { top: 8, right: 8, bottom: 0, left: 0 }, children: [
760
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.ChartContainer, { config: chartConfig, className: "aspect-auto h-72 w-full", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _recharts.BarChart, { accessibilityLayer: true, data: chartData, margin: { top: 8, right: 8, bottom: 0, left: 0 }, children: [
761
761
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _recharts.CartesianGrid, { vertical: false }),
762
762
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
763
763
  _recharts.XAxis,
@@ -781,10 +781,10 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
781
781
  }
782
782
  ),
783
783
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
784
- _chunk3JET3LL7js.ChartTooltip,
784
+ _chunk3M7D6NXUjs.ChartTooltip,
785
785
  {
786
786
  content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
787
- _chunk3JET3LL7js.ChartTooltipContent,
787
+ _chunk3M7D6NXUjs.ChartTooltipContent,
788
788
  {
789
789
  labelFormatter: (value) => bucketDate(String(value), granularity),
790
790
  valueFormatter: (value) => formatValue(Number(value), metric),
@@ -793,7 +793,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
793
793
  )
794
794
  }
795
795
  ),
796
- seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.ChartLegend, { content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.ChartLegendContent, {}) }) : null,
796
+ seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.ChartLegend, { content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.ChartLegendContent, {}) }) : null,
797
797
  seriesKeys.map((series, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
798
798
  _recharts.Bar,
799
799
  {
@@ -845,19 +845,19 @@ function TokenUsageAdminContainer() {
845
845
  [t]
846
846
  );
847
847
  if (error) {
848
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
848
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
849
849
  }
850
- if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.RoundPageContainer, { fullWidth: true, forceHeader: true });
850
+ if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
851
851
  const emptyLabel = t("token_usage.admin.no_data");
852
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
852
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
853
853
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminTiles, { summary, metric: filters.metric, singleCustomerMode: hidePlatform }),
854
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
855
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.CardHeader, { children: [
856
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.admin.usage_over_time") }),
857
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardAction, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
854
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
855
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: [
856
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.usage_over_time") }),
857
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardAction, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
858
858
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.admin.stack_by") }),
859
859
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
860
- _chunk3JET3LL7js.Select,
860
+ _chunk3M7D6NXUjs.Select,
861
861
  {
862
862
  items: stackByItems,
863
863
  value: filters.stackBy,
@@ -865,29 +865,29 @@ function TokenUsageAdminContainer() {
865
865
  if (value) setFilters({ stackBy: value });
866
866
  },
867
867
  children: [
868
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectValue, {}) }),
869
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectContent, { children: STACK_BY_VALUES.map((value) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SelectItem, { value, children: stackByItems[value] }, value)) })
868
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectValue, {}) }),
869
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectContent, { children: STACK_BY_VALUES.map((value) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectItem, { value, children: stackByItems[value] }, value)) })
870
870
  ]
871
871
  }
872
872
  )
873
873
  ] }) })
874
874
  ] }),
875
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: filters.metric, stackBy: filters.stackBy }) })
875
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: filters.metric, stackBy: filters.stackBy }) })
876
876
  ] }),
877
877
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-4 md:grid-cols-2", children: [
878
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
879
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.admin.by_company") }) }),
880
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byCompany, metric: filters.metric, emptyLabel }) })
878
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
879
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.by_company") }) }),
880
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byCompany, metric: filters.metric, emptyLabel }) })
881
881
  ] }),
882
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
883
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.admin.by_user") }) }),
884
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byUser, metric: filters.metric, emptyLabel }) })
882
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
883
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.by_user") }) }),
884
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byUser, metric: filters.metric, emptyLabel }) })
885
885
  ] })
886
886
  ] }),
887
887
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk5PNDDYGLjs.cn.call(void 0, "grid gap-4", !hidePlatform && "md:grid-cols-2"), children: [
888
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
889
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.admin.customer_by_operation") }) }),
890
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
888
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
889
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.customer_by_operation") }) }),
890
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
891
891
  TokenUsageRankedBar,
892
892
  {
893
893
  rows: byCustomerOperation,
@@ -897,9 +897,9 @@ function TokenUsageAdminContainer() {
897
897
  }
898
898
  ) })
899
899
  ] }),
900
- !hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
901
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.admin.platform_by_operation") }) }),
902
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
900
+ !hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
901
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.platform_by_operation") }) }),
902
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
903
903
  TokenUsageRankedBar,
904
904
  {
905
905
  rows: byOperation,
@@ -910,9 +910,9 @@ function TokenUsageAdminContainer() {
910
910
  ) })
911
911
  ] })
912
912
  ] }),
913
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
914
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.admin.detail") }) }),
915
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageBreakdownTable, { rows: byCompany, metric: filters.metric }) })
913
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
914
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.detail") }) }),
915
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageBreakdownTable, { rows: byCompany, metric: filters.metric }) })
916
916
  ] })
917
917
  ] }) });
918
918
  }
@@ -1033,7 +1033,7 @@ var TOKEN_USAGE_REPORT_I18N_KEYS = [
1033
1033
 
1034
1034
  function TokenUsageReportFilterBar({ onChange }) {
1035
1035
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-help": "tokenusage.filters", className: "flex flex-wrap items-center gap-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1036
- _chunk3JET3LL7js.DateRangeSelector,
1036
+ _chunk3M7D6NXUjs.DateRangeSelector,
1037
1037
  {
1038
1038
  onDateChange: (range) => {
1039
1039
  if (!_optionalChain([range, 'optionalAccess', _5 => _5.from]) || !_optionalChain([range, 'optionalAccess', _6 => _6.to])) return;
@@ -1066,7 +1066,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
1066
1066
  pageUrl = TOKEN_USAGE_REPORT_PAGE_URL
1067
1067
  }) => {
1068
1068
  const t = _nextintl.useTranslations.call(void 0, );
1069
- const generateUrl = _chunk3JET3LL7js.usePageUrlGenerator.call(void 0, );
1069
+ const generateUrl = _chunk3M7D6NXUjs.usePageUrlGenerator.call(void 0, );
1070
1070
  const [filters, setFilterState] = _react.useState.call(void 0, () => {
1071
1071
  const range = defaultRange2();
1072
1072
  return { from: _nullishCoalesce(initialFrom, () => ( range.from)), to: _nullishCoalesce(initialTo, () => ( range.to)) };
@@ -1130,7 +1130,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
1130
1130
  () => ({ summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error }),
1131
1131
  [summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error]
1132
1132
  );
1133
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportContext.Provider, { value: contextValue, children }) });
1133
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportContext.Provider, { value: contextValue, children }) });
1134
1134
  }, "TokenUsageReportProvider");
1135
1135
  var useTokenUsageReport = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
1136
1136
  const ctx = _react.useContext.call(void 0, TokenUsageReportContext);
@@ -1158,7 +1158,7 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1158
1158
  const monthlyColor = monthlyPercentage > 75 ? "text-success" : monthlyPercentage >= 5 ? "text-warning" : "text-destructive";
1159
1159
  const whole = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (value) => decimal(Math.max(0, Math.floor(value)), 0), "whole");
1160
1160
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3", children: [
1161
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { "data-testid": "tile-used", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.CardContent, { className: "grid gap-1", children: [
1161
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-used", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1162
1162
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.used_in_period") }),
1163
1163
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: formatValue(_chunkC2WQXUL5js.metricValue.call(void 0, current, metric), metric) }),
1164
1164
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
@@ -1174,7 +1174,7 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1174
1174
  ] })
1175
1175
  ] }) }),
1176
1176
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3 sm:grid-cols-3", children: [
1177
- balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { "data-testid": "tile-monthly", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.CardContent, { className: "grid gap-1", children: [
1177
+ balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-monthly", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1178
1178
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.monthly_left") }),
1179
1179
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-baseline gap-1", children: [
1180
1180
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "data-testid": "tile-monthly-value", className: _chunk5PNDDYGLjs.cn.call(void 0, "text-sm font-medium tabular-nums", monthlyColor), children: whole(balances.availableMonthlyCredits) }),
@@ -1184,11 +1184,11 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1184
1184
  ] })
1185
1185
  ] })
1186
1186
  ] }) }),
1187
- balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { "data-testid": "tile-extra", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.CardContent, { className: "grid gap-1", children: [
1187
+ balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-extra", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1188
1188
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.extra_credits") }),
1189
1189
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: whole(balances.availableExtraCredits) })
1190
1190
  ] }) }),
1191
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { "data-testid": "tile-calls", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.CardContent, { className: "grid gap-1", children: [
1191
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-calls", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1192
1192
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.calls") }),
1193
1193
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: decimal(current.calls, 0) })
1194
1194
  ] }) })
@@ -1230,21 +1230,21 @@ function TokenUsageReportContainer({ balances = null }) {
1230
1230
  const t = _nextintl.useTranslations.call(void 0, );
1231
1231
  const { summary, timeline, byOperation, byTarget, isLoading, error, targetPanelTitleKey } = useTokenUsageReport();
1232
1232
  if (error) {
1233
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
1233
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
1234
1234
  }
1235
- if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.RoundPageContainer, { fullWidth: true, forceHeader: true });
1235
+ if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
1236
1236
  const emptyLabel = t("token_usage.report.no_data");
1237
1237
  const targetTitle = targetPanelTitleKey && byTarget.length > 0 ? t(targetPanelTitleKey) : void 0;
1238
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
1238
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
1239
1239
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportTiles, { summary, metric: "credits", balances }),
1240
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
1241
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.report.usage_over_time") }) }),
1242
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: "credits", stackBy: "type" }) })
1240
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
1241
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.report.usage_over_time") }) }),
1242
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: "credits", stackBy: "type" }) })
1243
1243
  ] }),
1244
1244
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk5PNDDYGLjs.cn.call(void 0, "grid gap-4", targetTitle && "md:grid-cols-2"), children: [
1245
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
1246
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: t("token_usage.report.by_operation") }) }),
1247
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1245
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
1246
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.report.by_operation") }) }),
1247
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1248
1248
  TokenUsageRankedBar,
1249
1249
  {
1250
1250
  rows: byOperation,
@@ -1254,9 +1254,9 @@ function TokenUsageReportContainer({ balances = null }) {
1254
1254
  }
1255
1255
  ) })
1256
1256
  ] }),
1257
- targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3JET3LL7js.Card, { children: [
1258
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardTitle, { children: targetTitle }) }),
1259
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3JET3LL7js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byTarget, metric: "credits", emptyLabel }) })
1257
+ targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
1258
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: targetTitle }) }),
1259
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byTarget, metric: "credits", emptyLabel }) })
1260
1260
  ] })
1261
1261
  ] })
1262
1262
  ] }) });
@@ -37,7 +37,7 @@ import {
37
37
  TableHeader,
38
38
  TableRow,
39
39
  usePageUrlGenerator
40
- } from "../../chunk-KX2776OK.mjs";
40
+ } from "../../chunk-3W3VVX2N.mjs";
41
41
  import "../../chunk-XTOEN5GN.mjs";
42
42
  import "../../chunk-PW42LRSL.mjs";
43
43
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlonicora/nextjs-jsonapi",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "description": "Next.js JSON:API client with server/client support and caching",
5
5
  "author": "Carlo Nicora",
6
6
  "license": "GPL-3.0-or-later",
@@ -4,6 +4,7 @@ import { useAtomValue } from "jotai";
4
4
  import { HistoryIcon } from "lucide-react";
5
5
  import { useTranslations } from "next-intl";
6
6
  import { usePathname } from "next/navigation";
7
+ import { useEffect, useState } from "react";
7
8
  import { recentPagesAtom } from "../../atoms";
8
9
  import {
9
10
  DropdownMenu,
@@ -36,6 +37,15 @@ export function RecentPagesNavigator() {
36
37
  const t = useTranslations();
37
38
  const { isMobile } = useSidebar();
38
39
  const pathname = usePathname();
40
+ const [mounted, setMounted] = useState(false);
41
+
42
+ // The list lives in localStorage, which the server cannot read, so the server
43
+ // renders nothing. Under Cache Components the sidebar hydrates in its own
44
+ // boundary, after usePageTracker has already loaded the stored list into the
45
+ // atom; rendering it before mount would not match the server HTML.
46
+ useEffect(() => {
47
+ setMounted(true);
48
+ }, []);
39
49
 
40
50
  // The page the user is standing on is not somewhere to navigate back to, so
41
51
  // it is hidden while they are there. Filtering happens here rather than in
@@ -50,7 +60,7 @@ export function RecentPagesNavigator() {
50
60
 
51
61
  const pages = recentPages.filter((page) => !isCurrentPage(page.url));
52
62
 
53
- if (pages.length === 0) return null;
63
+ if (!mounted || pages.length === 0) return null;
54
64
 
55
65
  return (
56
66
  <SidebarMenuItem>
@@ -1,6 +1,7 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
  import { createStore, Provider } from "jotai";
4
+ import { renderToString } from "react-dom/server";
4
5
  import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
5
6
  import { recentPagesAtom, type RecentPage } from "../../../atoms";
6
7
  import { configureI18n } from "../../../i18n";
@@ -78,6 +79,24 @@ function renderNavigator({
78
79
  }
79
80
 
80
81
  describe("RecentPagesNavigator", () => {
82
+ it("renders nothing before mount even when pages are stored, so the server HTML matches", () => {
83
+ // Regression: under Cache Components the sidebar hydrates after usePageTracker
84
+ // has loaded localStorage into the atom; rendering the row on the first pass
85
+ // put an <li> the server never sent and failed hydration.
86
+ const store = createStore();
87
+ store.set(recentPagesAtom, PAGES);
88
+ const html = renderToString(
89
+ <Provider store={store}>
90
+ <SidebarProvider open>
91
+ <SidebarMenu>
92
+ <RecentPagesNavigator />
93
+ </SidebarMenu>
94
+ </SidebarProvider>
95
+ </Provider>,
96
+ );
97
+ expect(html).not.toContain("sidebar-recent-pages");
98
+ });
99
+
81
100
  it("renders nothing when no pages have been recorded", () => {
82
101
  renderNavigator({ pages: [] });
83
102
  expect(screen.queryByTestId("sidebar-recent-pages")).toBeNull();
@@ -1,6 +1,7 @@
1
1
  import { act, render, screen } from "@testing-library/react";
2
2
  import * as React from "react";
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
+ import { ViewportProvider } from "../../../contexts/ViewportContext";
4
5
  import type { SessionSnapshot } from "../../../server/ServerSession";
5
6
  import { SidebarProvider, useSidebar, useSidebarControls } from "../sidebar";
6
7
 
@@ -131,3 +132,138 @@ describe("SidebarProvider with a session", () => {
131
132
  expect(screen.getByTestId("state").textContent).toBe("collapsed");
132
133
  });
133
134
  });
135
+
136
+ describe("SidebarProvider with a session inside a ViewportProvider", () => {
137
+ let viewportListeners: Array<() => void>;
138
+
139
+ function setWidth(width: number) {
140
+ Object.defineProperty(window, "innerWidth", { writable: true, configurable: true, value: width });
141
+ }
142
+
143
+ function resize(width: number) {
144
+ setWidth(width);
145
+ for (const listener of viewportListeners) listener();
146
+ }
147
+
148
+ beforeEach(() => {
149
+ viewportListeners = [];
150
+ vi.stubGlobal(
151
+ "matchMedia",
152
+ vi.fn(() => ({
153
+ matches: false,
154
+ addEventListener: (_: string, listener: () => void) => viewportListeners.push(listener),
155
+ removeEventListener: (_: string, listener: () => void) => {
156
+ viewportListeners = viewportListeners.filter((l) => l !== listener);
157
+ },
158
+ })),
159
+ );
160
+ });
161
+
162
+ afterEach(() => {
163
+ vi.unstubAllGlobals();
164
+ setWidth(1024);
165
+ });
166
+
167
+ // The documented 4.0 shell: both providers receive the same session promise.
168
+ function Shell({ session }: { session: Promise<SessionSnapshot> }) {
169
+ return (
170
+ <ViewportProvider session={session}>
171
+ <SidebarProvider session={session}>
172
+ <React.Suspense fallback="waiting">
173
+ <MobileReader />
174
+ </React.Suspense>
175
+ </SidebarProvider>
176
+ </ViewportProvider>
177
+ );
178
+ }
179
+
180
+ it("follows the measurement when the session says mobile and the viewport is desktop", async () => {
181
+ setWidth(1280);
182
+ const session = deferred<SessionSnapshot>();
183
+ await act(async () => {
184
+ render(<Shell session={session.promise} />);
185
+ });
186
+ await act(async () => {
187
+ session.resolve(snapshot({ isMobile: true }));
188
+ });
189
+
190
+ expect(screen.getByText("desktop")).toBeInTheDocument();
191
+ });
192
+
193
+ it("follows the measurement when the session says desktop and the viewport is mobile", async () => {
194
+ setWidth(500);
195
+ const session = deferred<SessionSnapshot>();
196
+ await act(async () => {
197
+ render(<Shell session={session.promise} />);
198
+ });
199
+ await act(async () => {
200
+ session.resolve(snapshot({ isMobile: false }));
201
+ });
202
+
203
+ expect(screen.getByText("mobile")).toBeInTheDocument();
204
+ });
205
+
206
+ it("follows a live resize across the breakpoint", async () => {
207
+ setWidth(500);
208
+ const session = deferred<SessionSnapshot>();
209
+ await act(async () => {
210
+ render(<Shell session={session.promise} />);
211
+ });
212
+ await act(async () => {
213
+ session.resolve(snapshot({ isMobile: true }));
214
+ });
215
+ expect(screen.getByText("mobile")).toBeInTheDocument();
216
+
217
+ act(() => resize(1280));
218
+ expect(screen.getByText("desktop")).toBeInTheDocument();
219
+
220
+ act(() => resize(500));
221
+ expect(screen.getByText("mobile")).toBeInTheDocument();
222
+ });
223
+
224
+ it("toggleSidebar acts on the live value", async () => {
225
+ setWidth(1280);
226
+ const session = deferred<SessionSnapshot>();
227
+ function Toggler() {
228
+ const { toggleSidebar, state, openMobile } = useSidebar();
229
+ return (
230
+ <button onClick={toggleSidebar}>
231
+ {state}/{openMobile ? "sheet-open" : "sheet-closed"}
232
+ </button>
233
+ );
234
+ }
235
+ await act(async () => {
236
+ render(
237
+ <ViewportProvider session={session.promise}>
238
+ <SidebarProvider session={session.promise}>
239
+ <React.Suspense fallback="waiting">
240
+ <Toggler />
241
+ </React.Suspense>
242
+ </SidebarProvider>
243
+ </ViewportProvider>,
244
+ );
245
+ });
246
+ await act(async () => {
247
+ session.resolve(snapshot({ isMobile: true, sidebarOpen: true }));
248
+ });
249
+
250
+ act(() => screen.getByRole("button").click());
251
+ expect(screen.getByRole("button").textContent).toBe("collapsed/sheet-closed");
252
+ });
253
+
254
+ it("useSidebarControls never suspends while the session is pending", () => {
255
+ const pending = new Promise<SessionSnapshot>(() => {});
256
+ function ControlsReader() {
257
+ const { state } = useSidebarControls();
258
+ return <p>{state}</p>;
259
+ }
260
+ render(
261
+ <ViewportProvider session={pending}>
262
+ <SidebarProvider session={pending}>
263
+ <ControlsReader />
264
+ </SidebarProvider>
265
+ </ViewportProvider>,
266
+ );
267
+ expect(screen.getByText("expanded")).toBeInTheDocument();
268
+ });
269
+ });