@schematichq/schematic-components 0.7.5 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10765,6 +10765,7 @@ function BillingPriceViewFromJSONTyped(json, ignoreDiscriminator) {
10765
10765
  interval: json["interval"],
10766
10766
  isActive: json["is_active"],
10767
10767
  meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
10768
+ packageSize: json["package_size"],
10768
10769
  price: json["price"],
10769
10770
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
10770
10771
  priceExternalId: json["price_external_id"],
@@ -10826,6 +10827,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
10826
10827
  interval: json["interval"],
10827
10828
  meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
10828
10829
  name: json["name"],
10830
+ packageSize: json["package_size"],
10829
10831
  price: json["price"],
10830
10832
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
10831
10833
  priceExternalId: json["price_external_id"],
@@ -13193,7 +13195,7 @@ var EmbedProvider = ({
13193
13195
  (0, import_react11.useEffect)(() => {
13194
13196
  if (accessToken) {
13195
13197
  const { headers = {} } = apiConfig ?? {};
13196
- headers["X-Schematic-Components-Version"] = "0.7.5";
13198
+ headers["X-Schematic-Components-Version"] = "0.7.7";
13197
13199
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13198
13200
  const config = new Configuration({
13199
13201
  ...apiConfig,
@@ -14450,43 +14452,61 @@ var ProgressBar = ({
14450
14452
 
14451
14453
  // src/components/ui/text/styles.ts
14452
14454
  var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
14453
- TextPropNames2["Align"] = "$align";
14454
14455
  TextPropNames2["Font"] = "$font";
14455
14456
  TextPropNames2["Size"] = "$size";
14456
14457
  TextPropNames2["Weight"] = "$weight";
14457
14458
  TextPropNames2["Color"] = "$color";
14458
14459
  TextPropNames2["Leading"] = "$leading";
14460
+ TextPropNames2["Align"] = "$align";
14459
14461
  return TextPropNames2;
14460
14462
  })(TextPropNames || {});
14461
- var Text = dt.span.attrs(({ onClick }) => ({
14463
+ var Text = dt.span.withConfig({
14464
+ shouldForwardProp: (prop) => prop !== "display"
14465
+ }).attrs(({ onClick }) => ({
14462
14466
  ...onClick && { tabIndex: 0 }
14463
- }))`
14464
- ${({ $font }) => $font && lt`
14465
- font-family: ${$font}, sans-serif;
14466
- `};
14467
- ${({ $size }) => typeof $size !== "undefined" && lt`
14468
- font-size: ${typeof $size === "number" ? `${$size / TEXT_BASE_SIZE}rem` : $size};
14469
- `};
14470
- ${({ $weight }) => typeof $weight !== "undefined" && lt`
14471
- font-weight: ${$weight};
14472
- font-variation-settings: "wght" ${$weight};
14473
- `};
14474
- ${({ $leading }) => attr("line-height", $leading)};
14475
- ${({ $align }) => attr("text-align", $align)};
14476
- color: ${({ $color, theme }) => $color || theme.typography.text.color};
14477
-
14478
- &:focus-visible {
14479
- outline: 2px solid ${({ theme }) => theme.primary};
14480
- outline-offset: 2px;
14481
- }
14482
-
14483
- ${({ onClick }) => onClick && lt`
14484
- &:hover {
14485
- cursor: pointer;
14486
- text-decoration: underline;
14467
+ }))(
14468
+ ({
14469
+ display = "text",
14470
+ theme,
14471
+ onClick,
14472
+ $font,
14473
+ $size,
14474
+ $weight,
14475
+ $color,
14476
+ $leading = 1.35,
14477
+ $align
14478
+ }) => {
14479
+ const settings = theme.typography[display];
14480
+ const fontFamily = $font || settings.fontFamily;
14481
+ const fontSize = $size || settings.fontSize;
14482
+ const fontWeight = $weight || settings.fontWeight;
14483
+ const color = $color || settings.color;
14484
+ return lt`
14485
+ font-family: ${fontFamily}, sans-serif;
14486
+ font-size: ${typeof fontSize === "number" ? `${fontSize / TEXT_BASE_SIZE}rem` : fontSize};
14487
+ font-weight: ${fontWeight};
14488
+ font-variation-settings: "wght" ${fontWeight};
14489
+ line-height: ${$leading};
14490
+ color: ${color};
14491
+
14492
+ ${$align && lt`
14493
+ text-align: ${$align};
14494
+ `};
14495
+
14496
+ ${onClick && lt`
14497
+ &:hover {
14498
+ cursor: pointer;
14499
+ text-decoration: underline;
14500
+ }
14501
+ `}
14502
+
14503
+ &:focus-visible {
14504
+ outline: 2px solid ${({ theme: theme2 }) => theme2.primary};
14505
+ outline-offset: 2px;
14487
14506
  }
14488
- `}
14489
- `;
14507
+ `;
14508
+ }
14509
+ );
14490
14510
 
14491
14511
  // src/components/ui/tooltip/Tooltip.tsx
14492
14512
  var import_debounce = __toESM(require_debounce());
@@ -14773,7 +14793,7 @@ var Container2 = dt.div`
14773
14793
  all: initial;
14774
14794
  box-sizing: border-box;
14775
14795
  display: block;
14776
- font-size: ${TEXT_BASE_SIZE}px;
14796
+ font-size: 1rem;
14777
14797
  line-height: 1.35;
14778
14798
  width: 100%;
14779
14799
  height: 100%;
@@ -14830,6 +14850,7 @@ var StageButton = ({
14830
14850
  checkoutStages,
14831
14851
  hasAddOns,
14832
14852
  hasPayInAdvanceEntitlements,
14853
+ hasUnstagedChanges,
14833
14854
  isLoading,
14834
14855
  requiresPayment,
14835
14856
  setCheckoutStage,
@@ -14841,7 +14862,7 @@ var StageButton = ({
14841
14862
  EmbedButton,
14842
14863
  {
14843
14864
  type: "button",
14844
- disabled: isLoading || !canUpdateSubscription,
14865
+ disabled: isLoading || !hasUnstagedChanges || !canUpdateSubscription,
14845
14866
  onClick: checkout,
14846
14867
  isLoading,
14847
14868
  children: t2("Subscribe and close")
@@ -14882,7 +14903,7 @@ var StageButton = ({
14882
14903
  EmbedButton,
14883
14904
  {
14884
14905
  type: "button",
14885
- disabled: !canUpdateSubscription,
14906
+ disabled: !hasUnstagedChanges || !canUpdateSubscription,
14886
14907
  onClick: async () => {
14887
14908
  checkout();
14888
14909
  },
@@ -15008,7 +15029,7 @@ var StageButton = ({
15008
15029
  EmbedButton,
15009
15030
  {
15010
15031
  type: "button",
15011
- disabled: isLoading || !canCheckout,
15032
+ disabled: isLoading || !hasUnstagedChanges || !canCheckout,
15012
15033
  onClick: checkout,
15013
15034
  isLoading,
15014
15035
  children: canTrial ? t2("Start trial") : t2("Pay now")
@@ -15212,14 +15233,6 @@ var Sidebar = ({
15212
15233
  }
15213
15234
  }, [t2, api, hydrate, setError, setIsLoading, setLayout]);
15214
15235
  const selectedAddOns = addOns.filter((addOn) => addOn.isSelected);
15215
- const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
15216
- const canUpdateSubscription = mode === "edit" || api !== null && (willPlanChange || // TODO: test add-on comparison for finding "changes"
15217
- selectedAddOns.length !== currentAddOns.length || !selectedAddOns.every(
15218
- (addOn) => currentAddOns.some((currentAddOn) => addOn.id === currentAddOn.id)
15219
- ) || payInAdvanceEntitlements.every(
15220
- ({ quantity, usage }) => quantity >= usage
15221
- )) && !isLoading;
15222
- const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15223
15236
  const {
15224
15237
  changedUsageBasedEntitlements,
15225
15238
  addedUsageBasedEntitlements,
@@ -15276,6 +15289,7 @@ var Sidebar = ({
15276
15289
  currentUsageBasedEntitlements,
15277
15290
  usageBasedEntitlements
15278
15291
  ]);
15292
+ const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
15279
15293
  const removedAddOns = currentAddOns.filter(
15280
15294
  (current) => !selectedAddOns.some((selected) => current.id === selected.id)
15281
15295
  );
@@ -15283,6 +15297,10 @@ var Sidebar = ({
15283
15297
  (selected) => !currentAddOns.some((current) => selected.id === current.id)
15284
15298
  );
15285
15299
  const willAddOnsChange = removedAddOns.length > 0 || addedAddOns.length > 0;
15300
+ const willPayInAdvanceEntitlementsChange = payInAdvanceEntitlements.length > 0 && payInAdvanceEntitlements.some(({ quantity, usage }) => quantity !== usage);
15301
+ const hasUnstagedChanges = willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
15302
+ const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
15303
+ const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15286
15304
  const isTrialable = selectedPlan?.companyCanTrial;
15287
15305
  const today = /* @__PURE__ */ new Date();
15288
15306
  const trialEndsOn = new Date(today);
@@ -16194,6 +16212,7 @@ var Sidebar = ({
16194
16212
  checkoutStages,
16195
16213
  hasAddOns: addOns.length > 0,
16196
16214
  hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
16215
+ hasUnstagedChanges,
16197
16216
  isLoading,
16198
16217
  requiresPayment,
16199
16218
  setCheckoutStage,
@@ -16374,158 +16393,6 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
16374
16393
  ) });
16375
16394
  };
16376
16395
 
16377
- // node_modules/@stripe/stripe-js/dist/index.mjs
16378
- var RELEASE_TRAIN = "basil";
16379
- var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
16380
- return version === 3 ? "v3" : version;
16381
- };
16382
- var ORIGIN = "https://js.stripe.com";
16383
- var STRIPE_JS_URL = "".concat(ORIGIN, "/").concat(RELEASE_TRAIN, "/stripe.js");
16384
- var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
16385
- var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
16386
- var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
16387
- var isStripeJSURL = function isStripeJSURL2(url) {
16388
- return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
16389
- };
16390
- var findScript = function findScript2() {
16391
- var scripts = document.querySelectorAll('script[src^="'.concat(ORIGIN, '"]'));
16392
- for (var i2 = 0; i2 < scripts.length; i2++) {
16393
- var script = scripts[i2];
16394
- if (!isStripeJSURL(script.src)) {
16395
- continue;
16396
- }
16397
- return script;
16398
- }
16399
- return null;
16400
- };
16401
- var injectScript = function injectScript2(params) {
16402
- var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
16403
- var script = document.createElement("script");
16404
- script.src = "".concat(STRIPE_JS_URL).concat(queryString);
16405
- var headOrBody = document.head || document.body;
16406
- if (!headOrBody) {
16407
- throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
16408
- }
16409
- headOrBody.appendChild(script);
16410
- return script;
16411
- };
16412
- var registerWrapper = function registerWrapper2(stripe, startTime) {
16413
- if (!stripe || !stripe._registerWrapper) {
16414
- return;
16415
- }
16416
- stripe._registerWrapper({
16417
- name: "stripe-js",
16418
- version: "7.0.0",
16419
- startTime
16420
- });
16421
- };
16422
- var stripePromise$1 = null;
16423
- var onErrorListener = null;
16424
- var onLoadListener = null;
16425
- var onError = function onError2(reject) {
16426
- return function(cause) {
16427
- reject(new Error("Failed to load Stripe.js", {
16428
- cause
16429
- }));
16430
- };
16431
- };
16432
- var onLoad = function onLoad2(resolve, reject) {
16433
- return function() {
16434
- if (window.Stripe) {
16435
- resolve(window.Stripe);
16436
- } else {
16437
- reject(new Error("Stripe.js not available"));
16438
- }
16439
- };
16440
- };
16441
- var loadScript = function loadScript2(params) {
16442
- if (stripePromise$1 !== null) {
16443
- return stripePromise$1;
16444
- }
16445
- stripePromise$1 = new Promise(function(resolve, reject) {
16446
- if (typeof window === "undefined" || typeof document === "undefined") {
16447
- resolve(null);
16448
- return;
16449
- }
16450
- if (window.Stripe && params) {
16451
- console.warn(EXISTING_SCRIPT_MESSAGE);
16452
- }
16453
- if (window.Stripe) {
16454
- resolve(window.Stripe);
16455
- return;
16456
- }
16457
- try {
16458
- var script = findScript();
16459
- if (script && params) {
16460
- console.warn(EXISTING_SCRIPT_MESSAGE);
16461
- } else if (!script) {
16462
- script = injectScript(params);
16463
- } else if (script && onLoadListener !== null && onErrorListener !== null) {
16464
- var _script$parentNode;
16465
- script.removeEventListener("load", onLoadListener);
16466
- script.removeEventListener("error", onErrorListener);
16467
- (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
16468
- script = injectScript(params);
16469
- }
16470
- onLoadListener = onLoad(resolve, reject);
16471
- onErrorListener = onError(reject);
16472
- script.addEventListener("load", onLoadListener);
16473
- script.addEventListener("error", onErrorListener);
16474
- } catch (error) {
16475
- reject(error);
16476
- return;
16477
- }
16478
- });
16479
- return stripePromise$1["catch"](function(error) {
16480
- stripePromise$1 = null;
16481
- return Promise.reject(error);
16482
- });
16483
- };
16484
- var initStripe = function initStripe2(maybeStripe, args, startTime) {
16485
- if (maybeStripe === null) {
16486
- return null;
16487
- }
16488
- var pk = args[0];
16489
- var isTestKey = pk.match(/^pk_test/);
16490
- var version = runtimeVersionToUrlVersion(maybeStripe.version);
16491
- var expectedVersion = RELEASE_TRAIN;
16492
- if (isTestKey && version !== expectedVersion) {
16493
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.0.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
16494
- }
16495
- var stripe = maybeStripe.apply(void 0, args);
16496
- registerWrapper(stripe, startTime);
16497
- return stripe;
16498
- };
16499
- var stripePromise;
16500
- var loadCalled = false;
16501
- var getStripePromise = function getStripePromise2() {
16502
- if (stripePromise) {
16503
- return stripePromise;
16504
- }
16505
- stripePromise = loadScript(null)["catch"](function(error) {
16506
- stripePromise = null;
16507
- return Promise.reject(error);
16508
- });
16509
- return stripePromise;
16510
- };
16511
- Promise.resolve().then(function() {
16512
- return getStripePromise();
16513
- })["catch"](function(error) {
16514
- if (!loadCalled) {
16515
- console.warn(error);
16516
- }
16517
- });
16518
- var loadStripe = function loadStripe2() {
16519
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
16520
- args[_key] = arguments[_key];
16521
- }
16522
- loadCalled = true;
16523
- var startTime = Date.now();
16524
- return getStripePromise().then(function(maybeStripe) {
16525
- return initStripe(maybeStripe, args, startTime);
16526
- });
16527
- };
16528
-
16529
16396
  // src/components/shared/checkout-dialog/Checkout.tsx
16530
16397
  var import_react24 = require("react");
16531
16398
  var import_jsx_runtime15 = require("react/jsx-runtime");
@@ -16536,36 +16403,11 @@ var Checkout = ({
16536
16403
  }) => {
16537
16404
  const { t: t2 } = useTranslation();
16538
16405
  const theme = nt();
16539
- const { api, data } = useEmbed();
16540
16406
  const isLightBackground = useIsLightBackground();
16541
- const [stripe, setStripe] = (0, import_react24.useState)(null);
16542
- const [setupIntent, setSetupIntent] = (0, import_react24.useState)();
16543
16407
  const [discount, setDiscount] = (0, import_react24.useState)("");
16544
- (0, import_react24.useEffect)(() => {
16545
- if (api && data.component?.id) {
16546
- api.getSetupIntent({ componentId: data.component.id }).then((res) => setSetupIntent(res.data));
16547
- }
16548
- }, [api, data.component?.id]);
16549
- (0, import_react24.useEffect)(() => {
16550
- if (setupIntent?.publishableKey) {
16551
- setStripe(loadStripe(setupIntent.publishableKey));
16552
- }
16553
- }, [setupIntent?.publishableKey]);
16554
16408
  if (!requiresPayment) {
16555
16409
  return null;
16556
16410
  }
16557
- if (!stripe) {
16558
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
16559
- Flex,
16560
- {
16561
- $justifyContent: "center",
16562
- $alignItems: "center",
16563
- $flexGrow: 1,
16564
- $marginTop: "-3.5rem",
16565
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { $color: theme.primary, $size: "3xl" })
16566
- }
16567
- );
16568
- }
16569
16411
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
16570
16412
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PaymentMethodDetails, { setPaymentMethodId }),
16571
16413
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
@@ -16919,12 +16761,19 @@ var Plan = ({
16919
16761
  }[entitlement.metricPeriod];
16920
16762
  }
16921
16763
  const limit = entitlement.softLimit ?? entitlement.valueNumeric;
16922
- const {
16923
- price: entitlementPrice,
16924
- currency: entitlementCurrency
16925
- } = getBillingPrice(
16764
+ const entitlementPriceObject = getBillingPrice(
16926
16765
  period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
16927
- ) || {};
16766
+ ) || null;
16767
+ let entitlementPrice = entitlementPriceObject?.price;
16768
+ const entitlementCurrency = entitlementPriceObject?.currency;
16769
+ if (entitlement.priceBehavior === "overage" && entitlementPriceObject) {
16770
+ const { priceTier } = entitlementPriceObject;
16771
+ if (priceTier.length) {
16772
+ const lastTier = priceTier[priceTier.length - 1];
16773
+ const { perUnitPrice, perUnitPriceDecimal } = lastTier;
16774
+ entitlementPrice = perUnitPriceDecimal ? Number(perUnitPriceDecimal) : perUnitPrice ?? 0;
16775
+ }
16776
+ }
16928
16777
  if (entitlement.priceBehavior && typeof entitlementPrice !== "number") {
16929
16778
  return acc;
16930
16779
  }
@@ -18377,6 +18226,10 @@ var StyledViewport = dt.div.withConfig({
18377
18226
  @media (min-width: 768px) {
18378
18227
  grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
18379
18228
  }
18229
+
18230
+ @container (max-width: 768px) {
18231
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
18232
+ }
18380
18233
  `;
18381
18234
 
18382
18235
  // src/components/layout/viewport/Viewport.tsx
@@ -18870,10 +18723,13 @@ var Invoices = (0, import_react34.forwardRef)(({ className, data, ...rest }, ref
18870
18723
  );
18871
18724
  };
18872
18725
  (0, import_react34.useEffect)(() => {
18873
- api?.listInvoices().then(({ data: data2 }) => {
18874
- setInvoices(formatInvoices(data2));
18726
+ api?.listInvoices().then((response) => {
18727
+ setInvoices(formatInvoices(response.data));
18875
18728
  });
18876
18729
  }, [api]);
18730
+ (0, import_react34.useEffect)(() => {
18731
+ setInvoices(formatInvoices(data));
18732
+ }, [data]);
18877
18733
  if (invoices.length === 0) {
18878
18734
  return null;
18879
18735
  }
@@ -19047,9 +18903,32 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
19047
18903
  }, index) => {
19048
18904
  const limit = softLimit ?? allocation ?? 0;
19049
18905
  const isOverage = priceBehavior === "overage" && typeof softLimit === "number" && typeof usage === "number" && usage > softLimit;
19050
- const { price, currency } = getBillingPrice(
18906
+ let { price, currency } = getBillingPrice(
19051
18907
  planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
19052
18908
  ) || {};
18909
+ if (priceBehavior === "overage") {
18910
+ const productId = (yearlyUsageBasedPrice ?? monthlyUsageBasedPrice)?.productId;
18911
+ if (productId) {
18912
+ const products = data?.subscription?.products ?? [];
18913
+ const product = products.find((p2) => p2.id === productId);
18914
+ if (product && product.priceTier?.length > 1) {
18915
+ const overagePrice = product.priceTier[product.priceTier.length - 1];
18916
+ price = overagePrice.perUnitPriceDecimal ? Number(overagePrice.perUnitPriceDecimal) : overagePrice.perUnitPrice ?? 0;
18917
+ currency = product.currency;
18918
+ }
18919
+ }
18920
+ }
18921
+ if (isOverage) {
18922
+ const productId = (yearlyUsageBasedPrice ?? monthlyUsageBasedPrice).productId;
18923
+ if (productId) {
18924
+ const products = data?.subscription?.products ?? [];
18925
+ const product = products.find((p2) => p2.id === productId);
18926
+ if (product) {
18927
+ price = product.price;
18928
+ currency = product.currency;
18929
+ }
18930
+ }
18931
+ }
19053
18932
  const progressBar = props.isVisible && typeof usage === "number" && limit > 0 && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
19054
18933
  ProgressBar,
19055
18934
  {
@@ -19600,6 +19479,160 @@ PaymentMethod.displayName = "PaymentMethod";
19600
19479
 
19601
19480
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
19602
19481
  var import_react_stripe_js2 = require("@stripe/react-stripe-js");
19482
+
19483
+ // node_modules/@stripe/stripe-js/dist/index.mjs
19484
+ var RELEASE_TRAIN = "basil";
19485
+ var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
19486
+ return version === 3 ? "v3" : version;
19487
+ };
19488
+ var ORIGIN = "https://js.stripe.com";
19489
+ var STRIPE_JS_URL = "".concat(ORIGIN, "/").concat(RELEASE_TRAIN, "/stripe.js");
19490
+ var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
19491
+ var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
19492
+ var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
19493
+ var isStripeJSURL = function isStripeJSURL2(url) {
19494
+ return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
19495
+ };
19496
+ var findScript = function findScript2() {
19497
+ var scripts = document.querySelectorAll('script[src^="'.concat(ORIGIN, '"]'));
19498
+ for (var i2 = 0; i2 < scripts.length; i2++) {
19499
+ var script = scripts[i2];
19500
+ if (!isStripeJSURL(script.src)) {
19501
+ continue;
19502
+ }
19503
+ return script;
19504
+ }
19505
+ return null;
19506
+ };
19507
+ var injectScript = function injectScript2(params) {
19508
+ var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
19509
+ var script = document.createElement("script");
19510
+ script.src = "".concat(STRIPE_JS_URL).concat(queryString);
19511
+ var headOrBody = document.head || document.body;
19512
+ if (!headOrBody) {
19513
+ throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
19514
+ }
19515
+ headOrBody.appendChild(script);
19516
+ return script;
19517
+ };
19518
+ var registerWrapper = function registerWrapper2(stripe, startTime) {
19519
+ if (!stripe || !stripe._registerWrapper) {
19520
+ return;
19521
+ }
19522
+ stripe._registerWrapper({
19523
+ name: "stripe-js",
19524
+ version: "7.0.0",
19525
+ startTime
19526
+ });
19527
+ };
19528
+ var stripePromise$1 = null;
19529
+ var onErrorListener = null;
19530
+ var onLoadListener = null;
19531
+ var onError = function onError2(reject) {
19532
+ return function(cause) {
19533
+ reject(new Error("Failed to load Stripe.js", {
19534
+ cause
19535
+ }));
19536
+ };
19537
+ };
19538
+ var onLoad = function onLoad2(resolve, reject) {
19539
+ return function() {
19540
+ if (window.Stripe) {
19541
+ resolve(window.Stripe);
19542
+ } else {
19543
+ reject(new Error("Stripe.js not available"));
19544
+ }
19545
+ };
19546
+ };
19547
+ var loadScript = function loadScript2(params) {
19548
+ if (stripePromise$1 !== null) {
19549
+ return stripePromise$1;
19550
+ }
19551
+ stripePromise$1 = new Promise(function(resolve, reject) {
19552
+ if (typeof window === "undefined" || typeof document === "undefined") {
19553
+ resolve(null);
19554
+ return;
19555
+ }
19556
+ if (window.Stripe && params) {
19557
+ console.warn(EXISTING_SCRIPT_MESSAGE);
19558
+ }
19559
+ if (window.Stripe) {
19560
+ resolve(window.Stripe);
19561
+ return;
19562
+ }
19563
+ try {
19564
+ var script = findScript();
19565
+ if (script && params) {
19566
+ console.warn(EXISTING_SCRIPT_MESSAGE);
19567
+ } else if (!script) {
19568
+ script = injectScript(params);
19569
+ } else if (script && onLoadListener !== null && onErrorListener !== null) {
19570
+ var _script$parentNode;
19571
+ script.removeEventListener("load", onLoadListener);
19572
+ script.removeEventListener("error", onErrorListener);
19573
+ (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
19574
+ script = injectScript(params);
19575
+ }
19576
+ onLoadListener = onLoad(resolve, reject);
19577
+ onErrorListener = onError(reject);
19578
+ script.addEventListener("load", onLoadListener);
19579
+ script.addEventListener("error", onErrorListener);
19580
+ } catch (error) {
19581
+ reject(error);
19582
+ return;
19583
+ }
19584
+ });
19585
+ return stripePromise$1["catch"](function(error) {
19586
+ stripePromise$1 = null;
19587
+ return Promise.reject(error);
19588
+ });
19589
+ };
19590
+ var initStripe = function initStripe2(maybeStripe, args, startTime) {
19591
+ if (maybeStripe === null) {
19592
+ return null;
19593
+ }
19594
+ var pk = args[0];
19595
+ var isTestKey = pk.match(/^pk_test/);
19596
+ var version = runtimeVersionToUrlVersion(maybeStripe.version);
19597
+ var expectedVersion = RELEASE_TRAIN;
19598
+ if (isTestKey && version !== expectedVersion) {
19599
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.0.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
19600
+ }
19601
+ var stripe = maybeStripe.apply(void 0, args);
19602
+ registerWrapper(stripe, startTime);
19603
+ return stripe;
19604
+ };
19605
+ var stripePromise;
19606
+ var loadCalled = false;
19607
+ var getStripePromise = function getStripePromise2() {
19608
+ if (stripePromise) {
19609
+ return stripePromise;
19610
+ }
19611
+ stripePromise = loadScript(null)["catch"](function(error) {
19612
+ stripePromise = null;
19613
+ return Promise.reject(error);
19614
+ });
19615
+ return stripePromise;
19616
+ };
19617
+ Promise.resolve().then(function() {
19618
+ return getStripePromise();
19619
+ })["catch"](function(error) {
19620
+ if (!loadCalled) {
19621
+ console.warn(error);
19622
+ }
19623
+ });
19624
+ var loadStripe = function loadStripe2() {
19625
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19626
+ args[_key] = arguments[_key];
19627
+ }
19628
+ loadCalled = true;
19629
+ var startTime = Date.now();
19630
+ return getStripePromise().then(function(maybeStripe) {
19631
+ return initStripe(maybeStripe, args, startTime);
19632
+ });
19633
+ };
19634
+
19635
+ // src/components/elements/payment-method/PaymentMethodDetails.tsx
19603
19636
  var import_react38 = require("react");
19604
19637
  var import_jsx_runtime34 = require("react/jsx-runtime");
19605
19638
  var resolveDesignProps6 = () => {
@@ -19950,7 +19983,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
19950
19983
  const isTrialSubscription = billingSubscription?.status === "trialing";
19951
19984
  const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
19952
19985
  const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
19953
- const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
19986
+ const headerPriceFontStyle = isUsageBasedPlan ? "heading3" : props.header.price.fontStyle;
19954
19987
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
19955
19988
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
19956
19989
  Notice,
@@ -19962,32 +19995,12 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
19962
19995
  $textAlign: "center",
19963
19996
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19964
19997
  children: [
19965
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
19966
- Text,
19967
- {
19968
- as: "h3",
19969
- $font: theme.typography.heading3.fontFamily,
19970
- $size: theme.typography.heading3.fontSize,
19971
- $weight: theme.typography.heading3.fontWeight,
19972
- $color: theme.typography.heading3.color,
19973
- children: t2("Trial ends in", { days: trialEndDays.toString() })
19974
- }
19975
- ),
19976
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
19977
- Text,
19978
- {
19979
- as: "p",
19980
- $font: theme.typography.text.fontFamily,
19981
- $size: 0.8125 * theme.typography.text.fontSize,
19982
- $weight: theme.typography.text.fontWeight,
19983
- $color: theme.typography.text.color,
19984
- children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
19985
- defaultPlanName: defaultPlan?.name
19986
- }) : t2("After the trial, cancel no default", {
19987
- planName: currentPlan?.name
19988
- })
19989
- }
19990
- )
19998
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "h3", display: "heading3", children: t2("Trial ends in", { days: trialEndDays.toString() }) }),
19999
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
20000
+ defaultPlanName: defaultPlan?.name
20001
+ }) : t2("After the trial, cancel no default", {
20002
+ planName: currentPlan?.name
20003
+ }) })
19991
20004
  ]
19992
20005
  }
