@schematichq/schematic-components 0.4.2 → 0.4.4-rc.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.
@@ -3734,18 +3734,22 @@ function useAvailablePlans(activePeriod) {
3734
3734
  }, [data.activePlans, data.activeAddOns]);
3735
3735
  const getActivePlans = useCallback2(
3736
3736
  (plans) => {
3737
- const plansWithSelected = (mode === "edit" ? plans.slice() : plans.filter(
3737
+ const customPlanExist = plans.some((plan) => plan.custom);
3738
+ let plansWithSelected = mode === "edit" ? plans.slice() : plans.filter(
3738
3739
  (plan) => activePeriod === "month" && plan.monthlyPrice || activePeriod === "year" && plan.yearlyPrice
3739
- )).sort((a2, b2) => {
3740
- if (activePeriod === "year") {
3741
- return (a2.yearlyPrice?.price ?? 0) - (b2.yearlyPrice?.price ?? 0);
3742
- }
3743
- if (activePeriod === "month") {
3744
- return (a2.monthlyPrice?.price ?? 0) - (b2.monthlyPrice?.price ?? 0);
3745
- }
3746
- return 0;
3747
- }).map((plan) => ({ ...plan, isSelected: false }));
3748
- return plansWithSelected;
3740
+ );
3741
+ if (!customPlanExist) {
3742
+ plansWithSelected = plansWithSelected.sort((a2, b2) => {
3743
+ if (activePeriod === "year") {
3744
+ return (a2.yearlyPrice?.price ?? 0) - (b2.yearlyPrice?.price ?? 0);
3745
+ }
3746
+ if (activePeriod === "month") {
3747
+ return (a2.monthlyPrice?.price ?? 0) - (b2.monthlyPrice?.price ?? 0);
3748
+ }
3749
+ return 0;
3750
+ });
3751
+ }
3752
+ return plansWithSelected.map((plan) => ({ ...plan, isSelected: false }));
3749
3753
  },
3750
3754
  [activePeriod, mode]
3751
3755
  );
@@ -11207,6 +11211,21 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11207
11211
  };
11208
11212
  }
11209
11213
 
11214
+ // src/api/models/CustomPlanConfig.ts
11215
+ function CustomPlanConfigFromJSON(json) {
11216
+ return CustomPlanConfigFromJSONTyped(json, false);
11217
+ }
11218
+ function CustomPlanConfigFromJSONTyped(json, ignoreDiscriminator) {
11219
+ if (json == null) {
11220
+ return json;
11221
+ }
11222
+ return {
11223
+ ctaText: json["cta_text"],
11224
+ ctaWebSite: json["cta_web_site"],
11225
+ priceText: json["price_text"]
11226
+ };
11227
+ }
11228
+
11210
11229
  // src/api/models/CompanyPlanDetailResponseData.ts
11211
11230
  function CompanyPlanDetailResponseDataFromJSON(json) {
11212
11231
  return CompanyPlanDetailResponseDataFromJSONTyped(json, false);
@@ -11222,6 +11241,8 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11222
11241
  companyCount: json["company_count"],
11223
11242
  createdAt: new Date(json["created_at"]),
11224
11243
  current: json["current"],
11244
+ custom: json["custom"],
11245
+ customPlanConfig: json["custom_plan_config"] == null ? void 0 : CustomPlanConfigFromJSON(json["custom_plan_config"]),
11225
11246
  description: json["description"],
11226
11247
  entitlements: json["entitlements"].map(
11227
11248
  PlanEntitlementResponseDataFromJSON
@@ -11231,6 +11252,7 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11231
11252
  ),
11232
11253
  icon: json["icon"],
11233
11254
  id: json["id"],
11255
+ isCustom: json["is_custom"],
11234
11256
  isDefault: json["is_default"],
11235
11257
  isFree: json["is_free"],
11236
11258
  isTrialable: json["is_trialable"],
@@ -11872,6 +11894,8 @@ var en_default = {
11872
11894
  "Error retrieving plan details. Please try again in a moment.": "Error retrieving plan details. Please try again in a moment.",
11873
11895
  "Error updating payment method. Please try again.": "Error updating payment method. Please try again.",
11874
11896
  "Estimated bill.": "Estimated bill.",
11897
+ "Custom Plan Price": "Custom price",
11898
+ "Custom Plan CTA": "Talk to support",
11875
11899
  "Everything in": "Everything in {{plan}}, plus",
11876
11900
  Expired: "Expired",
11877
11901
  "Expires in x months": "Expires in {{months}} mo",
@@ -12479,8 +12503,12 @@ function isEditorState(obj) {
12479
12503
  });
12480
12504
  }
12481
12505
  function getEditorState(json) {
12482
- const obj = JSON.parse(json);
12483
- return isEditorState(obj) ? obj : void 0;
12506
+ if (json) {
12507
+ const obj = JSON.parse(json);
12508
+ if (isEditorState(obj)) {
12509
+ return obj;
12510
+ }
12511
+ }
12484
12512
  }
