@schematichq/schematic-components 2.31.0 → 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.
@@ -67,13 +67,15 @@ var init_tokens = __esm({
67
67
  "hsla(0, 0%, 0%, 0.175)",
68
68
  "hsla(0, 0%, 100%, 0.2)"
69
69
  ),
70
- "--schematic-card-padding": "2.8125rem",
70
+ // 45px from a 750px viewport up; narrower screens give the content the
71
+ // room instead (about 22px on a 375px phone).
72
+ "--schematic-card-padding": "min(2.8125rem, 6vw)",
71
73
  "--schematic-danger": ld("#d75a5c", "#ff6b6e"),
72
74
  "--schematic-font-body": '"Public Sans", system-ui, sans-serif',
73
75
  "--schematic-font-heading": '"Manrope", system-ui, sans-serif',
74
76
  // Link buttons' face: Edit, Set default, Try again, and the rest.
75
77
  "--schematic-font-link": '"Inter", system-ui, sans-serif',
76
- "--schematic-line-height": "1.5",
78
+ "--schematic-line-height": "1.375",
77
79
  "--schematic-line-height-heading": "1.2",
78
80
  "--schematic-meter-track": ld("#f2f4f7", "#26282d"),
79
81
  "--schematic-muted": ld("#8a8a8a", "#a1a1a1"),
@@ -127,13 +129,27 @@ function resolveAppearance(host) {
127
129
  fontFamily: style.fontFamily
128
130
  };
129
131
  probe.remove();
130
- const variables = {};
132
+ const variables = {
133
+ gridColumnSpacing: "1.5rem",
134
+ gridRowSpacing: "1.5rem",
135
+ spacingUnit: "0.25rem"
136
+ };
131
137
  for (const [name, value] of Object.entries(candidates)) {
132
138
  if (resolved(value)) {
133
139
  variables[name] = value;
134
140
  }
135
141
  }
136
- return { theme: "stripe", variables };
142
+ return {
143
+ theme: "stripe",
144
+ variables,
145
+ rules: {
146
+ ".Label": {
147
+ fontSize: "1rem",
148
+ fontWeight: "400",
149
+ marginBottom: "0.75rem"
150
+ }
151
+ }
152
+ };
137
153
  }
