@schematichq/schematic-components 2.1.0 → 2.1.2

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.
@@ -4321,6 +4321,7 @@ var initialContext = {
4321
4321
  setAccessToken: stub,
4322
4322
  setLayout: stub,
4323
4323
  setCheckoutState: stub,
4324
+ initializeWithPlan: stub,
4324
4325
  setData: stub,
4325
4326
  updateSettings: stub,
4326
4327
  debug: stub,
@@ -6443,7 +6444,9 @@ var I18n = class _I18n extends EventEmitter {
6443
6444
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
6444
6445
  }
6445
6446
  static createInstance(options = {}, callback) {
6446
- return new _I18n(options, callback);
6447
+ const instance2 = new _I18n(options, callback);
6448
+ instance2.createInstance = _I18n.createInstance;
6449
+ return instance2;
6447
6450
  }
6448
6451
  cloneInstance(options = {}, callback = noop) {
6449
6452
  const forkResourceStore = options.forkResourceStore;
@@ -6507,7 +6510,6 @@ var I18n = class _I18n extends EventEmitter {
6507
6510
  }
6508
6511
  };
6509
6512
  var instance = I18n.createInstance();
6510
- instance.createInstance = I18n.createInstance;
6511
6513
  var createInstance = instance.createInstance;
6512
6514
  var dir = instance.dir;
6513
6515
  var init = instance.init;
@@ -8057,6 +8059,13 @@ function BillingPlanCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminat
8057
8059
  return json;
8058
8060
  }
8059
8061
  return {
8062
+ autoTopupAmount: json["auto_topup_amount"] == null ? void 0 : json["auto_topup_amount"],
8063
+ autoTopupAmountType: json["auto_topup_amount_type"] == null ? void 0 : json["auto_topup_amount_type"],
8064
+ autoTopupEnabled: json["auto_topup_enabled"],
8065
+ autoTopupExpiryType: json["auto_topup_expiry_type"] == null ? void 0 : json["auto_topup_expiry_type"],
8066
+ autoTopupExpiryUnit: json["auto_topup_expiry_unit"] == null ? void 0 : json["auto_topup_expiry_unit"],
8067
+ autoTopupExpiryUnitCount: json["auto_topup_expiry_unit_count"] == null ? void 0 : json["auto_topup_expiry_unit_count"],
8068
+ autoTopupThresholdPercent: json["auto_topup_threshold_percent"] == null ? void 0 : json["auto_topup_threshold_percent"],
8060
8069
  createdAt: new Date(json["created_at"]),
8061
8070
  creditAmount: json["credit_amount"],
8062
8071
  creditId: json["credit_id"],
@@ -8283,6 +8292,7 @@ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
8283
8292
  return json;
8284
8293
  }
8285
8294
  return {
8295
+ applicationId: json["application_id"] == null ? void 0 : json["application_id"],
8286
8296
  cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
8287
8297
  cancelAtPeriodEnd: json["cancel_at_period_end"],
8288
8298
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
@@ -8378,6 +8388,7 @@ function CheckoutResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8378
8388
  return json;
8379
8389
  }
8380
8390
  return {
8391
+ applicationId: json["application_id"] == null ? void 0 : json["application_id"],
8381
8392
  cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
8382
8393
  cancelAtPeriodEnd: json["cancel_at_period_end"],
8383
8394
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
@@ -8492,6 +8503,43 @@ function CompanyEventPeriodMetricsResponseDataFromJSONTyped(json, ignoreDiscrimi
8492
8503
  };
8493
8504
  }
8494
8505
 
