@schematichq/schematic-components 2.31.1 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,8 +87,8 @@ __export(PaymentMethodForm_exports, {
87
87
  resolveAppearance: () => resolveAppearance
88
88
  });
89
89
  import { useSetupIntent } from "@schematichq/schematic-react";
90
- import { useEffect as useEffect2, useId as useId3, useRef as useRef2, useState as useState3 } from "react";
91
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
90
+ import { useEffect as useEffect2, useId as useId3, useRef as useRef2, useState as useState4 } from "react";
91
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
92
92
  function orUndefined(value) {
93
93
  return value === void 0 || value === "" ? void 0 : value;
94
94
  }
@@ -141,7 +141,7 @@ function PaymentMethodForm({
141
141
  t
142
142
  }) {
143
143
  const { create } = useSetupIntent();
144
- const [state, setState] = useState3({ status: "loading" });
144
+ const [state, setState] = useState4({ status: "loading" });
145
145
  const hostRef = useRef2(null);
146
146
  useEffect2(() => {
147
147
  let cancelled = false;
@@ -189,7 +189,7 @@ function PaymentMethodForm({
189
189
  };
190
190
  }, [create, locale]);
191
191
  if (state.status === "loading") {
192
- return /* @__PURE__ */ jsxs5(
192
+ return /* @__PURE__ */ jsxs6(
193
193
  "div",
194
194
  {
195
195
  "aria-busy": "true",
@@ -197,15 +197,15 @@ function PaymentMethodForm({
197
197
  "data-state": "pending",
198
198
  ref: hostRef,
199
199
  children: [
200
- /* @__PURE__ */ jsx6("span", { className: "schematic-hidden", children: t("paymentMethodsFormLoading") }),
201
- /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton", children: /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
200
+ /* @__PURE__ */ jsx7("span", { className: "schematic-hidden", children: t("paymentMethodsFormLoading") }),
201
+ /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton", children: /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
202
202
  ]
203
203
  }
204
204
  );
205
205
  }
206
206
  if (state.status === "failed") {
207
- return /* @__PURE__ */ jsxs5("div", { className: "schematic-payment-methods__form", "data-state": "error", children: [
208
- /* @__PURE__ */ jsx6(
207
+ return /* @__PURE__ */ jsxs6("div", { className: "schematic-payment-methods__form", "data-state": "error", children: [
208
+ /* @__PURE__ */ jsx7(
209
209
  "p",
210
210
  {
211
211
  className: "schematic-error schematic-small schematic-payment-methods__form-error",
@@ -213,11 +213,11 @@ function PaymentMethodForm({
213
213
  children: t(state.errorKey)
214
214
  }
215
215
  ),
216
- onSelectExisting !== void 0 && /* @__PURE__ */ jsx6(SelectExisting, { t, onSelectExisting })
216
+ onSelectExisting !== void 0 && /* @__PURE__ */ jsx7(SelectExisting, { t, onSelectExisting })
217
217
  ] });
218
218
  }
219
219
  const { Elements } = state.ui;
220
- return /* @__PURE__ */ jsx6(
220
+ return /* @__PURE__ */ jsx7(
221
221
  Elements,
222
222
  {
223
223
  stripe: state.stripe,
@@ -225,7 +225,7 @@ function PaymentMethodForm({
225
225
  appearance: state.appearance,
226
226
  clientSecret: state.clientSecret
227
227
  },
228
- children: /* @__PURE__ */ jsx6(
228
+ children: /* @__PURE__ */ jsx7(
229
229
  Fields,
230
230
  {
231
231
  checkoutPrefill,
@@ -257,13 +257,13 @@ function Fields({
257
257
  const emailId = useId3();
258
258
  const stripe = useStripe();
259
259
  const elements = useElements();
260
- const [saving, setSaving] = useState3(false);
261
- const [message, setMessage] = useState3(null);
262
- const [complete, setComplete] = useState3(false);
263
- const [ready, setReady] = useState3(false);
264
- const [loadFailed, setLoadFailed] = useState3(false);
265
- const [addressComplete, setAddressComplete] = useState3(!collectAddress);
266
- const [typedEmail, setTypedEmail] = useState3(null);
260
+ const [saving, setSaving] = useState4(false);
261
+ const [message, setMessage] = useState4(null);
262
+ const [complete, setComplete] = useState4(false);
263
+ const [ready, setReady] = useState4(false);
264
+ const [loadFailed, setLoadFailed] = useState4(false);
265
+ const [addressComplete, setAddressComplete] = useState4(!collectAddress);
266
+ const [typedEmail, setTypedEmail] = useState4(null);
267
267
  const email = typedEmail ?? orUndefined(prefill?.email) ?? "";
268
268
  const emailValid = !collectEmail || VALID_EMAIL.test(email);
269
269
  useEffect2(() => {
@@ -318,14 +318,14 @@ function Fields({
318
318
  setSaving(false);
319
319
  }
320
320
  };
321
- return /* @__PURE__ */ jsxs5(
321
+ return /* @__PURE__ */ jsxs6(
322
322
  "form",
323
323
  {
324
324
  className: "schematic-payment-methods__form",
325
325
  "data-state": "ready",
326
326
  onSubmit: (event) => void submit(event),
327
327
  children: [
328
- /* @__PURE__ */ jsx6("div", { className: "schematic-payment-methods__fields", children: /* @__PURE__ */ jsx6(
328
+ /* @__PURE__ */ jsx7("div", { className: "schematic-payment-methods__fields", children: /* @__PURE__ */ jsx7(
329
329
  PaymentElement,
330
330
  {
331
331
  onChange: (event) => setComplete(event.complete),
@@ -336,8 +336,8 @@ function Fields({
336
336
  }
337
337
  }
338
338
  ) }),
339
- collectEmail && /* @__PURE__ */ jsxs5("div", { className: "schematic-payment-methods__field", children: [
340
- /* @__PURE__ */ jsx6(
339
+ collectEmail && /* @__PURE__ */ jsxs6("div", { className: "schematic-payment-methods__field", children: [
340
+ /* @__PURE__ */ jsx7(
341
341
  "label",
342
342
  {
343
343
  className: "schematic-payment-methods__field-label",
@@ -345,7 +345,7 @@ function Fields({
345
345
  children: t("paymentMethodsEmail")
346
346
  }
347
347
  ),
348
- /* @__PURE__ */ jsx6(
348
+ /* @__PURE__ */ jsx7(
349
349
  "input",
350
350
  {
351
351
  autoComplete: "email",
@@ -359,7 +359,7 @@ function Fields({
359
359
  }
360
360
  )
361
361
  ] }),
362
- showAddress && /* @__PURE__ */ jsx6("div", { className: "schematic-payment-methods__address", children: /* @__PURE__ */ jsx6(
362
+ showAddress && /* @__PURE__ */ jsx7("div", { className: "schematic-payment-methods__address", children: /* @__PURE__ */ jsx7(
363
363
  AddressElement,
364
364
  {
365
365
  options: {
@@ -373,7 +373,7 @@ function Fields({
373
373
  },
374
374
  prefillName ?? ""
375
375
  ) }),
376
- loadFailed && /* @__PURE__ */ jsx6(
376
+ loadFailed && /* @__PURE__ */ jsx7(
377
377
  "p",
378
378
  {
379
379
  className: "schematic-error schematic-small schematic-payment-methods__form-error",
@@ -381,7 +381,7 @@ function Fields({
381
381
  children: t("paymentMethodsFormError")
382
382
  }
383
383
  ),
384
- message !== null && /* @__PURE__ */ jsx6(
384
+ message !== null && /* @__PURE__ */ jsx7(
385
385
  "p",
386
386
  {
387
387
  className: "schematic-error schematic-small schematic-payment-methods__form-error",
@@ -389,7 +389,7 @@ function Fields({
389
389
  children: message
390
390
  }
391
391
  ),
392
- /* @__PURE__ */ jsx6(
392
+ /* @__PURE__ */ jsx7(
393
393
  "button",
394
394
  {
395
395
  className: "schematic-cta schematic-payment-methods__save",
@@ -398,7 +398,7 @@ function Fields({
398
398
  children: saving ? t("paymentMethodsSaving") : t("paymentMethodsSave")
399
399
  }
400
400
  ),
401
- onSelectExisting !== void 0 && /* @__PURE__ */ jsx6(
401
+ onSelectExisting !== void 0 && /* @__PURE__ */ jsx7(
402
402
  SelectExisting,
403
403
  {
404
404
  disabled: saving,
@@ -415,7 +415,7 @@ function SelectExisting({
415
415
  onSelectExisting,
416
416
  t
417
417
  }) {
418
- return /* @__PURE__ */ jsx6(
418
+ return /* @__PURE__ */ jsx7(
419
419
  "button",
420
420
  {
421
421
  className: "schematic-link-button schematic-payment-methods__select-existing",
@@ -456,8 +456,8 @@ import {
456
456
  BillingDataProvider,
457
457
  FEATURE_USER_USAGE_LIMIT,
458
458
  SchematicI18nProvider,
459
- useFeatureUsage as useFeatureUsage2,
460
- useFeatureUserUsage,
459
+ useFeatureUsage as useFeatureUsage3,
460
+ useFeatureUserUsage as useFeatureUserUsage2,
461
461
  useInvalidateBillingData,
462
462
  useInvoices as useInvoices2,
463
463
  usePaymentMethods as usePaymentMethods2,
@@ -1492,6 +1492,192 @@ function nonEmpty(value) {
1492
1492
  return value === void 0 || value === null || value === "" ? null : value;
1493
1493
  }
1494
1494
 
1495
+ // src/elements/model/meteredFeatures.ts
1496
+ var TONES = [
1497
+ "ok",
1498
+ "ok",
1499
+ "ok",
1500
+ "warning",
1501
+ "critical",
1502
+ "critical"
1503
+ ];
1504
+ function deriveMeteredFeatures(features, options) {
1505
+ const ordered = options.visibleFeatures === void 0 ? features : options.visibleFeatures.flatMap((id) => {
1506
+ const row = features.find((f) => f.featureId === id);
1507
+ return row === void 0 ? [] : [row];
1508
+ });
1509
+ return ordered.filter((row) => row.featureType === "event" || row.featureType === "trait").map((row) => meteredFeatureRow(row, options));
1510
+ }
1511
+ function meteredFeatureRow(row, options) {
1512
+ const { locale } = options;
1513
+ const unit = {
1514
+ name: row.featureName,
1515
+ singularName: row.featureSingularName ?? void 0,
1516
+ pluralName: row.featurePluralName ?? void 0
1517
+ };
1518
+ const limit = usageLimit(row, options);
1519
+ const resetsAt = usableDate(row.resetsAt);
1520
+ return {
1521
+ featureId: row.featureId,
1522
+ name: row.featureName,
1523
+ description: row.featureDescription === "" ? null : row.featureDescription ?? null,
1524
+ icon: row.featureIcon === "" ? null : row.featureIcon ?? null,
1525
+ headline: headline(row, limit, unit, locale),
1526
+ limit: limitLine(row, limit, unit, options),
1527
+ resetsAt: resetsAt === void 0 ? null : formatDate(resetsAt, locale, { month: "short", year: void 0 }),
1528
+ hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
1529
+ amount: row.allocation,
1530
+ units: featureName(unit, row.allocation, locale)
1531
+ } : null,
1532
+ meter: meter(row, options),
1533
+ priceDetails: priceDetails(row, unit, locale),
1534
+ canAddMore: row.priceBehavior === "pay_in_advance",
1535
+ hasUsageByUser: row.featureType === "event",
1536
+ unit,
1537
+ source: row
1538
+ };
1539
+ }
1540
+ function headline(row, limit, unit, locale) {
1541
+ if (row.priceBehavior === "pay_in_advance") {
1542
+ return {
1543
+ kind: "quantity",
1544
+ amount: limit === null ? null : formatNumber(limit, locale),
1545
+ units: featureName(unit, limit ?? 0, locale)
1546
+ };
1547
+ }
1548
+ if (typeof row.usage !== "number") {
1549
+ return null;
1550
+ }
1551
+ return {
1552
+ kind: "used",
1553
+ amount: formatNumber(row.usage, locale),
1554
+ units: featureName(unit, row.usage, locale)
1555
+ };
1556
+ }
1557
+ function limitLine(row, limit, unit, options) {
1558
+ const { locale } = options;
1559
+ switch (row.priceBehavior) {
1560
+ case "tier": {
1561
+ const tier = currentTier(row);
1562
+ if (tier !== null) {
1563
+ return tier.to === null ? { kind: "tierUnlimited", feature: featureName(unit, 0, locale) } : {
1564
+ kind: "tierUpTo",
1565
+ amount: formatNumber(tier.to, locale),
1566
+ feature: featureName(unit, tier.to, locale)
1567
+ };
1568
+ }
1569
+ break;
1570
+ }
1571
+ case "overage":
1572
+ if (limit !== null) {
1573
+ return { kind: "included", amount: formatNumber(limit, locale) };
1574
+ }
1575
+ break;
1576
+ case "pay_in_advance":
1577
+ if (typeof row.usage === "number") {
1578
+ return { kind: "used", amount: formatNumber(row.usage, locale) };
1579
+ }
1580
+ break;
1581
+ case "pay_as_you_go":
1582
+ if (typeof row.currentCost === "number" && row.price !== void 0) {
1583
+ return {
1584
+ kind: "cost",
1585
+ cost: formatCurrency(row.currentCost, row.price.currency, locale)
1586
+ };
1587
+ }
1588
+ break;
1589
+ case "credit_burndown":
1590
+ if (options.showCredits === false || typeof row.consumptionRate !== "number" || row.creditName === void 0 || row.creditName === null) {
1591
+ return null;
1592
+ }
1593
+ return {
1594
+ kind: "perUse",
1595
+ amount: formatConsumptionRate(row.consumptionRate, locale),
1596
+ units: featureName(
1597
+ {
1598
+ name: row.creditName,
1599
+ singularName: row.creditSingularName,
1600
+ pluralName: row.creditPluralName
1601
+ },
1602
+ row.consumptionRate,
1603
+ locale
1604
+ )
1605
+ };
1606
+ default:
1607
+ break;
1608
+ }
1609
+ return limit === null ? { kind: "noLimit" } : { kind: "limitOf", amount: formatNumber(limit, locale) };
1610
+ }
1611
+ function meter(row, options) {
1612
+ if (row.priceBehavior === "pay_as_you_go" || row.priceBehavior === "credit_burndown" || typeof row.usage !== "number") {
1613
+ return null;
1614
+ }
1615
+ const total = options.showWarningThresholdAsLimit === true && typeof row.warningThreshold === "number" ? row.warningThreshold : row.softLimit ?? row.allocation ?? null;
1616
+ if (typeof total !== "number") {
1617
+ return null;
1618
+ }
1619
+ const usage = row.usage;
1620
+ const past = row.priceBehavior === "overage" && usage > total;
1621
+ const ratio = past ? Math.min(usage, total) / Math.max(usage, total) : total === 0 ? 1 : usage / total;
1622
+ const digits = { maximumFractionDigits: 10 };
1623
+ return {
1624
+ value: usage,
1625
+ total,
1626
+ percent: Math.min(ratio * 100, 100),
1627
+ tone: row.priceBehavior === "tier" ? "tier" : past ? "overage" : TONES[Math.floor(
1628
+ (total === 0 ? 1 : Math.min(usage, total) / total) * (TONES.length - 1)
1629
+ )],
1630
+ valueText: formatNumber(usage, options.locale, digits),
1631
+ totalText: formatNumber(total, options.locale, digits)
1632
+ };
1633
+ }
1634
+ function priceDetails(row, unit, locale) {
1635
+ const price = row.price;
1636
+ if (price === void 0) {
1637
+ return null;
1638
+ }
1639
+ const tier = currentTier(row);
1640
+ const period = row.featureType === "trait" ? pricePeriod(price) : null;
1641
+ const money = (amount) => formatCurrency(amount, price.currency, locale);
1642
+ if (row.priceBehavior === "overage") {
1643
+ if (tier === null || tier.perUnitPrice === null) {
1644
+ return null;
1645
+ }
1646
+ const size = price.packageSize;
1647
+ const over = typeof row.usage === "number" && typeof row.softLimit === "number" ? Math.max(0, row.usage - row.softLimit) : 0;
1648
+ return {
1649
+ kind: "overage",
1650
+ unitPrice: money(tier.perUnitPrice),
1651
+ packageSize: size,
1652
+ units: featureName(unit, size, locale),
1653
+ period,
1654
+ overage: {
1655
+ amount: formatNumber(over, locale),
1656
+ units: featureName(unit, over, locale),
1657
+ cost: money(tier.perUnitPrice * over)
1658
+ }
1659
+ };
1660
+ }
1661
+ if (row.priceBehavior === "tier") {
1662
+ if (tier === null || tier.perUnitPrice === null) {
1663
+ return null;
1664
+ }
1665
+ return {
1666
+ kind: "tier",
1667
+ from: tier.from === 0 ? 1 : tier.from,
1668
+ to: tier.to,
1669
+ cost: typeof row.currentCost === "number" ? money(row.currentCost) : null,
1670
+ period,
1671
+ tiers: {
1672
+ ranges: tierRanges(price),
1673
+ currency: price.currency,
1674
+ mode: price.tiersMode ?? null
1675
+ }
1676
+ };
1677
+ }
1678
+ return null;
1679
+ }
1680
+
1495
1681
  // src/elements/strings.ts
1496
1682
  var DEFAULT_STRINGS_LOCALE = "en";
1497
1683
  var DEFAULT_STRINGS = {
@@ -1567,6 +1753,32 @@ var DEFAULT_STRINGS = {
1567
1753
  includedFeaturesHideAll: "Hide all",
1568
1754
  includedFeaturesExpires: "Expires {{date}}",
1569
1755
  includedFeaturesPerLicense: "Includes {{amount}} {{creditName}} per {{licenseName}}",
1756
+ meteredFeaturesLoading: "Loading usage",
1757
+ meteredFeaturesHeader: "Usage",
1758
+ meteredFeaturesError: "There was a problem retrieving your usage.",
1759
+ meteredFeaturesUnavailable: "Usage is not available for this account.",
1760
+ meteredFeaturesUsed: "{{amount}} {{units}} used",
1761
+ meteredFeaturesIncluded: "{{amount}} included",
1762
+ meteredFeaturesInUse: "{{amount}} used",
1763
+ meteredFeaturesLimitOf: "Limit of {{amount}}",
1764
+ meteredFeaturesNoLimit: "No limit",
1765
+ meteredFeaturesAddMore: "Add More",
1766
+ meteredFeaturesAdditional: "Additional",
1767
+ meteredFeaturesTier: "Tier",
1768
+ usageByUserHeader: "Usage by user",
1769
+ usageByUserTotal: "{{amount}} used by your team this period",
1770
+ usageByUserError: "There was a problem retrieving usage by user.",
1771
+ usageByUserUnattributed: "Unattributed",
1772
+ // Looked up by the bare key with `{ count }`; `shown` is the count formatted.
1773
+ usageByUserMore: "plus {{shown}} more",
1774
+ usageByUserShowTop: "Show top {{shown}} users",
1775
+ usageByUserShowTop_one: "Show top {{shown}} user",
1776
+ usageByUserShowTop_other: "Show top {{shown}} users",
1777
+ usageByUserShowAllCount: "Show all {{shown}} users",
1778
+ usageByUserShowAllCount_one: "Show all {{shown}} user",
1779
+ usageByUserShowAllCount_other: "Show all {{shown}} users",
1780
+ usageByUserShowAll: "Show all",
1781
+ usageByUserShowFewer: "Show fewer",
1570
1782
  // Shared by the usage elements.
1571
1783
  usageUnits: "{{amount}} {{units}}",
1572
1784
  usagePerUnit: "{{cost}} per {{unit}}",
@@ -2305,6 +2517,238 @@ var invoicesCss = `
2305
2517
  }
2306
2518
  `;
2307
2519
 
2520
+ // src/elements/styles/metered-features.ts
2521
+ var meteredFeaturesCss = `
2522
+ .schematic-metered-features__list {
2523
+ display: flex;
2524
+ flex-direction: column;
2525
+ gap: var(--schematic-space);
2526
+ list-style: none;
2527
+ margin: 0;
2528
+ padding: 0;
2529
+ }
2530
+
2531
+ /* Each feature is a card; while pending or failed, the root is the card. */
2532
+ .schematic-metered-features[data-state="pending"],
2533
+ .schematic-metered-features[data-state="error"] {
2534
+ background: var(--schematic-background);
2535
+ border-radius: var(--schematic-radius);
2536
+ box-shadow: var(--schematic-shadow);
2537
+ padding: calc(var(--schematic-card-padding) * 0.75)
2538
+ var(--schematic-card-padding);
2539
+ }
2540
+
2541
+ .schematic-metered-features__feature {
2542
+ container-type: inline-size;
2543
+ display: flex;
2544
+ flex-direction: column;
2545
+ gap: calc(var(--schematic-space) * 1.5);
2546
+ overflow: hidden;
2547
+ }
2548
+
2549
+ .schematic-metered-features__main {
2550
+ display: flex;
2551
+ gap: calc(var(--schematic-space) * 1.5);
2552
+ }
2553
+
2554
+ /* Kept without a glyph, as in the embed, so names line up. */
2555
+ .schematic-metered-features__icon {
2556
+ align-items: center;
2557
+ background: var(--schematic-surface);
2558
+ border-radius: 9999px;
2559
+ color: var(--schematic-accent);
2560
+ display: inline-flex;
2561
+ flex-shrink: 0;
2562
+ font-size: 1.5rem;
2563
+ height: 2.75rem;
2564
+ justify-content: center;
2565
+ width: 2.75rem;
2566
+ }
2567
+
2568
+ /* The glyph takes the base text colour rather than inheriting, so the accent
2569
+ is set on it too. */
2570
+ .schematic-metered-features__icon .schematic-icon {
2571
+ color: var(--schematic-accent);
2572
+ }
2573
+
2574
+ .schematic-metered-features__body {
2575
+ display: flex;
2576
+ flex-direction: column;
2577
+ flex-grow: 1;
2578
+ gap: calc(var(--schematic-space) * 2);
2579
+ min-width: 0;
2580
+ }
2581
+
2582
+ .schematic-metered-features__top {
2583
+ display: flex;
2584
+ flex-wrap: wrap;
2585
+ gap: var(--schematic-space);
2586
+ }
2587
+
2588
+ .schematic-metered-features__title {
2589
+ display: flex;
2590
+ flex: 1 1 min-content;
2591
+ flex-direction: column;
2592
+ gap: 0.5rem;
2593
+ }
2594
+
2595
+ .schematic-metered-features__name {
2596
+ font-family: var(--schematic-font-heading);
2597
+ font-size: 1.8125rem;
2598
+ font-weight: 800;
2599
+ line-height: var(--schematic-line-height-heading);
2600
+ margin: 0;
2601
+ }
2602
+
2603
+ /* Beside the title when both fit, otherwise beneath it as in the embed,
2604
+ rather than wrapping in a narrow column. */
2605
+ .schematic-metered-features__figures {
2606
+ display: flex;
2607
+ flex: 0 0 auto;
2608
+ flex-direction: column;
2609
+ gap: 0.25rem;
2610
+ max-width: 100%;
2611
+ text-align: end;
2612
+ }
2613
+
2614
+ .schematic-metered-features__headline {
2615
+ font-size: 1.0625rem;
2616
+ font-variant-numeric: tabular-nums;
2617
+ font-weight: 500;
2618
+ white-space: nowrap;
2619
+ }
2620
+
2621
+ @container (max-width: 30rem) {
2622
+ .schematic-metered-features__figures {
2623
+ min-width: 0;
2624
+ text-align: start;
2625
+ }
2626
+
2627
+ /* Too narrow to keep "1,300 GB of storage used" on one line. */
2628
+ .schematic-metered-features__headline {
2629
+ white-space: normal;
2630
+ }
2631
+ }
2632
+
2633
+ .schematic-metered-features__limit {
2634
+ font-variant-numeric: tabular-nums;
2635
+ }
2636
+
2637
+ .schematic-metered-features__add-more {
2638
+ align-self: flex-start;
2639
+ white-space: nowrap;
2640
+ }
2641
+
2642
+ /* Negative margins undo the card's padding so the footer bleeds to its edges. */
2643
+ .schematic-metered-features__price-details {
2644
+ align-items: center;
2645
+ background: var(--schematic-surface);
2646
+ display: flex;
2647
+ gap: var(--schematic-space);
2648
+ justify-content: space-between;
2649
+ margin: 0 calc(var(--schematic-card-padding) * -1)
2650
+ calc(var(--schematic-card-padding) * -0.75);
2651
+ padding: calc(var(--schematic-card-padding) * 0.4375)
2652
+ var(--schematic-card-padding);
2653
+ }
2654
+
2655
+ .schematic-metered-features .schematic-skeleton__cell[data-column="name"] {
2656
+ width: 10rem;
2657
+ }
2658
+
2659
+ .schematic-metered-features .schematic-skeleton__cell[data-column="usage"] {
2660
+ width: 6rem;
2661
+ }
2662
+
2663
+ .schematic-metered-features__meter {
2664
+ align-items: center;
2665
+ display: flex;
2666
+ gap: var(--schematic-space);
2667
+ }
2668
+
2669
+ .schematic-metered-features__meter .schematic-meter {
2670
+ flex-grow: 1;
2671
+ min-width: 6rem;
2672
+ }
2673
+
2674
+ .schematic-meter--tier {
2675
+ background: color-mix(in srgb, var(--schematic-accent) 50%, transparent);
2676
+ }
2677
+
2678
+ /* Past the soft limit, the fill is the included share over a warning track. */
2679
+ .schematic-meter--overage {
2680
+ background: var(--schematic-warning);
2681
+ }
2682
+
2683
+ .schematic-metered-features__meter-label {
2684
+ font-size: 0.875rem;
2685
+ font-variant-numeric: tabular-nums;
2686
+ font-weight: 500;
2687
+ white-space: nowrap;
2688
+ }
2689
+
2690
+ .schematic-usage-by-user {
2691
+ align-items: flex-start;
2692
+ display: flex;
2693
+ flex-direction: column;
2694
+ gap: 0.25rem;
2695
+ }
2696
+
2697
+ .schematic-usage-by-user__title {
2698
+ font-family: var(--schematic-font-heading);
2699
+ font-size: 1.125rem;
2700
+ font-weight: 800;
2701
+ }
2702
+
2703
+ .schematic-usage-by-user__list {
2704
+ align-self: stretch;
2705
+ list-style: none;
2706
+ margin: 0.5rem 0 0;
2707
+ padding: 0;
2708
+ }
2709
+
2710
+ .schematic-usage-by-user__user {
2711
+ align-items: center;
2712
+ display: flex;
2713
+ gap: 0.75rem;
2714
+ padding: 0.5rem 0;
2715
+ }
2716
+
2717
+ .schematic-usage-by-user__avatar {
2718
+ align-items: center;
2719
+ background: var(--schematic-surface);
2720
+ border-radius: 9999px;
2721
+ display: inline-flex;
2722
+ flex-shrink: 0;
2723
+ font-size: 0.6875rem;
2724
+ font-weight: 500;
2725
+ height: 1.75rem;
2726
+ justify-content: center;
2727
+ width: 1.75rem;
2728
+ }
2729
+
2730
+ .schematic-usage-by-user__name {
2731
+ flex-grow: 1;
2732
+ overflow: hidden;
2733
+ text-overflow: ellipsis;
2734
+ white-space: nowrap;
2735
+ }
2736
+
2737
+ .schematic-usage-by-user__amount {
2738
+ text-align: end;
2739
+ }
2740
+
2741
+ .schematic-usage-by-user__toggle {
2742
+ align-items: center;
2743
+ display: inline-flex;
2744
+ gap: 0.25rem;
2745
+ }
2746
+
2747
+ .schematic-usage-by-user__toggle .schematic-chevron {
2748
+ margin-inline-start: -0.333rem;
2749
+ }
2750
+ `;
2751
+
2308
2752
  // src/elements/styles/payment-methods.ts
2309
2753
  var paymentMethodsCss = `
2310
2754
  .schematic-payment-methods {
@@ -3272,13 +3716,14 @@ ${upcomingBillCss}
3272
3716
  ${paymentMethodsCss}
3273
3717
  ${tooltipCss}
3274
3718
  ${includedFeaturesCss}
3719
+ ${meteredFeaturesCss}
3275
3720
  `;
3276
3721
  var schematicStylesCss = withTokenDefaults(rulesCss) + iconsCss;
3277
3722
  var SchematicStyles = () => /* @__PURE__ */ jsx("style", { "data-schematic-styles": "", children: schematicStylesCss });
3278
3723
 
3279
3724
  // src/elements/IncludedFeatures.tsx
3280
3725
  import { useFeatureUsage } from "@schematichq/schematic-react";
3281
- import { useMemo, useState } from "react";
3726
+ import { useMemo as useMemo2, useState as useState2 } from "react";
3282
3727
 
3283
3728
  // src/elements/common.tsx
3284
3729
  import {
@@ -3469,7 +3914,10 @@ var Dialog = ({ children, className, closeLabel, onClose, open, title, titleId }
3469
3914
  };
3470
3915
 
3471
3916
  // src/elements/usage.tsx
3917
+ import { useMemo, useState } from "react";
3472
3918
  import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
3919
+ var COLLAPSED_USER_COUNT = 3;
3920
+ var EXPANDED_USER_COUNT = 20;
3473
3921
  function shortPeriod(period, t) {
3474
3922
  switch (period) {
3475
3923
  case "month":
@@ -3531,6 +3979,106 @@ function PriceTiers({
3531
3979
  mode !== null && /* @__PURE__ */ jsx3("span", { className: "schematic-tiers__mode", children: mode === "volume" ? t("usageTiersVolume") : t("usageTiersGraduated") })
3532
3980
  ] });
3533
3981
  }
3982
+ function UserBreakdown({
3983
+ breakdown,
3984
+ error,
3985
+ locale,
3986
+ onRetry,
3987
+ t,
3988
+ unit
3989
+ }) {
3990
+ const [expanded, setExpanded] = useState(false);
3991
+ const users = useMemo(
3992
+ () => [...breakdown?.users ?? []].sort((a, b) => b.amount - a.amount),
3993
+ [breakdown?.users]
3994
+ );
3995
+ const amount = (value) => `${formatNumber(value, locale)} ${featureName(unit, value, locale)}`;
3996
+ if (breakdown === void 0 && error !== void 0) {
3997
+ return /* @__PURE__ */ jsxs2("div", { className: "schematic-usage-by-user", role: "alert", children: [
3998
+ /* @__PURE__ */ jsx3("span", { className: "schematic-usage-by-user__title", children: t("usageByUserHeader") }),
3999
+ /* @__PURE__ */ jsx3("span", { className: "schematic-error", children: t("usageByUserError") }),
4000
+ /* @__PURE__ */ jsx3(
4001
+ "button",
4002
+ {
4003
+ className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-status__retry",
4004
+ type: "button",
4005
+ onClick: onRetry,
4006
+ children: t("retry")
4007
+ }
4008
+ )
4009
+ ] });
4010
+ }
4011
+ const unattributed = breakdown?.unattributed ?? null;
4012
+ if (breakdown === void 0 || users.length === 0 && unattributed === null) {
4013
+ return null;
4014
+ }
4015
+ const visible = users.slice(
4016
+ 0,
4017
+ expanded ? EXPANDED_USER_COUNT : COLLAPSED_USER_COUNT
4018
+ );
4019
+ const remaining = Math.max(breakdown.count - visible.length, 0);
4020
+ const hidden = Math.max(
4021
+ Math.min(breakdown.count, EXPANDED_USER_COUNT) - Math.min(users.length, COLLAPSED_USER_COUNT),
4022
+ 0
4023
+ );
4024
+ const expandLabel = breakdown.count > EXPANDED_USER_COUNT ? t("usageByUserShowTop", {
4025
+ count: EXPANDED_USER_COUNT,
4026
+ shown: formatNumber(EXPANDED_USER_COUNT, locale)
4027
+ }) : hidden > 0 ? t("usageByUserShowAllCount", {
4028
+ count: breakdown.count,
4029
+ shown: formatNumber(breakdown.count, locale)
4030
+ }) : t("usageByUserShowAll");
4031
+ const user = (key, label, value, muted = false) => /* @__PURE__ */ jsxs2("li", { className: "schematic-usage-by-user__user", children: [
4032
+ /* @__PURE__ */ jsx3("span", { "aria-hidden": "true", className: "schematic-usage-by-user__avatar", children: muted ? "?" : (label.trim()[0] ?? "?").toUpperCase() }),
4033
+ /* @__PURE__ */ jsx3(
4034
+ "span",
4035
+ {
4036
+ className: cx(
4037
+ "schematic-usage-by-user__name",
4038
+ muted && "schematic-muted"
4039
+ ),
4040
+ children: label
4041
+ }
4042
+ ),
4043
+ /* @__PURE__ */ jsx3("span", { className: "schematic-muted schematic-usage-by-user__amount", children: amount(value) })
4044
+ ] }, key);
4045
+ return /* @__PURE__ */ jsxs2("div", { className: "schematic-usage-by-user", children: [
4046
+ /* @__PURE__ */ jsx3("span", { className: "schematic-usage-by-user__title", children: t("usageByUserHeader") }),
4047
+ /* @__PURE__ */ jsx3("span", { className: "schematic-muted", children: t("usageByUserTotal", { amount: amount(breakdown.total) }) }),
4048
+ /* @__PURE__ */ jsxs2("ul", { className: "schematic-usage-by-user__list", children: [
4049
+ visible.map((entry) => user(entry.id, entry.label, entry.amount)),
4050
+ expanded && unattributed !== null && user(
4051
+ "unattributed",
4052
+ t("usageByUserUnattributed"),
4053
+ unattributed,
4054
+ true
4055
+ )
4056
+ ] }),
4057
+ expanded && remaining > 0 && /* @__PURE__ */ jsx3("span", { className: "schematic-muted", children: t("usageByUserMore", {
4058
+ count: remaining,
4059
+ shown: formatNumber(remaining, locale)
4060
+ }) }),
4061
+ (hidden > 0 || unattributed !== null) && /* @__PURE__ */ jsxs2(
4062
+ "button",
4063
+ {
4064
+ "aria-expanded": expanded,
4065
+ className: "schematic-link-button schematic-usage-by-user__toggle",
4066
+ type: "button",
4067
+ onClick: () => setExpanded((value) => !value),
4068
+ children: [
4069
+ /* @__PURE__ */ jsx3(
4070
+ "i",
4071
+ {
4072
+ "aria-hidden": "true",
4073
+ className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
4074
+ }
4075
+ ),
4076
+ /* @__PURE__ */ jsx3("span", { className: "schematic-link-button__label", children: expanded ? t("usageByUserShowFewer") : expandLabel })
4077
+ ]
4078
+ }
4079
+ )
4080
+ ] });
4081
+ }
3534
4082
 
3535
4083
  // src/elements/IncludedFeatures.tsx
3536
4084
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
@@ -3554,8 +4102,8 @@ function IncludedFeatures({
3554
4102
  const { data: features, error, isPending, refetch } = useFeatureUsage();
3555
4103
  const locale = useResolvedLocale(localeProp);
3556
4104
  const t = useTranslator(strings, localeProp);
3557
- const [expanded, setExpanded] = useState(false);
3558
- const rows = useMemo(
4105
+ const [expanded, setExpanded] = useState2(false);
4106
+ const rows = useMemo2(
3559
4107
  () => features === void 0 ? [] : deriveIncludedFeatures(features, {
3560
4108
  locale,
3561
4109
  showCredits,
@@ -3766,7 +4314,7 @@ IncludedFeatures.resources = ["featureUsage"];
3766
4314
 
3767
4315
  // src/elements/Invoices.tsx
3768
4316
  import { useInvoices } from "@schematichq/schematic-react";
3769
- import { useId as useId2, useMemo as useMemo2, useState as useState2 } from "react";
4317
+ import { useId as useId2, useMemo as useMemo3, useState as useState3 } from "react";
3770
4318
  import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
3771
4319
  var SKELETON_ROWS = 4;
3772
4320
  function Invoices({
@@ -3790,8 +4338,8 @@ function Invoices({
3790
4338
  } = useInvoices(query);
3791
4339
  const locale = useResolvedLocale(localeProp);
3792
4340
  const t = useTranslator(strings, localeProp);
3793
- const [expanded, setExpanded] = useState2(false);
3794
- const list = useMemo2(
4341
+ const [expanded, setExpanded] = useState3(false);
4342
+ const list = useMemo3(
3795
4343
  () => page === void 0 ? void 0 : deriveInvoiceList(page, { locale }),
3796
4344
  [locale, page]
3797
4345
  );
@@ -3936,10 +4484,356 @@ function InvoiceDate({ row, t }) {
3936
4484
  }
3937
4485
  Invoices.resources = ["invoices"];
3938
4486
 
4487
+ // src/elements/MeteredFeatures.tsx
4488
+ import {
4489
+ useFeatureUsage as useFeatureUsage2,
4490
+ useFeatureUserUsage
4491
+ } from "@schematichq/schematic-react";
4492
+ import { useMemo as useMemo4 } from "react";
4493
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
4494
+ function MeteredFeatures({
4495
+ addMoreTarget,
4496
+ addMoreUrl,
4497
+ className,
4498
+ headingLevel = 2,
4499
+ locale: localeProp,
4500
+ onAddMore,
4501
+ showAllocation = true,
4502
+ showCredits = true,
4503
+ showDescription = true,
4504
+ showHardLimit = false,
4505
+ showHeader = false,
4506
+ showIcon = true,
4507
+ showMeter = true,
4508
+ showUsage = true,
4509
+ showUsageByUser = true,
4510
+ showWarningThresholdAsLimit = false,
4511
+ strings,
4512
+ visibleFeatures
4513
+ }) {
4514
+ const { data: features, error, isPending, refetch } = useFeatureUsage2();
4515
+ const locale = useResolvedLocale(localeProp);
4516
+ const t = useTranslator(strings, localeProp);
4517
+ const rows = useMemo4(
4518
+ () => features === void 0 ? [] : deriveMeteredFeatures(features, {
4519
+ locale,
4520
+ showCredits,
4521
+ showWarningThresholdAsLimit,
4522
+ visibleFeatures
4523
+ }),
4524
+ [
4525
+ features,
4526
+ locale,
4527
+ showCredits,
4528
+ showWarningThresholdAsLimit,
4529
+ visibleFeatures
4530
+ ]
4531
+ );
4532
+ const unavailable = features === void 0 && httpStatus(error) === 404;
4533
+ const errorMessage = error === void 0 ? void 0 : unavailable ? t("meteredFeaturesUnavailable") : t("meteredFeaturesError");
4534
+ if (features !== void 0 && error === void 0 && rows.length === 0) {
4535
+ return null;
4536
+ }
4537
+ const Heading = `h${headingLevel}`;
4538
+ const NameHeading = showHeader ? `h${Math.min(6, headingLevel + 1)}` : Heading;
4539
+ return /* @__PURE__ */ jsxs5(
4540
+ StatusFrame,
4541
+ {
4542
+ className: cx("schematic-metered-features", className),
4543
+ error,
4544
+ errorMessage,
4545
+ hasData: features !== void 0,
4546
+ isPending,
4547
+ loadingLabel: t("meteredFeaturesLoading"),
4548
+ onRetry: refetch,
4549
+ retryText: t("retry"),
4550
+ skeleton: /* @__PURE__ */ jsx6(MeteredFeaturesSkeleton, { showHeader }),
4551
+ children: [
4552
+ showHeader && /* @__PURE__ */ jsx6("div", { className: "schematic-header", children: /* @__PURE__ */ jsx6(Heading, { className: "schematic-header__title", children: t("meteredFeaturesHeader") }) }),
4553
+ /* @__PURE__ */ jsx6("ul", { className: "schematic-metered-features__list", children: rows.map((row) => /* @__PURE__ */ jsxs5(
4554
+ "li",
4555
+ {
4556
+ className: "schematic-card schematic-metered-features__feature",
4557
+ "data-testid": "schematic-metered-feature",
4558
+ children: [
4559
+ /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__main", children: [
4560
+ showIcon && /* @__PURE__ */ jsx6("span", { className: "schematic-metered-features__icon", children: row.icon !== null && /* @__PURE__ */ jsx6(
4561
+ "i",
4562
+ {
4563
+ "aria-hidden": "true",
4564
+ className: `schematic-icon schematic-icon--${row.icon}`
4565
+ }
4566
+ ) }),
4567
+ /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__body", children: [
4568
+ /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__top", children: [
4569
+ /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__title", children: [
4570
+ /* @__PURE__ */ jsx6(NameHeading, { className: "schematic-metered-features__name", children: row.name }),
4571
+ showDescription && row.description !== null && /* @__PURE__ */ jsx6("p", { className: "schematic-muted", children: row.description })
4572
+ ] }),
4573
+ /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__figures", children: [
4574
+ showUsage && row.headline !== null && /* @__PURE__ */ jsx6("span", { className: "schematic-metered-features__headline", children: headlineText(row.headline, t) }),
4575
+ showAllocation && /* @__PURE__ */ jsx6(
4576
+ LimitLine,
4577
+ {
4578
+ row,
4579
+ showHardLimit,
4580
+ t
4581
+ }
4582
+ )
4583
+ ] })
4584
+ ] }),
4585
+ showMeter && row.meter !== null && /* @__PURE__ */ jsx6(Meter, { meter: row.meter }),
4586
+ row.canAddMore && /* @__PURE__ */ jsx6(
4587
+ AddMore,
4588
+ {
4589
+ label: t("meteredFeaturesAddMore"),
4590
+ onAddMore: onAddMore === void 0 ? void 0 : () => onAddMore(row.source),
4591
+ target: addMoreTarget,
4592
+ url: addMoreUrl
4593
+ }
4594
+ )
4595
+ ] })
4596
+ ] }),
4597
+ showUsageByUser && row.hasUsageByUser && /* @__PURE__ */ jsx6(UsageByUser, { locale, row, t }),
4598
+ row.priceDetails !== null && /* @__PURE__ */ jsx6(
4599
+ PriceDetails,
4600
+ {
4601
+ details: row.priceDetails,
4602
+ locale,
4603
+ row,
4604
+ t
4605
+ }
4606
+ )
4607
+ ]
4608
+ },
4609
+ row.featureId
4610
+ )) })
4611
+ ]
4612
+ }
4613
+ );
4614
+ }
4615
+ function headlineText(headline2, t) {
4616
+ if (headline2.kind === "used") {
4617
+ return t("meteredFeaturesUsed", {
4618
+ amount: headline2.amount,
4619
+ units: headline2.units
4620
+ });
4621
+ }
4622
+ return headline2.amount === null ? headline2.units : t("usageUnits", { amount: headline2.amount, units: headline2.units });
4623
+ }
4624
+ function limitText(limit, t) {
4625
+ switch (limit.kind) {
4626
+ case "tierUpTo":
4627
+ return t("usageTierUpTo", {
4628
+ amount: limit.amount,
4629
+ feature: limit.feature
4630
+ });
4631
+ case "tierUnlimited":
4632
+ return t("usageTierUnlimited", { feature: limit.feature });
4633
+ case "included":
4634
+ return t("meteredFeaturesIncluded", { amount: limit.amount });
4635
+ case "used":
4636
+ return t("meteredFeaturesInUse", { amount: limit.amount });
4637
+ case "cost":
4638
+ return limit.cost;
4639
+ case "perUse":
4640
+ return t("usagePerUse", { amount: limit.amount, units: limit.units });
4641
+ case "limitOf":
4642
+ return t("meteredFeaturesLimitOf", { amount: limit.amount });
4643
+ case "noLimit":
4644
+ return t("meteredFeaturesNoLimit");
4645
+ }
4646
+ }
4647
+ function LimitLine({
4648
+ row,
4649
+ showHardLimit,
4650
+ t
4651
+ }) {
4652
+ const parts = [];
4653
+ if (row.limit !== null) {
4654
+ parts.push(limitText(row.limit, t));
4655
+ }
4656
+ if (row.resetsAt !== null) {
4657
+ parts.push(t("usageResets", { date: row.resetsAt }));
4658
+ }
4659
+ if (parts.length === 0) {
4660
+ return null;
4661
+ }
4662
+ return /* @__PURE__ */ jsxs5("span", { className: "schematic-muted schematic-metered-features__limit", children: [
4663
+ parts.join(" \u2022 "),
4664
+ showHardLimit && row.hardLimit !== null && /* @__PURE__ */ jsx6(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
4665
+ amount: row.hardLimit.amount,
4666
+ units: row.hardLimit.units
4667
+ }) })
4668
+ ] });
4669
+ }
4670
+ var METER_TONE_CLASS = {
4671
+ ok: void 0,
4672
+ warning: "schematic-meter--warning",
4673
+ critical: "schematic-meter--over",
4674
+ tier: "schematic-meter--tier",
4675
+ overage: "schematic-meter--overage"
4676
+ };
4677
+ function Meter({ meter: meter2 }) {
4678
+ return /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__meter", children: [
4679
+ /* @__PURE__ */ jsx6(
4680
+ "div",
4681
+ {
4682
+ "aria-valuemax": meter2.total,
4683
+ "aria-valuemin": 0,
4684
+ "aria-valuenow": meter2.value,
4685
+ className: cx("schematic-meter", METER_TONE_CLASS[meter2.tone]),
4686
+ "data-tone": meter2.tone,
4687
+ role: "meter",
4688
+ children: /* @__PURE__ */ jsx6(
4689
+ "div",
4690
+ {
4691
+ className: "schematic-meter__fill",
4692
+ style: { width: `${meter2.percent}%` }
4693
+ }
4694
+ )
4695
+ }
4696
+ ),
4697
+ meter2.total > 0 && /* @__PURE__ */ jsxs5("span", { className: "schematic-metered-features__meter-label", children: [
4698
+ meter2.valueText,
4699
+ "/",
4700
+ meter2.totalText
4701
+ ] })
4702
+ ] });
4703
+ }
4704
+ function AddMore({
4705
+ label,
4706
+ onAddMore,
4707
+ target,
4708
+ url
4709
+ }) {
4710
+ if (onAddMore !== void 0) {
4711
+ return /* @__PURE__ */ jsx6(
4712
+ "button",
4713
+ {
4714
+ className: "schematic-cta schematic-metered-features__add-more",
4715
+ type: "button",
4716
+ onClick: onAddMore,
4717
+ children: label
4718
+ }
4719
+ );
4720
+ }
4721
+ if (url !== void 0) {
4722
+ return /* @__PURE__ */ jsx6(
4723
+ "a",
4724
+ {
4725
+ className: "schematic-cta schematic-metered-features__add-more",
4726
+ href: url,
4727
+ target,
4728
+ children: label
4729
+ }
4730
+ );
4731
+ }
4732
+ return null;
4733
+ }
4734
+ function PriceDetails({
4735
+ details,
4736
+ locale,
4737
+ row,
4738
+ t
4739
+ }) {
4740
+ const period = details.period === null ? void 0 : shortPeriod(details.period, t);
4741
+ if (details.kind === "overage") {
4742
+ return /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__price-details", children: [
4743
+ /* @__PURE__ */ jsxs5("span", { children: [
4744
+ t("meteredFeaturesAdditional"),
4745
+ ": ",
4746
+ details.unitPrice,
4747
+ /* @__PURE__ */ jsxs5("sub", { children: [
4748
+ "/",
4749
+ details.packageSize > 1 && `${details.packageSize} `,
4750
+ details.units,
4751
+ period !== void 0 && `/${period}`
4752
+ ] })
4753
+ ] }),
4754
+ /* @__PURE__ */ jsxs5("span", { children: [
4755
+ details.overage.amount,
4756
+ " ",
4757
+ details.overage.units,
4758
+ " \xB7 ",
4759
+ details.overage.cost,
4760
+ period !== void 0 && /* @__PURE__ */ jsxs5("sub", { children: [
4761
+ "/",
4762
+ period
4763
+ ] })
4764
+ ] })
4765
+ ] });
4766
+ }
4767
+ return /* @__PURE__ */ jsxs5("div", { className: "schematic-metered-features__price-details", children: [
4768
+ /* @__PURE__ */ jsxs5("span", { children: [
4769
+ t("meteredFeaturesTier"),
4770
+ ": ",
4771
+ details.from,
4772
+ details.to === null ? "+" : details.to !== details.from ? `\u2013${details.to}` : "",
4773
+ /* @__PURE__ */ jsx6(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ jsx6(
4774
+ PriceTiers,
4775
+ {
4776
+ currency: details.tiers.currency,
4777
+ locale,
4778
+ mode: details.tiers.mode,
4779
+ period: details.period,
4780
+ ranges: details.tiers.ranges,
4781
+ t,
4782
+ unit: featureName(row.unit, 1, locale)
4783
+ }
4784
+ ) })
4785
+ ] }),
4786
+ details.cost !== null && /* @__PURE__ */ jsxs5("span", { children: [
4787
+ details.cost,
4788
+ period !== void 0 && /* @__PURE__ */ jsxs5("sub", { children: [
4789
+ "/",
4790
+ period
4791
+ ] })
4792
+ ] })
4793
+ ] });
4794
+ }
4795
+ function UsageByUser({
4796
+ locale,
4797
+ row,
4798
+ t
4799
+ }) {
4800
+ const { data, error, refetch } = useFeatureUserUsage(row.featureId);
4801
+ return /* @__PURE__ */ jsx6(
4802
+ UserBreakdown,
4803
+ {
4804
+ breakdown: data === void 0 ? void 0 : {
4805
+ count: data.count,
4806
+ total: data.total,
4807
+ unattributed: data.unattributed ?? null,
4808
+ users: data.users.map((user) => ({
4809
+ amount: user.usage,
4810
+ id: user.userId,
4811
+ label: user.name ?? user.userId
4812
+ }))
4813
+ },
4814
+ error,
4815
+ locale,
4816
+ onRetry: refetch,
4817
+ t,
4818
+ unit: row.unit
4819
+ }
4820
+ );
4821
+ }
4822
+ function MeteredFeaturesSkeleton({ showHeader }) {
4823
+ return /* @__PURE__ */ jsxs5("div", { className: "schematic-skeleton", children: [
4824
+ showHeader && /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton__heading" }),
4825
+ [0, 1].map((index) => /* @__PURE__ */ jsxs5("div", { className: "schematic-skeleton__row", children: [
4826
+ /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
4827
+ /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
4828
+ ] }, index))
4829
+ ] });
4830
+ }
4831
+ MeteredFeatures.resources = ["featureUsage"];
4832
+
3939
4833
  // src/elements/PaymentMethods.tsx
3940
4834
  import { usePaymentMethods } from "@schematichq/schematic-react";
3941
- import { Suspense, lazy, useCallback as useCallback2, useMemo as useMemo3, useState as useState4 } from "react";
3942
- import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
4835
+ import { Suspense, lazy, useCallback as useCallback2, useMemo as useMemo5, useState as useState5 } from "react";
4836
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3943
4837
  var PaymentMethodForm2 = lazy(() => Promise.resolve().then(() => (init_PaymentMethodForm(), PaymentMethodForm_exports)));
3944
4838
  function PaymentMethods({
3945
4839
  allowEdit = true,
@@ -3964,10 +4858,10 @@ function PaymentMethods({
3964
4858
  } = usePaymentMethods();
3965
4859
  const locale = useResolvedLocale(localeProp);
3966
4860
  const t = useTranslator(strings, localeProp);
3967
- const [dialog, setDialog] = useState4(null);
3968
- const [choosing, setChoosing] = useState4(false);
3969
- const [lastWrite, setLastWrite] = useState4(null);
3970
- const derived = useMemo3(
4861
+ const [dialog, setDialog] = useState5(null);
4862
+ const [choosing, setChoosing] = useState5(false);
4863
+ const [lastWrite, setLastWrite] = useState5(null);
4864
+ const derived = useMemo5(
3971
4865
  () => methods === void 0 ? void 0 : derivePaymentMethods(methods, { locale }),
3972
4866
  [locale, methods]
3973
4867
  );
@@ -3998,7 +4892,7 @@ function PaymentMethods({
3998
4892
  const Heading = `h${headingLevel}`;
3999
4893
  const unavailable = derived === void 0 && httpStatus(error) === 404;
4000
4894
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("paymentMethodsUnavailable") : t("paymentMethodsError");
4001
- return /* @__PURE__ */ jsx7(
4895
+ return /* @__PURE__ */ jsx8(
4002
4896
  StatusFrame,
4003
4897
  {
4004
4898
  className: cx("schematic-card", "schematic-payment-methods", className),
@@ -4009,9 +4903,9 @@ function PaymentMethods({
4009
4903
  loadingLabel: t("paymentMethodsLoading"),
4010
4904
  onRetry: refetch,
4011
4905
  retryText: t("retry"),
4012
- skeleton: /* @__PURE__ */ jsx7(PaymentMethodsSkeleton, { showHeader }),
4013
- children: derived !== void 0 && /* @__PURE__ */ jsxs6(Fragment3, { children: [
4014
- showHeader && /* @__PURE__ */ jsx7(
4906
+ skeleton: /* @__PURE__ */ jsx8(PaymentMethodsSkeleton, { showHeader }),
4907
+ children: derived !== void 0 && /* @__PURE__ */ jsxs7(Fragment3, { children: [
4908
+ showHeader && /* @__PURE__ */ jsx8(
4015
4909
  PaymentMethodsHeader,
4016
4910
  {
4017
4911
  derived,
@@ -4020,7 +4914,7 @@ function PaymentMethods({
4020
4914
  t
4021
4915
  }
4022
4916
  ),
4023
- /* @__PURE__ */ jsx7(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ jsx7(
4917
+ /* @__PURE__ */ jsx8(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ jsx8(
4024
4918
  "button",
4025
4919
  {
4026
4920
  className: "schematic-link-button schematic-payment-methods__edit",
@@ -4029,7 +4923,7 @@ function PaymentMethods({
4029
4923
  children: derived.current === null ? t("paymentMethodsAdd") : t("paymentMethodsEdit")
4030
4924
  }
4031
4925
  ) }),
4032
- dialog !== null && /* @__PURE__ */ jsx7(
4926
+ dialog !== null && /* @__PURE__ */ jsx8(
4033
4927
  PaymentMethodsDialog,
4034
4928
  {
4035
4929
  checkoutPrefill,
@@ -4081,7 +4975,7 @@ function PaymentMethodsDialog({
4081
4975
  const { current, others, rows } = derived;
4082
4976
  const hasMethods = rows.length > 0;
4083
4977
  const showForm = view === "add" || !hasMethods;
4084
- return /* @__PURE__ */ jsxs6(
4978
+ return /* @__PURE__ */ jsxs7(
4085
4979
  Dialog,
4086
4980
  {
4087
4981
  className: "schematic-payment-methods__dialog",
@@ -4090,11 +4984,11 @@ function PaymentMethodsDialog({
4090
4984
  title: t("paymentMethodsDialogTitle"),
4091
4985
  onClose,
4092
4986
  children: [
4093
- showForm ? /* @__PURE__ */ jsx7(
4987
+ showForm ? /* @__PURE__ */ jsx8(
4094
4988
  Suspense,
4095
4989
  {
4096
- fallback: /* @__PURE__ */ jsx7(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
4097
- children: /* @__PURE__ */ jsx7(
4990
+ fallback: /* @__PURE__ */ jsx8(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
4991
+ children: /* @__PURE__ */ jsx8(
4098
4992
  PaymentMethodForm2,
4099
4993
  {
4100
4994
  checkoutPrefill,
@@ -4106,8 +5000,8 @@ function PaymentMethodsDialog({
4106
5000
  }
4107
5001
  )
4108
5002
  }
4109
- ) : /* @__PURE__ */ jsxs6(Fragment3, { children: [
4110
- /* @__PURE__ */ jsx7(
5003
+ ) : /* @__PURE__ */ jsxs7(Fragment3, { children: [
5004
+ /* @__PURE__ */ jsx8(
4111
5005
  PaymentMethodsHeader,
4112
5006
  {
4113
5007
  derived,
@@ -4116,7 +5010,7 @@ function PaymentMethodsDialog({
4116
5010
  t
4117
5011
  }
4118
5012
  ),
4119
- /* @__PURE__ */ jsx7(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ jsx7(
5013
+ /* @__PURE__ */ jsx8(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ jsx8(
4120
5014
  "button",
4121
5015
  {
4122
5016
  className: "schematic-link-button schematic-payment-methods__remove-current",
@@ -4126,7 +5020,7 @@ function PaymentMethodsDialog({
4126
5020
  children: t("paymentMethodsRemove")
4127
5021
  }
4128
5022
  ) }),
4129
- /* @__PURE__ */ jsxs6(
5023
+ /* @__PURE__ */ jsxs7(
4130
5024
  "button",
4131
5025
  {
4132
5026
  "aria-expanded": choosing,
@@ -4134,8 +5028,8 @@ function PaymentMethodsDialog({
4134
5028
  type: "button",
4135
5029
  onClick: onChoose,
4136
5030
  children: [
4137
- /* @__PURE__ */ jsx7("span", { className: "schematic-payment-methods__choose-label", children: t("paymentMethodsChooseDifferent") }),
4138
- /* @__PURE__ */ jsx7(
5031
+ /* @__PURE__ */ jsx8("span", { className: "schematic-payment-methods__choose-label", children: t("paymentMethodsChooseDifferent") }),
5032
+ /* @__PURE__ */ jsx8(
4139
5033
  "i",
4140
5034
  {
4141
5035
  "aria-hidden": "true",
@@ -4150,13 +5044,13 @@ function PaymentMethodsDialog({
4150
5044
  ]
4151
5045
  }
4152
5046
  ),
4153
- choosing && /* @__PURE__ */ jsxs6(Fragment3, { children: [
4154
- others.length > 0 && /* @__PURE__ */ jsx7(
5047
+ choosing && /* @__PURE__ */ jsxs7(Fragment3, { children: [
5048
+ others.length > 0 && /* @__PURE__ */ jsx8(
4155
5049
  "ul",
4156
5050
  {
4157
5051
  "aria-label": t("paymentMethodsChooseDifferent"),
4158
5052
  className: "schematic-payment-methods__list",
4159
- children: others.map((row) => /* @__PURE__ */ jsxs6(
5053
+ children: others.map((row) => /* @__PURE__ */ jsxs7(
4160
5054
  "li",
4161
5055
  {
4162
5056
  className: "schematic-payment-methods__row",
@@ -4164,11 +5058,11 @@ function PaymentMethodsDialog({
4164
5058
  "data-kind": row.kind,
4165
5059
  "data-testid": "schematic-payment-method",
4166
5060
  children: [
4167
- /* @__PURE__ */ jsx7(Method, { row, t }),
4168
- row.expiresShort !== null && /* @__PURE__ */ jsx7("span", { className: "schematic-payment-methods__expires", children: t("paymentMethodsExpires", {
5061
+ /* @__PURE__ */ jsx8(Method, { row, t }),
5062
+ row.expiresShort !== null && /* @__PURE__ */ jsx8("span", { className: "schematic-payment-methods__expires", children: t("paymentMethodsExpires", {
4169
5063
  date: row.expiresShort
4170
5064
  }) }),
4171
- /* @__PURE__ */ jsx7(
5065
+ /* @__PURE__ */ jsx8(
4172
5066
  "button",
4173
5067
  {
4174
5068
  className: "schematic-link-button schematic-payment-methods__set-default",
@@ -4178,7 +5072,7 @@ function PaymentMethodsDialog({
4178
5072
  children: t("paymentMethodsSetDefault")
4179
5073
  }
4180
5074
  ),
4181
- row.canRemove && /* @__PURE__ */ jsx7(
5075
+ row.canRemove && /* @__PURE__ */ jsx8(
4182
5076
  "button",
4183
5077
  {
4184
5078
  "aria-label": t("paymentMethodsRemove"),
@@ -4186,7 +5080,7 @@ function PaymentMethodsDialog({
4186
5080
  disabled: isMutating,
4187
5081
  type: "button",
4188
5082
  onClick: () => onRemove(row),
4189
- children: /* @__PURE__ */ jsx7(
5083
+ children: /* @__PURE__ */ jsx8(
4190
5084
  "i",
4191
5085
  {
4192
5086
  "aria-hidden": "true",
@@ -4201,7 +5095,7 @@ function PaymentMethodsDialog({
4201
5095
  ))
4202
5096
  }
4203
5097
  ),
4204
- /* @__PURE__ */ jsx7(
5098
+ /* @__PURE__ */ jsx8(
4205
5099
  "button",
4206
5100
  {
4207
5101
  className: "schematic-cta schematic-payment-methods__add-new",
@@ -4213,14 +5107,14 @@ function PaymentMethodsDialog({
4213
5107
  )
4214
5108
  ] })
4215
5109
  ] }),
4216
- mutationError !== void 0 && /* @__PURE__ */ jsxs6(
5110
+ mutationError !== void 0 && /* @__PURE__ */ jsxs7(
4217
5111
  "p",
4218
5112
  {
4219
5113
  className: "schematic-status-note schematic-error schematic-payment-methods__error",
4220
5114
  role: "alert",
4221
5115
  children: [
4222
- /* @__PURE__ */ jsx7("span", { className: "schematic-payment-methods__error-message", children: mutationError }),
4223
- onRetry !== void 0 && /* @__PURE__ */ jsx7(
5116
+ /* @__PURE__ */ jsx8("span", { className: "schematic-payment-methods__error-message", children: mutationError }),
5117
+ onRetry !== void 0 && /* @__PURE__ */ jsx8(
4224
5118
  "button",
4225
5119
  {
4226
5120
  className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-payment-methods__error-retry",
@@ -4243,9 +5137,9 @@ function PaymentMethodsHeader({
4243
5137
  showExpiration,
4244
5138
  t
4245
5139
  }) {
4246
- return /* @__PURE__ */ jsxs6("div", { className: "schematic-header", children: [
4247
- /* @__PURE__ */ jsx7(Heading, { className: "schematic-header__title", children: t("paymentMethodsHeader") }),
4248
- showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ jsx7(
5140
+ return /* @__PURE__ */ jsxs7("div", { className: "schematic-header", children: [
5141
+ /* @__PURE__ */ jsx8(Heading, { className: "schematic-header__title", children: t("paymentMethodsHeader") }),
5142
+ showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ jsx8(
4249
5143
  "span",
4250
5144
  {
4251
5145
  className: "schematic-small schematic-payment-methods__expiry-warning",
@@ -4260,37 +5154,37 @@ function MethodPill({
4260
5154
  row,
4261
5155
  t
4262
5156
  }) {
4263
- return /* @__PURE__ */ jsxs6(
5157
+ return /* @__PURE__ */ jsxs7(
4264
5158
  "div",
4265
5159
  {
4266
5160
  className: "schematic-payment-methods__current",
4267
5161
  "data-testid": "schematic-payment-method-current",
4268
5162
  children: [
4269
- row === null ? /* @__PURE__ */ jsx7("span", { className: "schematic-payment-methods__empty", children: t("paymentMethodsEmpty") }) : /* @__PURE__ */ jsx7(Method, { row, t }),
5163
+ row === null ? /* @__PURE__ */ jsx8("span", { className: "schematic-payment-methods__empty", children: t("paymentMethodsEmpty") }) : /* @__PURE__ */ jsx8(Method, { row, t }),
4270
5164
  children
4271
5165
  ]
4272
5166
  }
4273
5167
  );
4274
5168
  }
4275
5169
  function Method({ row, t }) {
4276
- return /* @__PURE__ */ jsxs6(
5170
+ return /* @__PURE__ */ jsxs7(
4277
5171
  "span",
4278
5172
  {
4279
5173
  className: "schematic-payment-methods__method",
4280
5174
  "data-brand": row.brand,
4281
5175
  "data-kind": row.kind,
4282
5176
  children: [
4283
- /* @__PURE__ */ jsx7(
5177
+ /* @__PURE__ */ jsx8(
4284
5178
  "i",
4285
5179
  {
4286
5180
  "aria-hidden": "true",
4287
5181
  className: `schematic-icon schematic-icon--${row.icon} schematic-payment-methods__icon`
4288
5182
  }
4289
5183
  ),
4290
- /* @__PURE__ */ jsx7("span", { className: "schematic-payment-methods__label", children: labelText(row.label, t) }),
4291
- row.last4 !== null && /* @__PURE__ */ jsxs6(Fragment3, { children: [
5184
+ /* @__PURE__ */ jsx8("span", { className: "schematic-payment-methods__label", children: labelText(row.label, t) }),
5185
+ row.last4 !== null && /* @__PURE__ */ jsxs7(Fragment3, { children: [
4292
5186
  " ",
4293
- /* @__PURE__ */ jsx7("span", { className: "schematic-payment-methods__last4", children: row.last4 })
5187
+ /* @__PURE__ */ jsx8("span", { className: "schematic-payment-methods__last4", children: row.last4 })
4294
5188
  ] })
4295
5189
  ]
4296
5190
  }
@@ -4304,24 +5198,24 @@ function expiryWarningText(derived, t) {
4304
5198
  return derived.expiryWarning === "expired" ? t("paymentMethodsExpired") : t("paymentMethodsExpiresInMonths", { months });
4305
5199
  }
4306
5200
  function PaymentMethodsSkeleton({ showHeader }) {
4307
- return /* @__PURE__ */ jsxs6("div", { className: "schematic-skeleton", children: [
4308
- showHeader && /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__heading" }),
4309
- /* @__PURE__ */ jsxs6("div", { className: "schematic-skeleton__row", children: [
4310
- /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__cell", "data-column": "method" }),
4311
- /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__cell", "data-column": "action" })
5201
+ return /* @__PURE__ */ jsxs7("div", { className: "schematic-skeleton", children: [
5202
+ showHeader && /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__heading" }),
5203
+ /* @__PURE__ */ jsxs7("div", { className: "schematic-skeleton__row", children: [
5204
+ /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__cell", "data-column": "method" }),
5205
+ /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__cell", "data-column": "action" })
4312
5206
  ] })
4313
5207
  ] });
4314
5208
  }
4315
5209
  function FormSkeleton({ label }) {
4316
- return /* @__PURE__ */ jsxs6(
5210
+ return /* @__PURE__ */ jsxs7(
4317
5211
  "div",
4318
5212
  {
4319
5213
  "aria-busy": "true",
4320
5214
  className: "schematic-payment-methods__form",
4321
5215
  "data-state": "pending",
4322
5216
  children: [
4323
- /* @__PURE__ */ jsx7("span", { className: "schematic-hidden", children: label }),
4324
- /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton", children: /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
5217
+ /* @__PURE__ */ jsx8("span", { className: "schematic-hidden", children: label }),
5218
+ /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton", children: /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
4325
5219
  ]
4326
5220
  }
4327
5221
  );
@@ -4330,8 +5224,8 @@ PaymentMethods.resources = ["paymentMethods"];
4330
5224
 
4331
5225
  // src/elements/UpcomingBill.tsx
4332
5226
  import { useUpcomingInvoice } from "@schematichq/schematic-react";
4333
- import { useMemo as useMemo4 } from "react";
4334
- import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
5227
+ import { useMemo as useMemo6 } from "react";
5228
+ import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
4335
5229
  function UpcomingBill({
4336
5230
  className,
4337
5231
  headingLevel = 2,
@@ -4345,7 +5239,7 @@ function UpcomingBill({
4345
5239
  const { data: invoice, error, isPending, refetch } = useUpcomingInvoice();
4346
5240
  const locale = useResolvedLocale(localeProp);
4347
5241
  const t = useTranslator(strings, localeProp);
4348
- const bill = useMemo4(
5242
+ const bill = useMemo6(
4349
5243
  () => invoice === void 0 || invoice === null ? null : deriveUpcomingInvoice(invoice, { locale }),
4350
5244
  [invoice, locale]
4351
5245
  );
@@ -4354,7 +5248,7 @@ function UpcomingBill({
4354
5248
  const discountRow = showDiscounts && bill !== null && bill.discounts.length > 0;
4355
5249
  const unavailable = invoice === void 0 && httpStatus(error) === 404;
4356
5250
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("upcomingBillUnavailable") : t("upcomingBillError");
4357
- return /* @__PURE__ */ jsx8(
5251
+ return /* @__PURE__ */ jsx9(
4358
5252
  StatusFrame,
4359
5253
  {
4360
5254
  className: cx("schematic-card", "schematic-upcoming-bill", className),
@@ -4365,11 +5259,11 @@ function UpcomingBill({
4365
5259
  loadingLabel: t("upcomingBillLoading"),
4366
5260
  onRetry: refetch,
4367
5261
  retryText: t("retry"),
4368
- skeleton: /* @__PURE__ */ jsx8(UpcomingBillSkeleton, { showHeader }),
4369
- children: bill === null ? invoice !== void 0 && /* @__PURE__ */ jsx8("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ jsxs7(Fragment4, { children: [
4370
- showHeader && bill.dueAt !== null && /* @__PURE__ */ jsx8("div", { className: "schematic-header", children: /* @__PURE__ */ jsx8(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
4371
- showAmount && /* @__PURE__ */ jsxs7("div", { className: "schematic-upcoming-bill__amount", children: [
4372
- /* @__PURE__ */ jsx8(
5262
+ skeleton: /* @__PURE__ */ jsx9(UpcomingBillSkeleton, { showHeader }),
5263
+ children: bill === null ? invoice !== void 0 && /* @__PURE__ */ jsx9("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ jsxs8(Fragment4, { children: [
5264
+ showHeader && bill.dueAt !== null && /* @__PURE__ */ jsx9("div", { className: "schematic-header", children: /* @__PURE__ */ jsx9(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
5265
+ showAmount && /* @__PURE__ */ jsxs8("div", { className: "schematic-upcoming-bill__amount", children: [
5266
+ /* @__PURE__ */ jsx9(
4373
5267
  "span",
4374
5268
  {
4375
5269
  className: "schematic-upcoming-bill__total",
@@ -4377,46 +5271,46 @@ function UpcomingBill({
4377
5271
  children: bill.amountDueText
4378
5272
  }
4379
5273
  ),
4380
- /* @__PURE__ */ jsx8("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
5274
+ /* @__PURE__ */ jsx9("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
4381
5275
  ] }),
4382
- (balanceRows || discountRow) && /* @__PURE__ */ jsxs7("div", { className: "schematic-upcoming-bill__rows", children: [
4383
- balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ jsxs7(
5276
+ (balanceRows || discountRow) && /* @__PURE__ */ jsxs8("div", { className: "schematic-upcoming-bill__rows", children: [
5277
+ balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ jsxs8(
4384
5278
  "div",
4385
5279
  {
4386
5280
  className: "schematic-row schematic-upcoming-bill__balance-applied",
4387
5281
  "data-testid": "schematic-balance-applied",
4388
5282
  children: [
4389
- /* @__PURE__ */ jsx8("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
4390
- /* @__PURE__ */ jsx8("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
5283
+ /* @__PURE__ */ jsx9("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
5284
+ /* @__PURE__ */ jsx9("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
4391
5285
  ]
4392
5286
  }
4393
5287
  ),
4394
- balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ jsxs7(
5288
+ balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ jsxs8(
4395
5289
  "div",
4396
5290
  {
4397
5291
  className: "schematic-row schematic-upcoming-bill__balance-remaining",
4398
5292
  "data-testid": "schematic-balance-remaining",
4399
5293
  children: [
4400
- /* @__PURE__ */ jsx8("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
4401
- /* @__PURE__ */ jsx8("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
5294
+ /* @__PURE__ */ jsx9("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
5295
+ /* @__PURE__ */ jsx9("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
4402
5296
  ]
4403
5297
  }
4404
5298
  ),
4405
- discountRow && /* @__PURE__ */ jsxs7(
5299
+ discountRow && /* @__PURE__ */ jsxs8(
4406
5300
  "div",
4407
5301
  {
4408
5302
  className: "schematic-row schematic-upcoming-bill__discount-row",
4409
5303
  "data-testid": "schematic-discounts",
4410
5304
  children: [
4411
- /* @__PURE__ */ jsx8("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
4412
- /* @__PURE__ */ jsx8("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ jsxs7(
5305
+ /* @__PURE__ */ jsx9("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
5306
+ /* @__PURE__ */ jsx9("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ jsxs8(
4413
5307
  "li",
4414
5308
  {
4415
5309
  className: "schematic-upcoming-bill__discount",
4416
5310
  "data-testid": "schematic-discount",
4417
5311
  children: [
4418
- discount.code !== null && /* @__PURE__ */ jsx8("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
4419
- /* @__PURE__ */ jsx8("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
5312
+ discount.code !== null && /* @__PURE__ */ jsx9("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
5313
+ /* @__PURE__ */ jsx9("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
4420
5314
  ]
4421
5315
  },
4422
5316
  `${discount.couponName}-${index}`
@@ -4430,10 +5324,10 @@ function UpcomingBill({
4430
5324
  );
4431
5325
  }
4432
5326
  function UpcomingBillSkeleton({ showHeader }) {
4433
- return /* @__PURE__ */ jsxs7("div", { className: "schematic-skeleton", children: [
4434
- showHeader && /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__heading" }),
4435
- /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
4436
- /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
5327
+ return /* @__PURE__ */ jsxs8("div", { className: "schematic-skeleton", children: [
5328
+ showHeader && /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__heading" }),
5329
+ /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
5330
+ /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
4437
5331
  ] });
4438
5332
  }
4439
5333
  function discountText(discount, t) {
@@ -4452,6 +5346,7 @@ export {
4452
5346
  FEATURE_USER_USAGE_LIMIT,
4453
5347
  IncludedFeatures,
4454
5348
  Invoices,
5349
+ MeteredFeatures,
4455
5350
  PaymentMethods,
4456
5351
  SCHEMATIC_TOKENS,
4457
5352
  SchematicI18nProvider,
@@ -4462,6 +5357,7 @@ export {
4462
5357
  currentTier,
4463
5358
  deriveIncludedFeatures,
4464
5359
  deriveInvoiceList,
5360
+ deriveMeteredFeatures,
4465
5361
  derivePaymentMethods,
4466
5362
  deriveUpcomingInvoice,
4467
5363
  featureName,
@@ -4485,8 +5381,8 @@ export {
4485
5381
  tierRanges,
4486
5382
  unitPrice,
4487
5383
  usageLimit,
4488
- useFeatureUsage2 as useFeatureUsage,
4489
- useFeatureUserUsage,
5384
+ useFeatureUsage3 as useFeatureUsage,
5385
+ useFeatureUserUsage2 as useFeatureUserUsage,
4490
5386
  useInvalidateBillingData,
4491
5387
  useInvoices2 as useInvoices,
4492
5388
  usePaymentMethods2 as usePaymentMethods,