@burdenoff/microfe-billing 2026.601.6 → 2026.604.2

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.
@@ -1,22 +1,23 @@
1
1
  import { useBilling as e } from "../../../providers/BillingProvider.js";
2
2
  import { statusTokens as t } from "../../../shared/utils/tokens.js";
3
- import { formatDateTime as n, formatNumber as r, formatRelativeTime as i } from "../../../shared/utils/format.js";
4
- import { useBillingPermissions as a } from "../../../hooks/useBillingPermissions.js";
5
- import { useBillingAccountsForUsage as o, useEnhancedUsagePage as s, useQuotaUsageDetails as c, useWorkspaceQuotaHistory as l } from "../hooks/useUsage.js";
6
- import { useCallback as u, useDeferredValue as d, useMemo as f, useState as p } from "react";
7
- import { AlertCircle as m, AlertTriangle as h, CheckCircle as g, ChevronDown as _, ChevronLeft as v, ChevronRight as y, Clock as b, Info as x, Layers as S, Package as C, RefreshCw as w, Search as T, X as E, XCircle as D } from "lucide-react";
8
- import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
9
- import { useI18n as ee } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
3
+ import { QuotaStatus as n } from "../../../shared/types/graphql.js";
4
+ import { formatDateTime as r, formatNumber as i, formatRelativeTime as a } from "../../../shared/utils/format.js";
5
+ import { useBillingPermissions as o } from "../../../hooks/useBillingPermissions.js";
6
+ import { useBillingAccountsForUsage as s, useEnhancedUsagePage as c, useQuotaUsageDetails as l, useWorkspaceQuotaHistory as u, useWorkspaceQuotaOverview as d } from "../hooks/useUsage.js";
7
+ import { useCallback as ee, useDeferredValue as f, useMemo as p, useState as m } from "react";
8
+ import { AlertCircle as h, AlertTriangle as g, CheckCircle as _, ChevronDown as v, ChevronLeft as y, ChevronRight as b, Clock as x, Info as S, Layers as C, Package as w, RefreshCw as T, Search as E, X as D, XCircle as O } from "lucide-react";
9
+ import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
10
+ import { useI18n as te } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
10
11
  //#region src/billing/modules/usage/pages/UsagePage.tsx