19993
20006
  ) : willSubscriptionCancel && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
@@ -20000,35 +20013,15 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20000
20013
  $textAlign: "center",
20001
20014
  $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
20002
20015
  children: [
20003
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20004
- Text,
20005
- {
20006
- as: "h3",
20007
- $font: theme.typography.heading3.fontFamily,
20008
- $size: theme.typography.heading3.fontSize,
20009
- $weight: theme.typography.heading3.fontWeight,
20010
- $color: theme.typography.heading3.color,
20011
- children: t2("Subscription canceled")
20012
- }
20013
- ),
20014
- billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20015
- Text,
20016
- {
20017
- as: "p",
20018
- $font: theme.typography.text.fontFamily,
20019
- $size: 0.8125 * theme.typography.text.fontSize,
20020
- $weight: theme.typography.text.fontWeight,
20021
- $color: theme.typography.text.color,
20022
- children: t2("Access to plan will end on", {
20023
- date: toPrettyDate(
20024
- new Date(billingSubscription.cancelAt * 1e3),
20025
- {
20026
- month: "numeric"
20027
- }
20028
- )
20029
- })
20030
- }
20031
- )
20016
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "h3", display: "heading3", children: t2("Subscription canceled") }),
20017
+ billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: t2("Access to plan will end on", {
20018
+ date: toPrettyDate(
20019
+ new Date(billingSubscription.cancelAt * 1e3),
20020
+ {
20021
+ month: "numeric"
20022
+ }
20023
+ )
20024
+ }) })
20032
20025
  ]
