@schematichq/schematic-components 1.6.1 → 1.7.0
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.
- package/dist/schematic-components.cjs.js +574 -305
- package/dist/schematic-components.d.ts +394 -165
- package/dist/schematic-components.esm.js +475 -206
- package/package.json +7 -7
|
@@ -1894,6 +1894,7 @@ __export(index_exports, {
|
|
|
1894
1894
|
useAvailablePlans: () => useAvailablePlans,
|
|
1895
1895
|
useEmbed: () => useEmbed,
|
|
1896
1896
|
useIsLightBackground: () => useIsLightBackground,
|
|
1897
|
+
usePaymentConfirmation: () => usePaymentConfirmation,
|
|
1897
1898
|
usePrevious: () => usePrevious2,
|
|
1898
1899
|
useRequest: () => useRequest,
|
|
1899
1900
|
useTrialEnd: () => useTrialEnd,
|
|
@@ -1902,10 +1903,10 @@ __export(index_exports, {
|
|
|
1902
1903
|
module.exports = __toCommonJS(index_exports);
|
|
1903
1904
|
|
|
1904
1905
|
// src/components/elements/button/Button.tsx
|
|
1905
|
-
var
|
|
1906
|
+
var import_react40 = require("react");
|
|
1906
1907
|
|
|
1907
1908
|
// src/components/layout/card/Card.tsx
|
|
1908
|
-
var
|
|
1909
|
+
var import_react24 = require("react");
|
|
1909
1910
|
|
|
1910
1911
|
// src/const/components.ts
|
|
1911
1912
|
var VISIBLE_ENTITLEMENT_COUNT = 4;
|
|
@@ -2041,6 +2042,18 @@ function getEntitlementCost(entitlement, period = "month") {
|
|
|
2041
2042
|
}
|
|
2042
2043
|
}
|
|
2043
2044
|
}
|
|
2045
|
+
function isBillingAddressRequiredForTax(financeData) {
|
|
2046
|
+
if (!financeData) {
|
|
2047
|
+
return false;
|
|
2048
|
+
}
|
|
2049
|
+
return financeData.taxRequireBillingDetails;
|
|
2050
|
+
}
|
|
2051
|
+
function shouldCollectBillingAddress(collectAddressSetting, financeData) {
|
|
2052
|
+
if (collectAddressSetting) {
|
|
2053
|
+
return true;
|
|
2054
|
+
}
|
|
2055
|
+
return isBillingAddressRequiredForTax(financeData);
|
|
2056
|
+
}
|
|
2044
2057
|
|
|
2045
2058
|
// src/utils/api/credit.ts
|
|
2046
2059
|
function getResetCadencePeriod(cadence) {
|
|
@@ -4287,7 +4300,8 @@ var initialContext = {
|
|
|
4287
4300
|
setCheckoutState: stub,
|
|
4288
4301
|
setData: stub,
|
|
4289
4302
|
updateSettings: stub,
|
|
4290
|
-
debug: stub
|
|
4303
|
+
debug: stub,
|
|
4304
|
+
finishCheckout: stub
|
|
4291
4305
|
};
|
|
4292
4306
|
var EmbedContext = (0, import_react3.createContext)(initialContext);
|
|
4293
4307
|
|
|
@@ -6766,7 +6780,7 @@ var en_default = {
|
|
|
6766
6780
|
"Add-ons Quantity": "Add-ons Quantity",
|
|
6767
6781
|
Additional: "Additional",
|
|
6768
6782
|
"After the trial, cancel no default": "After the trial, you will be lose access to {{planName}} plan and your subscription will be cancelled.",
|
|
6769
|
-
"After the trial, cancel": "After the trial, you will be downgraded to the {{
|
|
6783
|
+
"After the trial, cancel": "After the trial, you will be downgraded to the {{postTrialPlanName}} plan and your subscription will be cancelled.",
|
|
6770
6784
|
"After the trial, subscribe": "After the trial, subscription starts and you will be billed.",
|
|
6771
6785
|
"Amount off": "{{amount}} off",
|
|
6772
6786
|
"An invoice is created when charges reach $X; the rest is billed monthly.": "An invoice is created when charges reach {{amount}}; the rest is billed monthly.",
|
|
@@ -6866,6 +6880,7 @@ var en_default = {
|
|
|
6866
6880
|
"Subscription canceled": "Subscription canceled",
|
|
6867
6881
|
Subscription: "Subscription",
|
|
6868
6882
|
"Talk to support": "Talk to support",
|
|
6883
|
+
"Tax (description):": "Tax ({{description}}):",
|
|
6869
6884
|
"There was a problem retrieving your upcoming invoice.": "There was a problem retrieving your upcoming invoice.",
|
|
6870
6885
|
"There was a problem retrieving your invoices.": "There was a problem retrieving your invoices.",
|
|
6871
6886
|
"Tiers apply progressively as quantity increases.": "Tiers apply progressively as quantity increases.",
|
|
@@ -7552,11 +7567,15 @@ function BillingPlanCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminat
|
|
|
7552
7567
|
creditName: json["credit_name"],
|
|
7553
7568
|
creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
|
|
7554
7569
|
creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
|
|
7570
|
+
expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
|
|
7571
|
+
expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
|
|
7572
|
+
expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
|
|
7555
7573
|
id: json["id"],
|
|
7556
7574
|
planId: json["plan_id"],
|
|
7557
7575
|
planName: json["plan_name"],
|
|
7558
7576
|
resetCadence: json["reset_cadence"],
|
|
7559
7577
|
resetStart: json["reset_start"],
|
|
7578
|
+
resetType: json["reset_type"] == null ? void 0 : json["reset_type"],
|
|
7560
7579
|
updatedAt: new Date(json["updated_at"])
|
|
7561
7580
|
};
|
|
7562
7581
|
}
|
|
@@ -7701,36 +7720,6 @@ function BillingSubscriptionDiscountViewFromJSONTyped(json, ignoreDiscriminator)
|
|
|
7701
7720
|
};
|
|
7702
7721
|
}
|
|
7703
7722
|
|
|
7704
|
-
// src/api/checkoutexternal/models/BillingSubscriptionResponseData.ts
|
|
7705
|
-
function BillingSubscriptionResponseDataFromJSON(json) {
|
|
7706
|
-
return BillingSubscriptionResponseDataFromJSONTyped(json, false);
|
|
7707
|
-
}
|
|
7708
|
-
function BillingSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
7709
|
-
if (json == null) {
|
|
7710
|
-
return json;
|
|
7711
|
-
}
|
|
7712
|
-
return {
|
|
7713
|
-
cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
|
|
7714
|
-
cancelAtPeriodEnd: json["cancel_at_period_end"],
|
|
7715
|
-
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
7716
|
-
createdAt: new Date(json["created_at"]),
|
|
7717
|
-
currency: json["currency"],
|
|
7718
|
-
customerExternalId: json["customer_external_id"],
|
|
7719
|
-
defaultPaymentMethodId: json["default_payment_method_id"] == null ? void 0 : json["default_payment_method_id"],
|
|
7720
|
-
expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
|
|
7721
|
-
id: json["id"],
|
|
7722
|
-
interval: json["interval"],
|
|
7723
|
-
metadata: json["metadata"] == null ? void 0 : json["metadata"],
|
|
7724
|
-
periodEnd: json["period_end"],
|
|
7725
|
-
periodStart: json["period_start"],
|
|
7726
|
-
status: json["status"],
|
|
7727
|
-
subscriptionExternalId: json["subscription_external_id"],
|
|
7728
|
-
totalPrice: json["total_price"],
|
|
7729
|
-
trialEnd: json["trial_end"] == null ? void 0 : json["trial_end"],
|
|
7730
|
-
trialEndSetting: json["trial_end_setting"] == null ? void 0 : json["trial_end_setting"]
|
|
7731
|
-
};
|
|
7732
|
-
}
|
|
7733
|
-
|
|
7734
7723
|
// src/api/checkoutexternal/models/InvoiceResponseData.ts
|
|
7735
7724
|
function InvoiceResponseDataFromJSON(json) {
|
|
7736
7725
|
return InvoiceResponseDataFromJSONTyped(json, false);
|
|
@@ -7884,6 +7873,38 @@ function ChangeSubscriptionRequestBodyToJSON(value) {
|
|
|
7884
7873
|
};
|
|
7885
7874
|
}
|
|
7886
7875
|
|
|
7876
|
+
// src/api/checkoutexternal/models/CheckoutResponseData.ts
|
|
7877
|
+
function CheckoutResponseDataFromJSON(json) {
|
|
7878
|
+
return CheckoutResponseDataFromJSONTyped(json, false);
|
|
7879
|
+
}
|
|
7880
|
+
function CheckoutResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
7881
|
+
if (json == null) {
|
|
7882
|
+
return json;
|
|
7883
|
+
}
|
|
7884
|
+
return {
|
|
7885
|
+
cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
|
|
7886
|
+
cancelAtPeriodEnd: json["cancel_at_period_end"],
|
|
7887
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
7888
|
+
confirmPaymentIntentClientSecret: json["confirm_payment_intent_client_secret"] == null ? void 0 : json["confirm_payment_intent_client_secret"],
|
|
7889
|
+
confirmPaymentIntentId: json["confirm_payment_intent_id"] == null ? void 0 : json["confirm_payment_intent_id"],
|
|
7890
|
+
createdAt: new Date(json["created_at"]),
|
|
7891
|
+
currency: json["currency"],
|
|
7892
|
+
customerExternalId: json["customer_external_id"],
|
|
7893
|
+
defaultPaymentMethodId: json["default_payment_method_id"] == null ? void 0 : json["default_payment_method_id"],
|
|
7894
|
+
expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
|
|
7895
|
+
id: json["id"],
|
|
7896
|
+
interval: json["interval"],
|
|
7897
|
+
metadata: json["metadata"] == null ? void 0 : json["metadata"],
|
|
7898
|
+
periodEnd: json["period_end"],
|
|
7899
|
+
periodStart: json["period_start"],
|
|
7900
|
+
status: json["status"],
|
|
7901
|
+
subscriptionExternalId: json["subscription_external_id"],
|
|
7902
|
+
totalPrice: json["total_price"],
|
|
7903
|
+
trialEnd: json["trial_end"] == null ? void 0 : json["trial_end"],
|
|
7904
|
+
trialEndSetting: json["trial_end_setting"] == null ? void 0 : json["trial_end_setting"]
|
|
7905
|
+
};
|
|
7906
|
+
}
|
|
7907
|
+
|
|
7887
7908
|
// src/api/checkoutexternal/models/CheckoutResponse.ts
|
|
7888
7909
|
function CheckoutResponseFromJSON(json) {
|
|
7889
7910
|
return CheckoutResponseFromJSONTyped(json, false);
|
|
@@ -7893,7 +7914,7 @@ function CheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
7893
7914
|
return json;
|
|
7894
7915
|
}
|
|
7895
7916
|
return {
|
|
7896
|
-
data:
|
|
7917
|
+
data: CheckoutResponseDataFromJSON(json["data"]),
|
|
7897
7918
|
params: json["params"]
|
|
7898
7919
|
};
|
|
7899
7920
|
}
|
|
@@ -8131,6 +8152,24 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8131
8152
|
};
|
|
8132
8153
|
}
|
|
8133
8154
|
|
|
8155
|
+
// src/api/checkoutexternal/models/CompanyOverrideNoteResponseData.ts
|
|
8156
|
+
function CompanyOverrideNoteResponseDataFromJSON(json) {
|
|
8157
|
+
return CompanyOverrideNoteResponseDataFromJSONTyped(json, false);
|
|
8158
|
+
}
|
|
8159
|
+
function CompanyOverrideNoteResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
8160
|
+
if (json == null) {
|
|
8161
|
+
return json;
|
|
8162
|
+
}
|
|
8163
|
+
return {
|
|
8164
|
+
createdAt: new Date(json["created_at"]),
|
|
8165
|
+
externalUserId: json["external_user_id"],
|
|
8166
|
+
externalUserName: json["external_user_name"],
|
|
8167
|
+
id: json["id"],
|
|
8168
|
+
note: json["note"],
|
|
8169
|
+
updatedAt: new Date(json["updated_at"])
|
|
8170
|
+
};
|
|
8171
|
+
}
|
|
8172
|
+
|
|
8134
8173
|
// src/api/checkoutexternal/models/FeatureResponseData.ts
|
|
8135
8174
|
function FeatureResponseDataFromJSON(json) {
|
|
8136
8175
|
return FeatureResponseDataFromJSONTyped(json, false);
|
|
@@ -8176,6 +8215,9 @@ function CompanyOverrideResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8176
8215
|
id: json["id"],
|
|
8177
8216
|
metricPeriod: json["metric_period"] == null ? void 0 : json["metric_period"],
|
|
8178
8217
|
metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : json["metric_period_month_reset"],
|
|
8218
|
+
notes: json["notes"].map(
|
|
8219
|
+
CompanyOverrideNoteResponseDataFromJSON
|
|
8220
|
+
),
|
|
8179
8221
|
ruleId: json["rule_id"] == null ? void 0 : json["rule_id"],
|
|
8180
8222
|
ruleIdUsageExceeded: json["rule_id_usage_exceeded"] == null ? void 0 : json["rule_id_usage_exceeded"],
|
|
8181
8223
|
updatedAt: new Date(json["updated_at"]),
|
|
@@ -8392,12 +8434,16 @@ function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8392
8434
|
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
8393
8435
|
creditId: json["credit_id"],
|
|
8394
8436
|
creditName: json["credit_name"],
|
|
8437
|
+
expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
|
|
8438
|
+
expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
|
|
8439
|
+
expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
|
|
8395
8440
|
id: json["id"],
|
|
8396
8441
|
planId: json["plan_id"],
|
|
8397
8442
|
planName: json["plan_name"],
|
|
8398
8443
|
pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
|
|
8399
8444
|
resetCadence: json["reset_cadence"],
|
|
8400
8445
|
resetStart: json["reset_start"],
|
|
8446
|
+
resetType: json["reset_type"],
|
|
8401
8447
|
singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
|
|
8402
8448
|
updatedAt: new Date(json["updated_at"])
|
|
8403
8449
|
};
|
|
@@ -8651,7 +8697,8 @@ function ComponentCheckoutSettingsFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8651
8697
|
return {
|
|
8652
8698
|
collectAddress: json["collect_address"],
|
|
8653
8699
|
collectEmail: json["collect_email"],
|
|
8654
|
-
collectPhone: json["collect_phone"]
|
|
8700
|
+
collectPhone: json["collect_phone"],
|
|
8701
|
+
taxCollectionEnabled: json["tax_collection_enabled"]
|
|
8655
8702
|
};
|
|
8656
8703
|
}
|
|
8657
8704
|
|
|
@@ -8838,6 +8885,8 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8838
8885
|
),
|
|
8839
8886
|
defaultPlan: json["default_plan"] == null ? void 0 : PlanDetailResponseDataFromJSON(json["default_plan"]),
|
|
8840
8887
|
featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
|
|
8888
|
+
postTrialPlan: json["post_trial_plan"] == null ? void 0 : PlanDetailResponseDataFromJSON(json["post_trial_plan"]),
|
|
8889
|
+
showCredits: json["show_credits"],
|
|
8841
8890
|
showPeriodToggle: json["show_period_toggle"],
|
|
8842
8891
|
showZeroPriceAsFree: json["show_zero_price_as_free"],
|
|
8843
8892
|
stripeEmbed: json["stripe_embed"] == null ? void 0 : StripeEmbedInfoFromJSON(json["stripe_embed"]),
|
|
@@ -9022,6 +9071,9 @@ function PreviewSubscriptionFinanceResponseDataFromJSONTyped(json, ignoreDiscrim
|
|
|
9022
9071
|
periodStart: new Date(json["period_start"]),
|
|
9023
9072
|
promoCodeApplied: json["promo_code_applied"],
|
|
9024
9073
|
proration: json["proration"],
|
|
9074
|
+
taxAmount: json["tax_amount"] == null ? void 0 : json["tax_amount"],
|
|
9075
|
+
taxDisplayName: json["tax_display_name"] == null ? void 0 : json["tax_display_name"],
|
|
9076
|
+
taxRequireBillingDetails: json["tax_require_billing_details"],
|
|
9025
9077
|
trialEnd: json["trial_end"] == null ? void 0 : new Date(json["trial_end"]),
|
|
9026
9078
|
upcomingInvoiceLineItems: json["upcoming_invoice_line_items"].map(PreviewSubscriptionUpcomingInvoiceLineItemsFromJSON)
|
|
9027
9079
|
};
|
|
@@ -10261,12 +10313,16 @@ function PlanCreditGrantViewFromJSONTyped3(json, ignoreDiscriminator) {
|
|
|
10261
10313
|
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
10262
10314
|
creditId: json["credit_id"],
|
|
10263
10315
|
creditName: json["credit_name"],
|
|
10316
|
+
expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
|
|
10317
|
+
expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
|
|
10318
|
+
expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
|
|
10264
10319
|
id: json["id"],
|
|
10265
10320
|
planId: json["plan_id"],
|
|
10266
10321
|
planName: json["plan_name"],
|
|
10267
10322
|
pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
|
|
10268
10323
|
resetCadence: json["reset_cadence"],
|
|
10269
10324
|
resetStart: json["reset_start"],
|
|
10325
|
+
resetType: json["reset_type"],
|
|
10270
10326
|
singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
|
|
10271
10327
|
updatedAt: new Date(json["updated_at"])
|
|
10272
10328
|
};
|
|
@@ -10392,6 +10448,7 @@ function PublicPlansResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
10392
10448
|
CompatiblePlansFromJSON2
|
|
10393
10449
|
),
|
|
10394
10450
|
capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON2(json["capabilities"]),
|
|
10451
|
+
showCredits: json["show_credits"],
|
|
10395
10452
|
showPeriodToggle: json["show_period_toggle"],
|
|
10396
10453
|
showZeroPriceAsFree: json["show_zero_price_as_free"]
|
|
10397
10454
|
};
|
|
@@ -10591,7 +10648,7 @@ var EmbedProvider = ({
|
|
|
10591
10648
|
});
|
|
10592
10649
|
const customHeaders = (0, import_react12.useMemo)(
|
|
10593
10650
|
() => ({
|
|
10594
|
-
"X-Schematic-Components-Version": "1.
|
|
10651
|
+
"X-Schematic-Components-Version": "1.7.0",
|
|
10595
10652
|
"X-Schematic-Session-ID": sessionIdRef.current
|
|
10596
10653
|
}),
|
|
10597
10654
|
[]
|
|
@@ -10605,6 +10662,15 @@ var EmbedProvider = ({
|
|
|
10605
10662
|
},
|
|
10606
10663
|
[options.debug]
|
|
10607
10664
|
);
|
|
10665
|
+
const finishCheckout = (0, import_react12.useCallback)(
|
|
10666
|
+
(checkoutData) => {
|
|
10667
|
+
dispatch({
|
|
10668
|
+
type: "CHECKOUT",
|
|
10669
|
+
data: checkoutData
|
|
10670
|
+
});
|
|
10671
|
+
},
|
|
10672
|
+
[dispatch]
|
|
10673
|
+
);
|
|
10608
10674
|
const hydratePublic = (0, import_react12.useCallback)(async () => {
|
|
10609
10675
|
dispatch({ type: "HYDRATE_STARTED" });
|
|
10610
10676
|
try {
|
|
@@ -10746,7 +10812,7 @@ var EmbedProvider = ({
|
|
|
10746
10812
|
const response = await api.checkout?.checkout({
|
|
10747
10813
|
changeSubscriptionRequestBody
|
|
10748
10814
|
});
|
|
10749
|
-
if (response) {
|
|
10815
|
+
if (response && !response.data.confirmPaymentIntentClientSecret) {
|
|
10750
10816
|
dispatch({
|
|
10751
10817
|
type: "CHECKOUT",
|
|
10752
10818
|
data: response.data
|
|
@@ -10957,6 +11023,7 @@ var EmbedProvider = ({
|
|
|
10957
11023
|
getUpcomingInvoice: debouncedGetUpcomingInvoice,
|
|
10958
11024
|
getCustomerBalance: debouncedGetCustomerBalance,
|
|
10959
11025
|
listInvoices: debouncedListInvoices,
|
|
11026
|
+
finishCheckout,
|
|
10960
11027
|
setError,
|
|
10961
11028
|
setAccessToken,
|
|
10962
11029
|
setLayout,
|
|
@@ -10986,23 +11053,131 @@ function useIsLightBackground() {
|
|
|
10986
11053
|
return isLightBackground;
|
|
10987
11054
|
}
|
|
10988
11055
|
|
|
10989
|
-
// src/hooks/
|
|
11056
|
+
// src/hooks/usePaymentConfirmation.ts
|
|
10990
11057
|
var import_react15 = require("react");
|
|
10991
|
-
|
|
10992
|
-
|
|
11058
|
+
var usePaymentConfirmation = ({
|
|
11059
|
+
stripe,
|
|
11060
|
+
clientSecret,
|
|
11061
|
+
onSuccess,
|
|
11062
|
+
onError: onError3,
|
|
11063
|
+
autoConfirm = false
|
|
11064
|
+
}) => {
|
|
11065
|
+
const [isConfirming, setIsConfirming] = (0, import_react15.useState)(false);
|
|
11066
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
11067
|
+
const [status, setStatus] = (0, import_react15.useState)("idle");
|
|
11068
|
+
const confirmedSecrets = (0, import_react15.useRef)(/* @__PURE__ */ new Set());
|
|
11069
|
+
const abortControllerRef = (0, import_react15.useRef)(null);
|
|
11070
|
+
const confirmPayment = (0, import_react15.useCallback)(async () => {
|
|
11071
|
+
if (!stripe || !clientSecret) {
|
|
11072
|
+
const error2 = new Error(
|
|
11073
|
+
"Missing required parameters: stripe instance or client secret"
|
|
11074
|
+
);
|
|
11075
|
+
setError(error2);
|
|
11076
|
+
setStatus("failed");
|
|
11077
|
+
onError3?.(error2);
|
|
11078
|
+
return;
|
|
11079
|
+
}
|
|
11080
|
+
if (confirmedSecrets.current.has(clientSecret) || isConfirming) {
|
|
11081
|
+
console.warn("Payment confirmation already attempted or in progress");
|
|
11082
|
+
return;
|
|
11083
|
+
}
|
|
11084
|
+
if (abortControllerRef.current) {
|
|
11085
|
+
abortControllerRef.current.abort();
|
|
11086
|
+
}
|
|
11087
|
+
abortControllerRef.current = new AbortController();
|
|
11088
|
+
const { signal } = abortControllerRef.current;
|
|
11089
|
+
setIsConfirming(true);
|
|
11090
|
+
setError(null);
|
|
11091
|
+
setStatus("confirming");
|
|
11092
|
+
try {
|
|
11093
|
+
confirmedSecrets.current.add(clientSecret);
|
|
11094
|
+
const stripeInstance = await stripe;
|
|
11095
|
+
if (signal.aborted) {
|
|
11096
|
+
throw new Error("Payment confirmation was cancelled");
|
|
11097
|
+
}
|
|
11098
|
+
if (!stripeInstance) {
|
|
11099
|
+
throw new Error("Failed to load Stripe instance");
|
|
11100
|
+
}
|
|
11101
|
+
const result = await stripeInstance.confirmCardPayment(clientSecret);
|
|
11102
|
+
if (signal.aborted) {
|
|
11103
|
+
throw new Error("Payment confirmation was cancelled");
|
|
11104
|
+
}
|
|
11105
|
+
if (result.error) {
|
|
11106
|
+
throw new Error(result.error.message || "Payment confirmation failed");
|
|
11107
|
+
}
|
|
11108
|
+
setStatus("succeeded");
|
|
11109
|
+
onSuccess?.();
|
|
11110
|
+
} catch (err2) {
|
|
11111
|
+
if (!signal.aborted) {
|
|
11112
|
+
const error2 = err2 instanceof Error ? err2 : new Error("Unknown error occurred");
|
|
11113
|
+
setError(error2);
|
|
11114
|
+
setStatus("failed");
|
|
11115
|
+
onError3?.(error2);
|
|
11116
|
+
confirmedSecrets.current.delete(clientSecret);
|
|
11117
|
+
}
|
|
11118
|
+
} finally {
|
|
11119
|
+
if (!signal.aborted) {
|
|
11120
|
+
setIsConfirming(false);
|
|
11121
|
+
}
|
|
11122
|
+
abortControllerRef.current = null;
|
|
11123
|
+
}
|
|
11124
|
+
}, [stripe, clientSecret, onSuccess, onError3, isConfirming]);
|
|
11125
|
+
const reset = (0, import_react15.useCallback)(() => {
|
|
11126
|
+
if (clientSecret) {
|
|
11127
|
+
confirmedSecrets.current.delete(clientSecret);
|
|
11128
|
+
}
|
|
11129
|
+
setIsConfirming(false);
|
|
11130
|
+
setError(null);
|
|
11131
|
+
setStatus("idle");
|
|
11132
|
+
if (abortControllerRef.current) {
|
|
11133
|
+
abortControllerRef.current.abort();
|
|
11134
|
+
abortControllerRef.current = null;
|
|
11135
|
+
}
|
|
11136
|
+
}, [clientSecret]);
|
|
10993
11137
|
(0, import_react15.useEffect)(() => {
|
|
11138
|
+
if (autoConfirm && status === "idle" && stripe && clientSecret) {
|
|
11139
|
+
confirmPayment();
|
|
11140
|
+
}
|
|
11141
|
+
}, [autoConfirm, stripe, clientSecret]);
|
|
11142
|
+
(0, import_react15.useEffect)(() => {
|
|
11143
|
+
return () => {
|
|
11144
|
+
if (abortControllerRef.current) {
|
|
11145
|
+
abortControllerRef.current.abort();
|
|
11146
|
+
abortControllerRef.current = null;
|
|
11147
|
+
}
|
|
11148
|
+
};
|
|
11149
|
+
}, []);
|
|
11150
|
+
(0, import_react15.useEffect)(() => {
|
|
11151
|
+
if (clientSecret && status !== "idle") {
|
|
11152
|
+
reset();
|
|
11153
|
+
}
|
|
11154
|
+
}, [clientSecret]);
|
|
11155
|
+
return {
|
|
11156
|
+
confirmPayment,
|
|
11157
|
+
isConfirming,
|
|
11158
|
+
error,
|
|
11159
|
+
status,
|
|
11160
|
+
reset
|
|
11161
|
+
};
|
|
11162
|
+
};
|
|
11163
|
+
|
|
11164
|
+
// src/hooks/usePrevious.ts
|
|
11165
|
+
var import_react16 = require("react");
|
|
11166
|
+
function usePrevious2(value) {
|
|
11167
|
+
const ref = (0, import_react16.useRef)(void 0);
|
|
11168
|
+
(0, import_react16.useEffect)(() => {
|
|
10994
11169
|
ref.current = value;
|
|
10995
11170
|
}, [value]);
|
|
10996
11171
|
return ref.current;
|
|
10997
11172
|
}
|
|
10998
11173
|
|
|
10999
11174
|
// src/hooks/useRequest.ts
|
|
11000
|
-
var
|
|
11175
|
+
var import_react17 = require("react");
|
|
11001
11176
|
function useRequest(fn) {
|
|
11002
|
-
const [isLoading, setIsLoading] = (0,
|
|
11003
|
-
const [error, setError] = (0,
|
|
11004
|
-
const [data, setData] = (0,
|
|
11005
|
-
const request = (0,
|
|
11177
|
+
const [isLoading, setIsLoading] = (0, import_react17.useState)(false);
|
|
11178
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
11179
|
+
const [data, setData] = (0, import_react17.useState)(void 0);
|
|
11180
|
+
const request = (0, import_react17.useCallback)(async () => {
|
|
11006
11181
|
try {
|
|
11007
11182
|
setError(null);
|
|
11008
11183
|
setIsLoading(true);
|
|
@@ -11017,7 +11192,7 @@ function useRequest(fn) {
|
|
|
11017
11192
|
setIsLoading(false);
|
|
11018
11193
|
}
|
|
11019
11194
|
}, [fn]);
|
|
11020
|
-
const value = (0,
|
|
11195
|
+
const value = (0, import_react17.useMemo)(() => {
|
|
11021
11196
|
const state = { isLoading, error, data };
|
|
11022
11197
|
return [state, request];
|
|
11023
11198
|
}, [isLoading, error, data, request]);
|
|
@@ -11025,11 +11200,11 @@ function useRequest(fn) {
|
|
|
11025
11200
|
}
|
|
11026
11201
|
|
|
11027
11202
|
// src/hooks/useTrialEnd.ts
|
|
11028
|
-
var
|
|
11203
|
+
var import_react18 = require("react");
|
|
11029
11204
|
function useTrialEnd() {
|
|
11030
11205
|
const { t: t2 } = useTranslation();
|
|
11031
11206
|
const { data } = useEmbed();
|
|
11032
|
-
const { endDate, formatted } = (0,
|
|
11207
|
+
const { endDate, formatted } = (0, import_react18.useMemo)(() => {
|
|
11033
11208
|
const billingSubscription = isCheckoutData(data) ? data.company?.billingSubscription : void 0;
|
|
11034
11209
|
const end = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
|
|
11035
11210
|
let formatted2;
|
|
@@ -11062,12 +11237,12 @@ function useTrialEnd() {
|
|
|
11062
11237
|
}
|
|
11063
11238
|
|
|
11064
11239
|
// src/hooks/useWrapChildren.ts
|
|
11065
|
-
var
|
|
11240
|
+
var import_react19 = require("react");
|
|
11066
11241
|
function useWrapChildren(elements) {
|
|
11067
|
-
const [shouldWrap, setShouldWrap] = (0,
|
|
11242
|
+
const [shouldWrap, setShouldWrap] = (0, import_react19.useState)(
|
|
11068
11243
|
() => new Array(elements.length).fill(false)
|
|
11069
11244
|
);
|
|
11070
|
-
(0,
|
|
11245
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
11071
11246
|
const rowShouldWrap = (parent) => [...parent.children].some(
|
|
11072
11247
|
(el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
|
|
11073
11248
|
);
|
|
@@ -11588,7 +11763,7 @@ var Input = dt.input(({ theme, $size = "md", $variant = "filled" }) => {
|
|
|
11588
11763
|
});
|
|
11589
11764
|
|
|
11590
11765
|
// src/components/ui/modal/Modal.tsx
|
|
11591
|
-
var
|
|
11766
|
+
var import_react20 = require("react");
|
|
11592
11767
|
|
|
11593
11768
|
// src/components/ui/modal/styles.ts
|
|
11594
11769
|
var Overlay = dt(Box)`
|
|
@@ -11653,12 +11828,12 @@ var Modal2 = ({
|
|
|
11653
11828
|
}) => {
|
|
11654
11829
|
const { setLayout } = useEmbed();
|
|
11655
11830
|
const isLightBackground = useIsLightBackground();
|
|
11656
|
-
const ref = (0,
|
|
11657
|
-
const handleClose = (0,
|
|
11831
|
+
const ref = (0, import_react20.useRef)(null);
|
|
11832
|
+
const handleClose = (0, import_react20.useCallback)(() => {
|
|
11658
11833
|
setLayout("portal");
|
|
11659
11834
|
onClose?.();
|
|
11660
11835
|
}, [setLayout, onClose]);
|
|
11661
|
-
(0,
|
|
11836
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
11662
11837
|
contentRef?.current?.focus({ preventScroll: true });
|
|
11663
11838
|
}, [contentRef]);
|
|
11664
11839
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Container, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -11688,7 +11863,7 @@ var Modal2 = ({
|
|
|
11688
11863
|
Modal2.displayName = "Modal";
|
|
11689
11864
|
|
|
11690
11865
|
// src/components/ui/modal/ModalHeader.tsx
|
|
11691
|
-
var
|
|
11866
|
+
var import_react21 = require("react");
|
|
11692
11867
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
11693
11868
|
var ModalHeader = ({
|
|
11694
11869
|
children,
|
|
@@ -11697,7 +11872,7 @@ var ModalHeader = ({
|
|
|
11697
11872
|
}) => {
|
|
11698
11873
|
const { settings, setLayout } = useEmbed();
|
|
11699
11874
|
const isLightBackground = useIsLightBackground();
|
|
11700
|
-
const handleClose = (0,
|
|
11875
|
+
const handleClose = (0, import_react21.useCallback)(() => {
|
|
11701
11876
|
setLayout("portal");
|
|
11702
11877
|
onClose?.();
|
|
11703
11878
|
}, [setLayout, onClose]);
|
|
@@ -11754,7 +11929,7 @@ var ModalHeader = ({
|
|
|
11754
11929
|
};
|
|
11755
11930
|
|
|
11756
11931
|
// src/components/ui/progress-bar/ProgressBar.tsx
|
|
11757
|
-
var
|
|
11932
|
+
var import_react22 = require("react");
|
|
11758
11933
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
11759
11934
|
var progressColorMap = [
|
|
11760
11935
|
"blue",
|
|
@@ -11764,7 +11939,7 @@ var progressColorMap = [
|
|
|
11764
11939
|
"red",
|
|
11765
11940
|
"red"
|
|
11766
11941
|
];
|
|
11767
|
-
var ProgressBar = (0,
|
|
11942
|
+
var ProgressBar = (0, import_react22.forwardRef)(
|
|
11768
11943
|
({
|
|
11769
11944
|
progress,
|
|
11770
11945
|
value,
|
|
@@ -11886,7 +12061,7 @@ var Text = dt.span.withConfig({
|
|
|
11886
12061
|
|
|
11887
12062
|
// src/components/ui/tooltip/Tooltip.tsx
|
|
11888
12063
|
var import_debounce2 = __toESM(require_debounce());
|
|
11889
|
-
var
|
|
12064
|
+
var import_react23 = require("react");
|
|
11890
12065
|
var import_react_dom = require("react-dom");
|
|
11891
12066
|
|
|
11892
12067
|
// src/components/ui/tooltip/styles.ts
|
|
@@ -12043,10 +12218,10 @@ var Tooltip = ({
|
|
|
12043
12218
|
fullWidth = false,
|
|
12044
12219
|
...rest
|
|
12045
12220
|
}) => {
|
|
12046
|
-
const ref = (0,
|
|
12047
|
-
const [show, setShow] = (0,
|
|
12048
|
-
const [coords2, setCoords] = (0,
|
|
12049
|
-
const updateCoords = (0,
|
|
12221
|
+
const ref = (0, import_react23.useRef)(null);
|
|
12222
|
+
const [show, setShow] = (0, import_react23.useState)(false);
|
|
12223
|
+
const [coords2, setCoords] = (0, import_react23.useState)({ x: 0, y: 0 });
|
|
12224
|
+
const updateCoords = (0, import_react23.useCallback)(() => {
|
|
12050
12225
|
if (ref.current) {
|
|
12051
12226
|
const { top: offsetTop, left: offsetLeft } = document.body.getBoundingClientRect();
|
|
12052
12227
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -12064,14 +12239,14 @@ var Tooltip = ({
|
|
|
12064
12239
|
});
|
|
12065
12240
|
}
|
|
12066
12241
|
}, [position2]);
|
|
12067
|
-
(0,
|
|
12242
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
12068
12243
|
const handleResize = (0, import_debounce2.default)(updateCoords, EVENT_DEBOUNCE_TIMEOUT);
|
|
12069
12244
|
window.addEventListener("resize", handleResize);
|
|
12070
12245
|
return () => {
|
|
12071
12246
|
window.removeEventListener("resize", handleResize);
|
|
12072
12247
|
};
|
|
12073
12248
|
}, [updateCoords]);
|
|
12074
|
-
(0,
|
|
12249
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
12075
12250
|
updateCoords();
|
|
12076
12251
|
}, [updateCoords, show]);
|
|
12077
12252
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
@@ -12134,7 +12309,7 @@ var StyledCard = dt.div(({ theme }) => {
|
|
|
12134
12309
|
|
|
12135
12310
|
// src/components/layout/card/Card.tsx
|
|
12136
12311
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
12137
|
-
var Card = (0,
|
|
12312
|
+
var Card = (0, import_react24.forwardRef)(
|
|
12138
12313
|
({ children, className }, ref) => {
|
|
12139
12314
|
const { settings, isPending } = useEmbed();
|
|
12140
12315
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(StyledCard, { ref, className, children: [
|
|
@@ -12162,7 +12337,7 @@ var Card = (0, import_react23.forwardRef)(
|
|
|
12162
12337
|
Card.displayName = "Card";
|
|
12163
12338
|
|
|
12164
12339
|
// src/components/layout/column/Column.tsx
|
|
12165
|
-
var
|
|
12340
|
+
var import_react25 = require("react");
|
|
12166
12341
|
|
|
12167
12342
|
// src/components/layout/column/styles.ts
|
|
12168
12343
|
var StyledColumn = dt.div`
|
|
@@ -12171,15 +12346,15 @@ var StyledColumn = dt.div`
|
|
|
12171
12346
|
|
|
12172
12347
|
// src/components/layout/column/Column.tsx
|
|
12173
12348
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
12174
|
-
var Column = (0,
|
|
12349
|
+
var Column = (0, import_react25.forwardRef)(
|
|
12175
12350
|
({ children, basis, ...props }, ref) => {
|
|
12176
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children:
|
|
12351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react25.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
|
|
12177
12352
|
}
|
|
12178
12353
|
);
|
|
12179
12354
|
Column.displayName = "Column";
|
|
12180
12355
|
|
|
12181
12356
|
// src/components/layout/root/Root.tsx
|
|
12182
|
-
var
|
|
12357
|
+
var import_react26 = require("react");
|
|
12183
12358
|
|
|
12184
12359
|
// src/components/layout/root/styles.ts
|
|
12185
12360
|
var Container = dt.div`
|
|
@@ -12216,7 +12391,7 @@ var Container = dt.div`
|
|
|
12216
12391
|
|
|
12217
12392
|
// src/components/layout/root/Root.tsx
|
|
12218
12393
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
12219
|
-
var Root = (0,
|
|
12394
|
+
var Root = (0, import_react26.forwardRef)(
|
|
12220
12395
|
({ data, settings, ...props }, ref) => {
|
|
12221
12396
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Container, { ref, ...props });
|
|
12222
12397
|
}
|
|
@@ -12225,7 +12400,7 @@ Root.displayName = "Root";
|
|
|
12225
12400
|
|
|
12226
12401
|
// src/components/layout/viewport/Viewport.tsx
|
|
12227
12402
|
var import_debounce3 = __toESM(require_debounce());
|
|
12228
|
-
var
|
|
12403
|
+
var import_react39 = require("react");
|
|
12229
12404
|
var import_react_dom2 = require("react-dom");
|
|
12230
12405
|
|
|
12231
12406
|
// src/components/shared/billing-threshold-tooltip/BillingThresholdTooltip.tsx
|
|
@@ -12258,10 +12433,10 @@ var BillingThresholdTooltip = ({
|
|
|
12258
12433
|
};
|
|
12259
12434
|
|
|
12260
12435
|
// src/components/shared/checkout-dialog/CheckoutDialog.tsx
|
|
12261
|
-
var
|
|
12436
|
+
var import_react31 = require("react");
|
|
12262
12437
|
|
|
12263
12438
|
// src/components/shared/sidebar/Sidebar.tsx
|
|
12264
|
-
var
|
|
12439
|
+
var import_react28 = require("react");
|
|
12265
12440
|
|
|
12266
12441
|
// src/components/shared/sidebar/EntitlementRow.tsx
|
|
12267
12442
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
@@ -12335,11 +12510,11 @@ var EntitlementRow = (entitlement) => {
|
|
|
12335
12510
|
};
|
|
12336
12511
|
|
|
12337
12512
|
// src/components/shared/sidebar/Proration.tsx
|
|
12338
|
-
var
|
|
12513
|
+
var import_react27 = require("react");
|
|
12339
12514
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
12340
12515
|
var Proration = ({ currency, charges }) => {
|
|
12341
12516
|
const { t: t2 } = useTranslation();
|
|
12342
|
-
const [open, setOpen] = (0,
|
|
12517
|
+
const [open, setOpen] = (0, import_react27.useState)(false);
|
|
12343
12518
|
const toggle = (e2) => {
|
|
12344
12519
|
e2.preventDefault();
|
|
12345
12520
|
e2.stopPropagation();
|
|
@@ -12655,10 +12830,19 @@ var Sidebar = ({
|
|
|
12655
12830
|
updatePromoCode,
|
|
12656
12831
|
showHeader = true,
|
|
12657
12832
|
shouldTrial = false,
|
|
12658
|
-
willTrialWithoutPaymentMethod = false
|
|
12833
|
+
willTrialWithoutPaymentMethod = false,
|
|
12834
|
+
setConfirmPaymentIntent
|
|
12659
12835
|
}) => {
|
|
12660
12836
|
const { t: t2 } = useTranslation();
|
|
12661
|
-
const {
|
|
12837
|
+
const {
|
|
12838
|
+
data,
|
|
12839
|
+
settings,
|
|
12840
|
+
layout,
|
|
12841
|
+
setLayout,
|
|
12842
|
+
checkout,
|
|
12843
|
+
finishCheckout,
|
|
12844
|
+
unsubscribe
|
|
12845
|
+
} = useEmbed();
|
|
12662
12846
|
const isLightBackground = useIsLightBackground();
|
|
12663
12847
|
const {
|
|
12664
12848
|
currentPlan,
|
|
@@ -12668,7 +12852,7 @@ var Sidebar = ({
|
|
|
12668
12852
|
billingSubscription,
|
|
12669
12853
|
paymentMethod,
|
|
12670
12854
|
trialPaymentMethodRequired
|
|
12671
|
-
} = (0,
|
|
12855
|
+
} = (0, import_react28.useMemo)(() => {
|
|
12672
12856
|
if (isCheckoutData(data)) {
|
|
12673
12857
|
const currentEntitlements2 = data.featureUsage?.features || [];
|
|
12674
12858
|
return {
|
|
@@ -12706,7 +12890,7 @@ var Sidebar = ({
|
|
|
12706
12890
|
trialPaymentMethodRequired: false
|
|
12707
12891
|
};
|
|
12708
12892
|
}, [data, planPeriod]);
|
|
12709
|
-
const { payInAdvanceEntitlements } = (0,
|
|
12893
|
+
const { payInAdvanceEntitlements } = (0, import_react28.useMemo)(() => {
|
|
12710
12894
|
const payAsYouGoEntitlements = [];
|
|
12711
12895
|
const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
|
|
12712
12896
|
(entitlement) => {
|
|
@@ -12718,7 +12902,7 @@ var Sidebar = ({
|
|
|
12718
12902
|
);
|
|
12719
12903
|
return { payAsYouGoEntitlements, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
|
|
12720
12904
|
}, [usageBasedEntitlements]);
|
|
12721
|
-
const subscriptionPrice = (0,
|
|
12905
|
+
const subscriptionPrice = (0, import_react28.useMemo)(() => {
|
|
12722
12906
|
let planPrice;
|
|
12723
12907
|
let currency;
|
|
12724
12908
|
if (selectedPlan) {
|
|
@@ -12746,17 +12930,28 @@ var Sidebar = ({
|
|
|
12746
12930
|
total += payInAdvanceCost;
|
|
12747
12931
|
return formatCurrency(total, currency);
|
|
12748
12932
|
}, [selectedPlan, currentPlan, planPeriod, addOns, payInAdvanceEntitlements]);
|
|
12749
|
-
const {
|
|
12933
|
+
const {
|
|
12934
|
+
amountOff,
|
|
12935
|
+
dueNow,
|
|
12936
|
+
newCharges,
|
|
12937
|
+
percentOff,
|
|
12938
|
+
periodStart,
|
|
12939
|
+
proration,
|
|
12940
|
+
taxAmount,
|
|
12941
|
+
taxDescription
|
|
12942
|
+
} = (0, import_react28.useMemo)(() => {
|
|
12750
12943
|
return {
|
|
12751
12944
|
amountOff: charges?.amountOff ?? 0,
|
|
12752
12945
|
dueNow: charges?.dueNow ?? 0,
|
|
12753
12946
|
newCharges: charges?.newCharges ?? 0,
|
|
12754
12947
|
percentOff: charges?.percentOff ?? 0,
|
|
12755
12948
|
periodStart: charges?.periodStart,
|
|
12756
|
-
proration: charges?.proration ?? 0
|
|
12949
|
+
proration: charges?.proration ?? 0,
|
|
12950
|
+
taxAmount: charges?.taxAmount ?? 0,
|
|
12951
|
+
taxDescription: charges?.taxDisplayName
|
|
12757
12952
|
};
|
|
12758
12953
|
}, [charges]);
|
|
12759
|
-
const updatedUsageBasedEntitlements = (0,
|
|
12954
|
+
const updatedUsageBasedEntitlements = (0, import_react28.useMemo)(() => {
|
|
12760
12955
|
const changedUsageBasedEntitlements = [];
|
|
12761
12956
|
const addedUsageBasedEntitlements = selectedPlan ? usageBasedEntitlements.reduce(
|
|
12762
12957
|
(acc, selected) => {
|
|
@@ -12807,19 +13002,19 @@ var Sidebar = ({
|
|
|
12807
13002
|
currentUsageBasedEntitlements,
|
|
12808
13003
|
usageBasedEntitlements
|
|
12809
13004
|
]);
|
|
12810
|
-
const selectedAddOns = (0,
|
|
13005
|
+
const selectedAddOns = (0, import_react28.useMemo)(
|
|
12811
13006
|
() => addOns.filter((addOn) => addOn.isSelected),
|
|
12812
13007
|
[addOns]
|
|
12813
13008
|
);
|
|
12814
|
-
const addedCreditBundles = (0,
|
|
13009
|
+
const addedCreditBundles = (0, import_react28.useMemo)(
|
|
12815
13010
|
() => creditBundles.filter((bundle) => bundle.count > 0),
|
|
12816
13011
|
[creditBundles]
|
|
12817
13012
|
);
|
|
12818
|
-
const discountApplied = (0,
|
|
13013
|
+
const discountApplied = (0, import_react28.useMemo)(
|
|
12819
13014
|
() => promoCode && (amountOff > 0 || percentOff > 0),
|
|
12820
13015
|
[promoCode, amountOff, percentOff]
|
|
12821
13016
|
);
|
|
12822
|
-
const handleCheckout = (0,
|
|
13017
|
+
const handleCheckout = (0, import_react28.useCallback)(async () => {
|
|
12823
13018
|
const planId = selectedPlan?.id;
|
|
12824
13019
|
const priceId = (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
|
|
12825
13020
|
try {
|
|
@@ -12857,7 +13052,7 @@ var Sidebar = ({
|
|
|
12857
13052
|
[]
|
|
12858
13053
|
);
|
|
12859
13054
|
const allPayInAdvance = [...planPayInAdvance, ...addOnPayInAdvance];
|
|
12860
|
-
await checkout({
|
|
13055
|
+
const checkoutResponseFromBackend = await checkout({
|
|
12861
13056
|
newPlanId: planId,
|
|
12862
13057
|
newPriceId: priceId,
|
|
12863
13058
|
addOnIds: addOns.reduce((acc, addOn) => {
|
|
@@ -12889,8 +13084,32 @@ var Sidebar = ({
|
|
|
12889
13084
|
...paymentMethodId && { paymentMethodId },
|
|
12890
13085
|
...promoCode && { promoCode }
|
|
12891
13086
|
});
|
|
12892
|
-
|
|
12893
|
-
|
|
13087
|
+
if (checkoutResponseFromBackend?.data.confirmPaymentIntentClientSecret) {
|
|
13088
|
+
setConfirmPaymentIntent({
|
|
13089
|
+
clientSecret: checkoutResponseFromBackend?.data.confirmPaymentIntentClientSecret,
|
|
13090
|
+
callback: (confirmed) => {
|
|
13091
|
+
if (typeof confirmed === "undefined") {
|
|
13092
|
+
return;
|
|
13093
|
+
}
|
|
13094
|
+
console.log("Payment intent has confirmed. Result: ", confirmed);
|
|
13095
|
+
setIsLoading(false);
|
|
13096
|
+
if (!confirmed) {
|
|
13097
|
+
setError(
|
|
13098
|
+
t2(
|
|
13099
|
+
"Error processing payment. Please try a different payment method."
|
|
13100
|
+
)
|
|
13101
|
+
);
|
|
13102
|
+
setLayout("checkout");
|
|
13103
|
+
} else {
|
|
13104
|
+
finishCheckout(checkoutResponseFromBackend?.data);
|
|
13105
|
+
setLayout("portal");
|
|
13106
|
+
}
|
|
13107
|
+
}
|
|
13108
|
+
});
|
|
13109
|
+
} else {
|
|
13110
|
+
setIsLoading(false);
|
|
13111
|
+
setLayout("portal");
|
|
13112
|
+
}
|
|
12894
13113
|
} catch {
|
|
12895
13114
|
setIsLoading(false);
|
|
12896
13115
|
setLayout("checkout");
|
|
@@ -12901,6 +13120,7 @@ var Sidebar = ({
|
|
|
12901
13120
|
}, [
|
|
12902
13121
|
t2,
|
|
12903
13122
|
checkout,
|
|
13123
|
+
setConfirmPaymentIntent,
|
|
12904
13124
|
paymentMethodId,
|
|
12905
13125
|
planPeriod,
|
|
12906
13126
|
selectedPlan,
|
|
@@ -12912,9 +13132,10 @@ var Sidebar = ({
|
|
|
12912
13132
|
payInAdvanceEntitlements,
|
|
12913
13133
|
addOnUsageBasedEntitlements,
|
|
12914
13134
|
shouldTrial,
|
|
12915
|
-
promoCode
|
|
13135
|
+
promoCode,
|
|
13136
|
+
finishCheckout
|
|
12916
13137
|
]);
|
|
12917
|
-
const handleUnsubscribe = (0,
|
|
13138
|
+
const handleUnsubscribe = (0, import_react28.useCallback)(async () => {
|
|
12918
13139
|
try {
|
|
12919
13140
|
setError(void 0);
|
|
12920
13141
|
setIsLoading(true);
|
|
@@ -12928,7 +13149,7 @@ var Sidebar = ({
|
|
|
12928
13149
|
}
|
|
12929
13150
|
}, [t2, unsubscribe, setError, setIsLoading, setLayout]);
|
|
12930
13151
|
const willPlanChange = isHydratedPlan(selectedPlan) && !selectedPlan.current;
|
|
12931
|
-
const { removedAddOns, willAddOnsChange } = (0,
|
|
13152
|
+
const { removedAddOns, willAddOnsChange } = (0, import_react28.useMemo)(() => {
|
|
12932
13153
|
const addedAddOns = selectedAddOns.filter(
|
|
12933
13154
|
(selected) => !currentAddOns.some((current) => selected.id === current.id)
|
|
12934
13155
|
);
|
|
@@ -13386,6 +13607,20 @@ var Sidebar = ({
|
|
|
13386
13607
|
]
|
|
13387
13608
|
}
|
|
13388
13609
|
),
|
|
13610
|
+
taxAmount > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
13611
|
+
Flex,
|
|
13612
|
+
{
|
|
13613
|
+
$justifyContent: "space-between",
|
|
13614
|
+
$alignItems: "center",
|
|
13615
|
+
$gap: "1rem",
|
|
13616
|
+
children: [
|
|
13617
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box, { $opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text, { children: t2("Tax (description):", {
|
|
13618
|
+
description: taxDescription
|
|
13619
|
+
}) }) }),
|
|
13620
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text, { children: formatCurrency(taxAmount, selectedPlanCurrency) }) })
|
|
13621
|
+
]
|
|
13622
|
+
}
|
|
13623
|
+
),
|
|
13389
13624
|
charges && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
13390
13625
|
Flex,
|
|
13391
13626
|
{
|
|
@@ -13590,21 +13825,32 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
13590
13825
|
};
|
|
13591
13826
|
|
|
13592
13827
|
// src/components/shared/checkout-dialog/Checkout.tsx
|
|
13593
|
-
var
|
|
13828
|
+
var import_react29 = require("react");
|
|
13594
13829
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
13595
13830
|
var Checkout = ({
|
|
13596
13831
|
isPaymentMethodRequired,
|
|
13597
13832
|
setPaymentMethodId,
|
|
13598
|
-
updatePromoCode
|
|
13833
|
+
updatePromoCode,
|
|
13834
|
+
confirmPaymentIntentProps,
|
|
13835
|
+
financeData,
|
|
13836
|
+
onPaymentMethodSaved
|
|
13599
13837
|
}) => {
|
|
13600
13838
|
const { t: t2 } = useTranslation();
|
|
13601
13839
|
const isLightBackground = useIsLightBackground();
|
|
13602
|
-
const [discount, setDiscount] = (0,
|
|
13840
|
+
const [discount, setDiscount] = (0, import_react29.useState)("");
|
|
13603
13841
|
if (!isPaymentMethodRequired) {
|
|
13604
13842
|
return null;
|
|
13605
13843
|
}
|
|
13606
13844
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
13607
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
13845
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
13846
|
+
PaymentMethodDetails,
|
|
13847
|
+
{
|
|
13848
|
+
confirmPaymentIntentProps,
|
|
13849
|
+
setPaymentMethodId,
|
|
13850
|
+
financeData,
|
|
13851
|
+
onPaymentMethodSaved
|
|
13852
|
+
}
|
|
13853
|
+
),
|
|
13608
13854
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
|
|
13609
13855
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { display: "heading4", children: t2("Discount") }) }),
|
|
13610
13856
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
@@ -13805,12 +14051,12 @@ var Navigation = ({
|
|
|
13805
14051
|
};
|
|
13806
14052
|
|
|
13807
14053
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
13808
|
-
var
|
|
14054
|
+
var import_react30 = require("react");
|
|
13809
14055
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
13810
14056
|
var Selected = ({ isCurrent = false, isTrial = false }) => {
|
|
13811
14057
|
const { t: t2 } = useTranslation();
|
|
13812
14058
|
const { settings } = useEmbed();
|
|
13813
|
-
const text = (0,
|
|
14059
|
+
const text = (0, import_react30.useMemo)(() => {
|
|
13814
14060
|
if (isCurrent) {
|
|
13815
14061
|
return isTrial ? t2("Trial in progress") : t2("Current plan");
|
|
13816
14062
|
}
|
|
@@ -13846,7 +14092,7 @@ var PlanButtonGroup = ({
|
|
|
13846
14092
|
}) => {
|
|
13847
14093
|
const { t: t2 } = useTranslation();
|
|
13848
14094
|
const { data } = useEmbed();
|
|
13849
|
-
const { isCurrentPlan, isValidPlan, isTrialing } = (0,
|
|
14095
|
+
const { isCurrentPlan, isValidPlan, isTrialing } = (0, import_react30.useMemo)(() => {
|
|
13850
14096
|
if (isCheckoutData(data)) {
|
|
13851
14097
|
return {
|
|
13852
14098
|
isCurrentPlan: data.company?.plan?.id === plan.id,
|
|
@@ -13957,10 +14203,10 @@ var Plan = ({
|
|
|
13957
14203
|
const { t: t2 } = useTranslation();
|
|
13958
14204
|
const { data, settings } = useEmbed();
|
|
13959
14205
|
const isLightBackground = useIsLightBackground();
|
|
13960
|
-
const [entitlementCounts, setEntitlementCounts] = (0,
|
|
14206
|
+
const [entitlementCounts, setEntitlementCounts] = (0, import_react30.useState)(
|
|
13961
14207
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
13962
14208
|
);
|
|
13963
|
-
const { isTrialing, showZeroPriceAsFree } = (0,
|
|
14209
|
+
const { isTrialing, showZeroPriceAsFree } = (0, import_react30.useMemo)(() => {
|
|
13964
14210
|
if (isCheckoutData(data)) {
|
|
13965
14211
|
return {
|
|
13966
14212
|
isTrialing: data.subscription?.status === "trialing",
|
|
@@ -13987,7 +14233,7 @@ var Plan = ({
|
|
|
13987
14233
|
return prev2;
|
|
13988
14234
|
});
|
|
13989
14235
|
};
|
|
13990
|
-
(0,
|
|
14236
|
+
(0, import_react30.useEffect)(() => {
|
|
13991
14237
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
13992
14238
|
}, [plans]);
|
|
13993
14239
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
@@ -14518,24 +14764,25 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14518
14764
|
const { t: t2 } = useTranslation();
|
|
14519
14765
|
const { data, settings, isPending, checkoutState, previewCheckout } = useEmbed();
|
|
14520
14766
|
const isLightBackground = useIsLightBackground();
|
|
14521
|
-
const contentRef = (0,
|
|
14522
|
-
const checkoutRef = (0,
|
|
14523
|
-
const [
|
|
14524
|
-
const [
|
|
14767
|
+
const contentRef = (0, import_react31.useRef)(null);
|
|
14768
|
+
const checkoutRef = (0, import_react31.useRef)(null);
|
|
14769
|
+
const [confirmPaymentIntentProps, setConfirmPaymentIntentProps] = (0, import_react31.useState)(void 0);
|
|
14770
|
+
const [charges, setCharges] = (0, import_react31.useState)();
|
|
14771
|
+
const [paymentMethodId, setPaymentMethodId] = (0, import_react31.useState)(
|
|
14525
14772
|
() => {
|
|
14526
14773
|
if (isCheckoutData(data)) {
|
|
14527
14774
|
return (data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId;
|
|
14528
14775
|
}
|
|
14529
14776
|
}
|
|
14530
14777
|
);
|
|
14531
|
-
const [isLoading, setIsLoading] = (0,
|
|
14532
|
-
const [error, setError] = (0,
|
|
14778
|
+
const [isLoading, setIsLoading] = (0, import_react31.useState)(false);
|
|
14779
|
+
const [error, setError] = (0, import_react31.useState)();
|
|
14533
14780
|
const {
|
|
14534
14781
|
currentPlanId,
|
|
14535
14782
|
currentEntitlements,
|
|
14536
14783
|
showPeriodToggle,
|
|
14537
14784
|
trialPaymentMethodRequired
|
|
14538
|
-
} = (0,
|
|
14785
|
+
} = (0, import_react31.useMemo)(() => {
|
|
14539
14786
|
if (isCheckoutData(data)) {
|
|
14540
14787
|
return {
|
|
14541
14788
|
currentPlanId: data.company?.plan?.id,
|
|
@@ -14551,11 +14798,11 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14551
14798
|
trialPaymentMethodRequired: false
|
|
14552
14799
|
};
|
|
14553
14800
|
}, [data]);
|
|
14554
|
-
const currentPeriod = (0,
|
|
14801
|
+
const currentPeriod = (0, import_react31.useMemo)(
|
|
14555
14802
|
() => checkoutState?.period || isCheckoutData(data) && data.company?.plan?.planPeriod || "month",
|
|
14556
14803
|
[data, checkoutState?.period]
|
|
14557
14804
|
);
|
|
14558
|
-
const [planPeriod, setPlanPeriod] = (0,
|
|
14805
|
+
const [planPeriod, setPlanPeriod] = (0, import_react31.useState)(currentPeriod);
|
|
14559
14806
|
const {
|
|
14560
14807
|
plans: availablePlans,
|
|
14561
14808
|
addOns: availableAddOns,
|
|
@@ -14563,15 +14810,15 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14563
14810
|
} = useAvailablePlans(planPeriod, {
|
|
14564
14811
|
useSelectedPeriod: showPeriodToggle
|
|
14565
14812
|
});
|
|
14566
|
-
const [selectedPlan, setSelectedPlan] = (0,
|
|
14813
|
+
const [selectedPlan, setSelectedPlan] = (0, import_react31.useState)(
|
|
14567
14814
|
() => {
|
|
14568
14815
|
return availablePlans.find(
|
|
14569
14816
|
(plan) => checkoutState?.planId ? plan.id === checkoutState.planId : isHydratedPlan(plan) && plan.current
|
|
14570
14817
|
);
|
|
14571
14818
|
}
|
|
14572
14819
|
);
|
|
14573
|
-
const [shouldTrial, setShouldTrial] = (0,
|
|
14574
|
-
const [addOns, setAddOns] = (0,
|
|
14820
|
+
const [shouldTrial, setShouldTrial] = (0, import_react31.useState)(false);
|
|
14821
|
+
const [addOns, setAddOns] = (0, import_react31.useState)(() => {
|
|
14575
14822
|
if (isCheckoutData(data)) {
|
|
14576
14823
|
return availableAddOns.map((addOn) => ({
|
|
14577
14824
|
...addOn,
|
|
@@ -14582,7 +14829,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14582
14829
|
}
|
|
14583
14830
|
return [];
|
|
14584
14831
|
});
|
|
14585
|
-
const [creditBundles, setCreditBundles] = (0,
|
|
14832
|
+
const [creditBundles, setCreditBundles] = (0, import_react31.useState)(() => {
|
|
14586
14833
|
if (isCheckoutData(data)) {
|
|
14587
14834
|
return data.creditBundles.map((bundle) => ({
|
|
14588
14835
|
...bundle,
|
|
@@ -14591,7 +14838,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14591
14838
|
}
|
|
14592
14839
|
return [];
|
|
14593
14840
|
});
|
|
14594
|
-
const [usageBasedEntitlements, setUsageBasedEntitlements] = (0,
|
|
14841
|
+
const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react31.useState)(
|
|
14595
14842
|
() => (selectedPlan?.entitlements || []).reduce(
|
|
14596
14843
|
createActiveUsageBasedEntitlementsReducer(
|
|
14597
14844
|
currentEntitlements,
|
|
@@ -14600,7 +14847,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14600
14847
|
[]
|
|
14601
14848
|
)
|
|
14602
14849
|
);
|
|
14603
|
-
const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] = (0,
|
|
14850
|
+
const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] = (0, import_react31.useState)(() => {
|
|
14604
14851
|
if (!isCheckoutData(data)) return [];
|
|
14605
14852
|
const currentAddOns = data.company?.addOns || [];
|
|
14606
14853
|
return currentAddOns.flatMap((currentAddOn) => {
|
|
@@ -14617,26 +14864,26 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14617
14864
|
);
|
|
14618
14865
|
});
|
|
14619
14866
|
});
|
|
14620
|
-
const payInAdvanceEntitlements = (0,
|
|
14867
|
+
const payInAdvanceEntitlements = (0, import_react31.useMemo)(
|
|
14621
14868
|
() => usageBasedEntitlements.filter(
|
|
14622
14869
|
(entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
|
|
14623
14870
|
),
|
|
14624
14871
|
[usageBasedEntitlements]
|
|
14625
14872
|
);
|
|
14626
|
-
const addOnPayInAdvanceEntitlements = (0,
|
|
14873
|
+
const addOnPayInAdvanceEntitlements = (0, import_react31.useMemo)(
|
|
14627
14874
|
() => addOnUsageBasedEntitlements.filter(
|
|
14628
14875
|
(entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
|
|
14629
14876
|
),
|
|
14630
14877
|
[addOnUsageBasedEntitlements]
|
|
14631
14878
|
);
|
|
14632
|
-
const [promoCode, setPromoCode] = (0,
|
|
14633
|
-
const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0,
|
|
14634
|
-
const willTrialWithoutPaymentMethod = (0,
|
|
14879
|
+
const [promoCode, setPromoCode] = (0, import_react31.useState)(null);
|
|
14880
|
+
const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0, import_react31.useState)(false);
|
|
14881
|
+
const willTrialWithoutPaymentMethod = (0, import_react31.useMemo)(
|
|
14635
14882
|
() => shouldTrial && !trialPaymentMethodRequired,
|
|
14636
14883
|
[shouldTrial, trialPaymentMethodRequired]
|
|
14637
14884
|
);
|
|
14638
14885
|
const isSelectedPlanTrialable = isHydratedPlan(selectedPlan) && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
|
|
14639
|
-
const checkoutStages = (0,
|
|
14886
|
+
const checkoutStages = (0, import_react31.useMemo)(() => {
|
|
14640
14887
|
const stages = [];
|
|
14641
14888
|
if (availablePlans.length > 0) {
|
|
14642
14889
|
stages.push({
|
|
@@ -14703,7 +14950,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14703
14950
|
creditBundles,
|
|
14704
14951
|
isPaymentMethodRequired
|
|
14705
14952
|
]);
|
|
14706
|
-
const [checkoutStage, setCheckoutStage] = (0,
|
|
14953
|
+
const [checkoutStage, setCheckoutStage] = (0, import_react31.useState)(() => {
|
|
14707
14954
|
if (checkoutState?.addOnId) {
|
|
14708
14955
|
return "addons";
|
|
14709
14956
|
}
|
|
@@ -14721,7 +14968,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14721
14968
|
}
|
|
14722
14969
|
return "plan";
|
|
14723
14970
|
});
|
|
14724
|
-
const handlePreviewCheckout = (0,
|
|
14971
|
+
const handlePreviewCheckout = (0, import_react31.useCallback)(
|
|
14725
14972
|
async (updates) => {
|
|
14726
14973
|
const period = updates.period || planPeriod;
|
|
14727
14974
|
const plan = updates.plan || selectedPlan;
|
|
@@ -14845,7 +15092,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14845
15092
|
promoCode
|
|
14846
15093
|
]
|
|
14847
15094
|
);
|
|
14848
|
-
const selectPlan = (0,
|
|
15095
|
+
const selectPlan = (0, import_react31.useCallback)(
|
|
14849
15096
|
(updates) => {
|
|
14850
15097
|
const plan = updates.plan;
|
|
14851
15098
|
const period = updates.period || planPeriod;
|
|
@@ -14900,7 +15147,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14900
15147
|
handlePreviewCheckout
|
|
14901
15148
|
]
|
|
14902
15149
|
);
|
|
14903
|
-
const changePlanPeriod = (0,
|
|
15150
|
+
const changePlanPeriod = (0, import_react31.useCallback)(
|
|
14904
15151
|
(period) => {
|
|
14905
15152
|
if (period !== planPeriod) {
|
|
14906
15153
|
setPlanPeriod(period);
|
|
@@ -14909,7 +15156,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14909
15156
|
},
|
|
14910
15157
|
[planPeriod, setPlanPeriod, handlePreviewCheckout]
|
|
14911
15158
|
);
|
|
14912
|
-
const toggleAddOn = (0,
|
|
15159
|
+
const toggleAddOn = (0, import_react31.useCallback)(
|
|
14913
15160
|
(id) => {
|
|
14914
15161
|
setAddOns((prev2) => {
|
|
14915
15162
|
const updated = prev2.map((addOn) => ({
|
|
@@ -14936,7 +15183,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14936
15183
|
},
|
|
14937
15184
|
[handlePreviewCheckout]
|
|
14938
15185
|
);
|
|
14939
|
-
const updateUsageBasedEntitlementQuantity = (0,
|
|
15186
|
+
const updateUsageBasedEntitlementQuantity = (0, import_react31.useCallback)(
|
|
14940
15187
|
(id, updatedQuantity) => {
|
|
14941
15188
|
setUsageBasedEntitlements((prev2) => {
|
|
14942
15189
|
const updated = prev2.map(
|
|
@@ -14955,7 +15202,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14955
15202
|
},
|
|
14956
15203
|
[handlePreviewCheckout]
|
|
14957
15204
|
);
|
|
14958
|
-
const updateCreditBundleCount = (0,
|
|
15205
|
+
const updateCreditBundleCount = (0, import_react31.useCallback)(
|
|
14959
15206
|
(id, updatedCount) => {
|
|
14960
15207
|
setCreditBundles((prev2) => {
|
|
14961
15208
|
const updated = prev2.map(
|
|
@@ -14970,7 +15217,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14970
15217
|
},
|
|
14971
15218
|
[handlePreviewCheckout]
|
|
14972
15219
|
);
|
|
14973
|
-
const updateAddOnEntitlementQuantity = (0,
|
|
15220
|
+
const updateAddOnEntitlementQuantity = (0, import_react31.useCallback)(
|
|
14974
15221
|
(id, updatedQuantity) => {
|
|
14975
15222
|
setAddOnUsageBasedEntitlements((prev2) => {
|
|
14976
15223
|
const updated = prev2.map(
|
|
@@ -14987,18 +15234,18 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14987
15234
|
},
|
|
14988
15235
|
[handlePreviewCheckout]
|
|
14989
15236
|
);
|
|
14990
|
-
const updatePromoCode = (0,
|
|
15237
|
+
const updatePromoCode = (0, import_react31.useCallback)(
|
|
14991
15238
|
async (code) => {
|
|
14992
15239
|
handlePreviewCheckout({ promoCode: code });
|
|
14993
15240
|
},
|
|
14994
15241
|
[handlePreviewCheckout]
|
|
14995
15242
|
);
|
|
14996
|
-
(0,
|
|
15243
|
+
(0, import_react31.useEffect)(() => {
|
|
14997
15244
|
if (selectedPlan) {
|
|
14998
15245
|
selectPlan({ plan: selectedPlan, period: currentPeriod });
|
|
14999
15246
|
}
|
|
15000
15247
|
}, []);
|
|
15001
|
-
(0,
|
|
15248
|
+
(0, import_react31.useEffect)(() => {
|
|
15002
15249
|
setAddOns((prevAddOns) => {
|
|
15003
15250
|
return availableAddOns.filter((availAddOn) => {
|
|
15004
15251
|
if (!selectedPlan) {
|
|
@@ -15020,7 +15267,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15020
15267
|
});
|
|
15021
15268
|
});
|
|
15022
15269
|
}, [availableAddOns, data?.addOnCompatibilities, selectedPlan]);
|
|
15023
|
-
(0,
|
|
15270
|
+
(0, import_react31.useEffect)(() => {
|
|
15024
15271
|
if (charges) {
|
|
15025
15272
|
checkoutRef.current?.scrollTo({
|
|
15026
15273
|
top: 0,
|
|
@@ -15029,7 +15276,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15029
15276
|
});
|
|
15030
15277
|
}
|
|
15031
15278
|
}, [charges]);
|
|
15032
|
-
(0,
|
|
15279
|
+
(0, import_react31.useLayoutEffect)(() => {
|
|
15033
15280
|
contentRef.current?.scrollTo({
|
|
15034
15281
|
top: 0,
|
|
15035
15282
|
left: 0,
|
|
@@ -15191,7 +15438,10 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15191
15438
|
{
|
|
15192
15439
|
isPaymentMethodRequired,
|
|
15193
15440
|
setPaymentMethodId: (id) => setPaymentMethodId(id),
|
|
15194
|
-
updatePromoCode
|
|
15441
|
+
updatePromoCode,
|
|
15442
|
+
confirmPaymentIntentProps,
|
|
15443
|
+
financeData: charges,
|
|
15444
|
+
onPaymentMethodSaved: handlePreviewCheckout
|
|
15195
15445
|
}
|
|
15196
15446
|
)
|
|
15197
15447
|
]
|
|
@@ -15220,6 +15470,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15220
15470
|
setIsLoading,
|
|
15221
15471
|
updatePromoCode,
|
|
15222
15472
|
shouldTrial,
|
|
15473
|
+
setConfirmPaymentIntent: setConfirmPaymentIntentProps,
|
|
15223
15474
|
willTrialWithoutPaymentMethod
|
|
15224
15475
|
}
|
|
15225
15476
|
)
|
|
@@ -15230,11 +15481,11 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15230
15481
|
};
|
|
15231
15482
|
|
|
15232
15483
|
// src/components/shared/payment-dialog/PaymentDialog.tsx
|
|
15233
|
-
var
|
|
15484
|
+
var import_react32 = require("react");
|
|
15234
15485
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
15235
15486
|
var PaymentDialog = ({ top = 0 }) => {
|
|
15236
15487
|
const { t: t2 } = useTranslation();
|
|
15237
|
-
const contentRef = (0,
|
|
15488
|
+
const contentRef = (0, import_react32.useRef)(null);
|
|
15238
15489
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Modal2, { size: "md", top, contentRef, children: [
|
|
15239
15490
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ModalHeader, { bordered: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text, { $size: 18, children: t2("Edit payment method") }) }),
|
|
15240
15491
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaymentMethodDetails, {})
|
|
@@ -15243,7 +15494,7 @@ var PaymentDialog = ({ top = 0 }) => {
|
|
|
15243
15494
|
|
|
15244
15495
|
// src/components/shared/payment-form/PaymentForm.tsx
|
|
15245
15496
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
15246
|
-
var
|
|
15497
|
+
var import_react33 = require("react");
|
|
15247
15498
|
|
|
15248
15499
|
// src/components/shared/payment-form/styles.ts
|
|
15249
15500
|
var Label = dt.label`
|
|
@@ -15300,19 +15551,26 @@ var Input2 = dt.input`
|
|
|
15300
15551
|
|
|
15301
15552
|
// src/components/shared/payment-form/PaymentForm.tsx
|
|
15302
15553
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
15303
|
-
var PaymentForm = ({ onConfirm }) => {
|
|
15554
|
+
var PaymentForm = ({ onConfirm, financeData }) => {
|
|
15304
15555
|
const { t: t2 } = useTranslation();
|
|
15305
15556
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
15306
15557
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
15307
15558
|
const { data } = useEmbed();
|
|
15308
|
-
const [email, setEmail] = (0,
|
|
15309
|
-
const [message, setMessage] = (0,
|
|
15310
|
-
const [isLoading, setIsLoading] = (0,
|
|
15311
|
-
const [isConfirmed, setIsConfirmed] = (0,
|
|
15312
|
-
const [isPaymentComplete, setIsPaymentComplete] = (0,
|
|
15313
|
-
const [isAddressComplete, setIsAddressComplete] = (0,
|
|
15314
|
-
(
|
|
15315
|
-
|
|
15559
|
+
const [email, setEmail] = (0, import_react33.useState)("");
|
|
15560
|
+
const [message, setMessage] = (0, import_react33.useState)();
|
|
15561
|
+
const [isLoading, setIsLoading] = (0, import_react33.useState)(false);
|
|
15562
|
+
const [isConfirmed, setIsConfirmed] = (0, import_react33.useState)(false);
|
|
15563
|
+
const [isPaymentComplete, setIsPaymentComplete] = (0, import_react33.useState)(false);
|
|
15564
|
+
const [isAddressComplete, setIsAddressComplete] = (0, import_react33.useState)(() => {
|
|
15565
|
+
if (!isCheckoutData(data)) {
|
|
15566
|
+
return true;
|
|
15567
|
+
}
|
|
15568
|
+
const shouldCollectAddress = shouldCollectBillingAddress(
|
|
15569
|
+
data.checkoutSettings.collectAddress,
|
|
15570
|
+
financeData
|
|
15571
|
+
);
|
|
15572
|
+
return !shouldCollectAddress;
|
|
15573
|
+
});
|
|
15316
15574
|
const handleSubmit = async (event) => {
|
|
15317
15575
|
event.preventDefault();
|
|
15318
15576
|
if (!stripe || !elements) {
|
|
@@ -15381,7 +15639,10 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
15381
15639
|
}
|
|
15382
15640
|
)
|
|
15383
15641
|
] }),
|
|
15384
|
-
isCheckoutData(data) && (
|
|
15642
|
+
isCheckoutData(data) && (shouldCollectBillingAddress(
|
|
15643
|
+
data.checkoutSettings.collectAddress,
|
|
15644
|
+
financeData
|
|
15645
|
+
) || data.checkoutSettings.collectPhone) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Box, { $marginBottom: "3.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
15385
15646
|
import_react_stripe_js.AddressElement,
|
|
15386
15647
|
{
|
|
15387
15648
|
options: {
|
|
@@ -15415,7 +15676,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
15415
15676
|
};
|
|
15416
15677
|
|
|
15417
15678
|
// src/components/shared/period-toggle/PeriodToggle.tsx
|
|
15418
|
-
var
|
|
15679
|
+
var import_react34 = require("react");
|
|
15419
15680
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
15420
15681
|
var PeriodToggle = ({
|
|
15421
15682
|
options,
|
|
@@ -15426,7 +15687,7 @@ var PeriodToggle = ({
|
|
|
15426
15687
|
const { t: t2 } = useTranslation();
|
|
15427
15688
|
const { settings } = useEmbed();
|
|
15428
15689
|
const isLightBackground = useIsLightBackground();
|
|
15429
|
-
const savingsPercentage = (0,
|
|
15690
|
+
const savingsPercentage = (0, import_react34.useMemo)(() => {
|
|
15430
15691
|
if (selectedPlan) {
|
|
15431
15692
|
const monthlyBillingPrice = getPlanPrice(selectedPlan, "month");
|
|
15432
15693
|
const yearlyBillingPrice = getPlanPrice(selectedPlan, "year");
|
|
@@ -15506,10 +15767,10 @@ var PeriodToggle = ({
|
|
|
15506
15767
|
};
|
|
15507
15768
|
|
|
15508
15769
|
// src/components/shared/pricing-tiers-tooltip/PricingTiersTooltip.tsx
|
|
15509
|
-
var
|
|
15770
|
+
var import_react36 = require("react");
|
|
15510
15771
|
|
|
15511
15772
|
// src/components/shared/pricing-tiers-tooltip/PriceText.tsx
|
|
15512
|
-
var
|
|
15773
|
+
var import_react35 = require("react");
|
|
15513
15774
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
15514
15775
|
var PriceText = ({
|
|
15515
15776
|
feature,
|
|
@@ -15519,7 +15780,7 @@ var PriceText = ({
|
|
|
15519
15780
|
perUnitPrice = 0
|
|
15520
15781
|
}) => {
|
|
15521
15782
|
const { settings } = useEmbed();
|
|
15522
|
-
const text = (0,
|
|
15783
|
+
const text = (0, import_react35.useMemo)(() => {
|
|
15523
15784
|
if (!flatAmount && perUnitPrice) {
|
|
15524
15785
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
15525
15786
|
formatCurrency(perUnitPrice, currency),
|
|
@@ -15567,7 +15828,7 @@ var PricingTiersTooltip = ({
|
|
|
15567
15828
|
const { t: t2 } = useTranslation();
|
|
15568
15829
|
const { settings } = useEmbed();
|
|
15569
15830
|
const isLightBackground = useIsLightBackground();
|
|
15570
|
-
const tiers = (0,
|
|
15831
|
+
const tiers = (0, import_react36.useMemo)(() => {
|
|
15571
15832
|
let start = 1;
|
|
15572
15833
|
return priceTiers.map((tier) => {
|
|
15573
15834
|
const { upTo, ...rest } = tier;
|
|
@@ -15655,13 +15916,13 @@ var PricingTiersTooltip = ({
|
|
|
15655
15916
|
};
|
|
15656
15917
|
|
|
15657
15918
|
// src/components/shared/tiered-pricing-details/TieredPricingDetails.tsx
|
|
15658
|
-
var
|
|
15919
|
+
var import_react37 = require("react");
|
|
15659
15920
|
var TieredPricingDetails = ({
|
|
15660
15921
|
entitlement,
|
|
15661
15922
|
period
|
|
15662
15923
|
}) => {
|
|
15663
15924
|
const { t: t2 } = useTranslation();
|
|
15664
|
-
const { currency, flatAmount, perUnitPrice, upTo } = (0,
|
|
15925
|
+
const { currency, flatAmount, perUnitPrice, upTo } = (0, import_react37.useMemo)(() => {
|
|
15665
15926
|
const { currency: currency2, priceTier } = getEntitlementPrice(entitlement, period) || {};
|
|
15666
15927
|
const { flatAmount: flatAmount2, perUnitPrice: perUnitPrice2, perUnitPriceDecimal, upTo: upTo2 } = priceTier?.[0] || {};
|
|
15667
15928
|
return {
|
|
@@ -15709,15 +15970,15 @@ var TieredPricingDetails = ({
|
|
|
15709
15970
|
};
|
|
15710
15971
|
|
|
15711
15972
|
// src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
|
|
15712
|
-
var
|
|
15973
|
+
var import_react38 = require("react");
|
|
15713
15974
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
15714
15975
|
var UnsubscribeDialog = ({ top = 0 }) => {
|
|
15715
15976
|
const { t: t2 } = useTranslation();
|
|
15716
15977
|
const { data, setCheckoutState } = useEmbed();
|
|
15717
|
-
const contentRef = (0,
|
|
15718
|
-
const [error, setError] = (0,
|
|
15719
|
-
const [isLoading, setIsLoading] = (0,
|
|
15720
|
-
const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0,
|
|
15978
|
+
const contentRef = (0, import_react38.useRef)(null);
|
|
15979
|
+
const [error, setError] = (0, import_react38.useState)();
|
|
15980
|
+
const [isLoading, setIsLoading] = (0, import_react38.useState)(false);
|
|
15981
|
+
const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0, import_react38.useMemo)(() => {
|
|
15721
15982
|
if (isCheckoutData(data)) {
|
|
15722
15983
|
return {
|
|
15723
15984
|
planPeriod: data.company?.plan?.planPeriod || "month",
|
|
@@ -15738,7 +15999,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
|
|
|
15738
15999
|
};
|
|
15739
16000
|
}, [data]);
|
|
15740
16001
|
const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
|
|
15741
|
-
const selectedPlan = (0,
|
|
16002
|
+
const selectedPlan = (0, import_react38.useMemo)(
|
|
15742
16003
|
() => availablePlans.find((plan) => plan.id === currentPlan?.id),
|
|
15743
16004
|
[currentPlan?.id, availablePlans]
|
|
15744
16005
|
);
|
|
@@ -15747,7 +16008,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
|
|
|
15747
16008
|
createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
|
|
15748
16009
|
[]
|
|
15749
16010
|
);
|
|
15750
|
-
const addOns = (0,
|
|
16011
|
+
const addOns = (0, import_react38.useMemo)(
|
|
15751
16012
|
() => availableAddOns.map((available) => ({
|
|
15752
16013
|
...available,
|
|
15753
16014
|
isSelected: currentAddOns.some((current) => available.id === current.id) ?? false
|
|
@@ -15823,7 +16084,9 @@ var UnsubscribeDialog = ({ top = 0 }) => {
|
|
|
15823
16084
|
isPaymentMethodRequired: false,
|
|
15824
16085
|
showHeader: false,
|
|
15825
16086
|
setError: (msg) => setError(msg),
|
|
15826
|
-
setIsLoading
|
|
16087
|
+
setIsLoading,
|
|
16088
|
+
setConfirmPaymentIntent: () => {
|
|
16089
|
+
}
|
|
15827
16090
|
}
|
|
15828
16091
|
)
|
|
15829
16092
|
]
|
|
@@ -15986,17 +16249,17 @@ var StyledViewport = dt.div.withConfig({
|
|
|
15986
16249
|
|
|
15987
16250
|
// src/components/layout/viewport/Viewport.tsx
|
|
15988
16251
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
15989
|
-
var Viewport = (0,
|
|
16252
|
+
var Viewport = (0, import_react39.forwardRef)(
|
|
15990
16253
|
({ children, portal, ...props }, ref) => {
|
|
15991
16254
|
const { data, layout, settings } = useEmbed();
|
|
15992
|
-
const [top, setTop] = (0,
|
|
15993
|
-
const { canCheckout, isBadgeVisible } = (0,
|
|
16255
|
+
const [top, setTop] = (0, import_react39.useState)(0);
|
|
16256
|
+
const { canCheckout, isBadgeVisible } = (0, import_react39.useMemo)(() => {
|
|
15994
16257
|
return {
|
|
15995
16258
|
canCheckout: data?.capabilities?.checkout ?? true,
|
|
15996
16259
|
isBadgeVisible: !data?.capabilities?.badgeVisibility || settings.badge?.visibility !== "hidden"
|
|
15997
16260
|
};
|
|
15998
16261
|
}, [data, settings]);
|
|
15999
|
-
(0,
|
|
16262
|
+
(0, import_react39.useLayoutEffect)(() => {
|
|
16000
16263
|
const parent = portal || document.body;
|
|
16001
16264
|
const setModalY = (0, import_debounce3.default)(() => {
|
|
16002
16265
|
const value = Math.abs(
|
|
@@ -16043,7 +16306,7 @@ var resolveDesignProps = (props) => {
|
|
|
16043
16306
|
}
|
|
16044
16307
|
};
|
|
16045
16308
|
};
|
|
16046
|
-
var ButtonElement = (0,
|
|
16309
|
+
var ButtonElement = (0, import_react40.forwardRef)(({ children, className, ...rest }, ref) => {
|
|
16047
16310
|
const props = resolveDesignProps(rest);
|
|
16048
16311
|
const buttonStyles2 = {
|
|
16049
16312
|
primary: {
|
|
@@ -16088,10 +16351,10 @@ var ButtonElement = (0, import_react39.forwardRef)(({ children, className, ...re
|
|
|
16088
16351
|
ButtonElement.displayName = "Button";
|
|
16089
16352
|
|
|
16090
16353
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
|
16091
|
-
var
|
|
16354
|
+
var import_react42 = require("react");
|
|
16092
16355
|
|
|
16093
16356
|
// src/components/elements/included-features/UsageDetails.tsx
|
|
16094
|
-
var
|
|
16357
|
+
var import_react41 = require("react");
|
|
16095
16358
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
16096
16359
|
var UsageDetails = ({
|
|
16097
16360
|
entitlement,
|
|
@@ -16110,14 +16373,14 @@ var UsageDetails = ({
|
|
|
16110
16373
|
} = entitlement;
|
|
16111
16374
|
const { t: t2 } = useTranslation();
|
|
16112
16375
|
const { data } = useEmbed();
|
|
16113
|
-
const period = (0,
|
|
16376
|
+
const period = (0, import_react41.useMemo)(() => {
|
|
16114
16377
|
return isCheckoutData(data) && typeof data.company?.plan?.planPeriod === "string" ? data.company.plan.planPeriod : void 0;
|
|
16115
16378
|
}, [data]);
|
|
16116
|
-
const { billingPrice, cost, currentTier } = (0,
|
|
16379
|
+
const { billingPrice, cost, currentTier } = (0, import_react41.useMemo)(
|
|
16117
16380
|
() => getUsageDetails(entitlement, period),
|
|
16118
16381
|
[entitlement, period]
|
|
16119
16382
|
);
|
|
16120
|
-
const text = (0,
|
|
16383
|
+
const text = (0, import_react41.useMemo)(() => {
|
|
16121
16384
|
if (!feature) {
|
|
16122
16385
|
return;
|
|
16123
16386
|
}
|
|
@@ -16192,7 +16455,7 @@ var UsageDetails = ({
|
|
|
16192
16455
|
billingPrice,
|
|
16193
16456
|
currentTier?.to
|
|
16194
16457
|
]);
|
|
16195
|
-
const usageText = (0,
|
|
16458
|
+
const usageText = (0, import_react41.useMemo)(() => {
|
|
16196
16459
|
if (!feature) {
|
|
16197
16460
|
return;
|
|
16198
16461
|
}
|
|
@@ -16201,7 +16464,7 @@ var UsageDetails = ({
|
|
|
16201
16464
|
let index = 0;
|
|
16202
16465
|
if (priceBehavior === "pay_in_advance" /* PayInAdvance */ && typeof period === "string" && typeof price === "number") {
|
|
16203
16466
|
acc.push(
|
|
16204
|
-
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
16467
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react41.Fragment, { children: [
|
|
16205
16468
|
formatCurrency(price, currency),
|
|
16206
16469
|
"/",
|
|
16207
16470
|
packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
@@ -16216,7 +16479,7 @@ var UsageDetails = ({
|
|
|
16216
16479
|
index += 1;
|
|
16217
16480
|
} else if ((priceBehavior === "pay_as_you_go" /* PayAsYouGo */ || priceBehavior === "overage" /* Overage */ || priceBehavior === "tier" /* Tiered */ || priceBehavior === "credit_burndown" /* Credit */) && typeof usage === "number") {
|
|
16218
16481
|
acc.push(
|
|
16219
|
-
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
16482
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react41.Fragment, { children: [
|
|
16220
16483
|
usage,
|
|
16221
16484
|
" ",
|
|
16222
16485
|
getFeatureName(feature, usage),
|
|
@@ -16228,14 +16491,14 @@ var UsageDetails = ({
|
|
|
16228
16491
|
}
|
|
16229
16492
|
if (typeof cost === "number" && cost > 0) {
|
|
16230
16493
|
acc.push(
|
|
16231
|
-
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
16494
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react41.Fragment, { children: [
|
|
16232
16495
|
acc.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: " \u2022 " }),
|
|
16233
16496
|
formatCurrency(cost, currency)
|
|
16234
16497
|
] }, index)
|
|
16235
16498
|
);
|
|
16236
16499
|
index += 1;
|
|
16237
16500
|
if (feature.featureType === "trait" /* Trait */ && typeof period === "string") {
|
|
16238
|
-
acc.push(/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
16501
|
+
acc.push(/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react41.Fragment, { children: [
|
|
16239
16502
|
"/",
|
|
16240
16503
|
shortenPeriod(period)
|
|
16241
16504
|
] }, index));
|
|
@@ -16244,7 +16507,7 @@ var UsageDetails = ({
|
|
|
16244
16507
|
}
|
|
16245
16508
|
if (metricResetAt) {
|
|
16246
16509
|
acc.push(
|
|
16247
|
-
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
16510
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react41.Fragment, { children: [
|
|
16248
16511
|
acc.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: " \u2022 " }),
|
|
16249
16512
|
t2("Resets", {
|
|
16250
16513
|
date: toPrettyDate(metricResetAt, {
|
|
@@ -16337,15 +16600,15 @@ function resolveDesignProps2(props) {
|
|
|
16337
16600
|
visibleFeatures: props.visibleFeatures
|
|
16338
16601
|
};
|
|
16339
16602
|
}
|
|
16340
|
-
var IncludedFeatures = (0,
|
|
16603
|
+
var IncludedFeatures = (0, import_react42.forwardRef)(({ className, ...rest }, ref) => {
|
|
16341
16604
|
const props = resolveDesignProps2(rest);
|
|
16342
16605
|
const { t: t2 } = useTranslation();
|
|
16343
16606
|
const { data, settings } = useEmbed();
|
|
16344
|
-
const elements = (0,
|
|
16607
|
+
const elements = (0, import_react42.useRef)([]);
|
|
16345
16608
|
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
16346
16609
|
const isLightBackground = useIsLightBackground();
|
|
16347
|
-
const [showCount, setShowCount] = (0,
|
|
16348
|
-
const { plan, addOns, featureUsage } = (0,
|
|
16610
|
+
const [showCount, setShowCount] = (0, import_react42.useState)(VISIBLE_ENTITLEMENT_COUNT);
|
|
16611
|
+
const { plan, addOns, featureUsage } = (0, import_react42.useMemo)(() => {
|
|
16349
16612
|
if (isCheckoutData(data)) {
|
|
16350
16613
|
const orderedFeatureUsage = props.visibleFeatures?.reduce(
|
|
16351
16614
|
(acc, id) => {
|
|
@@ -16481,7 +16744,7 @@ var IncludedFeatures = (0, import_react41.forwardRef)(({ className, ...rest }, r
|
|
|
16481
16744
|
IncludedFeatures.displayName = "IncludedFeatures";
|
|
16482
16745
|
|
|
16483
16746
|
// src/components/elements/invoices/Invoices.tsx
|
|
16484
|
-
var
|
|
16747
|
+
var import_react43 = require("react");
|
|
16485
16748
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
16486
16749
|
function resolveDesignProps3(props) {
|
|
16487
16750
|
return {
|
|
@@ -16516,15 +16779,15 @@ function formatInvoices(invoices, options) {
|
|
|
16516
16779
|
url: url || void 0
|
|
16517
16780
|
}));
|
|
16518
16781
|
}
|
|
16519
|
-
var Invoices = (0,
|
|
16782
|
+
var Invoices = (0, import_react43.forwardRef)(({ className, data, ...rest }, ref) => {
|
|
16520
16783
|
const props = resolveDesignProps3(rest);
|
|
16521
16784
|
const { t: t2 } = useTranslation();
|
|
16522
16785
|
const { listInvoices, settings } = useEmbed();
|
|
16523
|
-
const [isLoading, setIsLoading] = (0,
|
|
16524
|
-
const [error, setError] = (0,
|
|
16525
|
-
const [invoices, setInvoices] = (0,
|
|
16526
|
-
const [listSize, setListSize] = (0,
|
|
16527
|
-
const getInvoices = (0,
|
|
16786
|
+
const [isLoading, setIsLoading] = (0, import_react43.useState)(false);
|
|
16787
|
+
const [error, setError] = (0, import_react43.useState)();
|
|
16788
|
+
const [invoices, setInvoices] = (0, import_react43.useState)(() => formatInvoices(data));
|
|
16789
|
+
const [listSize, setListSize] = (0, import_react43.useState)(props.limit.number);
|
|
16790
|
+
const getInvoices = (0, import_react43.useCallback)(async () => {
|
|
16528
16791
|
try {
|
|
16529
16792
|
setError(void 0);
|
|
16530
16793
|
setIsLoading(true);
|
|
@@ -16543,10 +16806,10 @@ var Invoices = (0, import_react42.forwardRef)(({ className, data, ...rest }, ref
|
|
|
16543
16806
|
(prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
|
|
16544
16807
|
);
|
|
16545
16808
|
};
|
|
16546
|
-
(0,
|
|
16809
|
+
(0, import_react43.useEffect)(() => {
|
|
16547
16810
|
getInvoices();
|
|
16548
16811
|
}, [getInvoices]);
|
|
16549
|
-
(0,
|
|
16812
|
+
(0, import_react43.useEffect)(() => {
|
|
16550
16813
|
setInvoices(formatInvoices(data));
|
|
16551
16814
|
}, [data]);
|
|
16552
16815
|
if (invoices.length === 0) {
|
|
@@ -16626,7 +16889,7 @@ var Invoices = (0, import_react42.forwardRef)(({ className, data, ...rest }, ref
|
|
|
16626
16889
|
Invoices.displayName = "Invoices";
|
|
16627
16890
|
|
|
16628
16891
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
|
16629
|
-
var
|
|
16892
|
+
var import_react44 = require("react");
|
|
16630
16893
|
|
|
16631
16894
|
// src/components/elements/metered-features/Meter.tsx
|
|
16632
16895
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
@@ -16824,14 +17087,14 @@ function resolveDesignProps4(props) {
|
|
|
16824
17087
|
visibleFeatures: props.visibleFeatures
|
|
16825
17088
|
};
|
|
16826
17089
|
}
|
|
16827
|
-
var MeteredFeatures = (0,
|
|
17090
|
+
var MeteredFeatures = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
|
|
16828
17091
|
const props = resolveDesignProps4(rest);
|
|
16829
|
-
const elements = (0,
|
|
17092
|
+
const elements = (0, import_react44.useRef)([]);
|
|
16830
17093
|
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
16831
17094
|
const { t: t2 } = useTranslation();
|
|
16832
17095
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
16833
17096
|
const isLightBackground = useIsLightBackground();
|
|
16834
|
-
const { period, meteredFeatures, creditGroups } = (0,
|
|
17097
|
+
const { period, meteredFeatures, creditGroups } = (0, import_react44.useMemo)(() => {
|
|
16835
17098
|
if (isCheckoutData(data)) {
|
|
16836
17099
|
const period2 = typeof data.company?.plan?.planPeriod === "string" ? data.company?.plan?.planPeriod : void 0;
|
|
16837
17100
|
const orderedFeatureUsage = props.visibleFeatures?.reduce(
|
|
@@ -16865,10 +17128,10 @@ var MeteredFeatures = (0, import_react43.forwardRef)(({ className, ...rest }, re
|
|
|
16865
17128
|
creditGroups: []
|
|
16866
17129
|
};
|
|
16867
17130
|
}, [props.visibleFeatures, data]);
|
|
16868
|
-
const [creditVisibility, setCreditVisibility] = (0,
|
|
17131
|
+
const [creditVisibility, setCreditVisibility] = (0, import_react44.useState)(
|
|
16869
17132
|
creditGroups.map(({ id }) => ({ id, isExpanded: false }))
|
|
16870
17133
|
);
|
|
16871
|
-
const toggleBalanceDetails = (0,
|
|
17134
|
+
const toggleBalanceDetails = (0, import_react44.useCallback)((id) => {
|
|
16872
17135
|
setCreditVisibility(
|
|
16873
17136
|
(prev2) => prev2.map(
|
|
16874
17137
|
(item) => item.id === id ? { ...item, isExpanded: !item.isExpanded } : item
|
|
@@ -17137,10 +17400,10 @@ var MeteredFeatures = (0, import_react43.forwardRef)(({ className, ...rest }, re
|
|
|
17137
17400
|
MeteredFeatures.displayName = "MeteredFeatures";
|
|
17138
17401
|
|
|
17139
17402
|
// src/components/elements/payment-method/PaymentMethod.tsx
|
|
17140
|
-
var
|
|
17403
|
+
var import_react46 = require("react");
|
|
17141
17404
|
|
|
17142
17405
|
// src/components/elements/payment-method/PaymentMethodElement.tsx
|
|
17143
|
-
var
|
|
17406
|
+
var import_react45 = require("react");
|
|
17144
17407
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
17145
17408
|
var PaymentElement2 = ({
|
|
17146
17409
|
iconName,
|
|
@@ -17260,7 +17523,7 @@ var PaymentListElement = ({
|
|
|
17260
17523
|
}) => {
|
|
17261
17524
|
const isLightBackground = useIsLightBackground();
|
|
17262
17525
|
const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
|
|
17263
|
-
const expirationDate = (0,
|
|
17526
|
+
const expirationDate = (0, import_react45.useMemo)(() => {
|
|
17264
17527
|
const { cardExpMonth, cardExpYear } = paymentMethod;
|
|
17265
17528
|
if (!cardExpMonth || !cardExpYear) {
|
|
17266
17529
|
return;
|
|
@@ -17345,10 +17608,10 @@ var resolveDesignProps5 = (props) => {
|
|
|
17345
17608
|
}
|
|
17346
17609
|
};
|
|
17347
17610
|
};
|
|
17348
|
-
var PaymentMethod = (0,
|
|
17611
|
+
var PaymentMethod = (0, import_react46.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
|
|
17349
17612
|
const props = resolveDesignProps5(rest);
|
|
17350
17613
|
const { data, setLayout } = useEmbed();
|
|
17351
|
-
const { paymentMethod, monthsToExpiration } = (0,
|
|
17614
|
+
const { paymentMethod, monthsToExpiration } = (0, import_react46.useMemo)(() => {
|
|
17352
17615
|
if (isCheckoutData(data)) {
|
|
17353
17616
|
const paymentMethod2 = data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
|
|
17354
17617
|
let monthsToExpiration2;
|
|
@@ -17541,7 +17804,7 @@ var loadStripe = function loadStripe2() {
|
|
|
17541
17804
|
};
|
|
17542
17805
|
|
|
17543
17806
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
17544
|
-
var
|
|
17807
|
+
var import_react47 = require("react");
|
|
17545
17808
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
17546
17809
|
var resolveDesignProps6 = () => {
|
|
17547
17810
|
return {
|
|
@@ -17556,7 +17819,10 @@ var resolveDesignProps6 = () => {
|
|
|
17556
17819
|
};
|
|
17557
17820
|
};
|
|
17558
17821
|
var PaymentMethodDetails = ({
|
|
17559
|
-
setPaymentMethodId
|
|
17822
|
+
setPaymentMethodId,
|
|
17823
|
+
confirmPaymentIntentProps,
|
|
17824
|
+
financeData,
|
|
17825
|
+
onPaymentMethodSaved
|
|
17560
17826
|
}) => {
|
|
17561
17827
|
const props = resolveDesignProps6();
|
|
17562
17828
|
const { t: t2 } = useTranslation();
|
|
@@ -17567,7 +17833,7 @@ var PaymentMethodDetails = ({
|
|
|
17567
17833
|
updatePaymentMethod,
|
|
17568
17834
|
deletePaymentMethod
|
|
17569
17835
|
} = useEmbed();
|
|
17570
|
-
const { defaultPaymentMethod, paymentMethods, subscription } = (0,
|
|
17836
|
+
const { defaultPaymentMethod, paymentMethods, subscription } = (0, import_react47.useMemo)(() => {
|
|
17571
17837
|
if (isCheckoutData(data)) {
|
|
17572
17838
|
return {
|
|
17573
17839
|
defaultPaymentMethod: data.company?.defaultPaymentMethod,
|
|
@@ -17582,14 +17848,26 @@ var PaymentMethodDetails = ({
|
|
|
17582
17848
|
};
|
|
17583
17849
|
}, [data]);
|
|
17584
17850
|
const isLightBackground = useIsLightBackground();
|
|
17585
|
-
const [isLoading, setIsLoading] = (0,
|
|
17586
|
-
const [error, setError] = (0,
|
|
17587
|
-
const [showPaymentForm, setShowPaymentForm] = (0,
|
|
17588
|
-
const [stripe, setStripe] = (0,
|
|
17589
|
-
const [setupIntent, setSetupIntent] = (0,
|
|
17590
|
-
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0,
|
|
17591
|
-
const [currentPaymentMethod, setCurrentPaymentMethod] = (0,
|
|
17592
|
-
const
|
|
17851
|
+
const [isLoading, setIsLoading] = (0, import_react47.useState)(false);
|
|
17852
|
+
const [error, setError] = (0, import_react47.useState)();
|
|
17853
|
+
const [showPaymentForm, setShowPaymentForm] = (0, import_react47.useState)(false);
|
|
17854
|
+
const [stripe, setStripe] = (0, import_react47.useState)(null);
|
|
17855
|
+
const [setupIntent, setSetupIntent] = (0, import_react47.useState)();
|
|
17856
|
+
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react47.useState)(false);
|
|
17857
|
+
const [currentPaymentMethod, setCurrentPaymentMethod] = (0, import_react47.useState)(subscription?.paymentMethod || defaultPaymentMethod);
|
|
17858
|
+
const { isConfirming: isConfirmingPayment } = usePaymentConfirmation({
|
|
17859
|
+
stripe,
|
|
17860
|
+
clientSecret: confirmPaymentIntentProps?.clientSecret,
|
|
17861
|
+
onSuccess: () => {
|
|
17862
|
+
confirmPaymentIntentProps?.callback(true);
|
|
17863
|
+
},
|
|
17864
|
+
onError: (error2) => {
|
|
17865
|
+
console.error("Payment confirmation error:", error2);
|
|
17866
|
+
confirmPaymentIntentProps?.callback(false);
|
|
17867
|
+
},
|
|
17868
|
+
autoConfirm: true
|
|
17869
|
+
});
|
|
17870
|
+
const monthsToExpiration = (0, import_react47.useMemo)(() => {
|
|
17593
17871
|
let expiration;
|
|
17594
17872
|
if (typeof currentPaymentMethod?.cardExpYear === "number" && typeof currentPaymentMethod?.cardExpMonth === "number") {
|
|
17595
17873
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -17612,7 +17890,7 @@ var PaymentMethodDetails = ({
|
|
|
17612
17890
|
const toggleShowPaymentMethods = () => {
|
|
17613
17891
|
setShowDifferentPaymentMethods((prev2) => !prev2);
|
|
17614
17892
|
};
|
|
17615
|
-
const initializePaymentMethod = (0,
|
|
17893
|
+
const initializePaymentMethod = (0, import_react47.useCallback)(async () => {
|
|
17616
17894
|
try {
|
|
17617
17895
|
setIsLoading(true);
|
|
17618
17896
|
const response = await createSetupIntent();
|
|
@@ -17628,7 +17906,7 @@ var PaymentMethodDetails = ({
|
|
|
17628
17906
|
setIsLoading(false);
|
|
17629
17907
|
}
|
|
17630
17908
|
}, [t2, createSetupIntent]);
|
|
17631
|
-
const handleUpdatePaymentMethod = (0,
|
|
17909
|
+
const handleUpdatePaymentMethod = (0, import_react47.useCallback)(
|
|
17632
17910
|
async (paymentMethodId) => {
|
|
17633
17911
|
try {
|
|
17634
17912
|
setIsLoading(true);
|
|
@@ -17638,6 +17916,9 @@ var PaymentMethodDetails = ({
|
|
|
17638
17916
|
if (setPaymentMethodId) {
|
|
17639
17917
|
setPaymentMethodId(response.data.externalId);
|
|
17640
17918
|
}
|
|
17919
|
+
if (onPaymentMethodSaved) {
|
|
17920
|
+
onPaymentMethodSaved({});
|
|
17921
|
+
}
|
|
17641
17922
|
}
|
|
17642
17923
|
} catch {
|
|
17643
17924
|
setError(t2("Error updating payment method. Please try again."));
|
|
@@ -17645,9 +17926,9 @@ var PaymentMethodDetails = ({
|
|
|
17645
17926
|
setIsLoading(false);
|
|
17646
17927
|
}
|
|
17647
17928
|
},
|
|
17648
|
-
[t2, setPaymentMethodId, updatePaymentMethod]
|
|
17929
|
+
[t2, setPaymentMethodId, updatePaymentMethod, onPaymentMethodSaved]
|
|
17649
17930
|
);
|
|
17650
|
-
const handleDeletePaymentMethod = (0,
|
|
17931
|
+
const handleDeletePaymentMethod = (0, import_react47.useCallback)(
|
|
17651
17932
|
async (paymentMethodId) => {
|
|
17652
17933
|
try {
|
|
17653
17934
|
setIsLoading(true);
|
|
@@ -17660,7 +17941,7 @@ var PaymentMethodDetails = ({
|
|
|
17660
17941
|
},
|
|
17661
17942
|
[t2, deletePaymentMethod]
|
|
17662
17943
|
);
|
|
17663
|
-
(0,
|
|
17944
|
+
(0, import_react47.useEffect)(() => {
|
|
17664
17945
|
if (!stripe && setupIntent) {
|
|
17665
17946
|
let publishableKey = setupIntent.publishableKey || setupIntent.schematicPublishableKey;
|
|
17666
17947
|
const stripeOptions = {};
|
|
@@ -17668,10 +17949,11 @@ var PaymentMethodDetails = ({
|
|
|
17668
17949
|
publishableKey = setupIntent.schematicPublishableKey;
|
|
17669
17950
|
stripeOptions.stripeAccount = setupIntent.accountId;
|
|
17670
17951
|
}
|
|
17671
|
-
|
|
17952
|
+
const stripePromise2 = loadStripe(publishableKey, stripeOptions);
|
|
17953
|
+
setStripe(stripePromise2);
|
|
17672
17954
|
}
|
|
17673
17955
|
}, [stripe, setupIntent]);
|
|
17674
|
-
(0,
|
|
17956
|
+
(0, import_react47.useEffect)(() => {
|
|
17675
17957
|
if (!setupIntent && (!currentPaymentMethod || showPaymentForm)) {
|
|
17676
17958
|
initializePaymentMethod();
|
|
17677
17959
|
}
|
|
@@ -17686,7 +17968,7 @@ var PaymentMethodDetails = ({
|
|
|
17686
17968
|
Flex,
|
|
17687
17969
|
{
|
|
17688
17970
|
$position: "absolute",
|
|
17689
|
-
$zIndex: isLoading ? 1 : 0,
|
|
17971
|
+
$zIndex: isLoading || isConfirmingPayment ? 1 : 0,
|
|
17690
17972
|
$justifyContent: "center",
|
|
17691
17973
|
$alignItems: "center",
|
|
17692
17974
|
$width: "100%",
|
|
@@ -17696,7 +17978,7 @@ var PaymentMethodDetails = ({
|
|
|
17696
17978
|
{
|
|
17697
17979
|
$color: settings.theme.primary,
|
|
17698
17980
|
$size: "2xl",
|
|
17699
|
-
$isLoading: isLoading
|
|
17981
|
+
$isLoading: isLoading || isConfirmingPayment
|
|
17700
17982
|
}
|
|
17701
17983
|
)
|
|
17702
17984
|
}
|
|
@@ -17705,16 +17987,16 @@ var PaymentMethodDetails = ({
|
|
|
17705
17987
|
Flex,
|
|
17706
17988
|
{
|
|
17707
17989
|
$position: "relative",
|
|
17708
|
-
$zIndex: isLoading ? 0 : 1,
|
|
17990
|
+
$zIndex: isLoading || isConfirmingPayment ? 0 : 1,
|
|
17709
17991
|
$flexDirection: "column",
|
|
17710
17992
|
$flexGrow: 1,
|
|
17711
17993
|
$gap: "1rem",
|
|
17712
17994
|
$overflow: "auto",
|
|
17713
17995
|
$padding: "2rem 2.5rem 2rem 2.5rem",
|
|
17714
|
-
$visibility: isLoading ? "hidden" : "visible",
|
|
17996
|
+
$visibility: isLoading || isConfirmingPayment ? "hidden" : "visible",
|
|
17715
17997
|
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
|
|
17716
17998
|
children: [
|
|
17717
|
-
setupIntent && showPaymentForm ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
17999
|
+
setupIntent && showPaymentForm && stripe ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
17718
18000
|
import_react_stripe_js2.Elements,
|
|
17719
18001
|
{
|
|
17720
18002
|
stripe,
|
|
@@ -17747,6 +18029,7 @@ var PaymentMethodDetails = ({
|
|
|
17747
18029
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
17748
18030
|
PaymentForm,
|
|
17749
18031
|
{
|
|
18032
|
+
financeData,
|
|
17750
18033
|
onConfirm: async (paymentMethodId) => {
|
|
17751
18034
|
await handleUpdatePaymentMethod(paymentMethodId);
|
|
17752
18035
|
setShowPaymentForm(false);
|
|
@@ -17827,7 +18110,7 @@ var PaymentMethodDetails = ({
|
|
|
17827
18110
|
};
|
|
17828
18111
|
|
|
17829
18112
|
// src/components/elements/plan-manager/PlanManager.tsx
|
|
17830
|
-
var
|
|
18113
|
+
var import_react49 = require("react");
|
|
17831
18114
|
|
|
17832
18115
|
// src/components/elements/plan-manager/AddOn.tsx
|
|
17833
18116
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
@@ -17851,7 +18134,7 @@ var AddOn = ({ addOn, currency, layout }) => {
|
|
|
17851
18134
|
};
|
|
17852
18135
|
|
|
17853
18136
|
// src/components/elements/plan-manager/UsageDetails.tsx
|
|
17854
|
-
var
|
|
18137
|
+
var import_react48 = require("react");
|
|
17855
18138
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
17856
18139
|
var UsageDetails2 = ({
|
|
17857
18140
|
entitlement,
|
|
@@ -17865,18 +18148,18 @@ var UsageDetails2 = ({
|
|
|
17865
18148
|
limit,
|
|
17866
18149
|
amount = 0,
|
|
17867
18150
|
cost = 0
|
|
17868
|
-
} = (0,
|
|
18151
|
+
} = (0, import_react48.useMemo)(
|
|
17869
18152
|
() => getUsageDetails(entitlement, period),
|
|
17870
18153
|
[entitlement, period]
|
|
17871
18154
|
);
|
|
17872
|
-
const description = (0,
|
|
18155
|
+
const description = (0, import_react48.useMemo)(() => {
|
|
17873
18156
|
const acc = [];
|
|
17874
18157
|
let index = 0;
|
|
17875
18158
|
if (entitlement.priceBehavior === "overage" /* Overage */) {
|
|
17876
18159
|
acc.push(
|
|
17877
|
-
amount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
18160
|
+
amount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_react48.Fragment, { children: t2("X additional", {
|
|
17878
18161
|
amount
|
|
17879
|
-
}) }, index) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
18162
|
+
}) }, index) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_react48.Fragment, { children: [
|
|
17880
18163
|
t2("Additional"),
|
|
17881
18164
|
": "
|
|
17882
18165
|
] }, index)
|
|
@@ -17887,7 +18170,7 @@ var UsageDetails2 = ({
|
|
|
17887
18170
|
if (entitlement.priceBehavior !== "tier" /* Tiered */ && entitlement.feature && typeof price === "number" && !amount) {
|
|
17888
18171
|
const packageSize = billingPrice?.packageSize ?? 1;
|
|
17889
18172
|
acc.push(
|
|
17890
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
18173
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_react48.Fragment, { children: [
|
|
17891
18174
|
formatCurrency(price, billingPrice?.currency),
|
|
17892
18175
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("sub", { children: [
|
|
17893
18176
|
"/",
|
|
@@ -17908,7 +18191,7 @@ var UsageDetails2 = ({
|
|
|
17908
18191
|
if (entitlement.priceBehavior === "credit_burndown" /* Credit */ && entitlement.planEntitlement?.consumptionRate && entitlement.planEntitlement?.valueCredit) {
|
|
17909
18192
|
const creditAmount = entitlement.planEntitlement.consumptionRate * amount;
|
|
17910
18193
|
acc.push(
|
|
17911
|
-
creditAmount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
18194
|
+
creditAmount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_react48.Fragment, { children: [
|
|
17912
18195
|
creditAmount,
|
|
17913
18196
|
" ",
|
|
17914
18197
|
getFeatureName(
|
|
@@ -17917,7 +18200,7 @@ var UsageDetails2 = ({
|
|
|
17917
18200
|
),
|
|
17918
18201
|
" ",
|
|
17919
18202
|
t2("used")
|
|
17920
|
-
] }, index) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
18203
|
+
] }, index) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_react48.Fragment, { children: [
|
|
17921
18204
|
entitlement.planEntitlement.consumptionRate,
|
|
17922
18205
|
" ",
|
|
17923
18206
|
getFeatureName(
|
|
@@ -18015,7 +18298,7 @@ var resolveDesignProps7 = (props) => {
|
|
|
18015
18298
|
}
|
|
18016
18299
|
};
|
|
18017
18300
|
};
|
|
18018
|
-
var PlanManager = (0,
|
|
18301
|
+
var PlanManager = (0, import_react49.forwardRef)(({ children, className, portal, ...rest }, ref) => {
|
|
18019
18302
|
const props = resolveDesignProps7(rest);
|
|
18020
18303
|
const { t: t2 } = useTranslation();
|
|
18021
18304
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
@@ -18028,18 +18311,18 @@ var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal,
|
|
|
18028
18311
|
creditGroups,
|
|
18029
18312
|
billingSubscription,
|
|
18030
18313
|
canCheckout,
|
|
18031
|
-
|
|
18314
|
+
postTrialPlan,
|
|
18032
18315
|
featureUsage,
|
|
18033
18316
|
showZeroPriceAsFree,
|
|
18034
18317
|
trialPaymentMethodRequired
|
|
18035
|
-
} = (0,
|
|
18318
|
+
} = (0, import_react49.useMemo)(() => {
|
|
18036
18319
|
if (isCheckoutData(data)) {
|
|
18037
18320
|
const {
|
|
18038
18321
|
company,
|
|
18039
18322
|
creditBundles: creditBundles2,
|
|
18040
18323
|
creditGrants,
|
|
18041
18324
|
capabilities,
|
|
18042
|
-
|
|
18325
|
+
postTrialPlan: postTrialPlan2,
|
|
18043
18326
|
featureUsage: featureUsage2,
|
|
18044
18327
|
showZeroPriceAsFree: showZeroPriceAsFree2,
|
|
18045
18328
|
trialPaymentMethodRequired: trialPaymentMethodRequired2
|
|
@@ -18069,7 +18352,7 @@ var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal,
|
|
|
18069
18352
|
creditGroups: creditGroups2,
|
|
18070
18353
|
billingSubscription: company?.billingSubscription,
|
|
18071
18354
|
canCheckout: capabilities?.checkout ?? true,
|
|
18072
|
-
|
|
18355
|
+
postTrialPlan: postTrialPlan2,
|
|
18073
18356
|
featureUsage: featureUsage2?.features || [],
|
|
18074
18357
|
showZeroPriceAsFree: showZeroPriceAsFree2,
|
|
18075
18358
|
trialPaymentMethodRequired: trialPaymentMethodRequired2
|
|
@@ -18082,13 +18365,13 @@ var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal,
|
|
|
18082
18365
|
creditGroups: { plan: [], bundles: [], promotional: [] },
|
|
18083
18366
|
billingSubscription: void 0,
|
|
18084
18367
|
canCheckout: false,
|
|
18085
|
-
|
|
18368
|
+
postTrialPlan: void 0,
|
|
18086
18369
|
featureUsage: [],
|
|
18087
18370
|
showZeroPriceAsFree: false,
|
|
18088
18371
|
trialPaymentMethodRequired: false
|
|
18089
18372
|
};
|
|
18090
18373
|
}, [data]);
|
|
18091
|
-
const usageBasedEntitlements = (0,
|
|
18374
|
+
const usageBasedEntitlements = (0, import_react49.useMemo)(
|
|
18092
18375
|
() => featureUsage.filter((usage) => typeof usage.priceBehavior === "string"),
|
|
18093
18376
|
[featureUsage]
|
|
18094
18377
|
);
|
|
@@ -18097,7 +18380,7 @@ var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal,
|
|
|
18097
18380
|
subscriptionCurrency,
|
|
18098
18381
|
willSubscriptionCancel,
|
|
18099
18382
|
isTrialSubscription
|
|
18100
|
-
} = (0,
|
|
18383
|
+
} = (0, import_react49.useMemo)(() => {
|
|
18101
18384
|
const subscriptionInterval2 = billingSubscription?.interval;
|
|
18102
18385
|
const subscriptionCurrency2 = billingSubscription?.currency;
|
|
18103
18386
|
const isTrialSubscription2 = billingSubscription?.status === "trialing";
|
|
@@ -18123,8 +18406,8 @@ var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal,
|
|
|
18123
18406
|
$backgroundColor: isLightBackground ? darken(settings.theme.card.background, 0.04) : lighten(settings.theme.card.background, 0.04),
|
|
18124
18407
|
children: [
|
|
18125
18408
|
typeof trialEnd.formatted !== "undefined" && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Text, { as: "h3", display: "heading3", children: trialEnd.formatted }),
|
|
18126
|
-
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Text, { as: "p", $size: 0.8125 * settings.theme.typography.text.fontSize, children: trialPaymentMethodRequired ? t2("After the trial, subscribe") :
|
|
18127
|
-
|
|
18409
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Text, { as: "p", $size: 0.8125 * settings.theme.typography.text.fontSize, children: trialPaymentMethodRequired ? t2("After the trial, subscribe") : postTrialPlan ? t2("After the trial, cancel", {
|
|
18410
|
+
postTrialPlanName: postTrialPlan?.name
|
|
18128
18411
|
}) : t2("After the trial, cancel no default", {
|
|
18129
18412
|
planName: currentPlan?.name
|
|
18130
18413
|
}) })
|
|
@@ -18409,17 +18692,17 @@ var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal,
|
|
|
18409
18692
|
PlanManager.displayName = "PlanManager";
|
|
18410
18693
|
|
|
18411
18694
|
// src/components/elements/pricing-table/PricingTable.tsx
|
|
18412
|
-
var
|
|
18695
|
+
var import_react52 = require("react");
|
|
18413
18696
|
|
|
18414
18697
|
// src/components/elements/pricing-table/AddOn.tsx
|
|
18415
|
-
var
|
|
18698
|
+
var import_react50 = require("react");
|
|
18416
18699
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
18417
18700
|
var AddOn2 = ({ addOn, sharedProps, selectedPeriod }) => {
|
|
18418
18701
|
const { layout } = sharedProps;
|
|
18419
18702
|
const { t: t2 } = useTranslation();
|
|
18420
18703
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
18421
18704
|
const isLightBackground = useIsLightBackground();
|
|
18422
|
-
const { currentAddOns, canCheckout, isStandalone, showCallToAction } = (0,
|
|
18705
|
+
const { currentAddOns, canCheckout, isStandalone, showCallToAction } = (0, import_react50.useMemo)(() => {
|
|
18423
18706
|
if (isCheckoutData(data)) {
|
|
18424
18707
|
return {
|
|
18425
18708
|
currentAddOns: data.company?.addOns || [],
|
|
@@ -18592,7 +18875,7 @@ var AddOn2 = ({ addOn, sharedProps, selectedPeriod }) => {
|
|
|
18592
18875
|
};
|
|
18593
18876
|
|
|
18594
18877
|
// src/components/elements/pricing-table/Plan.tsx
|
|
18595
|
-
var
|
|
18878
|
+
var import_react51 = require("react");
|
|
18596
18879
|
|
|
18597
18880
|
// src/components/elements/pricing-table/Entitlement.tsx
|
|
18598
18881
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
@@ -18751,7 +19034,7 @@ var Plan2 = ({
|
|
|
18751
19034
|
isStandalone,
|
|
18752
19035
|
showCallToAction,
|
|
18753
19036
|
showZeroPriceAsFree
|
|
18754
|
-
} = (0,
|
|
19037
|
+
} = (0, import_react51.useMemo)(() => {
|
|
18755
19038
|
if (isCheckoutData(data)) {
|
|
18756
19039
|
const billingSubscription = data.company?.billingSubscription;
|
|
18757
19040
|
const isTrialSubscription2 = billingSubscription?.status === "trialing";
|
|
@@ -18776,7 +19059,7 @@ var Plan2 = ({
|
|
|
18776
19059
|
showZeroPriceAsFree: false
|
|
18777
19060
|
};
|
|
18778
19061
|
}, [data, sharedProps.callToActionUrl, sharedProps.onCallToAction]);
|
|
18779
|
-
const callToActionTarget = (0,
|
|
19062
|
+
const callToActionTarget = (0, import_react51.useMemo)(() => {
|
|
18780
19063
|
if (sharedProps.callToActionTarget) {
|
|
18781
19064
|
return sharedProps.callToActionTarget;
|
|
18782
19065
|
}
|
|
@@ -19088,12 +19371,12 @@ var resolveDesignProps8 = (props) => {
|
|
|
19088
19371
|
}
|
|
19089
19372
|
};
|
|
19090
19373
|
};
|
|
19091
|
-
var PricingTable = (0,
|
|
19374
|
+
var PricingTable = (0, import_react52.forwardRef)(
|
|
19092
19375
|
({ className, callToActionUrl, callToActionTarget, onCallToAction, ...rest }, ref) => {
|
|
19093
19376
|
const props = resolveDesignProps8(rest);
|
|
19094
19377
|
const { t: t2 } = useTranslation();
|
|
19095
19378
|
const { data, settings, isPending, hydratePublic } = useEmbed();
|
|
19096
|
-
const { currentPeriod, showPeriodToggle, isStandalone } = (0,
|
|
19379
|
+
const { currentPeriod, showPeriodToggle, isStandalone } = (0, import_react52.useMemo)(() => {
|
|
19097
19380
|
const showPeriodToggle2 = data?.showPeriodToggle ?? props.showPeriodToggle;
|
|
19098
19381
|
if (isCheckoutData(data)) {
|
|
19099
19382
|
const billingSubscription = data.company?.billingSubscription;
|
|
@@ -19119,11 +19402,11 @@ var PricingTable = (0, import_react51.forwardRef)(
|
|
|
19119
19402
|
isStandalone: true
|
|
19120
19403
|
};
|
|
19121
19404
|
}, [props.showPeriodToggle, data]);
|
|
19122
|
-
const [selectedPeriod, setSelectedPeriod] = (0,
|
|
19405
|
+
const [selectedPeriod, setSelectedPeriod] = (0, import_react52.useState)(currentPeriod);
|
|
19123
19406
|
const { plans, addOns, periods } = useAvailablePlans(selectedPeriod, {
|
|
19124
19407
|
useSelectedPeriod: showPeriodToggle
|
|
19125
19408
|
});
|
|
19126
|
-
const [entitlementCounts, setEntitlementCounts] = (0,
|
|
19409
|
+
const [entitlementCounts, setEntitlementCounts] = (0, import_react52.useState)(
|
|
19127
19410
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
19128
19411
|
);
|
|
19129
19412
|
const handleToggleShowAll = (id) => {
|
|
@@ -19141,12 +19424,12 @@ var PricingTable = (0, import_react51.forwardRef)(
|
|
|
19141
19424
|
return prev2;
|
|
19142
19425
|
});
|
|
19143
19426
|
};
|
|
19144
|
-
(0,
|
|
19427
|
+
(0, import_react52.useEffect)(() => {
|
|
19145
19428
|
if (isStandalone) {
|
|
19146
19429
|
hydratePublic();
|
|
19147
19430
|
}
|
|
19148
19431
|
}, [isStandalone, hydratePublic]);
|
|
19149
|
-
(0,
|
|
19432
|
+
(0, import_react52.useEffect)(() => {
|
|
19150
19433
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
19151
19434
|
}, [plans]);
|
|
19152
19435
|
if (isPending) {
|
|
@@ -19162,7 +19445,7 @@ var PricingTable = (0, import_react51.forwardRef)(
|
|
|
19162
19445
|
}
|
|
19163
19446
|
);
|
|
19164
19447
|
}
|
|
19165
|
-
const Wrapper = isStandalone ? Container :
|
|
19448
|
+
const Wrapper = isStandalone ? Container : import_react52.Fragment;
|
|
19166
19449
|
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
|
|
19167
19450
|
FussyChild,
|
|
19168
19451
|
{
|
|
@@ -19188,14 +19471,7 @@ var PricingTable = (0, import_react51.forwardRef)(
|
|
|
19188
19471
|
}
|
|
19189
19472
|
},
|
|
19190
19473
|
children: [
|
|
19191
|
-
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
19192
|
-
Text,
|
|
19193
|
-
{
|
|
19194
|
-
display: props.header.fontStyle,
|
|
19195
|
-
$color: settings.theme.card.background,
|
|
19196
|
-
children: props.header.isVisible && props.plans.isVisible && plans.length > 0 && t2("Plans")
|
|
19197
|
-
}
|
|
19198
|
-
),
|
|
19474
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Text, { display: props.header.fontStyle, children: props.header.isVisible && props.plans.isVisible && plans.length > 0 && t2("Plans") }),
|
|
19199
19475
|
showPeriodToggle && periods.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
19200
19476
|
PeriodToggle,
|
|
19201
19477
|
{
|
|
@@ -19248,14 +19524,7 @@ var PricingTable = (0, import_react51.forwardRef)(
|
|
|
19248
19524
|
$justifyContent: "space-between",
|
|
19249
19525
|
$alignItems: "center",
|
|
19250
19526
|
$marginBottom: "1rem",
|
|
19251
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
19252
|
-
Text,
|
|
19253
|
-
{
|
|
19254
|
-
display: props.header.fontStyle,
|
|
19255
|
-
$color: settings.theme.card.background,
|
|
19256
|
-
children: t2("Add-ons")
|
|
19257
|
-
}
|
|
19258
|
-
)
|
|
19527
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Text, { display: props.header.fontStyle, children: t2("Add-ons") })
|
|
19259
19528
|
}
|
|
19260
19529
|
),
|
|
19261
19530
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
@@ -19292,7 +19561,7 @@ var PricingTable = (0, import_react51.forwardRef)(
|
|
|
19292
19561
|
PricingTable.displayName = "PricingTable";
|
|
19293
19562
|
|
|
19294
19563
|
// src/components/elements/text/Text.tsx
|
|
19295
|
-
var
|
|
19564
|
+
var import_react53 = require("react");
|
|
19296
19565
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
19297
19566
|
var resolveDesignProps9 = (props) => {
|
|
19298
19567
|
return {
|
|
@@ -19303,7 +19572,7 @@ var resolveDesignProps9 = (props) => {
|
|
|
19303
19572
|
}
|
|
19304
19573
|
};
|
|
19305
19574
|
};
|
|
19306
|
-
var TextElement = (0,
|
|
19575
|
+
var TextElement = (0, import_react53.forwardRef)(({ children, className, ...rest }, ref) => {
|
|
19307
19576
|
const props = resolveDesignProps9(rest);
|
|
19308
19577
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Element, { as: Flex, ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
19309
19578
|
Text,
|
|
@@ -19318,7 +19587,7 @@ var TextElement = (0, import_react52.forwardRef)(({ children, className, ...rest
|
|
|
19318
19587
|
TextElement.displayName = "Text";
|
|
19319
19588
|
|
|
19320
19589
|
// src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
|
|
19321
|
-
var
|
|
19590
|
+
var import_react54 = require("react");
|
|
19322
19591
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
19323
19592
|
var buttonStyles = {
|
|
19324
19593
|
primary: {
|
|
@@ -19345,11 +19614,11 @@ var resolveDesignProps10 = (props) => {
|
|
|
19345
19614
|
}
|
|
19346
19615
|
};
|
|
19347
19616
|
};
|
|
19348
|
-
var UnsubscribeButton = (0,
|
|
19617
|
+
var UnsubscribeButton = (0, import_react54.forwardRef)(({ children, className, ...rest }, ref) => {
|
|
19349
19618
|
const props = resolveDesignProps10(rest);
|
|
19350
19619
|
const { t: t2 } = useTranslation();
|
|
19351
19620
|
const { data, setLayout } = useEmbed();
|
|
19352
|
-
const hasActiveSubscription = (0,
|
|
19621
|
+
const hasActiveSubscription = (0, import_react54.useMemo)(() => {
|
|
19353
19622
|
return isCheckoutData(data) && data.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
|
|
19354
19623
|
}, [data]);
|
|
19355
19624
|
if (!hasActiveSubscription) {
|
|
@@ -19384,7 +19653,7 @@ var UnsubscribeButton = (0, import_react53.forwardRef)(({ children, className, .
|
|
|
19384
19653
|
UnsubscribeButton.displayName = "UnsubscribeButton";
|
|
19385
19654
|
|
|
19386
19655
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
|
19387
|
-
var
|
|
19656
|
+
var import_react55 = require("react");
|
|
19388
19657
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
19389
19658
|
function resolveDesignProps11(props) {
|
|
19390
19659
|
return {
|
|
@@ -19404,16 +19673,16 @@ function resolveDesignProps11(props) {
|
|
|
19404
19673
|
}
|
|
19405
19674
|
};
|
|
19406
19675
|
}
|
|
19407
|
-
var UpcomingBill = (0,
|
|
19676
|
+
var UpcomingBill = (0, import_react55.forwardRef)(({ className, ...rest }, ref) => {
|
|
19408
19677
|
const props = resolveDesignProps11(rest);
|
|
19409
19678
|
const { t: t2 } = useTranslation();
|
|
19410
19679
|
const { data, settings, debug, getUpcomingInvoice, getCustomerBalance } = useEmbed();
|
|
19411
19680
|
const isLightBackground = useIsLightBackground();
|
|
19412
|
-
const [isLoading, setIsLoading] = (0,
|
|
19413
|
-
const [error, setError] = (0,
|
|
19414
|
-
const [upcomingInvoice, setUpcomingInvoice] = (0,
|
|
19415
|
-
const [balances, setBalances] = (0,
|
|
19416
|
-
const discounts = (0,
|
|
19681
|
+
const [isLoading, setIsLoading] = (0, import_react55.useState)(false);
|
|
19682
|
+
const [error, setError] = (0, import_react55.useState)();
|
|
19683
|
+
const [upcomingInvoice, setUpcomingInvoice] = (0, import_react55.useState)();
|
|
19684
|
+
const [balances, setBalances] = (0, import_react55.useState)([]);
|
|
19685
|
+
const discounts = (0, import_react55.useMemo)(() => {
|
|
19417
19686
|
return (isCheckoutData(data) && data.subscription?.discounts || []).map(
|
|
19418
19687
|
(discount) => ({
|
|
19419
19688
|
couponId: discount.couponId,
|
|
@@ -19425,7 +19694,7 @@ var UpcomingBill = (0, import_react54.forwardRef)(({ className, ...rest }, ref)
|
|
|
19425
19694
|
})
|
|
19426
19695
|
);
|
|
19427
19696
|
}, [data]);
|
|
19428
|
-
const getInvoice = (0,
|
|
19697
|
+
const getInvoice = (0, import_react55.useCallback)(async () => {
|
|
19429
19698
|
if (isCheckoutData(data) && data.component?.id && data.subscription && !data.subscription.cancelAt) {
|
|
19430
19699
|
try {
|
|
19431
19700
|
setError(void 0);
|
|
@@ -19441,7 +19710,7 @@ var UpcomingBill = (0, import_react54.forwardRef)(({ className, ...rest }, ref)
|
|
|
19441
19710
|
}
|
|
19442
19711
|
}
|
|
19443
19712
|
}, [data, getUpcomingInvoice]);
|
|
19444
|
-
const getBalances = (0,
|
|
19713
|
+
const getBalances = (0, import_react55.useCallback)(async () => {
|
|
19445
19714
|
try {
|
|
19446
19715
|
const response = await getCustomerBalance();
|
|
19447
19716
|
if (response) {
|
|
@@ -19451,10 +19720,10 @@ var UpcomingBill = (0, import_react54.forwardRef)(({ className, ...rest }, ref)
|
|
|
19451
19720
|
debug("Failed to fetch customer balance.", err2);
|
|
19452
19721
|
}
|
|
19453
19722
|
}, [debug, getCustomerBalance]);
|
|
19454
|
-
(0,
|
|
19723
|
+
(0, import_react55.useEffect)(() => {
|
|
19455
19724
|
getInvoice();
|
|
19456
19725
|
}, [getInvoice]);
|
|
19457
|
-
(0,
|
|
19726
|
+
(0, import_react55.useEffect)(() => {
|
|
19458
19727
|
getBalances();
|
|
19459
19728
|
}, [getBalances]);
|
|
19460
19729
|
if (!isCheckoutData(data) || !data.subscription || data.subscription.cancelAt) {
|
|
@@ -23766,10 +24035,10 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
|
23766
24035
|
var inflate_1 = inflate;
|
|
23767
24036
|
|
|
23768
24037
|
// src/components/embed/Embed.tsx
|
|
23769
|
-
var
|
|
24038
|
+
var import_react57 = require("react");
|
|
23770
24039
|
|
|
23771
24040
|
// src/components/embed/renderer.ts
|
|
23772
|
-
var
|
|
24041
|
+
var import_react56 = require("react");
|
|
23773
24042
|
var components = {
|
|
23774
24043
|
Root,
|
|
23775
24044
|
Viewport,
|
|
@@ -23833,7 +24102,7 @@ function createRenderer(options) {
|
|
|
23833
24102
|
const { className, ...rest } = props;
|
|
23834
24103
|
const resolvedProps = component === "div" ? rest : props;
|
|
23835
24104
|
const resolvedChildren = children.map(renderNode);
|
|
23836
|
-
return (0,
|
|
24105
|
+
return (0, import_react56.createElement)(
|
|
23837
24106
|
component,
|
|
23838
24107
|
{
|
|
23839
24108
|
key: index,
|
|
@@ -23881,8 +24150,8 @@ var Error2 = ({ message }) => {
|
|
|
23881
24150
|
);
|
|
23882
24151
|
};
|
|
23883
24152
|
var SchematicEmbed = ({ id, accessToken }) => {
|
|
23884
|
-
const [children, setChildren] = (0,
|
|
23885
|
-
const theme = (0,
|
|
24153
|
+
const [children, setChildren] = (0, import_react57.useState)(/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Loading, {}));
|
|
24154
|
+
const theme = (0, import_react57.useContext)(et);
|
|
23886
24155
|
const {
|
|
23887
24156
|
data,
|
|
23888
24157
|
error,
|
|
@@ -23893,17 +24162,17 @@ var SchematicEmbed = ({ id, accessToken }) => {
|
|
|
23893
24162
|
setAccessToken,
|
|
23894
24163
|
updateSettings
|
|
23895
24164
|
} = useEmbed();
|
|
23896
|
-
(0,
|
|
24165
|
+
(0, import_react57.useEffect)(() => {
|
|
23897
24166
|
if (accessToken) {
|
|
23898
24167
|
setAccessToken(accessToken);
|
|
23899
24168
|
}
|
|
23900
24169
|
}, [accessToken, setAccessToken]);
|
|
23901
|
-
(0,
|
|
24170
|
+
(0, import_react57.useEffect)(() => {
|
|
23902
24171
|
if (id && stale) {
|
|
23903
24172
|
hydrateComponent(id);
|
|
23904
24173
|
}
|
|
23905
24174
|
}, [id, hydrateComponent, stale]);
|
|
23906
|
-
(0,
|
|
24175
|
+
(0, import_react57.useEffect)(() => {
|
|
23907
24176
|
const renderer = createRenderer();
|
|
23908
24177
|
try {
|
|
23909
24178
|
if (isCheckoutData(data) && data.component?.ast) {
|