@schematichq/schematic-components 2.29.0 → 2.29.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.
@@ -3635,6 +3635,7 @@ __export(index_exports, {
3635
3635
  useCustomPlanBilling: () => useCustomPlanBilling,
3636
3636
  useEmbed: () => useEmbed,
3637
3637
  useIsLightBackground: () => useIsLightBackground,
3638
+ useNextBillDate: () => useNextBillDate,
3638
3639
  usePaymentConfirmation: () => usePaymentConfirmation,
3639
3640
  useRequest: () => useRequest,
3640
3641
  useSubscriptionCurrency: () => useSubscriptionCurrency,
@@ -3645,10 +3646,10 @@ __export(index_exports, {
3645
3646
  module.exports = __toCommonJS(index_exports);
3646
3647
 
3647
3648
  // src/components/elements/button/Button.tsx
3648
- var import_react40 = require("react");
3649
+ var import_react41 = require("react");
3649
3650
 
3650
3651
  // src/components/layout/card/Card.tsx
3651
- var import_react19 = require("react");
3652
+ var import_react20 = require("react");
3652
3653
 
3653
3654
  // src/const/components.ts
3654
3655
  var VISIBLE_CREDIT_COUNT = 3;
@@ -4329,6 +4330,10 @@ function BillingArrearsCadenceFromJSONTyped(json, ignoreDiscriminator) {
4329
4330
  }
4330
4331
 
4331
4332
  // src/api/checkoutexternal/models/BillingCollectionMethod.ts
4333
+ var BillingCollectionMethod = {
4334
+ ChargeAutomatically: "charge_automatically",
4335
+ SendInvoice: "send_invoice"
4336
+ };
4332
4337
  function BillingCollectionMethodFromJSON(json) {
4333
4338
  return BillingCollectionMethodFromJSONTyped(json, false);
4334
4339
  }
@@ -6428,6 +6433,48 @@ function CompanyOverrideResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6428
6433
  };
6429
6434
  }
6430
6435
 
6436
+ // src/api/checkoutexternal/models/CompanyPaymentMethodResponseData.ts
6437
+ function CompanyPaymentMethodResponseDataFromJSON(json) {
6438
+ return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
6439
+ }
6440
+ function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6441
+ if (json == null) {
6442
+ return json;
6443
+ }
6444
+ return {
6445
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
6446
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
6447
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
6448
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
6449
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
6450
+ canRemove: json["can_remove"],
6451
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
6452
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
6453
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
6454
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
6455
+ externalId: json["external_id"],
6456
+ id: json["id"],
6457
+ isDefault: json["is_default"],
6458
+ type: json["type"]
6459
+ };
6460
+ }
6461
+
6462
+ // src/api/checkoutexternal/models/CompanyPaymentMethodsResponseData.ts
6463
+ function CompanyPaymentMethodsResponseDataFromJSON(json) {
6464
+ return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
6465
+ }
6466
+ function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6467
+ if (json == null) {
6468
+ return json;
6469
+ }
6470
+ return {
6471
+ count: json["count"],
6472
+ paymentMethods: json["payment_methods"].map(
6473
+ CompanyPaymentMethodResponseDataFromJSON
6474
+ )
6475
+ };
6476
+ }
6477
+
6431
6478
  // src/api/checkoutexternal/models/CompanyPlanInvalidReason.ts
6432
6479
  var CompanyPlanInvalidReason = {
6433
6480
  DowngradeNotPermitted: "downgrade_not_permitted",
@@ -7831,6 +7878,20 @@ function GetCompanyInvoicesResponseFromJSONTyped(json, ignoreDiscriminator) {
7831
7878
  };
7832
7879
  }
7833
7880
 
7881
+ // src/api/checkoutexternal/models/GetCompanyPaymentMethodsResponse.ts
7882
+ function GetCompanyPaymentMethodsResponseFromJSON(json) {
7883
+ return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
7884
+ }
7885
+ function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
7886
+ if (json == null) {
7887
+ return json;
7888
+ }
7889
+ return {
7890
+ data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
7891
+ params: json["params"]
7892
+ };
7893
+ }
7894
+
7834
7895
  // src/api/checkoutexternal/models/GetCompanyUpcomingInvoiceResponse.ts
7835
7896
  function GetCompanyUpcomingInvoiceResponseFromJSON(json) {
7836
7897
  return GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, false);
@@ -8725,6 +8786,38 @@ var CheckoutexternalApi = class extends BaseAPI {
8725
8786
  );
8726
8787
  return await response.value();
8727
8788
  }
8789
+ /**
8790
+ * Get company payment methods
8791
+ */
8792
+ async getCompanyPaymentMethodsRaw(initOverrides) {
8793
+ const queryParameters = {};
8794
+ const headerParameters = {};
8795
+ if (this.configuration && this.configuration.apiKey) {
8796
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
8797
+ "X-Schematic-Api-Key"
8798
+ );
8799
+ }
8800
+ const response = await this.request(
8801
+ {
8802
+ path: `/company/payment-methods`,
8803
+ method: "GET",
8804
+ headers: headerParameters,
8805
+ query: queryParameters
8806
+ },
8807
+ initOverrides
8808
+ );
8809
+ return new JSONApiResponse(
8810
+ response,
8811
+ (jsonValue) => GetCompanyPaymentMethodsResponseFromJSON(jsonValue)
8812
+ );
8813
+ }
8814
+ /**
8815
+ * Get company payment methods
8816
+ */
8817
+ async getCompanyPaymentMethods(initOverrides) {
8818
+ const response = await this.getCompanyPaymentMethodsRaw(initOverrides);
8819
+ return await response.value();
8820
+ }
8728
8821
  /**
8729
8822
  * Get company upcoming invoice
8730
8823
  */