20033
20026
  }
20034
20027
  ),
@@ -20050,57 +20043,18 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20050
20043
  $gap: "1rem",
20051
20044
  children: [
20052
20045
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
20053
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20054
- Text,
20055
- {
20056
- as: Box,
20057
- $font: theme.typography[props.header.title.fontStyle].fontFamily,
20058
- $size: theme.typography[props.header.title.fontStyle].fontSize,
20059
- $weight: theme.typography[props.header.title.fontStyle].fontWeight,
20060
- $color: theme.typography[props.header.title.fontStyle].color,
20061
- $leading: 1,
20062
- children: currentPlan.name
20063
- }
20064
- ),
20065
- props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20066
- Text,
20067
- {
20068
- as: Box,
20069
- $font: theme.typography[props.header.description.fontStyle].fontFamily,
20070
- $size: theme.typography[props.header.description.fontStyle].fontSize,
20071
- $weight: theme.typography[props.header.description.fontStyle].fontWeight,
20072
- $color: theme.typography[props.header.description.fontStyle].color,
20073
- children: currentPlan.description
20074
- }
20075
- )
20046
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.header.title.fontStyle, $leading: 1, children: currentPlan.name }),
20047
+ props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.header.description.fontStyle, children: currentPlan.description })
20076
20048
  ] }),
