@schematichq/schematic-components 0.7.13 → 0.7.14

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.
@@ -6745,9 +6745,9 @@ var unitlessKeys = {
6745
6745
  var f = "undefined" != typeof process && void 0 !== process.env && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled";
6746
6746
  var m = "active";
6747
6747
  var y = "data-styled-version";
6748
- var v = "6.1.17";
6748
+ var v = "6.1.18";
6749
6749
  var g = "/*!sc*/\n";
6750
- var S = "undefined" != typeof window && "HTMLElement" in window;
6750
+ var S = "undefined" != typeof window && "undefined" != typeof document;
6751
6751
  var w = Boolean("boolean" == typeof SC_DISABLE_SPEEDY ? SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.REACT_APP_SC_DISABLE_SPEEDY && "" !== process.env.REACT_APP_SC_DISABLE_SPEEDY ? "false" !== process.env.REACT_APP_SC_DISABLE_SPEEDY && process.env.REACT_APP_SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.SC_DISABLE_SPEEDY && "" !== process.env.SC_DISABLE_SPEEDY ? "false" !== process.env.SC_DISABLE_SPEEDY && process.env.SC_DISABLE_SPEEDY : true);
6752
6752
  var b = {};
6753
6753
  var E = /invalid hook call/i;
@@ -8166,13 +8166,14 @@ var Translator = class _Translator extends EventEmitter {
8166
8166
  if (lng) this.language = lng;
8167
8167
  }
8168
8168
  exists(key) {
8169
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
8169
+ let o2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
8170
8170
  interpolation: {}
8171
8171
  };
8172
- if (key == null) {
8173
- return false;
8174
- }
8175
- const resolved = this.resolve(key, options2);
8172
+ const opt = {
8173
+ ...o2
8174
+ };
8175
+ if (key == null) return false;
8176
+ const resolved = this.resolve(key, opt);
8176
8177
  return resolved?.res !== void 0;
8177
8178
  }
8178
8179
  extractFromKey(key, opt) {
@@ -8199,7 +8200,10 @@ var Translator = class _Translator extends EventEmitter {
8199
8200
  namespaces: isString(namespaces) ? [namespaces] : namespaces
8200
8201
  };
8201
8202
  }
8202
- translate(keys, opt, lastKey) {
8203
+ translate(keys, o2, lastKey) {
8204
+ let opt = typeof o2 === "object" ? {
8205
+ ...o2
8206
+ } : o2;
8203
8207
  if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
8204
8208
  opt = this.options.overloadTranslationOptionHandler(arguments);
8205
8209
  }
@@ -8377,7 +8381,7 @@ var Translator = class _Translator extends EventEmitter {
8377
8381
  res = this.extendTranslation(res, keys, opt, resolved, lastKey);
8378
8382
  if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
8379
8383
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
8380
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : void 0);
8384
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : void 0, opt);
8381
8385
  }
8382
8386
  }
8383
8387
  if (returnDetails) {
@@ -9658,7 +9662,7 @@ var I18n = class _I18n extends EventEmitter {
9658
9662
  }
9659
9663
  if (!this.resolvedLanguage && this.languages.indexOf(l2) < 0 && this.store.hasLanguageSomeTranslations(l2)) {
9660
9664
  this.resolvedLanguage = l2;
9661
- if (this.languages.indexOf(l2) < 0) this.languages.unshift(l2);
9665
+ this.languages.unshift(l2);
9662
9666
  }
9663
9667
  }
9664
9668
  changeLanguage(lng, callback) {
@@ -9872,12 +9876,13 @@ var I18n = class _I18n extends EventEmitter {
9872
9876
  prev2[l2] = {
9873
9877
  ...this.store.data[l2]
9874
9878
  };
9875
- return Object.keys(prev2[l2]).reduce((acc, n) => {
9879
+ prev2[l2] = Object.keys(prev2[l2]).reduce((acc, n) => {
9876
9880
  acc[n] = {
9877
9881
  ...prev2[l2][n]
9878
9882
  };
9879
9883
  return acc;
9880
- }, {});
9884
+ }, prev2[l2]);
9885
+ return prev2;
9881
9886
  }, {});
9882
9887
  clone.store = new ResourceStore(clonedData, mergedOptions);
9883
9888
  clone.services.resourceStore = clone.store;