8506
+ // src/api/checkoutexternal/models/PlanCreditGrantView.ts
8507
+ function PlanCreditGrantViewFromJSON(json) {
8508
+ return PlanCreditGrantViewFromJSONTyped(json, false);
8509
+ }
8510
+ function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
8511
+ if (json == null) {
8512
+ return json;
8513
+ }
8514
+ return {
8515
+ billingCreditAutoTopupAmount: json["billing_credit_auto_topup_amount"] == null ? void 0 : json["billing_credit_auto_topup_amount"],
8516
+ billingCreditAutoTopupAmountType: json["billing_credit_auto_topup_amount_type"] == null ? void 0 : json["billing_credit_auto_topup_amount_type"],
8517
+ billingCreditAutoTopupEnabled: json["billing_credit_auto_topup_enabled"],
8518
+ billingCreditAutoTopupExpiryType: json["billing_credit_auto_topup_expiry_type"] == null ? void 0 : json["billing_credit_auto_topup_expiry_type"],
8519
+ billingCreditAutoTopupExpiryUnit: json["billing_credit_auto_topup_expiry_unit"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit"],
8520
+ billingCreditAutoTopupExpiryUnitCount: json["billing_credit_auto_topup_expiry_unit_count"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit_count"],
8521
+ billingCreditAutoTopupThresholdPercent: json["billing_credit_auto_topup_threshold_percent"] == null ? void 0 : json["billing_credit_auto_topup_threshold_percent"],
8522
+ createdAt: new Date(json["created_at"]),
8523
+ creditAmount: json["credit_amount"],
8524
+ creditDescription: json["credit_description"],
8525
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
8526
+ creditId: json["credit_id"],
8527
+ creditName: json["credit_name"],
8528
+ expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
8529
+ expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
8530
+ expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
8531
+ id: json["id"],
8532
+ planId: json["plan_id"],
8533
+ planName: json["plan_name"],
8534
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
8535
+ resetCadence: json["reset_cadence"],
8536
+ resetStart: json["reset_start"],
8537
+ resetType: json["reset_type"],
8538
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
8539
+ updatedAt: new Date(json["updated_at"])
8540
+ };
8541
+ }
8542
+
8495
8543
  // src/api/checkoutexternal/models/CompanyPlanWithBillingSubView.ts
8496
8544
  function CompanyPlanWithBillingSubViewFromJSON(json) {
8497
8545
  return CompanyPlanWithBillingSubViewFromJSONTyped(json, false);
@@ -8507,6 +8555,9 @@ function CompanyPlanWithBillingSubViewFromJSONTyped(json, ignoreDiscriminator) {
8507
8555
  description: json["description"] == null ? void 0 : json["description"],
8508
8556
  id: json["id"],
8509
8557
  imageUrl: json["image_url"] == null ? void 0 : json["image_url"],
8558
+ includedCreditGrants: json["included_credit_grants"].map(
8559
+ PlanCreditGrantViewFromJSON
8560
+ ),
8510
8561
  name: json["name"],
8511
8562
  planPeriod: json["plan_period"] == null ? void 0 : json["plan_period"],
8512
8563
  planPrice: json["plan_price"] == null ? void 0 : json["plan_price"]
@@ -8992,36 +9043,6 @@ function FeatureDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8992
9043
  };
8993
9044
  }
8994
9045
 
8995
- // src/api/checkoutexternal/models/PlanCreditGrantView.ts
8996
- function PlanCreditGrantViewFromJSON(json) {
8997
- return PlanCreditGrantViewFromJSONTyped(json, false);
8998
- }
8999
- function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
9000
- if (json == null) {
9001
- return json;
9002
- }
9003
- return {
9004
- createdAt: new Date(json["created_at"]),
9005
- creditAmount: json["credit_amount"],
9006
- creditDescription: json["credit_description"],
9007
- creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
9008
- creditId: json["credit_id"],
9009
- creditName: json["credit_name"],
9010
- expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
9011
- expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
9012
- expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
9013
- id: json["id"],
9014
- planId: json["plan_id"],
9015
- planName: json["plan_name"],
9016
- pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
9017
- resetCadence: json["reset_cadence"],
9018
- resetStart: json["reset_start"],
9019
- resetType: json["reset_type"],
9020
- singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
9021
- updatedAt: new Date(json["updated_at"])
9022
- };
9023
- }
9024
-
9025
9046
  // src/api/checkoutexternal/models/PlanResponseData.ts