20077
20049
  props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Box, { children: [
20078
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20079
- Text,
20080
- {
20081
- $font: headerPriceFontStyle.fontFamily,
20082
- $size: headerPriceFontStyle.fontSize,
20083
- $weight: headerPriceFontStyle.fontWeight,
20084
- $color: headerPriceFontStyle.color,
20085
- children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
20086
- currentPlan.planPrice,
20087
- subscriptionCurrency
20088
- )
20089
- }
20090
- ),
20091
- !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20092
- Text,
20093
- {
20094
- $font: theme.typography[props.header.price.fontStyle].fontFamily,
20095
- $size: theme.typography[props.header.price.fontStyle].fontSize,
20096
- $weight: theme.typography[props.header.price.fontStyle].fontWeight,
20097
- $color: theme.typography[props.header.price.fontStyle].color,
20098
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20099
- "/",
20100
- shortenPeriod(currentPlan.planPeriod)
20101
- ] })
20102
- }
20103
- )
20050
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: headerPriceFontStyle, children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
20051
+ currentPlan.planPrice,
20052
+ subscriptionCurrency
20053
+ ) }),
20054
+ !isUsageBasedPlan && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20055
+ "/",
20056
+ shortenPeriod(currentPlan.planPeriod)
20057
+ ] }) })
20104
20058
  ] })