@@ -14734,6 +14739,8 @@ function BillingPriceViewFromJSONTyped(json, ignoreDiscriminator) {
14734
14739
  id: json["id"],
14735
14740
  interval: json["interval"],
14736
14741
  isActive: json["is_active"],
14742
+ meterEventName: json["meter_event_name"] == null ? void 0 : json["meter_event_name"],
14743
+ meterEventPayloadKey: json["meter_event_payload_key"] == null ? void 0 : json["meter_event_payload_key"],
14737
14744
  meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
14738
14745
  packageSize: json["package_size"],
14739
14746
  price: json["price"],
@@ -15274,12 +15281,12 @@ function EventSummaryResponseDataFromJSONTyped(json, ignoreDiscriminator) {
15274
15281
  return json;
15275
15282
  }
15276
15283
  return {
15277
- companyCount: json["company_count"],
15284
+ companyCount: json["company_count"] == null ? void 0 : json["company_count"],
15278
15285
  environmentId: json["environment_id"],
15279
15286
  eventCount: json["event_count"],
15280
15287
  eventSubtype: json["event_subtype"],
15281
15288
  lastSeenAt: json["last_seen_at"] == null ? void 0 : new Date(json["last_seen_at"]),
15282
- userCount: json["user_count"]
15289
+ userCount: json["user_count"] == null ? void 0 : json["user_count"]
15283
15290
  };
15284
15291
  }
15285
15292
 
