@schematichq/schematic-components 2.31.0 → 2.31.1

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_react4.useSetupIntent)();
163
+ const [state, setState] = (0, import_react4.useState)({ status: "loading" });
164
+ const hostRef = (0, import_react4.useRef)(null);
165
+ (0, import_react4.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_runtime6.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_runtime6.jsx)("span", { className: "schematic-hidden", children: t("paymentMethodsFormLoading") }),
220
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton", children: /* @__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": "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_runtime6.jsxs)("div", { className: "schematic-payment-methods__form", "data-state": "error", children: [
227
+ /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.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_runtime6.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_runtime6.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_react4.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_react4.useState)(false);
280
+ const [message, setMessage] = (0, import_react4.useState)(null);
281
+ const [complete, setComplete] = (0, import_react4.useState)(false);
282
+ const [ready, setReady] = (0, import_react4.useState)(false);
283
+ const [loadFailed, setLoadFailed] = (0, import_react4.useState)(false);
284
+ const [addressComplete, setAddressComplete] = (0, import_react4.useState)(!collectAddress);
285
+ const [typedEmail, setTypedEmail] = (0, import_react4.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_react4.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_runtime6.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_runtime6.jsx)("div", { className: "schematic-payment-methods__fields", children: /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.jsxs)("div", { className: "schematic-payment-methods__field", children: [
359
+ /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.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_runtime6.jsx)("div", { className: "schematic-payment-methods__address", children: /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.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_runtime6.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_runtime6.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_runtime6.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_runtime6.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_react4, import_react4, import_jsx_runtime6, 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_react4 = require("@schematichq/schematic-react");
453
+ import_react4 = require("react");
438
454
  init_tokens();
439
- import_jsx_runtime4 = require("react/jsx-runtime");
455
+ import_jsx_runtime6 = 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,15 +476,20 @@ 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_react7.BillingDataProvider,
464
480
  DEFAULT_STRINGS: () => DEFAULT_STRINGS,
481
+ FEATURE_USER_USAGE_LIMIT: () => import_schematic_react7.FEATURE_USER_USAGE_LIMIT,
482
+ IncludedFeatures: () => IncludedFeatures,
465
483
  Invoices: () => Invoices,
466
484
  PaymentMethods: () => PaymentMethods,
467
485
  SCHEMATIC_TOKENS: () => SCHEMATIC_TOKENS,
468
- SchematicI18nProvider: () => import_schematic_react6.SchematicI18nProvider,
486
+ SchematicI18nProvider: () => import_schematic_react7.SchematicI18nProvider,
469
487
  SchematicStyles: () => SchematicStyles,
488
+ Tooltip: () => Tooltip,
470
489
  UpcomingBill: () => UpcomingBill,
471
490
  billingResources: () => billingResources,
491
+ currentTier: () => currentTier,
492
+ deriveIncludedFeatures: () => deriveIncludedFeatures,
472
493
  deriveInvoiceList: () => deriveInvoiceList,
473
494
  derivePaymentMethods: () => derivePaymentMethods,
474
495
  deriveUpcomingInvoice: () => deriveUpcomingInvoice,
@@ -483,26 +504,33 @@ __export(index_exports, {
483
504
  httpStatus: () => httpStatus,
484
505
  iconsCss: () => iconsCss,
485
506
  interpolate: () => interpolate,
507
+ isTieredPrice: () => isTieredPrice,
486
508
  lookup: () => lookup,
487
509
  plural: () => plural,
510
+ pricePeriod: () => pricePeriod,
488
511
  resolveLocale: () => resolveLocale,
489
512
  schematicStylesCss: () => schematicStylesCss,
490
513
  schematicTokensCss: () => schematicTokensCss,
491
- useInvalidateBillingData: () => import_schematic_react6.useInvalidateBillingData,
492
- useInvoices: () => import_schematic_react6.useInvoices,
493
- usePaymentMethods: () => import_schematic_react6.usePaymentMethods,
514
+ tierRanges: () => tierRanges,
515
+ unitPrice: () => unitPrice,
516
+ usageLimit: () => usageLimit,
517
+ useFeatureUsage: () => import_schematic_react7.useFeatureUsage,
518
+ useFeatureUserUsage: () => import_schematic_react7.useFeatureUserUsage,
519
+ useInvalidateBillingData: () => import_schematic_react7.useInvalidateBillingData,
520
+ useInvoices: () => import_schematic_react7.useInvoices,
521
+ usePaymentMethods: () => import_schematic_react7.usePaymentMethods,
494
522
  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,
523
+ useSchematicI18n: () => import_schematic_react7.useSchematicI18n,
524
+ useSchematicLocale: () => import_schematic_react7.useSchematicLocale,
525
+ useSchematicStrings: () => import_schematic_react7.useSchematicStrings,
526
+ useSchematicTranslate: () => import_schematic_react7.useSchematicTranslate,
527
+ useSetupIntent: () => import_schematic_react7.useSetupIntent,
500
528
  useTranslator: () => useTranslator,
501
- useUpcomingInvoice: () => import_schematic_react6.useUpcomingInvoice,
529
+ useUpcomingInvoice: () => import_schematic_react7.useUpcomingInvoice,
502
530
  viewerLocale: () => viewerLocale
503
531
  });
504
532
  module.exports = __toCommonJS(index_exports);
505
- var import_schematic_react6 = require("@schematichq/schematic-react");
533
+ var import_schematic_react7 = require("@schematichq/schematic-react");
506
534
 
507
535
  // src/elements/model/errors.ts
508
536
  function httpStatus(error) {
@@ -1263,6 +1291,270 @@ function derivePaymentMethods(methods, options) {
1263
1291
  };
1264
1292
  }
1265
1293
 
1294
+ // src/elements/model/featureUsage.ts
1295
+ function pricePeriod(price) {
1296
+ if (price === void 0) {
1297
+ return null;
1298
+ }
1299
+ if (price.interval === "month" && price.intervalCount === 3) {
1300
+ return "quarter";
1301
+ }
1302
+ return price.interval;
1303
+ }
1304
+ function isTieredPrice(price) {
1305
+ return price !== void 0 && (price.priceTiers.length > 1 || price.tiersMode !== void 0 && price.tiersMode !== null);
1306
+ }
1307
+ function unitPrice(price) {
1308
+ return decimalOr(price.priceDecimal, price.price);
1309
+ }
1310
+ function usageLimit(row, options = {}) {
1311
+ let limit = null;
1312
+ const behavior = row.priceBehavior ?? null;
1313
+ if ((behavior === null || behavior === "pay_in_advance") && typeof row.allocation === "number") {
1314
+ limit = row.allocation;
1315
+ } else if (behavior === "overage" && typeof row.softLimit === "number") {
1316
+ limit = row.softLimit;
1317
+ }
1318
+ if (options.showWarningThresholdAsLimit === true && typeof row.warningThreshold === "number") {
1319
+ limit = row.warningThreshold;
1320
+ }
1321
+ return limit;
1322
+ }
1323
+ function currentTier(row) {
1324
+ const tiers = row.price?.priceTiers ?? [];
1325
+ if (row.priceBehavior === "overage" && typeof row.softLimit === "number") {
1326
+ const overage = tiers.length === 2 ? tiers[1] : void 0;
1327
+ return overage === void 0 ? null : { ...tierRange(overage), from: row.softLimit + 1 };
1328
+ }
1329
+ if (row.priceBehavior === "tier" && typeof row.usage === "number") {
1330
+ const usage = row.usage;
1331
+ const tier = tiers.find(
1332
+ (t) => usage >= t.from && (t.to === void 0 || t.to === null || usage <= t.to)
1333
+ );
1334
+ return tier === void 0 ? null : tierRange(tier);
1335
+ }
1336
+ return null;
1337
+ }
1338
+ function tierRanges(price) {
1339
+ return (price?.priceTiers ?? []).map((tier, index) => {
1340
+ const range = tierRange(tier);
1341
+ return index === 0 ? { ...range, from: Math.max(1, range.from) } : range;
1342
+ });
1343
+ }
1344
+ function tierRange(tier) {
1345
+ return {
1346
+ from: tier.from,
1347
+ to: tier.to ?? null,
1348
+ flatPrice: tier.flatPrice ?? null,
1349
+ perUnitPrice: tier.perUnitPriceDecimal !== void 0 && tier.perUnitPriceDecimal !== null ? decimalOr(tier.perUnitPriceDecimal, tier.perUnitPrice ?? 0) : tier.perUnitPrice ?? null
1350
+ };
1351
+ }
1352
+ function decimalOr(decimal, fallback) {
1353
+ if (decimal === void 0 || decimal === null) {
1354
+ return fallback;
1355
+ }
1356
+ const parsed = Number(decimal);
1357
+ return Number.isFinite(parsed) ? parsed : fallback;
1358
+ }
1359
+
1360
+ // src/elements/model/includedFeatures.ts
1361
+ function deriveIncludedFeatures(features, options) {
1362
+ const ordered = options.visibleFeatures === void 0 ? features : options.visibleFeatures.flatMap((id) => {
1363
+ const row = features.find((f) => f.featureId === id);
1364
+ return row === void 0 ? [] : [row];
1365
+ });
1366
+ return ordered.map((row) => includedFeatureRow(row, options));
1367
+ }
1368
+ function includedFeatureRow(row, options) {
1369
+ const { locale } = options;
1370
+ const feature = {
1371
+ name: row.featureName,
1372
+ singularName: row.featureSingularName,
1373
+ pluralName: row.featurePluralName
1374
+ };
1375
+ const expiresAt = usableDate(row.expiresAt);
1376
+ const tiered = row.priceBehavior === "pay_in_advance" && isTieredPrice(row.price);
1377
+ const period = pricePeriod(row.price);
1378
+ return {
1379
+ featureId: row.featureId,
1380
+ name: row.featureName,
1381
+ description: nonEmpty(row.featureDescription),
1382
+ icon: nonEmpty(row.featureIcon),
1383
+ perLicenseCredits: row.perLicenseCreditGrants.filter((grant) => grant.scaling === "per_license").map((grant) => ({
1384
+ amount: grant.creditAmount,
1385
+ creditName: featureName(
1386
+ {
1387
+ name: grant.creditName,
1388
+ singularName: grant.creditSingularName,
1389
+ pluralName: grant.creditPluralName
1390
+ },
1391
+ grant.creditAmount,
1392
+ locale
1393
+ ),
1394
+ licenseName: featureName(feature, 1, locale)
1395
+ })),
1396
+ expiresAt: expiresAt === void 0 ? null : {
1397
+ date: expiresAt,
1398
+ text: formatDate(expiresAt, locale, { month: "short" })
1399
+ },
1400
+ entitlement: entitlementText(row, options),
1401
+ usage: usageSegments(row, locale, tiered, period),
1402
+ usageSummary: usageSummary(row, options),
1403
+ hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
1404
+ amount: row.allocation,
1405
+ units: featureName(feature, row.allocation, locale)
1406
+ } : null,
1407
+ tiers: (row.priceBehavior === "tier" || tiered) && row.price !== void 0 ? {
1408
+ ranges: tierRanges(row.price),
1409
+ currency: row.price.currency,
1410
+ mode: row.price.tiersMode ?? null,
1411
+ period
1412
+ } : null,
1413
+ source: row
1414
+ };
1415
+ }
1416
+ function isMetered(row) {
1417
+ return row.featureType === "event" || row.featureType === "trait";
1418
+ }
1419
+ function entitlementText(row, options) {
1420
+ if (!isMetered(row)) {
1421
+ return null;
1422
+ }
1423
+ const { locale } = options;
1424
+ const feature = {
1425
+ name: row.featureName,
1426
+ singularName: row.featureSingularName,
1427
+ pluralName: row.featurePluralName
1428
+ };
1429
+ const units = (count) => ({
1430
+ amount: formatNumber(count, locale),
1431
+ units: featureName(feature, count, locale)
1432
+ });
1433
+ switch (row.priceBehavior) {
1434
+ case "pay_in_advance":
1435
+ return typeof row.allocation === "number" ? { kind: "units", ...units(row.allocation) } : null;
1436
+ case "pay_as_you_go": {
1437
+ if (row.price === void 0) {
1438
+ return null;
1439
+ }
1440
+ const cost = formatCurrency(
1441
+ unitPrice(row.price),
1442
+ row.price.currency,
1443
+ locale
1444
+ );
1445
+ const size = row.price.packageSize;
1446
+ return size > 1 ? {
1447
+ kind: "perPackage",
1448
+ cost,
1449
+ size,
1450
+ units: featureName(feature, size, locale)
1451
+ } : { kind: "perUnit", cost, unit: featureName(feature, 1, locale) };
1452
+ }
1453
+ case "overage":
1454
+ return typeof row.softLimit === "number" ? { kind: "units", ...units(row.softLimit) } : null;
1455
+ case "tier": {
1456
+ const tier = currentTier(row);
1457
+ if (tier === null) {
1458
+ return null;
1459
+ }
1460
+ return tier.to === null ? { kind: "tierUnlimited", feature: featureName(feature, 0, locale) } : {
1461
+ kind: "tierUpTo",
1462
+ amount: formatNumber(tier.to, locale),
1463
+ feature: featureName(feature, tier.to, locale)
1464
+ };
1465
+ }
1466
+ case "credit_burndown":
1467
+ if (options.showCredits === false || typeof row.consumptionRate !== "number" || row.creditName === void 0 || row.creditName === null) {
1468
+ return null;
1469
+ }
1470
+ return {
1471
+ kind: "perUse",
1472
+ amount: formatConsumptionRate(row.consumptionRate, locale),
1473
+ units: featureName(
1474
+ {
1475
+ name: row.creditName,
1476
+ singularName: row.creditSingularName,
1477
+ pluralName: row.creditPluralName
1478
+ },
1479
+ row.consumptionRate,
1480
+ locale
1481
+ )
1482
+ };
1483
+ default:
1484
+ break;
1485
+ }
1486
+ if (typeof row.allocation === "number") {
1487
+ const limit = usageLimit(row, options) ?? row.allocation;
1488
+ return { kind: "units", ...units(limit) };
1489
+ }
1490
+ if (row.valueType === "unlimited") {
1491
+ return { kind: "unlimited", item: featureName(feature, 0, locale) };
1492
+ }
1493
+ return null;
1494
+ }
1495
+ function usageSegments(row, locale, tiered, period) {
1496
+ if (!isMetered(row)) {
1497
+ return [];
1498
+ }
1499
+ const feature = {
1500
+ name: row.featureName,
1501
+ singularName: row.featureSingularName,
1502
+ pluralName: row.featurePluralName
1503
+ };
1504
+ const segments = [];
1505
+ if (row.priceBehavior === "pay_in_advance" && !tiered && period !== null && row.price !== void 0) {
1506
+ const size = row.price.packageSize;
1507
+ segments.push({
1508
+ kind: "unitPricePerPeriod",
1509
+ cost: formatCurrency(unitPrice(row.price), row.price.currency, locale),
1510
+ size,
1511
+ units: featureName(feature, size, locale),
1512
+ period
1513
+ });
1514
+ } else if ((row.priceBehavior === "pay_as_you_go" || row.priceBehavior === "overage" || row.priceBehavior === "tier" || row.priceBehavior === "credit_burndown" || tiered) && typeof row.usage === "number") {
1515
+ segments.push({
1516
+ kind: "used",
1517
+ amount: String(row.usage),
1518
+ units: featureName(feature, row.usage, locale)
1519
+ });
1520
+ }
1521
+ if (typeof row.currentCost === "number" && row.currentCost > 0 && row.price !== void 0) {
1522
+ segments.push({
1523
+ kind: "cost",
1524
+ cost: formatCurrency(row.currentCost, row.price.currency, locale),
1525
+ period: row.featureType === "trait" ? period : null
1526
+ });
1527
+ }
1528
+ const resetsAt = usableDate(row.resetsAt);
1529
+ if (resetsAt !== void 0) {
1530
+ segments.push({
1531
+ kind: "resets",
1532
+ date: formatDate(resetsAt, locale, { month: "short", year: void 0 })
1533
+ });
1534
+ }
1535
+ return segments;
1536
+ }
1537
+ function usageSummary(row, options) {
1538
+ if (!isMetered(row) || typeof row.usage !== "number") {
1539
+ return null;
1540
+ }
1541
+ const amount = formatNumber(row.usage, options.locale);
1542
+ if (typeof row.allocation === "number") {
1543
+ return {
1544
+ kind: "limited",
1545
+ amount,
1546
+ allocation: formatNumber(
1547
+ usageLimit(row, options) ?? row.allocation,
1548
+ options.locale
1549
+ )
1550
+ };
1551
+ }
1552
+ return { kind: "unlimited", amount };
1553
+ }
1554
+ function nonEmpty(value) {
1555
+ return value === void 0 || value === null || value === "" ? null : value;
1556
+ }
1557
+
1266
1558
  // src/elements/strings.ts
1267
1559
  var DEFAULT_STRINGS_LOCALE = "en";
1268
1560
  var DEFAULT_STRINGS = {
@@ -1329,7 +1621,37 @@ var DEFAULT_STRINGS = {
1329
1621
  paymentMethodsSaving: "Loading",
1330
1622
  paymentMethodsSaveError: "A problem occurred while saving your payment method.",
1331
1623
  paymentMethodsSetDefaultError: "Error updating payment method. Please try again.",
1332
- paymentMethodsRemoveError: "Error deleting payment method. Please try again."
1624
+ paymentMethodsRemoveError: "Error deleting payment method. Please try again.",
1625
+ includedFeaturesLoading: "Loading features",
1626
+ includedFeaturesHeader: "Included features",
1627
+ includedFeaturesError: "There was a problem retrieving your features.",
1628
+ includedFeaturesUnavailable: "Features are not available for this account.",
1629
+ includedFeaturesSeeAll: "See all",
1630
+ includedFeaturesHideAll: "Hide all",
1631
+ includedFeaturesExpires: "Expires {{date}}",
1632
+ includedFeaturesPerLicense: "Includes {{amount}} {{creditName}} per {{licenseName}}",
1633
+ // Shared by the usage elements.
1634
+ usageUnits: "{{amount}} {{units}}",
1635
+ usagePerUnit: "{{cost}} per {{unit}}",
1636
+ usagePerPackage: "{{cost}} per {{size}} {{units}}",
1637
+ usageTierUpTo: "Up to {{amount}} {{feature}} in this tier",
1638
+ usageTierUnlimited: "Unlimited {{feature}} in this tier",
1639
+ usagePerUse: "{{amount}} {{units}} per use",
1640
+ usageUnlimited: "Unlimited {{item}}",
1641
+ usageUnitPricePerPeriod: "{{cost}}/{{unit}}/{{period}}",
1642
+ usagePackagePricePerPeriod: "{{cost}}/{{size}} {{units}}/{{period}}",
1643
+ usageUsed: "{{amount}} {{units}} used",
1644
+ usageResets: "Resets {{date}}",
1645
+ usageLimited: "{{amount}} of {{allocation}} used",
1646
+ usageUnlimitedUsed: "{{amount}} used",
1647
+ usageHardLimitLabel: "Limit",
1648
+ usageHardLimit: "Up to a limit of {{amount}} {{units}}",
1649
+ usageTieredPricingLabel: "Tiered pricing",
1650
+ usageTiersVolume: "Price by unit based on final tier reached.",
1651
+ usageTiersGraduated: "Tiers apply progressively as quantity increases.",
1652
+ periodMonthShort: "mo",
1653
+ periodQuarterShort: "qtr",
1654
+ periodYearShort: "yr"
1333
1655
  };
1334
1656
  var MISSING_STRING = "\0schematic:missing";
1335
1657
  function interpolate(template, vars) {
@@ -1368,15 +1690,29 @@ var dialogCss = `
1368
1690
  border: 0;
1369
1691
  border-radius: 0.5rem;
1370
1692
  box-shadow: var(--schematic-shadow);
1693
+ box-sizing: border-box;
1371
1694
  color: var(--schematic-text);
1372
- line-height: 1.375;
1373
1695
  margin: auto;
1374
1696
  max-height: calc(100vh - 2 * var(--schematic-space));
1375
- max-width: 48rem;
1697
+ max-width: none;
1376
1698
  /* No padding of its own: a click on the backdrop lands on the dialog
1377
1699
  itself, and one inside lands on the header or body. */
1378
1700
  padding: 0;
1379
- width: calc(100% - 2 * var(--schematic-space));
1701
+ /* Never wider than the screen, whatever it holds. */
1702
+ width: min(48rem, calc(100vw - 2 * var(--schematic-space)));
1703
+ }
1704
+
1705
+ /* Centred by vw on a phone: a host page wider than the screen widens the
1706
+ layout viewport, and auto margins would centre the dialog half off the
1707
+ screen. Desktop keeps auto margins, as vw counts the scrollbar there. */
1708
+ @media (max-width: 52rem) {
1709
+ .schematic-dialog {
1710
+ inset-inline: 0 auto;
1711
+ margin-inline: calc(
1712
+ (100vw - min(48rem, calc(100vw - 2 * var(--schematic-space)))) / 2
1713
+ )
1714
+ 0;
1715
+ }
1380
1716
  }
1381
1717
 
1382
1718
  .schematic-dialog::backdrop {
@@ -1408,7 +1744,7 @@ var dialogCss = `
1408
1744
  font-family: var(--schematic-font-body);
1409
1745
  font-size: 1.125rem;
1410
1746
  font-weight: 400;
1411
- line-height: var(--schematic-line-height-heading);
1747
+ line-height: var(--schematic-line-height);
1412
1748
  margin: 0;
1413
1749
  }
1414
1750
 
@@ -1437,6 +1773,8 @@ var dialogCss = `
1437
1773
  display: flex;
1438
1774
  flex-direction: column;
1439
1775
  gap: var(--schematic-space);
1776
+ min-width: 0;
1777
+ overflow-wrap: anywhere;
1440
1778
  padding: calc(var(--schematic-space) * 1.5);
1441
1779
  }
1442
1780
  `;
@@ -1851,6 +2189,109 @@ var iconsCss = String.raw`
1851
2189
  }
1852
2190
  `;
1853
2191
 
2192
+ // src/elements/styles/included-features.ts
2193
+ var includedFeaturesCss = `
2194
+ .schematic-included-features {
2195
+ container-type: inline-size;
2196
+ }
2197
+
2198
+ .schematic-included-features__list {
2199
+ display: flex;
2200
+ flex-direction: column;
2201
+ gap: calc(var(--schematic-space) * 1.5);
2202
+ list-style: none;
2203
+ margin: 0;
2204
+ padding: 0;
2205
+ }
2206
+
2207
+ /* Icon, name and details; the usage drops beneath on a narrow card. */
2208
+ .schematic-included-features__row {
2209
+ column-gap: 0.5rem;
2210
+ display: grid;
2211
+ grid-template-columns: min-content 1fr;
2212
+ }
2213
+
2214
+ /* Two classes: the icon font's own rule comes later in the sheet and sets
2215
+ display, which would leave the glyph in the circle's corner. */
2216
+ .schematic-included-features .schematic-included-features__icon {
2217
+ align-items: center;
2218
+ background: var(--schematic-surface);
2219
+ border-radius: 9999px;
2220
+ color: var(--schematic-accent);
2221
+ display: inline-flex;
2222
+ font-size: 1.5rem;
2223
+ height: 2.75rem;
2224
+ justify-content: center;
2225
+ margin-inline-end: 0.5rem;
2226
+ width: 2.75rem;
2227
+ }
2228
+
2229
+ .schematic-included-features__details {
2230
+ align-self: baseline;
2231
+ display: flex;
2232
+ flex-direction: column;
2233
+ gap: 0.25rem;
2234
+ grid-column: 2;
2235
+ }
2236
+
2237
+ /* An item name, as add-ons and plan lines elsewhere. */
2238
+ .schematic-included-features__name {
2239
+ font-family: var(--schematic-font-heading);
2240
+ font-size: 1.125rem;
2241
+ font-weight: 800;
2242
+ line-height: var(--schematic-line-height-heading);
2243
+ }
2244
+
2245
+ .schematic-included-features__usage {
2246
+ display: flex;
2247
+ flex-direction: column;
2248
+ gap: 0.25rem;
2249
+ grid-column: 1 / span 2;
2250
+ margin-inline-start: 3.75rem;
2251
+ margin-top: 0.75rem;
2252
+ }
2253
+
2254
+ .schematic-included-features__entitlement,
2255
+ .schematic-included-features__used {
2256
+ font-variant-numeric: tabular-nums;
2257
+ }
2258
+
2259
+ @container (min-width: 23.4375rem) {
2260
+ /* The usage takes the room it needs and wraps only when the name leaves
2261
+ it none. */
2262
+ .schematic-included-features__row {
2263
+ grid-template-columns: min-content 1fr auto;
2264
+ }
2265
+
2266
+ .schematic-included-features__usage {
2267
+ align-self: baseline;
2268
+ grid-column: 3;
2269
+ margin-inline-start: 0;
2270
+ margin-top: 0;
2271
+ text-align: end;
2272
+ }
2273
+ }
2274
+
2275
+ .schematic-included-features__toggle {
2276
+ align-items: center;
2277
+ display: inline-flex;
2278
+ gap: 0.25rem;
2279
+ margin-top: var(--schematic-space);
2280
+ }
2281
+
2282
+ .schematic-included-features__toggle .schematic-chevron {
2283
+ margin-inline-start: -0.333rem;
2284
+ }
2285
+
2286
+ .schematic-included-features .schematic-skeleton__cell[data-column="name"] {
2287
+ width: 10rem;
2288
+ }
2289
+
2290
+ .schematic-included-features .schematic-skeleton__cell[data-column="usage"] {
2291
+ width: 6rem;
2292
+ }
2293
+ `;
2294
+
1854
2295
  // src/elements/styles/invoices.ts
1855
2296
  var invoicesCss = `
1856
2297
  .schematic-invoices {
@@ -1880,6 +2321,7 @@ var invoicesCss = `
1880
2321
 
1881
2322
  .schematic-invoices__link {
1882
2323
  color: var(--schematic-accent);
2324
+ font-family: var(--schematic-font-link);
1883
2325
  text-decoration: none;
1884
2326
  }
1885
2327
 
@@ -1895,10 +2337,6 @@ var invoicesCss = `
1895
2337
  text-align: end;
1896
2338
  }
1897
2339
 
1898
- .schematic-invoices__credit {
1899
- color: var(--schematic-muted);
1900
- }
1901
-
1902
2340
  .schematic-invoices__actions {
1903
2341
  align-items: center;
1904
2342
  display: flex;
@@ -1909,23 +2347,12 @@ var invoicesCss = `
1909
2347
  .schematic-invoices__see-more {
1910
2348
  align-items: center;
1911
2349
  display: inline-flex;
1912
- gap: 0.375rem;
2350
+ gap: calc(var(--schematic-space) / 2);
1913
2351
  }
1914
2352
 
1915
- /* A chevron drawn from two borders. The vertical nudge lives in the
1916
- transform with the rotation so one transition carries both. */
2353
+ /* Cancels the glyph's side bearing, so the chevron sits flush. */
1917
2354
  .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);
2355
+ margin-inline-start: -0.333rem;
1929
2356
  }
1930
2357
 
1931
2358
  .schematic-invoices__empty {
@@ -1954,10 +2381,6 @@ var paymentMethodsCss = `
1954
2381
  margin-bottom: 0;
1955
2382
  }
1956
2383
 
1957
- .schematic-payment-methods .schematic-header__title {
1958
- margin-bottom: 0;
1959
- }
1960
-
1961
2384
  .schematic-payment-methods__expiry-warning {
1962
2385
  color: var(--schematic-danger);
1963
2386
  white-space: nowrap;
@@ -1974,12 +2397,21 @@ var paymentMethodsCss = `
1974
2397
  padding: calc(var(--schematic-space) / 2.25) var(--schematic-space);
1975
2398
  }
1976
2399
 
2400
+ /* One line: a label too long for the space truncates rather than wrapping
2401
+ "Card ending in" away from its digits or widening the dialog. */
1977
2402
  .schematic-payment-methods__method {
1978
2403
  align-items: center;
1979
2404
  display: inline-flex;
1980
2405
  flex-grow: 1;
1981
- flex-wrap: wrap;
1982
2406
  gap: 0.25em;
2407
+ min-width: 0;
2408
+ }
2409
+
2410
+ .schematic-payment-methods__label {
2411
+ min-width: 0;
2412
+ overflow: hidden;
2413
+ text-overflow: ellipsis;
2414
+ white-space: nowrap;
1983
2415
  }
1984
2416
 
1985
2417
  /* The brand's mark before the label, in the label's colour. */
@@ -1991,6 +2423,7 @@ var paymentMethodsCss = `
1991
2423
  }
1992
2424
 
1993
2425
  .schematic-payment-methods__last4 {
2426
+ flex-shrink: 0;
1994
2427
  font-variant-numeric: tabular-nums;
1995
2428
  }
1996
2429
 
@@ -2004,14 +2437,16 @@ var paymentMethodsCss = `
2004
2437
  white-space: nowrap;
2005
2438
  }
2006
2439
 
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. */
2440
+ /* The toggle that reveals the other methods. Its chevron is a glyph per
2441
+ state, down while folded and up while unfolded, and the hover underline
2442
+ goes on the label alone, as on every toggle. */
2011
2443
  .schematic-payment-methods__choose {
2012
2444
  align-items: center;
2013
2445
  align-self: flex-start;
2014
2446
  display: inline-flex;
2447
+ /* A button centres its text; a label that wraps on a phone keeps to the
2448
+ start. */
2449
+ text-align: start;
2015
2450
  gap: calc(var(--schematic-space) / 2);
2016
2451
  }
2017
2452
 
@@ -2023,10 +2458,6 @@ var paymentMethodsCss = `
2023
2458
  text-decoration: underline;
2024
2459
  }
2025
2460
 
2026
- .schematic-payment-methods__chevron {
2027
- color: var(--schematic-text);
2028
- font-size: 1.5em;
2029
- }
2030
2461
 
2031
2462
  /* A faintly tinted panel, roomier than the shared dialog body, with its
2032
2463
  parts spaced further apart. */
@@ -2070,6 +2501,12 @@ var paymentMethodsCss = `
2070
2501
  padding: calc(var(--schematic-space) / 2) 0;
2071
2502
  }
2072
2503
 
2504
+ /* The name takes the line's room first; the actions wrap under it before
2505
+ the name is cut short. */
2506
+ .schematic-payment-methods__row .schematic-payment-methods__method {
2507
+ flex: 1 1 10rem;
2508
+ }
2509
+
2073
2510
  .schematic-payment-methods__expires {
2074
2511
  flex-grow: 1;
2075
2512
  font-variant-numeric: tabular-nums;
@@ -2143,23 +2580,31 @@ var paymentMethodsCss = `
2143
2580
  white-space: nowrap;
2144
2581
  }
2145
2582
 
2583
+ /* Spaced as the embed's form: 24px between parts, and a wider break before
2584
+ Save under the address. */
2146
2585
  .schematic-payment-methods__form {
2147
2586
  display: flex;
2148
2587
  flex-direction: column;
2149
- gap: var(--schematic-space);
2588
+ gap: calc(var(--schematic-space) * 1.5);
2589
+ }
2590
+
2591
+ .schematic-payment-methods__address {
2592
+ margin-bottom: calc(var(--schematic-space) * 2);
2150
2593
  }
2151
2594
 
2152
- /* The fields the checkout settings add beside Stripe's own. */
2595
+ /* The fields the checkout settings add beside Stripe's own, labelled as
2596
+ Stripe's are. */
2153
2597
  .schematic-payment-methods__field {
2154
2598
  display: flex;
2155
2599
  flex-direction: column;
2156
- gap: calc(var(--schematic-space) / 2);
2600
+ gap: calc(var(--schematic-space) * 0.75);
2157
2601
  }
2158
2602
 
2159
2603
  .schematic-payment-methods__input {
2160
2604
  background: var(--schematic-background);
2161
2605
  border: 1px solid var(--schematic-border);
2162
- border-radius: var(--schematic-radius);
2606
+ /* The embed's 8px at the default radius; Stripe's fields take the same. */
2607
+ border-radius: calc(var(--schematic-radius) * 0.8);
2163
2608
  box-sizing: border-box;
2164
2609
  color: var(--schematic-text);
2165
2610
  font: inherit;
@@ -2190,6 +2635,83 @@ var paymentMethodsCss = `
2190
2635
  // src/elements/styles/index.tsx
2191
2636
  init_tokens();
2192
2637
 
2638
+ // src/elements/styles/tooltip.ts
2639
+ var tooltipCss = `
2640
+ .schematic-tooltip {
2641
+ display: inline-block;
2642
+ margin-inline-start: 0.25rem;
2643
+ position: relative;
2644
+ vertical-align: middle;
2645
+ }
2646
+
2647
+ .schematic-tooltip__trigger {
2648
+ background: none;
2649
+ border: 0;
2650
+ color: var(--schematic-muted);
2651
+ cursor: help;
2652
+ /* A button keeps the browser's control font; the glyph is the embed's
2653
+ 24px. */
2654
+ font-size: 1.5rem;
2655
+ line-height: 0;
2656
+ padding: 0;
2657
+ }
2658
+
2659
+ .schematic-tooltip__trigger:focus-visible {
2660
+ outline: 2px solid var(--schematic-accent);
2661
+ outline-offset: 2px;
2662
+ }
2663
+
2664
+ .schematic-tooltip__content {
2665
+ background: var(--schematic-background);
2666
+ border: 1px solid var(--schematic-border);
2667
+ border-radius: calc(var(--schematic-radius) / 2);
2668
+ bottom: calc(100% + 0.5rem);
2669
+ box-shadow: var(--schematic-shadow);
2670
+ color: var(--schematic-text);
2671
+ font-size: 0.875rem;
2672
+ inset-inline-end: 0;
2673
+ padding: 0.5rem 0.75rem;
2674
+ pointer-events: none;
2675
+ position: absolute;
2676
+ text-align: start;
2677
+ visibility: hidden;
2678
+ white-space: nowrap;
2679
+ z-index: 1;
2680
+ }
2681
+
2682
+ .schematic-tooltip:hover .schematic-tooltip__content,
2683
+ .schematic-tooltip:focus-within .schematic-tooltip__content {
2684
+ visibility: visible;
2685
+ }
2686
+
2687
+ .schematic-tiers {
2688
+ display: flex;
2689
+ flex-direction: column;
2690
+ gap: 0.5rem;
2691
+ }
2692
+
2693
+ .schematic-tiers__list {
2694
+ margin: 0;
2695
+ }
2696
+
2697
+ .schematic-tiers__tier {
2698
+ display: flex;
2699
+ gap: var(--schematic-space);
2700
+ justify-content: space-between;
2701
+ padding: 0.25rem 0;
2702
+ }
2703
+
2704
+ .schematic-tiers__price {
2705
+ margin: 0;
2706
+ }
2707
+
2708
+ .schematic-tiers__mode {
2709
+ border-top: 1px solid var(--schematic-border);
2710
+ padding-top: 0.5rem;
2711
+ white-space: normal;
2712
+ }
2713
+ `;
2714
+
2193
2715
  // src/elements/styles/upcoming-bill.ts
2194
2716
  var upcomingBillCss = `
2195
2717
  .schematic-upcoming-bill {
@@ -2202,10 +2724,6 @@ var upcomingBillCss = `
2202
2724
  margin-bottom: 0;
2203
2725
  }
2204
2726
 
2205
- .schematic-upcoming-bill .schematic-header__title {
2206
- margin-bottom: 0;
2207
- }
2208
-
2209
2727
  .schematic-upcoming-bill__amount {
2210
2728
  align-items: flex-start;
2211
2729
  display: flex;
@@ -2215,14 +2733,14 @@ var upcomingBillCss = `
2215
2733
 
2216
2734
  .schematic-upcoming-bill__total {
2217
2735
  font-family: var(--schematic-font-heading);
2218
- font-size: 1.8125rem;
2736
+ font-size: 2.3125rem;
2219
2737
  font-variant-numeric: tabular-nums;
2220
2738
  font-weight: 800;
2221
2739
  line-height: 1;
2222
2740
  }
2223
2741
 
2224
2742
  .schematic-upcoming-bill__estimate {
2225
- font-weight: 600;
2743
+ color: var(--schematic-muted);
2226
2744
  max-width: 10rem;
2227
2745
  text-align: end;
2228
2746
  }
@@ -2288,6 +2806,21 @@ var rulesCss = `
2288
2806
  margin: 0;
2289
2807
  }
2290
2808
 
2809
+ /* Unit suffixes ("/mo", "/seat") sit on the baseline, as in the embed. */
2810
+ :where([class^="schematic-"]) sub,
2811
+ :where([class^="schematic-"]) sup {
2812
+ line-height: 1;
2813
+ position: static;
2814
+ }
2815
+
2816
+ :where([class^="schematic-"]) sub {
2817
+ vertical-align: baseline;
2818
+ }
2819
+
2820
+ :where([class^="schematic-"]) sup {
2821
+ vertical-align: top;
2822
+ }
2823
+
2291
2824
  .schematic-card {
2292
2825
  background: var(--schematic-background);
2293
2826
  border-radius: var(--schematic-radius);
@@ -2383,6 +2916,7 @@ var rulesCss = `
2383
2916
 
2384
2917
  .schematic-error {
2385
2918
  color: var(--schematic-danger);
2919
+ font-weight: 500;
2386
2920
  }
2387
2921
 
2388
2922
  .schematic-status-note {
@@ -2445,10 +2979,26 @@ var rulesCss = `
2445
2979
  border-color: var(--schematic-primary);
2446
2980
  }
2447
2981
 
2982
+ /* The embed's small button: 15px type, 40px tall. */
2448
2983
  .schematic-cta--small {
2984
+ border-radius: 0.375rem;
2449
2985
  font-size: 0.9375rem;
2450
2986
  min-height: 2.5rem;
2451
- padding: 0.375rem 1rem;
2987
+ padding: 0.4375rem 1.25rem;
2988
+ }
2989
+
2990
+ /* The embed's ghost button, for secondary actions such as Try again. */
2991
+ .schematic-cta--ghost {
2992
+ background: transparent;
2993
+ border-color: color-mix(in srgb, var(--schematic-text) 20%, transparent);
2994
+ color: var(--schematic-text);
2995
+ }
2996
+
2997
+ .schematic-cta--ghost:hover:not(:disabled) {
2998
+ background: transparent;
2999
+ border-color: color-mix(in srgb, var(--schematic-text) 12.5%, transparent);
3000
+ box-shadow: 0 1px 2px
3001
+ color-mix(in srgb, var(--schematic-text) 7.5%, transparent);
2452
3002
  }
2453
3003
 
2454
3004
  .schematic-link-button {
@@ -2465,6 +3015,27 @@ var rulesCss = `
2465
3015
  text-decoration: underline;
2466
3016
  }
2467
3017
 
3018
+ /* Every toggle's chevron: the 24px glyph, muted. */
3019
+ .schematic-chevron {
3020
+ color: var(--schematic-muted);
3021
+ font-size: 1.5rem;
3022
+ }
3023
+
3024
+ /* A toggle underlines its label alone: a flex container hands its underline
3025
+ to every item, the chevron included, and an item cannot take it off. */
3026
+ .schematic-link-button:has(.schematic-link-button__label):hover {
3027
+ text-decoration: none;
3028
+ }
3029
+
3030
+ /* The reset colours every schematic- element; the label keeps the link's. */
3031
+ .schematic-link-button__label {
3032
+ color: inherit;
3033
+ }
3034
+
3035
+ .schematic-link-button:hover .schematic-link-button__label {
3036
+ text-decoration: underline;
3037
+ }
3038
+
2468
3039
  .schematic-meter {
2469
3040
  background: var(--schematic-meter-track);
2470
3041
  border-radius: 9999px;
@@ -2554,7 +3125,7 @@ var rulesCss = `
2554
3125
  font-size: 1.125rem;
2555
3126
  font-weight: 800;
2556
3127
  line-height: var(--schematic-line-height-heading);
2557
- margin: 0 0 calc(var(--schematic-space) / 2);
3128
+ margin: 0;
2558
3129
  }
2559
3130
 
2560
3131
  /* A label on the left, its value on the right. */
@@ -2762,11 +3333,13 @@ ${dialogCss}
2762
3333
  ${invoicesCss}
2763
3334
  ${upcomingBillCss}
2764
3335
  ${paymentMethodsCss}
3336
+ ${tooltipCss}
3337
+ ${includedFeaturesCss}
2765
3338
  `;
2766
3339
  var schematicStylesCss = withTokenDefaults(rulesCss) + iconsCss;
2767
3340
  var SchematicStyles = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { "data-schematic-styles": "", children: schematicStylesCss });
2768
3341
 
2769
- // src/elements/Invoices.tsx
3342
+ // src/elements/IncludedFeatures.tsx
2770
3343
  var import_schematic_react2 = require("@schematichq/schematic-react");
2771
3344
  var import_react2 = require("react");
2772
3345
 
@@ -2857,7 +3430,7 @@ var StatusFrame = ({
2857
3430
  onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2858
3431
  "button",
2859
3432
  {
2860
- className: "schematic-link-button schematic-status__retry",
3433
+ className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-status__retry",
2861
3434
  type: "button",
2862
3435
  onClick: onRetry,
2863
3436
  children: retryText
@@ -2876,6 +3449,28 @@ var StatusFrame = ({
2876
3449
  error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "schematic-status-note schematic-error", role: "alert", children: errorMessage ?? error.message })
2877
3450
  ] });
2878
3451
  };
3452
+ var Tooltip = ({ children, className, label }) => {
3453
+ const id = (0, import_react.useId)();
3454
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: cx("schematic-tooltip", className), children: [
3455
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3456
+ "button",
3457
+ {
3458
+ "aria-describedby": id,
3459
+ "aria-label": label,
3460
+ className: "schematic-tooltip__trigger",
3461
+ type: "button",
3462
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3463
+ "i",
3464
+ {
3465
+ "aria-hidden": "true",
3466
+ className: "schematic-icon schematic-icon--info-rounded"
3467
+ }
3468
+ )
3469
+ }
3470
+ ),
3471
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "schematic-tooltip__content", id, role: "tooltip", children })
3472
+ ] });
3473
+ };
2879
3474
  var Dialog = ({ children, className, closeLabel, onClose, open, title, titleId }) => {
2880
3475
  const ref = (0, import_react.useRef)(null);
2881
3476
  const generatedId = (0, import_react.useId)();
@@ -2927,8 +3522,306 @@ var Dialog = ({ children, className, closeLabel, onClose, open, title, titleId }
2927
3522
  );
2928
3523
  };
2929
3524
 
2930
- // src/elements/Invoices.tsx
3525
+ // src/elements/usage.tsx
2931
3526
  var import_jsx_runtime3 = require("react/jsx-runtime");
3527
+ function shortPeriod(period, t) {
3528
+ switch (period) {
3529
+ case "month":
3530
+ return t("periodMonthShort");
3531
+ case "quarter":
3532
+ return t("periodQuarterShort");
3533
+ case "year":
3534
+ return t("periodYearShort");
3535
+ default:
3536
+ return void 0;
3537
+ }
3538
+ }
3539
+ function PriceTiers({
3540
+ currency,
3541
+ locale,
3542
+ mode,
3543
+ period,
3544
+ ranges,
3545
+ t,
3546
+ unit
3547
+ }) {
3548
+ const perPeriod = period === null ? void 0 : shortPeriod(period, t);
3549
+ const money = (amount) => formatCurrency(amount, currency, locale);
3550
+ const perUnit = (amount) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3551
+ money(amount),
3552
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("sub", { children: [
3553
+ "/",
3554
+ unit
3555
+ ] })
3556
+ ] });
3557
+ const flat = (amount) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3558
+ money(amount),
3559
+ perPeriod !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("sub", { children: [
3560
+ "/",
3561
+ perPeriod
3562
+ ] })
3563
+ ] });
3564
+ const tierPrice = (flatPrice, perUnitPrice) => {
3565
+ if (flatPrice === 0 && perUnitPrice !== 0) {
3566
+ return perUnit(perUnitPrice);
3567
+ }
3568
+ if (flatPrice !== 0 && perUnitPrice === 0) {
3569
+ return flat(flatPrice);
3570
+ }
3571
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3572
+ perUnit(perUnitPrice),
3573
+ " + ",
3574
+ flat(flatPrice)
3575
+ ] });
3576
+ };
3577
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "schematic-tiers", children: [
3578
+ /* @__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: [
3579
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dt", { className: "schematic-tiers__range", children: [
3580
+ tier.from,
3581
+ tier.to === null ? "+" : tier.to !== tier.from ? `\u2013${tier.to}` : ""
3582
+ ] }),
3583
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { className: "schematic-tiers__price", children: tierPrice(tier.flatPrice ?? 0, tier.perUnitPrice ?? 0) })
3584
+ ] }, tier.from)) }),
3585
+ mode !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-tiers__mode", children: mode === "volume" ? t("usageTiersVolume") : t("usageTiersGraduated") })
3586
+ ] });
3587
+ }
3588
+
3589
+ // src/elements/IncludedFeatures.tsx
3590
+ var import_jsx_runtime4 = require("react/jsx-runtime");
3591
+ var VISIBLE_FEATURE_COUNT = 4;
3592
+ function IncludedFeatures({
3593
+ className,
3594
+ headingLevel = 2,
3595
+ locale: localeProp,
3596
+ showCredits = true,
3597
+ showDescription = true,
3598
+ showEntitlement = true,
3599
+ showExpiration = true,
3600
+ showHardLimit = false,
3601
+ showHeader = true,
3602
+ showIcon = true,
3603
+ showUsage = true,
3604
+ showWarningThresholdAsLimit = false,
3605
+ strings,
3606
+ visibleFeatures
3607
+ }) {
3608
+ const { data: features, error, isPending, refetch } = (0, import_schematic_react2.useFeatureUsage)();
3609
+ const locale = useResolvedLocale(localeProp);
3610
+ const t = useTranslator(strings, localeProp);
3611
+ const [expanded, setExpanded] = (0, import_react2.useState)(false);
3612
+ const rows = (0, import_react2.useMemo)(
3613
+ () => features === void 0 ? [] : deriveIncludedFeatures(features, {
3614
+ locale,
3615
+ showCredits,
3616
+ showWarningThresholdAsLimit,
3617
+ visibleFeatures
3618
+ }),
3619
+ [
3620
+ features,
3621
+ locale,
3622
+ showCredits,
3623
+ showWarningThresholdAsLimit,
3624
+ visibleFeatures
3625
+ ]
3626
+ );
3627
+ const Heading = `h${headingLevel}`;
3628
+ const canExpand = rows.length > VISIBLE_FEATURE_COUNT;
3629
+ const shown = canExpand && !expanded ? rows.slice(0, VISIBLE_FEATURE_COUNT) : rows;
3630
+ const unavailable = features === void 0 && httpStatus(error) === 404;
3631
+ const errorMessage = error === void 0 ? void 0 : unavailable ? t("includedFeaturesUnavailable") : t("includedFeaturesError");
3632
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
3633
+ StatusFrame,
3634
+ {
3635
+ className: cx("schematic-card", "schematic-included-features", className),
3636
+ error,
3637
+ errorMessage,
3638
+ hasData: features !== void 0,
3639
+ isPending,
3640
+ loadingLabel: t("includedFeaturesLoading"),
3641
+ onRetry: refetch,
3642
+ retryText: t("retry"),
3643
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IncludedFeaturesSkeleton, { showHeader }),
3644
+ children: [
3645
+ 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") }) }),
3646
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "schematic-included-features__list", children: shown.map((row) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
3647
+ "li",
3648
+ {
3649
+ className: "schematic-included-features__row",
3650
+ "data-testid": "schematic-included-feature",
3651
+ children: [
3652
+ showIcon && row.icon !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3653
+ "i",
3654
+ {
3655
+ "aria-hidden": "true",
3656
+ className: `schematic-icon schematic-icon--${row.icon} schematic-included-features__icon`
3657
+ }
3658
+ ),
3659
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-included-features__details", children: [
3660
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-included-features__name", children: row.name }),
3661
+ showDescription && row.description !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-muted schematic-small", children: row.description }),
3662
+ row.perLicenseCredits.map((credits, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3663
+ "span",
3664
+ {
3665
+ className: "schematic-muted schematic-small",
3666
+ children: t("includedFeaturesPerLicense", {
3667
+ amount: credits.amount,
3668
+ creditName: credits.creditName,
3669
+ licenseName: credits.licenseName
3670
+ })
3671
+ },
3672
+ `${credits.creditName}-${index}`
3673
+ )),
3674
+ showExpiration && row.expiresAt !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("em", { className: "schematic-muted schematic-small", children: t("includedFeaturesExpires", { date: row.expiresAt.text }) })
3675
+ ] }),
3676
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3677
+ UsageDetails,
3678
+ {
3679
+ row,
3680
+ showEntitlement,
3681
+ showHardLimit,
3682
+ showUsage,
3683
+ t,
3684
+ locale
3685
+ }
3686
+ )
3687
+ ]
3688
+ },
3689
+ row.featureId
3690
+ )) }),
3691
+ canExpand && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
3692
+ "button",
3693
+ {
3694
+ "aria-expanded": expanded,
3695
+ className: "schematic-link-button schematic-included-features__toggle",
3696
+ type: "button",
3697
+ onClick: () => setExpanded((value) => !value),
3698
+ children: [
3699
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3700
+ "i",
3701
+ {
3702
+ "aria-hidden": "true",
3703
+ className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
3704
+ }
3705
+ ),
3706
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("includedFeaturesHideAll") : t("includedFeaturesSeeAll") })
3707
+ ]
3708
+ }
3709
+ )
3710
+ ]
3711
+ }
3712
+ );
3713
+ }
3714
+ function UsageDetails({
3715
+ locale,
3716
+ row,
3717
+ showEntitlement,
3718
+ showHardLimit,
3719
+ showUsage,
3720
+ t
3721
+ }) {
3722
+ const usage = usageText(row.usage, row.usageSummary, t);
3723
+ if (row.entitlement === null && usage === null) {
3724
+ return null;
3725
+ }
3726
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-included-features__usage", children: [
3727
+ showEntitlement && row.entitlement !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "schematic-included-features__entitlement", children: [
3728
+ entitlementText2(row.entitlement, t),
3729
+ showHardLimit && row.hardLimit !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
3730
+ amount: row.hardLimit.amount,
3731
+ units: row.hardLimit.units
3732
+ }) })
3733
+ ] }),
3734
+ showUsage && usage !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "schematic-muted schematic-small schematic-included-features__used", children: [
3735
+ usage,
3736
+ 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)(
3737
+ PriceTiers,
3738
+ {
3739
+ currency: row.tiers.currency,
3740
+ locale,
3741
+ mode: row.tiers.mode,
3742
+ period: row.tiers.period,
3743
+ ranges: row.tiers.ranges,
3744
+ t,
3745
+ unit: row.source.featureSingularName ?? row.name
3746
+ }
3747
+ ) })
3748
+ ] })
3749
+ ] });
3750
+ }
3751
+ function entitlementText2(text, t) {
3752
+ switch (text.kind) {
3753
+ case "units":
3754
+ return t("usageUnits", { amount: text.amount, units: text.units });
3755
+ case "perUnit":
3756
+ return t("usagePerUnit", { cost: text.cost, unit: text.unit });
3757
+ case "perPackage":
3758
+ return t("usagePerPackage", {
3759
+ cost: text.cost,
3760
+ size: text.size,
3761
+ units: text.units
3762
+ });
3763
+ case "tierUpTo":
3764
+ return t("usageTierUpTo", { amount: text.amount, feature: text.feature });
3765
+ case "tierUnlimited":
3766
+ return t("usageTierUnlimited", { feature: text.feature });
3767
+ case "perUse":
3768
+ return t("usagePerUse", { amount: text.amount, units: text.units });
3769
+ case "unlimited":
3770
+ return t("usageUnlimited", { item: text.item });
3771
+ }
3772
+ }
3773
+ function usageText(segments, summary, t) {
3774
+ if (segments.length > 0) {
3775
+ return segments.map((segment) => segmentText(segment, t)).join(" \u2022 ");
3776
+ }
3777
+ if (summary === null) {
3778
+ return null;
3779
+ }
3780
+ return summary.kind === "limited" ? t("usageLimited", {
3781
+ amount: summary.amount,
3782
+ allocation: summary.allocation
3783
+ }) : t("usageUnlimitedUsed", { amount: summary.amount });
3784
+ }
3785
+ function segmentText(segment, t) {
3786
+ switch (segment.kind) {
3787
+ case "unitPricePerPeriod": {
3788
+ const period = shortPeriod(segment.period, t) ?? segment.period;
3789
+ return segment.size > 1 ? t("usagePackagePricePerPeriod", {
3790
+ cost: segment.cost,
3791
+ size: segment.size,
3792
+ units: segment.units,
3793
+ period
3794
+ }) : t("usageUnitPricePerPeriod", {
3795
+ cost: segment.cost,
3796
+ unit: segment.units,
3797
+ period
3798
+ });
3799
+ }
3800
+ case "used":
3801
+ return t("usageUsed", { amount: segment.amount, units: segment.units });
3802
+ case "cost": {
3803
+ const period = segment.period === null ? void 0 : shortPeriod(segment.period, t);
3804
+ return period === void 0 ? segment.cost : `${segment.cost}/${period}`;
3805
+ }
3806
+ case "resets":
3807
+ return t("usageResets", { date: segment.date });
3808
+ }
3809
+ }
3810
+ function IncludedFeaturesSkeleton({ showHeader }) {
3811
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-skeleton", children: [
3812
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__heading" }),
3813
+ [0, 1, 2].map((index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-skeleton__row", children: [
3814
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
3815
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
3816
+ ] }, index))
3817
+ ] });
3818
+ }
3819
+ IncludedFeatures.resources = ["featureUsage"];
3820
+
3821
+ // src/elements/Invoices.tsx
3822
+ var import_schematic_react3 = require("@schematichq/schematic-react");
3823
+ var import_react3 = require("react");
3824
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2932
3825
  var SKELETON_ROWS = 4;
2933
3826
  function Invoices({
2934
3827
  className,
@@ -2948,15 +3841,15 @@ function Invoices({
2948
3841
  isPending,
2949
3842
  loadMore,
2950
3843
  refetch
2951
- } = (0, import_schematic_react2.useInvoices)(query);
3844
+ } = (0, import_schematic_react3.useInvoices)(query);
2952
3845
  const locale = useResolvedLocale(localeProp);
2953
3846
  const t = useTranslator(strings, localeProp);
2954
- const [expanded, setExpanded] = (0, import_react2.useState)(false);
2955
- const list = (0, import_react2.useMemo)(
3847
+ const [expanded, setExpanded] = (0, import_react3.useState)(false);
3848
+ const list = (0, import_react3.useMemo)(
2956
3849
  () => page === void 0 ? void 0 : deriveInvoiceList(page, { locale }),
2957
3850
  [locale, page]
2958
3851
  );
2959
- const headingId = (0, import_react2.useId)();
3852
+ const headingId = (0, import_react3.useId)();
2960
3853
  const rows = list?.rows ?? [];
2961
3854
  const canCollapse = collapsible && rows.length > limit;
2962
3855
  const showingAll = !canCollapse || expanded;
@@ -2968,7 +3861,7 @@ function Invoices({
2968
3861
  );
2969
3862
  const unavailable = list === void 0 && httpStatus(error) === 404;
2970
3863
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("invoicesUnavailable") : t("invoicesError");
2971
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3864
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2972
3865
  StatusFrame,
2973
3866
  {
2974
3867
  className: cx("schematic-card", "schematic-invoices", className),
@@ -2979,7 +3872,7 @@ function Invoices({
2979
3872
  loadingLabel: t("invoicesLoading"),
2980
3873
  onRetry: refetch,
2981
3874
  retryText: t("retry"),
2982
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3875
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2983
3876
  InvoicesSkeleton,
2984
3877
  {
2985
3878
  columns,
@@ -2987,22 +3880,22 @@ function Invoices({
2987
3880
  showHeader
2988
3881
  }
2989
3882
  ),
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)(
3883
+ children: list !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3884
+ 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") }) }),
3885
+ 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
3886
  "ul",
2994
3887
  {
2995
3888
  className: "schematic-invoices__list",
2996
3889
  "aria-label": showHeader ? void 0 : t("invoicesHeader"),
2997
3890
  "aria-labelledby": showHeader ? headingId : void 0,
2998
- children: visible.map((row) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3891
+ children: visible.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2999
3892
  "li",
3000
3893
  {
3001
3894
  className: "schematic-invoices__row",
3002
3895
  "data-testid": "schematic-invoice",
3003
3896
  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)(
3897
+ showDate && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-invoices__date", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InvoiceDate, { row, t }) }),
3898
+ showAmount && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3006
3899
  "span",
3007
3900
  {
3008
3901
  className: cx(
@@ -3019,8 +3912,8 @@ function Invoices({
3019
3912
  ))
3020
3913
  }
3021
3914
  ),
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)(
3915
+ (canCollapse || showingAll && list.hasMore) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-invoices__actions", children: [
3916
+ canCollapse && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3024
3917
  "button",
3025
3918
  {
3026
3919
  "aria-expanded": expanded,
@@ -3028,18 +3921,23 @@ function Invoices({
3028
3921
  type: "button",
3029
3922
  onClick: () => setExpanded((value) => !value),
3030
3923
  children: [
3031
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3032
- "span",
3924
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3925
+ "i",
3033
3926
  {
3034
3927
  "aria-hidden": "true",
3035
- className: "schematic-invoices__chevron"
3928
+ className: cx(
3929
+ "schematic-icon",
3930
+ expanded ? "schematic-icon--chevron-up" : "schematic-icon--chevron-down",
3931
+ "schematic-chevron",
3932
+ "schematic-invoices__chevron"
3933
+ )
3036
3934
  }
3037
3935
  ),
3038
- expanded ? t("invoicesSeeLess") : t("invoicesSeeMore")
3936
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("invoicesSeeLess") : t("invoicesSeeMore") })
3039
3937
  ]
3040
3938
  }
3041
3939
  ),
3042
- showingAll && list.hasMore && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3940
+ showingAll && list.hasMore && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3043
3941
  "button",
3044
3942
  {
3045
3943
  className: "schematic-link-button schematic-invoices__load-more",
@@ -3062,9 +3960,9 @@ function InvoicesSkeleton({
3062
3960
  rows,
3063
3961
  showHeader
3064
3962
  }) {
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)(
3963
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-skeleton", children: [
3964
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__heading" }),
3965
+ 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
3966
  "div",
3069
3967
  {
3070
3968
  className: "schematic-skeleton__cell",
@@ -3076,10 +3974,10 @@ function InvoicesSkeleton({
3076
3974
  }
3077
3975
  function InvoiceDate({ row, t }) {
3078
3976
  if (row.url === null) {
3079
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-invoices__date-text", children: row.dateText });
3977
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-invoices__date-text", children: row.dateText });
3080
3978
  }
3081
3979
  const label = row.dateText === "" ? t("invoicesUndated") : row.dateText;
3082
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3980
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3083
3981
  "a",
3084
3982
  {
3085
3983
  className: "schematic-invoices__link",
@@ -3093,10 +3991,10 @@ function InvoiceDate({ row, t }) {
3093
3991
  Invoices.resources = ["invoices"];
3094
3992
 
3095
3993
  // src/elements/PaymentMethods.tsx
3096
- 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)));
3994
+ var import_schematic_react5 = require("@schematichq/schematic-react");
3995
+ var import_react5 = require("react");
3996
+ var import_jsx_runtime7 = require("react/jsx-runtime");
3997
+ var PaymentMethodForm2 = (0, import_react5.lazy)(() => Promise.resolve().then(() => (init_PaymentMethodForm(), PaymentMethodForm_exports)));
3100
3998
  function PaymentMethods({
3101
3999
  allowEdit = true,
3102
4000
  checkoutPrefill,
@@ -3117,24 +4015,24 @@ function PaymentMethods({
3117
4015
  refetch,
3118
4016
  remove,
3119
4017
  setDefault
3120
- } = (0, import_schematic_react4.usePaymentMethods)();
4018
+ } = (0, import_schematic_react5.usePaymentMethods)();
3121
4019
  const locale = useResolvedLocale(localeProp);
3122
4020
  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)(
4021
+ const [dialog, setDialog] = (0, import_react5.useState)(null);
4022
+ const [choosing, setChoosing] = (0, import_react5.useState)(false);
4023
+ const [lastWrite, setLastWrite] = (0, import_react5.useState)(null);
4024
+ const derived = (0, import_react5.useMemo)(
3127
4025
  () => methods === void 0 ? void 0 : derivePaymentMethods(methods, { locale }),
3128
4026
  [locale, methods]
3129
4027
  );
3130
- const write = (0, import_react4.useCallback)(async (next) => {
4028
+ const write = (0, import_react5.useCallback)(async (next) => {
3131
4029
  setLastWrite(next);
3132
4030
  try {
3133
4031
  await next.action();
3134
4032
  } catch {
3135
4033
  }
3136
4034
  }, []);
3137
- const saved = (0, import_react4.useCallback)(
4035
+ const saved = (0, import_react5.useCallback)(
3138
4036
  async (paymentMethodId) => {
3139
4037
  await write({
3140
4038
  action: () => setDefault(paymentMethodId),
@@ -3145,16 +4043,16 @@ function PaymentMethods({
3145
4043
  },
3146
4044
  [setDefault, write]
3147
4045
  );
3148
- const open = (0, import_react4.useCallback)(() => {
4046
+ const open = (0, import_react5.useCallback)(() => {
3149
4047
  setLastWrite(null);
3150
4048
  setChoosing(false);
3151
4049
  setDialog("current");
3152
4050
  }, []);
3153
- const close = (0, import_react4.useCallback)(() => setDialog(null), []);
4051
+ const close = (0, import_react5.useCallback)(() => setDialog(null), []);
3154
4052
  const Heading = `h${headingLevel}`;
3155
4053
  const unavailable = derived === void 0 && httpStatus(error) === 404;
3156
4054
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("paymentMethodsUnavailable") : t("paymentMethodsError");
3157
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4055
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3158
4056
  StatusFrame,
3159
4057
  {
3160
4058
  className: cx("schematic-card", "schematic-payment-methods", className),
@@ -3165,9 +4063,9 @@ function PaymentMethods({
3165
4063
  loadingLabel: t("paymentMethodsLoading"),
3166
4064
  onRetry: refetch,
3167
4065
  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)(
4066
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PaymentMethodsSkeleton, { showHeader }),
4067
+ children: derived !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
4068
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3171
4069
  PaymentMethodsHeader,
3172
4070
  {
3173
4071
  derived,
@@ -3176,7 +4074,7 @@ function PaymentMethods({
3176
4074
  t
3177
4075
  }
3178
4076
  ),
3179
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4077
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3180
4078
  "button",
3181
4079
  {
3182
4080
  className: "schematic-link-button schematic-payment-methods__edit",
@@ -3185,7 +4083,7 @@ function PaymentMethods({
3185
4083
  children: derived.current === null ? t("paymentMethodsAdd") : t("paymentMethodsEdit")
3186
4084
  }
3187
4085
  ) }),
3188
- dialog !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4086
+ dialog !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3189
4087
  PaymentMethodsDialog,
3190
4088
  {
3191
4089
  checkoutPrefill,
@@ -3237,7 +4135,7 @@ function PaymentMethodsDialog({
3237
4135
  const { current, others, rows } = derived;
3238
4136
  const hasMethods = rows.length > 0;
3239
4137
  const showForm = view === "add" || !hasMethods;
3240
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4138
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3241
4139
  Dialog,
3242
4140
  {
3243
4141
  className: "schematic-payment-methods__dialog",
@@ -3246,11 +4144,11 @@ function PaymentMethodsDialog({
3246
4144
  title: t("paymentMethodsDialogTitle"),
3247
4145
  onClose,
3248
4146
  children: [
3249
- showForm ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3250
- import_react4.Suspense,
4147
+ showForm ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4148
+ import_react5.Suspense,
3251
4149
  {
3252
- fallback: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
3253
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4150
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
4151
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3254
4152
  PaymentMethodForm2,
3255
4153
  {
3256
4154
  checkoutPrefill,
@@ -3262,8 +4160,8 @@ function PaymentMethodsDialog({
3262
4160
  }
3263
4161
  )
3264
4162
  }
3265
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3266
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4163
+ ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
4164
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3267
4165
  PaymentMethodsHeader,
3268
4166
  {
3269
4167
  derived,
@@ -3272,7 +4170,7 @@ function PaymentMethodsDialog({
3272
4170
  t
3273
4171
  }
3274
4172
  ),
3275
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4173
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3276
4174
  "button",
3277
4175
  {
3278
4176
  className: "schematic-link-button schematic-payment-methods__remove-current",
@@ -3282,7 +4180,7 @@ function PaymentMethodsDialog({
3282
4180
  children: t("paymentMethodsRemove")
3283
4181
  }
3284
4182
  ) }),
3285
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4183
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3286
4184
  "button",
3287
4185
  {
3288
4186
  "aria-expanded": choosing,
@@ -3290,14 +4188,15 @@ function PaymentMethodsDialog({
3290
4188
  type: "button",
3291
4189
  onClick: onChoose,
3292
4190
  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)(
4191
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-payment-methods__choose-label", children: t("paymentMethodsChooseDifferent") }),
4192
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3295
4193
  "i",
3296
4194
  {
3297
4195
  "aria-hidden": "true",
3298
4196
  className: cx(
3299
4197
  "schematic-icon",
3300
4198
  choosing ? "schematic-icon--chevron-up" : "schematic-icon--chevron-down",
4199
+ "schematic-chevron",
3301
4200
  "schematic-payment-methods__chevron"
3302
4201
  )
3303
4202
  }
@@ -3305,13 +4204,13 @@ function PaymentMethodsDialog({
3305
4204
  ]
3306
4205
  }
3307
4206
  ),
3308
- choosing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3309
- others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4207
+ choosing && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
4208
+ others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3310
4209
  "ul",
3311
4210
  {
3312
4211
  "aria-label": t("paymentMethodsChooseDifferent"),
3313
4212
  className: "schematic-payment-methods__list",
3314
- children: others.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4213
+ children: others.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3315
4214
  "li",
3316
4215
  {
3317
4216
  className: "schematic-payment-methods__row",
@@ -3319,11 +4218,11 @@ function PaymentMethodsDialog({
3319
4218
  "data-kind": row.kind,
3320
4219
  "data-testid": "schematic-payment-method",
3321
4220
  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", {
4221
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Method, { row, t }),
4222
+ row.expiresShort !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-payment-methods__expires", children: t("paymentMethodsExpires", {
3324
4223
  date: row.expiresShort
3325
4224
  }) }),
3326
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4225
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3327
4226
  "button",
3328
4227
  {
3329
4228
  className: "schematic-link-button schematic-payment-methods__set-default",
@@ -3333,7 +4232,7 @@ function PaymentMethodsDialog({
3333
4232
  children: t("paymentMethodsSetDefault")
3334
4233
  }
3335
4234
  ),
3336
- row.canRemove && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4235
+ row.canRemove && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3337
4236
  "button",
3338
4237
  {
3339
4238
  "aria-label": t("paymentMethodsRemove"),
@@ -3341,7 +4240,7 @@ function PaymentMethodsDialog({
3341
4240
  disabled: isMutating,
3342
4241
  type: "button",
3343
4242
  onClick: () => onRemove(row),
3344
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4243
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3345
4244
  "i",
3346
4245
  {
3347
4246
  "aria-hidden": "true",
@@ -3356,7 +4255,7 @@ function PaymentMethodsDialog({
3356
4255
  ))
3357
4256
  }
3358
4257
  ),
3359
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4258
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3360
4259
  "button",
3361
4260
  {
3362
4261
  className: "schematic-cta schematic-payment-methods__add-new",
@@ -3368,17 +4267,17 @@ function PaymentMethodsDialog({
3368
4267
  )
3369
4268
  ] })
3370
4269
  ] }),
3371
- mutationError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4270
+ mutationError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3372
4271
  "p",
3373
4272
  {
3374
4273
  className: "schematic-status-note schematic-error schematic-payment-methods__error",
3375
4274
  role: "alert",
3376
4275
  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)(
4276
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-payment-methods__error-message", children: mutationError }),
4277
+ onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3379
4278
  "button",
3380
4279
  {
3381
- className: "schematic-link-button schematic-payment-methods__error-retry",
4280
+ className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-payment-methods__error-retry",
3382
4281
  disabled: isMutating,
3383
4282
  type: "button",
3384
4283
  onClick: onRetry,
@@ -3398,9 +4297,9 @@ function PaymentMethodsHeader({
3398
4297
  showExpiration,
3399
4298
  t
3400
4299
  }) {
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)(
4300
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-header", children: [
4301
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Heading, { className: "schematic-header__title", children: t("paymentMethodsHeader") }),
4302
+ showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3404
4303
  "span",
3405
4304
  {
3406
4305
  className: "schematic-small schematic-payment-methods__expiry-warning",
@@ -3415,37 +4314,37 @@ function MethodPill({
3415
4314
  row,
3416
4315
  t
3417
4316
  }) {
3418
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4317
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3419
4318
  "div",
3420
4319
  {
3421
4320
  className: "schematic-payment-methods__current",
3422
4321
  "data-testid": "schematic-payment-method-current",
3423
4322
  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 }),
4323
+ row === null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-payment-methods__empty", children: t("paymentMethodsEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Method, { row, t }),
3425
4324
  children
3426
4325
  ]
3427
4326
  }
3428
4327
  );
3429
4328
  }
3430
4329
  function Method({ row, t }) {
3431
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4330
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3432
4331
  "span",
3433
4332
  {
3434
4333
  className: "schematic-payment-methods__method",
3435
4334
  "data-brand": row.brand,
3436
4335
  "data-kind": row.kind,
3437
4336
  children: [
3438
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4337
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3439
4338
  "i",
3440
4339
  {
3441
4340
  "aria-hidden": "true",
3442
4341
  className: `schematic-icon schematic-icon--${row.icon} schematic-payment-methods__icon`
3443
4342
  }
3444
4343
  ),
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: [
4344
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-payment-methods__label", children: labelText(row.label, t) }),
4345
+ row.last4 !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3447
4346
  " ",
3448
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-payment-methods__last4", children: row.last4 })
4347
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-payment-methods__last4", children: row.last4 })
3449
4348
  ] })
3450
4349
  ]
3451
4350
  }
@@ -3459,24 +4358,24 @@ function expiryWarningText(derived, t) {
3459
4358
  return derived.expiryWarning === "expired" ? t("paymentMethodsExpired") : t("paymentMethodsExpiresInMonths", { months });
3460
4359
  }
3461
4360
  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" })
4361
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-skeleton", children: [
4362
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__heading" }),
4363
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-skeleton__row", children: [
4364
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "method" }),
4365
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "action" })
3467
4366
  ] })
3468
4367
  ] });
3469
4368
  }
3470
4369
  function FormSkeleton({ label }) {
3471
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4370
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3472
4371
  "div",
3473
4372
  {
3474
4373
  "aria-busy": "true",
3475
4374
  className: "schematic-payment-methods__form",
3476
4375
  "data-state": "pending",
3477
4376
  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" }) }) })
4377
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-hidden", children: label }),
4378
+ /* @__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" }) }) })
3480
4379
  ]
3481
4380
  }
3482
4381
  );
@@ -3484,9 +4383,9 @@ function FormSkeleton({ label }) {
3484
4383
  PaymentMethods.resources = ["paymentMethods"];
3485
4384
 
3486
4385
  // 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");
4386
+ var import_schematic_react6 = require("@schematichq/schematic-react");
4387
+ var import_react6 = require("react");
4388
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3490
4389
  function UpcomingBill({
3491
4390
  className,
3492
4391
  headingLevel = 2,
@@ -3497,10 +4396,10 @@ function UpcomingBill({
3497
4396
  showHeader = true,
3498
4397
  strings
3499
4398
  }) {
3500
- const { data: invoice, error, isPending, refetch } = (0, import_schematic_react5.useUpcomingInvoice)();
4399
+ const { data: invoice, error, isPending, refetch } = (0, import_schematic_react6.useUpcomingInvoice)();
3501
4400
  const locale = useResolvedLocale(localeProp);
3502
4401
  const t = useTranslator(strings, localeProp);
3503
- const bill = (0, import_react5.useMemo)(
4402
+ const bill = (0, import_react6.useMemo)(
3504
4403
  () => invoice === void 0 || invoice === null ? null : deriveUpcomingInvoice(invoice, { locale }),
3505
4404
  [invoice, locale]
3506
4405
  );
@@ -3509,7 +4408,7 @@ function UpcomingBill({
3509
4408
  const discountRow = showDiscounts && bill !== null && bill.discounts.length > 0;
3510
4409
  const unavailable = invoice === void 0 && httpStatus(error) === 404;
3511
4410
  const errorMessage = error === void 0 ? void 0 : unavailable ? t("upcomingBillUnavailable") : t("upcomingBillError");
3512
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4411
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3513
4412
  StatusFrame,
3514
4413
  {
3515
4414
  className: cx("schematic-card", "schematic-upcoming-bill", className),
@@ -3520,11 +4419,11 @@ function UpcomingBill({
3520
4419
  loadingLabel: t("upcomingBillLoading"),
3521
4420
  onRetry: refetch,
3522
4421
  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)(
4422
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(UpcomingBillSkeleton, { showHeader }),
4423
+ children: bill === null ? invoice !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4424
+ showHeader && bill.dueAt !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
4425
+ showAmount && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-upcoming-bill__amount", children: [
4426
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3528
4427
  "span",
3529
4428
  {
3530
4429
  className: "schematic-upcoming-bill__total",
@@ -3532,46 +4431,46 @@ function UpcomingBill({
3532
4431
  children: bill.amountDueText
3533
4432
  }
3534
4433
  ),
3535
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
4434
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
3536
4435
  ] }),
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)(
4436
+ (balanceRows || discountRow) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-upcoming-bill__rows", children: [
4437
+ balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3539
4438
  "div",
3540
4439
  {
3541
4440
  className: "schematic-row schematic-upcoming-bill__balance-applied",
3542
4441
  "data-testid": "schematic-balance-applied",
3543
4442
  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 })
4443
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
4444
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
3546
4445
  ]
3547
4446
  }
3548
4447
  ),
3549
- balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
4448
+ balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3550
4449
  "div",
3551
4450
  {
3552
4451
  className: "schematic-row schematic-upcoming-bill__balance-remaining",
3553
4452
  "data-testid": "schematic-balance-remaining",
3554
4453
  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 })
4454
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
4455
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
3557
4456
  ]
3558
4457
  }
3559
4458
  ),
3560
- discountRow && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
4459
+ discountRow && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3561
4460
  "div",
3562
4461
  {
3563
4462
  className: "schematic-row schematic-upcoming-bill__discount-row",
3564
4463
  "data-testid": "schematic-discounts",
3565
4464
  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)(
4465
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
4466
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3568
4467
  "li",
3569
4468
  {
3570
4469
  className: "schematic-upcoming-bill__discount",
3571
4470
  "data-testid": "schematic-discount",
3572
4471
  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) })
4472
+ discount.code !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
4473
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
3575
4474
  ]
3576
4475
  },
3577
4476
  `${discount.couponName}-${index}`
@@ -3585,10 +4484,10 @@ function UpcomingBill({
3585
4484
  );
3586
4485
  }
3587
4486
  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" }) })
4487
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-skeleton", children: [
4488
+ showHeader && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__heading" }),
4489
+ /* @__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": "amount" }) }),
4490
+ /* @__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": "row" }) })
3592
4491
  ] });
3593
4492
  }
3594
4493
  function discountText(discount, t) {