20105
20059
  ]
20106
20060
  }
@@ -20109,9 +20063,6 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20109
20063
  props.addOns.showLabel && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20110
20064
  Text,
20111
20065
  {
20112
- $font: theme.typography.text.fontFamily,
20113
- $size: theme.typography.text.fontSize,
20114
- $weight: theme.typography.text.fontWeight,
20115
20066
  $color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
20116
20067
  $leading: 1,
20117
20068
  children: t2("Add-ons")
@@ -20125,32 +20076,14 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20125
20076
  $flexWrap: "wrap",
20126
20077
  $gap: "1rem",
20127
20078
  children: [
20128
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20129
- Text,
20130
- {
20131
- $font: theme.typography[props.addOns.fontStyle].fontFamily,
20132
- $size: theme.typography[props.addOns.fontStyle].fontSize,
20133
- $weight: theme.typography[props.addOns.fontStyle].fontWeight,
20134
- $color: theme.typography[props.addOns.fontStyle].color,
20135
- children: addOn.name
20136
- }
20137
- ),
20138
- addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20139
- Text,
20140
- {
20141
- $font: theme.typography.text.fontFamily,
20142
- $size: theme.typography.text.fontSize,
20143
- $weight: theme.typography.text.fontWeight,
20144
- $color: theme.typography.text.color,
20145
- children: [
20146
- formatCurrency(addOn.planPrice, subscriptionCurrency),
20147
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20148
- "/",
20149
- shortenPeriod(addOn.planPeriod)
20150
- ] })
20151
- ]
20152
- }
20153
- )
20079
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Text, { display: props.addOns.fontStyle, children: addOn.name }),
20080
+ addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Text, { children: [
20081
+ formatCurrency(addOn.planPrice, subscriptionCurrency),
20082
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20083
+ "/",
20084
+ shortenPeriod(addOn.planPeriod)
20085
+ ] })
20086
+ ] })
20154
20087
  ]