@@ -16426,6 +16433,7 @@ var en_default = {
16426
16433
  "Pay now": "Pay now",
16427
16434
  "Payment Method": "Payment Method",
16428
16435
  "Percent off": "{{percent}}% off",
16436
+ "Plan selected": "Plan selected",
16429
16437
  Plan: "Plan",
16430
16438
  Plans: "Plans",
16431
16439
  "Please provide an access token.": "Please provide an access token.",
@@ -16447,13 +16455,15 @@ var en_default = {
16447
16455
  "Session expired. Please refresh and try again.": "Session expired. Please refresh and try again.",
16448
16456
  "Show details": "Show details",
16449
16457
  "Start trial": "Start trial",
16458
+ "Start X day trial": "Start {{days}} day trial",
16450
16459
  "Subscribe and close": "Subscribe and close",
16451
16460
  "Subscription canceled": "Subscription canceled",
16452
16461
  Subscription: "Subscription",
16453
16462
  "Talk to support": "Talk to support",
16454
16463
  Total: "Total",
16455
16464
  "Trial ends in": "Trial ends in {{days}} days",
16456
- "Trial plan": "Try free for {{days}} days",
16465
+ "Trial in progress": "Trial in progress",
16466
+ "Trial selected": "Trial selected",
16457
16467
  Trial: "Trial",
16458
16468
  Unlimited: "Unlimited {{item}}",
16459
16469
  "Unsubscribe failed": "Unsubscribe failed",
@@ -17148,7 +17158,7 @@ var EmbedProvider = ({
17148
17158
  (0, import_react11.useEffect)(() => {
17149
17159
  if (accessToken) {
17150
17160
  const { headers = {} } = apiConfig ?? {};
17151
- headers["X-Schematic-Components-Version"] = "0.7.13";
17161
+ headers["X-Schematic-Components-Version"] = "0.7.14";
17152
17162
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
17153
17163
  const config = new Configuration({
17154
17164
  ...apiConfig,
@@ -17592,29 +17602,23 @@ var Button = dt.button(
17592
17602
  case "sm":
17593
17603
  return lt`
17594
17604
  font-size: ${15 / TEXT_BASE_SIZE}rem;
17595
- ${$variant !== "text" && lt`
17596
- height: ${40 / TEXT_BASE_SIZE}rem;
17597
- padding: ${7 / TEXT_BASE_SIZE}rem ${20 / TEXT_BASE_SIZE}rem;
17598
- border-radius: ${6 / TEXT_BASE_SIZE}rem;
17599
- `}
17605
+ height: ${40 / TEXT_BASE_SIZE}rem;
17606
+ padding: ${7 / TEXT_BASE_SIZE}rem ${20 / TEXT_BASE_SIZE}rem;
17607
+ border-radius: ${6 / TEXT_BASE_SIZE}rem;
17600
17608
  `;
17601
17609
  case "md":
17602
17610
  return lt`
17603
17611
  font-size: ${17 / TEXT_BASE_SIZE}rem;
17604
- ${$variant !== "text" && lt`
17605
- height: ${52 / TEXT_BASE_SIZE}rem;
17606
- padding: ${8 / TEXT_BASE_SIZE}rem ${24 / TEXT_BASE_SIZE}rem;
17607
- border-radius: ${8 / TEXT_BASE_SIZE}rem;
17608
- `}
17612
+ height: ${52 / TEXT_BASE_SIZE}rem;
17613
+ padding: ${8 / TEXT_BASE_SIZE}rem ${24 / TEXT_BASE_SIZE}rem;
17614
+ border-radius: ${8 / TEXT_BASE_SIZE}rem;
17609
17615
  `;
17610
17616
  case "lg":
17611
17617
  return lt`
17612
17618
  font-size: ${19 / TEXT_BASE_SIZE}rem;
17613
- ${$variant !== "text" && lt`
17614
- height: ${64 / TEXT_BASE_SIZE}rem;
17615
- padding: ${9 / TEXT_BASE_SIZE}rem ${28 / TEXT_BASE_SIZE}rem;
17616
- border-radius: ${10 / TEXT_BASE_SIZE}rem;
17617
- `}
17619
+ height: ${64 / TEXT_BASE_SIZE}rem;
17620
+ padding: ${9 / TEXT_BASE_SIZE}rem ${28 / TEXT_BASE_SIZE}rem;
17621
+ border-radius: ${10 / TEXT_BASE_SIZE}rem;
17618
17622
  `;
17619
17623
  }
17620
17624
  }}
@@ -18632,7 +18636,8 @@ var StageButton = ({
18632
18636
  isLoading,
18633
18637
  requiresPayment,
18634
18638
  setCheckoutStage,
18635
- trialPaymentMethodRequired
18639
+ trialPaymentMethodRequired,
18640
+ willTrial
18636
18641
  }) => {
18637
18642
  const { t: t2 } = useTranslation();
18638
18643
  const NoPaymentRequired = () => {
@@ -18648,42 +18653,14 @@ var StageButton = ({
18648
18653
  );
18649
18654
  };
18650
18655
  if (checkoutStage === "plan") {
18651
- if (canTrial) {
18652
- if (trialPaymentMethodRequired) {
18653
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
18654
- Button,
18655
- {
18656
- type: "button",
18657
- disabled: !hasAddOns && !canUpdateSubscription,
18658
- onClick: async () => {
18659
- setCheckoutStage?.("checkout");
18660
- },
18661
- $isLoading: isLoading,
18662
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
18663
- Flex,
18664
- {
18665
- $gap: "0.5rem",
18666
- $justifyContent: "center",
18667
- $alignItems: "center",
18668
- $padding: "0 1rem",
18669
- children: [
18670
- t2("Next"),
18671
- ": ",
18672
- t2("Checkout"),
18673
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon2, { name: "arrow-right" })
18674
- ]
18675
- }
18676
- )
18677
- }
18678
- );
18679
- }
18656
+ if (canTrial && trialPaymentMethodRequired) {
18680
18657
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
18681
18658
  Button,
18682
18659
  {
18683
18660
  type: "button",
18684
- disabled: !hasUnstagedChanges || !canUpdateSubscription,
18661
+ disabled: !hasAddOns && !canUpdateSubscription,
18685
18662
  onClick: async () => {
18686
- checkout();
18663
+ setCheckoutStage?.("checkout");
18687
18664
  },
18688
18665
  $isLoading: isLoading,
18689
18666
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
@@ -18694,7 +18671,9 @@ var StageButton = ({
18694
18671
  $alignItems: "center",
18695
18672
  $padding: "0 1rem",
18696
18673
  children: [
18697
- t2("Subscribe and close"),
18674
+ t2("Next"),
18675
+ ": ",
18676
+ t2("Checkout"),
18698
18677
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon2, { name: "arrow-right" })
18699
18678
  ]
18700
18679
  }
@@ -18703,7 +18682,7 @@ var StageButton = ({
18703
18682
  );
18704
18683
  }
18705
18684
  if (!requiresPayment && !checkoutStages?.some(
18706
- (stage) => stage.id === "addons" || stage.id === "usage"
18685
+ (stage) => stage.id === "usage" || stage.id === "addons"
18707
18686
  )) {
18708
18687
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NoPaymentRequired, {});
18709
18688
  }
@@ -18729,7 +18708,7 @@ var StageButton = ({
18729
18708
  );
18730
18709
  }
18731
18710
  if (checkoutStage === "usage") {
18732
- if (!requiresPayment) {
18711
+ if (!requiresPayment && !checkoutStages?.some((stage) => stage.id === "addons")) {
18733
18712
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NoPaymentRequired, {});
18734
18713
  }
18735
18714
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -18801,7 +18780,7 @@ var StageButton = ({
18801
18780
  disabled: isLoading || !hasUnstagedChanges || !canCheckout,
18802
18781
  onClick: checkout,
18803
18782
  $isLoading: isLoading,
18804
- children: canTrial ? t2("Start trial") : t2("Pay now")
18783
+ children: willTrial ? t2("Start trial") : t2("Pay now")
18805
18784
  }
18806
18785
  );
18807
18786
  }
@@ -18827,7 +18806,8 @@ var Sidebar = ({
18827
18806
  setError,
18828
18807
  setIsLoading,
18829
18808
  updatePromoCode,
18830
- showHeader = true
18809
+ showHeader = true,
18810
+ willTrial = false
18831
18811
  }) => {
18832
18812
  const { t: t2 } = useTranslation();
18833
18813
  const theme = nt();
@@ -18957,10 +18937,10 @@ var Sidebar = ({
18957
18937
  ...promoCode && { promoCode }
18958
18938
  }
18959
18939
  });
18960
- dispatchPlanChangedEvent(response.data);
18961
18940
  setIsLoading(false);
18962
18941
  setLayout("portal");
18963
- hydrate();
18942
+ await hydrate();
18943
+ dispatchPlanChangedEvent(response.data);
18964
18944
  } catch {
18965
18945
  setLayout("checkout");
18966
18946
  setError(
@@ -19058,6 +19038,7 @@ var Sidebar = ({
19058
19038
  currentUsageBasedEntitlements,
19059
19039
  usageBasedEntitlements
19060
19040
  ]);
19041
+ const willPeriodChange = planPeriod !== data.company?.plan?.planPeriod;
19061
19042
  const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
19062
19043
  const removedAddOns = currentAddOns.filter(
19063
19044
  (current) => !selectedAddOns.some((selected) => current.id === selected.id) && current.planPeriod !== "one-time"
@@ -19067,10 +19048,10 @@ var Sidebar = ({
19067
19048
  );
19068
19049
  const willAddOnsChange = removedAddOns.length > 0 || addedAddOns.length > 0;
19069
19050
  const willPayInAdvanceEntitlementsChange = payInAdvanceEntitlements.length > 0 && payInAdvanceEntitlements.some(({ quantity, usage }) => quantity !== usage);
19070
- const hasUnstagedChanges = willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
19051
+ const hasUnstagedChanges = willPeriodChange || willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
19071
19052
  const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
19072
19053
  const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
19073
- const isTrialable = selectedPlan?.companyCanTrial;
19054
+ const isTrialable = selectedPlan?.companyCanTrial === true;
19074
19055
  const today = /* @__PURE__ */ new Date();
19075
19056
  const trialEndsOn = new Date(today);
19076
19057
  if (isTrialable && selectedPlan.trialDays) {
@@ -19146,7 +19127,7 @@ var Sidebar = ({
19146
19127
  }
19147
19128
  ) }),
19148
19129
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Flex, { $flexDirection: "column", $gap: "0.5rem", $marginBottom: "1.5rem", children: [
19149
- data.company?.plan && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
19130
+ currentPlan && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
19150
19131
  Flex,
19151
19132
  {
19152
19133
  $justifyContent: "space-between",
@@ -19165,10 +19146,10 @@ var Sidebar = ({
19165
19146
  $size: theme.typography.heading4.fontSize,
19166
19147
  $weight: theme.typography.heading4.fontWeight,
19167
19148
  $color: theme.typography.heading4.color,
19168
- children: data.company.plan.name
19149
+ children: currentPlan.name
19169
19150
  }
19170
19151
  ) }),
19171
- typeof data.company.plan.planPrice === "number" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
19152
+ typeof currentPlan.planPrice === "number" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
19172
19153
  Text,
19173
19154
  {
19174
19155
  $font: theme.typography.text.fontFamily,
@@ -19177,14 +19158,12 @@ var Sidebar = ({
19177
19158
  $color: theme.typography.text.color,
19178
19159
  children: [
19179
19160
  formatCurrency(
19180
- data.company.plan.planPrice,
19181
- data.company.billingSubscription?.currency
19161
+ currentPlan.planPrice,
19162
+ data.company?.billingSubscription?.currency
19182
19163
  ),
19183
19164
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
19184
19165
  "/",
19185
- shortenPeriod(
19186
- data.company.plan.planPeriod || planPeriod
19187
- )
19166
+ shortenPeriod(currentPlan.planPeriod || planPeriod)
19188
19167
  ] })
19189
19168
  ]
19190
19169
  }
@@ -19950,7 +19929,7 @@ var Sidebar = ({
19950
19929
  layout === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19951
19930
  StageButton,
19952
19931
  {
19953
- canTrial: selectedPlan?.companyCanTrial === true,
19932
+ canTrial: isTrialable,
19954
19933
  canCheckout,
19955
19934
  canUpdateSubscription,
19956
19935
  checkout,
@@ -19962,7 +19941,8 @@ var Sidebar = ({
19962
19941
  isLoading,
19963
19942
  requiresPayment,
19964
19943
  setCheckoutStage,
19965
- trialPaymentMethodRequired: data.trialPaymentMethodRequired === true
19944
+ trialPaymentMethodRequired: data.trialPaymentMethodRequired === true,
19945
+ willTrial
19966
19946
  }
19967
19947
  ),
19968
19948
  layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { onClick: unsubscribe, $isLoading: isLoading, children: t2("Cancel subscription") }),
@@ -20272,13 +20252,11 @@ var Navigation = ({
20272
20252
  }
20273
20253
  ),
20274
20254
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
20275
- Box,
20255
+ Text,
20276
20256
  {
20257
+ as: Box,
20277
20258
  tabIndex: 0,
20278
- $fontSize: `${16 / TEXT_BASE_SIZE}rem`,
20279
- $fontFamily: theme.typography.text.fontFamily,
20280
- $fontWeight: index === activeIndex ? 600 : 400,
20281
- $color: theme.typography.text.color,
20259
+ $weight: index === activeIndex ? 600 : 400,
20282
20260
  ...!showFullContent && {
20283
20261
  $overflow: "hidden",
20284
20262
  $whiteSpace: "nowrap",
@@ -20331,15 +20309,162 @@ var ButtonLink = dt.a`
20331
20309
 
20332
20310
  // src/components/shared/checkout-dialog/Plan.tsx
20333
20311
  var import_jsx_runtime17 = require("react/jsx-runtime");
20312
+ var Selected = ({ isCurrent = false, isTrial = false }) => {
20313
+ const { t: t2 } = useTranslation();
20314
+ const theme = nt();
20315
+ const text = (0, import_react25.useMemo)(() => {
20316
+ if (isCurrent) {
20317
+ return isTrial ? t2("Trial in progress") : t2("Current plan");
20318
+ }
20319
+ return isTrial ? t2("Trial selected") : t2("Plan selected");
20320
+ }, [t2, isCurrent, isTrial]);
20321
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
20322
+ Flex,
20323
+ {
20324
+ $justifyContent: "center",
20325
+ $alignItems: "center",
20326
+ $gap: "0.25rem",
20327
+ $padding: "0.625rem 0",
20328
+ children: [
20329
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20330
+ Icon2,
20331
+ {
20332
+ name: "check-rounded",
20333
+ style: {
20334
+ fontSize: 20,
20335
+ lineHeight: 1,
20336
+ color: theme.primary
20337
+ }
20338
+ }
20339
+ ),
20340
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20341
+ Text,
20342
+ {
20343
+ $font: theme.typography.text.fontFamily,
20344
+ $size: 15 / 16 * theme.typography.text.fontSize,
20345
+ $weight: theme.typography.text.fontWeight,
20346
+ $color: theme.typography.text.color,
20347
+ $leading: 1,
20348
+ children: text
20349
+ }
20350
+ )
20351
+ ]
20352
+ }
20353
+ );
20354
+ };
20355
+ var PlanButtonGroup = ({
20356
+ plan,
20357
+ isLoading,
20358
+ isSelected,
20359
+ onSelect,
20360
+ willTrial
20361
+ }) => {
20362
+ const { t: t2 } = useTranslation();
20363
+ const { data } = useEmbed();
20364
+ const isCurrent = plan.id === data.company?.plan?.id;
20365
+ if (plan.companyCanTrial) {
20366
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Flex, { $flexDirection: "column", $gap: "1.5rem", children: [
20367
+ data.subscription?.status !== "trialing" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && willTrial ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20368
+ Selected,
20369
+ {
20370
+ isCurrent,
20371
+ isTrial: plan.companyCanTrial && willTrial
20372
+ }
20373
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20374
+ Button,
20375
+ {
20376
+ type: "button",
20377
+ disabled: (isLoading || !plan.valid) && !plan.custom,
20378
+ ...!plan.custom && {
20379
+ onClick: () => {
20380
+ onSelect({
20381
+ plan,
20382
+ shouldTrial: true
20383
+ });
20384
+ }
20385
+ },
20386
+ $size: "sm",
20387
+ $color: "primary",
20388
+ $variant: "filled",
20389
+ children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20390
+ ButtonLink,
20391
+ {
20392
+ href: plan.customPlanConfig?.ctaWebSite ?? "#",
20393
+ target: "_blank",
20394
+ children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
20395
+ }
20396
+ ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20397
+ Tooltip,
20398
+ {
20399
+ trigger: t2("Over usage limit"),
20400
+ content: t2("Current usage exceeds the limit of this plan.")
20401
+ }
20402
+ ) : t2("Start X day trial", { days: plan.trialDays })
20403
+ }
20404
+ ) }),
20405
+ !plan.custom && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && (!willTrial || data.subscription?.status === "trialing") ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20406
+ Button,
20407
+ {
20408
+ type: "button",
20409
+ disabled: isLoading || !plan.valid,
20410
+ onClick: () => {
20411
+ onSelect({ plan, shouldTrial: false });
20412
+ },
20413
+ $size: "sm",
20414
+ $color: "primary",
20415
+ $variant: data.subscription?.status === "trialing" ? "filled" : "text",
20416
+ children: !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20417
+ Tooltip,
20418
+ {
20419
+ trigger: t2("Over usage limit"),
20420
+ content: t2("Current usage exceeds the limit of this plan.")
20421
+ }
20422
+ ) : t2("Choose plan")
20423
+ }
20424
+ ) })
20425
+ ] });
20426
+ }
20427
+ return isSelected ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20428
+ Button,
20429
+ {
20430
+ type: "button",
20431
+ disabled: (isLoading || !plan.valid) && !plan.custom,
20432
+ ...!plan.custom && {
20433
+ onClick: () => {
20434
+ onSelect({ plan });
20435
+ }
20436
+ },
20437
+ $size: "sm",
20438
+ $color: "primary",
20439
+ $variant: "filled",
20440
+ children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20441
+ ButtonLink,
20442
+ {
20443
+ href: plan.customPlanConfig?.ctaWebSite ?? "#",
20444
+ target: "_blank",
20445
+ children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
20446
+ }
20447
+ ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20448
+ Tooltip,
20449
+ {
20450
+ trigger: t2("Over usage limit"),
20451
+ content: t2("Current usage exceeds the limit of this plan.")
20452
+ }
20453
+ ) : t2("Choose plan")
20454
+ }
20455
+ );
20456
+ };
20334
20457
  var Plan = ({
20335
20458
  isLoading,
20336
20459
  plans,
20337
20460
  selectedPlan,
20338
20461
  period,
20339
- selectPlan
20462
+ selectPlan,
20463
+ willTrial
20340
20464
  }) => {
20341
20465
  const { t: t2 } = useTranslation();
20342
20466
  const theme = nt();
20467
+ const { data } = useEmbed();
20343
20468
  const isLightBackground = useIsLightBackground();
20344
20469
  const [entitlementCounts, setEntitlementCounts] = (0, import_react25.useState)(
20345
20470
  () => plans.reduce(
@@ -20353,7 +20478,6 @@ var Plan = ({
20353
20478
  {}
20354
20479
  )
20355
20480
  );
20356
- const cardPadding = theme.card.padding / TEXT_BASE_SIZE;
20357
20481
  const handleToggleShowAll = (id) => {
20358
20482
  setEntitlementCounts((prev2) => {
20359
20483
  const count = { ...prev2[id] };
@@ -20366,6 +20490,7 @@ var Plan = ({
20366
20490
  };
20367
20491
  });
20368
20492
  };
20493
+ const cardPadding = theme.card.padding / TEXT_BASE_SIZE;
20369
20494
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20370
20495
  Box,
20371
20496
  {
@@ -20474,7 +20599,7 @@ var Plan = ({
20474
20599
  $size: 0.75 * theme.typography.text.fontSize,
20475
20600
  $weight: theme.typography.text.fontWeight,
20476
20601
  $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
20477
- children: t2("Active")
20602
+ children: data.subscription?.status === "trialing" ? t2("Trialing") : t2("Active")
20478
20603
  }
20479
20604
  )
20480
20605
  }
@@ -20689,70 +20814,14 @@ var Plan = ({
20689
20814
  }
20690
20815
  )
20691
20816
  ] }),
20692
- plan.id === selectedPlan?.id ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
20693
- Flex,
20817
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20818
+ PlanButtonGroup,
20694
20819
  {
20695
- $justifyContent: "center",
20696
- $alignItems: "center",
20697
- $gap: "0.25rem",
20698
- $padding: "0.625rem 0",
20699
- children: [
20700
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20701
- Icon2,
20702
- {
20703
- name: "check-rounded",
20704
- style: {
20705
- fontSize: 20,
20706
- lineHeight: 1,
20707
- color: theme.primary
20708
- }
20709
- }
20710
- ),
20711
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20712
- Text,
20713
- {
20714
- $font: theme.typography.text.fontFamily,
20715
- $size: 15 / 16 * theme.typography.text.fontSize,
20716
- $weight: theme.typography.text.fontWeight,
20717
- $color: theme.typography.text.color,
20718
- $leading: 1,
20719
- children: plan.current ? t2("Current plan") : t2("Selected")
20720
- }
20721
- )
20722
- ]
20723
- }
20724
- ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20725
- Button,
20726
- {
20727
- type: "button",
20728
- disabled: (isLoading || !plan.valid) && !plan.custom,
20729
- ...{
20730
- onClick: () => {
20731
- if (plan.custom) {
20732
- return;
20733
- }
20734
- selectPlan({ plan });
20735
- }
20736
- },
20737
- $size: "sm",
20738
- $color: "primary",
20739
- $variant: plan.current ? "outline" : "filled",
20740
- children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20741
- ButtonLink,
20742
- {
20743
- href: plan.customPlanConfig?.ctaWebSite ?? "#",
20744
- target: "_blank",
20745
- children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
20746
- }
20747
- ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20748
- Tooltip,
20749
- {
20750
- trigger: t2("Over usage limit"),
20751
- content: t2(
20752
- "Current usage exceeds the limit of this plan."
20753
- )
20754
- }
20755
- ) : plan.companyCanTrial ? t2("Trial plan", { days: plan.trialDays }) : t2("Choose plan")
20820
+ plan,
20821
+ isLoading,
20822
+ isSelected: plan.id === selectedPlan?.id,
20823
+ onSelect: selectPlan,
20824
+ willTrial
20756
20825
  }
20757
20826
  )
20758
20827
  ]
@@ -20967,7 +21036,6 @@ var CheckoutDialog = ({ top = 0 }) => {
20967
21036
  );
20968
21037
  const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
20969
21038
  const [error, setError] = (0, import_react26.useState)();
20970
- const [promoCode, setPromoCode] = (0, import_react26.useState)();
20971
21039
  const [planPeriod, setPlanPeriod] = (0, import_react26.useState)(
20972
21040
  selected.period || data.company?.plan?.planPeriod || "month"
20973
21041
  );
@@ -20981,6 +21049,9 @@ var CheckoutDialog = ({ top = 0 }) => {
20981
21049
  (plan) => selected.planId ? plan.id === selected.planId : plan.current
20982
21050
  )
20983
21051
  );
21052
+ const [willTrial, setWillTrial] = (0, import_react26.useState)(
21053
+ data.subscription?.status !== "trialing" && !data.trialPaymentMethodRequired
21054
+ );
20984
21055
  const [addOns, setAddOns] = (0, import_react26.useState)(
20985
21056
  () => availableAddOns.map((addOn) => ({
20986
21057
  ...addOn,
@@ -20989,6 +21060,7 @@ var CheckoutDialog = ({ top = 0 }) => {
20989
21060
  )
20990
21061
  }))
20991
21062
  );
21063
+ const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
20992
21064
  const currentEntitlements = (0, import_react26.useMemo)(() => {
20993
21065
  return data.featureUsage?.features || [];
20994
21066
  }, [data.featureUsage?.features]);
@@ -21007,11 +21079,14 @@ var CheckoutDialog = ({ top = 0 }) => {
21007
21079
  ),
21008
21080
  [usageBasedEntitlements]
21009
21081
  );
21010
- const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
21011
21082
  const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
21012
21083
  ({ quantity }) => quantity > 0
21013
21084
  );
21014
- const requiresPayment = (!selectedPlan?.companyCanTrial || !!data.trialPaymentMethodRequired) && (!selectedPlan?.isFree || hasActiveAddOns || hasActivePayInAdvanceEntitlements);
21085
+ const [promoCode, setPromoCode] = (0, import_react26.useState)();
21086
+ const isTrialable = selectedPlan?.isTrialable === true && selectedPlan?.companyCanTrial === true;
21087
+ const isTrialableAndFree = isTrialable && data.trialPaymentMethodRequired !== true;
21088
+ const planRequiresPayment = !isTrialableAndFree || !isTrialable && selectedPlan?.isFree !== true;
21089
+ const requiresPayment = planRequiresPayment || hasActiveAddOns || hasActivePayInAdvanceEntitlements;
21015
21090
  const checkoutStages = (0, import_react26.useMemo)(() => {
21016
21091
  const stages = [
21017
21092
  {
@@ -21021,13 +21096,16 @@ var CheckoutDialog = ({ top = 0 }) => {
21021
21096
  description: t2("Choose your base plan")
21022
21097
  }
21023
21098
  ];
21024
- if (payInAdvanceEntitlements.length) {
21099
+ if (willTrial) {
21100
+ return stages;
21101
+ }
21102
+ if (payInAdvanceEntitlements.length > 0) {
21025
21103
  stages.push({
21026
21104
  id: "usage",
21027
21105
  name: t2("Quantity")
21028
21106
  });
21029
21107
  }
21030
- if (availableAddOns.length && !selectedPlan?.companyCanTrial) {
21108
+ if (availableAddOns.length > 0) {
21031
21109
  stages.push({
21032
21110
  id: "addons",
21033
21111
  name: t2("Add-ons"),
@@ -21045,9 +21123,9 @@ var CheckoutDialog = ({ top = 0 }) => {
21045
21123
  return stages;
21046
21124
  }, [
21047
21125
  t2,
21126
+ willTrial,
21048
21127
  payInAdvanceEntitlements,
21049
21128
  availableAddOns,
21050
- selectedPlan?.companyCanTrial,
21051
21129
  requiresPayment
21052
21130
  ]);
21053
21131
  const [checkoutStage, setCheckoutStage] = (0, import_react26.useState)(() => {
@@ -21152,6 +21230,8 @@ var CheckoutDialog = ({ top = 0 }) => {
21152
21230
  setSelectedPlan(plan);
21153
21231
  setUsageBasedEntitlements(entitlements);
21154
21232
  }
21233
+ const shouldTrial = updates.shouldTrial ?? false;
21234
+ setWillTrial(shouldTrial && !data.trialPaymentMethodRequired);
21155
21235
  previewCheckout({
21156
21236
  period,
21157
21237
  plan: updates.plan,
@@ -21160,7 +21240,13 @@ var CheckoutDialog = ({ top = 0 }) => {
21160
21240
  )
21161
21241
  });
21162
21242
  },
21163
- [planPeriod, selectedPlan, currentEntitlements, previewCheckout]
21243
+ [
21244
+ data.trialPaymentMethodRequired,
21245
+ planPeriod,
21246
+ selectedPlan,
21247
+ currentEntitlements,
21248
+ previewCheckout
21249
+ ]
21164
21250
  );
21165
21251
  const changePlanPeriod = (0, import_react26.useCallback)(
21166
21252
  (period) => {
@@ -21357,7 +21443,8 @@ var CheckoutDialog = ({ top = 0 }) => {
21357
21443
  period: planPeriod,
21358
21444
  plans: availablePlans,
21359
21445
  selectedPlan,
21360
- selectPlan
21446
+ selectPlan,
21447
+ willTrial
21361
21448
  }
21362
21449
  ),
21363
21450
  checkoutStage === "usage" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -21409,7 +21496,8 @@ var CheckoutDialog = ({ top = 0 }) => {
21409
21496
  setCheckoutStage: (stage) => setCheckoutStage(stage),
21410
21497
  setError: (msg) => setError(msg),
21411
21498
  setIsLoading,
21412
- updatePromoCode: (code) => updatePromoCode(code)
21499
+ updatePromoCode: (code) => updatePromoCode(code),
21500
+ willTrial
21413
21501
  }
21414
21502
  )
21415
21503
  ]
@@ -23395,7 +23483,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
23395
23483
  }
23396
23484
  stripe._registerWrapper({
23397
23485
  name: "stripe-js",
23398
- version: "7.2.0",
23486
+ version: "7.3.0",
23399
23487
  startTime
23400
23488
  });
23401
23489
  };
@@ -23470,7 +23558,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
23470
23558
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
23471
23559
  var expectedVersion = RELEASE_TRAIN;
23472
23560
  if (isTestKey && version !== expectedVersion) {
23473
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
23561
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.3.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
23474
23562
  }
23475
23563
  var stripe = maybeStripe.apply(void 0, args);
23476
23564
  registerWrapper(stripe, startTime);
@@ -24666,7 +24754,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24666
24754
  "Current usage exceeds the limit of this plan."
24667
24755
  )
24668
24756
  }
24669
- ) : plan.companyCanTrial ? t2("Trial plan", { days: plan.trialDays }) : t2("Choose plan")
24757
+ ) : plan.companyCanTrial ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
24670
24758
  }
24671
24759
  )
24672
24760
  ]