11
- var te = ({ status: e, className: n = "size-4" }) => {
12
+ var ne = ({ status: e, className: n = "size-4" }) => {
12
13
  switch (e) {
13
- case "EXHAUSTED": return /* @__PURE__ */ k(D, { className: `${n} ${t.error.icon}` });
14
- case "CRITICAL": return /* @__PURE__ */ k(h, { className: `${n} ${t.error.icon}` });
15
- case "WARNING": return /* @__PURE__ */ k(m, { className: `${n} ${t.warning.icon}` });
16
- case "HEALTHY": return /* @__PURE__ */ k(g, { className: `${n} ${t.success.icon}` });
17
- default: return /* @__PURE__ */ k(x, { className: `${n} ${t.neutral.icon}` });
14
+ case "EXHAUSTED": return /* @__PURE__ */ A(O, { className: `${n} ${t.error.icon}` });
15
+ case "CRITICAL": return /* @__PURE__ */ A(g, { className: `${n} ${t.error.icon}` });
16
+ case "WARNING": return /* @__PURE__ */ A(h, { className: `${n} ${t.warning.icon}` });
17
+ case "HEALTHY": return /* @__PURE__ */ A(_, { className: `${n} ${t.success.icon}` });
18
+ default: return /* @__PURE__ */ A(S, { className: `${n} ${t.neutral.icon}` });
18
19
  }
19
- }, j = ({ status: e }) => /* @__PURE__ */ k("span", {
20
+ }, M = ({ status: e }) => /* @__PURE__ */ A("span", {
20
21
  className: `px-2 py-0.5 text-xs font-medium rounded ${{
21
22
  EXHAUSTED: `${t.error.bg} ${t.error.text}`,
22
23
  CRITICAL: `${t.error.bg} ${t.error.text}`,
@@ -25,11 +26,11 @@ var te = ({ status: e, className: n = "size-4" }) => {
25
26
  INACTIVE: `${t.neutral.bg} ${t.neutral.text}`
26
27
  }[e]}`,
27
28
  children: e
28
- }), M = ({ percentage: e, status: n }) => {
29
+ }), N = ({ percentage: e, status: n }) => {
29
30
  let r = Math.min(100, Math.max(0, e));
30
- return /* @__PURE__ */ k("div", {
31
+ return /* @__PURE__ */ A("div", {
31
32
  className: "w-full bg-muted rounded-full h-2.5 overflow-hidden",
32
- children: /* @__PURE__ */ k("div", {
33
+ children: /* @__PURE__ */ A("div", {
33
34
  className: `h-full rounded-full transition-all duration-300 ${{
34
35
  EXHAUSTED: t.error.dot,
35
36
  CRITICAL: t.error.dot,
@@ -40,7 +41,7 @@ var te = ({ status: e, className: n = "size-4" }) => {
40
41
  style: { width: `${r}%` }
41
42
  })
42
43
  });
43
- }, N = ({ label: e, value: n, icon: r, color: i, isActive: a, onClick: o }) => {
44
+ }, P = ({ label: e, value: n, icon: r, color: i, isActive: a, onClick: o }) => {
44
45
  let s = {
45
46
  blue: t.info,
46
47
  emerald: t.success,
@@ -66,119 +67,119 @@ var te = ({ status: e, className: n = "size-4" }) => {
66
67
  red: t.error.icon,
67
68
  gray: t.neutral.icon
68
69
  };
69
- return /* @__PURE__ */ A("button", {
70
+ return /* @__PURE__ */ j("button", {
70
71
  type: "button",
71
72
  onClick: o,
72
73
  className: `border rounded-lg p-4 w-full text-left transition-all ${c[i]} ${o ? "cursor-pointer hover:shadow-md" : ""} ${a ? l[i] : ""}`,
73
- children: [/* @__PURE__ */ A("div", {
74
+ children: [/* @__PURE__ */ j("div", {
74
75
  className: "flex items-center gap-2 mb-2",
75
- children: [/* @__PURE__ */ k("span", {
76
+ children: [/* @__PURE__ */ A("span", {
76
77
  className: u[i],
77
78
  children: r
78
- }), /* @__PURE__ */ k("span", {
79
+ }), /* @__PURE__ */ A("span", {
79
80
  className: "text-sm text-muted-foreground",
80
81
  children: e
81
82
  })]
82
- }), /* @__PURE__ */ k("p", {
83
+ }), /* @__PURE__ */ A("p", {
83
84
  className: "text-2xl font-bold text-foreground",
84
85
  children: n
85
86
  })]
86
87
  });
87
- }, P = ({ quota: e, planLabel: t, onClick: n }) => {
88
- let i = e.totalLimit != null && e.totalLimit > 0 && !e.noLimit;
89
- return /* @__PURE__ */ A("tr", {
88
+ }, F = ({ quota: e, planLabel: t, onClick: n }) => {
89
+ let r = e.totalLimit != null && e.totalLimit > 0 && !e.noLimit;
90
+ return /* @__PURE__ */ j("tr", {
90
91
  onClick: n,
91
92
  className: "cursor-pointer hover:bg-muted/40 transition-colors border-b border-border last:border-b-0",
92
93
  children: [
93
- /* @__PURE__ */ A("td", {
94
+ /* @__PURE__ */ j("td", {
94
95
  className: "px-4 py-3",
95
96
  children: [
96
- /* @__PURE__ */ k("span", {
97
+ /* @__PURE__ */ A("span", {
97
98
  className: "text-sm font-medium text-primary hover:underline capitalize",
98
99
  children: e.displayName || e.name.replace(/_/g, " ")
99
100
  }),
100
- /* @__PURE__ */ k("span", {
101
+ /* @__PURE__ */ A("span", {
101
102
  className: "block text-xs font-mono text-muted-foreground mt-0.5",
102
103
  children: e.name
103
104
  }),
104
- e.description && /* @__PURE__ */ k("span", {
105
+ e.description && /* @__PURE__ */ A("span", {
105
106
  className: "block text-xs text-muted-foreground mt-0.5 max-w-[220px] truncate",
106
107
  children: e.description
107
108
  }),
108
- e.quotaCount > 1 && /* @__PURE__ */ A("span", {
109
+ e.quotaCount > 1 && /* @__PURE__ */ j("span", {
109
110
  className: "block text-xs text-muted-foreground mt-0.5",
110
111
  children: [e.quotaCount, " assignments"]
111
112
  })
112
113
  ]
113
114
  }),
114
- t !== void 0 && /* @__PURE__ */ k("td", {
115
+ t !== void 0 && /* @__PURE__ */ A("td", {
115
116
  className: "px-4 py-3 text-sm text-muted-foreground whitespace-nowrap",
116
117
  children: t
117
118
  }),
118
- /* @__PURE__ */ k("td", {
119
+ /* @__PURE__ */ A("td", {
119
120
  className: "px-4 py-3",
120
- children: /* @__PURE__ */ A("div", {
121
+ children: /* @__PURE__ */ j("div", {
121
122
  className: "space-y-1.5",
122
- children: [/* @__PURE__ */ A("span", {
123
+ children: [/* @__PURE__ */ j("span", {
123
124
  className: "text-sm text-foreground tabular-nums",
124
125
  children: [
125
- r(e.totalUsed),
126
+ i(e.totalUsed),
126
127
  "\xA0/\xA0",
127
- i ? r(e.totalLimit) : "∞",
128
+ r ? i(e.totalLimit) : "∞",
128
129
  e.unit ? ` ${e.unit}` : ""
129
130
  ]
130
- }), /* @__PURE__ */ k(M, {
131
- percentage: i ? e.usagePercentage : 0,
131
+ }), /* @__PURE__ */ A(N, {
132
+ percentage: r ? e.usagePercentage : 0,
132
133
  status: e.status
133
134
  })]
134
135
  })
135
136
  }),
136
- /* @__PURE__ */ k("td", {
137
+ /* @__PURE__ */ A("td", {
137
138
  className: "px-4 py-3 text-sm text-muted-foreground tabular-nums whitespace-nowrap",
138
- children: i ? r(e.totalLimit) : "∞"
139
+ children: r ? i(e.totalLimit) : "∞"
139
140
  }),
140
- /* @__PURE__ */ k("td", {
141
+ /* @__PURE__ */ A("td", {
141
142
  className: "px-4 py-3",
142
- children: /* @__PURE__ */ k(j, { status: e.status })
143
+ children: /* @__PURE__ */ A(M, { status: e.status })
143
144
  })
144
145
  ]
145
146
  });
146
- }, ne = ({ quotas: e, planLabel: t, showPlanColumn: n = !0, onQuotaClick: r }) => /* @__PURE__ */ k("div", {
147
+ }, re = ({ quotas: e, planLabel: t, showPlanColumn: n = !0, onQuotaClick: r }) => /* @__PURE__ */ A("div", {
147
148
  className: "overflow-x-auto rounded-lg border border-border bg-card",
148
- children: /* @__PURE__ */ A("table", {
149
+ children: /* @__PURE__ */ j("table", {
149
150
  className: "w-full text-left",
150
- children: [/* @__PURE__ */ k("thead", { children: /* @__PURE__ */ A("tr", {
151
+ children: [/* @__PURE__ */ A("thead", { children: /* @__PURE__ */ j("tr", {
151
152
  className: "border-b border-border bg-muted/30",
152
153
  children: [
153
- /* @__PURE__ */ k("th", {
154
+ /* @__PURE__ */ A("th", {
154
155
  className: "px-4 py-2.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider",
155
156
  children: "Quotas"
156
157
  }),
157
- n && /* @__PURE__ */ k("th", {
158
+ n && /* @__PURE__ */ A("th", {
158
159
  className: "px-4 py-2.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider",
159
160
  children: "Plan"
160
161
  }),
161
- /* @__PURE__ */ k("th", {
162
+ /* @__PURE__ */ A("th", {
162
163
  className: "px-4 py-2.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider",
163
164
  children: "Current Usage"
164
165
  }),
165
- /* @__PURE__ */ k("th", {
166
+ /* @__PURE__ */ A("th", {
166
167
  className: "px-4 py-2.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider",
167
168
  children: "Limit"
168
169
  }),
169
- /* @__PURE__ */ k("th", {
170
+ /* @__PURE__ */ A("th", {
170
171
  className: "px-4 py-2.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider",
171
172
  children: "Status"
172
173
  })
173
174
  ]
174
- }) }), /* @__PURE__ */ k("tbody", { children: e.map((e) => /* @__PURE__ */ k(P, {
175
+ }) }), /* @__PURE__ */ A("tbody", { children: e.map((e) => /* @__PURE__ */ A(F, {
175
176
  quota: e,
176
177
  planLabel: n ? t : void 0,
177
178
  onClick: () => r(e)
178
179
  }, e.name)) })]
179
180
  })
180
- }), F = ({ subscription: e, onQuotaClick: n, defaultExpanded: r = !0 }) => {
181
- let [i, a] = p(r), o = {
181
+ }), ie = ({ subscription: e, onQuotaClick: n, defaultExpanded: r = !0 }) => {
182
+ let [i, a] = m(r), o = {
182
183
  active: `${t.success.bg} ${t.success.text}`,
183
184
  trialing: `${t.info.bg} ${t.info.text}`,
184
185
  past_due: `${t.warning.bg} ${t.warning.text}`,
@@ -186,27 +187,27 @@ var te = ({ status: e, className: n = "size-4" }) => {
186
187
  expired: `${t.neutral.bg} ${t.neutral.text}`,
187
188
  upgraded: `${t.primary.bg} ${t.primary.text}`
188
189
  };
189
- return /* @__PURE__ */ A("div", {
190
+ return /* @__PURE__ */ j("div", {
190
191
  className: "border border-border rounded-lg bg-card overflow-hidden",
191
192
  children: [
192
- /* @__PURE__ */ A("button", {
193
+ /* @__PURE__ */ j("button", {
193
194
  type: "button",
194
195
  onClick: () => a(!i),
195
196
  className: "w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",
196
- children: [/* @__PURE__ */ A("div", {
197
+ children: [/* @__PURE__ */ j("div", {
197
198
  className: "flex items-center gap-3",
198
- children: [/* @__PURE__ */ k(C, { className: "size-5 text-primary" }), /* @__PURE__ */ A("div", {
199
+ children: [/* @__PURE__ */ A(w, { className: "size-5 text-primary" }), /* @__PURE__ */ j("div", {
199
200
  className: "text-left",
200
- children: [/* @__PURE__ */ A("div", {
201
+ children: [/* @__PURE__ */ j("div", {
201
202
  className: "flex items-center gap-2",
202
- children: [/* @__PURE__ */ k("span", {
203
+ children: [/* @__PURE__ */ A("span", {
203
204
  className: "font-medium text-foreground",
204
205
  children: "Subscription"
205
- }), /* @__PURE__ */ k("span", {
206
+ }), /* @__PURE__ */ A("span", {
206
207
  className: `px-2 py-0.5 text-xs font-medium rounded capitalize ${o[e.status.toLowerCase()] || o.active}`,
207
208
  children: e.status
208
209
  })]
209
- }), /* @__PURE__ */ A("p", {
210
+ }), /* @__PURE__ */ j("p", {
210
211
  className: "text-xs text-muted-foreground",
211
212
  children: [
212
213
  e.aggregatedQuotas.length,
@@ -215,150 +216,150 @@ var te = ({ status: e, className: n = "size-4" }) => {
215
216
  ]
216
217
  })]
217
218
  })]
218
- }), k(i ? _ : y, { className: "size-5 text-muted-foreground" })]
219
+ }), A(i ? v : b, { className: "size-5 text-muted-foreground" })]
219
220
  }),
220
- i && e.aggregatedQuotas.length > 0 && /* @__PURE__ */ k("div", {
221
+ i && e.aggregatedQuotas.length > 0 && /* @__PURE__ */ A("div", {
221
222
  className: "border-t border-border",
222
- children: /* @__PURE__ */ k(ne, {
223
+ children: /* @__PURE__ */ A(re, {
223
224
  quotas: e.aggregatedQuotas,
224
225
  planLabel: e.planName || e.productId || void 0,
225
226
  showPlanColumn: !!(e.planName || e.productId),
226
227
  onQuotaClick: n
227
228
  })
228
229
  }),
229
- i && e.aggregatedQuotas.length === 0 && /* @__PURE__ */ k("div", {
230
+ i && e.aggregatedQuotas.length === 0 && /* @__PURE__ */ A("div", {
230
231
  className: "border-t border-border p-6 text-center",
231
- children: /* @__PURE__ */ k("p", {
232
+ children: /* @__PURE__ */ A("p", {
232
233
  className: "text-sm text-muted-foreground",
233
234
  children: "No quotas assigned to this subscription"
234
235
  })
235
236
  })
236
237
  ]
237
238
  });
238
- }, re = ({ quota: a, onClose: o }) => {
239
- let [s, u] = p([null]), d = s[s.length - 1] ?? null, f = s.length, { workspaceId: m } = e(), h = a.quotaAssignments[0]?.id, { usages: g, hasNextPage: _, nextCursor: b, isLoading: x } = c(h, 10, d, m), { snapshots: S, isLoading: C } = l(m, a.name, 24), w = () => {
240
- b && u((e) => [...e, b]);
241
- }, T = () => {
242
- s.length > 1 && u((e) => e.slice(0, -1));
239
+ }, ae = ({ quota: n, onClose: o }) => {
240
+ let [s, c] = m([null]), d = s[s.length - 1] ?? null, ee = s.length, { workspaceId: f } = e(), p = n.quotaAssignments[0]?.id, { usages: h, hasNextPage: g, nextCursor: _, isLoading: v } = l(p, 10, d, f), { snapshots: x, isLoading: S } = u(f, n.name, 24), C = () => {
241
+ _ && c((e) => [...e, _]);
242
+ }, w = () => {
243
+ s.length > 1 && c((e) => e.slice(0, -1));
243
244
  };
244
- return /* @__PURE__ */ A("div", {
245
+ return /* @__PURE__ */ j("div", {
245
246
  className: "fixed inset-0 z-50 flex items-center justify-center",
246
- children: [/* @__PURE__ */ k("div", {
247
+ children: [/* @__PURE__ */ A("div", {
247
248
  className: "absolute inset-0 bg-overlay-scrim",
248
249
  onClick: o
249
- }), /* @__PURE__ */ A("div", {
250
+ }), /* @__PURE__ */ j("div", {
250
251
  className: "relative bg-background border border-border rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[90vh] overflow-auto",
251
252
  role: "dialog",
252
253
  "aria-modal": "true",
253
254
  "aria-labelledby": "quota-detail-title",
254
255
  children: [
255
- /* @__PURE__ */ A("div", {
256
+ /* @__PURE__ */ j("div", {
256
257
  className: "sticky top-0 bg-background border-b border-border p-4 flex items-center justify-between",
257
- children: [/* @__PURE__ */ A("div", {
258
+ children: [/* @__PURE__ */ j("div", {
258
259
  className: "flex items-center gap-3",
259
- children: [/* @__PURE__ */ k(te, {
260
- status: a.status,
260
+ children: [/* @__PURE__ */ A(ne, {
261
+ status: n.status,
261
262
  className: "size-5"
262
- }), /* @__PURE__ */ A("div", { children: [
263
- /* @__PURE__ */ k("h2", {
263
+ }), /* @__PURE__ */ j("div", { children: [
264
+ /* @__PURE__ */ A("h2", {
264
265
  id: "quota-detail-title",
265
266
  className: "text-lg font-semibold capitalize",
266
- children: a.displayName || a.name.replace(/_/g, " ")
267
+ children: n.displayName || n.name.replace(/_/g, " ")
267
268
  }),
268
- /* @__PURE__ */ k("p", {
269
+ /* @__PURE__ */ A("p", {
269
270
  className: "text-xs font-mono text-muted-foreground",
270
- children: a.name
271
+ children: n.name
271
272
  }),
272
- a.description && /* @__PURE__ */ k("p", {
273
+ n.description && /* @__PURE__ */ A("p", {
273
274
  className: "text-sm text-muted-foreground mt-0.5",
274
- children: a.description
275
+ children: n.description
275
276
  }),
276
- /* @__PURE__ */ A("p", {
277
+ /* @__PURE__ */ j("p", {
277
278
  className: "text-sm text-muted-foreground mt-0.5",
278
279
  children: [
279
- a.quotaCount,
280
+ n.quotaCount,
280
281
  " quota assignment",
281
- a.quotaCount === 1 ? "" : "s"
282
+ n.quotaCount === 1 ? "" : "s"
282
283
  ]
283
284
  })
284
285
  ] })]
285
- }), /* @__PURE__ */ k("button", {
286
+ }), /* @__PURE__ */ A("button", {
286
287
  type: "button",
287
288
  onClick: o,
288
289
  className: "p-1 rounded-md hover:bg-muted/50 transition-colors",
289
290
  "aria-label": "Close quota details",
290
- children: /* @__PURE__ */ k(E, { className: "size-5" })
291
+ children: /* @__PURE__ */ A(D, { className: "size-5" })
291
292
  })]
292
293
  }),
293
- /* @__PURE__ */ A("div", {
294
+ /* @__PURE__ */ j("div", {
294
295
  className: "p-4 border-b border-border",
295
- children: [/* @__PURE__ */ A("div", {
296
+ children: [/* @__PURE__ */ j("div", {
296
297
  className: "mb-4",
297
298
  children: [
298
- /* @__PURE__ */ A("div", {
299
+ /* @__PURE__ */ j("div", {
299
300
  className: "flex items-center justify-between mb-2",
300
- children: [/* @__PURE__ */ k("span", {
301
+ children: [/* @__PURE__ */ A("span", {
301
302
  className: "text-sm text-muted-foreground",
302
303
  children: "Usage"
303
- }), /* @__PURE__ */ k(j, { status: a.status })]
304
+ }), /* @__PURE__ */ A(M, { status: n.status })]
304
305
  }),
305
- /* @__PURE__ */ k(M, {
306
- percentage: a.usagePercentage,
307
- status: a.status
306
+ /* @__PURE__ */ A(N, {
307
+ percentage: n.usagePercentage,
308
+ status: n.status
308
309
  }),
309
- /* @__PURE__ */ A("div", {
310
+ /* @__PURE__ */ j("div", {
310
311
  className: "flex items-center justify-between mt-2 text-sm",
311
- children: [/* @__PURE__ */ A("span", {
312
+ children: [/* @__PURE__ */ j("span", {
312
313
  className: "font-medium",
313
314
  children: [
314
- r(a.totalUsed),
315
+ i(n.totalUsed),
315
316
  " /",
316
317
  " ",
317
- a.totalLimit != null && a.totalLimit > 0 ? r(a.totalLimit) : "∞",
318
- a.unit && ` ${a.unit}`
318
+ n.totalLimit != null && n.totalLimit > 0 ? i(n.totalLimit) : "∞",
319
+ n.unit && ` ${n.unit}`
319
320
  ]
320
- }), /* @__PURE__ */ k("span", {
321
+ }), /* @__PURE__ */ A("span", {
321
322
  className: "text-muted-foreground",
322
- children: a.totalLimit != null && a.totalLimit > 0 ? `${Math.round(a.usagePercentage)}% used` : "Unlimited"
323
+ children: n.totalLimit != null && n.totalLimit > 0 ? `${Math.round(n.usagePercentage)}% used` : "Unlimited"
323
324
  })]
324
325
  })
325
326
  ]
326
- }), a.quotaCount > 1 && /* @__PURE__ */ A("div", {
327
+ }), n.quotaCount > 1 && /* @__PURE__ */ j("div", {
327
328
  className: "mt-4",
328
- children: [/* @__PURE__ */ k("h3", {
329
+ children: [/* @__PURE__ */ A("h3", {
329
330
  className: "text-sm font-medium text-foreground mb-3",
330
331
  children: "Quota Breakdown"
331
- }), /* @__PURE__ */ k("div", {
332
+ }), /* @__PURE__ */ A("div", {
332
333
  className: "border border-border rounded-lg overflow-hidden divide-y divide-border",
333
- children: [...a.quotaAssignments].sort((e, t) => (e.endtime ? new Date(e.endtime).getTime() : Infinity) - (t.endtime ? new Date(t.endtime).getTime() : Infinity)).map((e) => {
334
- let n = e.endtime ? new Date(e.endtime) : null, i = /* @__PURE__ */ new Date(), a = n && n < i, o = n ? Math.ceil((n.getTime() - i.getTime()) / (1440 * 60 * 1e3)) : null, s = o !== null && o > 0 && o <= 7;
335
- return /* @__PURE__ */ A("div", {
334
+ children: [...n.quotaAssignments].sort((e, t) => (e.endtime ? new Date(e.endtime).getTime() : Infinity) - (t.endtime ? new Date(t.endtime).getTime() : Infinity)).map((e) => {
335
+ let n = e.endtime ? new Date(e.endtime) : null, r = /* @__PURE__ */ new Date(), a = n && n < r, o = n ? Math.ceil((n.getTime() - r.getTime()) / (1440 * 60 * 1e3)) : null, s = o !== null && o > 0 && o <= 7;
336
+ return /* @__PURE__ */ j("div", {
336
337
  className: `flex items-center justify-between px-3 py-2.5 ${a ? "bg-muted/30" : s ? t.warning.bg : "bg-background"}`,
337
- children: [/* @__PURE__ */ A("div", {
338
+ children: [/* @__PURE__ */ j("div", {
338
339
  className: "flex items-center gap-2",
339
- children: [s && !a && /* @__PURE__ */ k("span", { className: `size-2 rounded-full ${t.warning.dot} animate-pulse` }), /* @__PURE__ */ A("div", {
340
+ children: [s && !a && /* @__PURE__ */ A("span", { className: `size-2 rounded-full ${t.warning.dot} animate-pulse` }), /* @__PURE__ */ j("div", {
340
341
  className: "flex flex-col",
341
- children: [/* @__PURE__ */ k("span", {
342
+ children: [/* @__PURE__ */ A("span", {
342
343
  className: `text-sm ${a ? "text-muted-foreground" : "text-foreground"}`,
343
344
  children: n ? n.toLocaleDateString("en-US", {
344
345
  month: "short",
345
346
  day: "numeric",
346
347
  year: "numeric"
347
348
  }) : "No expiry"
348
- }), /* @__PURE__ */ k("span", {
349
+ }), /* @__PURE__ */ A("span", {
349
350
  className: `text-xs ${a ? "text-destructive" : s ? t.warning.text : "text-muted-foreground"}`,
350
351
  children: a ? "Expired" : o === null ? "Never expires" : o === 0 ? "Expires today" : o === 1 ? "Expires tomorrow" : `${o} days left`
351
352
  })]
352
353
  })]
353
- }), /* @__PURE__ */ k("div", {
354
+ }), /* @__PURE__ */ A("div", {
354
355
  className: "text-right",
355
- children: /* @__PURE__ */ A("span", {
356
+ children: /* @__PURE__ */ j("span", {
356
357
  className: `text-sm font-semibold ${a ? "text-muted-foreground" : "text-foreground"}`,
357
- children: [r(e.used), /* @__PURE__ */ A("span", {
358
+ children: [i(e.used), /* @__PURE__ */ j("span", {
358
359
  className: "text-muted-foreground font-normal",
359
360
  children: [
360
361
  " / ",
361
- e.limit != null && e.limit > 0 ? r(e.limit) : "∞",
362
+ e.limit != null && e.limit > 0 ? i(e.limit) : "∞",
362
363
  e.unit && ` ${e.unit}`
363
364
  ]
364
365
  })]
@@ -369,115 +370,115 @@ var te = ({ status: e, className: n = "size-4" }) => {
369
370
  })]
370
371
  })]
371
372
  }),
372
- (C || S.length > 0) && /* @__PURE__ */ A("div", {
373
+ (S || x.length > 0) && /* @__PURE__ */ j("div", {
373
374
  className: "p-4 border-t border-border",
374
- children: [/* @__PURE__ */ k("h3", {
375
+ children: [/* @__PURE__ */ A("h3", {
375
376
  className: "text-sm font-medium text-foreground mb-3",
376
377
  children: "Live Value History"
377
- }), C ? /* @__PURE__ */ k("div", {
378
+ }), S ? /* @__PURE__ */ A("div", {
378
379
  className: "space-y-1.5",
379
380
  children: [
380
381
  1,
381
382
  2,
382
383
  3
383
- ].map((e) => /* @__PURE__ */ k("div", { className: "h-8 bg-muted animate-pulse rounded" }, e))
384
- }) : /* @__PURE__ */ k("div", {
384
+ ].map((e) => /* @__PURE__ */ A("div", { className: "h-8 bg-muted animate-pulse rounded" }, e))
385
+ }) : /* @__PURE__ */ A("div", {
385
386
  className: "space-y-1.5",
386
- children: S.map((e) => /* @__PURE__ */ A("div", {
387
+ children: x.map((e) => /* @__PURE__ */ j("div", {
387
388
  className: "flex items-center justify-between px-3 py-2 bg-muted/30 rounded-md",
388
- children: [/* @__PURE__ */ k("span", {
389
+ children: [/* @__PURE__ */ A("span", {
389
390
  className: "text-xs text-muted-foreground",
390
- children: n(e.snapshotAt)
391
- }), /* @__PURE__ */ A("span", {
391
+ children: r(e.snapshotAt)
392
+ }), /* @__PURE__ */ j("span", {
392
393
  className: "text-sm font-medium text-foreground tabular-nums",
393
394
  children: [
394
- r(e.value),
395
- a.unit && /* @__PURE__ */ k("span", {
395
+ i(e.value),
396
+ n.unit && /* @__PURE__ */ A("span", {
396
397
  className: "text-xs text-muted-foreground ml-1",
397
- children: a.unit
398
+ children: n.unit
398
399
  }),
399
- !e.noLimit && e.limit != null && /* @__PURE__ */ A("span", {
400
+ !e.noLimit && e.limit != null && /* @__PURE__ */ j("span", {
400
401
  className: "text-xs text-muted-foreground ml-1",
401
- children: ["/ ", r(e.limit)]
402
+ children: ["/ ", i(e.limit)]
402
403
  })
403
404
  ]
404
405
  })]
405
406
  }, e.id))
406
407
  })]
407
408
  }),
408
- /* @__PURE__ */ A("div", {
409
+ /* @__PURE__ */ j("div", {
409
410
  className: "p-4",
410
411
  children: [
411
- /* @__PURE__ */ k("h3", {
412
+ /* @__PURE__ */ A("h3", {
412
413
  className: "text-sm font-medium text-foreground mb-3",
413
414
  children: "Recent Usage"
414
415
  }),
415
- a.isCollectorBased ? /* @__PURE__ */ k("p", {
416
+ n.isCollectorBased ? /* @__PURE__ */ A("p", {
416
417
  className: "text-sm text-muted-foreground text-center py-6",
417
418
  children: "Usage is tracked via system metrics, individual event records are not available for this quota."
418
- }) : x ? /* @__PURE__ */ k("div", {
419
+ }) : v ? /* @__PURE__ */ A("div", {
419
420
  className: "space-y-2",
420
421
  children: [
421
422
  1,
422
423
  2,
423
424
  3
424
- ].map((e) => /* @__PURE__ */ k("div", { className: "h-12 bg-muted animate-pulse rounded" }, e))
425
- }) : g.length === 0 ? /* @__PURE__ */ k("p", {
425
+ ].map((e) => /* @__PURE__ */ A("div", { className: "h-12 bg-muted animate-pulse rounded" }, e))
426
+ }) : h.length === 0 ? /* @__PURE__ */ A("p", {
426
427
  className: "text-sm text-muted-foreground text-center py-6",
427
428
  children: "No usage records found"
428
- }) : /* @__PURE__ */ k("div", {
429
+ }) : /* @__PURE__ */ A("div", {
429
430
  className: "space-y-2",
430
- children: g.map((e) => /* @__PURE__ */ A("div", {
431
+ children: h.map((e) => /* @__PURE__ */ j("div", {
431
432
  className: "flex items-center justify-between p-3 border border-border rounded-lg",
432
- children: [/* @__PURE__ */ A("div", {
433
+ children: [/* @__PURE__ */ j("div", {
433
434
  className: "flex-1 min-w-0",
434
- children: [/* @__PURE__ */ k("p", {
435
+ children: [/* @__PURE__ */ A("p", {
435
436
  className: "text-sm font-medium text-foreground",
436
437
  children: e.description || "Usage recorded"
437
- }), /* @__PURE__ */ A("p", {
438
+ }), /* @__PURE__ */ j("p", {
438
439
  className: "text-xs text-muted-foreground",
439
440
  children: [
440
- i(e.timestamp),
441
+ a(e.timestamp),
441
442
  " • ",
442
- n(e.timestamp)
443
+ r(e.timestamp)
443
444
  ]
444
445
  })]
445
- }), /* @__PURE__ */ k("span", {
446
+ }), /* @__PURE__ */ A("span", {
446
447
  className: "text-sm font-medium text-foreground ml-4",
447
- children: r(e.amount)
448
+ children: i(e.amount)
448
449
  })]
449
450
  }, e.id))
450
451
  }),
451
- !a.isCollectorBased && (s.length > 1 || _) && /* @__PURE__ */ A("div", {
452
+ !n.isCollectorBased && (s.length > 1 || g) && /* @__PURE__ */ j("div", {
452
453
  className: "flex items-center justify-center gap-2 mt-4",
453
454
  children: [
454
- /* @__PURE__ */ k("button", {
455
+ /* @__PURE__ */ A("button", {
455
456
  type: "button",
456
- onClick: T,
457
+ onClick: w,
457
458
  disabled: s.length === 1,
458
459
  className: "px-3 py-1.5 text-sm border border-border rounded-md disabled:opacity-50",
459
460
  "aria-label": "Previous usage page",
460
- children: /* @__PURE__ */ k(v, { className: "size-4" })
461
+ children: /* @__PURE__ */ A(y, { className: "size-4" })
461
462
  }),
462
- /* @__PURE__ */ A("span", {
463
+ /* @__PURE__ */ j("span", {
463
464
  className: "text-sm text-muted-foreground",
464
- children: ["Page ", f]
465
+ children: ["Page ", ee]
465
466
  }),
466
- /* @__PURE__ */ k("button", {
467
+ /* @__PURE__ */ A("button", {
467
468
  type: "button",
468
- onClick: w,
469
- disabled: !_,
469
+ onClick: C,
470
+ disabled: !g,
470
471
  className: "px-3 py-1.5 text-sm border border-border rounded-md disabled:opacity-50",
471
472
  "aria-label": "Next usage page",
472
- children: /* @__PURE__ */ k(y, { className: "size-4" })
473
+ children: /* @__PURE__ */ A(b, { className: "size-4" })
473
474
  })
474
475
  ]
475
476
  })
476
477
  ]
477
478
  }),
478
- /* @__PURE__ */ k("div", {
479
+ /* @__PURE__ */ A("div", {
479
480
  className: "sticky bottom-0 bg-background border-t border-border p-4",
480
- children: /* @__PURE__ */ k("button", {
481
+ children: /* @__PURE__ */ A("button", {
481
482
  type: "button",
482
483
  onClick: o,
483
484
  className: "w-full py-2 px-4 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
@@ -487,454 +488,689 @@ var te = ({ status: e, className: n = "size-4" }) => {
487
488
  ]
488
489
  })]
489
490
  });
490
- }, I = () => {
491
- let { t: n } = ee(), r = (e, t) => {
491
+ };
492
+ function I(e, t) {
493
+ return t ? n.HEALTHY : e >= 100 ? n.EXHAUSTED : e >= 90 ? n.CRITICAL : e >= 75 ? n.WARNING : n.HEALTHY;
494
+ }
495
+ var oe = ({ workspaceId: e }) => {
496
+ let { overview: n, isLoading: r, error: a, refetch: o } = d(e);
497
+ if (r && n.length === 0) return /* @__PURE__ */ A("div", {
498
+ className: "space-y-3",
499
+ children: [
500
+ 1,
501
+ 2,
502
+ 3
503
+ ].map((e) => /* @__PURE__ */ A("div", { className: "h-16 bg-muted animate-pulse rounded-lg" }, e))
504
+ });
505
+ if (a) return /* @__PURE__ */ j("div", {
506
+ className: "text-center py-8 space-y-2",
507
+ children: [
508
+ /* @__PURE__ */ A(g, { className: "size-8 text-destructive mx-auto" }),
509
+ /* @__PURE__ */ A("p", {
510
+ className: "text-sm text-muted-foreground",
511
+ children: a.message
512
+ }),
513
+ /* @__PURE__ */ A("button", {
514
+ type: "button",
515
+ onClick: () => o(),
516
+ className: "px-3 py-1.5 text-sm border border-border rounded-md hover:bg-muted/50 transition-colors",
517
+ children: "Retry"
518
+ })
519
+ ]
520
+ });
521
+ if (n.length === 0) return /* @__PURE__ */ j("div", {
522
+ className: "text-center py-12 space-y-2",
523
+ children: [
524
+ /* @__PURE__ */ A(C, { className: "size-10 text-muted-foreground mx-auto opacity-40" }),
525
+ /* @__PURE__ */ A("h3", {
526
+ className: "text-base font-medium text-foreground",
527
+ children: "No workspace quotas assigned"
528
+ }),
529
+ /* @__PURE__ */ A("p", {
530
+ className: "text-sm text-muted-foreground max-w-sm mx-auto",
531
+ children: "Quotas are assigned to this workspace after a successful purchase. If you have an active subscription, contact support."
532
+ })
533
+ ]
534
+ });
535
+ let s = n.filter((e) => I(e.usagePercentage, e.assignment.noLimit) === "HEALTHY").length, c = n.filter((e) => I(e.usagePercentage, e.assignment.noLimit) === "WARNING").length, l = n.filter((e) => {
536
+ let t = I(e.usagePercentage, e.assignment.noLimit);
537
+ return t === "CRITICAL" || t === "EXHAUSTED";
538
+ }).length;
539
+ return /* @__PURE__ */ j("div", {
540
+ className: "space-y-4",
541
+ children: [
542
+ /* @__PURE__ */ j("div", {
543
+ className: "grid grid-cols-3 gap-3",
544
+ children: [
545
+ /* @__PURE__ */ j("div", {
546
+ className: `border rounded-lg p-3 ${t.success.bg} ${t.success.border}`,
547
+ children: [/* @__PURE__ */ j("div", {
548
+ className: "flex items-center gap-1.5 mb-1",
549
+ children: [/* @__PURE__ */ A(_, { className: `size-4 ${t.success.icon}` }), /* @__PURE__ */ A("span", {
550
+ className: "text-xs text-muted-foreground",
551
+ children: "Healthy"
552
+ })]
553
+ }), /* @__PURE__ */ A("p", {
554
+ className: "text-xl font-bold text-foreground",
555
+ children: s
556
+ })]
557
+ }),
558
+ /* @__PURE__ */ j("div", {
559
+ className: `border rounded-lg p-3 ${t.warning.bg} ${t.warning.border}`,
560
+ children: [/* @__PURE__ */ j("div", {
561
+ className: "flex items-center gap-1.5 mb-1",
562
+ children: [/* @__PURE__ */ A(h, { className: `size-4 ${t.warning.icon}` }), /* @__PURE__ */ A("span", {
563
+ className: "text-xs text-muted-foreground",
564
+ children: "Warning"
565
+ })]
566
+ }), /* @__PURE__ */ A("p", {
567
+ className: "text-xl font-bold text-foreground",
568
+ children: c
569
+ })]
570
+ }),
571
+ /* @__PURE__ */ j("div", {
572
+ className: `border rounded-lg p-3 ${t.error.bg} ${t.error.border}`,
573
+ children: [/* @__PURE__ */ j("div", {
574
+ className: "flex items-center gap-1.5 mb-1",
575
+ children: [/* @__PURE__ */ A(O, { className: `size-4 ${t.error.icon}` }), /* @__PURE__ */ A("span", {
576
+ className: "text-xs text-muted-foreground",
577
+ children: "Critical / Exhausted"
578
+ })]
579
+ }), /* @__PURE__ */ A("p", {
580
+ className: "text-xl font-bold text-foreground",
581
+ children: l
582
+ })]
583
+ })
584
+ ]
585
+ }),
586
+ /* @__PURE__ */ A("div", {
587
+ className: "border border-border rounded-lg overflow-hidden",
588
+ children: /* @__PURE__ */ j("table", {
589
+ className: "w-full text-sm",
590
+ children: [/* @__PURE__ */ A("thead", { children: /* @__PURE__ */ j("tr", {
591
+ className: "border-b border-border bg-muted/30",
592
+ children: [
593
+ /* @__PURE__ */ A("th", {
594
+ className: "text-left px-4 py-3 font-medium text-muted-foreground",
595
+ children: "Quota"
596
+ }),
597
+ /* @__PURE__ */ A("th", {
598
+ className: "text-left px-4 py-3 font-medium text-muted-foreground hidden sm:table-cell",
599
+ children: "Product"
600
+ }),
601
+ /* @__PURE__ */ A("th", {
602
+ className: "text-left px-4 py-3 font-medium text-muted-foreground hidden md:table-cell",
603
+ children: "Mode"
604
+ }),
605
+ /* @__PURE__ */ A("th", {
606
+ className: "text-left px-4 py-3 font-medium text-muted-foreground",
607
+ children: "Usage"
608
+ }),
609
+ /* @__PURE__ */ A("th", {
610
+ className: "text-left px-4 py-3 font-medium text-muted-foreground hidden sm:table-cell",
611
+ children: "Limit"
612
+ }),
613
+ /* @__PURE__ */ A("th", {
614
+ className: "text-left px-4 py-3 font-medium text-muted-foreground",
615
+ children: "Status"
616
+ })
617
+ ]
618
+ }) }), /* @__PURE__ */ A("tbody", {
619
+ className: "divide-y divide-border",
620
+ children: n.map((e) => {
621
+ let { assignment: t, liveStatus: n, effectiveUsed: r, remaining: a, usagePercentage: o } = e, s = I(o, t.noLimit), c = n !== null;
622
+ return /* @__PURE__ */ j("tr", {
623
+ className: "hover:bg-muted/20 transition-colors",
624
+ children: [
625
+ /* @__PURE__ */ j("td", {
626
+ className: "px-4 py-3",
627
+ children: [/* @__PURE__ */ A("div", {
628
+ className: "font-medium text-foreground",
629
+ children: t.quotaName
630
+ }), c && /* @__PURE__ */ j("div", {
631
+ className: "text-xs text-muted-foreground mt-0.5",
632
+ children: ["Live · ", new Date(n.scrapedAt).toLocaleTimeString()]
633
+ })]
634
+ }),
635
+ /* @__PURE__ */ A("td", {
636
+ className: "px-4 py-3 hidden sm:table-cell",
637
+ children: /* @__PURE__ */ A("span", {
638
+ className: "text-xs text-muted-foreground bg-muted px-1.5 py-0.5 rounded",
639
+ children: t.productId
640
+ })
641
+ }),
642
+ /* @__PURE__ */ A("td", {
643
+ className: "px-4 py-3 hidden md:table-cell",
644
+ children: /* @__PURE__ */ A("span", {
645
+ className: "text-xs text-muted-foreground capitalize",
646
+ children: t.quotaMode
647
+ })
648
+ }),
649
+ /* @__PURE__ */ A("td", {
650
+ className: "px-4 py-3",
651
+ children: /* @__PURE__ */ j("div", {
652
+ className: "space-y-1.5",
653
+ children: [/* @__PURE__ */ j("div", {
654
+ className: "text-foreground",
655
+ children: [i(r), !t.noLimit && t.limit != null && /* @__PURE__ */ j("span", {
656
+ className: "text-muted-foreground",
657
+ children: [
658
+ " ",
659
+ "/ ",
660
+ i(t.limit)
661
+ ]
662
+ })]
663
+ }), !t.noLimit && /* @__PURE__ */ A(N, {
664
+ percentage: o,
665
+ status: s
666
+ })]
667
+ })
668
+ }),
669
+ /* @__PURE__ */ A("td", {
670
+ className: "px-4 py-3 hidden sm:table-cell text-foreground",
671
+ children: t.noLimit ? /* @__PURE__ */ A("span", {
672
+ className: "text-muted-foreground",
673
+ children: "Unlimited"
674
+ }) : i(a ?? 0)
675
+ }),
676
+ /* @__PURE__ */ A("td", {
677
+ className: "px-4 py-3",
678
+ children: /* @__PURE__ */ A(M, { status: s })
679
+ })
680
+ ]
681
+ }, t.id);
682
+ })
683
+ })]
684
+ })
685
+ }),
686
+ /* @__PURE__ */ j("p", {
687
+ className: "text-xs text-muted-foreground",
688
+ children: [
689
+ "Workspace quotas are sourced from the activity service.",
690
+ " ",
691
+ n.some((e) => e.liveStatus) && "Live values are updated every ~60 seconds."
692
+ ]
693
+ })
694
+ ]
695
+ });
696
+ }, L = () => {
697
+ let { t: n } = te(), r = (e, t) => {
492
698
  let r = n(e);
493
699
  return r === e ? t : r;
494
- }, i = a(), [c, l] = p(() => {
700
+ }, i = o(), [a, l] = m(() => {
495
701
  if (!(typeof window > "u")) return new URLSearchParams(window.location.search).get("billingAccountId") || void 0;
496
- }), [v, y] = p(null), [x, j] = p(""), [M, P] = p("all"), [I, L] = p("active"), ie = d(x), { billingAccounts: R, isLoading: ae } = o(), oe = (R.find((e) => e.isDefault) ?? R[0])?.id, z = c ?? oe, { workspaceId: se, navigate: ce } = e(), { dashboard: B, pooledQuotas: V, activeSubscriptions: H, pastSubscriptions: U, isLoading: le, isPastSubscriptionsLoading: W, error: G, refetch: ue, loadMorePastSubscriptions: de, hasMorePastSubscriptions: fe, isLoadingMorePast: pe, pastSubscriptionsCount: K } = s({
497
- billingAccountId: z,
498
- workspaceId: se,
499
- searchQuery: ie || void 0,
500
- viewMode: I
501
- }), q = u((e) => M === "all" ? !0 : M === "healthy" ? e.status === "HEALTHY" : M === "warning" ? e.status === "WARNING" : M === "critical" ? e.status === "CRITICAL" || e.status === "EXHAUSTED" : !0, [M]), J = f(() => V.filter(q), [V, q]), Y = f(() => M === "all" ? H : H.map((e) => ({
702
+ }), [u, d] = m(null), [y, b] = m(""), [S, M] = m("all"), [N, F] = m("active"), I = f(y), { billingAccounts: L, isLoading: se } = s(), ce = (L.find((e) => e.isDefault) ?? L[0])?.id, R = a ?? ce, { workspaceId: z, navigate: le } = e(), [B, ue] = m("workspace"), { dashboard: V, pooledQuotas: H, activeSubscriptions: U, pastSubscriptions: W, isLoading: de, isPastSubscriptionsLoading: G, error: fe, refetch: pe, loadMorePastSubscriptions: me, hasMorePastSubscriptions: he, isLoadingMorePast: ge, pastSubscriptionsCount: _e } = c({
703
+ billingAccountId: R,
704
+ workspaceId: z,
705
+ searchQuery: I || void 0,
706
+ viewMode: N
707
+ }), K = ee((e) => S === "all" ? !0 : S === "healthy" ? e.status === "HEALTHY" : S === "warning" ? e.status === "WARNING" : S === "critical" ? e.status === "CRITICAL" || e.status === "EXHAUSTED" : !0, [S]), q = p(() => H.filter(K), [H, K]), J = p(() => S === "all" ? U : U.map((e) => ({
502
708
  ...e,
503
- aggregatedQuotas: e.aggregatedQuotas.filter(q)
709
+ aggregatedQuotas: e.aggregatedQuotas.filter(K)
504
710
  })).filter((e) => e.aggregatedQuotas.length > 0), [
505
- H,
506
- M,
507
- q
508
- ]), X = f(() => M === "all" ? U : U.map((e) => ({
711
+ U,
712
+ S,
713
+ K
714
+ ]), Y = p(() => S === "all" ? W : W.map((e) => ({
509
715
  ...e,
510
- aggregatedQuotas: e.aggregatedQuotas.filter(q)
716
+ aggregatedQuotas: e.aggregatedQuotas.filter(K)
511
717
  })).filter((e) => e.aggregatedQuotas.length > 0), [
512
- U,
513
- M,
514
- q
515
- ]), Z = f(() => I === "active" ? {
516
- active: Y,
718
+ W,
719
+ S,
720
+ K
721
+ ]), X = p(() => N === "active" ? {
722
+ active: J,
517
723
  past: []
518
- } : I === "past" ? {
724
+ } : N === "past" ? {
519
725
  active: [],
520
- past: X
726
+ past: Y
521
727
  } : {
522
- active: Y,
523
- past: X
728
+ active: J,
729
+ past: Y
524
730
  }, [
525
- I,
526
- Y,
527
- X
528
- ]), Q = x !== "" || M !== "all", me = ie !== x, he = () => {
529
- j(""), P("all");
731
+ N,
732
+ J,
733
+ Y
734
+ ]), Z = y !== "" || S !== "all", Q = I !== y, ve = () => {
735
+ b(""), M("all");
530
736
  }, $ = (e) => {
531
- P((t) => t === e ? "all" : e);
737
+ M((t) => t === e ? "all" : e);
532
738
  };
533
- if (!i.canViewUsage) return /* @__PURE__ */ k("div", {
739
+ if (!i.canViewUsage) return /* @__PURE__ */ A("div", {
534
740
  className: "flex items-center justify-center h-full min-h-[400px]",
535
- children: /* @__PURE__ */ A("div", {
741
+ children: /* @__PURE__ */ j("div", {
536
742
  className: "text-center space-y-2",
537
743
  children: [
538
- /* @__PURE__ */ k("div", {
744
+ /* @__PURE__ */ A("div", {
539
745
  className: "size-12 mx-auto rounded-full bg-muted flex items-center justify-center",
540
- children: /* @__PURE__ */ k(h, { className: "size-6 text-muted-foreground" })
746
+ children: /* @__PURE__ */ A(g, { className: "size-6 text-muted-foreground" })
541
747
  }),
542
- /* @__PURE__ */ k("h2", {
748
+ /* @__PURE__ */ A("h2", {
543
749
  className: "text-lg font-semibold text-foreground",
544
750
  children: "Access Denied"
545
751
  }),
546
- /* @__PURE__ */ k("p", {
752
+ /* @__PURE__ */ A("p", {
547
753
  className: "text-sm text-muted-foreground max-w-sm",
548
754
  children: "You don't have permission to view usage data."
549
755
  })
550
756
  ]
551
757
  })
552
758
  });
553
- if ((ae || le) && !B) return /* @__PURE__ */ A("div", {
759
+ if ((se || de) && !V) return /* @__PURE__ */ j("div", {
554
760
  className: "space-y-6 p-6",
555
761
  children: [
556
- /* @__PURE__ */ k("div", { className: "h-8 w-48 bg-muted animate-pulse rounded" }),
557
- /* @__PURE__ */ k("div", {
762
+ /* @__PURE__ */ A("div", { className: "h-8 w-48 bg-muted animate-pulse rounded" }),
763
+ /* @__PURE__ */ A("div", {
558
764
  className: "grid grid-cols-2 sm:grid-cols-4 gap-4",
559
765
  children: [
560
766
  1,
561
767
  2,
562
768
  3,
563
769
  4
564
- ].map((e) => /* @__PURE__ */ k("div", { className: "h-24 bg-muted animate-pulse rounded-lg" }, e))
770
+ ].map((e) => /* @__PURE__ */ A("div", { className: "h-24 bg-muted animate-pulse rounded-lg" }, e))
565
771
  }),
566
- /* @__PURE__ */ k("div", { className: "h-64 bg-muted animate-pulse rounded-lg" })
772
+ /* @__PURE__ */ A("div", { className: "h-64 bg-muted animate-pulse rounded-lg" })
567
773
  ]
568
774
  });
569
- if (G) return /* @__PURE__ */ k("div", {
775
+ if (fe) return /* @__PURE__ */ A("div", {
570
776
  className: "flex items-center justify-center h-full min-h-[400px]",
571
- children: /* @__PURE__ */ A("div", {
777
+ children: /* @__PURE__ */ j("div", {
572
778
  className: "text-center space-y-4",
573
779
  children: [
574
- /* @__PURE__ */ k("div", {
780
+ /* @__PURE__ */ A("div", {
575
781
  className: "size-12 mx-auto rounded-full bg-destructive/10 flex items-center justify-center",
576
- children: /* @__PURE__ */ k(h, { className: "size-6 text-destructive" })
782
+ children: /* @__PURE__ */ A(g, { className: "size-6 text-destructive" })
577
783
  }),
578
- /* @__PURE__ */ k("h2", {
784
+ /* @__PURE__ */ A("h2", {
579
785
  className: "text-lg font-semibold text-foreground",
580
786
  children: "Failed to load usage data"
581
787
  }),
582
- /* @__PURE__ */ k("p", {
788
+ /* @__PURE__ */ A("p", {
583
789
  className: "text-sm text-muted-foreground",
584
- children: G.message
790
+ children: fe.message
585
791
  }),
586
- /* @__PURE__ */ k("button", {
792
+ /* @__PURE__ */ A("button", {
587
793
  type: "button",
588
- onClick: () => ue(),
794
+ onClick: () => pe(),
589
795
  className: "px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
590
796
  children: "Try Again"
591
797
  })
592
798
  ]
593
799
  })
594
800
  });
595
- let ge = R.find((e) => e.id === z);
596
- return /* @__PURE__ */ A("div", {
801
+ let ye = L.find((e) => e.id === R);
802
+ return /* @__PURE__ */ j("div", {
597
803
  className: "space-y-6 p-6",
598
804
  children: [
599
- /* @__PURE__ */ A("div", {
805
+ /* @__PURE__ */ j("div", {
600
806
  className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
601
- children: [/* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("h1", {
807
+ children: [/* @__PURE__ */ j("div", { children: [/* @__PURE__ */ A("h1", {
602
808
  className: "text-2xl font-bold text-foreground",
603
809
  children: r("billing.usage.title", "Usage")
604
- }), /* @__PURE__ */ k("p", {
810
+ }), /* @__PURE__ */ A("p", {
605
811
  className: "text-sm text-muted-foreground mt-1",
606
812
  children: "Monitor your resource consumption and quota usage"
607
- })] }), /* @__PURE__ */ A("div", {
813
+ })] }), /* @__PURE__ */ j("div", {
608
814
  className: "flex items-center gap-3",
609
- children: [R.length > 1 && /* @__PURE__ */ k("select", {
610
- value: z || "",
611
- onChange: (e) => l(e.target.value),
612
- className: "px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary w-full sm:min-w-[200px]",
613
- children: R.map((e) => /* @__PURE__ */ k("option", {
614
- value: e.id,
615
- children: e.name
616
- }, e.id))
617
- }), /* @__PURE__ */ k("button", {
618
- type: "button",
619
- onClick: () => ue(),
620
- className: "p-2 border border-border rounded-md hover:bg-muted/50 transition-colors",
621
- title: "Refresh",
622
- children: /* @__PURE__ */ k(w, { className: "size-4" })
623
- })]
624
- })]
625
- }),
626
- /* @__PURE__ */ A("div", {
627
- className: "flex flex-col gap-3 sm:flex-row sm:items-center",
628
- children: [
629
- /* @__PURE__ */ A("div", {
630
- className: "relative flex-1 max-w-md",
631
- children: [
632
- /* @__PURE__ */ k(T, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" }),
633
- /* @__PURE__ */ k("input", {
634
- type: "text",
635
- value: x,
636
- onChange: (e) => j(e.target.value),
637
- placeholder: `Search ${I === "past" ? "past" : I === "all" ? "all" : "active"} quotas...`,
638
- className: "w-full pl-9 pr-3 py-2 text-sm border border-border rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"
639
- }),
640
- (x || me) && /* @__PURE__ */ k("button", {
815
+ children: [
816
+ /* @__PURE__ */ j("div", {
817
+ className: "flex items-center bg-muted/50 rounded-lg p-1 border border-border",
818
+ children: [/* @__PURE__ */ j("button", {
641
819
  type: "button",
642
- onClick: () => j(""),
643
- className: "absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted/50",
644
- children: me ? /* @__PURE__ */ k(w, { className: "size-3 text-muted-foreground animate-spin" }) : /* @__PURE__ */ k(E, { className: "size-3 text-muted-foreground" })
645
- })
646
- ]
647
- }),
648
- /* @__PURE__ */ A("div", {
649
- className: "flex items-center bg-muted/50 rounded-lg p-1 border border-border",
650
- children: [/* @__PURE__ */ A("button", {
651
- type: "button",
652
- onClick: () => L("active"),
653
- className: `flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-all ${I === "active" ? "bg-background text-foreground shadow-sm font-medium" : "text-muted-foreground hover:text-foreground"}`,
654
- children: [/* @__PURE__ */ k(C, { className: "size-3.5" }), "Active"]
655
- }), /* @__PURE__ */ A("button", {
820
+ onClick: () => ue("workspace"),
821
+ className: `flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-all ${B === "workspace" ? "bg-background text-foreground shadow-sm font-medium" : "text-muted-foreground hover:text-foreground"}`,
822
+ children: [/* @__PURE__ */ A(C, { className: "size-3.5" }), "Workspace"]
823
+ }), /* @__PURE__ */ j("button", {
824
+ type: "button",
825
+ onClick: () => ue("global"),
826
+ className: `flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-all ${B === "global" ? "bg-background text-foreground shadow-sm font-medium" : "text-muted-foreground hover:text-foreground"}`,
827
+ children: [/* @__PURE__ */ A(w, { className: "size-3.5" }), "Global"]
828
+ })]
829
+ }),
830
+ B === "global" && L.length > 1 && /* @__PURE__ */ A("select", {
831
+ value: R || "",
832
+ onChange: (e) => l(e.target.value),
833
+ className: "px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary w-full sm:min-w-[200px]",
834
+ children: L.map((e) => /* @__PURE__ */ A("option", {
835
+ value: e.id,
836
+ children: e.name
837
+ }, e.id))
838
+ }),
839
+ /* @__PURE__ */ A("button", {
656
840
  type: "button",
657
- onClick: () => L("past"),
658
- disabled: W && I !== "past",
659
- className: `flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-all ${I === "past" ? "bg-background text-foreground shadow-sm font-medium" : "text-muted-foreground hover:text-foreground"} ${W && I !== "past" ? "opacity-70" : ""}`,
660
- children: [W && I === "past" ? /* @__PURE__ */ k(w, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ k(b, { className: "size-3.5" }), "Past"]
661
- })]
662
- }),
663
- Q && /* @__PURE__ */ A("button", {
664
- type: "button",
665
- onClick: he,
666
- className: "flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted/50 transition-colors",
667
- children: [/* @__PURE__ */ k(E, { className: "size-3" }), "Clear filters"]
668
- })
669
- ]
670
- }),
671
- ge && /* @__PURE__ */ A("div", {
672
- className: "text-sm text-muted-foreground",
673
- children: [
674
- "Viewing usage for",
675
- " ",
676
- /* @__PURE__ */ k("span", {
677
- className: "font-medium text-foreground",
678
- children: ge.name
679
- })
680
- ]
681
- }),
682
- B && /* @__PURE__ */ A("div", {
683
- className: "grid grid-cols-2 sm:grid-cols-4 gap-4",
684
- children: [
685
- /* @__PURE__ */ k(N, {
686
- label: "Total Quotas",
687
- value: B.totalQuotas,
688
- icon: /* @__PURE__ */ k(S, { className: "size-5" }),
689
- color: "blue",
690
- isActive: M === "all",
691
- onClick: () => P("all")
692
- }),
693
- /* @__PURE__ */ k(N, {
694
- label: "Healthy",
695
- value: B.healthyQuotas,
696
- icon: /* @__PURE__ */ k(g, { className: "size-5" }),
697
- color: "emerald",
698
- isActive: M === "healthy",
699
- onClick: () => $("healthy")
700
- }),
701
- /* @__PURE__ */ k(N, {
702
- label: "Warning",
703
- value: B.warningQuotas,
704
- icon: /* @__PURE__ */ k(m, { className: "size-5" }),
705
- color: "amber",
706
- isActive: M === "warning",
707
- onClick: () => $("warning")
708
- }),
709
- /* @__PURE__ */ k(N, {
710
- label: "Critical / Exhausted",
711
- value: B.criticalQuotas + B.exhaustedQuotas,
712
- icon: /* @__PURE__ */ k(h, { className: "size-5" }),
713
- color: "red",
714
- isActive: M === "critical",
715
- onClick: () => $("critical")
716
- })
717
- ]
718
- }),
719
- B && (B.warningQuotas > 0 || B.criticalQuotas > 0 || B.exhaustedQuotas > 0) && /* @__PURE__ */ A("div", {
720
- className: `flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between p-4 rounded-lg border ${B.criticalQuotas > 0 || B.exhaustedQuotas > 0 ? `${t.error.bg} ${t.error.border}` : `${t.warning.bg} ${t.warning.border}`}`,
721
- children: [/* @__PURE__ */ A("div", {
722
- className: "flex items-center gap-3",
723
- children: [B.criticalQuotas > 0 || B.exhaustedQuotas > 0 ? /* @__PURE__ */ k(D, { className: `size-5 shrink-0 ${t.error.icon}` }) : /* @__PURE__ */ k(m, { className: `size-5 shrink-0 ${t.warning.icon}` }), /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("p", {
724
- className: `text-sm font-medium ${B.criticalQuotas > 0 || B.exhaustedQuotas > 0 ? t.error.text : t.warning.text}`,
725
- children: B.criticalQuotas > 0 || B.exhaustedQuotas > 0 ? `${B.criticalQuotas + B.exhaustedQuotas} quota${B.criticalQuotas + B.exhaustedQuotas === 1 ? "" : "s"} exhausted or critical` : `${B.warningQuotas} quota${B.warningQuotas === 1 ? "" : "s"} approaching the limit`
726
- }), /* @__PURE__ */ k("p", {
727
- className: "text-xs text-muted-foreground mt-0.5",
728
- children: "Contact support to request a quota increase for your plan."
729
- })] })]
730
- }), /* @__PURE__ */ k("button", {
731
- type: "button",
732
- onClick: () => ce("/support/tickets"),
733
- className: `shrink-0 px-4 py-2 text-sm font-medium rounded-md border transition-colors ${B.criticalQuotas > 0 || B.exhaustedQuotas > 0 ? "bg-destructive text-destructive-foreground border-destructive hover:bg-destructive/90" : "border-status-warning-border text-status-warning-text hover:bg-status-warning-bg-subtle"}`,
734
- children: "Request more quota"
735
- })]
736
- }),
737
- (Q || I !== "active") && /* @__PURE__ */ A("div", {
738
- className: "flex items-center gap-2 text-sm text-muted-foreground flex-wrap",
739
- children: [
740
- /* @__PURE__ */ A("span", { children: [
741
- "Showing",
742
- " ",
743
- Z.active.reduce((e, t) => e + t.aggregatedQuotas.length, 0) + Z.past.reduce((e, t) => e + t.aggregatedQuotas.length, 0) + (I === "past" ? 0 : J.length),
744
- " ",
745
- "quotas"
746
- ] }),
747
- /* @__PURE__ */ A("span", {
748
- className: "px-2 py-0.5 bg-primary/10 text-primary rounded text-xs capitalize",
749
- children: [I === "active" ? "Active" : I === "past" ? "Past" : "All", " subscriptions"]
750
- }),
751
- M !== "all" && /* @__PURE__ */ k("span", {
752
- className: "px-2 py-0.5 bg-muted rounded text-xs capitalize",
753
- children: M === "critical" ? "Critical / Exhausted" : M
754
- }),
755
- x && /* @__PURE__ */ A("span", {
756
- className: "px-2 py-0.5 bg-muted rounded text-xs",
757
- children: [
758
- "“",
759
- x,
760
- "”"
761
- ]
762
- })
763
- ]
764
- }),
765
- Z.active.length > 0 && /* @__PURE__ */ A("section", { children: [/* @__PURE__ */ A("h2", {
766
- className: "text-lg font-semibold text-foreground mb-4 flex items-center gap-2",
767
- children: [/* @__PURE__ */ k(C, { className: "size-5 text-primary" }), I === "all" ? "Active Subscription Quotas" : "Subscription Quotas"]
768
- }), /* @__PURE__ */ k("div", {
769
- className: "space-y-4",
770
- children: Z.active.map((e) => /* @__PURE__ */ k(F, {
771
- subscription: e,
772
- onQuotaClick: y,
773
- defaultExpanded: !0
774
- }, e.id))
775
- })] }),
776
- Z.past.length > 0 && /* @__PURE__ */ A("section", { children: [/* @__PURE__ */ A("h2", {
777
- className: "text-lg font-semibold text-foreground mb-4 flex items-center gap-2",
778
- children: [
779
- /* @__PURE__ */ k(b, { className: "size-5 text-muted-foreground" }),
780
- "Past Subscription Quotas",
781
- /* @__PURE__ */ k("span", {
782
- className: "text-xs font-normal text-muted-foreground",
783
- children: "(Canceled / Expired / Upgraded)"
784
- }),
785
- K > 0 && /* @__PURE__ */ A("span", {
786
- className: "text-xs font-normal px-2 py-0.5 bg-muted rounded-full",
787
- children: [
788
- Z.past.length,
789
- fe ? "+" : "",
790
- " of ",
791
- K
792
- ]
793
- })
794
- ]
795
- }), /* @__PURE__ */ A("div", {
796
- className: "space-y-4",
797
- children: [Z.past.map((e) => /* @__PURE__ */ k(F, {
798
- subscription: e,
799
- onQuotaClick: y,
800
- defaultExpanded: I === "past"
801
- }, e.id)), fe && /* @__PURE__ */ k("div", {
802
- className: "flex justify-center pt-2",
803
- children: /* @__PURE__ */ k("button", {
804
- type: "button",
805
- onClick: de,
806
- disabled: pe,
807
- className: "flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted/50 transition-colors disabled:opacity-50",
808
- children: pe ? /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(w, { className: "size-4 animate-spin" }), "Loading…"] }) : /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(_, { className: "size-4" }), "Load more past subscriptions"] })
809
- })
841
+ onClick: () => B === "workspace" ? void 0 : pe(),
842
+ className: "p-2 border border-border rounded-md hover:bg-muted/50 transition-colors",
843
+ title: "Refresh",
844
+ children: /* @__PURE__ */ A(T, { className: "size-4" })
845
+ })
846
+ ]
810
847
  })]
811
- })] }),
812
- I !== "past" && J.length > 0 && /* @__PURE__ */ A("section", { children: [/* @__PURE__ */ A("h2", {
813
- className: "text-lg font-semibold text-foreground mb-4 flex items-center gap-2",
814
- children: [
815
- /* @__PURE__ */ k(S, { className: `size-5 ${t.info.icon}` }),
816
- "Pooled Quotas",
817
- /* @__PURE__ */ k("span", {
818
- className: "text-xs font-normal text-muted-foreground",
819
- children: "(Shared across all products)"
820
- })
821
- ]
822
- }), /* @__PURE__ */ k(ne, {
823
- quotas: J,
824
- showPlanColumn: !1,
825
- onQuotaClick: y
826
- })] }),
827
- I === "active" && H.length === 0 && V.length === 0 && !Q && /* @__PURE__ */ A("div", {
828
- className: "flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg",
829
- children: [
830
- /* @__PURE__ */ k("div", {
831
- className: "size-12 rounded-full bg-muted flex items-center justify-center mb-4",
832
- children: /* @__PURE__ */ k(S, { className: "size-6 text-muted-foreground" })
833
- }),
834
- /* @__PURE__ */ k("h3", {
835
- className: "text-lg font-medium text-foreground",
836
- children: "No active quotas found"
837
- }),
838
- /* @__PURE__ */ k("p", {
839
- className: "text-sm text-muted-foreground mt-1 text-center max-w-sm",
840
- children: "Quotas will appear here once you have active subscriptions or pooled allocations."
841
- })
842
- ]
843
- }),
844
- I === "past" && U.length === 0 && !Q && !W && /* @__PURE__ */ A("div", {
845
- className: "flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg",
846
- children: [
847
- /* @__PURE__ */ k("div", {
848
- className: "size-12 rounded-full bg-muted flex items-center justify-center mb-4",
849
- children: /* @__PURE__ */ k(b, { className: "size-6 text-muted-foreground" })
850
- }),
851
- /* @__PURE__ */ k("h3", {
852
- className: "text-lg font-medium text-foreground",
853
- children: "No past subscriptions"
854
- }),
855
- /* @__PURE__ */ k("p", {
856
- className: "text-sm text-muted-foreground mt-1 text-center max-w-sm",
857
- children: "You don't have any canceled, expired, or upgraded subscriptions yet."
858
- }),
859
- /* @__PURE__ */ k("button", {
860
- type: "button",
861
- onClick: () => L("active"),
862
- className: "mt-4 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
863
- children: "View active subscriptions"
864
- })
865
- ]
866
848
  }),
867
- I === "past" && W && /* @__PURE__ */ k("div", {
868
- className: "space-y-4",
869
- children: [
870
- 1,
871
- 2,
872
- 3
873
- ].map((e) => /* @__PURE__ */ k("div", { className: "h-24 bg-muted animate-pulse rounded-lg" }, e))
849
+ B === "workspace" && z && /* @__PURE__ */ A(oe, { workspaceId: z }),
850
+ B === "workspace" && !z && /* @__PURE__ */ A("div", {
851
+ className: "text-center py-12 text-muted-foreground text-sm",
852
+ children: "No workspace context available."
874
853
  }),
875
- Q && Z.active.length === 0 && Z.past.length === 0 && (I === "past" || J.length === 0) && /* @__PURE__ */ A("div", {
876
- className: "flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg",
877
- children: [
878
- /* @__PURE__ */ k("div", {
879
- className: "size-12 rounded-full bg-muted flex items-center justify-center mb-4",
880
- children: M !== "all" && !x ? /* @__PURE__ */ k(te, {
881
- status: M === "healthy" ? "HEALTHY" : M === "warning" ? "WARNING" : "CRITICAL",
882
- className: "size-6"
883
- }) : /* @__PURE__ */ k(T, { className: "size-6 text-muted-foreground" })
884
- }),
885
- /* @__PURE__ */ k("h3", {
886
- className: "text-lg font-medium text-foreground",
887
- children: M !== "all" && !x ? `No ${M === "critical" ? "critical or exhausted" : M} quotas` : "No matching quotas"
888
- }),
889
- /* @__PURE__ */ k("p", {
890
- className: "text-sm text-muted-foreground mt-1 text-center max-w-sm",
891
- children: M !== "all" && !x ? /* @__PURE__ */ A(O, { children: ["All your quotas are in a different status.", B && /* @__PURE__ */ A("span", {
892
- className: "block mt-1",
854
+ B === "global" && /* @__PURE__ */ j(k, { children: [
855
+ /* @__PURE__ */ j("div", {
856
+ className: "flex flex-col gap-3 sm:flex-row sm:items-center",
857
+ children: [
858
+ /* @__PURE__ */ j("div", {
859
+ className: "relative flex-1 max-w-md",
893
860
  children: [
894
- "You have ",
895
- B.healthyQuotas,
896
- " healthy, ",
897
- B.warningQuotas,
898
- " warning, and ",
899
- B.criticalQuotas + B.exhaustedQuotas,
900
- " critical quotas."
861
+ /* @__PURE__ */ A(E, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" }),
862
+ /* @__PURE__ */ A("input", {
863
+ type: "text",
864
+ value: y,
865
+ onChange: (e) => b(e.target.value),
866
+ placeholder: `Search ${N === "past" ? "past" : N === "all" ? "all" : "active"} quotas...`,
867
+ className: "w-full pl-9 pr-3 py-2 text-sm border border-border rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"
868
+ }),
869
+ (y || Q) && /* @__PURE__ */ A("button", {
870
+ type: "button",
871
+ onClick: () => b(""),
872
+ className: "absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted/50",
873
+ children: Q ? /* @__PURE__ */ A(T, { className: "size-3 text-muted-foreground animate-spin" }) : /* @__PURE__ */ A(D, { className: "size-3 text-muted-foreground" })
874
+ })
901
875
  ]
902
- })] }) : /* @__PURE__ */ A(O, { children: [
903
- "No quotas match your current search or filter criteria in",
876
+ }),
877
+ /* @__PURE__ */ j("div", {
878
+ className: "flex items-center bg-muted/50 rounded-lg p-1 border border-border",
879
+ children: [/* @__PURE__ */ j("button", {
880
+ type: "button",
881
+ onClick: () => F("active"),
882
+ className: `flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-all ${N === "active" ? "bg-background text-foreground shadow-sm font-medium" : "text-muted-foreground hover:text-foreground"}`,
883
+ children: [/* @__PURE__ */ A(w, { className: "size-3.5" }), "Active"]
884
+ }), /* @__PURE__ */ j("button", {
885
+ type: "button",
886
+ onClick: () => F("past"),
887
+ disabled: G && N !== "past",
888
+ className: `flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-all ${N === "past" ? "bg-background text-foreground shadow-sm font-medium" : "text-muted-foreground hover:text-foreground"} ${G && N !== "past" ? "opacity-70" : ""}`,
889
+ children: [G && N === "past" ? /* @__PURE__ */ A(T, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ A(x, { className: "size-3.5" }), "Past"]
890
+ })]
891
+ }),
892
+ Z && /* @__PURE__ */ j("button", {
893
+ type: "button",
894
+ onClick: ve,
895
+ className: "flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted/50 transition-colors",
896
+ children: [/* @__PURE__ */ A(D, { className: "size-3" }), "Clear filters"]
897
+ })
898
+ ]
899
+ }),
900
+ ye && /* @__PURE__ */ j("div", {
901
+ className: "text-sm text-muted-foreground",
902
+ children: [
903
+ "Viewing usage for",
904
+ " ",
905
+ /* @__PURE__ */ A("span", {
906
+ className: "font-medium text-foreground",
907
+ children: ye.name
908
+ })
909
+ ]
910
+ }),
911
+ V && /* @__PURE__ */ j("div", {
912
+ className: "grid grid-cols-2 sm:grid-cols-4 gap-4",
913
+ children: [
914
+ /* @__PURE__ */ A(P, {
915
+ label: "Total Quotas",
916
+ value: V.totalQuotas,
917
+ icon: /* @__PURE__ */ A(C, { className: "size-5" }),
918
+ color: "blue",
919
+ isActive: S === "all",
920
+ onClick: () => M("all")
921
+ }),
922
+ /* @__PURE__ */ A(P, {
923
+ label: "Healthy",
924
+ value: V.healthyQuotas,
925
+ icon: /* @__PURE__ */ A(_, { className: "size-5" }),
926
+ color: "emerald",
927
+ isActive: S === "healthy",
928
+ onClick: () => $("healthy")
929
+ }),
930
+ /* @__PURE__ */ A(P, {
931
+ label: "Warning",
932
+ value: V.warningQuotas,
933
+ icon: /* @__PURE__ */ A(h, { className: "size-5" }),
934
+ color: "amber",
935
+ isActive: S === "warning",
936
+ onClick: () => $("warning")
937
+ }),
938
+ /* @__PURE__ */ A(P, {
939
+ label: "Critical / Exhausted",
940
+ value: V.criticalQuotas + V.exhaustedQuotas,
941
+ icon: /* @__PURE__ */ A(g, { className: "size-5" }),
942
+ color: "red",
943
+ isActive: S === "critical",
944
+ onClick: () => $("critical")
945
+ })
946
+ ]
947
+ }),
948
+ V && (V.warningQuotas > 0 || V.criticalQuotas > 0 || V.exhaustedQuotas > 0) && /* @__PURE__ */ j("div", {
949
+ className: `flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between p-4 rounded-lg border ${V.criticalQuotas > 0 || V.exhaustedQuotas > 0 ? `${t.error.bg} ${t.error.border}` : `${t.warning.bg} ${t.warning.border}`}`,
950
+ children: [/* @__PURE__ */ j("div", {
951
+ className: "flex items-center gap-3",
952
+ children: [V.criticalQuotas > 0 || V.exhaustedQuotas > 0 ? /* @__PURE__ */ A(O, { className: `size-5 shrink-0 ${t.error.icon}` }) : /* @__PURE__ */ A(h, { className: `size-5 shrink-0 ${t.warning.icon}` }), /* @__PURE__ */ j("div", { children: [/* @__PURE__ */ A("p", {
953
+ className: `text-sm font-medium ${V.criticalQuotas > 0 || V.exhaustedQuotas > 0 ? t.error.text : t.warning.text}`,
954
+ children: V.criticalQuotas > 0 || V.exhaustedQuotas > 0 ? `${V.criticalQuotas + V.exhaustedQuotas} quota${V.criticalQuotas + V.exhaustedQuotas === 1 ? "" : "s"} exhausted or critical` : `${V.warningQuotas} quota${V.warningQuotas === 1 ? "" : "s"} approaching the limit`
955
+ }), /* @__PURE__ */ A("p", {
956
+ className: "text-xs text-muted-foreground mt-0.5",
957
+ children: "Contact support to request a quota increase for your plan."
958
+ })] })]
959
+ }), /* @__PURE__ */ A("button", {
960
+ type: "button",
961
+ onClick: () => le("/support/tickets"),
962
+ className: `shrink-0 px-4 py-2 text-sm font-medium rounded-md border transition-colors ${V.criticalQuotas > 0 || V.exhaustedQuotas > 0 ? "bg-destructive text-destructive-foreground border-destructive hover:bg-destructive/90" : "border-status-warning-border text-status-warning-text hover:bg-status-warning-bg-subtle"}`,
963
+ children: "Request more quota"
964
+ })]
965
+ }),
966
+ (Z || N !== "active") && /* @__PURE__ */ j("div", {
967
+ className: "flex items-center gap-2 text-sm text-muted-foreground flex-wrap",
968
+ children: [
969
+ /* @__PURE__ */ j("span", { children: [
970
+ "Showing",
904
971
  " ",
905
- I === "past" ? "past" : I === "all" ? "any" : "active",
972
+ X.active.reduce((e, t) => e + t.aggregatedQuotas.length, 0) + X.past.reduce((e, t) => e + t.aggregatedQuotas.length, 0) + (N === "past" ? 0 : q.length),
906
973
  " ",
907
- "subscriptions.",
908
- I === "active" && !M.includes("all") && /* @__PURE__ */ k("span", {
909
- className: "block mt-1",
910
- children: "Try switching to “Past” or “All” to search across more subscriptions."
911
- })
912
- ] })
913
- }),
914
- /* @__PURE__ */ A("div", {
915
- className: "flex gap-2 mt-4",
916
- children: [/* @__PURE__ */ k("button", {
974
+ "quotas"
975
+ ] }),
976
+ /* @__PURE__ */ j("span", {
977
+ className: "px-2 py-0.5 bg-primary/10 text-primary rounded text-xs capitalize",
978
+ children: [
979
+ N === "active" ? "Active" : N === "past" ? "Past" : "All",
980
+ " ",
981
+ "subscriptions"
982
+ ]
983
+ }),
984
+ S !== "all" && /* @__PURE__ */ A("span", {
985
+ className: "px-2 py-0.5 bg-muted rounded text-xs capitalize",
986
+ children: S === "critical" ? "Critical / Exhausted" : S
987
+ }),
988
+ y && /* @__PURE__ */ j("span", {
989
+ className: "px-2 py-0.5 bg-muted rounded text-xs",
990
+ children: [
991
+ "“",
992
+ y,
993
+ "”"
994
+ ]
995
+ })
996
+ ]
997
+ }),
998
+ X.active.length > 0 && /* @__PURE__ */ j("section", { children: [/* @__PURE__ */ j("h2", {
999
+ className: "text-lg font-semibold text-foreground mb-4 flex items-center gap-2",
1000
+ children: [/* @__PURE__ */ A(w, { className: "size-5 text-primary" }), N === "all" ? "Active Subscription Quotas" : "Subscription Quotas"]
1001
+ }), /* @__PURE__ */ A("div", {
1002
+ className: "space-y-4",
1003
+ children: X.active.map((e) => /* @__PURE__ */ A(ie, {
1004
+ subscription: e,
1005
+ onQuotaClick: d,
1006
+ defaultExpanded: !0
1007
+ }, e.id))
1008
+ })] }),
1009
+ X.past.length > 0 && /* @__PURE__ */ j("section", { children: [/* @__PURE__ */ j("h2", {
1010
+ className: "text-lg font-semibold text-foreground mb-4 flex items-center gap-2",
1011
+ children: [
1012
+ /* @__PURE__ */ A(x, { className: "size-5 text-muted-foreground" }),
1013
+ "Past Subscription Quotas",
1014
+ /* @__PURE__ */ A("span", {
1015
+ className: "text-xs font-normal text-muted-foreground",
1016
+ children: "(Canceled / Expired / Upgraded)"
1017
+ }),
1018
+ _e > 0 && /* @__PURE__ */ j("span", {
1019
+ className: "text-xs font-normal px-2 py-0.5 bg-muted rounded-full",
1020
+ children: [
1021
+ X.past.length,
1022
+ he ? "+" : "",
1023
+ " of ",
1024
+ _e
1025
+ ]
1026
+ })
1027
+ ]
1028
+ }), /* @__PURE__ */ j("div", {
1029
+ className: "space-y-4",
1030
+ children: [X.past.map((e) => /* @__PURE__ */ A(ie, {
1031
+ subscription: e,
1032
+ onQuotaClick: d,
1033
+ defaultExpanded: N === "past"
1034
+ }, e.id)), he && /* @__PURE__ */ A("div", {
1035
+ className: "flex justify-center pt-2",
1036
+ children: /* @__PURE__ */ A("button", {
917
1037
  type: "button",
918
- onClick: he,
919
- className: "px-4 py-2 text-sm font-medium border border-border rounded-md hover:bg-muted/50 transition-colors",
920
- children: M === "all" ? "Clear filters" : "Show all quotas"
921
- }), I === "active" && x && /* @__PURE__ */ k("button", {
1038
+ onClick: me,
1039
+ disabled: ge,
1040
+ className: "flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted/50 transition-colors disabled:opacity-50",
1041
+ children: ge ? /* @__PURE__ */ j(k, { children: [/* @__PURE__ */ A(T, { className: "size-4 animate-spin" }), "Loading…"] }) : /* @__PURE__ */ j(k, { children: [/* @__PURE__ */ A(v, { className: "size-4" }), "Load more past subscriptions"] })
1042
+ })
1043
+ })]
1044
+ })] }),
1045
+ N !== "past" && q.length > 0 && /* @__PURE__ */ j("section", { children: [/* @__PURE__ */ j("h2", {
1046
+ className: "text-lg font-semibold text-foreground mb-4 flex items-center gap-2",
1047
+ children: [
1048
+ /* @__PURE__ */ A(C, { className: `size-5 ${t.info.icon}` }),
1049
+ "Pooled Quotas",
1050
+ /* @__PURE__ */ A("span", {
1051
+ className: "text-xs font-normal text-muted-foreground",
1052
+ children: "(Shared across all products)"
1053
+ })
1054
+ ]
1055
+ }), /* @__PURE__ */ A(re, {
1056
+ quotas: q,
1057
+ showPlanColumn: !1,
1058
+ onQuotaClick: d
1059
+ })] }),
1060
+ N === "active" && U.length === 0 && H.length === 0 && !Z && /* @__PURE__ */ j("div", {
1061
+ className: "flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg",
1062
+ children: [
1063
+ /* @__PURE__ */ A("div", {
1064
+ className: "size-12 rounded-full bg-muted flex items-center justify-center mb-4",
1065
+ children: /* @__PURE__ */ A(C, { className: "size-6 text-muted-foreground" })
1066
+ }),
1067
+ /* @__PURE__ */ A("h3", {
1068
+ className: "text-lg font-medium text-foreground",
1069
+ children: "No active quotas found"
1070
+ }),
1071
+ /* @__PURE__ */ A("p", {
1072
+ className: "text-sm text-muted-foreground mt-1 text-center max-w-sm",
1073
+ children: "Quotas will appear here once you have active subscriptions or pooled allocations."
1074
+ })
1075
+ ]
1076
+ }),
1077
+ N === "past" && W.length === 0 && !Z && !G && /* @__PURE__ */ j("div", {
1078
+ className: "flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg",
1079
+ children: [
1080
+ /* @__PURE__ */ A("div", {
1081
+ className: "size-12 rounded-full bg-muted flex items-center justify-center mb-4",
1082
+ children: /* @__PURE__ */ A(x, { className: "size-6 text-muted-foreground" })
1083
+ }),
1084
+ /* @__PURE__ */ A("h3", {
1085
+ className: "text-lg font-medium text-foreground",
1086
+ children: "No past subscriptions"
1087
+ }),
1088
+ /* @__PURE__ */ A("p", {
1089
+ className: "text-sm text-muted-foreground mt-1 text-center max-w-sm",
1090
+ children: "You don't have any canceled, expired, or upgraded subscriptions yet."
1091
+ }),
1092
+ /* @__PURE__ */ A("button", {
922
1093
  type: "button",
923
- onClick: () => L("all"),
924
- className: "px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
925
- children: "Search all"
926
- })]
927
- })
928
- ]
929
- }),
930
- v && /* @__PURE__ */ k(re, {
931
- quota: v,
932
- onClose: () => y(null)
1094
+ onClick: () => F("active"),
1095
+ className: "mt-4 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
1096
+ children: "View active subscriptions"
1097
+ })
1098
+ ]
1099
+ }),
1100
+ N === "past" && G && /* @__PURE__ */ A("div", {
1101
+ className: "space-y-4",
1102
+ children: [
1103
+ 1,
1104
+ 2,
1105
+ 3
1106
+ ].map((e) => /* @__PURE__ */ A("div", { className: "h-24 bg-muted animate-pulse rounded-lg" }, e))
1107
+ }),
1108
+ Z && X.active.length === 0 && X.past.length === 0 && (N === "past" || q.length === 0) && /* @__PURE__ */ j("div", {
1109
+ className: "flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg",
1110
+ children: [
1111
+ /* @__PURE__ */ A("div", {
1112
+ className: "size-12 rounded-full bg-muted flex items-center justify-center mb-4",
1113
+ children: S !== "all" && !y ? /* @__PURE__ */ A(ne, {
1114
+ status: S === "healthy" ? "HEALTHY" : S === "warning" ? "WARNING" : "CRITICAL",
1115
+ className: "size-6"
1116
+ }) : /* @__PURE__ */ A(E, { className: "size-6 text-muted-foreground" })
1117
+ }),
1118
+ /* @__PURE__ */ A("h3", {
1119
+ className: "text-lg font-medium text-foreground",
1120
+ children: S !== "all" && !y ? `No ${S === "critical" ? "critical or exhausted" : S} quotas` : "No matching quotas"
1121
+ }),
1122
+ /* @__PURE__ */ A("p", {
1123
+ className: "text-sm text-muted-foreground mt-1 text-center max-w-sm",
1124
+ children: S !== "all" && !y ? /* @__PURE__ */ j(k, { children: ["All your quotas are in a different status.", V && /* @__PURE__ */ j("span", {
1125
+ className: "block mt-1",
1126
+ children: [
1127
+ "You have ",
1128
+ V.healthyQuotas,
1129
+ " healthy, ",
1130
+ V.warningQuotas,
1131
+ " ",
1132
+ "warning, and ",
1133
+ V.criticalQuotas + V.exhaustedQuotas,
1134
+ " ",
1135
+ "critical quotas."
1136
+ ]
1137
+ })] }) : /* @__PURE__ */ j(k, { children: [
1138
+ "No quotas match your current search or filter criteria in",
1139
+ " ",
1140
+ N === "past" ? "past" : N === "all" ? "any" : "active",
1141
+ " ",
1142
+ "subscriptions.",
1143
+ N === "active" && !S.includes("all") && /* @__PURE__ */ A("span", {
1144
+ className: "block mt-1",
1145
+ children: "Try switching to “Past” or “All” to search across more subscriptions."
1146
+ })
1147
+ ] })
1148
+ }),
1149
+ /* @__PURE__ */ j("div", {
1150
+ className: "flex gap-2 mt-4",
1151
+ children: [/* @__PURE__ */ A("button", {
1152
+ type: "button",
1153
+ onClick: ve,
1154
+ className: "px-4 py-2 text-sm font-medium border border-border rounded-md hover:bg-muted/50 transition-colors",
1155
+ children: S === "all" ? "Clear filters" : "Show all quotas"
1156
+ }), N === "active" && y && /* @__PURE__ */ A("button", {
1157
+ type: "button",
1158
+ onClick: () => F("all"),
1159
+ className: "px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
1160
+ children: "Search all"
1161
+ })]
1162
+ })
1163
+ ]
1164
+ })
1165
+ ] }),
1166
+ u && /* @__PURE__ */ A(ae, {
1167
+ quota: u,
1168
+ onClose: () => d(null)
933
1169
  })
934
1170
  ]
935
1171
  });
936
1172
  };
937
1173
  //#endregion
938
- export { I as UsagePage };
1174
+ export { L as UsagePage };
939
1175
 
940
1176
  //# sourceMappingURL=UsagePage.js.map