20155
20088
  },
20156
20089
  addOnIndex
@@ -20160,9 +20093,6 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20160
20093
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20161
20094
  Text,
20162
20095
  {
20163
- $font: theme.typography.text.fontFamily,
20164
- $size: theme.typography.text.fontSize,
20165
- $weight: theme.typography.text.fontWeight,
20166
20096
  $color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
20167
20097
  $leading: 1,
20168
20098
  children: t2("Usage-based")
@@ -20171,8 +20101,24 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20171
20101
  usageBasedEntitlements.reduce(
20172
20102
  (acc, entitlement, entitlementIndex) => {
20173
20103
  const limit = entitlement.softLimit ?? entitlement.allocation ?? 0;
20174
- const overageAmount = entitlement.priceBehavior === "overage" && (entitlement?.usage ?? 0) - (entitlement?.softLimit ?? 0);
20104
+ let overageAmount = entitlement.priceBehavior === "overage" && (entitlement?.usage ?? 0) - (entitlement?.softLimit ?? 0);
20175
20105
  const amount = overageAmount || entitlement.allocation || 0;
20106
+ if (entitlement.priceBehavior === "overage" && data.subscription) {
20107
+ const subscription = data.subscription;
20108
+ const entitlementPrice = entitlement.monthlyUsageBasedPrice ?? entitlement.yearlyUsageBasedPrice;
20109
+ if (entitlementPrice) {
20110
+ const entitlementProduct = subscription.products.find(
20111
+ (product) => product.id === entitlementPrice.productId
20112
+ );
20113
+ if (entitlementProduct?.priceTier.length) {
20114
+ const entitlementProductLastTierPrice = entitlementProduct?.priceTier[entitlementProduct?.priceTier?.length - 1];
20115
+ overageAmount = (entitlement?.usage ?? 0) - (entitlementProduct?.priceTier[0].upTo ?? 0);
20116
+ entitlement.price = entitlementProductLastTierPrice?.perUnitPriceDecimal ? Number(
20117
+ entitlementProductLastTierPrice?.perUnitPriceDecimal
20118
+ ) : entitlementProductLastTierPrice.perUnitPrice ?? entitlement.price;
20119
+ }
20120
+ }
20121
+ }
20176
20122
  if (entitlement.feature?.name) {
20177
20123
  acc.push(
20178
20124
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
@@ -20183,38 +20129,27 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20183
20129
  $flexWrap: "wrap",
20184
20130
  $gap: "1rem",
20185
20131
  children: [
20186
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20187
- Text,
20188
- {
20189
- $font: theme.typography[props.addOns.fontStyle].fontFamily,
20190
- $size: theme.typography[props.addOns.fontStyle].fontSize,
20191
- $weight: theme.typography[props.addOns.fontStyle].fontWeight,
20192
- $color: theme.typography[props.addOns.fontStyle].color,
20193
- children: [
20194
- entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior === "overage" && limit > 0 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20195
- limit,
20196
- " ",
20197
- getFeatureName(entitlement.feature, limit)
20198
- ] }) : entitlement.feature.name,
20199
- entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20200
- "/",
20201
- shortenPeriod(currentPlan.planPeriod)
20202
- ] })
20203
- ]
20204
- }
20205
- ),
20132
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Text, { display: props.addOns.fontStyle, children: [
20133
+ entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior === "overage" && limit > 0 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20134
+ limit,
20135
+ " ",
20136
+ getFeatureName(entitlement.feature, limit)
20137
+ ] }) : entitlement.feature.name,
20138
+ entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20139
+ "/",
20140
+ shortenPeriod(currentPlan.planPeriod)
20141
+ ] })
20142
+ ] }),
20206
20143
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Flex, { $alignItems: "center", $gap: "1rem", children: [
20207
20144
  entitlement.priceBehavior === "overage" && currentPlan?.planPeriod ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
20208
20145
  Text,
20209
20146
  {
20210
- $font: theme.typography.text.fontFamily,
20211
20147
  $size: 0.875 * theme.typography.text.fontSize,
20212
- $weight: theme.typography.text.fontWeight,
20213
20148
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
20214
20149
  children: typeof overageAmount === "number" && overageAmount > 0 ? t2("X over the limit", {
20215
20150
  amount: overageAmount
20216
20151
  }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
20217
- t2("Overage fee"),
20152
+ t2("overage fee"),
20218
20153
  ":",
20219
20154
  " ",
20220
20155
  formatCurrency(
@@ -20234,9 +20169,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20234
20169
  ) : entitlement.priceBehavior === "pay_in_advance" && currentPlan?.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20235
20170
  Text,
20236
20171
  {
20237
- $font: theme.typography.text.fontFamily,
20238
20172
  $size: 0.875 * theme.typography.text.fontSize,
20239
- $weight: theme.typography.text.fontWeight,
20240
20173
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
20241
20174
  children: [
20242
20175
  formatCurrency(
@@ -20252,25 +20185,16 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
20252
20185
  ]
20253
20186
  }
20254
20187
  ),
20255
- amount > 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
20256
- Text,
20257
- {
20258
- $font: theme.typography.text.fontFamily,
20259
- $size: theme.typography.text.fontSize,
20260
- $weight: theme.typography.text.fontWeight,
20261
- $color: theme.typography.text.color,
20262
- children: [
20263
- formatCurrency(
20264
- (entitlement.price ?? 0) * amount,
20265
- entitlement.currency
20266
- ),
20267
- (entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20268
- "/",
20269
- currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
20270
- ] })
20271
- ]
20272
- }
20273
- )
20188
+ amount > 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Text, { children: [
20189
+ formatCurrency(
20190
+ (entitlement.price ?? 0) * amount,
20191
+ entitlement.currency
20192
+ ),
20193
+ (entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
20194
+ "/",
20195
+ currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
20196
+ ] })
20197
+ ] })
20274
20198
  ] })