138
154
  function PaymentMethodForm({
139
155
  checkoutPrefill,
@@ -143,10 +159,10 @@ function PaymentMethodForm({
143
159
  onSelectExisting,
144
160
  t
145
161
  }) {
146
- const { create } = (0, import_schematic_react3.useSetupIntent)();
147
- const [state, setState] = (0, import_react3.useState)({ status: "loading" });
148
- const hostRef = (0, import_react3.useRef)(null);
149
- (0, import_react3.useEffect)(() => {
162
+ const { create } = (0, import_schematic_react5.useSetupIntent)();
163
+ const [state, setState] = (0, import_react6.useState)({ status: "loading" });
164
+ const hostRef = (0, import_react6.useRef)(null);
165
+ (0, import_react6.useEffect)(() => {
150
166
  let cancelled = false;
151
167
  let setupFailed = false;
152
168
  Promise.all([
@@ -192,7 +208,7 @@ function PaymentMethodForm({
192
208
  };
193
209
  }, [create, locale]);
194
210
  if (state.status === "loading") {
195
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
211
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
196
212
  "div",
197
213
  {
198
214
  "aria-busy": "true",
@@ -200,15 +216,15 @@ function PaymentMethodForm({
200
216
  "data-state": "pending",
201
217
  ref: hostRef,
202
218
  children: [
203
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-hidden", children: t("paymentMethodsFormLoading") }),
204
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
219
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-hidden", children: t("paymentMethodsFormLoading") }),
220
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
205
221
  ]
206
222
  }
207
223
  );
208
224
  }
209
225
  if (state.status === "failed") {
210
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-payment-methods__form", "data-state": "error", children: [
211
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
226
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-payment-methods__form", "data-state": "error", children: [
227
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
212
228
  "p",
213
229
  {
214
230
  className: "schematic-error schematic-small schematic-payment-methods__form-error",
@@ -216,11 +232,11 @@ function PaymentMethodForm({
216
232
  children: t(state.errorKey)
217
233
  }
218
234
  ),
219
- onSelectExisting !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SelectExisting, { t, onSelectExisting })
235
+ onSelectExisting !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectExisting, { t, onSelectExisting })
220
236
  ] });
221
237
  }
222
238
  const { Elements } = state.ui;
223
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
239
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
224
240
  Elements,
225
241
  {
226
242
  stripe: state.stripe,
@@ -228,7 +244,7 @@ function PaymentMethodForm({
228
244
  appearance: state.appearance,
229
245
  clientSecret: state.clientSecret
230
246
  },
231
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
247
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
232
248
  Fields,
233
249
  {
234
250
  checkoutPrefill,
@@ -257,19 +273,19 @@ function Fields({
257
273
  const showAddress = collectAddress || collectPhone;
258
274
  const prefill = checkoutPrefill?.billingDetails;
259
275
  const prefillName = orUndefined(prefill?.name);
260
- const emailId = (0, import_react3.useId)();
276
+ const emailId = (0, import_react6.useId)();
261
277
  const stripe = useStripe();
262
278
  const elements = useElements();
263
- const [saving, setSaving] = (0, import_react3.useState)(false);
264
- const [message, setMessage] = (0, import_react3.useState)(null);
265
- const [complete, setComplete] = (0, import_react3.useState)(false);
266
- const [ready, setReady] = (0, import_react3.useState)(false);
267
- const [loadFailed, setLoadFailed] = (0, import_react3.useState)(false);
268
- const [addressComplete, setAddressComplete] = (0, import_react3.useState)(!collectAddress);
269
- const [typedEmail, setTypedEmail] = (0, import_react3.useState)(null);
279
+ const [saving, setSaving] = (0, import_react6.useState)(false);
280
+ const [message, setMessage] = (0, import_react6.useState)(null);
281
+ const [complete, setComplete] = (0, import_react6.useState)(false);
282
+ const [ready, setReady] = (0, import_react6.useState)(false);
283
+ const [loadFailed, setLoadFailed] = (0, import_react6.useState)(false);
284
+ const [addressComplete, setAddressComplete] = (0, import_react6.useState)(!collectAddress);
285
+ const [typedEmail, setTypedEmail] = (0, import_react6.useState)(null);
270
286
  const email = typedEmail ?? orUndefined(prefill?.email) ?? "";
271
287
  const emailValid = !collectEmail || VALID_EMAIL.test(email);
272
- (0, import_react3.useEffect)(() => {
288
+ (0, import_react6.useEffect)(() => {
273
289
  if (ready) {
274
290
  return;
275
291
  }
@@ -321,14 +337,14 @@ function Fields({
321
337
  setSaving(false);
322
338
  }
323
339
  };
324
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
340
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
325
341
  "form",
326
342
  {
327
343
  className: "schematic-payment-methods__form",
328
344
  "data-state": "ready",
329
345
  onSubmit: (event) => void submit(event),
330
346
  children: [
331
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-payment-methods__fields", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
347
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-payment-methods__fields", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
332
348
  PaymentElement,
333
349
  {
334
350
  onChange: (event) => setComplete(event.complete),
@@ -339,8 +355,8 @@ function Fields({
339
355
  }
340
356
  }
341
357
  ) }),
342
- collectEmail && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-payment-methods__field", children: [
343
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
358
+ collectEmail && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-payment-methods__field", children: [
359
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
344
360
  "label",
345
361
  {
346
362
  className: "schematic-payment-methods__field-label",
@@ -348,7 +364,7 @@ function Fields({
348
364
  children: t("paymentMethodsEmail")
349
365
  }
350
366
  ),
351
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
367
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
352
368
  "input",
353
369
  {
354
370
  autoComplete: "email",
@@ -362,7 +378,7 @@ function Fields({
362
378
  }
363
379
  )
364
380
  ] }),
365
- showAddress && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-payment-methods__address", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
381
+ showAddress && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-payment-methods__address", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
366
382
  AddressElement,
367
383
  {
368
384
  options: {
@@ -376,7 +392,7 @@ function Fields({
376
392
  },
377
393
  prefillName ?? ""
378
394
  ) }),
379
- loadFailed && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
395
+ loadFailed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
380
396
  "p",
381
397
  {
382
398
  className: "schematic-error schematic-small schematic-payment-methods__form-error",
@@ -384,7 +400,7 @@ function Fields({
384
400
  children: t("paymentMethodsFormError")
385
401
  }
386
402
  ),
387
- message !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
403
+ message !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
388
404
  "p",
389
405
  {
390
406
  className: "schematic-error schematic-small schematic-payment-methods__form-error",
@@ -392,7 +408,7 @@ function Fields({
392
408
  children: message
393
409
  }
394
410
  ),
395
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
411
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
396
412
  "button",
397
413
  {
398
414
  className: "schematic-cta schematic-payment-methods__save",
@@ -401,7 +417,7 @@ function Fields({
401
417
  children: saving ? t("paymentMethodsSaving") : t("paymentMethodsSave")
402
418
  }
403
419
  ),
404
- onSelectExisting !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
420
+ onSelectExisting !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
405
421
  SelectExisting,
406
422
  {
407
423
  disabled: saving,
@@ -418,7 +434,7 @@ function SelectExisting({
418
434
  onSelectExisting,
419
435
  t
420
436
  }) {
421
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
437
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
422
438
  "button",
423
439
  {
424
440
  className: "schematic-link-button schematic-payment-methods__select-existing",
@@ -429,21 +445,21 @@ function SelectExisting({
429
445
  }
430
446
  );
431
447
  }
432
- var import_schematic_react3, import_react3, import_jsx_runtime4, NO_CLIENT_SECRET, STRIPE_NOT_LOADED, PROBE_CSS, READY_TIMEOUT_MS, VALID_EMAIL, PaymentMethodForm_default;
448
+ var import_schematic_react5, import_react6, import_jsx_runtime7, NO_CLIENT_SECRET, STRIPE_NOT_LOADED, PROBE_CSS, READY_TIMEOUT_MS, VALID_EMAIL, PaymentMethodForm_default;
433
449
  var init_PaymentMethodForm = __esm({
434
450
  "src/elements/PaymentMethodForm.tsx"() {
435
451
  "use strict";
436
- import_schematic_react3 = require("@schematichq/schematic-react");
437
- import_react3 = require("react");
452
+ import_schematic_react5 = require("@schematichq/schematic-react");
453
+ import_react6 = require("react");
438
454
  init_tokens();
439
- import_jsx_runtime4 = require("react/jsx-runtime");
455
+ import_jsx_runtime7 = require("react/jsx-runtime");
440
456
  NO_CLIENT_SECRET = "The setup intent carries no client secret.";
441
457
  STRIPE_NOT_LOADED = "Stripe.js did not load.";
442
458
  PROBE_CSS = withTokenDefaults(
443
459
  [
444
460
  "background-color: var(--schematic-background)",
445
461
  "border-color: var(--schematic-accent)",
446
- "border-radius: var(--schematic-radius)",
462
+ "border-radius: calc(var(--schematic-radius) * 0.8)",
447
463
  "color: var(--schematic-text)",
448
464
  "font-family: var(--schematic-font-body)",
449
465
  "outline-color: var(--schematic-danger)",
@@ -460,16 +476,23 @@ var init_PaymentMethodForm = __esm({
460
476
  // src/elements/index.ts
461
477
  var index_exports = {};
462
478
  __export(index_exports, {
463
- BillingDataProvider: () => import_schematic_react6.BillingDataProvider,
479
+ BillingDataProvider: () => import_schematic_react8.BillingDataProvider,
464
480
  DEFAULT_STRINGS: () => DEFAULT_STRINGS,
481
+ FEATURE_USER_USAGE_LIMIT: () => import_schematic_react8.FEATURE_USER_USAGE_LIMIT,
482
+ IncludedFeatures: () => IncludedFeatures,
465
483
  Invoices: () => Invoices,
484
+ MeteredFeatures: () => MeteredFeatures,
466
485
  PaymentMethods: () => PaymentMethods,
467
486
  SCHEMATIC_TOKENS: () => SCHEMATIC_TOKENS,
468
- SchematicI18nProvider: () => import_schematic_react6.SchematicI18nProvider,
487
+ SchematicI18nProvider: () => import_schematic_react8.SchematicI18nProvider,
469
488
  SchematicStyles: () => SchematicStyles,
489
+ Tooltip: () => Tooltip,
470
490
  UpcomingBill: () => UpcomingBill,
471
491
  billingResources: () => billingResources,
492
+ currentTier: () => currentTier,
493
+ deriveIncludedFeatures: () => deriveIncludedFeatures,
472
494
  deriveInvoiceList: () => deriveInvoiceList,
495
+ deriveMeteredFeatures: () => deriveMeteredFeatures,
473
496
  derivePaymentMethods: () => derivePaymentMethods,
474
497
  deriveUpcomingInvoice: () => deriveUpcomingInvoice,
475
498
  featureName: () => featureName,
@@ -483,26 +506,33 @@ __export(index_exports, {
483
506
  httpStatus: () => httpStatus,
484
507
  iconsCss: () => iconsCss,
485
508
  interpolate: () => interpolate,
509
+ isTieredPrice: () => isTieredPrice,
486
510
  lookup: () => lookup,
487
511
  plural: () => plural,
512
+ pricePeriod: () => pricePeriod,
488
513
  resolveLocale: () => resolveLocale,
489
514
  schematicStylesCss: () => schematicStylesCss,
490
515
  schematicTokensCss: () => schematicTokensCss,
491
- useInvalidateBillingData: () => import_schematic_react6.useInvalidateBillingData,
492
- useInvoices: () => import_schematic_react6.useInvoices,
493
- usePaymentMethods: () => import_schematic_react6.usePaymentMethods,
516
+ tierRanges: () => tierRanges,
517
+ unitPrice: () => unitPrice,
518
+ usageLimit: () => usageLimit,
519
+ useFeatureUsage: () => import_schematic_react8.useFeatureUsage,
520
+ useFeatureUserUsage: () => import_schematic_react8.useFeatureUserUsage,
521
+ useInvalidateBillingData: () => import_schematic_react8.useInvalidateBillingData,
522
+ useInvoices: () => import_schematic_react8.useInvoices,
523
+ usePaymentMethods: () => import_schematic_react8.usePaymentMethods,
494
524
  useResolvedLocale: () => useResolvedLocale,
495
- useSchematicI18n: () => import_schematic_react6.useSchematicI18n,
496
- useSchematicLocale: () => import_schematic_react6.useSchematicLocale,
497
- useSchematicStrings: () => import_schematic_react6.useSchematicStrings,
498
- useSchematicTranslate: () => import_schematic_react6.useSchematicTranslate,
499
- useSetupIntent: () => import_schematic_react6.useSetupIntent,
525
+ useSchematicI18n: () => import_schematic_react8.useSchematicI18n,
526
+ useSchematicLocale: () => import_schematic_react8.useSchematicLocale,
527
+ useSchematicStrings: () => import_schematic_react8.useSchematicStrings,
528
+ useSchematicTranslate: () => import_schematic_react8.useSchematicTranslate,
529
+ useSetupIntent: () => import_schematic_react8.useSetupIntent,
500
530
  useTranslator: () => useTranslator,
501
- useUpcomingInvoice: () => import_schematic_react6.useUpcomingInvoice,
531
+ useUpcomingInvoice: () => import_schematic_react8.useUpcomingInvoice,
502
532
  viewerLocale: () => viewerLocale
503
533
  });
504
534
  module.exports = __toCommonJS(index_exports);
505
- var import_schematic_react6 = require("@schematichq/schematic-react");
535
+ var import_schematic_react8 = require("@schematichq/schematic-react");
506
536
 
507
537
  // src/elements/model/errors.ts
508
538
  function httpStatus(error) {
@@ -1263,6 +1293,456 @@ function derivePaymentMethods(methods, options) {
1263
1293
  };
1264
1294
  }
1265
1295
 
1296
+ // src/elements/model/featureUsage.ts
1297
+ function pricePeriod(price) {
1298
+ if (price === void 0) {
1299
+ return null;
1300
+ }
1301
+ if (price.interval === "month" && price.intervalCount === 3) {
1302
+ return "quarter";
1303
+ }
1304
+ return price.interval;
1305
+ }
1306
+ function isTieredPrice(price) {
1307
+ return price !== void 0 && (price.priceTiers.length > 1 || price.tiersMode !== void 0 && price.tiersMode !== null);
1308
+ }
1309
+ function unitPrice(price) {
1310
+ return decimalOr(price.priceDecimal, price.price);
1311
+ }
1312
+ function usageLimit(row, options = {}) {
1313
+ let limit = null;
1314
+ const behavior = row.priceBehavior ?? null;
1315
+ if ((behavior === null || behavior === "pay_in_advance") && typeof row.allocation === "number") {
1316
+ limit = row.allocation;
1317
+ } else if (behavior === "overage" && typeof row.softLimit === "number") {
1318
+ limit = row.softLimit;
1319
+ }
1320
+ if (options.showWarningThresholdAsLimit === true && typeof row.warningThreshold === "number") {
1321
+ limit = row.warningThreshold;
1322
+ }
1323
+ return limit;
1324
+ }
1325
+ function currentTier(row) {
1326
+ const tiers = row.price?.priceTiers ?? [];
1327
+ if (row.priceBehavior === "overage" && typeof row.softLimit === "number") {
1328
+ const overage = tiers.length === 2 ? tiers[1] : void 0;
1329
+ return overage === void 0 ? null : { ...tierRange(overage), from: row.softLimit + 1 };
1330
+ }
1331
+ if (row.priceBehavior === "tier" && typeof row.usage === "number") {
1332
+ const usage = row.usage;
1333
+ const tier = tiers.find(
1334
+ (t) => usage >= t.from && (t.to === void 0 || t.to === null || usage <= t.to)
1335
+ );
1336
+ return tier === void 0 ? null : tierRange(tier);
1337
+ }
1338
+ return null;
1339
+ }
1340
+ function tierRanges(price) {
1341
+ return (price?.priceTiers ?? []).map((tier, index) => {
1342
+ const range = tierRange(tier);
1343
+ return index === 0 ? { ...range, from: Math.max(1, range.from) } : range;
1344
+ });
1345
+ }
1346
+ function tierRange(tier) {
1347
+ return {
1348
+ from: tier.from,
1349
+ to: tier.to ?? null,
1350
+ flatPrice: tier.flatPrice ?? null,
1351
+ perUnitPrice: tier.perUnitPriceDecimal !== void 0 && tier.perUnitPriceDecimal !== null ? decimalOr(tier.perUnitPriceDecimal, tier.perUnitPrice ?? 0) : tier.perUnitPrice ?? null
1352
+ };
1353
+ }
1354
+ function decimalOr(decimal, fallback) {
1355
+ if (decimal === void 0 || decimal === null) {
1356
+ return fallback;
1357
+ }
1358
+ const parsed = Number(decimal);
1359
+ return Number.isFinite(parsed) ? parsed : fallback;
1360
+ }
1361
+
1362
+ // src/elements/model/includedFeatures.ts
1363
+ function deriveIncludedFeatures(features, options) {
1364
+ const ordered = options.visibleFeatures === void 0 ? features : options.visibleFeatures.flatMap((id) => {
1365
+ const row = features.find((f) => f.featureId === id);
1366
+ return row === void 0 ? [] : [row];
1367
+ });
1368
+ return ordered.map((row) => includedFeatureRow(row, options));
1369
+ }
1370
+ function includedFeatureRow(row, options) {
1371
+ const { locale } = options;
1372
+ const feature = {
1373
+ name: row.featureName,
1374
+ singularName: row.featureSingularName,
1375
+ pluralName: row.featurePluralName
1376
+ };
1377
+ const expiresAt = usableDate(row.expiresAt);
1378
+ const tiered = row.priceBehavior === "pay_in_advance" && isTieredPrice(row.price);
1379
+ const period = pricePeriod(row.price);
1380
+ return {
1381
+ featureId: row.featureId,
1382
+ name: row.featureName,
1383
+ description: nonEmpty(row.featureDescription),
1384
+ icon: nonEmpty(row.featureIcon),
1385
+ perLicenseCredits: row.perLicenseCreditGrants.filter((grant) => grant.scaling === "per_license").map((grant) => ({
1386
+ amount: grant.creditAmount,
1387
+ creditName: featureName(
1388
+ {
1389
+ name: grant.creditName,
1390
+ singularName: grant.creditSingularName,
1391
+ pluralName: grant.creditPluralName
1392
+ },
1393
+ grant.creditAmount,
1394
+ locale
1395
+ ),
1396
+ licenseName: featureName(feature, 1, locale)
1397
+ })),
1398
+ expiresAt: expiresAt === void 0 ? null : {
1399
+ date: expiresAt,
1400
+ text: formatDate(expiresAt, locale, { month: "short" })
1401
+ },
1402
+ entitlement: entitlementText(row, options),
1403
+ usage: usageSegments(row, locale, tiered, period),
1404
+ usageSummary: usageSummary(row, options),
1405
+ hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
1406
+ amount: row.allocation,
1407
+ units: featureName(feature, row.allocation, locale)
1408
+ } : null,
1409
+ tiers: (row.priceBehavior === "tier" || tiered) && row.price !== void 0 ? {
1410
+ ranges: tierRanges(row.price),
1411
+ currency: row.price.currency,
1412
+ mode: row.price.tiersMode ?? null,
1413
+ period
1414
+ } : null,
1415
+ source: row
1416
+ };
1417
+ }
1418
+ function isMetered(row) {
1419
+ return row.featureType === "event" || row.featureType === "trait";
1420
+ }
1421
+ function entitlementText(row, options) {
1422
+ if (!isMetered(row)) {
1423
+ return null;
1424
+ }
1425
+ const { locale } = options;
1426
+ const feature = {
1427
+ name: row.featureName,
1428
+ singularName: row.featureSingularName,
1429
+ pluralName: row.featurePluralName
1430
+ };
1431
+ const units = (count) => ({
1432
+ amount: formatNumber(count, locale),
1433
+ units: featureName(feature, count, locale)
1434
+ });
1435
+ switch (row.priceBehavior) {
1436
+ case "pay_in_advance":
1437
+ return typeof row.allocation === "number" ? { kind: "units", ...units(row.allocation) } : null;
1438
+ case "pay_as_you_go": {
1439
+ if (row.price === void 0) {
1440
+ return null;
1441
+ }
1442
+ const cost = formatCurrency(
1443
+ unitPrice(row.price),
1444
+ row.price.currency,
1445
+ locale
1446
+ );
1447
+ const size = row.price.packageSize;
1448
+ return size > 1 ? {
1449
+ kind: "perPackage",
1450
+ cost,
1451
+ size,
1452
+ units: featureName(feature, size, locale)
1453
+ } : { kind: "perUnit", cost, unit: featureName(feature, 1, locale) };
1454
+ }
1455
+ case "overage":
1456
+ return typeof row.softLimit === "number" ? { kind: "units", ...units(row.softLimit) } : null;
1457
+ case "tier": {
1458
+ const tier = currentTier(row);
1459
+ if (tier === null) {
1460
+ return null;
1461
+ }
1462
+ return tier.to === null ? { kind: "tierUnlimited", feature: featureName(feature, 0, locale) } : {
1463
+ kind: "tierUpTo",
1464
+ amount: formatNumber(tier.to, locale),
1465
+ feature: featureName(feature, tier.to, locale)
1466
+ };
1467
+ }
1468
+ case "credit_burndown":
1469
+ if (options.showCredits === false || typeof row.consumptionRate !== "number" || row.creditName === void 0 || row.creditName === null) {
1470
+ return null;
1471
+ }
1472
+ return {
1473
+ kind: "perUse",
1474
+ amount: formatConsumptionRate(row.consumptionRate, locale),
1475
+ units: featureName(
1476
+ {
1477
+ name: row.creditName,
1478
+ singularName: row.creditSingularName,
1479
+ pluralName: row.creditPluralName
1480
+ },
1481
+ row.consumptionRate,
1482
+ locale
1483
+ )
1484
+ };
1485
+ default:
1486
+ break;
1487
+ }
1488
+ if (typeof row.allocation === "number") {
1489
+ const limit = usageLimit(row, options) ?? row.allocation;
1490
+ return { kind: "units", ...units(limit) };
1491
+ }
1492
+ if (row.valueType === "unlimited") {
1493
+ return { kind: "unlimited", item: featureName(feature, 0, locale) };
1494
+ }
1495
+ return null;
1496
+ }
1497
+ function usageSegments(row, locale, tiered, period) {
1498
+ if (!isMetered(row)) {
1499
+ return [];
1500
+ }
1501
+ const feature = {
1502
+ name: row.featureName,
1503
+ singularName: row.featureSingularName,
1504
+ pluralName: row.featurePluralName
1505
+ };
1506
+ const segments = [];
1507
+ if (row.priceBehavior === "pay_in_advance" && !tiered && period !== null && row.price !== void 0) {
1508
+ const size = row.price.packageSize;
1509
+ segments.push({
1510
+ kind: "unitPricePerPeriod",
1511
+ cost: formatCurrency(unitPrice(row.price), row.price.currency, locale),
1512
+ size,
1513
+ units: featureName(feature, size, locale),
1514
+ period
1515
+ });
1516
+ } else if ((row.priceBehavior === "pay_as_you_go" || row.priceBehavior === "overage" || row.priceBehavior === "tier" || row.priceBehavior === "credit_burndown" || tiered) && typeof row.usage === "number") {
1517
+ segments.push({
1518
+ kind: "used",
1519
+ amount: String(row.usage),
1520
+ units: featureName(feature, row.usage, locale)
1521
+ });
1522
+ }
1523
+ if (typeof row.currentCost === "number" && row.currentCost > 0 && row.price !== void 0) {
1524
+ segments.push({
1525
+ kind: "cost",
1526
+ cost: formatCurrency(row.currentCost, row.price.currency, locale),
1527
+ period: row.featureType === "trait" ? period : null
1528
+ });
1529
+ }
1530
+ const resetsAt = usableDate(row.resetsAt);
1531
+ if (resetsAt !== void 0) {
1532
+ segments.push({
1533
+ kind: "resets",
1534
+ date: formatDate(resetsAt, locale, { month: "short", year: void 0 })
1535
+ });
1536
+ }
1537
+ return segments;
1538
+ }
1539
+ function usageSummary(row, options) {
1540
+ if (!isMetered(row) || typeof row.usage !== "number") {
1541
+ return null;
1542
+ }
1543
+ const amount = formatNumber(row.usage, options.locale);
1544
+ if (typeof row.allocation === "number") {
1545
+ return {
1546
+ kind: "limited",
1547
+ amount,
1548
+ allocation: formatNumber(
1549
+ usageLimit(row, options) ?? row.allocation,
1550
+ options.locale
1551
+ )
1552
+ };
1553
+ }
1554
+ return { kind: "unlimited", amount };
1555
+ }
1556
+ function nonEmpty(value) {
1557
+ return value === void 0 || value === null || value === "" ? null : value;
1558
+ }
1559
+
1560
+ // src/elements/model/meteredFeatures.ts
1561
+ var TONES = [
1562
+ "ok",
1563
+ "ok",
1564
+ "ok",
1565
+ "warning",
1566
+ "critical",
1567
+ "critical"
1568
+ ];
1569
+ function deriveMeteredFeatures(features, options) {
1570
+ const ordered = options.visibleFeatures === void 0 ? features : options.visibleFeatures.flatMap((id) => {
1571
+ const row = features.find((f) => f.featureId === id);
1572
+ return row === void 0 ? [] : [row];
1573
+ });
1574
+ return ordered.filter((row) => row.featureType === "event" || row.featureType === "trait").map((row) => meteredFeatureRow(row, options));
1575
+ }
1576
+ function meteredFeatureRow(row, options) {
1577
+ const { locale } = options;
1578
+ const unit = {
1579
+ name: row.featureName,
1580
+ singularName: row.featureSingularName ?? void 0,
1581
+ pluralName: row.featurePluralName ?? void 0
1582
+ };
1583
+ const limit = usageLimit(row, options);
1584
+ const resetsAt = usableDate(row.resetsAt);
1585
+ return {
1586
+ featureId: row.featureId,
1587
+ name: row.featureName,
1588
+ description: row.featureDescription === "" ? null : row.featureDescription ?? null,
1589
+ icon: row.featureIcon === "" ? null : row.featureIcon ?? null,
1590
+ headline: headline(row, limit, unit, locale),
1591
+ limit: limitLine(row, limit, unit, options),
1592
+ resetsAt: resetsAt === void 0 ? null : formatDate(resetsAt, locale, { month: "short", year: void 0 }),
1593
+ hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
1594
+ amount: row.allocation,
1595
+ units: featureName(unit, row.allocation, locale)
1596
+ } : null,
1597
+ meter: meter(row, options),
1598
+ priceDetails: priceDetails(row, unit, locale),
1599
+ canAddMore: row.priceBehavior === "pay_in_advance",
1600
+ hasUsageByUser: row.featureType === "event",
1601
+ unit,
1602
+ source: row
1603
+ };
1604
+ }
1605
+ function headline(row, limit, unit, locale) {
1606
+ if (row.priceBehavior === "pay_in_advance") {
1607
+ return {
1608
+ kind: "quantity",
1609
+ amount: limit === null ? null : formatNumber(limit, locale),
1610
+ units: featureName(unit, limit ?? 0, locale)
1611
+ };
1612
+ }
1613
+ if (typeof row.usage !== "number") {
1614
+ return null;
1615
+ }
1616
+ return {
1617
+ kind: "used",
1618
+ amount: formatNumber(row.usage, locale),
1619
+ units: featureName(unit, row.usage, locale)
1620
+ };
1621
+ }
1622
+ function limitLine(row, limit, unit, options) {
1623
+ const { locale } = options;
1624
+ switch (row.priceBehavior) {
1625
+ case "tier": {
1626
+ const tier = currentTier(row);
1627
+ if (tier !== null) {
1628
+ return tier.to === null ? { kind: "tierUnlimited", feature: featureName(unit, 0, locale) } : {
1629
+ kind: "tierUpTo",
1630
+ amount: formatNumber(tier.to, locale),
1631
+ feature: featureName(unit, tier.to, locale)
1632
+ };
1633
+ }
1634
+ break;
1635
+ }
1636
+ case "overage":
1637
+ if (limit !== null) {
1638
+ return { kind: "included", amount: formatNumber(limit, locale) };
1639
+ }
1640
+ break;
1641
+ case "pay_in_advance":
1642
+ if (typeof row.usage === "number") {
1643
+ return { kind: "used", amount: formatNumber(row.usage, locale) };
1644
+ }
1645
+ break;
1646
+ case "pay_as_you_go":
1647
+ if (typeof row.currentCost === "number" && row.price !== void 0) {
1648
+ return {
1649
+ kind: "cost",
1650
+ cost: formatCurrency(row.currentCost, row.price.currency, locale)
1651
+ };
1652
+ }
1653
+ break;
1654
+ case "credit_burndown":
1655
+ if (options.showCredits === false || typeof row.consumptionRate !== "number" || row.creditName === void 0 || row.creditName === null) {
1656
+ return null;
1657
+ }
1658
+ return {
1659
+ kind: "perUse",
1660
+ amount: formatConsumptionRate(row.consumptionRate, locale),
1661
+ units: featureName(
1662
+ {
1663
+ name: row.creditName,
1664
+ singularName: row.creditSingularName,
1665
+ pluralName: row.creditPluralName
1666
+ },
1667
+ row.consumptionRate,
1668
+ locale
1669
+ )
1670
+ };
1671
+ default:
1672
+ break;
1673
+ }
1674
+ return limit === null ? { kind: "noLimit" } : { kind: "limitOf", amount: formatNumber(limit, locale) };
1675
+ }
1676
+ function meter(row, options) {
1677
+ if (row.priceBehavior === "pay_as_you_go" || row.priceBehavior === "credit_burndown" || typeof row.usage !== "number") {
1678
+ return null;
1679
+ }
1680
+ const total = options.showWarningThresholdAsLimit === true && typeof row.warningThreshold === "number" ? row.warningThreshold : row.softLimit ?? row.allocation ?? null;
1681
+ if (typeof total !== "number") {
1682
+ return null;
1683
+ }
1684
+ const usage = row.usage;
1685
+ const past = row.priceBehavior === "overage" && usage > total;
1686
+ const ratio = past ? Math.min(usage, total) / Math.max(usage, total) : total === 0 ? 1 : usage / total;
1687
+ const digits = { maximumFractionDigits: 10 };
1688
+ return {
1689
+ value: usage,
1690
+ total,
1691
+ percent: Math.min(ratio * 100, 100),
1692
+ tone: row.priceBehavior === "tier" ? "tier" : past ? "overage" : TONES[Math.floor(
1693
+ (total === 0 ? 1 : Math.min(usage, total) / total) * (TONES.length - 1)
1694
+ )],
1695
+ valueText: formatNumber(usage, options.locale, digits),
1696
+ totalText: formatNumber(total, options.locale, digits)
1697
+ };
1698
+ }
1699
+ function priceDetails(row, unit, locale) {
1700
+ const price = row.price;
1701
+ if (price === void 0) {
1702
+ return null;
1703
+ }
1704
+ const tier = currentTier(row);
1705
+ const period = row.featureType === "trait" ? pricePeriod(price) : null;
1706
+ const money = (amount) => formatCurrency(amount, price.currency, locale);
1707
+ if (row.priceBehavior === "overage") {
1708
+ if (tier === null || tier.perUnitPrice === null) {
1709
+ return null;
1710
+ }
1711
+ const size = price.packageSize;
1712
+ const over = typeof row.usage === "number" && typeof row.softLimit === "number" ? Math.max(0, row.usage - row.softLimit) : 0;
1713
+ return {
1714
+ kind: "overage",
1715
+ unitPrice: money(tier.perUnitPrice),
1716
+ packageSize: size,
1717
+ units: featureName(unit, size, locale),
1718
+ period,
1719
+ overage: {
1720
+ amount: formatNumber(over, locale),
1721
+ units: featureName(unit, over, locale),
1722
+ cost: money(tier.perUnitPrice * over)
1723
+ }
1724
+ };
1725
+ }
1726
+ if (row.priceBehavior === "tier") {
1727
+ if (tier === null || tier.perUnitPrice === null) {
1728
+ return null;
1729
+ }
1730
+ return {
1731
+ kind: "tier",
1732
+ from: tier.from === 0 ? 1 : tier.from,
1733
+ to: tier.to,
1734
+ cost: typeof row.currentCost === "number" ? money(row.currentCost) : null,
1735
+ period,
1736
+ tiers: {
1737
+ ranges: tierRanges(price),
1738
+ currency: price.currency,
1739
+ mode: price.tiersMode ?? null
1740
+ }
1741
+ };
1742
+ }
1743
+ return null;
1744
+ }
1745
+
1266
1746
  // src/elements/strings.ts
1267
1747
  var DEFAULT_STRINGS_LOCALE = "en";
1268
1748
  var DEFAULT_STRINGS = {
@@ -1329,7 +1809,63 @@ var DEFAULT_STRINGS = {
1329
1809
  paymentMethodsSaving: "Loading",
1330
1810
  paymentMethodsSaveError: "A problem occurred while saving your payment method.",
1331
1811
  paymentMethodsSetDefaultError: "Error updating payment method. Please try again.",
1332
- paymentMethodsRemoveError: "Error deleting payment method. Please try again."
1812
+ paymentMethodsRemoveError: "Error deleting payment method. Please try again.",
1813
+ includedFeaturesLoading: "Loading features",
1814
+ includedFeaturesHeader: "Included features",
1815
+ includedFeaturesError: "There was a problem retrieving your features.",
1816
+ includedFeaturesUnavailable: "Features are not available for this account.",
1817
+ includedFeaturesSeeAll: "See all",
1818
+ includedFeaturesHideAll: "Hide all",
1819
+ includedFeaturesExpires: "Expires {{date}}",
1820
+ includedFeaturesPerLicense: "Includes {{amount}} {{creditName}} per {{licenseName}}",
1821
+ meteredFeaturesLoading: "Loading usage",
1822
+ meteredFeaturesHeader: "Usage",
1823
+ meteredFeaturesError: "There was a problem retrieving your usage.",
1824
+ meteredFeaturesUnavailable: "Usage is not available for this account.",
1825
+ meteredFeaturesUsed: "{{amount}} {{units}} used",
1826
+ meteredFeaturesIncluded: "{{amount}} included",
1827
+ meteredFeaturesInUse: "{{amount}} used",
1828
+ meteredFeaturesLimitOf: "Limit of {{amount}}",
1829
+ meteredFeaturesNoLimit: "No limit",
1830
+ meteredFeaturesAddMore: "Add More",
1831
+ meteredFeaturesAdditional: "Additional",
1832
+ meteredFeaturesTier: "Tier",
1833
+ usageByUserHeader: "Usage by user",
1834
+ usageByUserTotal: "{{amount}} used by your team this period",
1835
+ usageByUserError: "There was a problem retrieving usage by user.",
1836
+ usageByUserUnattributed: "Unattributed",
1837
+ // Looked up by the bare key with `{ count }`; `shown` is the count formatted.
1838
+ usageByUserMore: "plus {{shown}} more",
1839
+ usageByUserShowTop: "Show top {{shown}} users",
1840
+ usageByUserShowTop_one: "Show top {{shown}} user",
1841
+ usageByUserShowTop_other: "Show top {{shown}} users",
1842
+ usageByUserShowAllCount: "Show all {{shown}} users",
1843
+ usageByUserShowAllCount_one: "Show all {{shown}} user",
1844
+ usageByUserShowAllCount_other: "Show all {{shown}} users",
1845
+ usageByUserShowAll: "Show all",
1846
+ usageByUserShowFewer: "Show fewer",
1847
+ // Shared by the usage elements.
1848
+ usageUnits: "{{amount}} {{units}}",
1849
+ usagePerUnit: "{{cost}} per {{unit}}",
1850
+ usagePerPackage: "{{cost}} per {{size}} {{units}}",
1851
+ usageTierUpTo: "Up to {{amount}} {{feature}} in this tier",
1852
+ usageTierUnlimited: "Unlimited {{feature}} in this tier",
1853
+ usagePerUse: "{{amount}} {{units}} per use",
1854
+ usageUnlimited: "Unlimited {{item}}",
1855
+ usageUnitPricePerPeriod: "{{cost}}/{{unit}}/{{period}}",
1856
+ usagePackagePricePerPeriod: "{{cost}}/{{size}} {{units}}/{{period}}",
1857
+ usageUsed: "{{amount}} {{units}} used",
1858
+ usageResets: "Resets {{date}}",
1859
+ usageLimited: "{{amount}} of {{allocation}} used",
1860
+ usageUnlimitedUsed: "{{amount}} used",
1861
+ usageHardLimitLabel: "Limit",
1862
+ usageHardLimit: "Up to a limit of {{amount}} {{units}}",
1863
+ usageTieredPricingLabel: "Tiered pricing",
1864
+ usageTiersVolume: "Price by unit based on final tier reached.",
1865
+ usageTiersGraduated: "Tiers apply progressively as quantity increases.",
1866
+ periodMonthShort: "mo",
1867
+ periodQuarterShort: "qtr",
1868
+ periodYearShort: "yr"
1333
1869
  };
1334
1870
  var MISSING_STRING = "\0schematic:missing";
1335
1871
  function interpolate(template, vars) {
@@ -1368,15 +1904,29 @@ var dialogCss = `
1368
1904
  border: 0;
1369
1905
  border-radius: 0.5rem;
1370
1906
  box-shadow: var(--schematic-shadow);
1907
+ box-sizing: border-box;
1371
1908
  color: var(--schematic-text);
1372
- line-height: 1.375;
1373
1909
  margin: auto;
1374
1910
  max-height: calc(100vh - 2 * var(--schematic-space));
1375
- max-width: 48rem;
1911
+ max-width: none;
1376
1912
  /* No padding of its own: a click on the backdrop lands on the dialog
1377
1913
  itself, and one inside lands on the header or body. */
1378
1914
  padding: 0;
1379
- width: calc(100% - 2 * var(--schematic-space));
1915
+ /* Never wider than the screen, whatever it holds. */
1916
+ width: min(48rem, calc(100vw - 2 * var(--schematic-space)));
1917
+ }
1918
+
1919
+ /* Centred by vw on a phone: a host page wider than the screen widens the
1920
+ layout viewport, and auto margins would centre the dialog half off the
1921
+ screen. Desktop keeps auto margins, as vw counts the scrollbar there. */
1922
+ @media (max-width: 52rem) {
1923
+ .schematic-dialog {
1924
+ inset-inline: 0 auto;
1925
+ margin-inline: calc(
1926
+ (100vw - min(48rem, calc(100vw - 2 * var(--schematic-space)))) / 2
1927
+ )
1928
+ 0;
1929
+ }
1380
1930
  }
1381
1931
 
1382
1932
  .schematic-dialog::backdrop {
@@ -1408,7 +1958,7 @@ var dialogCss = `
1408
1958
  font-family: var(--schematic-font-body);
1409
1959
  font-size: 1.125rem;
1410
1960
  font-weight: 400;
1411
- line-height: var(--schematic-line-height-heading);
1961
+ line-height: var(--schematic-line-height);
1412
1962
  margin: 0;
1413
1963
  }
1414
1964
 
@@ -1437,6 +1987,8 @@ var dialogCss = `
1437
1987
  display: flex;
1438
1988
  flex-direction: column;
1439
1989
  gap: var(--schematic-space);
1990
+ min-width: 0;
1991
+ overflow-wrap: anywhere;
1440
1992
  padding: calc(var(--schematic-space) * 1.5);
1441
1993
  }
1442
1994
  `;
@@ -1851,6 +2403,109 @@ var iconsCss = String.raw`
1851
2403
  }
1852
2404
  `;
1853
2405
 
2406
+ // src/elements/styles/included-features.ts
2407
+ var includedFeaturesCss = `
2408
+ .schematic-included-features {
2409
+ container-type: inline-size;
2410
+ }
2411
+
2412
+ .schematic-included-features__list {
2413
+ display: flex;
2414
+ flex-direction: column;
2415
+ gap: calc(var(--schematic-space) * 1.5);
2416
+ list-style: none;
2417
+ margin: 0;
2418
+ padding: 0;
2419
+ }
2420
+
2421
+ /* Icon, name and details; the usage drops beneath on a narrow card. */
2422
+ .schematic-included-features__row {
2423
+ column-gap: 0.5rem;
2424
+ display: grid;
2425
+ grid-template-columns: min-content 1fr;
2426
+ }
2427
+
2428
+ /* Two classes: the icon font's own rule comes later in the sheet and sets
2429
+ display, which would leave the glyph in the circle's corner. */
2430
+ .schematic-included-features .schematic-included-features__icon {
2431
+ align-items: center;
2432
+ background: var(--schematic-surface);
2433
+ border-radius: 9999px;
2434
+ color: var(--schematic-accent);
2435
+ display: inline-flex;
2436
+ font-size: 1.5rem;
2437
+ height: 2.75rem;
2438
+ justify-content: center;
2439
+ margin-inline-end: 0.5rem;
2440
+ width: 2.75rem;
2441
+ }
2442
+
2443
+ .schematic-included-features__details {
2444
+ align-self: baseline;
2445
+ display: flex;
2446
+ flex-direction: column;
2447
+ gap: 0.25rem;
2448
+ grid-column: 2;
2449
+ }
2450
+
2451
+ /* An item name, as add-ons and plan lines elsewhere. */
2452
+ .schematic-included-features__name {
2453
+ font-family: var(--schematic-font-heading);
2454
+ font-size: 1.125rem;
2455
+ font-weight: 800;
2456
+ line-height: var(--schematic-line-height-heading);
2457
+ }
2458
+
2459
+ .schematic-included-features__usage {
2460
+ display: flex;
2461
+ flex-direction: column;
2462
+ gap: 0.25rem;
2463
+ grid-column: 1 / span 2;
2464
+ margin-inline-start: 3.75rem;
2465
+ margin-top: 0.75rem;
2466
+ }
2467
+
2468
+ .schematic-included-features__entitlement,
2469
+ .schematic-included-features__used {
2470
+ font-variant-numeric: tabular-nums;
2471
+ }
2472
+
2473
+ @container (min-width: 23.4375rem) {
2474
+ /* The usage takes the room it needs and wraps only when the name leaves
2475
+ it none. */
2476
+ .schematic-included-features__row {
2477
+ grid-template-columns: min-content 1fr auto;
2478
+ }
2479
+
2480
+ .schematic-included-features__usage {
2481
+ align-self: baseline;
2482
+ grid-column: 3;
2483
+ margin-inline-start: 0;
2484
+ margin-top: 0;
2485
+ text-align: end;
2486
+ }
2487
+ }
2488
+
2489
+ .schematic-included-features__toggle {
2490
+ align-items: center;
2491
+ display: inline-flex;
2492
+ gap: 0.25rem;
2493
+ margin-top: var(--schematic-space);
2494
+ }
2495
+
2496
+ .schematic-included-features__toggle .schematic-chevron {
2497
+ margin-inline-start: -0.333rem;
2498
+ }
2499
+
2500
+ .schematic-included-features .schematic-skeleton__cell[data-column="name"] {
2501
+ width: 10rem;
2502
+ }
2503
+
2504
+ .schematic-included-features .schematic-skeleton__cell[data-column="usage"] {
2505
+ width: 6rem;
2506
+ }
2507
+ `;
2508
+
1854
2509
  // src/elements/styles/invoices.ts
1855
2510
  var invoicesCss = `
1856
2511
  .schematic-invoices {
@@ -1880,6 +2535,7 @@ var invoicesCss = `
1880
2535
 
1881
2536
  .schematic-invoices__link {
1882
2537
  color: var(--schematic-accent);
2538
+ font-family: var(--schematic-font-link);
1883
2539
  text-decoration: none;
1884
2540
  }
1885
2541
 
@@ -1895,10 +2551,6 @@ var invoicesCss = `
1895
2551
  text-align: end;
1896
2552
  }
1897
2553
 
1898
- .schematic-invoices__credit {
1899
- color: var(--schematic-muted);
1900
- }
1901
-
1902
2554
  .schematic-invoices__actions {
1903
2555
  align-items: center;
1904
2556
  display: flex;
@@ -1909,23 +2561,12 @@ var invoicesCss = `
1909
2561
  .schematic-invoices__see-more {
1910
2562
  align-items: center;
1911
2563
  display: inline-flex;
1912
- gap: 0.375rem;
2564
+ gap: calc(var(--schematic-space) / 2);
1913
2565
  }
1914
2566
 
1915
- /* A chevron drawn from two borders. The vertical nudge lives in the
1916
- transform with the rotation so one transition carries both. */
2567
+ /* Cancels the glyph's side bearing, so the chevron sits flush. */
1917
2568
  .schematic-invoices__chevron {
1918
- border-block-end: 2px solid var(--schematic-muted);
1919
- border-inline-end: 2px solid var(--schematic-muted);
1920
- display: inline-block;
1921
- height: 0.5em;
1922
- transform: translateY(-0.125em) rotate(45deg);
1923
- transition: transform 0.15s;
1924
- width: 0.5em;
1925
- }
1926
-
1927
- .schematic-invoices__see-more[aria-expanded="true"] .schematic-invoices__chevron {
1928
- transform: translateY(0.125em) rotate(-135deg);
2569
+ margin-inline-start: -0.333rem;
1929
2570
  }
1930
2571
 
1931
2572
  .schematic-invoices__empty {
@@ -1941,77 +2582,317 @@ var invoicesCss = `
1941
2582
  }
1942
2583
  `;
1943
2584
 
1944
- // src/elements/styles/payment-methods.ts
1945
- var paymentMethodsCss = `
1946
- .schematic-payment-methods {
2585
+ // src/elements/styles/metered-features.ts
2586
+ var meteredFeaturesCss = `
2587
+ .schematic-metered-features__list {
1947
2588
  display: flex;
1948
2589
  flex-direction: column;
1949
2590
  gap: var(--schematic-space);
2591
+ list-style: none;
2592
+ margin: 0;
2593
+ padding: 0;
1950
2594
  }
1951
2595
 
1952
- .schematic-payment-methods .schematic-header {
1953
- align-items: center;
1954
- margin-bottom: 0;
2596
+ /* Each feature is a card; while pending or failed, the root is the card. */
2597
+ .schematic-metered-features[data-state="pending"],
2598
+ .schematic-metered-features[data-state="error"] {
2599
+ background: var(--schematic-background);
2600
+ border-radius: var(--schematic-radius);
2601
+ box-shadow: var(--schematic-shadow);
2602
+ padding: calc(var(--schematic-card-padding) * 0.75)
2603
+ var(--schematic-card-padding);
1955
2604
  }
1956
2605
 
1957
- .schematic-payment-methods .schematic-header__title {
1958
- margin-bottom: 0;
2606
+ .schematic-metered-features__feature {
2607
+ container-type: inline-size;
2608
+ display: flex;
2609
+ flex-direction: column;
2610
+ gap: calc(var(--schematic-space) * 1.5);
2611
+ overflow: hidden;
1959
2612
  }
1960
2613
 
1961
- .schematic-payment-methods__expiry-warning {
1962
- color: var(--schematic-danger);
1963
- white-space: nowrap;
2614
+ .schematic-metered-features__main {
2615
+ display: flex;
2616
+ gap: calc(var(--schematic-space) * 1.5);
1964
2617
  }
1965
2618
 
1966
- /* The pill: the default method on the left, Edit or Add on the right. */
1967
- .schematic-payment-methods__current {
2619
+ /* Kept without a glyph, as in the embed, so names line up. */
2620
+ .schematic-metered-features__icon {
1968
2621
  align-items: center;
1969
2622
  background: var(--schematic-surface);
1970
2623
  border-radius: 9999px;
1971
- display: flex;
1972
- gap: var(--schematic-space);
1973
- justify-content: space-between;
1974
- padding: calc(var(--schematic-space) / 2.25) var(--schematic-space);
1975
- }
1976
-
1977
- .schematic-payment-methods__method {
1978
- align-items: center;
2624
+ color: var(--schematic-accent);
1979
2625
  display: inline-flex;
1980
- flex-grow: 1;
1981
- flex-wrap: wrap;
1982
- gap: 0.25em;
1983
- }
1984
-
1985
- /* The brand's mark before the label, in the label's colour. */
1986
- .schematic-payment-methods__icon {
1987
- color: currentColor;
1988
2626
  flex-shrink: 0;
1989
- font-size: 1.5em;
1990
- margin-inline-end: calc(var(--schematic-space) / 4);
2627
+ font-size: 1.5rem;
2628
+ height: 2.75rem;
2629
+ justify-content: center;
2630
+ width: 2.75rem;
1991
2631
  }
1992
2632
 
1993
- .schematic-payment-methods__last4 {
1994
- font-variant-numeric: tabular-nums;
2633
+ /* The glyph takes the base text colour rather than inheriting, so the accent
2634
+ is set on it too. */
2635
+ .schematic-metered-features__icon .schematic-icon {
2636
+ color: var(--schematic-accent);
1995
2637
  }
1996
2638
 
1997
- .schematic-payment-methods__empty {
2639
+ .schematic-metered-features__body {
2640
+ display: flex;
2641
+ flex-direction: column;
1998
2642
  flex-grow: 1;
2643
+ gap: calc(var(--schematic-space) * 2);
2644
+ min-width: 0;
1999
2645
  }
2000
2646
 
2001
- .schematic-payment-methods__edit,
2002
- .schematic-payment-methods__remove-current {
2003
- flex-shrink: 0;
2004
- white-space: nowrap;
2647
+ .schematic-metered-features__top {
2648
+ display: flex;
2649
+ flex-wrap: wrap;
2650
+ gap: var(--schematic-space);
2005
2651
  }
2006
2652
 
2007
- /* The toggle that reveals the other methods, with its chevron: down while
2008
- folded, up while unfolded, each its own glyph. The chevron sits beside
2009
- the link in the text colour rather than as part of it. A flex container hands its underline to every item, and an item
2010
- cannot take it off, so the hover underline goes on the label alone. */
2653
+ .schematic-metered-features__title {
2654
+ display: flex;
2655
+ flex: 1 1 min-content;
2656
+ flex-direction: column;
2657
+ gap: 0.5rem;
2658
+ }
2659
+
2660
+ .schematic-metered-features__name {
2661
+ font-family: var(--schematic-font-heading);
2662
+ font-size: 1.8125rem;
2663
+ font-weight: 800;
2664
+ line-height: var(--schematic-line-height-heading);
2665
+ margin: 0;
2666
+ }
2667
+
2668
+ /* Beside the title when both fit, otherwise beneath it as in the embed,
2669
+ rather than wrapping in a narrow column. */
2670
+ .schematic-metered-features__figures {
2671
+ display: flex;
2672
+ flex: 0 0 auto;
2673
+ flex-direction: column;
2674
+ gap: 0.25rem;
2675
+ max-width: 100%;
2676
+ text-align: end;
2677
+ }
2678
+
2679
+ .schematic-metered-features__headline {
2680
+ font-size: 1.0625rem;
2681
+ font-variant-numeric: tabular-nums;
2682
+ font-weight: 500;
2683
+ white-space: nowrap;
2684
+ }
2685
+
2686
+ @container (max-width: 30rem) {
2687
+ .schematic-metered-features__figures {
2688
+ min-width: 0;
2689
+ text-align: start;
2690
+ }
2691
+
2692
+ /* Too narrow to keep "1,300 GB of storage used" on one line. */
2693
+ .schematic-metered-features__headline {
2694
+ white-space: normal;
2695
+ }
2696
+ }
2697
+
2698
+ .schematic-metered-features__limit {
2699
+ font-variant-numeric: tabular-nums;
2700
+ }
2701
+
2702
+ .schematic-metered-features__add-more {
2703
+ align-self: flex-start;
2704
+ white-space: nowrap;
2705
+ }
2706
+
2707
+ /* Negative margins undo the card's padding so the footer bleeds to its edges. */
2708
+ .schematic-metered-features__price-details {
2709
+ align-items: center;
2710
+ background: var(--schematic-surface);
2711
+ display: flex;
2712
+ gap: var(--schematic-space);
2713
+ justify-content: space-between;
2714
+ margin: 0 calc(var(--schematic-card-padding) * -1)
2715
+ calc(var(--schematic-card-padding) * -0.75);
2716
+ padding: calc(var(--schematic-card-padding) * 0.4375)
2717
+ var(--schematic-card-padding);
2718
+ }
2719
+
2720
+ .schematic-metered-features .schematic-skeleton__cell[data-column="name"] {
2721
+ width: 10rem;
2722
+ }
2723
+
2724
+ .schematic-metered-features .schematic-skeleton__cell[data-column="usage"] {
2725
+ width: 6rem;
2726
+ }
2727
+
2728
+ .schematic-metered-features__meter {
2729
+ align-items: center;
2730
+ display: flex;
2731
+ gap: var(--schematic-space);
2732
+ }
2733
+
2734
+ .schematic-metered-features__meter .schematic-meter {
2735
+ flex-grow: 1;
2736
+ min-width: 6rem;
2737
+ }
2738
+
2739
+ .schematic-meter--tier {
2740
+ background: color-mix(in srgb, var(--schematic-accent) 50%, transparent);
2741
+ }
2742
+
2743
+ /* Past the soft limit, the fill is the included share over a warning track. */
2744
+ .schematic-meter--overage {
2745
+ background: var(--schematic-warning);
2746
+ }
2747
+
2748
+ .schematic-metered-features__meter-label {
2749
+ font-size: 0.875rem;
2750
+ font-variant-numeric: tabular-nums;
2751
+ font-weight: 500;
2752
+ white-space: nowrap;
2753
+ }
2754
+
2755
+ .schematic-usage-by-user {
2756
+ align-items: flex-start;
2757
+ display: flex;
2758
+ flex-direction: column;
2759
+ gap: 0.25rem;
2760
+ }
2761
+
2762
+ .schematic-usage-by-user__title {
2763
+ font-family: var(--schematic-font-heading);
2764
+ font-size: 1.125rem;
2765
+ font-weight: 800;
2766
+ }
2767
+
2768
+ .schematic-usage-by-user__list {
2769
+ align-self: stretch;
2770
+ list-style: none;
2771
+ margin: 0.5rem 0 0;
2772
+ padding: 0;
2773
+ }
2774
+
2775
+ .schematic-usage-by-user__user {
2776
+ align-items: center;
2777
+ display: flex;
2778
+ gap: 0.75rem;
2779
+ padding: 0.5rem 0;
2780
+ }
2781
+
2782
+ .schematic-usage-by-user__avatar {
2783
+ align-items: center;
2784
+ background: var(--schematic-surface);
2785
+ border-radius: 9999px;
2786
+ display: inline-flex;
2787
+ flex-shrink: 0;
2788
+ font-size: 0.6875rem;
2789
+ font-weight: 500;
2790
+ height: 1.75rem;
2791
+ justify-content: center;
2792
+ width: 1.75rem;
2793
+ }
2794
+
2795
+ .schematic-usage-by-user__name {
2796
+ flex-grow: 1;
2797
+ overflow: hidden;
2798
+ text-overflow: ellipsis;
2799
+ white-space: nowrap;
2800
+ }
2801
+
2802
+ .schematic-usage-by-user__amount {
2803
+ text-align: end;
2804
+ }
2805
+
2806
+ .schematic-usage-by-user__toggle {
2807
+ align-items: center;
2808
+ display: inline-flex;
2809
+ gap: 0.25rem;
2810
+ }
2811
+
2812
+ .schematic-usage-by-user__toggle .schematic-chevron {
2813
+ margin-inline-start: -0.333rem;
2814
+ }
2815
+ `;
2816
+
2817
+ // src/elements/styles/payment-methods.ts
2818
+ var paymentMethodsCss = `
2819
+ .schematic-payment-methods {
2820
+ display: flex;
2821
+ flex-direction: column;
2822
+ gap: var(--schematic-space);
2823
+ }
2824
+
2825
+ .schematic-payment-methods .schematic-header {
2826
+ align-items: center;
2827
+ margin-bottom: 0;
2828
+ }
2829
+
2830
+ .schematic-payment-methods__expiry-warning {
2831
+ color: var(--schematic-danger);
2832
+ white-space: nowrap;
2833
+ }
2834
+
2835
+ /* The pill: the default method on the left, Edit or Add on the right. */
2836
+ .schematic-payment-methods__current {
2837
+ align-items: center;
2838
+ background: var(--schematic-surface);
2839
+ border-radius: 9999px;
2840
+ display: flex;
2841
+ gap: var(--schematic-space);
2842
+ justify-content: space-between;
2843
+ padding: calc(var(--schematic-space) / 2.25) var(--schematic-space);
2844
+ }
2845
+
2846
+ /* One line: a label too long for the space truncates rather than wrapping
2847
+ "Card ending in" away from its digits or widening the dialog. */
2848
+ .schematic-payment-methods__method {
2849
+ align-items: center;
2850
+ display: inline-flex;
2851
+ flex-grow: 1;
2852
+ gap: 0.25em;
2853
+ min-width: 0;
2854
+ }
2855
+
2856
+ .schematic-payment-methods__label {
2857
+ min-width: 0;
2858
+ overflow: hidden;
2859
+ text-overflow: ellipsis;
2860
+ white-space: nowrap;
2861
+ }
2862
+
2863
+ /* The brand's mark before the label, in the label's colour. */
2864
+ .schematic-payment-methods__icon {
2865
+ color: currentColor;
2866
+ flex-shrink: 0;
2867
+ font-size: 1.5em;
2868
+ margin-inline-end: calc(var(--schematic-space) / 4);
2869
+ }
2870
+
2871
+ .schematic-payment-methods__last4 {
2872
+ flex-shrink: 0;
2873
+ font-variant-numeric: tabular-nums;
2874
+ }
2875
+
2876
+ .schematic-payment-methods__empty {
2877
+ flex-grow: 1;
2878
+ }
2879
+
2880
+ .schematic-payment-methods__edit,
2881
+ .schematic-payment-methods__remove-current {
2882
+ flex-shrink: 0;
2883
+ white-space: nowrap;
2884
+ }
2885
+
2886
+ /* The toggle that reveals the other methods. Its chevron is a glyph per
2887
+ state, down while folded and up while unfolded, and the hover underline
2888
+ goes on the label alone, as on every toggle. */
2011
2889
  .schematic-payment-methods__choose {
2012
2890
  align-items: center;
2013
2891
  align-self: flex-start;
2014
2892
  display: inline-flex;
2893
+ /* A button centres its text; a label that wraps on a phone keeps to the
2894
+ start. */
2895
+ text-align: start;
2015
2896
  gap: calc(var(--schematic-space) / 2);
2016
2897
  }
2017
2898
 
@@ -2023,10 +2904,6 @@ var paymentMethodsCss = `
2023
2904
  text-decoration: underline;
2024
2905
  }
2025
2906
 
2026
- .schematic-payment-methods__chevron {
2027
- color: var(--schematic-text);
2028
- font-size: 1.5em;
2029
- }
2030
2907
 
2031
2908
  /* A faintly tinted panel, roomier than the shared dialog body, with its
2032
2909
  parts spaced further apart. */
@@ -2070,6 +2947,12 @@ var paymentMethodsCss = `
2070
2947
  padding: calc(var(--schematic-space) / 2) 0;
2071
2948
  }
2072
2949
 
2950
+ /* The name takes the line's room first; the actions wrap under it before
2951
+ the name is cut short. */
2952
+ .schematic-payment-methods__row .schematic-payment-methods__method {
2953
+ flex: 1 1 10rem;
2954
+ }
2955
+
2073
2956
  .schematic-payment-methods__expires {
2074
2957
  flex-grow: 1;
2075
2958
  font-variant-numeric: tabular-nums;
@@ -2143,23 +3026,31 @@ var paymentMethodsCss = `
2143
3026
  white-space: nowrap;
2144
3027
  }
2145
3028
 
3029
+ /* Spaced as the embed's form: 24px between parts, and a wider break before
3030
+ Save under the address. */
2146
3031
  .schematic-payment-methods__form {
2147
3032
  display: flex;
2148
3033
  flex-direction: column;
2149
- gap: var(--schematic-space);
3034
+ gap: calc(var(--schematic-space) * 1.5);
2150
3035
  }
2151
3036
 
2152
- /* The fields the checkout settings add beside Stripe's own. */
3037
+ .schematic-payment-methods__address {
3038
+ margin-bottom: calc(var(--schematic-space) * 2);
3039
+ }
3040
+
3041
+ /* The fields the checkout settings add beside Stripe's own, labelled as
3042
+ Stripe's are. */
2153
3043
  .schematic-payment-methods__field {
2154
3044
  display: flex;
2155
3045
  flex-direction: column;
2156
- gap: calc(var(--schematic-space) / 2);
3046
+ gap: calc(var(--schematic-space) * 0.75);
2157
3047
  }
2158
3048
 
2159
3049
  .schematic-payment-methods__input {
2160
3050
  background: var(--schematic-background);
2161
3051
  border: 1px solid var(--schematic-border);
2162
- border-radius: var(--schematic-radius);
3052
+ /* The embed's 8px at the default radius; Stripe's fields take the same. */
3053
+ border-radius: calc(var(--schematic-radius) * 0.8);
2163
3054
  box-sizing: border-box;
2164
3055
  color: var(--schematic-text);
2165
3056
  font: inherit;
@@ -2190,6 +3081,83 @@ var paymentMethodsCss = `
2190
3081
  // src/elements/styles/index.tsx
2191
3082
  init_tokens();
2192
3083
 
3084
+ // src/elements/styles/tooltip.ts
3085
+ var tooltipCss = `
3086
+ .schematic-tooltip {
3087
+ display: inline-block;
3088
+ margin-inline-start: 0.25rem;
3089
+ position: relative;
3090
+ vertical-align: middle;
3091
+ }
3092
+
3093
+ .schematic-tooltip__trigger {
3094
+ background: none;
3095
+ border: 0;
3096
+ color: var(--schematic-muted);
3097
+ cursor: help;
3098
+ /* A button keeps the browser's control font; the glyph is the embed's
3099
+ 24px. */
3100
+ font-size: 1.5rem;
3101
+ line-height: 0;
3102
+ padding: 0;
3103
+ }
3104
+
3105
+ .schematic-tooltip__trigger:focus-visible {
3106
+ outline: 2px solid var(--schematic-accent);
3107
+ outline-offset: 2px;
3108
+ }
3109
+
3110
+ .schematic-tooltip__content {
3111
+ background: var(--schematic-background);
3112
+ border: 1px solid var(--schematic-border);
3113
+ border-radius: calc(var(--schematic-radius) / 2);
3114
+ bottom: calc(100% + 0.5rem);
3115
+ box-shadow: var(--schematic-shadow);
3116
+ color: var(--schematic-text);
3117
+ font-size: 0.875rem;
3118
+ inset-inline-end: 0;
3119
+ padding: 0.5rem 0.75rem;
3120
+ pointer-events: none;
3121
+ position: absolute;
3122
+ text-align: start;
3123
+ visibility: hidden;
3124
+ white-space: nowrap;
3125
+ z-index: 1;
3126
+ }
3127
+
3128
+ .schematic-tooltip:hover .schematic-tooltip__content,
3129
+ .schematic-tooltip:focus-within .schematic-tooltip__content {
3130
+ visibility: visible;
3131
+ }
3132
+
3133
+ .schematic-tiers {
3134
+ display: flex;
3135
+ flex-direction: column;
3136
+ gap: 0.5rem;
3137
+ }
3138
+
3139
+ .schematic-tiers__list {
3140
+ margin: 0;
3141
+ }
3142
+
3143
+ .schematic-tiers__tier {
3144
+ display: flex;
3145
+ gap: var(--schematic-space);
3146
+ justify-content: space-between;
3147
+ padding: 0.25rem 0;
3148
+ }
3149
+
3150
+ .schematic-tiers__price {
3151
+ margin: 0;
3152
+ }
3153
+
3154
+ .schematic-tiers__mode {
3155
+ border-top: 1px solid var(--schematic-border);
3156
+ padding-top: 0.5rem;
3157
+ white-space: normal;
3158
+ }
3159
+ `;
3160
+
2193
3161
  // src/elements/styles/upcoming-bill.ts
2194
3162
  var upcomingBillCss = `
2195
3163
  .schematic-upcoming-bill {
@@ -2202,10 +3170,6 @@ var upcomingBillCss = `
2202
3170
  margin-bottom: 0;
2203
3171
  }
2204
3172
 
2205
- .schematic-upcoming-bill .schematic-header__title {
2206
- margin-bottom: 0;
2207
- }
2208
-
2209
3173
  .schematic-upcoming-bill__amount {
2210
3174
  align-items: flex-start;
2211
3175
  display: flex;
@@ -2215,14 +3179,14 @@ var upcomingBillCss = `
2215
3179
 
2216
3180
  .schematic-upcoming-bill__total {
2217
3181
  font-family: var(--schematic-font-heading);
2218
- font-size: 1.8125rem;
3182
+ font-size: 2.3125rem;
2219
3183
  font-variant-numeric: tabular-nums;
2220
3184
  font-weight: 800;
2221
3185
  line-height: 1;
2222
3186
  }
2223
3187
 
2224
3188
  .schematic-upcoming-bill__estimate {
2225
- font-weight: 600;
3189
+ color: var(--schematic-muted);
2226
3190
  max-width: 10rem;
2227
3191
  text-align: end;
2228
3192
  }
@@ -2288,6 +3252,21 @@ var rulesCss = `
2288
3252
  margin: 0;
2289
3253
  }
2290
3254
 
3255
+ /* Unit suffixes ("/mo", "/seat") sit on the baseline, as in the embed. */
3256
+ :where([class^="schematic-"]) sub,
3257
+ :where([class^="schematic-"]) sup {
3258
+ line-height: 1;
3259
+ position: static;
3260
+ }
3261
+
3262
+ :where([class^="schematic-"]) sub {
3263
+ vertical-align: baseline;
3264
+ }
3265
+
3266
+ :where([class^="schematic-"]) sup {
3267
+ vertical-align: top;
3268
+ }
3269
+
2291
3270
  .schematic-card {
2292
3271
  background: var(--schematic-background);
2293
3272
  border-radius: var(--schematic-radius);
@@ -2383,6 +3362,7 @@ var rulesCss = `
2383
3362
 
2384
3363
  .schematic-error {
2385
3364
  color: var(--schematic-danger);
3365
+ font-weight: 500;
2386
3366
  }
2387
3367
 
2388
3368
  .schematic-status-note {
@@ -2445,10 +3425,26 @@ var rulesCss = `
2445
3425
  border-color: var(--schematic-primary);
2446
3426
  }
2447
3427
 
3428
+ /* The embed's small button: 15px type, 40px tall. */
2448
3429
  .schematic-cta--small {
3430
+ border-radius: 0.375rem;
2449
3431
  font-size: 0.9375rem;
2450
3432
  min-height: 2.5rem;
2451
- padding: 0.375rem 1rem;
3433
+ padding: 0.4375rem 1.25rem;
3434
+ }
3435
+
3436
+ /* The embed's ghost button, for secondary actions such as Try again. */
3437
+ .schematic-cta--ghost {
3438
+ background: transparent;
3439
+ border-color: color-mix(in srgb, var(--schematic-text) 20%, transparent);
3440
+ color: var(--schematic-text);
3441
+ }
3442
+
3443
+ .schematic-cta--ghost:hover:not(:disabled) {
3444
+ background: transparent;
3445
+ border-color: color-mix(in srgb, var(--schematic-text) 12.5%, transparent);
3446
+ box-shadow: 0 1px 2px
3447
+ color-mix(in srgb, var(--schematic-text) 7.5%, transparent);
2452
3448
  }
2453
3449
 
2454
3450
  .schematic-link-button {
@@ -2465,6 +3461,27 @@ var rulesCss = `
2465
3461
  text-decoration: underline;
2466
3462
  }
2467
3463
 
3464
+ /* Every toggle's chevron: the 24px glyph, muted. */
3465
+ .schematic-chevron {
3466
+ color: var(--schematic-muted);
3467
+ font-size: 1.5rem;
3468
+ }
3469
+
3470
+ /* A toggle underlines its label alone: a flex container hands its underline
3471
+ to every item, the chevron included, and an item cannot take it off. */
3472
+ .schematic-link-button:has(.schematic-link-button__label):hover {
3473
+ text-decoration: none;
3474
+ }
3475
+
3476
+ /* The reset colours every schematic- element; the label keeps the link's. */
3477
+ .schematic-link-button__label {
3478
+ color: inherit;
3479
+ }
3480
+
3481
+ .schematic-link-button:hover .schematic-link-button__label {
3482
+ text-decoration: underline;
3483
+ }
3484
+
2468
3485
  .schematic-meter {
2469
3486
  background: var(--schematic-meter-track);
2470
3487
  border-radius: 9999px;
@@ -2554,7 +3571,7 @@ var rulesCss = `
2554
3571
  font-size: 1.125rem;
2555
3572
  font-weight: 800;
2556
3573
  line-height: var(--schematic-line-height-heading);
2557
- margin: 0 0 calc(var(--schematic-space) / 2);
3574
+ margin: 0;
2558
3575
  }
2559
3576
 
2560
3577
  /* A label on the left, its value on the right. */
@@ -2762,13 +3779,16 @@ ${dialogCss}
2762
3779
  ${invoicesCss}
2763
3780
  ${upcomingBillCss}
2764
3781
  ${paymentMethodsCss}
3782
+ ${tooltipCss}
3783
+ ${includedFeaturesCss}
3784
+ ${meteredFeaturesCss}
2765
3785
  `;
2766
3786
  var schematicStylesCss = withTokenDefaults(rulesCss) + iconsCss;
2767
3787
  var SchematicStyles = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { "data-schematic-styles": "", children: schematicStylesCss });
2768
3788
 
2769
- // src/elements/Invoices.tsx
3789
+ // src/elements/IncludedFeatures.tsx
2770
3790
  var import_schematic_react2 = require("@schematichq/schematic-react");
2771
- var import_react2 = require("react");
3791
+ var import_react3 = require("react");
2772
3792
 
2773
3793
  // src/elements/common.tsx
2774
3794
  var import_schematic_react = require("@schematichq/schematic-react");
@@ -2857,7 +3877,7 @@ var StatusFrame = ({
2857
3877
  onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2858
3878
  "button",
2859
3879
  {
2860
- className: "schematic-link-button schematic-status__retry",
3880
+ className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-status__retry",
2861
3881
  type: "button",
2862
3882
  onClick: onRetry,
2863
3883
  children: retryText
@@ -2876,6 +3896,28 @@ var StatusFrame = ({
2876
3896
  error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "schematic-status-note schematic-error", role: "alert", children: errorMessage ?? error.message })
2877
3897
  ] });
2878
3898
  };
3899
+ var Tooltip = ({ children, className, label }) => {
3900
+ const id = (0, import_react.useId)();
3901
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: cx("schematic-tooltip", className), children: [
3902
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3903
+ "button",
3904
+ {
3905
+ "aria-describedby": id,
3906
+ "aria-label": label,
3907
+ className: "schematic-tooltip__trigger",
3908
+ type: "button",
3909
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3910
+ "i",
3911
+ {
3912
+ "aria-hidden": "true",
3913
+ className: "schematic-icon schematic-icon--info-rounded"
3914
+ }
3915
+ )
3916
+ }
3917
+ ),
3918
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "schematic-tooltip__content", id, role: "tooltip", children })
3919
+ ] });
3920
+ };
2879
3921
  var Dialog = ({ children, className, closeLabel, onClose, open, title, titleId }) => {
2880
3922
  const ref = (0, import_react.useRef)(null);
2881
3923
  const generatedId = (0, import_react.useId)();
@@ -2889,46 +3931,447 @@ var Dialog = ({ children, className, closeLabel, onClose, open, title, titleId }
2889
3931
  if (!open) {
2890
3932
  return null;
2891
3933
  }
2892
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2893
- "dialog",
3934
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
3935
+ "dialog",
3936
+ {
3937
+ "aria-labelledby": headingId,
3938
+ className: cx("schematic-dialog", className),
3939
+ ref,
3940
+ onClick: (event) => {
3941
+ if (event.target === event.currentTarget) {
3942
+ onClose();
3943
+ }
3944
+ },
3945
+ onClose,
3946
+ children: [
3947
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "schematic-dialog__header", children: [
3948
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: "schematic-dialog__title", id: headingId, children: title }),
3949
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3950
+ "button",
3951
+ {
3952
+ "aria-label": closeLabel,
3953
+ className: "schematic-dialog__close",
3954
+ type: "button",
3955
+ onClick: onClose,
3956
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3957
+ "i",
3958
+ {
3959
+ "aria-hidden": "true",
3960
+ className: "schematic-icon schematic-icon--close"
3961
+ }
3962
+ )
3963
+ }
3964
+ )
3965
+ ] }),
3966
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "schematic-dialog__body", children })
3967
+ ]
3968
+ }
3969
+ );
3970
+ };
3971
+
3972
+ // src/elements/usage.tsx
3973
+ var import_react2 = require("react");
3974
+ var import_jsx_runtime3 = require("react/jsx-runtime");
3975
+ var COLLAPSED_USER_COUNT = 3;
3976
+ var EXPANDED_USER_COUNT = 20;
3977
+ function shortPeriod(period, t) {
3978
+ switch (period) {
3979
+ case "month":
3980
+ return t("periodMonthShort");
3981
+ case "quarter":
3982
+ return t("periodQuarterShort");
3983
+ case "year":
3984
+ return t("periodYearShort");
3985
+ default:
3986
+ return void 0;
3987
+ }
3988
+ }
3989
+ function PriceTiers({
3990
+ currency,
3991
+ locale,
3992
+ mode,
3993
+ period,
3994
+ ranges,
3995
+ t,
3996
+ unit
3997
+ }) {
3998
+ const perPeriod = period === null ? void 0 : shortPeriod(period, t);
3999
+ const money = (amount) => formatCurrency(amount, currency, locale);
4000
+ const perUnit = (amount) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
4001
+ money(amount),
4002
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("sub", { children: [
4003
+ "/",
4004
+ unit
4005
+ ] })
4006
+ ] });
4007
+ const flat = (amount) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
4008
+ money(amount),
4009
+ perPeriod !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("sub", { children: [
4010
+ "/",
4011
+ perPeriod
4012
+ ] })
4013
+ ] });
4014
+ const tierPrice = (flatPrice, perUnitPrice) => {
4015
+ if (flatPrice === 0 && perUnitPrice !== 0) {
4016
+ return perUnit(perUnitPrice);
4017
+ }
4018
+ if (flatPrice !== 0 && perUnitPrice === 0) {
4019
+ return flat(flatPrice);
4020
+ }
4021
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
4022
+ perUnit(perUnitPrice),
4023
+ " + ",
4024
+ flat(flatPrice)
4025
+ ] });
4026
+ };
4027
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "schematic-tiers", children: [
4028
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dl", { className: "schematic-tiers__list", children: ranges.map((tier) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-tiers__tier", children: [
4029
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dt", { className: "schematic-tiers__range", children: [
4030
+ tier.from,
4031
+ tier.to === null ? "+" : tier.to !== tier.from ? `\u2013${tier.to}` : ""
4032
+ ] }),
4033
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { className: "schematic-tiers__price", children: tierPrice(tier.flatPrice ?? 0, tier.perUnitPrice ?? 0) })
4034
+ ] }, tier.from)) }),
4035
+ mode !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-tiers__mode", children: mode === "volume" ? t("usageTiersVolume") : t("usageTiersGraduated") })
4036
+ ] });
4037
+ }
4038
+ function UserBreakdown({
4039
+ breakdown,
4040
+ error,
4041
+ locale,
4042
+ onRetry,
4043
+ t,
4044
+ unit
4045
+ }) {
4046
+ const [expanded, setExpanded] = (0, import_react2.useState)(false);
4047
+ const users = (0, import_react2.useMemo)(
4048
+ () => [...breakdown?.users ?? []].sort((a, b) => b.amount - a.amount),
4049
+ [breakdown?.users]
4050
+ );
4051
+ const amount = (value) => `${formatNumber(value, locale)} ${featureName(unit, value, locale)}`;
4052
+ if (breakdown === void 0 && error !== void 0) {
4053
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-usage-by-user", role: "alert", children: [
4054
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-usage-by-user__title", children: t("usageByUserHeader") }),
4055
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-error", children: t("usageByUserError") }),
4056
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4057
+ "button",
4058
+ {
4059
+ className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-status__retry",
4060
+ type: "button",
4061
+ onClick: onRetry,
4062
+ children: t("retry")
4063
+ }
4064
+ )
4065
+ ] });
4066
+ }
4067
+ const unattributed = breakdown?.unattributed ?? null;
4068
+ if (breakdown === void 0 || users.length === 0 && unattributed === null) {
4069
+ return null;
4070
+ }
4071
+ const visible = users.slice(
4072
+ 0,
4073
+ expanded ? EXPANDED_USER_COUNT : COLLAPSED_USER_COUNT
4074
+ );
4075
+ const remaining = Math.max(breakdown.count - visible.length, 0);
4076
+ const hidden = Math.max(
4077
+ Math.min(breakdown.count, EXPANDED_USER_COUNT) - Math.min(users.length, COLLAPSED_USER_COUNT),
4078
+ 0
4079
+ );
4080
+ const expandLabel = breakdown.count > EXPANDED_USER_COUNT ? t("usageByUserShowTop", {
4081
+ count: EXPANDED_USER_COUNT,
4082
+ shown: formatNumber(EXPANDED_USER_COUNT, locale)
4083
+ }) : hidden > 0 ? t("usageByUserShowAllCount", {
4084
+ count: breakdown.count,
4085
+ shown: formatNumber(breakdown.count, locale)
4086
+ }) : t("usageByUserShowAll");
4087
+ const user = (key, label, value, muted = false) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "schematic-usage-by-user__user", children: [
4088
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": "true", className: "schematic-usage-by-user__avatar", children: muted ? "?" : (label.trim()[0] ?? "?").toUpperCase() }),
4089
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4090
+ "span",
4091
+ {
4092
+ className: cx(
4093
+ "schematic-usage-by-user__name",
4094
+ muted && "schematic-muted"
4095
+ ),
4096
+ children: label
4097
+ }
4098
+ ),
4099
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-muted schematic-usage-by-user__amount", children: amount(value) })
4100
+ ] }, key);
4101
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-usage-by-user", children: [
4102
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-usage-by-user__title", children: t("usageByUserHeader") }),
4103
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-muted", children: t("usageByUserTotal", { amount: amount(breakdown.total) }) }),
4104
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("ul", { className: "schematic-usage-by-user__list", children: [
4105
+ visible.map((entry) => user(entry.id, entry.label, entry.amount)),
4106
+ expanded && unattributed !== null && user(
4107
+ "unattributed",
4108
+ t("usageByUserUnattributed"),
4109
+ unattributed,
4110
+ true
4111
+ )
4112
+ ] }),
4113
+ expanded && remaining > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-muted", children: t("usageByUserMore", {
4114
+ count: remaining,
4115
+ shown: formatNumber(remaining, locale)
4116
+ }) }),
4117
+ (hidden > 0 || unattributed !== null) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4118
+ "button",
4119
+ {
4120
+ "aria-expanded": expanded,
4121
+ className: "schematic-link-button schematic-usage-by-user__toggle",
4122
+ type: "button",
4123
+ onClick: () => setExpanded((value) => !value),
4124
+ children: [
4125
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4126
+ "i",
4127
+ {
4128
+ "aria-hidden": "true",
4129
+ className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
4130
+ }
4131
+ ),
4132
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("usageByUserShowFewer") : expandLabel })
4133
+ ]
4134
+ }
4135
+ )
4136
+ ] });
4137
+ }
4138
+
4139
+ // src/elements/IncludedFeatures.tsx
4140
+ var import_jsx_runtime4 = require("react/jsx-runtime");
4141
+ var VISIBLE_FEATURE_COUNT = 4;
4142
+ function IncludedFeatures({
4143
+ className,
4144
+ headingLevel = 2,
4145
+ locale: localeProp,
4146
+ showCredits = true,
4147
+ showDescription = true,
4148
+ showEntitlement = true,
4149
+ showExpiration = true,
4150
+ showHardLimit = false,
4151
+ showHeader = true,
4152
+ showIcon = true,
4153
+ showUsage = true,
4154
+ showWarningThresholdAsLimit = false,
4155
+ strings,
4156
+ visibleFeatures
4157
+ }) {
4158
+ const { data: features, error, isPending, refetch } = (0, import_schematic_react2.useFeatureUsage)();
4159
+ const locale = useResolvedLocale(localeProp);
4160
+ const t = useTranslator(strings, localeProp);
4161
+ const [expanded, setExpanded] = (0, import_react3.useState)(false);
4162
+ const rows = (0, import_react3.useMemo)(
4163
+ () => features === void 0 ? [] : deriveIncludedFeatures(features, {
4164
+ locale,
4165
+ showCredits,
4166
+ showWarningThresholdAsLimit,
4167
+ visibleFeatures
4168
+ }),
4169
+ [
4170
+ features,
4171
+ locale,
4172
+ showCredits,
4173
+ showWarningThresholdAsLimit,
4174
+ visibleFeatures
4175
+ ]
4176
+ );
4177
+ const Heading = `h${headingLevel}`;
4178
+ const canExpand = rows.length > VISIBLE_FEATURE_COUNT;
4179
+ const shown = canExpand && !expanded ? rows.slice(0, VISIBLE_FEATURE_COUNT) : rows;
4180
+ const unavailable = features === void 0 && httpStatus(error) === 404;
4181
+ const errorMessage = error === void 0 ? void 0 : unavailable ? t("includedFeaturesUnavailable") : t("includedFeaturesError");
4182
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
4183
+ StatusFrame,
2894
4184
  {
2895
- "aria-labelledby": headingId,
2896
- className: cx("schematic-dialog", className),
2897
- ref,
2898
- onClick: (event) => {
2899
- if (event.target === event.currentTarget) {
2900
- onClose();
2901
- }
2902
- },
2903
- onClose,
4185
+ className: cx("schematic-card", "schematic-included-features", className),
4186
+ error,
4187
+ errorMessage,
4188
+ hasData: features !== void 0,
4189
+ isPending,
4190
+ loadingLabel: t("includedFeaturesLoading"),
4191
+ onRetry: refetch,
4192
+ retryText: t("retry"),
4193
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IncludedFeaturesSkeleton, { showHeader }),
2904
4194
  children: [
2905
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "schematic-dialog__header", children: [
2906
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: "schematic-dialog__title", id: headingId, children: title }),
2907
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2908
- "button",
2909
- {
2910
- "aria-label": closeLabel,
2911
- className: "schematic-dialog__close",
2912
- type: "button",
2913
- onClick: onClose,
2914
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4195
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Heading, { className: "schematic-header__title", children: t("includedFeaturesHeader") }) }),
4196
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "schematic-included-features__list", children: shown.map((row) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
4197
+ "li",
4198
+ {
4199
+ className: "schematic-included-features__row",
4200
+ "data-testid": "schematic-included-feature",
4201
+ children: [
4202
+ showIcon && row.icon !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2915
4203
  "i",
2916
4204
  {
2917
4205
  "aria-hidden": "true",
2918
- className: "schematic-icon schematic-icon--close"
4206
+ className: `schematic-icon schematic-icon--${row.icon} schematic-included-features__icon`
4207
+ }
4208
+ ),
4209
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-included-features__details", children: [
4210
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-included-features__name", children: row.name }),
4211
+ showDescription && row.description !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-muted schematic-small", children: row.description }),
4212
+ row.perLicenseCredits.map((credits, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4213
+ "span",
4214
+ {
4215
+ className: "schematic-muted schematic-small",
4216
+ children: t("includedFeaturesPerLicense", {
4217
+ amount: credits.amount,
4218
+ creditName: credits.creditName,
4219
+ licenseName: credits.licenseName
4220
+ })
4221
+ },
4222
+ `${credits.creditName}-${index}`
4223
+ )),
4224
+ showExpiration && row.expiresAt !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("em", { className: "schematic-muted schematic-small", children: t("includedFeaturesExpires", { date: row.expiresAt.text }) })
4225
+ ] }),
4226
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4227
+ UsageDetails,
4228
+ {
4229
+ row,
4230
+ showEntitlement,
4231
+ showHardLimit,
4232
+ showUsage,
4233
+ t,
4234
+ locale
2919
4235
  }
2920
4236
  )
2921
- }
2922
- )
2923
- ] }),
2924
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "schematic-dialog__body", children })
4237
+ ]
4238
+ },
4239
+ row.featureId
4240
+ )) }),
4241
+ canExpand && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
4242
+ "button",
4243
+ {
4244
+ "aria-expanded": expanded,
4245
+ className: "schematic-link-button schematic-included-features__toggle",
4246
+ type: "button",
4247
+ onClick: () => setExpanded((value) => !value),
4248
+ children: [
4249
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4250
+ "i",
4251
+ {
4252
+ "aria-hidden": "true",
4253
+ className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
4254
+ }
4255
+ ),
4256
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("includedFeaturesHideAll") : t("includedFeaturesSeeAll") })
4257
+ ]
4258
+ }
4259
+ )
2925
4260
  ]
2926
4261
  }
2927
4262
  );
2928
- };
4263
+ }
4264
+ function UsageDetails({
4265
+ locale,
4266
+ row,
4267
+ showEntitlement,
4268
+ showHardLimit,
4269
+ showUsage,
4270
+ t
4271
+ }) {
4272
+ const usage = usageText(row.usage, row.usageSummary, t);
4273
+ if (row.entitlement === null && usage === null) {
4274
+ return null;
4275
+ }
4276
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-included-features__usage", children: [
4277
+ showEntitlement && row.entitlement !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "schematic-included-features__entitlement", children: [
4278
+ entitlementText2(row.entitlement, t),
4279
+ showHardLimit && row.hardLimit !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
4280
+ amount: row.hardLimit.amount,
4281
+ units: row.hardLimit.units
4282
+ }) })
4283
+ ] }),
4284
+ showUsage && usage !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "schematic-muted schematic-small schematic-included-features__used", children: [
4285
+ usage,
4286
+ row.tiers !== null && row.tiers.ranges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4287
+ PriceTiers,
4288
+ {
4289
+ currency: row.tiers.currency,
4290
+ locale,
4291
+ mode: row.tiers.mode,
4292
+ period: row.tiers.period,
4293
+ ranges: row.tiers.ranges,
4294
+ t,
4295
+ unit: row.source.featureSingularName ?? row.name
4296
+ }
4297
+ ) })
4298
+ ] })
4299
+ ] });
4300
+ }
4301
+ function entitlementText2(text, t) {
4302
+ switch (text.kind) {
4303
+ case "units":
4304
+ return t("usageUnits", { amount: text.amount, units: text.units });
4305
+ case "perUnit":
4306
+ return t("usagePerUnit", { cost: text.cost, unit: text.unit });
4307
+ case "perPackage":
4308
+ return t("usagePerPackage", {
4309
+ cost: text.cost,
4310
+ size: text.size,
4311
+ units: text.units
4312
+ });
4313
+ case "tierUpTo":
4314
+ return t("usageTierUpTo", { amount: text.amount, feature: text.feature });
4315
+ case "tierUnlimited":
4316
+ return t("usageTierUnlimited", { feature: text.feature });
4317
+ case "perUse":
4318
+ return t("usagePerUse", { amount: text.amount, units: text.units });
4319
+ case "unlimited":
4320
+ return t("usageUnlimited", { item: text.item });
4321
+ }
4322
+ }
4323
+ function usageText(segments, summary, t) {
4324
+ if (segments.length > 0) {
4325
+ return segments.map((segment) => segmentText(segment, t)).join(" \u2022 ");
4326
+ }
4327
+ if (summary === null) {
4328
+ return null;
4329
+ }
4330
+ return summary.kind === "limited" ? t("usageLimited", {
4331
+ amount: summary.amount,
4332
+ allocation: summary.allocation
4333
+ }) : t("usageUnlimitedUsed", { amount: summary.amount });
4334
+ }
4335
+ function segmentText(segment, t) {
4336
+ switch (segment.kind) {
4337
+ case "unitPricePerPeriod": {
4338
+ const period = shortPeriod(segment.period, t) ?? segment.period;
4339
+ return segment.size > 1 ? t("usagePackagePricePerPeriod", {
4340
+ cost: segment.cost,
4341
+ size: segment.size,
4342
+ units: segment.units,
4343
+ period
4344
+ }) : t("usageUnitPricePerPeriod", {
4345
+ cost: segment.cost,
4346
+ unit: segment.units,
4347
+ period
4348
+ });
4349
+ }
4350
+ case "used":
4351
+ return t("usageUsed", { amount: segment.amount, units: segment.units });
4352
+ case "cost": {
4353
+ const period = segment.period === null ? void 0 : shortPeriod(segment.period, t);
4354
+ return period === void 0 ? segment.cost : `${segment.cost}/${period}`;
4355
+ }
4356
+ case "resets":
4357
+ return t("usageResets", { date: segment.date });
4358
+ }
4359
+ }
4360
+ function IncludedFeaturesSkeleton({ showHeader }) {
4361
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-skeleton", children: [
4362
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__heading" }),
4363
+ [0, 1, 2].map((index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-skeleton__row", children: [
4364
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
4365
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
4366
+ ] }, index))
4367
+ ] });
4368
+ }
4369
+ IncludedFeatures.resources = ["featureUsage"];
2929
4370
 
2930
4371
  // src/elements/Invoices.tsx
2931
- var import_jsx_runtime3 = require("react/jsx-runtime");
4372
+ var import_schematic_react3 = require("@schematichq/schematic-react");
4373
+ var import_react4 = require("react");
4374
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2932
4375
  var SKELETON_ROWS = 4;
2933
4376
  function Invoices({
2934
4377
  className,
@@ -2948,15 +4391,15 @@ function Invoices({
2948
4391
  isPending,
2949
4392
  loadMore,
2950
4393
  refetch
2951
- } = (0, import_schematic_react2.useInvoices)(query);
4394
+ } = (0, import_schematic_react3.useInvoices)(query);
2952
4395
  const locale = useResolvedLocale(localeProp);
2953
4396
  const t = useTranslator(strings, localeProp);
2954
- const [expanded, setExpanded] = (0, import_react2.useState)(false);
2955
- const list = (0, import_react2.useMemo)(
4397
+ const [expanded, setExpanded] = (0, import_react4.useState)(false);
4398
+ const list = (0, import_react4.useMemo)(
2956
4399
  () => page === void 0 ? void 0 : deriveInvoiceList(page, { locale }),
2957
4400
  [locale, page]
2958
4401
  );
2959
- const headingId = (0, import_react2.useId)();
4402
+ const headingId = (0, import_react4.useId)();
2960
4403
  const rows = list?.rows ?? [];
2961
4404
  const canCollapse = collapsible && rows.length > limit;
2962
4405
  const showingAll = !canCollapse || expanded;
@@ -2968,7 +4411,7 @@ function Invoices({
2968
4411
  );
2969
4412
  const unavailable = list === void 0 && httpStatus(error) === 404;
2970
4413
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("invoicesUnavailable") : t("invoicesError");
2971
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4414
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2972
4415
  StatusFrame,
2973
4416
  {
2974
4417
  className: cx("schematic-card", "schematic-invoices", className),
@@ -2979,7 +4422,7 @@ function Invoices({
2979
4422
  loadingLabel: t("invoicesLoading"),
2980
4423
  onRetry: refetch,
2981
4424
  retryText: t("retry"),
2982
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4425
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2983
4426
  InvoicesSkeleton,
2984
4427
  {
2985
4428
  columns,
@@ -2987,22 +4430,22 @@ function Invoices({
2987
4430
  showHeader
2988
4431
  }
2989
4432
  ),
2990
- children: list !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2991
- showHeader && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { className: "schematic-header__title", id: headingId, children: t("invoicesHeader") }) }),
2992
- rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "schematic-muted schematic-invoices__empty", children: t("invoicesEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4433
+ children: list !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
4434
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Heading, { className: "schematic-header__title", id: headingId, children: t("invoicesHeader") }) }),
4435
+ rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "schematic-muted schematic-invoices__empty", children: t("invoicesEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2993
4436
  "ul",
2994
4437
  {
2995
4438
  className: "schematic-invoices__list",
2996
4439
  "aria-label": showHeader ? void 0 : t("invoicesHeader"),
2997
4440
  "aria-labelledby": showHeader ? headingId : void 0,
2998
- children: visible.map((row) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4441
+ children: visible.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2999
4442
  "li",
3000
4443
  {
3001
4444
  className: "schematic-invoices__row",
3002
4445
  "data-testid": "schematic-invoice",
3003
4446
  children: [
3004
- showDate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-invoices__date", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InvoiceDate, { row, t }) }),
3005
- showAmount && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4447
+ showDate && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-invoices__date", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InvoiceDate, { row, t }) }),
4448
+ showAmount && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3006
4449
  "span",
3007
4450
  {
3008
4451
  className: cx(
@@ -3019,8 +4462,8 @@ function Invoices({
3019
4462
  ))
3020
4463
  }
3021
4464
  ),
3022
- (canCollapse || showingAll && list.hasMore) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-invoices__actions", children: [
3023
- canCollapse && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4465
+ (canCollapse || showingAll && list.hasMore) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-invoices__actions", children: [
4466
+ canCollapse && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3024
4467
  "button",
3025
4468
  {
3026
4469
  "aria-expanded": expanded,
@@ -3028,18 +4471,23 @@ function Invoices({
3028
4471
  type: "button",
3029
4472
  onClick: () => setExpanded((value) => !value),
3030
4473
  children: [
3031
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3032
- "span",
4474
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4475
+ "i",
3033
4476
  {
3034
4477
  "aria-hidden": "true",
3035
- className: "schematic-invoices__chevron"
4478
+ className: cx(
4479
+ "schematic-icon",
4480
+ expanded ? "schematic-icon--chevron-up" : "schematic-icon--chevron-down",
4481
+ "schematic-chevron",
4482
+ "schematic-invoices__chevron"
4483
+ )
3036
4484
  }
3037
4485
  ),
3038
- expanded ? t("invoicesSeeLess") : t("invoicesSeeMore")
4486
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("invoicesSeeLess") : t("invoicesSeeMore") })
3039
4487
  ]
3040
4488
  }
3041
4489
  ),
3042
- showingAll && list.hasMore && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4490
+ showingAll && list.hasMore && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3043
4491
  "button",
3044
4492
  {
3045
4493
  className: "schematic-link-button schematic-invoices__load-more",
@@ -3062,9 +4510,9 @@ function InvoicesSkeleton({
3062
4510
  rows,
3063
4511
  showHeader
3064
4512
  }) {
3065
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-skeleton", children: [
3066
- showHeader && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "schematic-skeleton__heading" }),
3067
- Array.from({ length: rows }, (_, row) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "schematic-skeleton__row", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4513
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-skeleton", children: [
4514
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__heading" }),
4515
+ Array.from({ length: rows }, (_, row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__row", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3068
4516
  "div",
3069
4517
  {
3070
4518
  className: "schematic-skeleton__cell",
@@ -3076,10 +4524,10 @@ function InvoicesSkeleton({
3076
4524
  }
3077
4525
  function InvoiceDate({ row, t }) {
3078
4526
  if (row.url === null) {
3079
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-invoices__date-text", children: row.dateText });
4527
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-invoices__date-text", children: row.dateText });
3080
4528
  }
3081
4529
  const label = row.dateText === "" ? t("invoicesUndated") : row.dateText;
3082
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4530
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3083
4531
  "a",
3084
4532
  {
3085
4533
  className: "schematic-invoices__link",
@@ -3092,11 +4540,354 @@ function InvoiceDate({ row, t }) {
3092
4540
  }
3093
4541
  Invoices.resources = ["invoices"];
3094
4542
 
3095
- // src/elements/PaymentMethods.tsx
4543
+ // src/elements/MeteredFeatures.tsx
3096
4544
  var import_schematic_react4 = require("@schematichq/schematic-react");
3097
- var import_react4 = require("react");
3098
- var import_jsx_runtime5 = require("react/jsx-runtime");
3099
- var PaymentMethodForm2 = (0, import_react4.lazy)(() => Promise.resolve().then(() => (init_PaymentMethodForm(), PaymentMethodForm_exports)));
4545
+ var import_react5 = require("react");
4546
+ var import_jsx_runtime6 = require("react/jsx-runtime");
4547
+ function MeteredFeatures({
4548
+ addMoreTarget,
4549
+ addMoreUrl,
4550
+ className,
4551
+ headingLevel = 2,
4552
+ locale: localeProp,
4553
+ onAddMore,
4554
+ showAllocation = true,
4555
+ showCredits = true,
4556
+ showDescription = true,
4557
+ showHardLimit = false,
4558
+ showHeader = false,
4559
+ showIcon = true,
4560
+ showMeter = true,
4561
+ showUsage = true,
4562
+ showUsageByUser = true,
4563
+ showWarningThresholdAsLimit = false,
4564
+ strings,
4565
+ visibleFeatures
4566
+ }) {
4567
+ const { data: features, error, isPending, refetch } = (0, import_schematic_react4.useFeatureUsage)();
4568
+ const locale = useResolvedLocale(localeProp);
4569
+ const t = useTranslator(strings, localeProp);
4570
+ const rows = (0, import_react5.useMemo)(
4571
+ () => features === void 0 ? [] : deriveMeteredFeatures(features, {
4572
+ locale,
4573
+ showCredits,
4574
+ showWarningThresholdAsLimit,
4575
+ visibleFeatures
4576
+ }),
4577
+ [
4578
+ features,
4579
+ locale,
4580
+ showCredits,
4581
+ showWarningThresholdAsLimit,
4582
+ visibleFeatures
4583
+ ]
4584
+ );
4585
+ const unavailable = features === void 0 && httpStatus(error) === 404;
4586
+ const errorMessage = error === void 0 ? void 0 : unavailable ? t("meteredFeaturesUnavailable") : t("meteredFeaturesError");
4587
+ if (features !== void 0 && error === void 0 && rows.length === 0) {
4588
+ return null;
4589
+ }
4590
+ const Heading = `h${headingLevel}`;
4591
+ const NameHeading = showHeader ? `h${Math.min(6, headingLevel + 1)}` : Heading;
4592
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
4593
+ StatusFrame,
4594
+ {
4595
+ className: cx("schematic-metered-features", className),
4596
+ error,
4597
+ errorMessage,
4598
+ hasData: features !== void 0,
4599
+ isPending,
4600
+ loadingLabel: t("meteredFeaturesLoading"),
4601
+ onRetry: refetch,
4602
+ retryText: t("retry"),
4603
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MeteredFeaturesSkeleton, { showHeader }),
4604
+ children: [
4605
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Heading, { className: "schematic-header__title", children: t("meteredFeaturesHeader") }) }),
4606
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "schematic-metered-features__list", children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
4607
+ "li",
4608
+ {
4609
+ className: "schematic-card schematic-metered-features__feature",
4610
+ "data-testid": "schematic-metered-feature",
4611
+ children: [
4612
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__main", children: [
4613
+ showIcon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-metered-features__icon", children: row.icon !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4614
+ "i",
4615
+ {
4616
+ "aria-hidden": "true",
4617
+ className: `schematic-icon schematic-icon--${row.icon}`
4618
+ }
4619
+ ) }),
4620
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__body", children: [
4621
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__top", children: [
4622
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__title", children: [
4623
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(NameHeading, { className: "schematic-metered-features__name", children: row.name }),
4624
+ showDescription && row.description !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "schematic-muted", children: row.description })
4625
+ ] }),
4626
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__figures", children: [
4627
+ showUsage && row.headline !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-metered-features__headline", children: headlineText(row.headline, t) }),
4628
+ showAllocation && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4629
+ LimitLine,
4630
+ {
4631
+ row,
4632
+ showHardLimit,
4633
+ t
4634
+ }
4635
+ )
4636
+ ] })
4637
+ ] }),
4638
+ showMeter && row.meter !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Meter, { meter: row.meter }),
4639
+ row.canAddMore && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4640
+ AddMore,
4641
+ {
4642
+ label: t("meteredFeaturesAddMore"),
4643
+ onAddMore: onAddMore === void 0 ? void 0 : () => onAddMore(row.source),
4644
+ target: addMoreTarget,
4645
+ url: addMoreUrl
4646
+ }
4647
+ )
4648
+ ] })
4649
+ ] }),
4650
+ showUsageByUser && row.hasUsageByUser && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UsageByUser, { locale, row, t }),
4651
+ row.priceDetails !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4652
+ PriceDetails,
4653
+ {
4654
+ details: row.priceDetails,
4655
+ locale,
4656
+ row,
4657
+ t
4658
+ }
4659
+ )
4660
+ ]
4661
+ },
4662
+ row.featureId
4663
+ )) })
4664
+ ]
4665
+ }
4666
+ );
4667
+ }
4668
+ function headlineText(headline2, t) {
4669
+ if (headline2.kind === "used") {
4670
+ return t("meteredFeaturesUsed", {
4671
+ amount: headline2.amount,
4672
+ units: headline2.units
4673
+ });
4674
+ }
4675
+ return headline2.amount === null ? headline2.units : t("usageUnits", { amount: headline2.amount, units: headline2.units });
4676
+ }
4677
+ function limitText(limit, t) {
4678
+ switch (limit.kind) {
4679
+ case "tierUpTo":
4680
+ return t("usageTierUpTo", {
4681
+ amount: limit.amount,
4682
+ feature: limit.feature
4683
+ });
4684
+ case "tierUnlimited":
4685
+ return t("usageTierUnlimited", { feature: limit.feature });
4686
+ case "included":
4687
+ return t("meteredFeaturesIncluded", { amount: limit.amount });
4688
+ case "used":
4689
+ return t("meteredFeaturesInUse", { amount: limit.amount });
4690
+ case "cost":
4691
+ return limit.cost;
4692
+ case "perUse":
4693
+ return t("usagePerUse", { amount: limit.amount, units: limit.units });
4694
+ case "limitOf":
4695
+ return t("meteredFeaturesLimitOf", { amount: limit.amount });
4696
+ case "noLimit":
4697
+ return t("meteredFeaturesNoLimit");
4698
+ }
4699
+ }
4700
+ function LimitLine({
4701
+ row,
4702
+ showHardLimit,
4703
+ t
4704
+ }) {
4705
+ const parts = [];
4706
+ if (row.limit !== null) {
4707
+ parts.push(limitText(row.limit, t));
4708
+ }
4709
+ if (row.resetsAt !== null) {
4710
+ parts.push(t("usageResets", { date: row.resetsAt }));
4711
+ }
4712
+ if (parts.length === 0) {
4713
+ return null;
4714
+ }
4715
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "schematic-muted schematic-metered-features__limit", children: [
4716
+ parts.join(" \u2022 "),
4717
+ showHardLimit && row.hardLimit !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
4718
+ amount: row.hardLimit.amount,
4719
+ units: row.hardLimit.units
4720
+ }) })
4721
+ ] });
4722
+ }
4723
+ var METER_TONE_CLASS = {
4724
+ ok: void 0,
4725
+ warning: "schematic-meter--warning",
4726
+ critical: "schematic-meter--over",
4727
+ tier: "schematic-meter--tier",
4728
+ overage: "schematic-meter--overage"
4729
+ };
4730
+ function Meter({ meter: meter2 }) {
4731
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__meter", children: [
4732
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4733
+ "div",
4734
+ {
4735
+ "aria-valuemax": meter2.total,
4736
+ "aria-valuemin": 0,
4737
+ "aria-valuenow": meter2.value,
4738
+ className: cx("schematic-meter", METER_TONE_CLASS[meter2.tone]),
4739
+ "data-tone": meter2.tone,
4740
+ role: "meter",
4741
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4742
+ "div",
4743
+ {
4744
+ className: "schematic-meter__fill",
4745
+ style: { width: `${meter2.percent}%` }
4746
+ }
4747
+ )
4748
+ }
4749
+ ),
4750
+ meter2.total > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "schematic-metered-features__meter-label", children: [
4751
+ meter2.valueText,
4752
+ "/",
4753
+ meter2.totalText
4754
+ ] })
4755
+ ] });
4756
+ }
4757
+ function AddMore({
4758
+ label,
4759
+ onAddMore,
4760
+ target,
4761
+ url
4762
+ }) {
4763
+ if (onAddMore !== void 0) {
4764
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4765
+ "button",
4766
+ {
4767
+ className: "schematic-cta schematic-metered-features__add-more",
4768
+ type: "button",
4769
+ onClick: onAddMore,
4770
+ children: label
4771
+ }
4772
+ );
4773
+ }
4774
+ if (url !== void 0) {
4775
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4776
+ "a",
4777
+ {
4778
+ className: "schematic-cta schematic-metered-features__add-more",
4779
+ href: url,
4780
+ target,
4781
+ children: label
4782
+ }
4783
+ );
4784
+ }
4785
+ return null;
4786
+ }
4787
+ function PriceDetails({
4788
+ details,
4789
+ locale,
4790
+ row,
4791
+ t
4792
+ }) {
4793
+ const period = details.period === null ? void 0 : shortPeriod(details.period, t);
4794
+ if (details.kind === "overage") {
4795
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__price-details", children: [
4796
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
4797
+ t("meteredFeaturesAdditional"),
4798
+ ": ",
4799
+ details.unitPrice,
4800
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("sub", { children: [
4801
+ "/",
4802
+ details.packageSize > 1 && `${details.packageSize} `,
4803
+ details.units,
4804
+ period !== void 0 && `/${period}`
4805
+ ] })
4806
+ ] }),
4807
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
4808
+ details.overage.amount,
4809
+ " ",
4810
+ details.overage.units,
4811
+ " \xB7 ",
4812
+ details.overage.cost,
4813
+ period !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("sub", { children: [
4814
+ "/",
4815
+ period
4816
+ ] })
4817
+ ] })
4818
+ ] });
4819
+ }
4820
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-metered-features__price-details", children: [
4821
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
4822
+ t("meteredFeaturesTier"),
4823
+ ": ",
4824
+ details.from,
4825
+ details.to === null ? "+" : details.to !== details.from ? `\u2013${details.to}` : "",
4826
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4827
+ PriceTiers,
4828
+ {
4829
+ currency: details.tiers.currency,
4830
+ locale,
4831
+ mode: details.tiers.mode,
4832
+ period: details.period,
4833
+ ranges: details.tiers.ranges,
4834
+ t,
4835
+ unit: featureName(row.unit, 1, locale)
4836
+ }
4837
+ ) })
4838
+ ] }),
4839
+ details.cost !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
4840
+ details.cost,
4841
+ period !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("sub", { children: [
4842
+ "/",
4843
+ period
4844
+ ] })
4845
+ ] })
4846
+ ] });
4847
+ }
4848
+ function UsageByUser({
4849
+ locale,
4850
+ row,
4851
+ t
4852
+ }) {
4853
+ const { data, error, refetch } = (0, import_schematic_react4.useFeatureUserUsage)(row.featureId);
4854
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4855
+ UserBreakdown,
4856
+ {
4857
+ breakdown: data === void 0 ? void 0 : {
4858
+ count: data.count,
4859
+ total: data.total,
4860
+ unattributed: data.unattributed ?? null,
4861
+ users: data.users.map((user) => ({
4862
+ amount: user.usage,
4863
+ id: user.userId,
4864
+ label: user.name ?? user.userId
4865
+ }))
4866
+ },
4867
+ error,
4868
+ locale,
4869
+ onRetry: refetch,
4870
+ t,
4871
+ unit: row.unit
4872
+ }
4873
+ );
4874
+ }
4875
+ function MeteredFeaturesSkeleton({ showHeader }) {
4876
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-skeleton", children: [
4877
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__heading" }),
4878
+ [0, 1].map((index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-skeleton__row", children: [
4879
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
4880
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
4881
+ ] }, index))
4882
+ ] });
4883
+ }
4884
+ MeteredFeatures.resources = ["featureUsage"];
4885
+
4886
+ // src/elements/PaymentMethods.tsx
4887
+ var import_schematic_react6 = require("@schematichq/schematic-react");
4888
+ var import_react7 = require("react");
4889
+ var import_jsx_runtime8 = require("react/jsx-runtime");
4890
+ var PaymentMethodForm2 = (0, import_react7.lazy)(() => Promise.resolve().then(() => (init_PaymentMethodForm(), PaymentMethodForm_exports)));
3100
4891
  function PaymentMethods({
3101
4892
  allowEdit = true,
3102
4893
  checkoutPrefill,
@@ -3117,24 +4908,24 @@ function PaymentMethods({
3117
4908
  refetch,
3118
4909
  remove,
3119
4910
  setDefault
3120
- } = (0, import_schematic_react4.usePaymentMethods)();
4911
+ } = (0, import_schematic_react6.usePaymentMethods)();
3121
4912
  const locale = useResolvedLocale(localeProp);
3122
4913
  const t = useTranslator(strings, localeProp);
3123
- const [dialog, setDialog] = (0, import_react4.useState)(null);
3124
- const [choosing, setChoosing] = (0, import_react4.useState)(false);
3125
- const [lastWrite, setLastWrite] = (0, import_react4.useState)(null);
3126
- const derived = (0, import_react4.useMemo)(
4914
+ const [dialog, setDialog] = (0, import_react7.useState)(null);
4915
+ const [choosing, setChoosing] = (0, import_react7.useState)(false);
4916
+ const [lastWrite, setLastWrite] = (0, import_react7.useState)(null);
4917
+ const derived = (0, import_react7.useMemo)(
3127
4918
  () => methods === void 0 ? void 0 : derivePaymentMethods(methods, { locale }),
3128
4919
  [locale, methods]
3129
4920
  );
3130
- const write = (0, import_react4.useCallback)(async (next) => {
4921
+ const write = (0, import_react7.useCallback)(async (next) => {
3131
4922
  setLastWrite(next);
3132
4923
  try {
3133
4924
  await next.action();
3134
4925
  } catch {
3135
4926
  }
3136
4927
  }, []);
3137
- const saved = (0, import_react4.useCallback)(
4928
+ const saved = (0, import_react7.useCallback)(
3138
4929
  async (paymentMethodId) => {
3139
4930
  await write({
3140
4931
  action: () => setDefault(paymentMethodId),
@@ -3145,16 +4936,16 @@ function PaymentMethods({
3145
4936
  },
3146
4937
  [setDefault, write]
3147
4938
  );
3148
- const open = (0, import_react4.useCallback)(() => {
4939
+ const open = (0, import_react7.useCallback)(() => {
3149
4940
  setLastWrite(null);
3150
4941
  setChoosing(false);
3151
4942
  setDialog("current");
3152
4943
  }, []);
3153
- const close = (0, import_react4.useCallback)(() => setDialog(null), []);
4944
+ const close = (0, import_react7.useCallback)(() => setDialog(null), []);
3154
4945
  const Heading = `h${headingLevel}`;
3155
4946
  const unavailable = derived === void 0 && httpStatus(error) === 404;
3156
4947
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("paymentMethodsUnavailable") : t("paymentMethodsError");
3157
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4948
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3158
4949
  StatusFrame,
3159
4950
  {
3160
4951
  className: cx("schematic-card", "schematic-payment-methods", className),
@@ -3165,9 +4956,9 @@ function PaymentMethods({
3165
4956
  loadingLabel: t("paymentMethodsLoading"),
3166
4957
  onRetry: refetch,
3167
4958
  retryText: t("retry"),
3168
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PaymentMethodsSkeleton, { showHeader }),
3169
- children: derived !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3170
- showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4959
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PaymentMethodsSkeleton, { showHeader }),
4960
+ children: derived !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4961
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3171
4962
  PaymentMethodsHeader,
3172
4963
  {
3173
4964
  derived,
@@ -3176,7 +4967,7 @@ function PaymentMethods({
3176
4967
  t
3177
4968
  }
3178
4969
  ),
3179
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4970
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3180
4971
  "button",
3181
4972
  {
3182
4973
  className: "schematic-link-button schematic-payment-methods__edit",
@@ -3185,7 +4976,7 @@ function PaymentMethods({
3185
4976
  children: derived.current === null ? t("paymentMethodsAdd") : t("paymentMethodsEdit")
3186
4977
  }
3187
4978
  ) }),
3188
- dialog !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4979
+ dialog !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3189
4980
  PaymentMethodsDialog,
3190
4981
  {
3191
4982
  checkoutPrefill,
@@ -3237,7 +5028,7 @@ function PaymentMethodsDialog({
3237
5028
  const { current, others, rows } = derived;
3238
5029
  const hasMethods = rows.length > 0;
3239
5030
  const showForm = view === "add" || !hasMethods;
3240
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
5031
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3241
5032
  Dialog,
3242
5033
  {
3243
5034
  className: "schematic-payment-methods__dialog",
@@ -3246,11 +5037,11 @@ function PaymentMethodsDialog({
3246
5037
  title: t("paymentMethodsDialogTitle"),
3247
5038
  onClose,
3248
5039
  children: [
3249
- showForm ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3250
- import_react4.Suspense,
5040
+ showForm ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
5041
+ import_react7.Suspense,
3251
5042
  {
3252
- fallback: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
3253
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5043
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
5044
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3254
5045
  PaymentMethodForm2,
3255
5046
  {
3256
5047
  checkoutPrefill,
@@ -3262,8 +5053,8 @@ function PaymentMethodsDialog({
3262
5053
  }
3263
5054
  )
3264
5055
  }
3265
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3266
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5056
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
5057
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3267
5058
  PaymentMethodsHeader,
3268
5059
  {
3269
5060
  derived,
@@ -3272,7 +5063,7 @@ function PaymentMethodsDialog({
3272
5063
  t
3273
5064
  }
3274
5065
  ),
3275
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5066
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3276
5067
  "button",
3277
5068
  {
3278
5069
  className: "schematic-link-button schematic-payment-methods__remove-current",
@@ -3282,7 +5073,7 @@ function PaymentMethodsDialog({
3282
5073
  children: t("paymentMethodsRemove")
3283
5074
  }
3284
5075
  ) }),
3285
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
5076
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3286
5077
  "button",
3287
5078
  {
3288
5079
  "aria-expanded": choosing,
@@ -3290,14 +5081,15 @@ function PaymentMethodsDialog({
3290
5081
  type: "button",
3291
5082
  onClick: onChoose,
3292
5083
  children: [
3293
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-payment-methods__choose-label", children: t("paymentMethodsChooseDifferent") }),
3294
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5084
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-payment-methods__choose-label", children: t("paymentMethodsChooseDifferent") }),
5085
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3295
5086
  "i",
3296
5087
  {
3297
5088
  "aria-hidden": "true",
3298
5089
  className: cx(
3299
5090
  "schematic-icon",
3300
5091
  choosing ? "schematic-icon--chevron-up" : "schematic-icon--chevron-down",
5092
+ "schematic-chevron",
3301
5093
  "schematic-payment-methods__chevron"
3302
5094
  )
3303
5095
  }
@@ -3305,13 +5097,13 @@ function PaymentMethodsDialog({
3305
5097
  ]
3306
5098
  }
3307
5099
  ),
3308
- choosing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3309
- others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5100
+ choosing && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
5101
+ others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3310
5102
  "ul",
3311
5103
  {
3312
5104
  "aria-label": t("paymentMethodsChooseDifferent"),
3313
5105
  className: "schematic-payment-methods__list",
3314
- children: others.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
5106
+ children: others.map((row) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3315
5107
  "li",
3316
5108
  {
3317
5109
  className: "schematic-payment-methods__row",
@@ -3319,11 +5111,11 @@ function PaymentMethodsDialog({
3319
5111
  "data-kind": row.kind,
3320
5112
  "data-testid": "schematic-payment-method",
3321
5113
  children: [
3322
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Method, { row, t }),
3323
- row.expiresShort !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-payment-methods__expires", children: t("paymentMethodsExpires", {
5114
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Method, { row, t }),
5115
+ row.expiresShort !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-payment-methods__expires", children: t("paymentMethodsExpires", {
3324
5116
  date: row.expiresShort
3325
5117
  }) }),
3326
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5118
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3327
5119
  "button",
3328
5120
  {
3329
5121
  className: "schematic-link-button schematic-payment-methods__set-default",
@@ -3333,7 +5125,7 @@ function PaymentMethodsDialog({
3333
5125
  children: t("paymentMethodsSetDefault")
3334
5126
  }
3335
5127
  ),
3336
- row.canRemove && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5128
+ row.canRemove && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3337
5129
  "button",
3338
5130
  {
3339
5131
  "aria-label": t("paymentMethodsRemove"),
@@ -3341,7 +5133,7 @@ function PaymentMethodsDialog({
3341
5133
  disabled: isMutating,
3342
5134
  type: "button",
3343
5135
  onClick: () => onRemove(row),
3344
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5136
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3345
5137
  "i",
3346
5138
  {
3347
5139
  "aria-hidden": "true",
@@ -3356,7 +5148,7 @@ function PaymentMethodsDialog({
3356
5148
  ))
3357
5149
  }
3358
5150
  ),
3359
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5151
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3360
5152
  "button",
3361
5153
  {
3362
5154
  className: "schematic-cta schematic-payment-methods__add-new",
@@ -3368,17 +5160,17 @@ function PaymentMethodsDialog({
3368
5160
  )
3369
5161
  ] })
3370
5162
  ] }),
3371
- mutationError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
5163
+ mutationError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3372
5164
  "p",
3373
5165
  {
3374
5166
  className: "schematic-status-note schematic-error schematic-payment-methods__error",
3375
5167
  role: "alert",
3376
5168
  children: [
3377
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-payment-methods__error-message", children: mutationError }),
3378
- onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5169
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-payment-methods__error-message", children: mutationError }),
5170
+ onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3379
5171
  "button",
3380
5172
  {
3381
- className: "schematic-link-button schematic-payment-methods__error-retry",
5173
+ className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-payment-methods__error-retry",
3382
5174
  disabled: isMutating,
3383
5175
  type: "button",
3384
5176
  onClick: onRetry,
@@ -3398,9 +5190,9 @@ function PaymentMethodsHeader({
3398
5190
  showExpiration,
3399
5191
  t
3400
5192
  }) {
3401
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-header", children: [
3402
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Heading, { className: "schematic-header__title", children: t("paymentMethodsHeader") }),
3403
- showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5193
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-header", children: [
5194
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Heading, { className: "schematic-header__title", children: t("paymentMethodsHeader") }),
5195
+ showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3404
5196
  "span",
3405
5197
  {
3406
5198
  className: "schematic-small schematic-payment-methods__expiry-warning",
@@ -3415,37 +5207,37 @@ function MethodPill({
3415
5207
  row,
3416
5208
  t
3417
5209
  }) {
3418
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
5210
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3419
5211
  "div",
3420
5212
  {
3421
5213
  className: "schematic-payment-methods__current",
3422
5214
  "data-testid": "schematic-payment-method-current",
3423
5215
  children: [
3424
- row === null ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-payment-methods__empty", children: t("paymentMethodsEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Method, { row, t }),
5216
+ row === null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-payment-methods__empty", children: t("paymentMethodsEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Method, { row, t }),
3425
5217
  children
3426
5218
  ]
3427
5219
  }
3428
5220
  );
3429
5221
  }
3430
5222
  function Method({ row, t }) {
3431
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
5223
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3432
5224
  "span",
3433
5225
  {
3434
5226
  className: "schematic-payment-methods__method",
3435
5227
  "data-brand": row.brand,
3436
5228
  "data-kind": row.kind,
3437
5229
  children: [
3438
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5230
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3439
5231
  "i",
3440
5232
  {
3441
5233
  "aria-hidden": "true",
3442
5234
  className: `schematic-icon schematic-icon--${row.icon} schematic-payment-methods__icon`
3443
5235
  }
3444
5236
  ),
3445
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-payment-methods__label", children: labelText(row.label, t) }),
3446
- row.last4 !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
5237
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-payment-methods__label", children: labelText(row.label, t) }),
5238
+ row.last4 !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3447
5239
  " ",
3448
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-payment-methods__last4", children: row.last4 })
5240
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-payment-methods__last4", children: row.last4 })
3449
5241
  ] })
3450
5242
  ]
3451
5243
  }
@@ -3459,24 +5251,24 @@ function expiryWarningText(derived, t) {
3459
5251
  return derived.expiryWarning === "expired" ? t("paymentMethodsExpired") : t("paymentMethodsExpiresInMonths", { months });
3460
5252
  }
3461
5253
  function PaymentMethodsSkeleton({ showHeader }) {
3462
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-skeleton", children: [
3463
- showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__heading" }),
3464
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-skeleton__row", children: [
3465
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "method" }),
3466
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "action" })
5254
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-skeleton", children: [
5255
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__heading" }),
5256
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-skeleton__row", children: [
5257
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "method" }),
5258
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "action" })
3467
5259
  ] })
3468
5260
  ] });
3469
5261
  }
3470
5262
  function FormSkeleton({ label }) {
3471
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
5263
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3472
5264
  "div",
3473
5265
  {
3474
5266
  "aria-busy": "true",
3475
5267
  className: "schematic-payment-methods__form",
3476
5268
  "data-state": "pending",
3477
5269
  children: [
3478
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-hidden", children: label }),
3479
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
5270
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-hidden", children: label }),
5271
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
3480
5272
  ]
3481
5273
  }
3482
5274
  );
@@ -3484,9 +5276,9 @@ function FormSkeleton({ label }) {
3484
5276
  PaymentMethods.resources = ["paymentMethods"];
3485
5277
 
3486
5278
  // src/elements/UpcomingBill.tsx
3487
- var import_schematic_react5 = require("@schematichq/schematic-react");
3488
- var import_react5 = require("react");
3489
- var import_jsx_runtime6 = require("react/jsx-runtime");
5279
+ var import_schematic_react7 = require("@schematichq/schematic-react");
5280
+ var import_react8 = require("react");
5281
+ var import_jsx_runtime9 = require("react/jsx-runtime");
3490
5282
  function UpcomingBill({
3491
5283
  className,
3492
5284
  headingLevel = 2,
@@ -3497,10 +5289,10 @@ function UpcomingBill({
3497
5289
  showHeader = true,
3498
5290
  strings
3499
5291
  }) {
3500
- const { data: invoice, error, isPending, refetch } = (0, import_schematic_react5.useUpcomingInvoice)();
5292
+ const { data: invoice, error, isPending, refetch } = (0, import_schematic_react7.useUpcomingInvoice)();
3501
5293
  const locale = useResolvedLocale(localeProp);
3502
5294
  const t = useTranslator(strings, localeProp);
3503
- const bill = (0, import_react5.useMemo)(
5295
+ const bill = (0, import_react8.useMemo)(
3504
5296
  () => invoice === void 0 || invoice === null ? null : deriveUpcomingInvoice(invoice, { locale }),
3505
5297
  [invoice, locale]
3506
5298
  );
@@ -3509,7 +5301,7 @@ function UpcomingBill({
3509
5301
  const discountRow = showDiscounts && bill !== null && bill.discounts.length > 0;
3510
5302
  const unavailable = invoice === void 0 && httpStatus(error) === 404;
3511
5303
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("upcomingBillUnavailable") : t("upcomingBillError");
3512
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
5304
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3513
5305
  StatusFrame,
3514
5306
  {
3515
5307
  className: cx("schematic-card", "schematic-upcoming-bill", className),
@@ -3520,11 +5312,11 @@ function UpcomingBill({
3520
5312
  loadingLabel: t("upcomingBillLoading"),
3521
5313
  onRetry: refetch,
3522
5314
  retryText: t("retry"),
3523
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UpcomingBillSkeleton, { showHeader }),
3524
- children: bill === null ? invoice !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3525
- showHeader && bill.dueAt !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
3526
- showAmount && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-upcoming-bill__amount", children: [
3527
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
5315
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(UpcomingBillSkeleton, { showHeader }),
5316
+ children: bill === null ? invoice !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
5317
+ showHeader && bill.dueAt !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
5318
+ showAmount && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "schematic-upcoming-bill__amount", children: [
5319
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3528
5320
  "span",
3529
5321
  {
3530
5322
  className: "schematic-upcoming-bill__total",
@@ -3532,46 +5324,46 @@ function UpcomingBill({
3532
5324
  children: bill.amountDueText
3533
5325
  }
3534
5326
  ),
3535
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
5327
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
3536
5328
  ] }),
3537
- (balanceRows || discountRow) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-upcoming-bill__rows", children: [
3538
- balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
5329
+ (balanceRows || discountRow) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "schematic-upcoming-bill__rows", children: [
5330
+ balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3539
5331
  "div",
3540
5332
  {
3541
5333
  className: "schematic-row schematic-upcoming-bill__balance-applied",
3542
5334
  "data-testid": "schematic-balance-applied",
3543
5335
  children: [
3544
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
3545
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
5336
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
5337
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
3546
5338
  ]
3547
5339
  }
3548
5340
  ),
3549
- balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
5341
+ balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3550
5342
  "div",
3551
5343
  {
3552
5344
  className: "schematic-row schematic-upcoming-bill__balance-remaining",
3553
5345
  "data-testid": "schematic-balance-remaining",
3554
5346
  children: [
3555
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
3556
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
5347
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
5348
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
3557
5349
  ]
3558
5350
  }
3559
5351
  ),
3560
- discountRow && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
5352
+ discountRow && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3561
5353
  "div",
3562
5354
  {
3563
5355
  className: "schematic-row schematic-upcoming-bill__discount-row",
3564
5356
  "data-testid": "schematic-discounts",
3565
5357
  children: [
3566
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
3567
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
5358
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
5359
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3568
5360
  "li",
3569
5361
  {
3570
5362
  className: "schematic-upcoming-bill__discount",
3571
5363
  "data-testid": "schematic-discount",
3572
5364
  children: [
3573
- discount.code !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
3574
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
5365
+ discount.code !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
5366
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
3575
5367
  ]
3576
5368
  },
3577
5369
  `${discount.couponName}-${index}`
@@ -3585,10 +5377,10 @@ function UpcomingBill({
3585
5377
  );
3586
5378
  }
3587
5379
  function UpcomingBillSkeleton({ showHeader }) {
3588
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-skeleton", children: [
3589
- showHeader && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__heading" }),
3590
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
3591
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
5380
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "schematic-skeleton", children: [
5381
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__heading" }),
5382
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
5383
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
3592
5384
  ] });
3593
5385
  }
3594
5386
  function discountText(discount, t) {