9026
9047
  function PlanResponseDataFromJSON(json) {
9027
9048
  return PlanResponseDataFromJSONTyped(json, false);
@@ -10876,13 +10897,20 @@ function FeatureDetailResponseDataFromJSONTyped6(json, ignoreDiscriminator) {
10876
10897
 
10877
10898
  // src/api/componentspublic/models/PlanCreditGrantView.ts
10878
10899
  function PlanCreditGrantViewFromJSON2(json) {
10879
- return PlanCreditGrantViewFromJSONTyped3(json, false);
10900
+ return PlanCreditGrantViewFromJSONTyped4(json, false);
10880
10901
  }
10881
- function PlanCreditGrantViewFromJSONTyped3(json, ignoreDiscriminator) {
10902
+ function PlanCreditGrantViewFromJSONTyped4(json, ignoreDiscriminator) {
10882
10903
  if (json == null) {
10883
10904
  return json;
10884
10905
  }
10885
10906
  return {
10907
+ billingCreditAutoTopupAmount: json["billing_credit_auto_topup_amount"] == null ? void 0 : json["billing_credit_auto_topup_amount"],
10908
+ billingCreditAutoTopupAmountType: json["billing_credit_auto_topup_amount_type"] == null ? void 0 : json["billing_credit_auto_topup_amount_type"],
10909
+ billingCreditAutoTopupEnabled: json["billing_credit_auto_topup_enabled"],
10910
+ billingCreditAutoTopupExpiryType: json["billing_credit_auto_topup_expiry_type"] == null ? void 0 : json["billing_credit_auto_topup_expiry_type"],
10911
+ billingCreditAutoTopupExpiryUnit: json["billing_credit_auto_topup_expiry_unit"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit"],
10912
+ billingCreditAutoTopupExpiryUnitCount: json["billing_credit_auto_topup_expiry_unit_count"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit_count"],
10913
+ billingCreditAutoTopupThresholdPercent: json["billing_credit_auto_topup_threshold_percent"] == null ? void 0 : json["billing_credit_auto_topup_threshold_percent"],
10886
10914
  createdAt: new Date(json["created_at"]),
10887
10915
  creditAmount: json["credit_amount"],
10888
10916
  creditDescription: json["credit_description"],
@@ -11233,13 +11261,23 @@ var reducer = (state, action) => {
11233
11261
  checkoutState: { ...action.state }
11234
11262
  };
11235
11263
  }
11264
+ case "SET_PLANID_BYPASS": {
11265
+ return {
11266
+ ...state,
11267
+ layout: "checkout",
11268
+ checkoutState: {
11269
+ planId: action.planId,
11270
+ bypassPlanSelection: true
11271
+ }
11272
+ };
11273
+ }
11236
11274
  }
11237
11275
  };
11238
11276
 
11239
11277
  // src/context/EmbedProvider.tsx
11240
11278
  var import_jsx_runtime2 = require("react/jsx-runtime");
11241
11279
  var getCustomHeaders = (sessionId) => ({
11242
- "X-Schematic-Components-Version": "2.1.0",
11280
+ "X-Schematic-Components-Version": "2.1.2",
11243
11281
  "X-Schematic-Session-ID": sessionId
11244
11282
  });
11245
11283
  var EmbedProvider = ({
@@ -11531,6 +11569,9 @@ var EmbedProvider = ({
11531
11569
  const setCheckoutState = (0, import_react15.useCallback)((state2) => {
11532
11570
  dispatch({ type: "SET_CHECKOUT_STATE", state: state2 });
11533
11571
  }, []);
11572
+ const initializeWithPlan = (0, import_react15.useCallback)((planId) => {
11573
+ dispatch({ type: "SET_PLANID_BYPASS", planId });
11574
+ }, []);
11534
11575
  (0, import_react15.useEffect)(() => {
11535
11576
  const element = document.getElementById(
11536
11577
  "schematic-fonts"
@@ -11653,6 +11694,7 @@ var EmbedProvider = ({
11653
11694
  setAccessToken,
11654
11695
  setLayout,
11655
11696
  setCheckoutState,
11697
+ initializeWithPlan,
11656
11698
  setData,
11657
11699
  updateSettings,
11658
11700
  debug
@@ -12381,12 +12423,13 @@ var import_react22 = require("react");
12381
12423
  // src/components/ui/modal/styles.ts
12382
12424
  var Overlay = dt(Box)`
12383
12425
  position: absolute;
12384
- top: 50%;
12385
- left: 50%;
12426
+ top: 0;
12427
+ right: 0;
12428
+ bottom: 0;
12429
+ left: 0;
12386
12430
  z-index: 999999;
12387
- transform: translate(-50%, -50%);
12388
12431
  width: 100%;
12389
- height: 100%;
12432
+ height: 100dvh;
12390
12433
  overflow: hidden;
12391
12434
  scrollbar-width: thin;
12392
12435
  scrollbar-gutter: stable both-edges;
@@ -12403,7 +12446,7 @@ var Modal = dt.div.attrs({
12403
12446
  flex-direction: column;
12404
12447
  width: 100%;
12405
12448
  height: fit-content;
12406
- max-height: 100vh;
12449
+ max-height: 100dvh;
12407
12450
  overflow: auto;
12408
12451
  background-color: ${({ theme }) => theme.card.background};
12409
12452
  box-shadow:
@@ -12485,7 +12528,7 @@ var ModalContent = (0, import_react23.forwardRef)(({ children }, ref) => {
12485
12528
  md: {
12486
12529
  $flexDirection: "row",
12487
12530
  $height: "calc(100% - 5rem + 3px)",
12488
- $maxHeight: "calc(100vh - 5rem + 3px)"
12531
+ $maxHeight: "calc(100dvh - 5rem + 3px)"
12489
12532
  }
12490
12533
  },
12491
12534
  children
@@ -13036,7 +13079,7 @@ Root.displayName = "Root";
13036
13079
  // src/components/layout/viewport/Viewport.tsx
13037
13080
  var import_debounce3 = __toESM(require_debounce());
13038
13081
  var import_react42 = require("react");
13039
- var import_react_dom2 = require("react-dom");
13082
+ var import_react_dom3 = require("react-dom");
13040
13083
 
13041
13084
  // src/components/shared/billing-threshold-tooltip/BillingThresholdTooltip.tsx
13042
13085
  var import_jsx_runtime12 = require("react/jsx-runtime");
@@ -13072,6 +13115,7 @@ var import_react34 = require("react");
13072
13115
 
13073
13116
  // src/components/shared/sidebar/Sidebar.tsx
13074
13117
  var import_react31 = require("react");
13118
+ var import_react_dom2 = require("react-dom");
13075
13119
 
13076
13120
  // src/components/shared/sidebar/EntitlementRow.tsx
13077
13121
  var import_jsx_runtime13 = require("react/jsx-runtime");
@@ -13194,6 +13238,7 @@ var import_jsx_runtime15 = require("react/jsx-runtime");
13194
13238
  var NoPaymentRequired = ({
13195
13239
  isDisabled,
13196
13240
  isLoading,
13241
+ isSticky,
13197
13242
  onClick
13198
13243
  }) => {
13199
13244
  const { t: t2 } = useTranslation();
@@ -13204,6 +13249,7 @@ var NoPaymentRequired = ({
13204
13249
  disabled: isDisabled,
13205
13250
  onClick,
13206
13251
  $isLoading: isLoading,
13252
+ $size: isSticky ? "sm" : "md",
13207
13253
  $fullWidth: true,
13208
13254
  children: t2("Subscribe and close")
13209
13255
  }
@@ -13220,6 +13266,7 @@ var StageButton = ({
13220
13266
  hasPlan,
13221
13267
  inEditMode,
13222
13268
  isLoading,
13269
+ isSticky,
13223
13270
  isPaymentMethodRequired,
13224
13271
  isSelectedPlanTrialable,
13225
13272
  setCheckoutStage,
@@ -13267,7 +13314,8 @@ var StageButton = ({
13267
13314
  {
13268
13315
  isDisabled,
13269
13316
  isLoading,
13270
- onClick: checkout
13317
+ onClick: checkout,
13318
+ isSticky
13271
13319
  }
13272
13320
  );
13273
13321
  }
@@ -13283,6 +13331,7 @@ var StageButton = ({
13283
13331
  },
13284
13332
  $isLoading: isLoading,
13285
13333
  $fullWidth: true,
13334
+ $size: isSticky ? "sm" : "md",
13286
13335
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Flex, { $gap: "0.5rem", $justifyContent: "center", $alignItems: "center", children: [
13287
13336
  t2("Next"),
13288
13337
  ":",
@@ -13302,7 +13351,8 @@ var StageButton = ({
13302
13351
  {
13303
13352
  isDisabled,
13304
13353
  isLoading,
13305
- onClick: checkout
13354
+ onClick: checkout,
13355
+ isSticky
13306
13356
  }
13307
13357
  );
13308
13358
  }
@@ -13318,6 +13368,7 @@ var StageButton = ({
13318
13368
  },
13319
13369
  $isLoading: isLoading,
13320
13370
  $fullWidth: true,
13371
+ $size: isSticky ? "sm" : "md",
13321
13372
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
13322
13373
  Flex,
13323
13374
  {
@@ -13350,7 +13401,8 @@ var StageButton = ({
13350
13401
  {
13351
13402
  isDisabled,
13352
13403
  isLoading,
13353
- onClick: checkout
13404
+ onClick: checkout,
13405
+ isSticky
13354
13406
  }
13355
13407
  );
13356
13408
  }
@@ -13392,7 +13444,8 @@ var StageButton = ({
13392
13444
  {
13393
13445
  isDisabled,
13394
13446
  isLoading,
13395
- onClick: checkout
13447
+ onClick: checkout,
13448
+ isSticky
13396
13449
  }
13397
13450
  );
13398
13451
  }
@@ -13406,6 +13459,7 @@ var StageButton = ({
13406
13459
  },
13407
13460
  $isLoading: isLoading,
13408
13461
  $fullWidth: true,
13462
+ $size: isSticky ? "sm" : "md",
13409
13463
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
13410
13464
  Flex,
13411
13465
  {
@@ -13431,7 +13485,8 @@ var StageButton = ({
13431
13485
  {
13432
13486
  isDisabled,
13433
13487
  isLoading,
13434
- onClick: checkout
13488
+ onClick: checkout,
13489
+ isSticky
13435
13490
  }
13436
13491
  );
13437
13492
  }
@@ -13470,7 +13525,8 @@ var StageButton = ({
13470
13525
  {
13471
13526
  isDisabled,
13472
13527
  isLoading,
13473
- onClick: checkout
13528
+ onClick: checkout,
13529
+ isSticky
13474
13530
  }
13475
13531
  );
13476
13532
  }
@@ -13842,6 +13898,42 @@ var Sidebar = (0, import_react31.forwardRef)(
13842
13898
  trialEndsOn.setDate(trialEndsOn.getDate() + selectedPlan.trialDays);
13843
13899
  }
13844
13900
  const { price: selectedPlanPrice, currency: selectedPlanCurrency } = selectedPlan ? getPlanPrice(selectedPlan, planPeriod) || {} : {};
13901
+ const buttonRef = (0, import_react31.useRef)(null);
13902
+ const [checkoutButtonInView, setCheckoutButtonInView] = (0, import_react31.useState)(false);
13903
+ (0, import_react31.useEffect)(() => {
13904
+ const observer = new IntersectionObserver(
13905
+ ([entry]) => setCheckoutButtonInView(entry.isIntersecting),
13906
+ { threshold: 0 }
13907
+ );
13908
+ if (buttonRef.current) {
13909
+ observer.observe(buttonRef.current);
13910
+ }
13911
+ return () => observer.disconnect();
13912
+ }, []);
13913
+ const StageButtonComponent = () => {
13914
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
13915
+ StageButton,
13916
+ {
13917
+ checkout: handleCheckout,
13918
+ checkoutStage,
13919
+ checkoutStages,
13920
+ hasAddOns: addOns.length > 0,
13921
+ hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
13922
+ hasCreditBundles: creditBundles.length > 0,
13923
+ hasPaymentMethod: typeof paymentMethod !== "undefined" || typeof paymentMethodId === "string",
13924
+ hasPlan: typeof selectedPlan !== "undefined",
13925
+ inEditMode: settings.mode === "edit",
13926
+ isLoading,
13927
+ isPaymentMethodRequired,
13928
+ isSelectedPlanTrialable,
13929
+ isSticky: !checkoutButtonInView,
13930
+ setCheckoutStage,
13931
+ trialPaymentMethodRequired,
13932
+ shouldTrial,
13933
+ willTrialWithoutPaymentMethod
13934
+ }
13935
+ );
13936
+ };
13845
13937
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
13846
13938
  Flex,
13847
13939
  {
@@ -14327,27 +14419,42 @@ var Sidebar = (0, import_react31.forwardRef)(
14327
14419
  ] }) }),
14328
14420
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { children: formatCurrency(Math.abs(dueNow), selectedPlanCurrency) }) })
14329
14421
  ] }),
14330
- layout === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14331
- StageButton,
14332
- {
14333
- checkout: handleCheckout,
14334
- checkoutStage,
14335
- checkoutStages,
14336
- hasAddOns: addOns.length > 0,
14337
- hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
14338
- hasCreditBundles: creditBundles.length > 0,
14339
- hasPaymentMethod: typeof paymentMethod !== "undefined" || typeof paymentMethodId === "string",
14340
- hasPlan: typeof selectedPlan !== "undefined",
14341
- inEditMode: settings.mode === "edit",
14342
- isLoading,
14343
- isPaymentMethodRequired,
14344
- isSelectedPlanTrialable,
14345
- setCheckoutStage,
14346
- trialPaymentMethodRequired,
14347
- shouldTrial,
14348
- willTrialWithoutPaymentMethod
14349
- }
14350
- ),
14422
+ layout === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { ref: buttonRef, children: [
14423
+ checkoutButtonInView && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(StageButtonComponent, {}),
14424
+ !checkoutButtonInView && (0, import_react_dom2.createPortal)(
14425
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14426
+ "div",
14427
+ {
14428
+ style: {
14429
+ position: "fixed",
14430
+ bottom: "-1px",
14431
+ left: "0px",
14432
+ zIndex: 9999999,
14433
+ width: "100%",
14434
+ overflow: "hidden",
14435
+ backgroundColor: settings.theme.card.background,
14436
+ borderTopWidth: "1px",
14437
+ borderTopStyle: "solid",
14438
+ borderTopColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)"
14439
+ },
14440
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14441
+ "div",
14442
+ {
14443
+ style: {
14444
+ display: "flex",
14445
+ justifyContent: "center",
14446
+ alignItems: "center",
14447
+ padding: "1rem 1.5rem",
14448
+ backgroundColor: settings.theme.card.background
14449
+ },
14450
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(StageButtonComponent, {})
14451
+ }
14452
+ )
14453
+ }
14454
+ ),
14455
+ document.body
14456
+ )
14457
+ ] }),
14351
14458
  layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14352
14459
  Button,
14353
14460
  {
@@ -15780,6 +15887,7 @@ var CheckoutDialog = ({ top = 0 }) => {
15780
15887
  creditBundles,
15781
15888
  isPaymentMethodRequired
15782
15889
  ]);
15890
+ const [hasSkippedInitialPlan, setHasSkippedInitialPlan] = (0, import_react34.useState)(false);
15783
15891
  const [checkoutStage, setCheckoutStage] = (0, import_react34.useState)(() => {
15784
15892
  if (checkoutState?.addOnId) {
15785
15893
  return "addons";
@@ -15793,11 +15901,25 @@ var CheckoutDialog = ({ top = 0 }) => {
15793
15901
  if (checkoutState?.credits) {
15794
15902
  return "credits";
15795
15903
  }
15796
- if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId) {
15797
- return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : "plan";
15904
+ if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId || checkoutState?.bypassPlanSelection) {
15905
+ return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : checkoutStages.some((stage) => stage.id === "checkout") ? "checkout" : checkoutStages[0]?.id || "plan";
15798
15906
  }
15799
15907
  return "plan";
15800
15908
  });
15909
+ (0, import_react34.useEffect)(() => {
15910
+ if (checkoutState?.bypassPlanSelection && checkoutStage === "plan" && !hasSkippedInitialPlan) {
15911
+ const nextStage = checkoutStages.find((stage) => stage.id !== "plan");
15912
+ if (nextStage) {
15913
+ setHasSkippedInitialPlan(true);
15914
+ setCheckoutStage(nextStage.id);
15915
+ }
15916
+ }
15917
+ }, [
15918
+ checkoutStages,
15919
+ checkoutState?.bypassPlanSelection,
15920
+ checkoutStage,
15921
+ hasSkippedInitialPlan
15922
+ ]);
15801
15923
  const handlePreviewCheckout = (0, import_react34.useCallback)(
15802
15924
  async (updates) => {
15803
15925
  const period = updates.period || planPeriod;
@@ -15925,14 +16047,19 @@ var CheckoutDialog = ({ top = 0 }) => {
15925
16047
  const selectPlan = (0, import_react34.useCallback)(
15926
16048
  (updates) => {
15927
16049
  const plan = updates.plan;
15928
- const period = updates.period || planPeriod;
16050
+ const period = showPeriodToggle ? updates.period || planPeriod : plan.yearlyPrice && !plan.monthlyPrice ? "year" /* Year */ : "month" /* Month */;
15929
16051
  const updatedUsageBasedEntitlements = plan.entitlements.reduce(
15930
16052
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, period),
15931
16053
  []
15932
16054
  );
16055
+ if (period !== planPeriod || plan.id !== selectedPlan?.id) {
16056
+ setUsageBasedEntitlements(updatedUsageBasedEntitlements);
16057
+ }
16058
+ if (period !== planPeriod) {
16059
+ setPlanPeriod(period);
16060
+ }
15933
16061
  if (plan.id !== selectedPlan?.id) {
15934
16062
  setSelectedPlan(plan);
15935
- setUsageBasedEntitlements(updatedUsageBasedEntitlements);
15936
16063
  }
15937
16064
  const updatedShouldTrial = updates.shouldTrial ?? shouldTrial;
15938
16065
  setShouldTrial(updatedShouldTrial);
@@ -15961,6 +16088,7 @@ var CheckoutDialog = ({ top = 0 }) => {
15961
16088
  [
15962
16089
  selectedPlan?.id,
15963
16090
  planPeriod,
16091
+ showPeriodToggle,
15964
16092
  currentEntitlements,
15965
16093
  shouldTrial,
15966
16094
  willTrialWithoutPaymentMethod,
@@ -16066,11 +16194,28 @@ var CheckoutDialog = ({ top = 0 }) => {
16066
16194
  }
16067
16195
  }, []);
16068
16196
  (0, import_react34.useEffect)(() => {
16069
- const plan = availablePlans.find(
16070
- (plan2) => checkoutState?.planId ? plan2.id === checkoutState.planId : plan2.current
16071
- );
16072
- setSelectedPlan(plan);
16197
+ if (checkoutState?.planId) {
16198
+ const plan = availablePlans.find(
16199
+ (plan2) => plan2.id === checkoutState.planId
16200
+ );
16201
+ setSelectedPlan(plan);
16202
+ }
16073
16203
  }, [availablePlans, checkoutState?.planId]);
16204
+ (0, import_react34.useEffect)(() => {
16205
+ if (checkoutState?.addOnId) {
16206
+ const checkoutStateAddOn = availableAddOns.find(
16207
+ (addOn) => addOn.id === checkoutState.addOnId
16208
+ );
16209
+ setAddOns(
16210
+ (prev2) => prev2.map((addOn) => ({
16211
+ ...addOn,
16212
+ ...addOn.id === checkoutStateAddOn?.id && {
16213
+ isSelected: true
16214
+ }
16215
+ }))
16216
+ );
16217
+ }
16218
+ }, [availableAddOns, checkoutState?.addOnId]);
16074
16219
  (0, import_react34.useEffect)(() => {
16075
16220
  setAddOns((prevAddOns) => {
16076
16221
  return availableAddOns.filter((availAddOn) => {
@@ -16112,7 +16257,30 @@ var CheckoutDialog = ({ top = 0 }) => {
16112
16257
  const activeCheckoutStage = checkoutStages.find(
16113
16258
  (stage) => stage.id === checkoutStage
16114
16259
  );
16260
+ const shouldShowBypassOverlay = checkoutState?.bypassPlanSelection && checkoutStage === "plan" && !hasSkippedInitialPlan;
16115
16261
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Modal2, { ref: modalRef, size: "lg", top, children: [
16262
+ shouldShowBypassOverlay && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
16263
+ Flex,
16264
+ {
16265
+ $position: "absolute",
16266
+ $top: 0,
16267
+ $left: 0,
16268
+ $zIndex: 3,
16269
+ $width: "100%",
16270
+ $height: "100dvh",
16271
+ $justifyContent: "center",
16272
+ $alignItems: "center",
16273
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 100%, 0.9)" : "hsla(0, 0%, 0%, 0.9)",
16274
+ $backdropFilter: "blur(8px)",
16275
+ $padding: "1rem",
16276
+ $viewport: {
16277
+ md: {
16278
+ $padding: "1.5rem"
16279
+ }
16280
+ },
16281
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader, { $color: settings.theme.primary, $size: "2xl" })
16282
+ }
16283
+ ),
16116
16284
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ModalHeader, { bordered: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
16117
16285
  Flex,
16118
16286
  {
@@ -16502,7 +16670,6 @@ var PeriodToggle = ({
16502
16670
  const yearly = yearlyBillingPrice?.price ?? 0;
16503
16671
  return Math.round((monthly - yearly) / monthly * 1e4) / 100;
16504
16672
  }
16505
- return 0;
16506
16673
  }, [selectedPlan]);
16507
16674
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
16508
16675
  Flex,
@@ -16557,7 +16724,7 @@ var PeriodToggle = ({
16557
16724
  },
16558
16725
  option
16559
16726
  );
16560
- if (option === "year") {
16727
+ if (option === "year" && typeof savingsPercentage === "number") {
16561
16728
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
16562
16729
  Tooltip,
16563
16730
  {
@@ -17106,12 +17273,12 @@ var Viewport = (0, import_react42.forwardRef)(
17106
17273
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RenderLayout, { children }),
17107
17274
  isBadgeVisible && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, {})
17108
17275
  ] }),
17109
- canCheckout && layout === "checkout" && (0, import_react_dom2.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CheckoutDialog, { top }), portal || document.body),
17110
- layout === "unsubscribe" && (0, import_react_dom2.createPortal)(
17276
+ canCheckout && layout === "checkout" && (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CheckoutDialog, { top }), portal || document.body),
17277
+ layout === "unsubscribe" && (0, import_react_dom3.createPortal)(
17111
17278
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(UnsubscribeDialog, { top }),
17112
17279
  portal || document.body
17113
17280
  ),
17114
- layout === "payment" && (0, import_react_dom2.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(PaymentDialog, { top }), portal || document.body)
17281
+ layout === "payment" && (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(PaymentDialog, { top }), portal || document.body)
17115
17282
  ] });
17116
17283
  }
17117
17284
  );
@@ -18506,7 +18673,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
18506
18673
  }
18507
18674
  stripe._registerWrapper({
18508
18675
  name: "stripe-js",
18509
- version: "8.2.0",
18676
+ version: "8.3.0",
18510
18677
  startTime
18511
18678
  });
18512
18679
  };
@@ -18581,7 +18748,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
18581
18748
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
18582
18749
  var expectedVersion = RELEASE_TRAIN;
18583
18750
  if (isTestKey && version !== expectedVersion) {
18584
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
18751
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.3.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
18585
18752
  }
18586
18753
  var stripe = maybeStripe.apply(void 0, args);
18587
18754
  registerWrapper(stripe, startTime);
@@ -19112,7 +19279,7 @@ var resolveDesignProps7 = (props) => {
19112
19279
  var PlanManager = (0, import_react52.forwardRef)(({ children, className, portal, ...rest }, ref) => {
19113
19280
  const props = resolveDesignProps7(rest);
19114
19281
  const { t: t2 } = useTranslation();
19115
- const { data, settings, setCheckoutState } = useEmbed();
19282
+ const { data, settings, setLayout } = useEmbed();
19116
19283
  const isLightBackground = useIsLightBackground();
19117
19284
  const trialEnd = useTrialEnd();
19118
19285
  const {
@@ -19473,11 +19640,7 @@ var PlanManager = (0, import_react52.forwardRef)(({ children, className, portal,
19473
19640
  {
19474
19641
  type: "button",
19475
19642
  onClick: () => {
19476
- setCheckoutState({
19477
- planId: currentPlan?.id,
19478
- addOnId: void 0,
19479
- usage: false
19480
- });
19643
+ setLayout("checkout");
19481
19644
  },
19482
19645
  $size: props.callToAction.buttonSize,
19483
19646
  $color: props.callToAction.buttonStyle,
@@ -20310,25 +20473,9 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20310
20473
  },
20311
20474
  []
20312
20475
  );
20313
- const { currentPeriod, isStandalone } = (0, import_react55.useMemo)(() => {
20314
- const isStandalone2 = typeof data?.component === "undefined";
20315
- return {
20316
- currentPeriod: data?.company?.plan?.planPeriod || "month",
20317
- currentAddOns: data?.company?.addOns || [],
20318
- canCheckout: isStandalone2 ?? data?.capabilities?.checkout ?? true,
20319
- isTrialSubscription: data?.company?.billingSubscription?.status === "trialing",
20320
- willSubscriptionCancel: data?.company?.billingSubscription?.cancelAt,
20321
- isStandalone: isStandalone2
20322
- };
20323
- }, [
20324
- data?.capabilities?.checkout,
20325
- data?.company?.addOns,
20326
- data?.company?.billingSubscription?.cancelAt,
20327
- data?.company?.billingSubscription?.status,
20328
- data?.company?.plan?.planPeriod,
20329
- data?.component
20330
- ]);
20331
- const [selectedPeriod, setSelectedPeriod] = (0, import_react55.useState)(currentPeriod);
20476
+ const [selectedPeriod, setSelectedPeriod] = (0, import_react55.useState)(
20477
+ () => data?.company?.plan?.planPeriod || "month"
20478
+ );
20332
20479
  const showPeriodToggle = rest.showPeriodToggle ?? data?.showPeriodToggle ?? true;
20333
20480
  const { plans, addOns, periods } = useAvailablePlans(selectedPeriod, {
20334
20481
  useSelectedPeriod: showPeriodToggle
@@ -20352,10 +20499,10 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20352
20499
  });
20353
20500
  };
20354
20501
  (0, import_react55.useEffect)(() => {
20355
- if (isStandalone) {
20502
+ if (typeof data?.component === "undefined") {
20356
20503
  hydratePublic();
20357
20504
  }
20358
- }, [isStandalone, hydratePublic]);
20505
+ }, [data?.component, hydratePublic]);
20359
20506
  (0, import_react55.useEffect)(() => {
20360
20507
  setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
20361
20508
  }, [plans]);
@@ -20372,12 +20519,13 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20372
20519
  }
20373
20520
  );
20374
20521
  }
20522
+ const currentPlan = plans.find((plan) => plan.id === data?.company?.plan?.id);
20375
20523
  const showCallToAction = typeof data?.component !== "undefined" || typeof rest.callToActionUrl === "string" || typeof rest.onCallToAction === "function";
20376
20524
  const callToActionTarget = getCallToActionTarget(
20377
20525
  rest.callToActionUrl,
20378
20526
  rest.callToActionTarget
20379
20527
  );
20380
- const Wrapper = isStandalone ? Container : import_react55.Fragment;
20528
+ const Wrapper = typeof data?.component === "undefined" ? Container : import_react55.Fragment;
20381
20529
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
20382
20530
  FussyChild,
20383
20531
  {
@@ -20410,6 +20558,7 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20410
20558
  {
20411
20559
  options: periods,
20412
20560
  selectedOption: selectedPeriod,
20561
+ selectedPlan: currentPlan,
20413
20562
  onSelect: (period) => {
20414
20563
  if (period !== selectedPeriod) {
20415
20564
  setSelectedPeriod(period);