@@ -13662,6 +13755,7 @@ var en = {
13662
13755
  "Error saving custom field values. Please try again.": "Error saving custom field values. Please try again.",
13663
13756
  "Pay now": "Pay now",
13664
13757
  "Payment Details": "Payment Details",
13758
+ "Payment due": "Payment due {{date}}",
13665
13759
  "Plan selected": "Plan selected",
13666
13760
  "Please accept the agreement to continue.": "Please accept the agreement to continue.",
13667
13761
  "Please try again later.": "Please try again later.",
@@ -15924,7 +16018,7 @@ var reducer = (state, action) => {
15924
16018
  // src/context/EmbedProvider.tsx
15925
16019
  var import_jsx_runtime4 = require("react/jsx-runtime");
15926
16020
  var getCustomHeaders = (sessionId) => ({
15927
- "X-Schematic-Components-Version": "2.29.0",
16021
+ "X-Schematic-Components-Version": "2.29.1",
15928
16022
  "X-Schematic-Session-ID": sessionId
15929
16023
  });
15930
16024
  var normalizeCurrencyFilter = (filter) => {
@@ -16710,8 +16804,31 @@ function useIsLightBackground() {
16710
16804
  return isLightBackground;
16711
16805
  }
16712
16806
 
16713
- // src/hooks/usePaymentConfirmation.ts
16807
+ // src/hooks/useNextBillDate.ts
16714
16808
  var import_react10 = require("react");
16809
+ function useNextBillDate(upcomingInvoice) {
16810
+ const { data } = useEmbed();
16811
+ const invoice = upcomingInvoice === void 0 ? data?.upcomingInvoice : upcomingInvoice;
16812
+ const subscription = data?.company?.billingSubscription;
16813
+ const cancelAtPeriodEnd = subscription?.cancelAtPeriodEnd;
16814
+ const periodEnd = subscription?.periodEnd;
16815
+ const collectionMethod = invoice?.collectionMethod;
16816
+ const dueDate = invoice?.dueDate ?? void 0;
16817
+ return (0, import_react10.useMemo)(() => {
16818
+ if (cancelAtPeriodEnd) {
16819
+ return { billDate: void 0, paymentDueDate: void 0 };
16820
+ }
16821
+ const billDate = periodEnd && periodEnd > 0 ? new Date(periodEnd * 1e3) : dueDate;
16822
+ const hasSeparateDeadline = collectionMethod === BillingCollectionMethod.SendInvoice && dueDate && billDate && new Date(dueDate).toDateString() !== new Date(billDate).toDateString();
16823
+ return {
16824
+ billDate,
16825
+ paymentDueDate: hasSeparateDeadline ? dueDate : void 0
16826
+ };
16827
+ }, [cancelAtPeriodEnd, periodEnd, collectionMethod, dueDate]);
16828
+ }
16829
+
16830
+ // src/hooks/usePaymentConfirmation.ts
16831
+ var import_react11 = require("react");
16715
16832
  var usePaymentConfirmation = ({
16716
16833
  stripe,
16717
16834
  clientSecret,
@@ -16719,24 +16836,24 @@ var usePaymentConfirmation = ({
16719
16836
  onError: onError3,
16720
16837
  autoConfirm = false
16721
16838
  }) => {
16722
- const [state, setState] = (0, import_react10.useState)(() => ({
16839
+ const [state, setState] = (0, import_react11.useState)(() => ({
16723
16840
  secret: clientSecret,
16724
16841
  status: "idle",
16725
16842
  error: null
16726
16843
  }));
16727
- const onSuccessRef = (0, import_react10.useRef)(onSuccess);
16728
- const onErrorRef = (0, import_react10.useRef)(onError3);
16729
- (0, import_react10.useEffect)(() => {
16844
+ const onSuccessRef = (0, import_react11.useRef)(onSuccess);
16845
+ const onErrorRef = (0, import_react11.useRef)(onError3);
16846
+ (0, import_react11.useEffect)(() => {
16730
16847
  onSuccessRef.current = onSuccess;
16731
16848
  onErrorRef.current = onError3;
16732
16849
  });
16733
- const confirmedSecrets = (0, import_react10.useRef)(/* @__PURE__ */ new Set());
16734
- const abortControllerRef = (0, import_react10.useRef)(null);
16850
+ const confirmedSecrets = (0, import_react11.useRef)(/* @__PURE__ */ new Set());
16851
+ const abortControllerRef = (0, import_react11.useRef)(null);
16735
16852
  const isCurrentSecret = state.secret === clientSecret;
16736
16853
  const status = isCurrentSecret ? state.status : "idle";
16737
16854
  const error = isCurrentSecret ? state.error : null;
16738
16855
  const isConfirming = status === "confirming";
16739
- const confirmPayment = (0, import_react10.useCallback)(async () => {
16856
+ const confirmPayment = (0, import_react11.useCallback)(async () => {
16740
16857
  if (!stripe || !clientSecret) {
16741
16858
  const err = new Error(
16742
16859
  "Missing required parameters: stripe instance or client secret"
@@ -16784,7 +16901,7 @@ var usePaymentConfirmation = ({
16784
16901
  abortControllerRef.current = null;
16785
16902
  }
16786
16903
  }, [stripe, clientSecret]);
16787
- const reset = (0, import_react10.useCallback)(() => {
16904
+ const reset = (0, import_react11.useCallback)(() => {
16788
16905
  if (clientSecret) {
16789
16906
  confirmedSecrets.current.delete(clientSecret);
16790
16907
  }
@@ -16794,12 +16911,12 @@ var usePaymentConfirmation = ({
16794
16911
  abortControllerRef.current = null;
16795
16912
  }
16796
16913
  }, [clientSecret]);
16797
- (0, import_react10.useEffect)(() => {
16914
+ (0, import_react11.useEffect)(() => {
16798
16915
  if (autoConfirm && status === "idle" && stripe && clientSecret) {
16799
16916
  queueMicrotask(confirmPayment);
16800
16917
  }
16801
16918
  }, [autoConfirm, stripe, clientSecret, status, confirmPayment]);
16802
- (0, import_react10.useEffect)(() => {
16919
+ (0, import_react11.useEffect)(() => {
16803
16920
  return () => {
16804
16921
  if (abortControllerRef.current) {
16805
16922
  abortControllerRef.current.abort();
@@ -16817,12 +16934,12 @@ var usePaymentConfirmation = ({
16817
16934
  };
16818
16935
 
16819
16936
  // src/hooks/useRequest.ts
16820
- var import_react11 = require("react");
16937
+ var import_react12 = require("react");
16821
16938
  function useRequest(fn) {
16822
- const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
16823
- const [error, setError] = (0, import_react11.useState)(null);
16824
- const [data, setData] = (0, import_react11.useState)(void 0);
16825
- const request = (0, import_react11.useCallback)(async () => {
16939
+ const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
16940
+ const [error, setError] = (0, import_react12.useState)(null);
16941
+ const [data, setData] = (0, import_react12.useState)(void 0);
16942
+ const request = (0, import_react12.useCallback)(async () => {
16826
16943
  try {
16827
16944
  setError(null);
16828
16945
  setIsLoading(true);
@@ -16837,7 +16954,7 @@ function useRequest(fn) {
16837
16954
  setIsLoading(false);
16838
16955
  }
16839
16956
  }, [fn]);
16840
- const value = (0, import_react11.useMemo)(() => {
16957
+ const value = (0, import_react12.useMemo)(() => {
16841
16958
  const state = { isLoading, error, data };
16842
16959
  return [state, request];
16843
16960
  }, [isLoading, error, data, request]);
@@ -16845,11 +16962,11 @@ function useRequest(fn) {
16845
16962
  }
16846
16963
 
16847
16964
  // src/hooks/useTrialEnd.ts
16848
- var import_react12 = require("react");
16965
+ var import_react13 = require("react");
16849
16966
  function useTrialEnd() {
16850
16967
  const { data } = useEmbed();
16851
16968
  const { t: t2 } = useTranslation();
16852
- const { endDate, amount, units } = (0, import_react12.useMemo)(() => {
16969
+ const { endDate, amount, units } = (0, import_react13.useMemo)(() => {
16853
16970
  const billingSubscription = data?.company?.billingSubscription;
16854
16971
  const end = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
16855
16972
  let amount2;
@@ -16879,19 +16996,19 @@ function useTrialEnd() {
16879
16996
  }
16880
16997
 
16881
16998
  // src/hooks/useTruncatedList.ts
16882
- var import_react13 = require("react");
16999
+ var import_react14 = require("react");
16883
17000
  function useTruncatedList(items, { limit }) {
16884
- const [isExpandedState, setIsExpanded] = (0, import_react13.useState)(false);
17001
+ const [isExpandedState, setIsExpanded] = (0, import_react14.useState)(false);
16885
17002
  const total = items.length;
16886
17003
  const canExpand = total > limit;
16887
17004
  const isExpanded = canExpand && isExpandedState;
16888
- const visibleItems = (0, import_react13.useMemo)(
17005
+ const visibleItems = (0, import_react14.useMemo)(
16889
17006
  () => canExpand && !isExpanded ? items.slice(0, limit) : items,
16890
17007
  [items, limit, canExpand, isExpanded]
16891
17008
  );
16892
- const toggle = (0, import_react13.useCallback)(() => setIsExpanded((prev) => !prev), []);
16893
- const expand = (0, import_react13.useCallback)(() => setIsExpanded(true), []);
16894
- const collapse = (0, import_react13.useCallback)(() => setIsExpanded(false), []);
17009
+ const toggle = (0, import_react14.useCallback)(() => setIsExpanded((prev) => !prev), []);
17010
+ const expand = (0, import_react14.useCallback)(() => setIsExpanded(true), []);
17011
+ const collapse = (0, import_react14.useCallback)(() => setIsExpanded(false), []);
16895
17012
  return {
16896
17013
  items: visibleItems,
16897
17014
  total,
@@ -16905,10 +17022,10 @@ function useTruncatedList(items, { limit }) {
16905
17022
  }
16906
17023
 
16907
17024
  // src/hooks/useWrapChildren.ts
16908
- var import_react14 = require("react");
17025
+ var import_react15 = require("react");
16909
17026
  function useWrapChildren(ref) {
16910
- const [shouldWrap, setShouldWrap] = (0, import_react14.useState)([]);
16911
- (0, import_react14.useLayoutEffect)(() => {
17027
+ const [shouldWrap, setShouldWrap] = (0, import_react15.useState)([]);
17028
+ (0, import_react15.useLayoutEffect)(() => {
16912
17029
  const rowShouldWrap = (parent) => [...parent.children].some(
16913
17030
  (el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
16914
17031
  );
@@ -17369,7 +17486,7 @@ var Checkbox = import_styled_components8.styled.input.attrs({ type: "checkbox" }
17369
17486
  `;
17370
17487
 
17371
17488
  // src/components/ui/dialog/Dialog.tsx
17372
- var import_react15 = require("react");
17489
+ var import_react16 = require("react");
17373
17490
 
17374
17491
  // src/components/ui/dialog/styles.ts
17375
17492
  var import_styled_components9 = __toESM(require_styled_components_cjs());
@@ -17437,7 +17554,7 @@ var Dialog = import_styled_components9.styled.dialog(
17437
17554
 
17438
17555
  // src/components/ui/dialog/Dialog.tsx
17439
17556
  var import_jsx_runtime5 = require("react/jsx-runtime");
17440
- var Dialog2 = (0, import_react15.forwardRef)(
17557
+ var Dialog2 = (0, import_react16.forwardRef)(
17441
17558
  ({
17442
17559
  children,
17443
17560
  isModal = true,
@@ -17447,9 +17564,9 @@ var Dialog2 = (0, import_react15.forwardRef)(
17447
17564
  onClose,
17448
17565
  ...rest
17449
17566
  }, outerRef) => {
17450
- const innerRef = (0, import_react15.useRef)(null);
17451
- (0, import_react15.useImperativeHandle)(outerRef, () => innerRef.current, []);
17452
- (0, import_react15.useLayoutEffect)(() => {
17567
+ const innerRef = (0, import_react16.useRef)(null);
17568
+ (0, import_react16.useImperativeHandle)(outerRef, () => innerRef.current, []);
17569
+ (0, import_react16.useLayoutEffect)(() => {
17453
17570
  if (!isModal) {
17454
17571
  return;
17455
17572
  }
@@ -17461,7 +17578,7 @@ var Dialog2 = (0, import_react15.forwardRef)(
17461
17578
  document.body.style.overflow = initialOverflowValue;
17462
17579
  };
17463
17580
  }, [isModal]);
17464
- const dialog = (0, import_react15.useMemo)(
17581
+ const dialog = (0, import_react16.useMemo)(
17465
17582
  () => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17466
17583
  Dialog,
17467
17584
  {
@@ -17510,9 +17627,9 @@ var DialogClose = ({ onClose, ...rest }) => {
17510
17627
  };
17511
17628
 
17512
17629
  // src/components/ui/dialog/DialogContent.tsx
17513
- var import_react16 = require("react");
17630
+ var import_react17 = require("react");
17514
17631
  var import_jsx_runtime7 = require("react/jsx-runtime");
17515
- var DialogContent2 = (0, import_react16.forwardRef)(({ children }, ref) => {
17632
+ var DialogContent2 = (0, import_react17.forwardRef)(({ children }, ref) => {
17516
17633
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogContent, { ref, children });
17517
17634
  });
17518
17635
  DialogContent2.displayName = "DialogContent";
@@ -17706,7 +17823,7 @@ var Overlay = (0, import_styled_components12.styled)(Flex)(({ theme }) => {
17706
17823
  });
17707
17824
 
17708
17825
  // src/components/ui/progress-bar/ProgressBar.tsx
17709
- var import_react17 = require("react");
17826
+ var import_react18 = require("react");
17710
17827
  var import_jsx_runtime10 = require("react/jsx-runtime");
17711
17828
  var progressColorMap = [
17712
17829
  "blue",
@@ -17716,7 +17833,7 @@ var progressColorMap = [
17716
17833
  "red",
17717
17834
  "red"
17718
17835
  ];
17719
- var ProgressBar = (0, import_react17.forwardRef)(
17836
+ var ProgressBar = (0, import_react18.forwardRef)(
17720
17837
  ({
17721
17838
  progress,
17722
17839
  value,
@@ -17926,7 +18043,7 @@ var Toggle = import_styled_components14.styled.input.attrs({ type: "checkbox" })
17926
18043
 
17927
18044
  // src/components/ui/tooltip/Tooltip.tsx
17928
18045
  var import_debounce3 = __toESM(require_debounce());
17929
- var import_react18 = require("react");
18046
+ var import_react19 = require("react");
17930
18047
  var import_react_dom = require("react-dom");
17931
18048
 
17932
18049
  // src/components/ui/tooltip/styles.ts
@@ -18097,10 +18214,10 @@ var Tooltip = ({
18097
18214
  position = "top",
18098
18215
  ...rest
18099
18216
  }) => {
18100
- const triggerRef = (0, import_react18.useRef)(null);
18101
- const [show, setShow] = (0, import_react18.useState)(false);
18102
- const [coords2, setCoords] = (0, import_react18.useState)({ x: 0, y: 0 });
18103
- const updateCoords = (0, import_react18.useCallback)(() => {
18217
+ const triggerRef = (0, import_react19.useRef)(null);
18218
+ const [show, setShow] = (0, import_react19.useState)(false);
18219
+ const [coords2, setCoords] = (0, import_react19.useState)({ x: 0, y: 0 });
18220
+ const updateCoords = (0, import_react19.useCallback)(() => {
18104
18221
  const coords3 = getCoords({
18105
18222
  element: triggerRef.current,
18106
18223
  portal,
@@ -18108,7 +18225,7 @@ var Tooltip = ({
18108
18225
  });
18109
18226
  setCoords(coords3);
18110
18227
  }, [portal, position]);
18111
- (0, import_react18.useLayoutEffect)(() => {
18228
+ (0, import_react19.useLayoutEffect)(() => {
18112
18229
  updateCoords();
18113
18230
  const handleResize = (0, import_debounce3.default)(updateCoords, EVENT_DEBOUNCE_TIMEOUT);
18114
18231
  window.addEventListener("resize", handleResize);
@@ -18119,7 +18236,7 @@ var Tooltip = ({
18119
18236
  };
18120
18237
  }, [updateCoords]);
18121
18238
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
18122
- (0, import_react18.cloneElement)(trigger, {
18239
+ (0, import_react19.cloneElement)(trigger, {
18123
18240
  ref: triggerRef,
18124
18241
  onFocus: () => setShow(true),
18125
18242
  onBlur: () => setShow(false),
@@ -18176,7 +18293,7 @@ var StyledCard = import_styled_components16.styled.div(({ theme }) => {
18176
18293
 
18177
18294
  // src/components/layout/card/Card.tsx
18178
18295
  var import_jsx_runtime12 = require("react/jsx-runtime");
18179
- var Card = (0, import_react19.forwardRef)(
18296
+ var Card = (0, import_react20.forwardRef)(
18180
18297
  ({ children, className }, ref) => {
18181
18298
  const { settings, isPending } = useEmbed();
18182
18299
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(StyledCard, { ref, className, children: [
@@ -18204,7 +18321,7 @@ var Card = (0, import_react19.forwardRef)(
18204
18321
  Card.displayName = "Card";
18205
18322
 
18206
18323
  // src/components/layout/column/Column.tsx
18207
- var import_react20 = require("react");
18324
+ var import_react21 = require("react");
18208
18325
 
18209
18326
  // src/components/layout/column/styles.ts
18210
18327
  var import_styled_components17 = __toESM(require_styled_components_cjs());
@@ -18214,15 +18331,15 @@ var StyledColumn = import_styled_components17.styled.div`
18214
18331
 
18215
18332
  // src/components/layout/column/Column.tsx
18216
18333
  var import_jsx_runtime13 = require("react/jsx-runtime");
18217
- var Column = (0, import_react20.forwardRef)(
18334
+ var Column = (0, import_react21.forwardRef)(
18218
18335
  ({ children, basis, ...props }, ref) => {
18219
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StyledColumn, { ref, ...props, children: import_react20.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Card, { children }) : children });
18336
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StyledColumn, { ref, ...props, children: import_react21.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Card, { children }) : children });
18220
18337
  }
18221
18338
  );
18222
18339
  Column.displayName = "Column";
18223
18340
 
18224
18341
  // src/components/layout/root/Root.tsx
18225
- var import_react21 = require("react");
18342
+ var import_react22 = require("react");
18226
18343
 
18227
18344
  // src/components/layout/root/styles.ts
18228
18345
  var import_styled_components18 = __toESM(require_styled_components_cjs());
@@ -18262,7 +18379,7 @@ var Container = import_styled_components18.styled.div`
18262
18379
 
18263
18380
  // src/components/layout/root/Root.tsx
18264
18381
  var import_jsx_runtime14 = require("react/jsx-runtime");
18265
- var Root = (0, import_react21.forwardRef)(
18382
+ var Root = (0, import_react22.forwardRef)(
18266
18383
  ({ data, settings, ...props }, ref) => {
18267
18384
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Container, { ref, ...props });
18268
18385
  }
@@ -18271,7 +18388,7 @@ Root.displayName = "Root";
18271
18388
 
18272
18389
  // src/components/layout/viewport/Viewport.tsx
18273
18390
  var import_debounce5 = __toESM(require_debounce());
18274
- var import_react39 = require("react");
18391
+ var import_react40 = require("react");
18275
18392
  var import_react_dom3 = require("react-dom");
18276
18393
 
18277
18394
  // src/components/shared/auto-topup-notice/AutoTopupNotice.tsx
@@ -18477,7 +18594,7 @@ var ButtonGroup = ({
18477
18594
  };
18478
18595
 
18479
18596
  // src/components/shared/checkout-dialog/Plan/Entitlement.tsx
18480
- var import_react22 = require("react");
18597
+ var import_react23 = require("react");
18481
18598
  var import_jsx_runtime19 = require("react/jsx-runtime");
18482
18599
  var Entitlement = ({
18483
18600
  portal,
@@ -18507,7 +18624,7 @@ var Entitlement = ({
18507
18624
  tiersMode
18508
18625
  } = entitlementBillingPrice || {};
18509
18626
  const tiered = entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance && isTieredPrice(entitlementBillingPrice);
18510
- const text = (0, import_react22.useMemo)(() => {
18627
+ const text = (0, import_react23.useMemo)(() => {
18511
18628
  if (!entitlement.feature) {
18512
18629
  return;
18513
18630
  }
@@ -18615,7 +18732,7 @@ var Entitlement = ({
18615
18732
  selectedCurrency,
18616
18733
  showWarningThresholdAsLimit
18617
18734
  ]);
18618
- const usageText = (0, import_react22.useMemo)(() => {
18735
+ const usageText = (0, import_react23.useMemo)(() => {
18619
18736
  if (!entitlement.feature) {
18620
18737
  return;
18621
18738
  }
@@ -18698,7 +18815,7 @@ var Entitlement = ({
18698
18815
  };
18699
18816
 
18700
18817
  // src/components/shared/checkout-dialog/Plan/Plan.tsx
18701
- var import_react23 = require("react");
18818
+ var import_react24 = require("react");
18702
18819
  var import_jsx_runtime20 = require("react/jsx-runtime");
18703
18820
  var Plan = ({
18704
18821
  portal,
@@ -18714,7 +18831,7 @@ var Plan = ({
18714
18831
  const { data, settings } = useEmbed();
18715
18832
  const isLightBackground = useIsLightBackground();
18716
18833
  const trialEnd = useTrialEnd();
18717
- const [entitlementVisibility, setEntitlementVisibility] = (0, import_react23.useState)({});
18834
+ const [entitlementVisibility, setEntitlementVisibility] = (0, import_react24.useState)({});
18718
18835
  const handleToggleShowAll = (id) => {
18719
18836
  setEntitlementVisibility((prev) => {
18720
18837
  const updated = !(prev[id] ?? false);
@@ -18961,7 +19078,7 @@ var Plan = ({
18961
19078
  };
18962
19079
 
18963
19080
  // src/components/shared/checkout-dialog/AutoTopup.tsx
18964
- var import_react24 = require("react");
19081
+ var import_react25 = require("react");
18965
19082
  var import_jsx_runtime21 = require("react/jsx-runtime");
18966
19083
  var AutoTopup = ({
18967
19084
  planCreditGrants,
@@ -18971,7 +19088,7 @@ var AutoTopup = ({
18971
19088
  const { settings } = useEmbed();
18972
19089
  const { t: t2, locale } = useTranslation();
18973
19090
  const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
18974
- const configurableCreditGrants = (0, import_react24.useMemo)(() => {
19091
+ const configurableCreditGrants = (0, import_react25.useMemo)(() => {
18975
19092
  return planCreditGrants.reduce(
18976
19093
  (acc, grant) => {
18977
19094
  if (isSelfServiceAutoTopupAvailable(grant)) {
@@ -19097,7 +19214,7 @@ var AutoTopup = ({
19097
19214
  };
19098
19215
 
19099
19216
  // src/components/shared/checkout-dialog/Quantity.tsx
19100
- var import_react25 = require("react");
19217
+ var import_react26 = require("react");
19101
19218
  var import_jsx_runtime22 = require("react/jsx-runtime");
19102
19219
  var Quantity = ({
19103
19220
  portal,
@@ -19112,12 +19229,12 @@ var Quantity = ({
19112
19229
  const isLightBackground = useIsLightBackground();
19113
19230
  const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
19114
19231
  const unitPriceFontSize = 0.875 * settings.theme.typography.text.fontSize;
19115
- const planCredits = (0, import_react25.useMemo)(
19232
+ const planCredits = (0, import_react26.useMemo)(
19116
19233
  () => groupPlanCreditGrants(selectedPlan?.includedCreditGrants ?? []),
19117
19234
  [selectedPlan?.includedCreditGrants]
19118
19235
  );
19119
19236
  const prorationBehavior = data?.checkoutSettings?.prorationBehavior;
19120
- const renewalDate = data?.upcomingInvoice?.dueDate ?? void 0;
19237
+ const { billDate: renewalDate } = useNextBillDate();
19121
19238
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Flex, { $flexDirection: "column", $gap: "1rem", children: entitlements.reduce((acc, entitlement) => {
19122
19239
  if (entitlement.feature) {
19123
19240
  const entitlementBillingPrice = getEntitlementPrice(
@@ -19797,7 +19914,7 @@ var Credits = ({
19797
19914
  };
19798
19915
 
19799
19916
  // src/components/shared/checkout-dialog/Checkout.tsx
19800
- var import_react27 = require("react");
19917
+ var import_react28 = require("react");
19801
19918
 
19802
19919
  // src/components/shared/payment-form/styles.ts
19803
19920
  var import_styled_components19 = __toESM(require_styled_components_cjs());
@@ -19891,7 +20008,7 @@ var CustomCheckoutFields = ({
19891
20008
  };
19892
20009
 
19893
20010
  // src/components/shared/checkout-dialog/TaxIdField.tsx
19894
- var import_react26 = require("react");
20011
+ var import_react27 = require("react");
19895
20012
  var import_styled_components20 = __toESM(require_styled_components_cjs());
19896
20013
  var import_jsx_runtime26 = require("react/jsx-runtime");
19897
20014
  var Select = (0, import_styled_components20.styled)(Input2).attrs({ as: "select" })`
@@ -19907,7 +20024,7 @@ var TaxIdField = ({
19907
20024
  }) => {
19908
20025
  const { t: t2, locale } = useTranslation();
19909
20026
  const isLightBackground = useIsLightBackground();
19910
- const countryOptions = (0, import_react26.useMemo)(() => taxIdCountryOptions(locale), [locale]);
20027
+ const countryOptions = (0, import_react27.useMemo)(() => taxIdCountryOptions(locale), [locale]);
19911
20028
  const jurisdictions = taxIdJurisdictionsForCountry(value.country);
19912
20029
  const handleCountryChange = (country) => {
19913
20030
  const next = taxIdJurisdictionsForCountry(country);
@@ -20008,7 +20125,7 @@ var Checkout = ({
20008
20125
  }) => {
20009
20126
  const { t: t2 } = useTranslation();
20010
20127
  const isLightBackground = useIsLightBackground();
20011
- const [discount, setDiscount] = (0, import_react27.useState)(promoCode ?? "");
20128
+ const [discount, setDiscount] = (0, import_react28.useState)(promoCode ?? "");
20012
20129
  const hasCustomFields = !!customCheckoutFields && customCheckoutFields.length > 0;
20013
20130
  const showTaxId = collectTaxId && !!taxIdValues && !!onTaxIdChange;
20014
20131
  if (!isPaymentMethodRequired && !hasCustomFields && !showTaxId && !optInRequired) {
@@ -20132,7 +20249,7 @@ var Checkout = ({
20132
20249
 
20133
20250
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
20134
20251
  var import_debounce4 = __toESM(require_debounce());
20135
- var import_react28 = require("react");
20252
+ var import_react29 = require("react");
20136
20253
 
20137
20254
  // src/components/shared/checkout-dialog/Navigation.tsx
20138
20255
  var import_jsx_runtime28 = require("react/jsx-runtime");
@@ -20270,30 +20387,30 @@ var CheckoutDialog = ({ top }) => {
20270
20387
  getTaxId
20271
20388
  } = useEmbed();
20272
20389
  const isLightBackground = useIsLightBackground();
20273
- const dialogRef = (0, import_react28.useRef)(null);
20274
- const contentRef = (0, import_react28.useRef)(null);
20275
- const stageRef = (0, import_react28.useRef)(null);
20276
- const sidebarRef = (0, import_react28.useRef)(null);
20277
- const [dialogElement, setDialogElement] = (0, import_react28.useState)(
20390
+ const dialogRef = (0, import_react29.useRef)(null);
20391
+ const contentRef = (0, import_react29.useRef)(null);
20392
+ const stageRef = (0, import_react29.useRef)(null);
20393
+ const sidebarRef = (0, import_react29.useRef)(null);
20394
+ const [dialogElement, setDialogElement] = (0, import_react29.useState)(
20278
20395
  null
20279
20396
  );
20280
- const setDialog = (0, import_react28.useCallback)((element) => {
20397
+ const setDialog = (0, import_react29.useCallback)((element) => {
20281
20398
  dialogRef.current = element;
20282
20399
  setDialogElement(element);
20283
20400
  }, []);
20284
- const [confirmPaymentIntentProps, setConfirmPaymentIntentProps] = (0, import_react28.useState)(void 0);
20285
- const [charges, setCharges] = (0, import_react28.useState)();
20286
- const [paymentMethodId, setPaymentMethodId] = (0, import_react28.useState)(
20401
+ const [confirmPaymentIntentProps, setConfirmPaymentIntentProps] = (0, import_react29.useState)(void 0);
20402
+ const [charges, setCharges] = (0, import_react29.useState)();
20403
+ const [paymentMethodId, setPaymentMethodId] = (0, import_react29.useState)(
20287
20404
  () => {
20288
20405
  return data?.subscription?.paymentMethod?.externalId || data?.company?.defaultPaymentMethod?.externalId;
20289
20406
  }
20290
20407
  );
20291
- const [isLoading, setIsLoading] = (0, import_react28.useState)(false);
20292
- const [error, setError] = (0, import_react28.useState)();
20293
- const [isModal, setIsModal] = (0, import_react28.useState)(true);
20408
+ const [isLoading, setIsLoading] = (0, import_react29.useState)(false);
20409
+ const [error, setError] = (0, import_react29.useState)();
20410
+ const [isModal, setIsModal] = (0, import_react29.useState)(true);
20294
20411
  const showPeriodToggle = data?.displaySettings?.showPeriodToggle ?? true;
20295
20412
  const trialPaymentMethodRequired = data?.trialPaymentMethodRequired === true;
20296
- const featureUsage = (0, import_react28.useMemo)(
20413
+ const featureUsage = (0, import_react29.useMemo)(
20297
20414
  () => data?.featureUsage?.features ?? [],
20298
20415
  [data?.featureUsage?.features]
20299
20416
  );
@@ -20314,13 +20431,13 @@ var CheckoutDialog = ({ top }) => {
20314
20431
  }
20315
20432
  return requestedPeriod;
20316
20433
  };
20317
- const [planPeriod, setPlanPeriod] = (0, import_react28.useState)(getValidatedPeriod);
20434
+ const [planPeriod, setPlanPeriod] = (0, import_react29.useState)(getValidatedPeriod);
20318
20435
  const { currencies, invalidFilterEntries } = useAvailableCurrenciesWithInvalid();
20319
20436
  const lockedCurrency = useSubscriptionCurrency();
20320
20437
  const hasCurrencyFilter = !!currencyFilter && currencyFilter.length > 0;
20321
20438
  const filterBlocksSubscriptionCurrency = hasCurrencyFilter && !!lockedCurrency && !currencyFilter.includes(lockedCurrency);
20322
20439
  const prefilledCurrency = checkoutState?.selectedCurrency?.toUpperCase();
20323
- const [selectedCurrency, setSelectedCurrency] = (0, import_react28.useState)(
20440
+ const [selectedCurrency, setSelectedCurrency] = (0, import_react29.useState)(
20324
20441
  () => prefilledCurrency ?? currencies[0] ?? DEFAULT_CURRENCY
20325
20442
  );
20326
20443
  if (currencies.length > 0 && !currencies.includes(selectedCurrency)) {
@@ -20331,7 +20448,7 @@ var CheckoutDialog = ({ top }) => {
20331
20448
  const canSelectCurrency = currencies.length > 1 && !lockedCurrency && currencySelectorEnabled;
20332
20449
  const hasCurrency = !!lockedCurrency || currencies.length > 1 || hasCurrencyFilter;
20333
20450
  const hasNoUsableCurrency = !lockedCurrency && currencies.length === 0;
20334
- (0, import_react28.useEffect)(() => {
20451
+ (0, import_react29.useEffect)(() => {
20335
20452
  if (filterBlocksSubscriptionCurrency) {
20336
20453
  console.error(
20337
20454
  `[Schematic] currencyFilter excludes the active subscription currency (${lockedCurrency}); keeping subscription currency.`
@@ -20348,8 +20465,8 @@ var CheckoutDialog = ({ top }) => {
20348
20465
  } = useAvailablePlans(planPeriod, {
20349
20466
  useSelectedPeriod: showPeriodToggle
20350
20467
  });
20351
- const [selectedPlanId, setSelectedPlanId] = (0, import_react28.useState)(void 0);
20352
- const selectedPlan = (0, import_react28.useMemo)(() => {
20468
+ const [selectedPlanId, setSelectedPlanId] = (0, import_react29.useState)(void 0);
20469
+ const selectedPlan = (0, import_react29.useMemo)(() => {
20353
20470
  if (selectedPlanId === null) {
20354
20471
  return void 0;
20355
20472
  }
@@ -20364,8 +20481,8 @@ var CheckoutDialog = ({ top }) => {
20364
20481
  (!plan.isTrialable || !plan.companyCanTrial)
20365
20482
  );
20366
20483
  }, [availablePlans, checkoutState, selectedPlanId]);
20367
- const [shouldTrial, setShouldTrial] = (0, import_react28.useState)(false);
20368
- const planCreditGrants = (0, import_react28.useMemo)(() => {
20484
+ const [shouldTrial, setShouldTrial] = (0, import_react29.useState)(false);
20485
+ const planCreditGrants = (0, import_react29.useMemo)(() => {
20369
20486
  const grants = mergeCompanyGrants(
20370
20487
  selectedPlan?.includedCreditGrants,
20371
20488
  data?.company?.plan?.includedCreditGrants
@@ -20375,7 +20492,7 @@ var CheckoutDialog = ({ top }) => {
20375
20492
  selectedPlan?.includedCreditGrants,
20376
20493
  data?.company?.plan?.includedCreditGrants
20377
20494
  ]);
20378
- const [autoTopupConfigs, setAutoTopupConfigs] = (0, import_react28.useState)(() => {
20495
+ const [autoTopupConfigs, setAutoTopupConfigs] = (0, import_react29.useState)(() => {
20379
20496
  const initialConfigs = data?.company?.plan?.includedCreditGrants.reduce(
20380
20497
  (acc, companyGrant) => {
20381
20498
  const {
@@ -20395,7 +20512,7 @@ var CheckoutDialog = ({ top }) => {
20395
20512
  );
20396
20513
  return new Map(initialConfigs);
20397
20514
  });
20398
- const [selectedAddOnIds, setSelectedAddOnIds] = (0, import_react28.useState)(() => {
20515
+ const [selectedAddOnIds, setSelectedAddOnIds] = (0, import_react29.useState)(() => {
20399
20516
  const ids = /* @__PURE__ */ new Set();
20400
20517
  if (checkoutState?.addOnIds) {
20401
20518
  for (const id of checkoutState.addOnIds) ids.add(id);
@@ -20411,11 +20528,11 @@ var CheckoutDialog = ({ top }) => {
20411
20528
  }
20412
20529
  return ids;
20413
20530
  });
20414
- const addOnCompatibilityLookup = (0, import_react28.useMemo)(
20531
+ const addOnCompatibilityLookup = (0, import_react29.useMemo)(
20415
20532
  () => buildAddOnCompatibilityLookup(data?.addOnCompatibilities),
20416
20533
  [data?.addOnCompatibilities]
20417
20534
  );
20418
- const addOns = (0, import_react28.useMemo)(() => {
20535
+ const addOns = (0, import_react29.useMemo)(() => {
20419
20536
  return availableAddOns.filter((availAddOn) => {
20420
20537
  if (hasCurrency && !planSupportsCurrency(availAddOn, effectiveCurrency)) {
20421
20538
  return false;
@@ -20441,20 +20558,20 @@ var CheckoutDialog = ({ top }) => {
20441
20558
  selectedAddOnIds
20442
20559
  ]);
20443
20560
  const isIndividualBundlePurchase = data?.checkoutSettings.bundlePurchaseBehavior === CheckoutBundlePurchaseBehavior.Individual;
20444
- const [bundleCounts, setBundleCounts] = (0, import_react28.useState)({});
20445
- const bundleCountsRef = (0, import_react28.useRef)(bundleCounts);
20561
+ const [bundleCounts, setBundleCounts] = (0, import_react29.useState)({});
20562
+ const bundleCountsRef = (0, import_react29.useRef)(bundleCounts);
20446
20563
  const bundleGatingPlanId = selectedPlan?.id ?? data?.company?.plan?.id;
20447
- const creditBundles = (0, import_react28.useMemo)(() => {
20564
+ const creditBundles = (0, import_react29.useMemo)(() => {
20448
20565
  return deriveCreditBundles(
20449
20566
  data?.creditBundles,
20450
20567
  bundleGatingPlanId,
20451
20568
  bundleCounts
20452
20569
  );
20453
20570
  }, [bundleGatingPlanId, data?.creditBundles, bundleCounts]);
20454
- const [hasInitialPaymentMethod] = (0, import_react28.useState)(
20571
+ const [hasInitialPaymentMethod] = (0, import_react29.useState)(
20455
20572
  () => !!(data?.subscription?.paymentMethod?.externalId || data?.company?.defaultPaymentMethod?.externalId)
20456
20573
  );
20457
- const isCreditOnlyPurchase = (0, import_react28.useMemo)(
20574
+ const isCreditOnlyPurchase = (0, import_react29.useMemo)(
20458
20575
  () => isCreditOnlyCheckout({
20459
20576
  plan: selectedPlan,
20460
20577
  creditBundles,
@@ -20471,7 +20588,7 @@ var CheckoutDialog = ({ top }) => {
20471
20588
  effectiveCurrency
20472
20589
  ]
20473
20590
  );
20474
- const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react28.useState)(
20591
+ const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react29.useState)(
20475
20592
  () => applyPrefilledQuantities(
20476
20593
  (selectedPlan?.entitlements || []).reduce(
20477
20594
  createActiveUsageBasedEntitlementsReducer(featureUsage, planPeriod),
@@ -20480,7 +20597,7 @@ var CheckoutDialog = ({ top }) => {
20480
20597
  checkoutState?.payInAdvanceQuantities
20481
20598
  )
20482
20599
  );
20483
- const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] = (0, import_react28.useState)(() => {
20600
+ const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] = (0, import_react29.useState)(() => {
20484
20601
  const currentAddOnEntitlements = (data?.company?.addOns || []).flatMap(
20485
20602
  (currentAddOn) => {
20486
20603
  const availableAddOn = availableAddOns.find(
@@ -20521,45 +20638,45 @@ var CheckoutDialog = ({ top }) => {
20521
20638
  checkoutState?.payInAdvanceQuantities
20522
20639
  );
20523
20640
  });
20524
- const payInAdvanceEntitlements = (0, import_react28.useMemo)(
20641
+ const payInAdvanceEntitlements = (0, import_react29.useMemo)(
20525
20642
  () => usageBasedEntitlements.filter(
20526
20643
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
20527
20644
  ),
20528
20645
  [usageBasedEntitlements]
20529
20646
  );
20530
- const addOnPayInAdvanceEntitlements = (0, import_react28.useMemo)(
20647
+ const addOnPayInAdvanceEntitlements = (0, import_react29.useMemo)(
20531
20648
  () => addOnUsageBasedEntitlements.filter(
20532
20649
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
20533
20650
  ),
20534
20651
  [addOnUsageBasedEntitlements]
20535
20652
  );
20536
- const [promoCode, setPromoCode] = (0, import_react28.useState)(
20653
+ const [promoCode, setPromoCode] = (0, import_react29.useState)(
20537
20654
  () => checkoutState?.promoCode ?? null
20538
20655
  );
20539
- const [customFieldValues, setCustomFieldValues] = (0, import_react28.useState)(() => {
20656
+ const [customFieldValues, setCustomFieldValues] = (0, import_react29.useState)(() => {
20540
20657
  const values = {};
20541
20658
  for (const field of data?.customCheckoutFields ?? []) {
20542
20659
  values[field.id] = field.value ?? "";
20543
20660
  }
20544
20661
  return values;
20545
20662
  });
20546
- const hasIncompleteRequiredCustomFields = (0, import_react28.useMemo)(() => {
20663
+ const hasIncompleteRequiredCustomFields = (0, import_react29.useMemo)(() => {
20547
20664
  return (data?.customCheckoutFields ?? []).some(
20548
20665
  (field) => field.required && !customFieldValues[field.id]?.trim()
20549
20666
  );
20550
20667
  }, [data?.customCheckoutFields, customFieldValues]);
20551
- const handleCustomFieldChange = (0, import_react28.useCallback)(
20668
+ const handleCustomFieldChange = (0, import_react29.useCallback)(
20552
20669
  (fieldId, value) => {
20553
20670
  setCustomFieldValues((prev) => ({ ...prev, [fieldId]: value }));
20554
20671
  },
20555
20672
  []
20556
20673
  );
20557
20674
  const collectTaxId = data?.checkoutSettings.collectTaxId ?? false;
20558
- const [taxIdValues, setTaxIdValues] = (0, import_react28.useState)(emptyTaxIdValues);
20559
- const [taxIdError, setTaxIdError] = (0, import_react28.useState)();
20560
- const lastSavedTaxIdRef = (0, import_react28.useRef)(void 0);
20561
- const pendingTaxIdSaveRef = (0, import_react28.useRef)(null);
20562
- (0, import_react28.useEffect)(() => {
20675
+ const [taxIdValues, setTaxIdValues] = (0, import_react29.useState)(emptyTaxIdValues);
20676
+ const [taxIdError, setTaxIdError] = (0, import_react29.useState)();
20677
+ const lastSavedTaxIdRef = (0, import_react29.useRef)(void 0);
20678
+ const pendingTaxIdSaveRef = (0, import_react29.useRef)(null);
20679
+ (0, import_react29.useEffect)(() => {
20563
20680
  if (!collectTaxId) {
20564
20681
  return;
20565
20682
  }
@@ -20586,19 +20703,19 @@ var CheckoutDialog = ({ top }) => {
20586
20703
  cancelled = true;
20587
20704
  };
20588
20705
  }, [collectTaxId, getTaxId]);
20589
- const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0, import_react28.useState)(false);
20590
- const [optInRequired, setOptInRequired] = (0, import_react28.useState)(false);
20591
- const [optInTitle, setOptInTitle] = (0, import_react28.useState)(null);
20592
- const [optInText, setOptInText] = (0, import_react28.useState)(null);
20593
- const [optInAccepted, setOptInAccepted] = (0, import_react28.useState)(false);
20594
- const presentedOptInRef = (0, import_react28.useRef)(null);
20595
- const [willScheduleDowngrade, setWillScheduleDowngrade] = (0, import_react28.useState)(false);
20596
- const willTrialWithoutPaymentMethod = (0, import_react28.useMemo)(
20706
+ const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0, import_react29.useState)(false);
20707
+ const [optInRequired, setOptInRequired] = (0, import_react29.useState)(false);
20708
+ const [optInTitle, setOptInTitle] = (0, import_react29.useState)(null);
20709
+ const [optInText, setOptInText] = (0, import_react29.useState)(null);
20710
+ const [optInAccepted, setOptInAccepted] = (0, import_react29.useState)(false);
20711
+ const presentedOptInRef = (0, import_react29.useRef)(null);
20712
+ const [willScheduleDowngrade, setWillScheduleDowngrade] = (0, import_react29.useState)(false);
20713
+ const willTrialWithoutPaymentMethod = (0, import_react29.useMemo)(
20597
20714
  () => shouldTrial && !trialPaymentMethodRequired,
20598
20715
  [shouldTrial, trialPaymentMethodRequired]
20599
20716
  );
20600
20717
  const isSelectedPlanTrialable = selectedPlan && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
20601
- const checkoutStages = (0, import_react28.useMemo)(() => {
20718
+ const checkoutStages = (0, import_react29.useMemo)(() => {
20602
20719
  const stages = [];
20603
20720
  const checkoutStage2 = {
20604
20721
  id: "checkout",
@@ -20686,10 +20803,10 @@ var CheckoutDialog = ({ top }) => {
20686
20803
  isCreditOnlyPurchase,
20687
20804
  hasInitialPaymentMethod
20688
20805
  ]);
20689
- const [isBypassLoading, setIsBypassLoading] = (0, import_react28.useState)(
20806
+ const [isBypassLoading, setIsBypassLoading] = (0, import_react29.useState)(
20690
20807
  () => checkoutState?.bypassPlanSelection || checkoutState?.bypassAddOnSelection || checkoutState?.bypassCreditsSelection || checkoutState?.bypassUsageSelection || checkoutState?.bypassAddOnUsageSelection
20691
20808
  );
20692
- const [checkoutStage, setCheckoutStage] = (0, import_react28.useState)(() => {
20809
+ const [checkoutStage, setCheckoutStage] = (0, import_react29.useState)(() => {
20693
20810
  if (checkoutState?.addOnId) {
20694
20811
  return "addons";
20695
20812
  }
@@ -20704,7 +20821,7 @@ var CheckoutDialog = ({ top }) => {
20704
20821
  }
20705
20822
  return "plan";
20706
20823
  });
20707
- const effectiveCheckoutStage = (0, import_react28.useMemo)(() => {
20824
+ const effectiveCheckoutStage = (0, import_react29.useMemo)(() => {
20708
20825
  if (isBypassLoading) return checkoutStage;
20709
20826
  let id = checkoutStage;
20710
20827
  if (id === "credits" && !checkoutStages.some((stage) => stage.id === id)) {
@@ -20718,9 +20835,9 @@ var CheckoutDialog = ({ top }) => {
20718
20835
  }
20719
20836
  return id;
20720
20837
  }, [checkoutStage, checkoutStages, checkoutState, isBypassLoading]);
20721
- const previewRequestIdRef = (0, import_react28.useRef)(0);
20838
+ const previewRequestIdRef = (0, import_react29.useRef)(0);
20722
20839
  const planStageVisible = checkoutStages.some((stage) => stage.id === "plan") && !checkoutState?.bypassPlanSelection;
20723
- const checkoutStageCurrencies = (0, import_react28.useMemo)(() => {
20840
+ const checkoutStageCurrencies = (0, import_react29.useMemo)(() => {
20724
20841
  if (!selectedPlan) return currencies;
20725
20842
  return currencies.filter(
20726
20843
  (currency) => planOffersCurrencyForPeriod(selectedPlan, planPeriod, currency)
@@ -20729,7 +20846,7 @@ var CheckoutDialog = ({ top }) => {
20729
20846
  const showPlanCurrencySelector = canSelectCurrency && planStageVisible;
20730
20847
  const showCheckoutCurrencySelector = canSelectCurrency && !planStageVisible && checkoutStageCurrencies.length > 1;
20731
20848
  const currencyPeriodMismatch = hasCurrency && !lockedCurrency && !planStageVisible && !!selectedPlan && !planOffersCurrencyForPeriod(selectedPlan, planPeriod, effectiveCurrency);
20732
- (0, import_react28.useEffect)(() => {
20849
+ (0, import_react29.useEffect)(() => {
20733
20850
  if (currencyPeriodMismatch) {
20734
20851
  console.error(
20735
20852
  `[Schematic] No ${effectiveCurrency} price for the "${planPeriod}" billing period on the selected plan; refusing to fall back to the default currency.`
@@ -20747,7 +20864,7 @@ var CheckoutDialog = ({ top }) => {
20747
20864
  selectedPlan?.id,
20748
20865
  debug
20749
20866
  ]);
20750
- const handlePreviewCheckout = (0, import_react28.useCallback)(
20867
+ const handlePreviewCheckout = (0, import_react29.useCallback)(
20751
20868
  async (updates) => {
20752
20869
  const period = updates.period || planPeriod;
20753
20870
  const plan = updates.plan || selectedPlan;
@@ -20927,12 +21044,12 @@ var CheckoutDialog = ({ top }) => {
20927
21044
  isBypassLoading
20928
21045
  ]
20929
21046
  );
20930
- const handlePreviewCheckoutRef = (0, import_react28.useRef)(handlePreviewCheckout);
20931
- (0, import_react28.useEffect)(() => {
21047
+ const handlePreviewCheckoutRef = (0, import_react29.useRef)(handlePreviewCheckout);
21048
+ (0, import_react29.useEffect)(() => {
20932
21049
  handlePreviewCheckoutRef.current = handlePreviewCheckout;
20933
21050
  }, [handlePreviewCheckout]);
20934
- const debouncedPreviewCheckoutRef = (0, import_react28.useRef)(null);
20935
- (0, import_react28.useEffect)(() => {
21051
+ const debouncedPreviewCheckoutRef = (0, import_react29.useRef)(null);
21052
+ (0, import_react29.useEffect)(() => {
20936
21053
  const debounced = (0, import_debounce4.default)(
20937
21054
  (updates) => handlePreviewCheckoutRef.current(updates),
20938
21055
  FETCH_DEBOUNCE_TIMEOUT,
@@ -20944,7 +21061,7 @@ var CheckoutDialog = ({ top }) => {
20944
21061
  debouncedPreviewCheckoutRef.current = null;
20945
21062
  };
20946
21063
  }, []);
20947
- const saveTaxId = (0, import_react28.useCallback)(
21064
+ const saveTaxId = (0, import_react29.useCallback)(
20948
21065
  async ({ refreshPreview = false } = {}) => {
20949
21066
  const input = toTaxIdInput(taxIdValues);
20950
21067
  if (!input) {
@@ -20978,13 +21095,13 @@ var CheckoutDialog = ({ top }) => {
20978
21095
  },
20979
21096
  [t2, taxIdValues, updateTaxId]
20980
21097
  );
20981
- const debouncedPreviewCheckout = (0, import_react28.useCallback)(
21098
+ const debouncedPreviewCheckout = (0, import_react29.useCallback)(
20982
21099
  (updates) => {
20983
21100
  debouncedPreviewCheckoutRef.current?.(updates);
20984
21101
  },
20985
21102
  []
20986
21103
  );
20987
- const selectPlan = (0, import_react28.useCallback)(
21104
+ const selectPlan = (0, import_react29.useCallback)(
20988
21105
  (updates) => {
20989
21106
  const plan = updates.plan;
20990
21107
  const period = showPeriodToggle ? updates.period || planPeriod : plan.monthlyPrice ? BillingProductPriceInterval.Month : plan.quarterlyPrice ? "quarter" : plan.yearlyPrice ? BillingProductPriceInterval.Year : BillingProductPriceInterval.Month;
@@ -21056,7 +21173,7 @@ var CheckoutDialog = ({ top }) => {
21056
21173
  checkoutState?.payInAdvanceQuantities
21057
21174
  ]
21058
21175
  );
21059
- const changePlanPeriod = (0, import_react28.useCallback)(
21176
+ const changePlanPeriod = (0, import_react29.useCallback)(
21060
21177
  (period) => {
21061
21178
  if (period === planPeriod) {
21062
21179
  return;
@@ -21113,7 +21230,7 @@ var CheckoutDialog = ({ top }) => {
21113
21230
  handlePreviewCheckout
21114
21231
  ]
21115
21232
  );
21116
- const toggleAddOn = (0, import_react28.useCallback)(
21233
+ const toggleAddOn = (0, import_react29.useCallback)(
21117
21234
  (id) => {
21118
21235
  const updated = addOns.map((addOn) => ({
21119
21236
  ...addOn,
@@ -21146,7 +21263,7 @@ var CheckoutDialog = ({ top }) => {
21146
21263
  },
21147
21264
  [handlePreviewCheckout, addOnUsageBasedEntitlements, addOns]
21148
21265
  );
21149
- const updateAutoTopupConfig = (0, import_react28.useCallback)(
21266
+ const updateAutoTopupConfig = (0, import_react29.useCallback)(
21150
21267
  (id, updates) => {
21151
21268
  setAutoTopupConfigs((prev) => {
21152
21269
  const nextMap = new Map(prev);
@@ -21166,7 +21283,7 @@ var CheckoutDialog = ({ top }) => {
21166
21283
  },
21167
21284
  [debouncedPreviewCheckout, planCreditGrants]
21168
21285
  );
21169
- const updateUsageBasedEntitlementQuantity = (0, import_react28.useCallback)(
21286
+ const updateUsageBasedEntitlementQuantity = (0, import_react29.useCallback)(
21170
21287
  (id, updatedQuantity) => {
21171
21288
  setUsageBasedEntitlements((prev) => {
21172
21289
  const updated = prev.map(
@@ -21185,7 +21302,7 @@ var CheckoutDialog = ({ top }) => {
21185
21302
  },
21186
21303
  [debouncedPreviewCheckout]
21187
21304
  );
21188
- const updateCreditBundleCount = (0, import_react28.useCallback)(
21305
+ const updateCreditBundleCount = (0, import_react29.useCallback)(
21189
21306
  (id, updatedCount) => {
21190
21307
  const nextCounts = { ...bundleCountsRef.current, [id]: updatedCount };
21191
21308
  bundleCountsRef.current = nextCounts;
@@ -21200,7 +21317,7 @@ var CheckoutDialog = ({ top }) => {
21200
21317
  },
21201
21318
  [bundleGatingPlanId, data?.creditBundles, debouncedPreviewCheckout]
21202
21319
  );
21203
- const toggleCreditBundle = (0, import_react28.useCallback)(
21320
+ const toggleCreditBundle = (0, import_react29.useCallback)(
21204
21321
  (id) => {
21205
21322
  const nextCounts = { ...bundleCountsRef.current };
21206
21323
  if (nextCounts[id]) {
@@ -21220,7 +21337,7 @@ var CheckoutDialog = ({ top }) => {
21220
21337
  },
21221
21338
  [bundleGatingPlanId, data?.creditBundles, handlePreviewCheckout]
21222
21339
  );
21223
- const updateAddOnEntitlementQuantity = (0, import_react28.useCallback)(
21340
+ const updateAddOnEntitlementQuantity = (0, import_react29.useCallback)(
21224
21341
  (id, updatedQuantity) => {
21225
21342
  setAddOnUsageBasedEntitlements((prev) => {
21226
21343
  const updated = prev.map(
@@ -21240,25 +21357,25 @@ var CheckoutDialog = ({ top }) => {
21240
21357
  },
21241
21358
  [debouncedPreviewCheckout]
21242
21359
  );
21243
- const updatePromoCode = (0, import_react28.useCallback)(
21360
+ const updatePromoCode = (0, import_react29.useCallback)(
21244
21361
  async (code) => {
21245
21362
  handlePreviewCheckout({ promoCode: code });
21246
21363
  },
21247
21364
  [handlePreviewCheckout]
21248
21365
  );
21249
- const handleClose = (0, import_react28.useCallback)(() => {
21366
+ const handleClose = (0, import_react29.useCallback)(() => {
21250
21367
  clearCheckoutState();
21251
21368
  setLayout("portal");
21252
21369
  }, [setLayout, clearCheckoutState]);
21253
- const hasInitializedPlan = (0, import_react28.useRef)(false);
21254
- (0, import_react28.useEffect)(() => {
21370
+ const hasInitializedPlan = (0, import_react29.useRef)(false);
21371
+ (0, import_react29.useEffect)(() => {
21255
21372
  if (!hasInitializedPlan.current && selectedPlan) {
21256
21373
  hasInitializedPlan.current = true;
21257
21374
  const shouldTrial2 = checkoutState?.startTrialIfAvailable && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
21258
21375
  selectPlan({ plan: selectedPlan, period: planPeriod, shouldTrial: shouldTrial2 });
21259
21376
  }
21260
21377
  }, [selectedPlan, planPeriod, selectPlan]);
21261
- (0, import_react28.useLayoutEffect)(() => {
21378
+ (0, import_react29.useLayoutEffect)(() => {
21262
21379
  const element = dialogRef.current;
21263
21380
  if (layout !== "checkout" || !element) {
21264
21381
  return;
@@ -21274,14 +21391,14 @@ var CheckoutDialog = ({ top }) => {
21274
21391
  element.show();
21275
21392
  }
21276
21393
  }, [layout]);
21277
- (0, import_react28.useLayoutEffect)(() => {
21394
+ (0, import_react29.useLayoutEffect)(() => {
21278
21395
  stageRef.current?.scrollTo({
21279
21396
  top: 0,
21280
21397
  left: 0,
21281
21398
  behavior: "smooth"
21282
21399
  });
21283
21400
  }, [effectiveCheckoutStage]);
21284
- (0, import_react28.useLayoutEffect)(() => {
21401
+ (0, import_react29.useLayoutEffect)(() => {
21285
21402
  if (charges) {
21286
21403
  sidebarRef.current?.scrollTo({
21287
21404
  top: 0,
@@ -21293,7 +21410,7 @@ var CheckoutDialog = ({ top }) => {
21293
21410
  const activeCheckoutStage = checkoutStages.find(
21294
21411
  (stage) => stage.id === effectiveCheckoutStage
21295
21412
  );
21296
- const visibleStages = (0, import_react28.useMemo)(() => {
21413
+ const visibleStages = (0, import_react29.useMemo)(() => {
21297
21414
  if (!checkoutState?.hideSkippedStages) {
21298
21415
  return checkoutStages;
21299
21416
  }
@@ -21316,7 +21433,7 @@ var CheckoutDialog = ({ top }) => {
21316
21433
  return true;
21317
21434
  });
21318
21435
  }, [checkoutStages, checkoutState]);
21319
- const navigableStages = (0, import_react28.useMemo)(() => {
21436
+ const navigableStages = (0, import_react29.useMemo)(() => {
21320
21437
  return checkoutStages.filter((stage) => {
21321
21438
  if (stage.id === "plan" && checkoutState?.bypassPlanSelection) {
21322
21439
  return false;
@@ -21926,44 +22043,44 @@ var InvalidCurrencyNotice = ({
21926
22043
  };
21927
22044
 
21928
22045
  // src/components/shared/payment-dialog/PaymentDialog.tsx
21929
- var import_react30 = require("react");
22046
+ var import_react31 = require("react");
21930
22047
 
21931
22048
  // src/components/shared/checkout-dialog/EditableCustomCheckoutFields.tsx
21932
- var import_react29 = require("react");
22049
+ var import_react30 = require("react");
21933
22050
  var import_jsx_runtime35 = require("react/jsx-runtime");
21934
22051
  var EditableCustomCheckoutFields = () => {
21935
22052
  const { t: t2 } = useTranslation();
21936
22053
  const isLightBackground = useIsLightBackground();
21937
22054
  const { data, updateCustomFieldValues } = useEmbed();
21938
- const customCheckoutFields = (0, import_react29.useMemo)(
22055
+ const customCheckoutFields = (0, import_react30.useMemo)(
21939
22056
  () => data?.customCheckoutFields ?? [],
21940
22057
  [data?.customCheckoutFields]
21941
22058
  );
21942
- const serverFieldValues = (0, import_react29.useMemo)(() => {
22059
+ const serverFieldValues = (0, import_react30.useMemo)(() => {
21943
22060
  const values2 = {};
21944
22061
  for (const field of customCheckoutFields) {
21945
22062
  values2[field.id] = field.value ?? "";
21946
22063
  }
21947
22064
  return values2;
21948
22065
  }, [customCheckoutFields]);
21949
- const [editing, setEditing] = (0, import_react29.useState)(false);
21950
- const [values, setValues] = (0, import_react29.useState)(serverFieldValues);
21951
- const [isSaving, setIsSaving] = (0, import_react29.useState)(false);
21952
- const [error, setError] = (0, import_react29.useState)();
21953
- const handleChange = (0, import_react29.useCallback)((fieldId, value) => {
22066
+ const [editing, setEditing] = (0, import_react30.useState)(false);
22067
+ const [values, setValues] = (0, import_react30.useState)(serverFieldValues);
22068
+ const [isSaving, setIsSaving] = (0, import_react30.useState)(false);
22069
+ const [error, setError] = (0, import_react30.useState)();
22070
+ const handleChange = (0, import_react30.useCallback)((fieldId, value) => {
21954
22071
  setValues((prev) => ({ ...prev, [fieldId]: value }));
21955
22072
  }, []);
21956
- const handleEdit = (0, import_react29.useCallback)(() => {
22073
+ const handleEdit = (0, import_react30.useCallback)(() => {
21957
22074
  setError(void 0);
21958
22075
  setValues(serverFieldValues);
21959
22076
  setEditing(true);
21960
22077
  }, [serverFieldValues]);
21961
- const handleCancel = (0, import_react29.useCallback)(() => {
22078
+ const handleCancel = (0, import_react30.useCallback)(() => {
21962
22079
  setError(void 0);
21963
22080
  setEditing(false);
21964
22081
  setValues(serverFieldValues);
21965
22082
  }, [serverFieldValues]);
21966
- const handleSave = (0, import_react29.useCallback)(async () => {
22083
+ const handleSave = (0, import_react30.useCallback)(async () => {
21967
22084
  setError(void 0);
21968
22085
  setIsSaving(true);
21969
22086
  try {
@@ -22051,13 +22168,13 @@ var import_jsx_runtime36 = require("react/jsx-runtime");
22051
22168
  var PaymentDialog = ({ top }) => {
22052
22169
  const { t: t2 } = useTranslation();
22053
22170
  const { layout, setLayout, clearCheckoutState } = useEmbed();
22054
- const dialogRef = (0, import_react30.useRef)(null);
22055
- const [isModal, setIsModal] = (0, import_react30.useState)(true);
22056
- const handleClose = (0, import_react30.useCallback)(() => {
22171
+ const dialogRef = (0, import_react31.useRef)(null);
22172
+ const [isModal, setIsModal] = (0, import_react31.useState)(true);
22173
+ const handleClose = (0, import_react31.useCallback)(() => {
22057
22174
  clearCheckoutState();
22058
22175
  setLayout("portal");
22059
22176
  }, [setLayout, clearCheckoutState]);
22060
- (0, import_react30.useLayoutEffect)(() => {
22177
+ (0, import_react31.useLayoutEffect)(() => {
22061
22178
  const element = dialogRef.current;
22062
22179
  if (layout !== "payment" || !element) {
22063
22180
  return;
@@ -22104,7 +22221,7 @@ var PaymentDialog = ({ top }) => {
22104
22221
 
22105
22222
  // src/components/shared/payment-form/PaymentForm.tsx
22106
22223
  var import_react_stripe_js = require("@stripe/react-stripe-js");
22107
- var import_react31 = require("react");
22224
+ var import_react32 = require("react");
22108
22225
  var import_jsx_runtime37 = require("react/jsx-runtime");
22109
22226
  var PaymentForm = ({ onConfirm, financeData }) => {
22110
22227
  const { t: t2 } = useTranslation();
@@ -22119,32 +22236,32 @@ var PaymentForm = ({ onConfirm, financeData }) => {
22119
22236
  financeData
22120
22237
  );
22121
22238
  const showBillingAddress = shouldCollectAddress || collectPhone;
22122
- const loadTimerRef = (0, import_react31.useRef)(
22239
+ const loadTimerRef = (0, import_react32.useRef)(
22123
22240
  void 0
22124
22241
  );
22125
- const [email, setEmail] = (0, import_react31.useState)(() => billing?.email ?? "");
22126
- const userEditedEmailRef = (0, import_react31.useRef)(false);
22127
- const [message, setMessage] = (0, import_react31.useState)();
22128
- const [isLoading, setIsLoading] = (0, import_react31.useState)(false);
22129
- const [isConfirmed, setIsConfirmed] = (0, import_react31.useState)(false);
22130
- const [isPaymentComplete, setIsPaymentComplete] = (0, import_react31.useState)(false);
22131
- const [isPaymentReady, setIsPaymentReady] = (0, import_react31.useState)(false);
22132
- const [loadError, setLoadError] = (0, import_react31.useState)();
22133
- const [isEmailValid, setIsEmailValid] = (0, import_react31.useState)(() => !collectEmail);
22134
- const emailInputRef = (0, import_react31.useRef)(null);
22135
- const [isAddressComplete, setIsAddressComplete] = (0, import_react31.useState)(
22242
+ const [email, setEmail] = (0, import_react32.useState)(() => billing?.email ?? "");
22243
+ const userEditedEmailRef = (0, import_react32.useRef)(false);
22244
+ const [message, setMessage] = (0, import_react32.useState)();
22245
+ const [isLoading, setIsLoading] = (0, import_react32.useState)(false);
22246
+ const [isConfirmed, setIsConfirmed] = (0, import_react32.useState)(false);
22247
+ const [isPaymentComplete, setIsPaymentComplete] = (0, import_react32.useState)(false);
22248
+ const [isPaymentReady, setIsPaymentReady] = (0, import_react32.useState)(false);
22249
+ const [loadError, setLoadError] = (0, import_react32.useState)();
22250
+ const [isEmailValid, setIsEmailValid] = (0, import_react32.useState)(() => !collectEmail);
22251
+ const emailInputRef = (0, import_react32.useRef)(null);
22252
+ const [isAddressComplete, setIsAddressComplete] = (0, import_react32.useState)(
22136
22253
  () => !shouldCollectAddress
22137
22254
  );
22138
- const addressDefaultsKey = (0, import_react31.useMemo)(
22255
+ const addressDefaultsKey = (0, import_react32.useMemo)(
22139
22256
  () => JSON.stringify(billing ?? {}),
22140
22257
  [billing]
22141
22258
  );
22142
- (0, import_react31.useEffect)(() => {
22259
+ (0, import_react32.useEffect)(() => {
22143
22260
  if (!userEditedEmailRef.current && billing?.email) {
22144
22261
  setEmail(billing.email);
22145
22262
  }
22146
22263
  }, [billing?.email]);
22147
- (0, import_react31.useEffect)(() => {
22264
+ (0, import_react32.useEffect)(() => {
22148
22265
  setIsEmailValid(
22149
22266
  !collectEmail || (emailInputRef.current?.checkValidity() ?? false)
22150
22267
  );
@@ -22189,7 +22306,7 @@ var PaymentForm = ({ onConfirm, financeData }) => {
22189
22306
  setIsLoading(false);
22190
22307
  }
22191
22308
  };
22192
- (0, import_react31.useEffect)(() => {
22309
+ (0, import_react32.useEffect)(() => {
22193
22310
  loadTimerRef.current = setTimeout(() => {
22194
22311
  if (!isPaymentReady) {
22195
22312
  setLoadError(t2("Unable to load payment form."));
@@ -22300,7 +22417,7 @@ var PaymentForm = ({ onConfirm, financeData }) => {
22300
22417
  };
22301
22418
 
22302
22419
  // src/components/shared/period-toggle/PeriodToggle.tsx
22303
- var import_react32 = require("react");
22420
+ var import_react33 = require("react");
22304
22421
  var import_jsx_runtime38 = require("react/jsx-runtime");
22305
22422
  var PERIOD_MONTH_COUNT = {
22306
22423
  year: 12,
@@ -22316,7 +22433,7 @@ var PeriodToggle = ({
22316
22433
  const { t: t2 } = useTranslation();
22317
22434
  const { settings } = useEmbed();
22318
22435
  const isLightBackground = useIsLightBackground();
22319
- const savingsByPeriod = (0, import_react32.useMemo)(() => {
22436
+ const savingsByPeriod = (0, import_react33.useMemo)(() => {
22320
22437
  const result = {};
22321
22438
  if (!selectedPlan) {
22322
22439
  return result;
@@ -22473,10 +22590,10 @@ var PlanCreditText = ({
22473
22590
  };
22474
22591
 
22475
22592
  // src/components/shared/pricing-tiers-tooltip/PricingTiersTooltip.tsx
22476
- var import_react34 = require("react");
22593
+ var import_react35 = require("react");
22477
22594
 
22478
22595
  // src/components/shared/pricing-tiers-tooltip/PriceText.tsx
22479
- var import_react33 = require("react");
22596
+ var import_react34 = require("react");
22480
22597
  var import_jsx_runtime40 = require("react/jsx-runtime");
22481
22598
  var PriceText = ({
22482
22599
  feature,
@@ -22487,7 +22604,7 @@ var PriceText = ({
22487
22604
  }) => {
22488
22605
  const { settings } = useEmbed();
22489
22606
  const { t: t2, locale } = useTranslation();
22490
- const text = (0, import_react33.useMemo)(() => {
22607
+ const text = (0, import_react34.useMemo)(() => {
22491
22608
  if (!flatAmount && perUnitPrice) {
22492
22609
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
22493
22610
  formatCurrency(perUnitPrice, { locale, currency }),
@@ -22544,7 +22661,7 @@ var PricingTiersTooltip = ({
22544
22661
  const { t: t2 } = useTranslation();
22545
22662
  const { settings } = useEmbed();
22546
22663
  const isLightBackground = useIsLightBackground();
22547
- const { tiers } = (0, import_react34.useMemo)(() => {
22664
+ const { tiers } = (0, import_react35.useMemo)(() => {
22548
22665
  return priceTiers.reduce(
22549
22666
  (acc, tier) => {
22550
22667
  const end = tier.upTo ?? Infinity;
@@ -22638,7 +22755,7 @@ var PricingTiersTooltip = ({
22638
22755
  };
22639
22756
 
22640
22757
  // src/components/shared/subscription-sidebar/SubscriptionSidebar.tsx
22641
- var import_react36 = require("react");
22758
+ var import_react37 = require("react");
22642
22759
  var import_react_dom2 = require("react-dom");
22643
22760
 
22644
22761
  // src/components/shared/subscription-sidebar/CheckoutStageButton.tsx
@@ -23120,12 +23237,12 @@ var EntitlementRow = (props) => {
23120
23237
  };
23121
23238
 
23122
23239
  // src/components/shared/subscription-sidebar/Proration.tsx
23123
- var import_react35 = require("react");
23240
+ var import_react36 = require("react");
23124
23241
  var import_jsx_runtime44 = require("react/jsx-runtime");
23125
23242
  var Proration = ({ currency, charges }) => {
23126
23243
  const { t: t2, locale } = useTranslation();
23127
23244
  const { settings } = useEmbed();
23128
- const [open, setOpen] = (0, import_react35.useState)(false);
23245
+ const [open, setOpen] = (0, import_react36.useState)(false);
23129
23246
  const toggle = (e) => {
23130
23247
  e.preventDefault();
23131
23248
  e.stopPropagation();
@@ -23176,7 +23293,7 @@ var Proration = ({ currency, charges }) => {
23176
23293
 
23177
23294
  // src/components/shared/subscription-sidebar/SubscriptionSidebar.tsx
23178
23295
  var import_jsx_runtime45 = require("react/jsx-runtime");
23179
- var SubscriptionSidebar = (0, import_react36.forwardRef)(
23296
+ var SubscriptionSidebar = (0, import_react37.forwardRef)(
23180
23297
  ({
23181
23298
  portal,
23182
23299
  planPeriod,
@@ -23227,8 +23344,8 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23227
23344
  } = useEmbed();
23228
23345
  const isIndividualBundlePurchase = data?.checkoutSettings.bundlePurchaseBehavior === CheckoutBundlePurchaseBehavior.Individual;
23229
23346
  const isLightBackground = useIsLightBackground();
23230
- const buttonRef = (0, import_react36.useRef)(null);
23231
- const [isButtonInView, setIsButtonInView] = (0, import_react36.useState)(false);
23347
+ const buttonRef = (0, import_react37.useRef)(null);
23348
+ const [isButtonInView, setIsButtonInView] = (0, import_react37.useState)(false);
23232
23349
  const {
23233
23350
  currentPlan,
23234
23351
  currentAddOns,
@@ -23237,7 +23354,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23237
23354
  billingSubscription,
23238
23355
  paymentMethod,
23239
23356
  trialPaymentMethodRequired
23240
- } = (0, import_react36.useMemo)(() => {
23357
+ } = (0, import_react37.useMemo)(() => {
23241
23358
  const currentEntitlements2 = data?.featureUsage?.features || [];
23242
23359
  return {
23243
23360
  currentPlan: data?.company?.plan,
@@ -23260,7 +23377,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23260
23377
  data?.subscription?.paymentMethod,
23261
23378
  data?.trialPaymentMethodRequired
23262
23379
  ]);
23263
- const planCreditGrants = (0, import_react36.useMemo)(() => {
23380
+ const planCreditGrants = (0, import_react37.useMemo)(() => {
23264
23381
  const grants = mergeCompanyGrants(
23265
23382
  selectedPlan?.includedCreditGrants,
23266
23383
  data?.company?.plan?.includedCreditGrants
@@ -23270,11 +23387,11 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23270
23387
  selectedPlan?.includedCreditGrants,
23271
23388
  data?.company?.plan?.includedCreditGrants
23272
23389
  ]);
23273
- const planCredits = (0, import_react36.useMemo)(
23390
+ const planCredits = (0, import_react37.useMemo)(
23274
23391
  () => groupPlanCreditGrants(selectedPlan?.includedCreditGrants ?? []),
23275
23392
  [selectedPlan?.includedCreditGrants]
23276
23393
  );
23277
- const { payInAdvanceEntitlements } = (0, import_react36.useMemo)(() => {
23394
+ const { payInAdvanceEntitlements } = (0, import_react37.useMemo)(() => {
23278
23395
  const payAsYouGoEntitlements = [];
23279
23396
  const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
23280
23397
  (entitlement) => {
@@ -23286,7 +23403,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23286
23403
  );
23287
23404
  return { payAsYouGoEntitlements, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
23288
23405
  }, [usageBasedEntitlements]);
23289
- const { subscriptionPrice, subscriptionTotal, subscriptionCurrency } = (0, import_react36.useMemo)(() => {
23406
+ const { subscriptionPrice, subscriptionTotal, subscriptionCurrency } = (0, import_react37.useMemo)(() => {
23290
23407
  let planPrice;
23291
23408
  let resolvedCurrency;
23292
23409
  if (selectedPlan) {
@@ -23357,7 +23474,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23357
23474
  proration,
23358
23475
  taxAmount,
23359
23476
  taxDescription
23360
- } = (0, import_react36.useMemo)(() => {
23477
+ } = (0, import_react37.useMemo)(() => {
23361
23478
  return {
23362
23479
  amountOff: charges?.amountOff ?? 0,
23363
23480
  discountAmount: charges?.discountAmount ?? 0,
@@ -23427,7 +23544,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23427
23544
  }
23428
23545
  );
23429
23546
  };
23430
- const updatedUsageBasedEntitlements = (0, import_react36.useMemo)(() => {
23547
+ const updatedUsageBasedEntitlements = (0, import_react37.useMemo)(() => {
23431
23548
  const changedUsageBasedEntitlements = [];
23432
23549
  const allSelectedUsageBasedEntitlements = [
23433
23550
  ...usageBasedEntitlements,
@@ -23490,19 +23607,19 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23490
23607
  usageBasedEntitlements,
23491
23608
  addOnUsageBasedEntitlements
23492
23609
  ]);
23493
- const selectedAddOnsWithPrice = (0, import_react36.useMemo)(
23610
+ const selectedAddOnsWithPrice = (0, import_react37.useMemo)(
23494
23611
  () => addOns.filter(
23495
23612
  (addOn) => addOn.isSelected && getPlanPrice(addOn, void 0, void 0, currency)?.price
23496
23613
  ),
23497
23614
  [addOns, currency]
23498
23615
  );
23499
- const selectedOneTimeAddOns = (0, import_react36.useMemo)(
23616
+ const selectedOneTimeAddOns = (0, import_react37.useMemo)(
23500
23617
  () => addOns.filter(
23501
23618
  (addOn) => addOn.isSelected && addOn.chargeType === ChargeType.oneTime && getAddOnPrice(addOn, planPeriod, currency)?.price
23502
23619
  ),
23503
23620
  [addOns, planPeriod, currency]
23504
23621
  );
23505
- const { removedAddOns, willAddOnsChange } = (0, import_react36.useMemo)(() => {
23622
+ const { removedAddOns, willAddOnsChange } = (0, import_react37.useMemo)(() => {
23506
23623
  const addedAddOns = selectedAddOnsWithPrice.filter(
23507
23624
  (selected) => getPlanPrice(selected, void 0, void 0, currency)?.price && !currentAddOns.some((current) => selected.id === current.id)
23508
23625
  );
@@ -23518,15 +23635,15 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23518
23635
  willAddOnsChange: willAddOnsChange2
23519
23636
  };
23520
23637
  }, [currentAddOns, selectedAddOnsWithPrice, currency]);
23521
- const addedCreditBundles = (0, import_react36.useMemo)(
23638
+ const addedCreditBundles = (0, import_react37.useMemo)(
23522
23639
  () => creditBundles.filter((bundle) => bundle.count > 0),
23523
23640
  [creditBundles]
23524
23641
  );
23525
- const discountApplied = (0, import_react36.useMemo)(
23642
+ const discountApplied = (0, import_react37.useMemo)(
23526
23643
  () => promoCode && (amountOff > 0 || percentOff > 0),
23527
23644
  [promoCode, amountOff, percentOff]
23528
23645
  );
23529
- const subscriptionDiscount = (0, import_react36.useMemo)(
23646
+ const subscriptionDiscount = (0, import_react37.useMemo)(
23530
23647
  () => getSubscriptionDiscount(
23531
23648
  charges?.discounts,
23532
23649
  subscriptionTotal,
@@ -23535,7 +23652,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23535
23652
  ),
23536
23653
  [charges?.discounts, subscriptionTotal, subscriptionCurrency, locale]
23537
23654
  );
23538
- const handleCheckout = (0, import_react36.useCallback)(async () => {
23655
+ const handleCheckout = (0, import_react37.useCallback)(async () => {
23539
23656
  const planId = selectedPlan?.id;
23540
23657
  const currencyPrice = selectedPlan ? getPlanPrice(
23541
23658
  selectedPlan,
@@ -23672,7 +23789,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23672
23789
  customFieldValues,
23673
23790
  ensureTaxIdSaved
23674
23791
  ]);
23675
- const handleUnsubscribe = (0, import_react36.useCallback)(async () => {
23792
+ const handleUnsubscribe = (0, import_react37.useCallback)(async () => {
23676
23793
  try {
23677
23794
  setError(void 0);
23678
23795
  setIsLoading(true);
@@ -23686,7 +23803,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23686
23803
  }
23687
23804
  }, [t2, unsubscribe, setError, setIsLoading, setLayout]);
23688
23805
  const isSelectedPlanTrialable = selectedPlan?.companyCanTrial === true && selectedPlan?.isTrialable === true;
23689
- const button = (0, import_react36.useMemo)(() => {
23806
+ const button = (0, import_react37.useMemo)(() => {
23690
23807
  const hasEntitlementDowngrade = payInAdvanceEntitlements.some((e) => e.quantity < e.usage) || addOnPayInAdvanceEntitlements.some((e) => e.quantity < e.usage);
23691
23808
  const canCheckout = error !== t2("Downgrade not permitted.") && !hasEntitlementDowngrade;
23692
23809
  const isSticky = !isButtonInView;
@@ -23760,7 +23877,7 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
23760
23877
  isCreditOnlyPurchase,
23761
23878
  hasIncompleteRequiredCustomFields
23762
23879
  ]);
23763
- (0, import_react36.useLayoutEffect)(() => {
23880
+ (0, import_react37.useLayoutEffect)(() => {
23764
23881
  const element = buttonRef.current;
23765
23882
  if (!element) {
23766
23883
  return;
@@ -24414,14 +24531,14 @@ var SubscriptionSidebar = (0, import_react36.forwardRef)(
24414
24531
  SubscriptionSidebar.displayName = "SubscriptionSidebar";
24415
24532
 
24416
24533
  // src/components/shared/tiered-pricing-details/TieredPricingDetails.tsx
24417
- var import_react37 = require("react");
24534
+ var import_react38 = require("react");
24418
24535
  var TieredPricingDetails = ({
24419
24536
  entitlement,
24420
24537
  period,
24421
24538
  currency: selectedCurrency
24422
24539
  }) => {
24423
24540
  const { t: t2, locale } = useTranslation();
24424
- const { currency, flatAmount, perUnitPrice, upTo } = (0, import_react37.useMemo)(() => {
24541
+ const { currency, flatAmount, perUnitPrice, upTo } = (0, import_react38.useMemo)(() => {
24425
24542
  const { currency: currency2, priceTier } = getEntitlementPrice(entitlement, period, selectedCurrency) || {};
24426
24543
  const { flatAmount: flatAmount2, perUnitPrice: perUnitPrice2, perUnitPriceDecimal, upTo: upTo2 } = priceTier?.[0] || {};
24427
24544
  return {
@@ -24469,25 +24586,26 @@ var TieredPricingDetails = ({
24469
24586
  };
24470
24587
 
24471
24588
  // src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
24472
- var import_react38 = require("react");
24589
+ var import_react39 = require("react");
24473
24590
  var import_jsx_runtime46 = require("react/jsx-runtime");
24474
24591
  var UnsubscribeDialog = ({ top }) => {
24475
24592
  const { t: t2, locale } = useTranslation();
24476
24593
  const { data, layout, setLayout, setCheckoutState, clearCheckoutState } = useEmbed();
24477
- const dialogRef = (0, import_react38.useRef)(null);
24478
- const sidebarRef = (0, import_react38.useRef)(null);
24479
- const [dialogElement, setDialogElement] = (0, import_react38.useState)(
24594
+ const dialogRef = (0, import_react39.useRef)(null);
24595
+ const sidebarRef = (0, import_react39.useRef)(null);
24596
+ const [dialogElement, setDialogElement] = (0, import_react39.useState)(
24480
24597
  null
24481
24598
  );
24482
- const setDialog = (0, import_react38.useCallback)((element) => {
24599
+ const setDialog = (0, import_react39.useCallback)((element) => {
24483
24600
  dialogRef.current = element;
24484
24601
  setDialogElement(element);
24485
24602
  }, []);
24486
- const [error, setError] = (0, import_react38.useState)();
24487
- const [isLoading, setIsLoading] = (0, import_react38.useState)(false);
24488
- const [isModal, setIsModal] = (0, import_react38.useState)(true);
24489
- const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0, import_react38.useMemo)(() => {
24490
- const cancelDate2 = data?.subscription?.cancelAt || data?.upcomingInvoice?.dueDate;
24603
+ const [error, setError] = (0, import_react39.useState)();
24604
+ const [isLoading, setIsLoading] = (0, import_react39.useState)(false);
24605
+ const [isModal, setIsModal] = (0, import_react39.useState)(true);
24606
+ const { billDate } = useNextBillDate();
24607
+ const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0, import_react39.useMemo)(() => {
24608
+ const cancelDate2 = data?.subscription?.cancelAt || billDate;
24491
24609
  return {
24492
24610
  planPeriod: getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || "month",
24493
24611
  currentPlan: data?.company?.plan,
@@ -24501,10 +24619,10 @@ var UnsubscribeDialog = ({ top }) => {
24501
24619
  data?.company?.plan,
24502
24620
  data?.featureUsage,
24503
24621
  data?.subscription?.cancelAt,
24504
- data?.upcomingInvoice?.dueDate
24622
+ billDate
24505
24623
  ]);
24506
24624
  const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
24507
- const selectedPlan = (0, import_react38.useMemo)(
24625
+ const selectedPlan = (0, import_react39.useMemo)(
24508
24626
  () => availablePlans.find((plan) => plan.id === currentPlan?.id),
24509
24627
  [currentPlan?.id, availablePlans]
24510
24628
  );
@@ -24513,18 +24631,18 @@ var UnsubscribeDialog = ({ top }) => {
24513
24631
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
24514
24632
  []
24515
24633
  );
24516
- const addOns = (0, import_react38.useMemo)(
24634
+ const addOns = (0, import_react39.useMemo)(
24517
24635
  () => availableAddOns.map((available) => ({
24518
24636
  ...available,
24519
24637
  isSelected: currentAddOns.some((current) => available.id === current.id) ?? false
24520
24638
  })),
24521
24639
  [currentAddOns, availableAddOns]
24522
24640
  );
24523
- const handleClose = (0, import_react38.useCallback)(() => {
24641
+ const handleClose = (0, import_react39.useCallback)(() => {
24524
24642
  clearCheckoutState();
24525
24643
  setLayout("portal");
24526
24644
  }, [setLayout, clearCheckoutState]);
24527
- (0, import_react38.useLayoutEffect)(() => {
24645
+ (0, import_react39.useLayoutEffect)(() => {
24528
24646
  const element = dialogRef.current;
24529
24647
  if (layout !== "unsubscribe" || !element) {
24530
24648
  return;
@@ -24811,13 +24929,13 @@ var StyledViewport = import_styled_components21.styled.div.withConfig({
24811
24929
 
24812
24930
  // src/components/layout/viewport/Viewport.tsx
24813
24931
  var import_jsx_runtime50 = require("react/jsx-runtime");
24814
- var Viewport = (0, import_react39.forwardRef)(
24932
+ var Viewport = (0, import_react40.forwardRef)(
24815
24933
  ({ children, portal, ...props }, ref) => {
24816
24934
  portal = portal || document.body;
24817
- const portalRef = (0, import_react39.useRef)(portal);
24935
+ const portalRef = (0, import_react40.useRef)(portal);
24818
24936
  const { data, layout, settings } = useEmbed();
24819
- const [top, setTop] = (0, import_react39.useState)(0);
24820
- (0, import_react39.useLayoutEffect)(() => {
24937
+ const [top, setTop] = (0, import_react40.useState)(0);
24938
+ (0, import_react40.useLayoutEffect)(() => {
24821
24939
  const element = portalRef.current;
24822
24940
  const setModalY = (0, import_debounce5.default)(() => {
24823
24941
  const value = Math.abs(
@@ -24860,7 +24978,7 @@ var resolveDesignProps = (props) => {
24860
24978
  }
24861
24979
  };
24862
24980
  };
24863
- var ButtonElement = (0, import_react40.forwardRef)(({ children, className, ...rest }, ref) => {
24981
+ var ButtonElement = (0, import_react41.forwardRef)(({ children, className, ...rest }, ref) => {
24864
24982
  const props = resolveDesignProps(rest);
24865
24983
  const buttonStyles2 = {
24866
24984
  primary: {
@@ -24905,10 +25023,10 @@ var ButtonElement = (0, import_react40.forwardRef)(({ children, className, ...re
24905
25023
  ButtonElement.displayName = "Button";
24906
25024
 
24907
25025
  // src/components/elements/included-features/IncludedFeatures.tsx
24908
- var import_react42 = require("react");
25026
+ var import_react43 = require("react");
24909
25027
 
24910
25028
  // src/components/elements/included-features/UsageDetails.tsx
24911
- var import_react41 = require("react");
25029
+ var import_react42 = require("react");
24912
25030
  var import_jsx_runtime52 = require("react/jsx-runtime");
24913
25031
  var UsageDetails = ({ entitlement, layout }) => {
24914
25032
  const {
@@ -24936,7 +25054,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24936
25054
  currentTier,
24937
25055
  tiersMode,
24938
25056
  tiered
24939
- } = (0, import_react41.useMemo)(() => {
25057
+ } = (0, import_react42.useMemo)(() => {
24940
25058
  const { billingPrice, amount, limit: limit2, cost: cost2, currentTier: currentTier2 } = getUsageDetails(
24941
25059
  entitlement,
24942
25060
  period,
@@ -24963,7 +25081,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24963
25081
  tiered: priceBehavior === EntitlementPriceBehavior.PayInAdvance && isTieredPrice(billingPrice)
24964
25082
  };
24965
25083
  }, [entitlement, period, priceBehavior, showWarningThresholdAsLimit]);
24966
- const text = (0, import_react41.useMemo)(() => {
25084
+ const text = (0, import_react42.useMemo)(() => {
24967
25085
  if (!feature || feature.featureType !== FeatureType.Event && feature.featureType !== FeatureType.Trait) {
24968
25086
  return;
24969
25087
  }
@@ -25038,7 +25156,7 @@ var UsageDetails = ({ entitlement, layout }) => {
25038
25156
  currentTier,
25039
25157
  showCredits
25040
25158
  ]);
25041
- const usageText = (0, import_react41.useMemo)(() => {
25159
+ const usageText = (0, import_react42.useMemo)(() => {
25042
25160
  if (!feature || feature.featureType !== FeatureType.Event && feature.featureType !== FeatureType.Trait) {
25043
25161
  return;
25044
25162
  }
@@ -25046,7 +25164,7 @@ var UsageDetails = ({ entitlement, layout }) => {
25046
25164
  let index = 0;
25047
25165
  if (priceBehavior === EntitlementPriceBehavior.PayInAdvance && !tiered && typeof period === "string" && typeof price === "number") {
25048
25166
  acc.push(
25049
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react41.Fragment, { children: packageSize > 1 ? t2("$X/Y units/period", {
25167
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react42.Fragment, { children: packageSize > 1 ? t2("$X/Y units/period", {
25050
25168
  cost: formatCurrency(price, { locale, currency }),
25051
25169
  size: packageSize,
25052
25170
  units: getFeatureName(feature, locale, packageSize),
@@ -25060,7 +25178,7 @@ var UsageDetails = ({ entitlement, layout }) => {
25060
25178
  index += 1;
25061
25179
  } else if ((priceBehavior === EntitlementPriceBehavior.PayAsYouGo || priceBehavior === EntitlementPriceBehavior.Overage || priceBehavior === EntitlementPriceBehavior.Tier || priceBehavior === EntitlementPriceBehavior.CreditBurndown || tiered) && typeof usage === "number") {
25062
25180
  acc.push(
25063
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react41.Fragment, { children: t2("X units used", {
25181
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react42.Fragment, { children: t2("X units used", {
25064
25182
  amount: usage,
25065
25183
  units: getFeatureName(feature, locale, usage)
25066
25184
  }) }, index)
@@ -25069,14 +25187,14 @@ var UsageDetails = ({ entitlement, layout }) => {
25069
25187
  }
25070
25188
  if (typeof cost === "number" && cost > 0) {
25071
25189
  acc.push(
25072
- /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react41.Fragment, { children: [
25190
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react42.Fragment, { children: [
25073
25191
  acc.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: " \u2022 " }),
25074
25192
  formatCurrency(cost, { locale, currency })
25075
25193
  ] }, index)
25076
25194
  );
25077
25195
  index += 1;
25078
25196
  if (feature.featureType === FeatureType.Trait && typeof period === "string") {
25079
- acc.push(/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react41.Fragment, { children: [
25197
+ acc.push(/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react42.Fragment, { children: [
25080
25198
  "/",
25081
25199
  shortenPeriod(period, t2)
25082
25200
  ] }, index));
@@ -25085,7 +25203,7 @@ var UsageDetails = ({ entitlement, layout }) => {
25085
25203
  }
25086
25204
  if (metricResetAt) {
25087
25205
  acc.push(
25088
- /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react41.Fragment, { children: [
25206
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react42.Fragment, { children: [
25089
25207
  acc.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: " \u2022 " }),
25090
25208
  t2("Resets", {
25091
25209
  date: toPrettyDate(metricResetAt, {
@@ -25210,12 +25328,12 @@ function resolveDesignProps2(props) {
25210
25328
  }
25211
25329
  };
25212
25330
  }
25213
- var IncludedFeatures = (0, import_react42.forwardRef)(({ className, ...rest }, ref) => {
25331
+ var IncludedFeatures = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
25214
25332
  const props = resolveDesignProps2(rest);
25215
25333
  const { t: t2, locale } = useTranslation();
25216
25334
  const { data, settings } = useEmbed();
25217
25335
  const isLightBackground = useIsLightBackground();
25218
- const { plan, addOns, featureUsage } = (0, import_react42.useMemo)(() => {
25336
+ const { plan, addOns, featureUsage } = (0, import_react43.useMemo)(() => {
25219
25337
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
25220
25338
  (acc, id) => {
25221
25339
  const mappedFeatureUsage = data?.featureUsage?.features.find(
@@ -25261,7 +25379,7 @@ var IncludedFeatures = (0, import_react42.forwardRef)(({ className, ...rest }, r
25261
25379
  }
25262
25380
  },
25263
25381
  children: visibleFeatureUsage.items.map((entitlement, index) => {
25264
- return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_react42.Fragment, { children: [
25382
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_react43.Fragment, { children: [
25265
25383
  props.icons.isVisible && entitlement.feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
25266
25384
  Icon3,
25267
25385
  {
@@ -25353,7 +25471,7 @@ var IncludedFeatures = (0, import_react42.forwardRef)(({ className, ...rest }, r
25353
25471
  IncludedFeatures.displayName = "IncludedFeatures";
25354
25472
 
25355
25473
  // src/components/elements/invoices/Invoices.tsx
25356
- var import_react43 = require("react");
25474
+ var import_react44 = require("react");
25357
25475
  var import_jsx_runtime54 = require("react/jsx-runtime");
25358
25476
  function resolveDesignProps3(props) {
25359
25477
  return {
@@ -25412,27 +25530,27 @@ function formatInvoices(invoices, locale, options) {
25412
25530
  };
25413
25531
  });
25414
25532
  }
25415
- var Invoices = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
25533
+ var Invoices = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
25416
25534
  const props = resolveDesignProps3(rest);
25417
25535
  const { t: t2, locale } = useTranslation();
25418
25536
  const { data, listInvoices, settings } = useEmbed();
25419
- const [isLoading, setIsLoading] = (0, import_react43.useState)(false);
25420
- const [error, setError] = (0, import_react43.useState)();
25421
- const [rawInvoices, setInvoices] = (0, import_react43.useState)(
25537
+ const [isLoading, setIsLoading] = (0, import_react44.useState)(false);
25538
+ const [error, setError] = (0, import_react44.useState)();
25539
+ const [rawInvoices, setInvoices] = (0, import_react44.useState)(
25422
25540
  () => data && "invoices" in data ? data.invoices : rest.data
25423
25541
  );
25424
- const invoices = (0, import_react43.useMemo)(
25542
+ const invoices = (0, import_react44.useMemo)(
25425
25543
  () => formatInvoices(rawInvoices, locale),
25426
25544
  [rawInvoices, locale]
25427
25545
  );
25428
- const reachableInvoices = (0, import_react43.useMemo)(
25546
+ const reachableInvoices = (0, import_react44.useMemo)(
25429
25547
  () => invoices.slice(0, MAX_VISIBLE_INVOICE_COUNT),
25430
25548
  [invoices]
25431
25549
  );
25432
25550
  const visibleInvoices = useTruncatedList(reachableInvoices, {
25433
25551
  limit: props.limit.number
25434
25552
  });
25435
- const getInvoices = (0, import_react43.useCallback)(async () => {
25553
+ const getInvoices = (0, import_react44.useCallback)(async () => {
25436
25554
  try {
25437
25555
  setError(void 0);
25438
25556
  setIsLoading(true);
@@ -25446,15 +25564,15 @@ var Invoices = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
25446
25564
  setIsLoading(false);
25447
25565
  }
25448
25566
  }, [listInvoices]);
25449
- (0, import_react43.useEffect)(() => {
25567
+ (0, import_react44.useEffect)(() => {
25450
25568
  getInvoices();
25451
25569
  }, [getInvoices]);
25452
- (0, import_react43.useEffect)(() => {
25570
+ (0, import_react44.useEffect)(() => {
25453
25571
  if (rest.data) {
25454
25572
  setInvoices(rest.data);
25455
25573
  }
25456
25574
  }, [rest.data]);
25457
- (0, import_react43.useEffect)(() => {
25575
+ (0, import_react44.useEffect)(() => {
25458
25576
  if (data && "invoices" in data) {
25459
25577
  const invoicesPreviewData = data.invoices;
25460
25578
  setInvoices(invoicesPreviewData);
@@ -25544,7 +25662,7 @@ var Invoices = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
25544
25662
  Invoices.displayName = "Invoices";
25545
25663
 
25546
25664
  // src/components/elements/metered-features/MeteredFeatures.tsx
25547
- var import_react45 = require("react");
25665
+ var import_react46 = require("react");
25548
25666
 
25549
25667
  // src/components/elements/metered-features/Meter.tsx
25550
25668
  var import_jsx_runtime55 = require("react/jsx-runtime");
@@ -25677,7 +25795,7 @@ var PriceDetails = ({
25677
25795
  };
25678
25796
 
25679
25797
  // src/components/elements/metered-features/UsageByUser.tsx
25680
- var import_react44 = require("react");
25798
+ var import_react45 = require("react");
25681
25799
  var import_jsx_runtime57 = require("react/jsx-runtime");
25682
25800
  var COLLAPSED_COUNT = 3;
25683
25801
  var EXPANDED_COUNT = 20;
@@ -25734,13 +25852,13 @@ var UsageByUser = ({ source, unit }) => {
25734
25852
  const { t: t2, locale } = useTranslation();
25735
25853
  const isLightBackground = useIsLightBackground();
25736
25854
  const { getCreditUsageByUser, getFeatureUsageByUser } = useEmbed();
25737
- const [expanded, setExpanded] = (0, import_react44.useState)(false);
25738
- const [result, setResult] = (0, import_react44.useState)();
25739
- const [attempt, setAttempt] = (0, import_react44.useState)(0);
25855
+ const [expanded, setExpanded] = (0, import_react45.useState)(false);
25856
+ const [result, setResult] = (0, import_react45.useState)();
25857
+ const [attempt, setAttempt] = (0, import_react45.useState)(0);
25740
25858
  const { kind, id } = source;
25741
25859
  const sourceKey = `${kind}:${id}`;
25742
25860
  const current = result?.sourceKey === sourceKey ? result : void 0;
25743
- (0, import_react44.useEffect)(() => {
25861
+ (0, import_react45.useEffect)(() => {
25744
25862
  let active = true;
25745
25863
  const apply = (next) => {
25746
25864
  if (active) {
@@ -25774,7 +25892,7 @@ var UsageByUser = ({ source, unit }) => {
25774
25892
  sourceKey
25775
25893
  ]);
25776
25894
  const entries = current?.section?.entries;
25777
- const attributed = (0, import_react44.useMemo)(
25895
+ const attributed = (0, import_react45.useMemo)(
25778
25896
  () => [...entries ?? []].sort((a, b) => b.amount - a.amount),
25779
25897
  [entries]
25780
25898
  );
@@ -25961,15 +26079,16 @@ function resolveDesignProps4(props) {
25961
26079
  visibleFeatures: props.visibleFeatures
25962
26080
  };
25963
26081
  }
25964
- var MeteredFeatures = (0, import_react45.forwardRef)(({ className, ...rest }, ref) => {
26082
+ var MeteredFeatures = (0, import_react46.forwardRef)(({ className, ...rest }, ref) => {
25965
26083
  const props = resolveDesignProps4(rest);
25966
- const elementsRef = (0, import_react45.useRef)([]);
26084
+ const elementsRef = (0, import_react46.useRef)([]);
25967
26085
  const shouldWrapChildren = useWrapChildren(elementsRef);
25968
26086
  const { t: t2, locale } = useTranslation();
25969
26087
  const { data, settings, setCheckoutState, warningThresholdConfig } = useEmbed();
25970
26088
  const showWarningThresholdAsLimit = warningThresholdConfig?.showAsLimit ?? false;
25971
26089
  const isLightBackground = useIsLightBackground();
25972
- const meteredFeatures = (0, import_react45.useMemo)(() => {
26090
+ const { billDate: renewalDate } = useNextBillDate();
26091
+ const meteredFeatures = (0, import_react46.useMemo)(() => {
25973
26092
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
25974
26093
  (acc, id) => {
25975
26094
  const mappedFeatureUsage = data?.featureUsage?.features.find(
@@ -25986,7 +26105,7 @@ var MeteredFeatures = (0, import_react45.forwardRef)(({ className, ...rest }, re
25986
26105
  ({ feature }) => feature?.featureType === FeatureType.Event || feature?.featureType === FeatureType.Trait
25987
26106
  );
25988
26107
  }, [props.visibleFeatures, data?.featureUsage?.features]);
25989
- const creditGroups = (0, import_react45.useMemo)(
26108
+ const creditGroups = (0, import_react46.useMemo)(
25990
26109
  () => withEmptyPlanCreditBalances(
25991
26110
  aggregateActiveGrantsByCredit(data?.creditGrants || []),
25992
26111
  listPlanCredits(
@@ -25997,11 +26116,11 @@ var MeteredFeatures = (0, import_react45.forwardRef)(({ className, ...rest }, re
25997
26116
  ),
25998
26117
  [data?.creditGrants, data?.featureUsage?.features, data?.company]
25999
26118
  );
26000
- const planCreditCompositions = (0, import_react45.useMemo)(
26119
+ const planCreditCompositions = (0, import_react46.useMemo)(
26001
26120
  () => groupPlanCreditGrants(data?.company?.plan?.includedCreditGrants ?? []),
26002
26121
  [data?.company?.plan?.includedCreditGrants]
26003
26122
  );
26004
- const resolveLicenseQuantity = (0, import_react45.useCallback)(
26123
+ const resolveLicenseQuantity = (0, import_react46.useCallback)(
26005
26124
  (licenseId) => {
26006
26125
  const allocation = findLicenseSource(
26007
26126
  data?.featureUsage?.features ?? [],
@@ -26011,17 +26130,17 @@ var MeteredFeatures = (0, import_react45.forwardRef)(({ className, ...rest }, re
26011
26130
  },
26012
26131
  [data?.featureUsage?.features]
26013
26132
  );
26014
- const purchasableCreditIds = (0, import_react45.useMemo)(
26133
+ const purchasableCreditIds = (0, import_react46.useMemo)(
26015
26134
  () => getPurchasableCreditIds(data?.creditBundles, data?.company?.plan?.id),
26016
26135
  [data?.creditBundles, data?.company?.plan?.id]
26017
26136
  );
26018
- const [expandedCreditIds, setExpandedCreditIds] = (0, import_react45.useState)(
26137
+ const [expandedCreditIds, setExpandedCreditIds] = (0, import_react46.useState)(
26019
26138
  () => /* @__PURE__ */ new Set()
26020
26139
  );
26021
- const [fullLedgerCreditIds, setFullLedgerCreditIds] = (0, import_react45.useState)(
26140
+ const [fullLedgerCreditIds, setFullLedgerCreditIds] = (0, import_react46.useState)(
26022
26141
  () => /* @__PURE__ */ new Set()
26023
26142
  );
26024
- const toggleFullLedger = (0, import_react45.useCallback)((id) => {
26143
+ const toggleFullLedger = (0, import_react46.useCallback)((id) => {
26025
26144
  setFullLedgerCreditIds((prev) => {
26026
26145
  const next = new Set(prev);
26027
26146
  if (next.has(id)) {
@@ -26032,7 +26151,7 @@ var MeteredFeatures = (0, import_react45.forwardRef)(({ className, ...rest }, re
26032
26151
  return next;
26033
26152
  });
26034
26153
  }, []);
26035
- const toggleBalanceDetails = (0, import_react45.useCallback)((id) => {
26154
+ const toggleBalanceDetails = (0, import_react46.useCallback)((id) => {
26036
26155
  setExpandedCreditIds((prev) => {
26037
26156
  const next = new Set(prev);
26038
26157
  if (next.has(id)) {
@@ -26256,7 +26375,6 @@ var MeteredFeatures = (0, import_react45.forwardRef)(({ className, ...rest }, re
26256
26375
  })
26257
26376
  );
26258
26377
  }
26259
- const renewalDate = data?.upcomingInvoice?.dueDate;
26260
26378
  return (
26261
26379
  // Pulled up against the balance line despite the column's 2rem gap
26262
26380
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Box, { $marginTop: "-1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
@@ -26417,10 +26535,10 @@ var MeteredFeatures = (0, import_react45.forwardRef)(({ className, ...rest }, re
26417
26535
  MeteredFeatures.displayName = "MeteredFeatures";
26418
26536
 
26419
26537
  // src/components/elements/payment-method/PaymentMethod.tsx
26420
- var import_react47 = require("react");
26538
+ var import_react48 = require("react");
26421
26539
 
26422
26540
  // src/components/elements/payment-method/PaymentMethodElement.tsx
26423
- var import_react46 = require("react");
26541
+ var import_react47 = require("react");
26424
26542
  var import_jsx_runtime59 = require("react/jsx-runtime");
26425
26543
  var PaymentElement2 = ({
26426
26544
  iconName,
@@ -26596,7 +26714,7 @@ var PaymentListElement = ({
26596
26714
  const { settings } = useEmbed();
26597
26715
  const isLightBackground = useIsLightBackground();
26598
26716
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
26599
- const expirationDate = (0, import_react46.useMemo)(() => {
26717
+ const expirationDate = (0, import_react47.useMemo)(() => {
26600
26718
  const { cardExpMonth, cardExpYear } = paymentMethod;
26601
26719
  if (!cardExpMonth || !cardExpYear) {
26602
26720
  return;
@@ -26688,10 +26806,10 @@ var resolveDesignProps5 = (props) => {
26688
26806
  }
26689
26807
  };
26690
26808
  };
26691
- var PaymentMethod = (0, import_react47.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
26809
+ var PaymentMethod = (0, import_react48.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
26692
26810
  const props = resolveDesignProps5(rest);
26693
26811
  const { data, setLayout } = useEmbed();
26694
- const { paymentMethod, monthsToExpiration } = (0, import_react47.useMemo)(() => {
26812
+ const { paymentMethod, monthsToExpiration } = (0, import_react48.useMemo)(() => {
26695
26813
  const paymentMethod2 = data?.subscription?.paymentMethod || data?.company?.defaultPaymentMethod;
26696
26814
  let monthsToExpiration2;
26697
26815
  if (typeof paymentMethod2?.cardExpYear === "number" && typeof paymentMethod2?.cardExpMonth === "number") {
@@ -26895,7 +27013,7 @@ var loadStripe = function loadStripe2() {
26895
27013
  };
26896
27014
 
26897
27015
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
26898
- var import_react48 = require("react");
27016
+ var import_react49 = require("react");
26899
27017
  var import_jsx_runtime61 = require("react/jsx-runtime");
26900
27018
  var resolveDesignProps6 = () => {
26901
27019
  return {
@@ -26924,7 +27042,7 @@ var PaymentMethodDetails = ({
26924
27042
  updatePaymentMethod,
26925
27043
  deletePaymentMethod
26926
27044
  } = useEmbed();
26927
- const { defaultPaymentMethod, paymentMethods, subscription } = (0, import_react48.useMemo)(() => {
27045
+ const { defaultPaymentMethod, paymentMethods, subscription } = (0, import_react49.useMemo)(() => {
26928
27046
  return {
26929
27047
  defaultPaymentMethod: data?.company?.defaultPaymentMethod,
26930
27048
  paymentMethods: data?.company?.paymentMethods || [],
@@ -26937,13 +27055,13 @@ var PaymentMethodDetails = ({
26937
27055
  ]);
26938
27056
  const isLightBackground = useIsLightBackground();
26939
27057
  const initialPaymentMethod = subscription?.paymentMethod || defaultPaymentMethod;
26940
- const [isLoading, setIsLoading] = (0, import_react48.useState)(!initialPaymentMethod);
26941
- const [error, setError] = (0, import_react48.useState)();
26942
- const [showPaymentForm, setShowPaymentForm] = (0, import_react48.useState)(false);
26943
- const [stripe, setStripe] = (0, import_react48.useState)(null);
26944
- const [setupIntent, setSetupIntent] = (0, import_react48.useState)();
26945
- const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react48.useState)(false);
26946
- const [currentPaymentMethod, setCurrentPaymentMethod] = (0, import_react48.useState)(initialPaymentMethod);
27058
+ const [isLoading, setIsLoading] = (0, import_react49.useState)(!initialPaymentMethod);
27059
+ const [error, setError] = (0, import_react49.useState)();
27060
+ const [showPaymentForm, setShowPaymentForm] = (0, import_react49.useState)(false);
27061
+ const [stripe, setStripe] = (0, import_react49.useState)(null);
27062
+ const [setupIntent, setSetupIntent] = (0, import_react49.useState)();
27063
+ const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react49.useState)(false);
27064
+ const [currentPaymentMethod, setCurrentPaymentMethod] = (0, import_react49.useState)(initialPaymentMethod);
26947
27065
  const { isConfirming: isConfirmingPayment } = usePaymentConfirmation({
26948
27066
  stripe,
26949
27067
  clientSecret: confirmPaymentIntentProps?.clientSecret,
@@ -26956,7 +27074,7 @@ var PaymentMethodDetails = ({
26956
27074
  },
26957
27075
  autoConfirm: true
26958
27076
  });
26959
- const monthsToExpiration = (0, import_react48.useMemo)(() => {
27077
+ const monthsToExpiration = (0, import_react49.useMemo)(() => {
26960
27078
  let expiration;
26961
27079
  if (typeof currentPaymentMethod?.cardExpYear === "number" && typeof currentPaymentMethod?.cardExpMonth === "number") {
26962
27080
  const now = /* @__PURE__ */ new Date();
@@ -26979,8 +27097,8 @@ var PaymentMethodDetails = ({
26979
27097
  const toggleShowPaymentMethods = () => {
26980
27098
  setShowDifferentPaymentMethods((prev) => !prev);
26981
27099
  };
26982
- const locale = (0, import_react48.useMemo)(() => stripeLocale(language), [language]);
26983
- const initializeStripe = (0, import_react48.useCallback)(() => {
27100
+ const locale = (0, import_react49.useMemo)(() => stripeLocale(language), [language]);
27101
+ const initializeStripe = (0, import_react49.useCallback)(() => {
26984
27102
  if (stripe || !setupIntent) {
26985
27103
  return;
26986
27104
  }
@@ -27003,7 +27121,7 @@ var PaymentMethodDetails = ({
27003
27121
  setShowPaymentForm(false);
27004
27122
  });
27005
27123
  }, [t2, stripe, setupIntent, locale]);
27006
- const initializePaymentMethod = (0, import_react48.useCallback)(() => {
27124
+ const initializePaymentMethod = (0, import_react49.useCallback)(() => {
27007
27125
  const pending = createSetupIntent() ?? Promise.resolve(void 0);
27008
27126
  return pending.then((response) => {
27009
27127
  if (response) {
@@ -27018,7 +27136,7 @@ var PaymentMethodDetails = ({
27018
27136
  setIsLoading(false);
27019
27137
  });
27020
27138
  }, [t2, createSetupIntent]);
27021
- const handleUpdatePaymentMethod = (0, import_react48.useCallback)(
27139
+ const handleUpdatePaymentMethod = (0, import_react49.useCallback)(
27022
27140
  async (paymentMethodId) => {
27023
27141
  try {
27024
27142
  setIsLoading(true);
@@ -27040,7 +27158,7 @@ var PaymentMethodDetails = ({
27040
27158
  },
27041
27159
  [t2, setPaymentMethodId, updatePaymentMethod, onPaymentMethodSaved]
27042
27160
  );
27043
- const handleDeletePaymentMethod = (0, import_react48.useCallback)(
27161
+ const handleDeletePaymentMethod = (0, import_react49.useCallback)(
27044
27162
  async (paymentMethodId) => {
27045
27163
  try {
27046
27164
  setIsLoading(true);
@@ -27056,10 +27174,10 @@ var PaymentMethodDetails = ({
27056
27174
  },
27057
27175
  [t2, deletePaymentMethod]
27058
27176
  );
27059
- (0, import_react48.useEffect)(() => {
27177
+ (0, import_react49.useEffect)(() => {
27060
27178
  initializeStripe();
27061
27179
  }, [initializeStripe]);
27062
- (0, import_react48.useEffect)(() => {
27180
+ (0, import_react49.useEffect)(() => {
27063
27181
  if (!setupIntent && (!currentPaymentMethod || showPaymentForm)) {
27064
27182
  initializePaymentMethod();
27065
27183
  }
@@ -27239,7 +27357,7 @@ var PaymentMethodDetails = ({
27239
27357
  };
27240
27358
 
27241
27359
  // src/components/elements/plan-manager/PlanManager.tsx
27242
- var import_react50 = require("react");
27360
+ var import_react51 = require("react");
27243
27361
 
27244
27362
  // src/components/elements/plan-manager/AddOn.tsx
27245
27363
  var import_jsx_runtime62 = require("react/jsx-runtime");
@@ -27265,7 +27383,7 @@ var AddOn = ({ addOn, currency, period, layout }) => {
27265
27383
  };
27266
27384
 
27267
27385
  // src/components/elements/plan-manager/UsageDetails.tsx
27268
- var import_react49 = require("react");
27386
+ var import_react50 = require("react");
27269
27387
  var import_jsx_runtime63 = require("react/jsx-runtime");
27270
27388
  var UsageDetails2 = ({
27271
27389
  entitlement,
@@ -27281,31 +27399,31 @@ var UsageDetails2 = ({
27281
27399
  billingPrice,
27282
27400
  limit,
27283
27401
  cost = 0
27284
- } = (0, import_react49.useMemo)(
27402
+ } = (0, import_react50.useMemo)(
27285
27403
  () => getUsageDetails(entitlement, period, currency, {
27286
27404
  showWarningThresholdAsLimit
27287
27405
  }),
27288
27406
  [entitlement, period, currency, showWarningThresholdAsLimit]
27289
27407
  );
27290
- const description = (0, import_react49.useMemo)(() => {
27408
+ const description = (0, import_react50.useMemo)(() => {
27291
27409
  const acc = [];
27292
27410
  let index = 0;
27293
27411
  if (entitlement.priceBehavior === EntitlementPriceBehavior.Overage) {
27294
- acc.push(/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_react49.Fragment, { children: [
27412
+ acc.push(/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_react50.Fragment, { children: [
27295
27413
  t2("Additional"),
27296
27414
  ": "
27297
27415
  ] }, index));
27298
27416
  index += 1;
27299
27417
  }
27300
27418
  if (entitlement.priceBehavior === EntitlementPriceBehavior.Tier) {
27301
- acc.push(/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react49.Fragment, { children: t2("Tier-based") }, index));
27419
+ acc.push(/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react50.Fragment, { children: t2("Tier-based") }, index));
27302
27420
  index += 1;
27303
27421
  }
27304
27422
  const { price } = getEntitlementPrice(entitlement, period, currency) || {};
27305
27423
  if ((entitlement.priceBehavior === EntitlementPriceBehavior.PayAsYouGo || entitlement.priceBehavior === EntitlementPriceBehavior.Overage) && entitlement.feature && typeof price === "number") {
27306
27424
  const packageSize = billingPrice?.packageSize ?? 1;
27307
27425
  acc.push(
27308
- /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_react49.Fragment, { children: [
27426
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_react50.Fragment, { children: [
27309
27427
  formatCurrency(price, { locale, currency: billingPrice?.currency }),
27310
27428
  /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("sub", { children: [
27311
27429
  "/",
@@ -27325,7 +27443,7 @@ var UsageDetails2 = ({
27325
27443
  }
27326
27444
  if (showCredits && entitlement.priceBehavior === EntitlementPriceBehavior.CreditBurndown && entitlement.planEntitlement?.consumptionRate && entitlement.planEntitlement?.valueCredit) {
27327
27445
  acc.push(
27328
- /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_react49.Fragment, { children: [
27446
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_react50.Fragment, { children: [
27329
27447
  formatConsumptionRate(
27330
27448
  entitlement.planEntitlement.consumptionRate,
27331
27449
  locale
@@ -27447,7 +27565,7 @@ var resolveDesignProps7 = (props) => {
27447
27565
  }
27448
27566
  };
27449
27567
  };
27450
- var PlanManager = (0, import_react50.forwardRef)(({ children, className, portal, ...rest }, ref) => {
27568
+ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal, ...rest }, ref) => {
27451
27569
  const props = resolveDesignProps7(rest);
27452
27570
  const { t: t2, locale } = useTranslation();
27453
27571
  const { data, settings, setCheckoutState, setLayout } = useEmbed();
@@ -27466,7 +27584,7 @@ var PlanManager = (0, import_react50.forwardRef)(({ children, className, portal,
27466
27584
  showCredits,
27467
27585
  showZeroPriceAsFree,
27468
27586
  trialPaymentMethodRequired
27469
- } = (0, import_react50.useMemo)(() => {
27587
+ } = (0, import_react51.useMemo)(() => {
27470
27588
  const planCreditOrder = /* @__PURE__ */ new Map();
27471
27589
  (data?.company?.plan?.includedCreditGrants ?? []).forEach((grant) => {
27472
27590
  if (!planCreditOrder.has(grant.creditId)) {
@@ -27526,15 +27644,15 @@ var PlanManager = (0, import_react50.forwardRef)(({ children, className, portal,
27526
27644
  data?.displaySettings?.showZeroPriceAsFree,
27527
27645
  data?.trialPaymentMethodRequired
27528
27646
  ]);
27529
- const usageBasedEntitlements = (0, import_react50.useMemo)(
27647
+ const usageBasedEntitlements = (0, import_react51.useMemo)(
27530
27648
  () => featureUsage.filter((usage) => typeof usage.priceBehavior === "string"),
27531
27649
  [featureUsage]
27532
27650
  );
27533
- const planCreditCompositions = (0, import_react50.useMemo)(
27651
+ const planCreditCompositions = (0, import_react51.useMemo)(
27534
27652
  () => groupPlanCreditGrants(currentPlan?.includedCreditGrants ?? []),
27535
27653
  [currentPlan?.includedCreditGrants]
27536
27654
  );
27537
- const resolveLicenseQuantity = (0, import_react50.useMemo)(() => {
27655
+ const resolveLicenseQuantity = (0, import_react51.useMemo)(() => {
27538
27656
  return (licenseId) => {
27539
27657
  const allocation = findLicenseSource(featureUsage, licenseId)?.allocation;
27540
27658
  return typeof allocation === "number" ? allocation : void 0;
@@ -27557,7 +27675,7 @@ var PlanManager = (0, import_react50.forwardRef)(({ children, className, portal,
27557
27675
  subscriptionCurrency,
27558
27676
  willSubscriptionCancel,
27559
27677
  isTrialSubscription
27560
- } = (0, import_react50.useMemo)(() => {
27678
+ } = (0, import_react51.useMemo)(() => {
27561
27679
  const subscriptionInterval2 = getSubscriptionPeriod(billingSubscription) ?? billingSubscription?.interval;
27562
27680
  const subscriptionCurrency2 = billingSubscription?.currency;
27563
27681
  const isTrialSubscription2 = billingSubscription?.status === "trialing";
@@ -27570,7 +27688,7 @@ var PlanManager = (0, import_react50.forwardRef)(({ children, className, portal,
27570
27688
  };
27571
27689
  }, [billingSubscription]);
27572
27690
  const currentPlanPeriod = getSubscriptionPeriod(billingSubscription) ?? currentPlan?.planPeriod ?? void 0;
27573
- const { isFreePlan, isUsageBasedPlan } = (0, import_react50.useMemo)(() => {
27691
+ const { isFreePlan, isUsageBasedPlan } = (0, import_react51.useMemo)(() => {
27574
27692
  const isFreePlan2 = currentPlan?.planPrice === 0;
27575
27693
  const isUsageBasedPlan2 = isFreePlan2 && usageBasedEntitlements.length > 0;
27576
27694
  return { isFreePlan: isFreePlan2, isUsageBasedPlan: isUsageBasedPlan2 };
@@ -28214,10 +28332,10 @@ var PlanManager = (0, import_react50.forwardRef)(({ children, className, portal,
28214
28332
  PlanManager.displayName = "PlanManager";
28215
28333
 
28216
28334
  // src/components/elements/pricing-table/PricingTable.tsx
28217
- var import_react53 = require("react");
28335
+ var import_react54 = require("react");
28218
28336
 
28219
28337
  // src/components/elements/pricing-table/AddOn.tsx
28220
- var import_react51 = require("react");
28338
+ var import_react52 = require("react");
28221
28339
  var import_jsx_runtime65 = require("react/jsx-runtime");
28222
28340
  function renderMeteredEntitlementPricing2({
28223
28341
  priceBehavior,
@@ -28275,7 +28393,7 @@ var AddOn2 = ({
28275
28393
  const { data, settings, setCheckoutState, warningThresholdConfig } = useEmbed();
28276
28394
  const showWarningThresholdAsLimit = warningThresholdConfig?.showAsLimit ?? false;
28277
28395
  const isLightBackground = useIsLightBackground();
28278
- const { currentAddOns, canCheckout, isStandalone } = (0, import_react51.useMemo)(() => {
28396
+ const { currentAddOns, canCheckout, isStandalone } = (0, import_react52.useMemo)(() => {
28279
28397
  const isStandalone2 = typeof data?.component === "undefined";
28280
28398
  return {
28281
28399
  currentAddOns: data?.company?.addOns || [],
@@ -28544,7 +28662,7 @@ var AddOn2 = ({
28544
28662
  };
28545
28663
 
28546
28664
  // src/components/elements/pricing-table/Plan.tsx
28547
- var import_react52 = require("react");
28665
+ var import_react53 = require("react");
28548
28666
 
28549
28667
  // src/components/elements/pricing-table/Entitlement.tsx
28550
28668
  var import_jsx_runtime66 = require("react/jsx-runtime");
@@ -28767,7 +28885,7 @@ var Plan2 = ({
28767
28885
  const { data, settings, setCheckoutState } = useEmbed();
28768
28886
  const isLightBackground = useIsLightBackground();
28769
28887
  const trialEnd = useTrialEnd();
28770
- const [entitlementVisibility, setEntitlementVisibility] = (0, import_react52.useState)({});
28888
+ const [entitlementVisibility, setEntitlementVisibility] = (0, import_react53.useState)({});
28771
28889
  const handleToggleShowAll = (id) => {
28772
28890
  setEntitlementVisibility((prev) => {
28773
28891
  const updated = !(prev[id] ?? false);
@@ -29105,11 +29223,11 @@ var resolveDesignProps8 = (props) => {
29105
29223
  }
29106
29224
  };
29107
29225
  };
29108
- var PricingTable = (0, import_react53.forwardRef)(({ className, ...rest }, ref) => {
29226
+ var PricingTable = (0, import_react54.forwardRef)(({ className, ...rest }, ref) => {
29109
29227
  const props = resolveDesignProps8(rest);
29110
29228
  const { t: t2 } = useTranslation();
29111
29229
  const { data, settings, isPending, hydratePublic, currencyFilter } = useEmbed();
29112
- const getCallToActionTarget = (0, import_react53.useCallback)(
29230
+ const getCallToActionTarget = (0, import_react54.useCallback)(
29113
29231
  (url, target) => {
29114
29232
  if (target) {
29115
29233
  return target;
@@ -29127,11 +29245,11 @@ var PricingTable = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
29127
29245
  },
29128
29246
  []
29129
29247
  );
29130
- const [selectedPeriod, setSelectedPeriod] = (0, import_react53.useState)(
29248
+ const [selectedPeriod, setSelectedPeriod] = (0, import_react54.useState)(
29131
29249
  () => getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || getDefaultPlanPeriod(data?.activePlans)
29132
29250
  );
29133
29251
  const { currencies, invalidFilterEntries } = useAvailableCurrenciesWithInvalid();
29134
- const [selectedCurrency, setSelectedCurrency] = (0, import_react53.useState)(
29252
+ const [selectedCurrency, setSelectedCurrency] = (0, import_react54.useState)(
29135
29253
  () => currencies[0] ?? DEFAULT_CURRENCY
29136
29254
  );
29137
29255
  if (currencies.length > 0 && !currencies.includes(selectedCurrency)) {
@@ -29149,19 +29267,19 @@ var PricingTable = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
29149
29267
  } = useAvailablePlans(selectedPeriod, {
29150
29268
  useSelectedPeriod: showPeriodToggle
29151
29269
  });
29152
- const plans = (0, import_react53.useMemo)(
29270
+ const plans = (0, import_react54.useMemo)(
29153
29271
  () => hasCurrency ? allPlans.filter(
29154
29272
  (plan) => planSupportsCurrency(plan, selectedCurrency)
29155
29273
  ) : allPlans,
29156
29274
  [allPlans, hasCurrency, selectedCurrency]
29157
29275
  );
29158
- const addOns = (0, import_react53.useMemo)(
29276
+ const addOns = (0, import_react54.useMemo)(
29159
29277
  () => hasCurrency ? allAddOns.filter(
29160
29278
  (addOn) => planSupportsCurrency(addOn, selectedCurrency)
29161
29279
  ) : allAddOns,
29162
29280
  [allAddOns, hasCurrency, selectedCurrency]
29163
29281
  );
29164
- (0, import_react53.useEffect)(() => {
29282
+ (0, import_react54.useEffect)(() => {
29165
29283
  if (typeof data?.component === "undefined") {
29166
29284
  hydratePublic();
29167
29285
  }
@@ -29188,7 +29306,7 @@ var PricingTable = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
29188
29306
  rest.callToActionUrl,
29189
29307
  rest.callToActionTarget
29190
29308
  );
29191
- const Wrapper = typeof data?.component === "undefined" ? Container : import_react53.Fragment;
29309
+ const Wrapper = typeof data?.component === "undefined" ? Container : import_react54.Fragment;
29192
29310
  return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
29193
29311
  FussyChild,
29194
29312
  {
@@ -29342,7 +29460,7 @@ var PricingTable = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
29342
29460
  PricingTable.displayName = "PricingTable";
29343
29461
 
29344
29462
  // src/components/elements/text/Text.tsx
29345
- var import_react54 = require("react");
29463
+ var import_react55 = require("react");
29346
29464
  var import_jsx_runtime69 = require("react/jsx-runtime");
29347
29465
  var resolveDesignProps9 = (props) => {
29348
29466
  return {
@@ -29353,7 +29471,7 @@ var resolveDesignProps9 = (props) => {
29353
29471
  }
29354
29472
  };
29355
29473
  };
29356
- var TextElement = (0, import_react54.forwardRef)(({ children, className, ...rest }, ref) => {
29474
+ var TextElement = (0, import_react55.forwardRef)(({ children, className, ...rest }, ref) => {
29357
29475
  const props = resolveDesignProps9(rest);
29358
29476
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Element, { as: Flex, ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
29359
29477
  Text,
@@ -29368,7 +29486,7 @@ var TextElement = (0, import_react54.forwardRef)(({ children, className, ...rest
29368
29486
  TextElement.displayName = "Text";
29369
29487
 
29370
29488
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
29371
- var import_react55 = require("react");
29489
+ var import_react56 = require("react");
29372
29490
  var import_jsx_runtime70 = require("react/jsx-runtime");
29373
29491
  var buttonStyles = {
29374
29492
  primary: {
@@ -29395,11 +29513,11 @@ var resolveDesignProps10 = (props) => {
29395
29513
  }
29396
29514
  };
29397
29515
  };
29398
- var UnsubscribeButton = (0, import_react55.forwardRef)(({ children, className, ...rest }, ref) => {
29516
+ var UnsubscribeButton = (0, import_react56.forwardRef)(({ children, className, ...rest }, ref) => {
29399
29517
  const props = resolveDesignProps10(rest);
29400
29518
  const { t: t2 } = useTranslation();
29401
29519
  const { data, setLayout } = useEmbed();
29402
- const hasActiveSubscription = (0, import_react55.useMemo)(() => {
29520
+ const hasActiveSubscription = (0, import_react56.useMemo)(() => {
29403
29521
  return data?.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
29404
29522
  }, [data?.subscription]);
29405
29523
  if (!hasActiveSubscription) {
@@ -29434,7 +29552,7 @@ var UnsubscribeButton = (0, import_react55.forwardRef)(({ children, className, .
29434
29552
  UnsubscribeButton.displayName = "UnsubscribeButton";
29435
29553
 
29436
29554
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
29437
- var import_react56 = require("react");
29555
+ var import_react57 = require("react");
29438
29556
  var import_jsx_runtime71 = require("react/jsx-runtime");
29439
29557
  function resolveDesignProps11(props) {
29440
29558
  return {
@@ -29454,15 +29572,15 @@ function resolveDesignProps11(props) {
29454
29572
  }
29455
29573
  };
29456
29574
  }
29457
- var UpcomingBill = (0, import_react56.forwardRef)(({ className, ...rest }, ref) => {
29575
+ var UpcomingBill = (0, import_react57.forwardRef)(({ className, ...rest }, ref) => {
29458
29576
  const props = resolveDesignProps11(rest);
29459
29577
  const { t: t2, locale } = useTranslation();
29460
29578
  const { data, settings, getUpcomingInvoice } = useEmbed();
29461
29579
  const isLightBackground = useIsLightBackground();
29462
- const [isLoading, setIsLoading] = (0, import_react56.useState)(false);
29463
- const [error, setError] = (0, import_react56.useState)();
29464
- const [upcomingInvoice, setUpcomingInvoice] = (0, import_react56.useState)(data?.upcomingInvoice);
29465
- const discounts = (0, import_react56.useMemo)(() => {
29580
+ const [isLoading, setIsLoading] = (0, import_react57.useState)(false);
29581
+ const [error, setError] = (0, import_react57.useState)();
29582
+ const [upcomingInvoice, setUpcomingInvoice] = (0, import_react57.useState)(data?.upcomingInvoice);
29583
+ const discounts = (0, import_react57.useMemo)(() => {
29466
29584
  return (data?.subscription?.discounts || []).filter(
29467
29585
  (discount) => (
29468
29586
  // Only surface discounts that are currently active and actually
@@ -29480,7 +29598,7 @@ var UpcomingBill = (0, import_react56.forwardRef)(({ className, ...rest }, ref)
29480
29598
  durationInMonths: discount.durationInMonths ?? void 0
29481
29599
  }));
29482
29600
  }, [data?.subscription?.discounts]);
29483
- const getInvoice = (0, import_react56.useCallback)(async () => {
29601
+ const getInvoice = (0, import_react57.useCallback)(async () => {
29484
29602
  if (data?.component?.id && data?.subscription && !data.subscription.cancelAt) {
29485
29603
  try {
29486
29604
  setError(void 0);
@@ -29496,15 +29614,15 @@ var UpcomingBill = (0, import_react56.forwardRef)(({ className, ...rest }, ref)
29496
29614
  }
29497
29615
  }
29498
29616
  }, [data?.component?.id, data?.subscription, getUpcomingInvoice]);
29499
- (0, import_react56.useEffect)(() => {
29617
+ (0, import_react57.useEffect)(() => {
29500
29618
  getInvoice();
29501
29619
  }, [getInvoice]);
29502
- (0, import_react56.useEffect)(() => {
29620
+ (0, import_react57.useEffect)(() => {
29503
29621
  if (data?.upcomingInvoice) {
29504
29622
  setUpcomingInvoice(data.upcomingInvoice);
29505
29623
  }
29506
29624
  }, [data?.upcomingInvoice]);
29507
- const { currency, applied, remaining } = (0, import_react56.useMemo)(() => {
29625
+ const { currency, applied, remaining } = (0, import_react57.useMemo)(() => {
29508
29626
  const currency2 = upcomingInvoice?.currency;
29509
29627
  const startingBalance = upcomingInvoice?.startingBalance ?? 0;
29510
29628
  const endingBalance = upcomingInvoice?.endingBalance ?? 0;
@@ -29518,6 +29636,7 @@ var UpcomingBill = (0, import_react56.forwardRef)(({ className, ...rest }, ref)
29518
29636
  upcomingInvoice?.endingBalance,
29519
29637
  upcomingInvoice?.subtotal
29520
29638
  ]);
29639
+ const { billDate, paymentDueDate } = useNextBillDate(upcomingInvoice ?? null);
29521
29640
  const hasApplied = applied > 0;
29522
29641
  const hasBalance = remaining > 0 || applied > 0;
29523
29642
  if (!data?.subscription || data.subscription.cancelAt) {
@@ -29549,10 +29668,21 @@ var UpcomingBill = (0, import_react56.forwardRef)(({ className, ...rest }, ref)
29549
29668
  ]
29550
29669
  }
29551
29670
  ) : !isLoading && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TransitionBox, { children: upcomingInvoice ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
29552
- props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Text, { display: props.header.fontStyle, children: [
29553
- t2(props.header.prefix),
29554
- " ",
29555
- toPrettyDate(upcomingInvoice.dueDate, { locale })
29671
+ props.header.isVisible && upcomingInvoice.dueDate && billDate && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Flex, { $flexDirection: "column", $gap: "0.25rem", children: [
29672
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Text, { display: props.header.fontStyle, children: [
29673
+ t2(props.header.prefix),
29674
+ " ",
29675
+ toPrettyDate(billDate, { locale })
29676
+ ] }),
29677
+ paymentDueDate && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
29678
+ Text,
29679
+ {
29680
+ $size: 0.8125 * settings.theme.typography.text.fontSize,
29681
+ children: t2("Payment due", {
29682
+ date: toPrettyDate(paymentDueDate, { locale })
29683
+ })
29684
+ }
29685
+ )
29556
29686
  ] }),
29557
29687
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
29558
29688
  Flex,
@@ -32294,11 +32424,11 @@ function inflate(input, options = {}) {
32294
32424
  }
32295
32425
 
32296
32426
  // src/components/embed/Embed.tsx
32297
- var import_react58 = require("react");
32427
+ var import_react59 = require("react");
32298
32428
  var import_styled_components23 = __toESM(require_styled_components_cjs());
32299
32429
 
32300
32430
  // src/components/embed/renderer.ts
32301
- var import_react57 = require("react");
32431
+ var import_react58 = require("react");
32302
32432
  var components = {
32303
32433
  Root,
32304
32434
  Viewport,
@@ -32362,7 +32492,7 @@ function createRenderer(options) {
32362
32492
  const { className, ...rest } = props;
32363
32493
  const resolvedProps = component === "div" ? rest : props;
32364
32494
  const resolvedChildren = children.map(renderNode);
32365
- return (0, import_react57.createElement)(
32495
+ return (0, import_react58.createElement)(
32366
32496
  component,
32367
32497
  {
32368
32498
  key: index,
@@ -32412,7 +32542,7 @@ var Error2 = ({ message }) => {
32412
32542
  );
32413
32543
  };
32414
32544
  var SchematicEmbed = ({ id, accessToken }) => {
32415
- const theme = (0, import_react58.useContext)(import_styled_components23.ThemeContext);
32545
+ const theme = (0, import_react59.useContext)(import_styled_components23.ThemeContext);
32416
32546
  const { t: t2 } = useTranslation();
32417
32547
  const {
32418
32548
  data,
@@ -32425,7 +32555,7 @@ var SchematicEmbed = ({ id, accessToken }) => {
32425
32555
  setBuilderSettings
32426
32556
  } = useEmbed();
32427
32557
  const compressedAst = data?.component?.ast;
32428
- const { children, parsedSettings, parseError } = (0, import_react58.useMemo)(() => {
32558
+ const { children, parsedSettings, parseError } = (0, import_react59.useMemo)(() => {
32429
32559
  let children2 = null;
32430
32560
  let parsedSettings2 = null;
32431
32561
  let parseError2 = null;
@@ -32457,22 +32587,22 @@ var SchematicEmbed = ({ id, accessToken }) => {
32457
32587
  parseError: parseError2
32458
32588
  };
32459
32589
  }, [compressedAst]);
32460
- (0, import_react58.useEffect)(() => {
32590
+ (0, import_react59.useEffect)(() => {
32461
32591
  if (accessToken) {
32462
32592
  setAccessToken(accessToken);
32463
32593
  }
32464
32594
  }, [accessToken, setAccessToken]);
32465
- (0, import_react58.useEffect)(() => {
32595
+ (0, import_react59.useEffect)(() => {
32466
32596
  if (id && stale) {
32467
32597
  hydrateComponent(id);
32468
32598
  }
32469
32599
  }, [id, hydrateComponent, stale]);
32470
- (0, import_react58.useEffect)(() => {
32600
+ (0, import_react59.useEffect)(() => {
32471
32601
  if (parsedSettings) {
32472
32602
  setBuilderSettings(parsedSettings);
32473
32603
  }
32474
32604
  }, [parsedSettings, setBuilderSettings]);
32475
- (0, import_react58.useEffect)(() => {
32605
+ (0, import_react59.useEffect)(() => {
32476
32606
  if (parseError) {
32477
32607
  setError(parseError);
32478
32608
  }