20275
20199
  ]
20276
20200
  },
@@ -20569,12 +20493,25 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
20569
20493
  plan.entitlements.reduce(
20570
20494
  (acc, entitlement, entitlementIndex) => {
20571
20495
  const limit = entitlement.softLimit ?? entitlement.valueNumeric;
20572
- const {
20573
- price: entitlementPrice,
20574
- currency: entitlementCurrency
20575
- } = getBillingPrice(
20576
- selectedPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
20577
- ) || {};
20496
+ let entitlementPriceObject;
20497
+ if (selectedPeriod === "month") {
20498
+ entitlementPriceObject = entitlement.meteredMonthlyPrice;
20499
+ } else if (selectedPeriod === "year") {
20500
+ entitlementPriceObject = entitlement.meteredYearlyPrice;
20501
+ }
20502
+ let entitlementPrice;
20503
+ let entitlementCurrency;
20504
+ if (entitlementPriceObject) {
20505
+ entitlementPrice = entitlementPriceObject?.price;
20506
+ entitlementCurrency = entitlementPriceObject?.currency;
20507
+ }
20508
+ if (entitlementPriceObject && entitlement.priceBehavior === "overage") {
20509
+ if (entitlementPriceObject.priceTier?.length > 1) {
20510
+ const overagePrice = entitlementPriceObject.priceTier[entitlementPriceObject.priceTier.length - 1];
20511
+ entitlementPrice = overagePrice.perUnitPrice ?? Number(overagePrice.perUnitPriceDecimal);
20512
+ entitlementCurrency = entitlementPriceObject.currency;
20513
+ }
20514
+ }
20578
20515
  if (entitlement.priceBehavior && typeof entitlementPrice !== "number") {
20579
20516
  return acc;
20580
20517
  }