12485
12513
  function parseEditorState(data) {
12486
12514
  const initialMap = {};
@@ -12660,7 +12688,7 @@ var EmbedProvider = ({
12660
12688
  useEffect2(() => {
12661
12689
  if (accessToken) {
12662
12690
  const { headers = {} } = apiConfig ?? {};
12663
- headers["X-Schematic-Components-Version"] = "0.4.2";
12691
+ headers["X-Schematic-Components-Version"] = "0.4.4-rc.1";
12664
12692
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
12665
12693
  const config = new Configuration({
12666
12694
  ...apiConfig,
@@ -12841,7 +12869,7 @@ function camelToHyphen(str) {
12841
12869
  function formatNumber(num) {
12842
12870
  return new Intl.NumberFormat("en-US").format(num);
12843
12871
  }
12844
- function formatCurrency(amount) {
12872
+ function formatCurrency(amount, currency = "USD") {
12845
12873
  try {
12846
12874
  const dollars = amount / 100;
12847
12875
  const formatValue = (value, symbol) => {
@@ -12849,6 +12877,9 @@ function formatCurrency(amount) {
12849
12877
  if (formatted.endsWith(".0")) {
12850
12878
  formatted = formatted.slice(0, -2);
12851
12879
  }
12880
+ if (currency.toUpperCase() !== "USD") {
12881
+ return `${currency.toUpperCase()}${formatted}${symbol}`;
12882
+ }
12852
12883
  return `$${formatted}${symbol}`;
12853
12884
  };
12854
12885
  if (dollars >= 1e6) {
@@ -12858,14 +12889,14 @@ function formatCurrency(amount) {
12858
12889
  } else {
12859
12890
  return new Intl.NumberFormat("en-US", {
12860
12891
  style: "currency",
12861
- currency: "USD"
12892
+ currency: currency.toUpperCase()
12862
12893
  }).format(dollars);
12863
12894
  }
12864
12895
  } catch (error) {
12865
12896
  console.error("Error formatting currency", error);
12866
12897
  return new Intl.NumberFormat("en-US", {
12867
12898
  style: "currency",
12868
- currency: "USD"
12899
+ currency: currency.toUpperCase()
12869
12900
  }).format(amount / 100);
12870
12901
  }
12871
12902
  }
@@ -14399,6 +14430,7 @@ var Sidebar = ({
14399
14430
  }
14400
14431
  let total = 0;
14401
14432
  const planPrice = (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price;
14433
+ const currency = (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency;
14402
14434
  if (planPrice) {
14403
14435
  total += planPrice;
14404
14436
  }
@@ -14412,7 +14444,7 @@ var Sidebar = ({
14412
14444
  0
14413
14445
  );
14414
14446
  total += payInAdvanceCost;
14415
- return formatCurrency(total);
14447
+ return formatCurrency(total, currency);
14416
14448
  }, [selectedPlan, addOns, payInAdvanceEntitlements, planPeriod]);
14417
14449
  const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = useMemo4(() => {
14418
14450
  return {
@@ -14647,7 +14679,10 @@ var Sidebar = ({
14647
14679
  $weight: theme.typography.text.fontWeight,
14648
14680
  $color: theme.typography.text.color,
14649
14681
  children: [
14650
- formatCurrency(data.company.plan.planPrice),
14682
+ formatCurrency(
14683
+ data.company.plan.planPrice,
14684
+ data.company.billingSubscription?.currency
14685
+ ),
14651
14686
  /* @__PURE__ */ jsxs8("sub", { children: [
14652
14687
  "/",
14653
14688
  shortenPeriod(
@@ -14707,7 +14742,8 @@ var Sidebar = ({
14707
14742
  $color: theme.typography.text.color,
14708
14743
  children: [
14709
14744
  formatCurrency(
14710
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
14745
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0,
14746
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency
14711
14747
  ),
14712
14748
  /* @__PURE__ */ jsxs8("sub", { children: [
14713
14749
  "/",
@@ -14770,14 +14806,20 @@ var Sidebar = ({
14770
14806
  $color: theme.typography.text.color,
14771
14807
  children: [
14772
14808
  entitlement.priceBehavior === "pay_in_advance" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14773
- formatCurrency(price * quantity),
14809
+ formatCurrency(
14810
+ price * quantity,
14811
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14812
+ ),
14774
14813
  /* @__PURE__ */ jsxs8("sub", { children: [
14775
14814
  "/",
14776
14815
  shortenPeriod(planPeriod)
14777
14816
  ] })
14778
14817
  ] }),
14779
14818
  entitlement.priceBehavior === "pay_as_you_go" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14780
- formatCurrency(price),
14819
+ formatCurrency(
14820
+ price,
14821
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14822
+ ),
14781
14823
  /* @__PURE__ */ jsxs8("sub", { children: [
14782
14824
  "/",
14783
14825
  (0, import_pluralize.default)(
@@ -14837,7 +14879,8 @@ var Sidebar = ({
14837
14879
  $color: theme.typography.text.color,
14838
14880
  children: [
14839
14881
  formatCurrency(
14840
- ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * previous.quantity
14882
+ ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * previous.quantity,
14883
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14841
14884
  ),
14842
14885
  /* @__PURE__ */ jsxs8("sub", { children: [
14843
14886
  "/",
@@ -14879,7 +14922,8 @@ var Sidebar = ({
14879
14922
  $color: theme.typography.text.color,
14880
14923
  children: [
14881
14924
  formatCurrency(
14882
- ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * next2.quantity
14925
+ ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * next2.quantity,
14926
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14883
14927
  ),
14884
14928
  /* @__PURE__ */ jsxs8("sub", { children: [
14885
14929
  "/",
@@ -14933,14 +14977,20 @@ var Sidebar = ({
14933
14977
  $color: theme.typography.text.color,
14934
14978
  children: [
14935
14979
  entitlement.priceBehavior === "pay_in_advance" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14936
- formatCurrency(price * quantity),
14980
+ formatCurrency(
14981
+ price * quantity,
14982
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14983
+ ),
14937
14984
  /* @__PURE__ */ jsxs8("sub", { children: [
14938
14985
  "/",
14939
14986
  shortenPeriod(planPeriod)
14940
14987
  ] })
14941
14988
  ] }),
14942
14989
  entitlement.priceBehavior === "pay_as_you_go" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14943
- formatCurrency(price),
14990
+ formatCurrency(
14991
+ price,
14992
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14993
+ ),
14944
14994
  /* @__PURE__ */ jsxs8("sub", { children: [
14945
14995
  "/",
14946
14996
  (0, import_pluralize.default)(
@@ -15001,7 +15051,8 @@ var Sidebar = ({
15001
15051
  children: [
15002
15052
  "-",
15003
15053
  formatCurrency(
15004
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
15054
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0,
15055
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency
15005
15056
  ),
15006
15057
  "/",
15007
15058
  /* @__PURE__ */ jsx12("sub", { children: shortenPeriod(planPeriod) })
@@ -15051,7 +15102,10 @@ var Sidebar = ({
15051
15102
  $weight: theme.typography.text.fontWeight,
15052
15103
  $color: theme.typography.text.color,
15053
15104
  children: [
15054
- formatCurrency(addOn.planPrice),
15105
+ formatCurrency(
15106
+ addOn.planPrice,
15107
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15108
+ ),
15055
15109
  /* @__PURE__ */ jsxs8("sub", { children: [
15056
15110
  "/",
15057
15111
  shortenPeriod(addOn.planPeriod)
@@ -15138,7 +15192,10 @@ var Sidebar = ({
15138
15192
  $size: theme.typography.text.fontSize,
15139
15193
  $weight: theme.typography.text.fontWeight,
15140
15194
  $color: theme.typography.text.color,
15141
- children: formatCurrency(proration)
15195
+ children: formatCurrency(
15196
+ proration,
15197
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15198
+ )
15142
15199
  }
15143
15200
  ) })
15144
15201
  ]
@@ -15242,7 +15299,10 @@ var Sidebar = ({
15242
15299
  $size: theme.typography.text.fontSize,
15243
15300
  $weight: theme.typography.text.fontWeight,
15244
15301
  $color: theme.typography.text.color,
15245
- children: formatCurrency(newCharges / 100 * percentOff)
15302
+ children: formatCurrency(
15303
+ newCharges / 100 * percentOff,
15304
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15305
+ )
15246
15306
  }
15247
15307
  ) })
15248
15308
  ]
@@ -15263,7 +15323,10 @@ var Sidebar = ({
15263
15323
  $weight: theme.typography.text.fontWeight,
15264
15324
  $color: theme.typography.text.color,
15265
15325
  children: t2("X off", {
15266
- amount: formatCurrency(Math.abs(amountOff))
15326
+ amount: formatCurrency(
15327
+ Math.abs(amountOff),
15328
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15329
+ )
15267
15330
  })
15268
15331
  }
15269
15332
  ) }),
@@ -15276,7 +15339,10 @@ var Sidebar = ({
15276
15339
  $color: theme.typography.text.color,
15277
15340
  children: [
15278
15341
  "-",
15279
- formatCurrency(Math.abs(amountOff))
15342
+ formatCurrency(
15343
+ Math.abs(amountOff),
15344
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15345
+ )
15280
15346
  ]
15281
15347
  }
15282
15348
  ) })
@@ -15349,7 +15415,10 @@ var Sidebar = ({
15349
15415
  $size: theme.typography.text.fontSize,
15350
15416
  $weight: theme.typography.text.fontWeight,
15351
15417
  $color: theme.typography.text.color,
15352
- children: formatCurrency(Math.max(0, dueNow))
15418
+ children: formatCurrency(
15419
+ Math.max(0, dueNow),
15420
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15421
+ )
15353
15422
  }
15354
15423
  ) })
15355
15424
  ]
@@ -15376,7 +15445,10 @@ var Sidebar = ({
15376
15445
  $size: theme.typography.text.fontSize,
15377
15446
  $weight: theme.typography.text.fontWeight,
15378
15447
  $color: theme.typography.text.color,
15379
- children: formatCurrency(Math.abs(dueNow))
15448
+ children: formatCurrency(
15449
+ Math.abs(dueNow),
15450
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15451
+ )
15380
15452
  }
15381
15453
  ) })
15382
15454
  ] }),
@@ -15430,6 +15502,16 @@ var Sidebar = ({
15430
15502
  // src/components/shared/checkout-dialog/Plan.tsx
15431
15503
  import { useState as useState5 } from "react";
15432
15504
  var import_pluralize2 = __toESM(require_pluralize());
15505
+
15506
+ // src/components/elements/pricing-table/styles.ts
15507
+ var ButtonLink = dt.a`
15508
+ display: flex;
15509
+ justify-content: center;
15510
+ align-items: center;
15511
+ flex-grow: 1;
15512
+ `;
15513
+
15514
+ // src/components/shared/checkout-dialog/Plan.tsx
15433
15515
  import { Fragment as Fragment5, jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
15434
15516
  var Plan = ({
15435
15517
  isLoading,
@@ -15536,12 +15618,13 @@ var Plan = ({
15536
15618
  $size: theme.typography.heading2.fontSize,
15537
15619
  $weight: theme.typography.heading2.fontWeight,
15538
15620
  $color: theme.typography.heading2.color,
15539
- children: formatCurrency(
15540
- (period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
15621
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig?.priceText : t2("Custom Plan Price") : formatCurrency(
15622
+ (period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0,
15623
+ (period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.currency
15541
15624
  )
15542
15625
  }
15543
15626
  ),
15544
- /* @__PURE__ */ jsxs9(
15627
+ !plan.custom && /* @__PURE__ */ jsxs9(
15545
15628
  Text,
15546
15629
  {
15547
15630
  $font: theme.typography.heading2.fontFamily,
@@ -15602,6 +15685,7 @@ var Plan = ({
15602
15685
  }[entitlement.metricPeriod];
15603
15686
  }
15604
15687
  const price = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price;
15688
+ const currency = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency;
15605
15689
  if (entitlement.priceBehavior && typeof price !== "number") {
15606
15690
  return acc;
15607
15691
  }
@@ -15633,7 +15717,7 @@ var Plan = ({
15633
15717
  $weight: theme.typography.text.fontWeight,
15634
15718
  $color: theme.typography.text.color,
15635
15719
  children: typeof price !== "undefined" ? /* @__PURE__ */ jsxs9(Fragment5, { children: [
15636
- formatCurrency(price),
15720
+ formatCurrency(price, currency),
15637
15721
  " ",
15638
15722
  t2("per"),
15639
15723
  " ",
@@ -15736,13 +15820,25 @@ var Plan = ({
15736
15820
  EmbedButton,
15737
15821
  {
15738
15822
  disabled: isLoading || !plan.valid,
15739
- onClick: () => {
15740
- selectPlan(plan);
15823
+ ...{
15824
+ onClick: () => {
15825
+ if (plan.custom) {
15826
+ return;
15827
+ }
15828
+ selectPlan({ plan });
15829
+ }
15741
15830
  },
15742
15831
  $size: "sm",
15743
15832
  $color: "primary",
15744
15833
  $variant: plan.current ? "outline" : "filled",
15745
- children: !plan.valid ? /* @__PURE__ */ jsx13(
15834
+ children: plan.custom ? /* @__PURE__ */ jsx13(
15835
+ ButtonLink,
15836
+ {
15837
+ href: plan.customPlanConfig?.ctaWebSite ?? "#",
15838
+ target: "_blank",
15839
+ children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
15840
+ }
15841
+ ) : !plan.valid ? /* @__PURE__ */ jsx13(
15746
15842
  Tooltip,
15747
15843
  {
15748
15844
  trigger: t2("Over usage limit"),
@@ -15823,7 +15919,8 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
15823
15919
  $weight: theme.typography.heading2.fontWeight,
15824
15920
  $color: theme.typography.heading2.color,
15825
15921
  children: formatCurrency(
15826
- (period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0
15922
+ (period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0,
15923
+ (period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.currency
15827
15924
  )
15828
15925
  }
15829
15926
  ),
@@ -16024,7 +16121,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16024
16121
  $color: theme.typography.text.color,
16025
16122
  children: [
16026
16123
  formatCurrency(
16027
- ((period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * quantity
16124
+ ((period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * quantity,
16125
+ (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
16028
16126
  ),
16029
16127
  /* @__PURE__ */ jsxs11("sub", { children: [
16030
16128
  "/",
@@ -16042,7 +16140,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16042
16140
  $color: unitPriceColor,
16043
16141
  children: [
16044
16142
  formatCurrency(
16045
- (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0
16143
+ (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0,
16144
+ (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
16046
16145
  ),
16047
16146
  /* @__PURE__ */ jsxs11("sub", { children: [
16048
16147
  "/",
@@ -16075,14 +16174,19 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16075
16174
  import { useEffect as useEffect4, useState as useState6 } from "react";
16076
16175
 
16077
16176
  // node_modules/@stripe/stripe-js/dist/index.mjs
16078
- var V3_URL = "https://js.stripe.com/v3";
16177
+ var ORIGIN = "https://js.stripe.com";
16178
+ var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
16079
16179
  var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
16180
+ var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
16080
16181
  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";
16182
+ var isStripeJSURL = function isStripeJSURL2(url) {
16183
+ return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
16184
+ };
16081
16185
  var findScript = function findScript2() {
16082
- var scripts = document.querySelectorAll('script[src^="'.concat(V3_URL, '"]'));
16186
+ var scripts = document.querySelectorAll('script[src^="'.concat(ORIGIN, '"]'));
16083
16187
  for (var i2 = 0; i2 < scripts.length; i2++) {
16084
16188
  var script = scripts[i2];
16085
- if (!V3_URL_REGEX.test(script.src)) {
16189
+ if (!isStripeJSURL(script.src)) {
16086
16190
  continue;
16087
16191
  }
16088
16192
  return script;
@@ -16092,7 +16196,7 @@ var findScript = function findScript2() {
16092
16196
  var injectScript = function injectScript2(params) {
16093
16197
  var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
16094
16198
  var script = document.createElement("script");
16095
- script.src = "".concat(V3_URL).concat(queryString);
16199
+ script.src = "".concat(STRIPE_JS_URL).concat(queryString);
16096
16200
  var headOrBody = document.head || document.body;
16097
16201
  if (!headOrBody) {
16098
16202
  throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
@@ -16106,7 +16210,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
16106
16210
  }
16107
16211
  stripe._registerWrapper({
16108
16212
  name: "stripe-js",
16109
- version: "5.6.0",
16213
+ version: "5.7.0",
16110
16214
  startTime
16111
16215
  });
16112
16216
  };
@@ -16388,12 +16492,6 @@ var CheckoutDialog = ({ top = 0 }) => {
16388
16492
  const modalRef = useRef5(null);
16389
16493
  const contentRef = useRef5(null);
16390
16494
  const checkoutRef = useRef5(null);
16391
- const [checkoutStage, setCheckoutStage] = useState7(
16392
- () => selected.addOnId ? "addons" : selected.usage ? "usage" : "plan"
16393
- );
16394
- const [planPeriod, setPlanPeriod] = useState7(
16395
- selected.period || data.company?.plan?.planPeriod || "month"
16396
- );
16397
16495
  const [charges, setCharges] = useState7();
16398
16496
  const [paymentMethodId, setPaymentMethodId] = useState7();
16399
16497
  const [isLoading, setIsLoading] = useState7(false);
@@ -16402,13 +16500,18 @@ var CheckoutDialog = ({ top = 0 }) => {
16402
16500
  !data.subscription?.paymentMethod
16403
16501
  );
16404
16502
  const [promoCode, setPromoCode] = useState7();
16503
+ const [planPeriod, setPlanPeriod] = useState7(
16504
+ selected.period || data.company?.plan?.planPeriod || "month"
16505
+ );
16405
16506
  const {
16406
16507
  plans: availablePlans,
16407
16508
  addOns: availableAddOns,
16408
16509
  periods: availablePeriods
16409
16510
  } = useAvailablePlans(planPeriod);
16410
16511
  const [selectedPlan, setSelectedPlan] = useState7(
16411
- () => availablePlans.find((plan) => plan.current)
16512
+ () => availablePlans.find(
16513
+ (plan) => selected.planId ? plan.id === selected.planId : plan.current
16514
+ )
16412
16515
  );
16413
16516
  const currentAddOns = data.company?.addOns || [];
16414
16517
  const [addOns, setAddOns] = useState7(
@@ -16514,51 +16617,25 @@ var CheckoutDialog = ({ top = 0 }) => {
16514
16617
  selectedPlan?.companyCanTrial,
16515
16618
  requiresPayment
16516
16619
  ]);
16620
+ const [checkoutStage, setCheckoutStage] = useState7(() => {
16621
+ if (selected.addOnId) {
16622
+ return "addons";
16623
+ }
16624
+ if (selected.usage) {
16625
+ return "usage";
16626
+ }
16627
+ if (selected.planId !== currentPlan?.id) {
16628
+ return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : "plan";
16629
+ }
16630
+ return "plan";
16631
+ });
16517
16632
  const isLightBackground = useIsLightBackground();
16518
- const selectPlan = useCallback7(
16519
- (updatedPlan, updatedPeriod) => {
16520
- const entitlements = updatedPlan.entitlements.reduce(
16521
- createActiveUsageBasedEntitlementsReducer(updatedPeriod),
16522
- []
16523
- );
16524
- setSelectedPlan(updatedPlan);
16525
- setUsageBasedEntitlements(entitlements);
16526
- },
16527
- [createActiveUsageBasedEntitlementsReducer]
16528
- );
16529
- const toggleAddOn = (id) => {
16530
- setAddOns(
16531
- (prev2) => prev2.map((addOn) => ({
16532
- ...addOn,
16533
- ...addOn.id === id && { isSelected: !addOn.isSelected }
16534
- }))
16535
- );
16536
- };
16537
- const changePlanPeriod = useCallback7(
16538
- (period) => {
16539
- if (selectedPlan) {
16540
- selectPlan(selectedPlan, period);
16541
- }
16542
- setPlanPeriod(period);
16543
- },
16544
- [selectedPlan, selectPlan, setPlanPeriod]
16545
- );
16546
- const updateUsageBasedEntitlementQuantity = (id, updatedQuantity) => {
16547
- setUsageBasedEntitlements(
16548
- (prev2) => prev2.map(
16549
- ({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
16550
- entitlement,
16551
- allocation,
16552
- quantity: updatedQuantity,
16553
- usage
16554
- } : { entitlement, allocation, quantity, usage }
16555
- )
16556
- );
16557
- };
16558
- useEffect5(() => {
16559
- async function previewCheckout() {
16560
- const planPriceId = planPeriod === "month" ? selectedPlan?.monthlyPrice?.id : selectedPlan?.yearlyPrice?.id;
16561
- if (!api || !selectedPlan || !planPriceId) {
16633
+ const previewCheckout = useCallback7(
16634
+ async (updates) => {
16635
+ const period = updates.period || planPeriod;
16636
+ const plan = updates.plan || selectedPlan;
16637
+ const planPriceId = period === "month" ? plan?.monthlyPrice?.id : plan?.yearlyPrice?.id;
16638
+ if (!api || !plan || !planPriceId) {
16562
16639
  return;
16563
16640
  }
16564
16641
  setError(void 0);
@@ -16567,23 +16644,26 @@ var CheckoutDialog = ({ top = 0 }) => {
16567
16644
  try {
16568
16645
  const { data: data2 } = await api.previewCheckout({
16569
16646
  changeSubscriptionRequestBody: {
16570
- newPlanId: selectedPlan.id,
16647
+ newPlanId: plan.id,
16571
16648
  newPriceId: planPriceId,
16572
- addOnIds: addOns.reduce((acc, addOn) => {
16573
- if (addOn.isSelected) {
16574
- const addOnPriceId = (planPeriod === "month" ? addOn?.monthlyPrice : addOn?.yearlyPrice)?.id;
16575
- if (addOnPriceId) {
16576
- acc.push({
16577
- addOnId: addOn.id,
16578
- priceId: addOnPriceId
16579
- });
16649
+ addOnIds: (updates.addOns || addOns).reduce(
16650
+ (acc, addOn) => {
16651
+ if (addOn.isSelected) {
16652
+ const addOnPriceId = (period === "month" ? addOn?.monthlyPrice : addOn?.yearlyPrice)?.id;
16653
+ if (addOnPriceId) {
16654
+ acc.push({
16655
+ addOnId: addOn.id,
16656
+ priceId: addOnPriceId
16657
+ });
16658
+ }
16580
16659
  }
16581
- }
16582
- return acc;
16583
- }, []),
16584
- payInAdvance: payInAdvanceEntitlements.reduce(
16660
+ return acc;
16661
+ },
16662
+ []
16663
+ ),
16664
+ payInAdvance: (updates.payInAdvanceEntitlements || payInAdvanceEntitlements).reduce(
16585
16665
  (acc, { entitlement, quantity }) => {
16586
- const priceId = (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.priceId;
16666
+ const priceId = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.priceId;
16587
16667
  if (priceId) {
16588
16668
  acc.push({
16589
16669
  priceId,
@@ -16594,7 +16674,7 @@ var CheckoutDialog = ({ top = 0 }) => {
16594
16674
  },
16595
16675
  []
16596
16676
  ),
16597
- promoCode
16677
+ promoCode: updates.promoCode || promoCode
16598
16678
  }
16599
16679
  });
16600
16680
  setCharges(data2);
@@ -16613,19 +16693,88 @@ var CheckoutDialog = ({ top = 0 }) => {
16613
16693
  } finally {
16614
16694
  setIsLoading(false);
16615
16695
  }
16616
- }
16617
- previewCheckout();
16618
- }, [
16619
- t2,
16620
- api,
16621
- planPeriod,
16622
- selectedPlan,
16623
- addOns,
16624
- payInAdvanceEntitlements,
16625
- promoCode
16626
- ]);
16696
+ },
16697
+ [
16698
+ t2,
16699
+ api,
16700
+ planPeriod,
16701
+ selectedPlan,
16702
+ addOns,
16703
+ payInAdvanceEntitlements,
16704
+ promoCode
16705
+ ]
16706
+ );
16707
+ const selectPlan = useCallback7(
16708
+ (updates) => {
16709
+ const plan = updates.plan || selectedPlan;
16710
+ if (!plan) {
16711
+ return;
16712
+ }
16713
+ const period = updates.period || planPeriod;
16714
+ const entitlements = plan.entitlements.reduce(
16715
+ createActiveUsageBasedEntitlementsReducer(period),
16716
+ []
16717
+ );
16718
+ if (updates.plan) {
16719
+ setSelectedPlan(plan);
16720
+ setUsageBasedEntitlements(entitlements);
16721
+ }
16722
+ previewCheckout({
16723
+ period,
16724
+ plan: updates.plan,
16725
+ payInAdvanceEntitlements: entitlements.filter(
16726
+ ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
16727
+ )
16728
+ });
16729
+ },
16730
+ [
16731
+ planPeriod,
16732
+ selectedPlan,
16733
+ createActiveUsageBasedEntitlementsReducer,
16734
+ previewCheckout
16735
+ ]
16736
+ );
16737
+ const changePlanPeriod = useCallback7(
16738
+ (period) => {
16739
+ setPlanPeriod(period);
16740
+ previewCheckout({ period });
16741
+ },
16742
+ [setPlanPeriod, previewCheckout]
16743
+ );
16744
+ const toggleAddOn = (id) => {
16745
+ setAddOns((prev2) => {
16746
+ const updated = prev2.map((addOn) => ({
16747
+ ...addOn,
16748
+ ...addOn.id === id && { isSelected: !addOn.isSelected }
16749
+ }));
16750
+ previewCheckout({ addOns: updated });
16751
+ return updated;
16752
+ });
16753
+ };
16754
+ const updateUsageBasedEntitlementQuantity = useCallback7(
16755
+ (id, updatedQuantity) => {
16756
+ setUsageBasedEntitlements((prev2) => {
16757
+ const updated = prev2.map(
16758
+ ({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
16759
+ entitlement,
16760
+ allocation,
16761
+ quantity: updatedQuantity,
16762
+ usage
16763
+ } : { entitlement, allocation, quantity, usage }
16764
+ );
16765
+ previewCheckout({
16766
+ payInAdvanceEntitlements: updated.filter(
16767
+ ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
16768
+ )
16769
+ });
16770
+ return updated;
16771
+ });
16772
+ },
16773
+ [previewCheckout]
16774
+ );
16627
16775
  const updatePromoCode = (code) => {
16628
16776
  setPromoCode(code);
16777
+ previewCheckout({ promoCode: code });
16629
16778
  };
16630
16779
  useEffect5(() => {
16631
16780
  if (charges) {
@@ -17395,6 +17544,18 @@ var Details = ({
17395
17544
  const { t: t2 } = useTranslation();
17396
17545
  const theme = nt();
17397
17546
  const { data } = useEmbed();
17547
+ const currency = useMemo7(() => {
17548
+ if (data.company?.plan?.planPeriod === "month") {
17549
+ return monthlyUsageBasedPrice?.currency;
17550
+ }
17551
+ if (data.company?.plan?.planPeriod === "year") {
17552
+ return yearlyUsageBasedPrice?.currency;
17553
+ }
17554
+ }, [
17555
+ data.company?.plan?.planPeriod,
17556
+ monthlyUsageBasedPrice,
17557
+ yearlyUsageBasedPrice
17558
+ ]);
17398
17559
  const price = useMemo7(() => {
17399
17560
  if (data.company?.plan?.planPeriod === "month") {
17400
17561
  return monthlyUsageBasedPrice?.price;
@@ -17415,7 +17576,7 @@ var Details = ({
17415
17576
  return `${formatNumber(allocation)} ${(0, import_pluralize4.default)(feature.name, allocation)}`;
17416
17577
  }
17417
17578
  if (priceBehavior === "pay_as_you_go" && typeof price === "number") {
17418
- return `${formatCurrency(price)} ${t2("per")} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}`;
17579
+ return `${formatCurrency(price, currency)} ${t2("per")} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}`;
17419
17580
  }
17420
17581
  if (!priceBehavior && typeof allocation === "number") {
17421
17582
  return `${formatNumber(allocation)} ${(0, import_pluralize4.default)(feature.name, allocation)}`;
@@ -17423,7 +17584,7 @@ var Details = ({
17423
17584
  if (!priceBehavior) {
17424
17585
  return t2("Unlimited", { item: (0, import_pluralize4.default)(feature.name) });
17425
17586
  }
17426
- }, [allocation, feature?.name, price, priceBehavior, t2]);
17587
+ }, [allocation, feature?.name, price, priceBehavior, t2, currency]);
17427
17588
  const usageText = useMemo7(() => {
17428
17589
  if (!feature?.name) {
17429
17590
  return;
@@ -17431,15 +17592,15 @@ var Details = ({
17431
17592
  if (usageData) {
17432
17593
  let acc;
17433
17594
  if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
17434
- acc = `${formatCurrency(price)}/${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
17595
+ acc = `${formatCurrency(price, currency)}/${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
17435
17596
  } else if (priceBehavior === "pay_as_you_go" && typeof usage === "number") {
17436
17597
  acc = `${usage} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), usage)} ${t2("used")}`;
17437
17598
  }
17438
17599
  if (acc) {
17439
17600
  if (usageData?.priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
17440
- acc += ` \u2022 ${formatCurrency(price * allocation)}`;
17601
+ acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
17441
17602
  } else if (usageData?.priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
17442
- acc += ` \u2022 ${formatCurrency(price * usage)}`;
17603
+ acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
17443
17604
  }
17444
17605
  return acc;
17445
17606
  }
@@ -17460,7 +17621,8 @@ var Details = ({
17460
17621
  priceBehavior,
17461
17622
  t2,
17462
17623
  usage,
17463
- usageData
17624
+ usageData,
17625
+ currency
17464
17626
  ]);
17465
17627
  if (!text) {
17466
17628
  return null;
@@ -17741,9 +17903,9 @@ function resolveDesignProps2(props) {
17741
17903
  function formatInvoices(invoices) {
17742
17904
  return (invoices || []).filter(
17743
17905
  ({ url, amountDue, amountPaid }) => url && (amountDue === 0 || amountPaid > 0)
17744
- ).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url }) => ({
17906
+ ).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
17745
17907
  ...dueDate && { date: toPrettyDate(dueDate) },
17746
- amount: formatCurrency(amountDue),
17908
+ amount: formatCurrency(amountDue, currency),
17747
17909
  url
17748
17910
  }));
17749
17911
  }
@@ -17926,10 +18088,13 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
17926
18088
  yearlyUsageBasedPrice
17927
18089
  }, index) => {
17928
18090
  let price;
18091
+ let currency;
17929
18092
  if (planPeriod === "month") {
17930
18093
  price = monthlyUsageBasedPrice?.price;
18094
+ currency = monthlyUsageBasedPrice?.currency;
17931
18095
  } else if (planPeriod === "year") {
17932
18096
  price = yearlyUsageBasedPrice?.price;
18097
+ currency = yearlyUsageBasedPrice?.currency;
17933
18098
  }
17934
18099
  return /* @__PURE__ */ jsxs21(Element, { as: Flex, $gap: "1.5rem", children: [
17935
18100
  props.icon.isVisible && feature?.icon && /* @__PURE__ */ jsx28(
@@ -18003,7 +18168,7 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
18003
18168
  formatNumber(allocation),
18004
18169
  " ",
18005
18170
  (0, import_pluralize5.default)(feature.name, allocation)
18006
- ] }) : priceBehavior === "pay_as_you_go" ? typeof price === "number" && typeof usage === "number" && formatCurrency(usage * price) : typeof usage === "number" && /* @__PURE__ */ jsxs21(Fragment10, { children: [
18171
+ ] }) : priceBehavior === "pay_as_you_go" ? typeof price === "number" && typeof usage === "number" && formatCurrency(usage * price, currency) : typeof usage === "number" && /* @__PURE__ */ jsxs21(Fragment10, { children: [
18007
18172
  formatNumber(usage),
18008
18173
  " ",
18009
18174
  (0, import_pluralize5.default)(feature.name, usage)
@@ -18495,19 +18660,23 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18495
18660
  (acc, usage) => {
18496
18661
  const quantity = usage?.allocation ?? 0;
18497
18662
  let price;
18663
+ let currencyCode;
18498
18664
  if (currentPlan?.planPeriod === "month") {
18499
18665
  price = usage.monthlyUsageBasedPrice?.price;
18666
+ currencyCode = usage.monthlyUsageBasedPrice?.currency;
18500
18667
  } else if (currentPlan?.planPeriod === "year") {
18501
18668
  price = usage.yearlyUsageBasedPrice?.price;
18669
+ currencyCode = usage.yearlyUsageBasedPrice?.currency;
18502
18670
  }
18503
18671
  if (usage.priceBehavior && typeof price === "number" && quantity > 0) {
18504
- acc.push({ ...usage, price, quantity });
18672
+ acc.push({ ...usage, price, quantity, currencyCode });
18505
18673
  }
18506
18674
  return acc;
18507
18675
  },
18508
18676
  []
18509
18677
  );
18510
18678
  const billingSubscription = data.company?.billingSubscription;
18679
+ const subscriptionCurrency = billingSubscription?.currency ?? "USD";
18511
18680
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18512
18681
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18513
18682
  const todayDate = /* @__PURE__ */ new Date();
@@ -18601,7 +18770,10 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18601
18770
  $size: theme.typography[props.header.price.fontStyle].fontSize,
18602
18771
  $weight: theme.typography[props.header.price.fontStyle].fontWeight,
18603
18772
  $color: theme.typography[props.header.price.fontStyle].color,
18604
- children: formatCurrency(currentPlan.planPrice)
18773
+ children: formatCurrency(
18774
+ currentPlan.planPrice,
18775
+ subscriptionCurrency
18776
+ )
18605
18777
  }
18606
18778
  ),
18607
18779
  /* @__PURE__ */ jsx30(
@@ -18659,7 +18831,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18659
18831
  $weight: theme.typography.text.fontWeight,
18660
18832
  $color: theme.typography.text.color,
18661
18833
  children: [
18662
- formatCurrency(addOn.planPrice),
18834
+ formatCurrency(addOn.planPrice, subscriptionCurrency),
18663
18835
  /* @__PURE__ */ jsxs23("sub", { children: [
18664
18836
  "/",
18665
18837
  shortenPeriod(addOn.planPeriod)
@@ -18722,7 +18894,10 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18722
18894
  $weight: theme.typography.text.fontWeight,
18723
18895
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
18724
18896
  children: [
18725
- formatCurrency(entitlement.price),
18897
+ formatCurrency(
18898
+ entitlement.price,
18899
+ entitlement.currencyCode
18900
+ ),
18726
18901
  /* @__PURE__ */ jsxs23("sub", { children: [
18727
18902
  "/",
18728
18903
  (0, import_pluralize6.default)(
@@ -18744,7 +18919,8 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18744
18919
  $color: theme.typography.text.color,
18745
18920
  children: [
18746
18921
  formatCurrency(
18747
- entitlement.price * (entitlement.priceBehavior === "pay_in_advance" ? entitlement.quantity : 1)
18922
+ entitlement.price * (entitlement.priceBehavior === "pay_in_advance" ? entitlement.quantity : 1),
18923
+ entitlement.currencyCode
18748
18924
  ),
18749
18925
  /* @__PURE__ */ jsxs23("sub", { children: [
18750
18926
  "/",
@@ -18924,7 +19100,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
18924
19100
  $display: "grid",
18925
19101
  $gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
18926
19102
  $gap: "1rem",
18927
- children: plans.map((plan, index, self2) => {
19103
+ children: plans.map((plan, index) => {
18928
19104
  const isActivePlan = plan.current && data.company?.plan?.planPeriod === selectedPeriod;
18929
19105
  const count = entitlementCounts[plan.id];
18930
19106
  let isExpanded = false;
@@ -18983,12 +19159,13 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
18983
19159
  $size: theme.typography[props.plans.name.fontStyle].fontSize,
18984
19160
  $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
18985
19161
  $color: theme.typography[props.plans.name.fontStyle].color,
18986
- children: formatCurrency(
18987
- (selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
19162
+ children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig?.priceText : t2("Custom Plan Price") : formatCurrency(
19163
+ (selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0,
19164
+ (selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.currency
18988
19165
  )
18989
19166
  }
18990
19167
  ),
18991
- /* @__PURE__ */ jsxs24(
19168
+ !plan.custom && /* @__PURE__ */ jsxs24(
18992
19169
  Text,
18993
19170
  {
18994
19171
  $font: theme.typography[props.plans.name.fontStyle].fontFamily,
@@ -19029,18 +19206,6 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19029
19206
  $padding: `${0.75 * cardPadding}rem ${cardPadding}rem 0`,
19030
19207
  children: [
19031
19208
  props.plans.showEntitlements && /* @__PURE__ */ jsxs24(Flex, { $flexDirection: "column", $gap: "1rem", $flexGrow: "1", children: [
19032
- props.plans.showInclusionText && index > 0 && /* @__PURE__ */ jsx31(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx31(
19033
- Text,
19034
- {
19035
- $font: theme.typography.text.fontFamily,
19036
- $size: theme.typography.text.fontSize,
19037
- $weight: theme.typography.text.fontWeight,
19038
- $color: theme.typography.text.color,
19039
- children: t2("Everything in", {
19040
- plan: self2[index - 1].name
19041
- })
19042
- }
19043
- ) }),
19044
19209
  plan.entitlements.slice().sort((a2, b2) => {
19045
19210
  if (a2.feature?.name && b2.feature?.name && a2.feature?.name > b2.feature?.name) {
19046
19211
  return 1;
@@ -19051,10 +19216,13 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19051
19216
  return 0;
19052
19217
  }).reduce((acc, entitlement) => {
19053
19218
  let price;
19219
+ let currency;
19054
19220
  if (selectedPeriod === "month") {
19055
19221
  price = entitlement.meteredMonthlyPrice?.price;
19222
+ currency = entitlement.meteredMonthlyPrice?.currency;
19056
19223
  } else if (selectedPeriod === "year") {
19057
19224
  price = entitlement.meteredYearlyPrice?.price;
19225
+ currency = entitlement.meteredYearlyPrice?.currency;
19058
19226
  }
19059
19227
  if (entitlement.priceBehavior && typeof price !== "number") {
19060
19228
  return acc;
@@ -19081,7 +19249,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19081
19249
  $color: theme.typography.text.color,
19082
19250
  $leading: 1.35,
19083
19251
  children: typeof price !== "undefined" ? /* @__PURE__ */ jsxs24(Fragment13, { children: [
19084
- formatCurrency(price),
19252
+ formatCurrency(price, currency),
19085
19253
  " ",
19086
19254
  t2("per"),
19087
19255
  " ",
@@ -19189,13 +19357,15 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19189
19357
  EmbedButton,
19190
19358
  {
19191
19359
  disabled: !plan.valid || !canCheckout,
19192
- onClick: () => {
19193
- setSelected({
19194
- period: selectedPeriod,
19195
- planId: isActivePlan ? null : plan.id,
19196
- usage: false
19197
- });
19198
- setLayout("checkout");
19360
+ ...!plan.custom && {
19361
+ onClick: () => {
19362
+ setSelected({
19363
+ period: selectedPeriod,
19364
+ planId: isActivePlan ? null : plan.id,
19365
+ usage: false
19366
+ });
19367
+ setLayout("checkout");
19368
+ }
19199
19369
  },
19200
19370
  ...index > currentPlanIndex ? {
19201
19371
  $size: props.upgrade.buttonSize,
@@ -19206,7 +19376,14 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19206
19376
  $color: props.downgrade.buttonStyle,
19207
19377
  $variant: "outline"
19208
19378
  },
19209
- children: !plan.valid ? /* @__PURE__ */ jsx31(
19379
+ children: plan.custom ? /* @__PURE__ */ jsx31(
19380
+ ButtonLink,
19381
+ {
19382
+ href: plan.customPlanConfig?.ctaWebSite ?? "#",
19383
+ target: "_blank",
19384
+ children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
19385
+ }
19386
+ ) : !plan.valid ? /* @__PURE__ */ jsx31(
19210
19387
  Tooltip,
19211
19388
  {
19212
19389
  trigger: t2("Over usage limit"),
@@ -19299,7 +19476,8 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19299
19476
  $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
19300
19477
  $color: theme.typography[props.plans.name.fontStyle].color,
19301
19478
  children: formatCurrency(
19302
- (selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0
19479
+ (selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0,
19480
+ (selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.currency
19303
19481
  )
19304
19482
  }
19305
19483
  ),
@@ -19482,7 +19660,8 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19482
19660
  },
19483
19661
  ...data.upcomingInvoice?.dueDate && {
19484
19662
  dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
19485
- }
19663
+ },
19664
+ currency: data.upcomingInvoice?.currency
19486
19665
  }
19487
19666
  };
19488
19667
  }, [data.subscription, data.upcomingInvoice]);
@@ -19521,7 +19700,10 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19521
19700
  $weight: theme.typography[props.price.fontStyle].fontWeight,
19522
19701
  $color: theme.typography[props.price.fontStyle].color,
19523
19702
  $leading: 1,
19524
- children: formatCurrency(upcomingInvoice.amountDue)
19703
+ children: formatCurrency(
19704
+ upcomingInvoice.amountDue,
19705
+ upcomingInvoice.currency
19706
+ )
19525
19707
  }
19526
19708
  ) }),
19527
19709
  /* @__PURE__ */ jsx32(Box, { $lineHeight: 1.15, $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ jsx32(
@@ -19536,7 +19718,7 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19536
19718
  }
19537
19719
  ) })
19538
19720
  ] }),
19539
- /* @__PURE__ */ jsxs25(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
19721
+ discounts.length > 0 && /* @__PURE__ */ jsxs25(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
19540
19722
  /* @__PURE__ */ jsx32(Box, { children: /* @__PURE__ */ jsx32(
19541
19723
  Text,
19542
19724
  {
@@ -19588,7 +19770,7 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19588
19770
  UpcomingBill.displayName = "UpcomingBill";
19589
19771
 
19590
19772
  // src/components/embed/ComponentTree.tsx
19591
- import { useEffect as useEffect9, useState as useState16, Children as Children2 } from "react";
19773
+ import { useEffect as useEffect9, useState as useState16 } from "react";
19592
19774
 
19593
19775
  // src/components/embed/renderer.ts
19594
19776
  import { createElement as createElement5 } from "react";
@@ -19691,7 +19873,7 @@ var Error2 = ({ message }) => {
19691
19873
  );
19692
19874
  };
19693
19875
  var ComponentTree = () => {
19694
- const { error, nodes } = useEmbed();
19876
+ const { error, nodes, isPending } = useEmbed();
19695
19877
  const [children, setChildren] = useState16(/* @__PURE__ */ jsx33(Loading, {}));
19696
19878
  useEffect9(() => {
19697
19879
  const renderer = createRenderer();
@@ -19701,7 +19883,7 @@ var ComponentTree = () => {
19701
19883
  console.error(error);
19702
19884
  return /* @__PURE__ */ jsx33(Error2, { message: error.message });
19703
19885
  }
19704
- if (Children2.count(children) === 0) {
19886
+ if (isPending) {
19705
19887
  return /* @__PURE__ */ jsx33(Loading, {});
19706
19888
  }
19707
19889
  return /* @__PURE__ */ jsx33(Fragment14, { children });