@schematichq/schematic-components 0.4.0-rc.14 → 0.4.0-rc.16
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 +717 -564
- package/dist/schematic-components.d.ts +16 -48
- package/dist/schematic-components.esm.js +621 -468
- package/package.json +2 -2
|
@@ -2116,12 +2116,14 @@ __export(index_exports, {
|
|
|
2116
2116
|
useAvailablePlans: () => useAvailablePlans,
|
|
2117
2117
|
useEmbed: () => useEmbed,
|
|
2118
2118
|
useIsLightBackground: () => useIsLightBackground,
|
|
2119
|
+
usePrevious: () => usePrevious2,
|
|
2120
|
+
useTrialEnd: () => useTrialEnd,
|
|
2119
2121
|
useWrapChildren: () => useWrapChildren
|
|
2120
2122
|
});
|
|
2121
2123
|
module.exports = __toCommonJS(index_exports);
|
|
2122
2124
|
|
|
2123
2125
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
|
2124
|
-
var
|
|
2126
|
+
var import_react32 = require("react");
|
|
2125
2127
|
|
|
2126
2128
|
// node_modules/react-i18next/dist/es/Trans.js
|
|
2127
2129
|
var import_react3 = require("react");
|
|
@@ -3779,7 +3781,7 @@ function useAvailablePlans(activePeriod) {
|
|
|
3779
3781
|
}, [data.activePlans, data.activeAddOns]);
|
|
3780
3782
|
const getActivePlans = (0, import_react10.useCallback)(
|
|
3781
3783
|
(plans) => {
|
|
3782
|
-
|
|
3784
|
+
const plansWithSelected = (mode === "edit" ? plans.slice() : plans.filter(
|
|
3783
3785
|
(plan) => activePeriod === "month" && plan.monthlyPrice || activePeriod === "year" && plan.yearlyPrice
|
|
3784
3786
|
)).sort((a2, b2) => {
|
|
3785
3787
|
if (activePeriod === "year") {
|
|
@@ -3790,6 +3792,7 @@ function useAvailablePlans(activePeriod) {
|
|
|
3790
3792
|
}
|
|
3791
3793
|
return 0;
|
|
3792
3794
|
}).map((plan) => ({ ...plan, isSelected: false }));
|
|
3795
|
+
return plansWithSelected;
|
|
3793
3796
|
},
|
|
3794
3797
|
[activePeriod, mode]
|
|
3795
3798
|
);
|
|
@@ -11224,6 +11227,7 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
11224
11227
|
planId: json["plan_id"],
|
|
11225
11228
|
priceBehavior: json["price_behavior"] == null ? void 0 : json["price_behavior"],
|
|
11226
11229
|
ruleId: json["rule_id"],
|
|
11230
|
+
ruleIdUsageExceeded: json["rule_id_usage_exceeded"] == null ? void 0 : json["rule_id_usage_exceeded"],
|
|
11227
11231
|
updatedAt: new Date(json["updated_at"]),
|
|
11228
11232
|
valueBool: json["value_bool"] == null ? void 0 : json["value_bool"],
|
|
11229
11233
|
valueNumeric: json["value_numeric"] == null ? void 0 : json["value_numeric"],
|
|
@@ -11867,7 +11871,8 @@ var en_default = {
|
|
|
11867
11871
|
"Add Seats": "Add More",
|
|
11868
11872
|
"Add-ons": "Add-ons",
|
|
11869
11873
|
"After the trial, subscribe": "After the trial, subscription starts and you will be billed.",
|
|
11870
|
-
"After the trial, cancel": "After the trial, the subscription
|
|
11874
|
+
"After the trial, cancel": "After the trial, you will be downgraded to the {{defaultPlanName}} plan and your subscription will be cancelled.",
|
|
11875
|
+
"After the trial, cancel no default": "After the trial, you will be lose access to {{planName}} plan and your subscription will be cancelled.",
|
|
11871
11876
|
Billed: "Billed {{period}}",
|
|
11872
11877
|
"billing period": "billing period",
|
|
11873
11878
|
"Cannot downgrade entitlement": "Cannot downgrade to a lower quantity than current usage.",
|
|
@@ -11876,7 +11881,6 @@ var en_default = {
|
|
|
11876
11881
|
"Change payment method": "Change payment method",
|
|
11877
11882
|
"Change plan": "Change plan",
|
|
11878
11883
|
Checkout: "Checkout",
|
|
11879
|
-
"Checkout Trial": "Subscribe and close",
|
|
11880
11884
|
"Choose add-on": "Choose add-on",
|
|
11881
11885
|
"Choose plan": "Choose plan",
|
|
11882
11886
|
"Choose your base plan": "Choose your base plan",
|
|
@@ -11925,7 +11929,9 @@ var en_default = {
|
|
|
11925
11929
|
"Select plan": "Select plan",
|
|
11926
11930
|
"Select quantity": "Select quantity",
|
|
11927
11931
|
Selected: "Selected",
|
|
11932
|
+
"Session expired. Please refresh and try again.": "Session expired. Please refresh and try again.",
|
|
11928
11933
|
"Start trial": "Start trial",
|
|
11934
|
+
"Subscribe and close": "Subscribe and close",
|
|
11929
11935
|
Subscription: "Subscription",
|
|
11930
11936
|
Trial: "Trial",
|
|
11931
11937
|
"Trial ends in": "Trial ends in {{days}} days",
|
|
@@ -12522,7 +12528,7 @@ var EmbedProvider = ({
|
|
|
12522
12528
|
(0, import_react11.useEffect)(() => {
|
|
12523
12529
|
if (accessToken) {
|
|
12524
12530
|
const { headers = {} } = apiConfig ?? {};
|
|
12525
|
-
headers["X-Schematic-Components-Version"] = "0.4.0-rc.
|
|
12531
|
+
headers["X-Schematic-Components-Version"] = "0.4.0-rc.16";
|
|
12526
12532
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
12527
12533
|
const config = new Configuration({
|
|
12528
12534
|
...apiConfig,
|
|
@@ -12773,13 +12779,37 @@ function useIsLightBackground() {
|
|
|
12773
12779
|
return isLightBackground;
|
|
12774
12780
|
}
|
|
12775
12781
|
|
|
12776
|
-
// src/hooks/
|
|
12782
|
+
// src/hooks/usePrevious.ts
|
|
12777
12783
|
var import_react14 = require("react");
|
|
12784
|
+
function usePrevious2(value) {
|
|
12785
|
+
const ref = (0, import_react14.useRef)();
|
|
12786
|
+
(0, import_react14.useEffect)(() => {
|
|
12787
|
+
ref.current = value;
|
|
12788
|
+
}, [value]);
|
|
12789
|
+
return ref.current;
|
|
12790
|
+
}
|
|
12791
|
+
|
|
12792
|
+
// src/hooks/useTrialEnd.ts
|
|
12793
|
+
function useTrialEnd() {
|
|
12794
|
+
const { data } = useEmbed();
|
|
12795
|
+
const billingSubscription = data.company?.billingSubscription;
|
|
12796
|
+
const trialEndDate = billingSubscription?.trialEnd && new Date(billingSubscription.trialEnd * 1e3);
|
|
12797
|
+
if (trialEndDate) {
|
|
12798
|
+
const todayDate = /* @__PURE__ */ new Date();
|
|
12799
|
+
const trialEndDays = Math.floor(
|
|
12800
|
+
(trialEndDate.getTime() - todayDate.getTime()) / (1e3 * 60 * 60 * 24)
|
|
12801
|
+
);
|
|
12802
|
+
return trialEndDays;
|
|
12803
|
+
}
|
|
12804
|
+
}
|
|
12805
|
+
|
|
12806
|
+
// src/hooks/useWrapChildren.ts
|
|
12807
|
+
var import_react15 = require("react");
|
|
12778
12808
|
function useWrapChildren(elements) {
|
|
12779
|
-
const [shouldWrap, setShouldWrap] = (0,
|
|
12809
|
+
const [shouldWrap, setShouldWrap] = (0, import_react15.useState)(
|
|
12780
12810
|
() => new Array(elements.length).fill(false)
|
|
12781
12811
|
);
|
|
12782
|
-
(0,
|
|
12812
|
+
(0, import_react15.useLayoutEffect)(() => {
|
|
12783
12813
|
const rowShouldWrap = (parent) => [...parent.children].some(
|
|
12784
12814
|
(el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
|
|
12785
12815
|
);
|
|
@@ -12802,7 +12832,7 @@ function useWrapChildren(elements) {
|
|
|
12802
12832
|
}
|
|
12803
12833
|
|
|
12804
12834
|
// src/components/layout/root/Root.tsx
|
|
12805
|
-
var
|
|
12835
|
+
var import_react20 = require("react");
|
|
12806
12836
|
|
|
12807
12837
|
// src/components/ui/box/styles.ts
|
|
12808
12838
|
var Box = dt.div((props) => {
|
|
@@ -12833,7 +12863,7 @@ var Box = dt.div((props) => {
|
|
|
12833
12863
|
});
|
|
12834
12864
|
|
|
12835
12865
|
// src/components/ui/button/Button.tsx
|
|
12836
|
-
var
|
|
12866
|
+
var import_react16 = require("react");
|
|
12837
12867
|
|
|
12838
12868
|
// src/components/ui/button/styles.ts
|
|
12839
12869
|
var Button = dt.button`
|
|
@@ -12920,7 +12950,7 @@ var Button = dt.button`
|
|
|
12920
12950
|
|
|
12921
12951
|
// src/components/ui/button/Button.tsx
|
|
12922
12952
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
12923
|
-
var Button2 = (0,
|
|
12953
|
+
var Button2 = (0, import_react16.forwardRef)(
|
|
12924
12954
|
({
|
|
12925
12955
|
color = "white",
|
|
12926
12956
|
size = "md",
|
|
@@ -13361,14 +13391,14 @@ var Loader = dt.div`
|
|
|
13361
13391
|
`;
|
|
13362
13392
|
|
|
13363
13393
|
// src/components/ui/modal/Modal.tsx
|
|
13364
|
-
var
|
|
13394
|
+
var import_react17 = require("react");
|
|
13365
13395
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
13366
|
-
var Modal = (0,
|
|
13396
|
+
var Modal = (0, import_react17.forwardRef)(
|
|
13367
13397
|
({ children, contentRef, size = "auto", top = 0, onClose, ...rest }, ref) => {
|
|
13368
13398
|
const theme = nt();
|
|
13369
13399
|
const { setLayout } = useEmbed();
|
|
13370
13400
|
const isLightBackground = useIsLightBackground();
|
|
13371
|
-
const handleClose = (0,
|
|
13401
|
+
const handleClose = (0, import_react17.useCallback)(() => {
|
|
13372
13402
|
setLayout("portal");
|
|
13373
13403
|
onClose?.();
|
|
13374
13404
|
}, [setLayout, onClose]);
|
|
@@ -13440,7 +13470,7 @@ var Modal = (0, import_react16.forwardRef)(
|
|
|
13440
13470
|
Modal.displayName = "Modal";
|
|
13441
13471
|
|
|
13442
13472
|
// src/components/ui/modal/ModalHeader.tsx
|
|
13443
|
-
var
|
|
13473
|
+
var import_react18 = require("react");
|
|
13444
13474
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
13445
13475
|
var ModalHeader = ({
|
|
13446
13476
|
children,
|
|
@@ -13450,7 +13480,7 @@ var ModalHeader = ({
|
|
|
13450
13480
|
const theme = nt();
|
|
13451
13481
|
const { setLayout } = useEmbed();
|
|
13452
13482
|
const isLightBackground = useIsLightBackground();
|
|
13453
|
-
const handleClose = (0,
|
|
13483
|
+
const handleClose = (0, import_react18.useCallback)(() => {
|
|
13454
13484
|
setLayout("portal");
|
|
13455
13485
|
onClose?.();
|
|
13456
13486
|
}, [setLayout, onClose]);
|
|
@@ -13604,7 +13634,7 @@ var Text = dt.span.attrs(({ onClick }) => ({
|
|
|
13604
13634
|
`;
|
|
13605
13635
|
|
|
13606
13636
|
// src/components/ui/tooltip/Tooltip.tsx
|
|
13607
|
-
var
|
|
13637
|
+
var import_react19 = require("react");
|
|
13608
13638
|
var import_react_dom = require("react-dom");
|
|
13609
13639
|
|
|
13610
13640
|
// src/components/ui/tooltip/styles.ts
|
|
@@ -13742,10 +13772,10 @@ var Tooltip = ({
|
|
|
13742
13772
|
zIndex = 1,
|
|
13743
13773
|
...rest
|
|
13744
13774
|
}) => {
|
|
13745
|
-
const ref = (0,
|
|
13746
|
-
const [show, setShow] = (0,
|
|
13747
|
-
const [coords2, setCoords] = (0,
|
|
13748
|
-
(0,
|
|
13775
|
+
const ref = (0, import_react19.useRef)(null);
|
|
13776
|
+
const [show, setShow] = (0, import_react19.useState)(false);
|
|
13777
|
+
const [coords2, setCoords] = (0, import_react19.useState)({ x: 0, y: 0 });
|
|
13778
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
13749
13779
|
if (ref.current) {
|
|
13750
13780
|
const { top: offsetTop, left: offsetLeft } = document.body.getBoundingClientRect();
|
|
13751
13781
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -13800,7 +13830,7 @@ var Container2 = dt(Box)`
|
|
|
13800
13830
|
|
|
13801
13831
|
// src/components/layout/root/Root.tsx
|
|
13802
13832
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
13803
|
-
var Root = (0,
|
|
13833
|
+
var Root = (0, import_react20.forwardRef)(
|
|
13804
13834
|
({ data, settings, ...props }, ref) => {
|
|
13805
13835
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Container2, { ref, ...props });
|
|
13806
13836
|
}
|
|
@@ -13808,145 +13838,11 @@ var Root = (0, import_react19.forwardRef)(
|
|
|
13808
13838
|
Root.displayName = "Root";
|
|
13809
13839
|
|
|
13810
13840
|
// src/components/layout/viewport/Viewport.tsx
|
|
13811
|
-
var
|
|
13841
|
+
var import_react28 = require("react");
|
|
13812
13842
|
var import_react_dom2 = require("react-dom");
|
|
13813
13843
|
|
|
13814
13844
|
// src/components/shared/checkout-dialog/CheckoutDialog.tsx
|
|
13815
|
-
var
|
|
13816
|
-
|
|
13817
|
-
// node_modules/@stripe/stripe-js/dist/index.mjs
|
|
13818
|
-
var V3_URL = "https://js.stripe.com/v3";
|
|
13819
|
-
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
13820
|
-
var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
|
|
13821
|
-
var findScript = function findScript2() {
|
|
13822
|
-
var scripts = document.querySelectorAll('script[src^="'.concat(V3_URL, '"]'));
|
|
13823
|
-
for (var i2 = 0; i2 < scripts.length; i2++) {
|
|
13824
|
-
var script = scripts[i2];
|
|
13825
|
-
if (!V3_URL_REGEX.test(script.src)) {
|
|
13826
|
-
continue;
|
|
13827
|
-
}
|
|
13828
|
-
return script;
|
|
13829
|
-
}
|
|
13830
|
-
return null;
|
|
13831
|
-
};
|
|
13832
|
-
var injectScript = function injectScript2(params) {
|
|
13833
|
-
var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
|
|
13834
|
-
var script = document.createElement("script");
|
|
13835
|
-
script.src = "".concat(V3_URL).concat(queryString);
|
|
13836
|
-
var headOrBody = document.head || document.body;
|
|
13837
|
-
if (!headOrBody) {
|
|
13838
|
-
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
|
|
13839
|
-
}
|
|
13840
|
-
headOrBody.appendChild(script);
|
|
13841
|
-
return script;
|
|
13842
|
-
};
|
|
13843
|
-
var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
13844
|
-
if (!stripe || !stripe._registerWrapper) {
|
|
13845
|
-
return;
|
|
13846
|
-
}
|
|
13847
|
-
stripe._registerWrapper({
|
|
13848
|
-
name: "stripe-js",
|
|
13849
|
-
version: "5.5.0",
|
|
13850
|
-
startTime
|
|
13851
|
-
});
|
|
13852
|
-
};
|
|
13853
|
-
var stripePromise$1 = null;
|
|
13854
|
-
var onErrorListener = null;
|
|
13855
|
-
var onLoadListener = null;
|
|
13856
|
-
var onError = function onError2(reject) {
|
|
13857
|
-
return function() {
|
|
13858
|
-
reject(new Error("Failed to load Stripe.js"));
|
|
13859
|
-
};
|
|
13860
|
-
};
|
|
13861
|
-
var onLoad = function onLoad2(resolve, reject) {
|
|
13862
|
-
return function() {
|
|
13863
|
-
if (window.Stripe) {
|
|
13864
|
-
resolve(window.Stripe);
|
|
13865
|
-
} else {
|
|
13866
|
-
reject(new Error("Stripe.js not available"));
|
|
13867
|
-
}
|
|
13868
|
-
};
|
|
13869
|
-
};
|
|
13870
|
-
var loadScript = function loadScript2(params) {
|
|
13871
|
-
if (stripePromise$1 !== null) {
|
|
13872
|
-
return stripePromise$1;
|
|
13873
|
-
}
|
|
13874
|
-
stripePromise$1 = new Promise(function(resolve, reject) {
|
|
13875
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
13876
|
-
resolve(null);
|
|
13877
|
-
return;
|
|
13878
|
-
}
|
|
13879
|
-
if (window.Stripe && params) {
|
|
13880
|
-
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
13881
|
-
}
|
|
13882
|
-
if (window.Stripe) {
|
|
13883
|
-
resolve(window.Stripe);
|
|
13884
|
-
return;
|
|
13885
|
-
}
|
|
13886
|
-
try {
|
|
13887
|
-
var script = findScript();
|
|
13888
|
-
if (script && params) {
|
|
13889
|
-
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
13890
|
-
} else if (!script) {
|
|
13891
|
-
script = injectScript(params);
|
|
13892
|
-
} else if (script && onLoadListener !== null && onErrorListener !== null) {
|
|
13893
|
-
var _script$parentNode;
|
|
13894
|
-
script.removeEventListener("load", onLoadListener);
|
|
13895
|
-
script.removeEventListener("error", onErrorListener);
|
|
13896
|
-
(_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
|
|
13897
|
-
script = injectScript(params);
|
|
13898
|
-
}
|
|
13899
|
-
onLoadListener = onLoad(resolve, reject);
|
|
13900
|
-
onErrorListener = onError(reject);
|
|
13901
|
-
script.addEventListener("load", onLoadListener);
|
|
13902
|
-
script.addEventListener("error", onErrorListener);
|
|
13903
|
-
} catch (error) {
|
|
13904
|
-
reject(error);
|
|
13905
|
-
return;
|
|
13906
|
-
}
|
|
13907
|
-
});
|
|
13908
|
-
return stripePromise$1["catch"](function(error) {
|
|
13909
|
-
stripePromise$1 = null;
|
|
13910
|
-
return Promise.reject(error);
|
|
13911
|
-
});
|
|
13912
|
-
};
|
|
13913
|
-
var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
13914
|
-
if (maybeStripe === null) {
|
|
13915
|
-
return null;
|
|
13916
|
-
}
|
|
13917
|
-
var stripe = maybeStripe.apply(void 0, args);
|
|
13918
|
-
registerWrapper(stripe, startTime);
|
|
13919
|
-
return stripe;
|
|
13920
|
-
};
|
|
13921
|
-
var stripePromise;
|
|
13922
|
-
var loadCalled = false;
|
|
13923
|
-
var getStripePromise = function getStripePromise2() {
|
|
13924
|
-
if (stripePromise) {
|
|
13925
|
-
return stripePromise;
|
|
13926
|
-
}
|
|
13927
|
-
stripePromise = loadScript(null)["catch"](function(error) {
|
|
13928
|
-
stripePromise = null;
|
|
13929
|
-
return Promise.reject(error);
|
|
13930
|
-
});
|
|
13931
|
-
return stripePromise;
|
|
13932
|
-
};
|
|
13933
|
-
Promise.resolve().then(function() {
|
|
13934
|
-
return getStripePromise();
|
|
13935
|
-
})["catch"](function(error) {
|
|
13936
|
-
if (!loadCalled) {
|
|
13937
|
-
console.warn(error);
|
|
13938
|
-
}
|
|
13939
|
-
});
|
|
13940
|
-
var loadStripe = function loadStripe2() {
|
|
13941
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13942
|
-
args[_key] = arguments[_key];
|
|
13943
|
-
}
|
|
13944
|
-
loadCalled = true;
|
|
13945
|
-
var startTime = Date.now();
|
|
13946
|
-
return getStripePromise().then(function(maybeStripe) {
|
|
13947
|
-
return initStripe(maybeStripe, args, startTime);
|
|
13948
|
-
});
|
|
13949
|
-
};
|
|
13845
|
+
var import_react24 = require("react");
|
|
13950
13846
|
|
|
13951
13847
|
// src/components/shared/checkout-dialog/Navigation.tsx
|
|
13952
13848
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
@@ -14051,7 +13947,7 @@ var Navigation = ({
|
|
|
14051
13947
|
};
|
|
14052
13948
|
|
|
14053
13949
|
// src/components/shared/checkout-dialog/Sidebar.tsx
|
|
14054
|
-
var
|
|
13950
|
+
var import_react21 = require("react");
|
|
14055
13951
|
var import_pluralize = __toESM(require_pluralize());
|
|
14056
13952
|
|
|
14057
13953
|
// src/components/shared/checkout-dialog/StageButton.tsx
|
|
@@ -14062,22 +13958,25 @@ var StageButton = ({
|
|
|
14062
13958
|
canUpdateSubscription,
|
|
14063
13959
|
checkout,
|
|
14064
13960
|
checkoutStage,
|
|
13961
|
+
checkoutStages,
|
|
14065
13962
|
hasAddOns,
|
|
14066
13963
|
hasPayInAdvanceEntitlements,
|
|
14067
13964
|
isLoading,
|
|
13965
|
+
requiresPayment,
|
|
14068
13966
|
setCheckoutStage,
|
|
14069
|
-
setSetupIntent,
|
|
14070
13967
|
trialPaymentMethodRequired
|
|
14071
13968
|
}) => {
|
|
14072
13969
|
const { t: t2 } = useTranslation();
|
|
14073
|
-
const
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
13970
|
+
const NoPaymentRequired = () => {
|
|
13971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
13972
|
+
EmbedButton,
|
|
13973
|
+
{
|
|
13974
|
+
disabled: isLoading || !canCheckout,
|
|
13975
|
+
onClick: checkout,
|
|
13976
|
+
isLoading,
|
|
13977
|
+
children: t2("Subscribe and close")
|
|
13978
|
+
}
|
|
13979
|
+
);
|
|
14081
13980
|
};
|
|
14082
13981
|
if (checkoutStage === "plan") {
|
|
14083
13982
|
if (canTrial) {
|
|
@@ -14087,7 +13986,6 @@ var StageButton = ({
|
|
|
14087
13986
|
{
|
|
14088
13987
|
disabled: !hasAddOns && !canUpdateSubscription,
|
|
14089
13988
|
onClick: async () => {
|
|
14090
|
-
getPaymentIntent();
|
|
14091
13989
|
setCheckoutStage("checkout");
|
|
14092
13990
|
},
|
|
14093
13991
|
isLoading,
|
|
@@ -14114,7 +14012,6 @@ var StageButton = ({
|
|
|
14114
14012
|
{
|
|
14115
14013
|
disabled: !canUpdateSubscription,
|
|
14116
14014
|
onClick: async () => {
|
|
14117
|
-
getPaymentIntent();
|
|
14118
14015
|
checkout();
|
|
14119
14016
|
},
|
|
14120
14017
|
isLoading,
|
|
@@ -14126,7 +14023,7 @@ var StageButton = ({
|
|
|
14126
14023
|
$alignItems: "center",
|
|
14127
14024
|
$padding: "0 1rem",
|
|
14128
14025
|
children: [
|
|
14129
|
-
t2("
|
|
14026
|
+
t2("Subscribe and close"),
|
|
14130
14027
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon2, { name: "arrow-right" })
|
|
14131
14028
|
]
|
|
14132
14029
|
}
|
|
@@ -14134,14 +14031,16 @@ var StageButton = ({
|
|
|
14134
14031
|
}
|
|
14135
14032
|
);
|
|
14136
14033
|
}
|
|
14034
|
+
if (!requiresPayment && !checkoutStages.some(
|
|
14035
|
+
(stage) => stage.id === "addons" || stage.id === "usage"
|
|
14036
|
+
)) {
|
|
14037
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NoPaymentRequired, {});
|
|
14038
|
+
}
|
|
14137
14039
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
14138
14040
|
EmbedButton,
|
|
14139
14041
|
{
|
|
14140
14042
|
disabled: !canUpdateSubscription,
|
|
14141
14043
|
onClick: async () => {
|
|
14142
|
-
if (!hasAddOns && !hasPayInAdvanceEntitlements) {
|
|
14143
|
-
getPaymentIntent();
|
|
14144
|
-
}
|
|
14145
14044
|
setCheckoutStage(
|
|
14146
14045
|
hasPayInAdvanceEntitlements ? "usage" : hasAddOns ? "addons" : "checkout"
|
|
14147
14046
|
);
|
|
@@ -14167,14 +14066,14 @@ var StageButton = ({
|
|
|
14167
14066
|
);
|
|
14168
14067
|
}
|
|
14169
14068
|
if (checkoutStage === "usage") {
|
|
14069
|
+
if (!requiresPayment) {
|
|
14070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NoPaymentRequired, {});
|
|
14071
|
+
}
|
|
14170
14072
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
14171
14073
|
EmbedButton,
|
|
14172
14074
|
{
|
|
14173
14075
|
disabled: !canUpdateSubscription,
|
|
14174
14076
|
onClick: async () => {
|
|
14175
|
-
if (!hasAddOns) {
|
|
14176
|
-
getPaymentIntent();
|
|
14177
|
-
}
|
|
14178
14077
|
setCheckoutStage(hasAddOns ? "addons" : "checkout");
|
|
14179
14078
|
},
|
|
14180
14079
|
isLoading,
|
|
@@ -14197,12 +14096,14 @@ var StageButton = ({
|
|
|
14197
14096
|
);
|
|
14198
14097
|
}
|
|
14199
14098
|
if (checkoutStage === "addons") {
|
|
14099
|
+
if (!requiresPayment) {
|
|
14100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NoPaymentRequired, {});
|
|
14101
|
+
}
|
|
14200
14102
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
14201
14103
|
EmbedButton,
|
|
14202
14104
|
{
|
|
14203
14105
|
disabled: !canUpdateSubscription,
|
|
14204
14106
|
onClick: async () => {
|
|
14205
|
-
getPaymentIntent();
|
|
14206
14107
|
setCheckoutStage("checkout");
|
|
14207
14108
|
},
|
|
14208
14109
|
isLoading,
|
|
@@ -14225,6 +14126,9 @@ var StageButton = ({
|
|
|
14225
14126
|
);
|
|
14226
14127
|
}
|
|
14227
14128
|
if (checkoutStage === "checkout") {
|
|
14129
|
+
if (!requiresPayment) {
|
|
14130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NoPaymentRequired, {});
|
|
14131
|
+
}
|
|
14228
14132
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
14229
14133
|
EmbedButton,
|
|
14230
14134
|
{
|
|
@@ -14244,17 +14148,18 @@ var Sidebar = ({
|
|
|
14244
14148
|
charges,
|
|
14245
14149
|
checkoutRef,
|
|
14246
14150
|
checkoutStage,
|
|
14151
|
+
checkoutStages,
|
|
14247
14152
|
currentAddOns,
|
|
14248
|
-
currentPlan,
|
|
14249
14153
|
currentUsageBasedEntitlements,
|
|
14250
14154
|
error,
|
|
14155
|
+
currentPlan,
|
|
14251
14156
|
isLoading,
|
|
14252
14157
|
paymentMethodId,
|
|
14253
14158
|
planPeriod,
|
|
14159
|
+
requiresPayment,
|
|
14254
14160
|
selectedPlan,
|
|
14255
14161
|
setCheckoutStage,
|
|
14256
14162
|
setError,
|
|
14257
|
-
setSetupIntent,
|
|
14258
14163
|
showPaymentForm,
|
|
14259
14164
|
toggleLoading,
|
|
14260
14165
|
usageBasedEntitlements
|
|
@@ -14269,7 +14174,7 @@ var Sidebar = ({
|
|
|
14269
14174
|
const payAsYouGoEntitlements = usageBasedEntitlements.filter(
|
|
14270
14175
|
({ entitlement }) => entitlement.priceBehavior === "pay_as_you_go"
|
|
14271
14176
|
);
|
|
14272
|
-
const subscriptionPrice = (0,
|
|
14177
|
+
const subscriptionPrice = (0, import_react21.useMemo)(() => {
|
|
14273
14178
|
if (!selectedPlan || !selectedPlan.monthlyPrice || !selectedPlan.yearlyPrice) {
|
|
14274
14179
|
return;
|
|
14275
14180
|
}
|
|
@@ -14278,20 +14183,19 @@ var Sidebar = ({
|
|
|
14278
14183
|
if (planPrice) {
|
|
14279
14184
|
total += planPrice;
|
|
14280
14185
|
}
|
|
14281
|
-
const addOnCost = addOns.reduce(
|
|
14282
|
-
|
|
14283
|
-
|
|
14186
|
+
const addOnCost = addOns.reduce(
|
|
14187
|
+
(sum, addOn) => sum + (addOn.isSelected ? (planPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price || 0 : 0),
|
|
14188
|
+
0
|
|
14189
|
+
);
|
|
14284
14190
|
total += addOnCost;
|
|
14285
14191
|
const payInAdvanceCost = payInAdvanceEntitlements.reduce(
|
|
14286
|
-
(sum, { entitlement, quantity }) =>
|
|
14287
|
-
return sum + quantity * ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0);
|
|
14288
|
-
},
|
|
14192
|
+
(sum, { entitlement, quantity }) => sum + quantity * ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0),
|
|
14289
14193
|
0
|
|
14290
14194
|
);
|
|
14291
14195
|
total += payInAdvanceCost;
|
|
14292
14196
|
return formatCurrency(total);
|
|
14293
14197
|
}, [selectedPlan, addOns, payInAdvanceEntitlements, planPeriod]);
|
|
14294
|
-
const checkout = (0,
|
|
14198
|
+
const checkout = (0, import_react21.useCallback)(async () => {
|
|
14295
14199
|
const priceId = (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
|
|
14296
14200
|
if (!api || !selectedPlan || !priceId) {
|
|
14297
14201
|
return;
|
|
@@ -14352,7 +14256,7 @@ var Sidebar = ({
|
|
|
14352
14256
|
payInAdvanceEntitlements
|
|
14353
14257
|
]);
|
|
14354
14258
|
const selectedAddOns = addOns.filter((addOn) => addOn.isSelected);
|
|
14355
|
-
const willPlanChange =
|
|
14259
|
+
const willPlanChange = typeof selectedPlan !== "undefined" && selectedPlan.current === false;
|
|
14356
14260
|
const canUpdateSubscription = mode === "edit" || api !== null && (willPlanChange || // TODO: test add-on comparison for finding "changes"
|
|
14357
14261
|
selectedAddOns.length !== currentAddOns.length || !selectedAddOns.every(
|
|
14358
14262
|
(addOn) => currentAddOns.some((currentAddOn) => addOn.id === currentAddOn.id)
|
|
@@ -14366,21 +14270,42 @@ var Sidebar = ({
|
|
|
14366
14270
|
const changed = currentUsageBasedEntitlements.find(
|
|
14367
14271
|
(current) => current.usageData.featureId === selected.entitlement.featureId && current.quantity !== selected.quantity
|
|
14368
14272
|
);
|
|
14369
|
-
|
|
14370
|
-
(entitlement) => entitlement.id === selected.entitlement.id
|
|
14371
|
-
);
|
|
14372
|
-
if (changed && changed.quantity > 0) {
|
|
14273
|
+
if (changed) {
|
|
14373
14274
|
changedUsageBasedEntitlements.push({
|
|
14374
|
-
|
|
14375
|
-
|
|
14275
|
+
entitlement: selected.entitlement,
|
|
14276
|
+
previous: changed,
|
|
14277
|
+
next: {
|
|
14278
|
+
allocation: selected.allocation,
|
|
14279
|
+
quantity: selected.quantity,
|
|
14280
|
+
usage: selected.usage
|
|
14281
|
+
}
|
|
14282
|
+
});
|
|
14283
|
+
} else {
|
|
14284
|
+
acc.push(selected);
|
|
14285
|
+
}
|
|
14286
|
+
return acc;
|
|
14287
|
+
},
|
|
14288
|
+
[]
|
|
14289
|
+
);
|
|
14290
|
+
const removedUsageBasedEntitlements = currentUsageBasedEntitlements.reduce(
|
|
14291
|
+
(acc, current) => {
|
|
14292
|
+
const match2 = usageBasedEntitlements.every(
|
|
14293
|
+
({ entitlement }) => entitlement.featureId !== current.usageData.featureId
|
|
14294
|
+
) && currentPlan?.entitlements.find(
|
|
14295
|
+
(entitlement) => entitlement.featureId === current.usageData.featureId
|
|
14296
|
+
);
|
|
14297
|
+
if (match2) {
|
|
14298
|
+
acc.push({
|
|
14299
|
+
entitlement: match2,
|
|
14300
|
+
allocation: current.allocation,
|
|
14301
|
+
quantity: current.quantity
|
|
14376
14302
|
});
|
|
14377
14303
|
}
|
|
14378
|
-
acc.push(selected);
|
|
14379
14304
|
return acc;
|
|
14380
14305
|
},
|
|
14381
14306
|
[]
|
|
14382
14307
|
);
|
|
14383
|
-
const willUsageBasedEntitlementsChange = changedUsageBasedEntitlements.length > 0 || addedUsageBasedEntitlements.length > 0;
|
|
14308
|
+
const willUsageBasedEntitlementsChange = changedUsageBasedEntitlements.length > 0 || addedUsageBasedEntitlements.length > 0 || removedUsageBasedEntitlements.length > 0;
|
|
14384
14309
|
const removedAddOns = currentAddOns.filter(
|
|
14385
14310
|
(current) => !selectedAddOns.some((selected) => current.id === selected.id)
|
|
14386
14311
|
);
|
|
@@ -14459,7 +14384,7 @@ var Sidebar = ({
|
|
|
14459
14384
|
}
|
|
14460
14385
|
) }),
|
|
14461
14386
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $flexDirection: "column", $gap: "0.5rem", $marginBottom: "1.5rem", children: [
|
|
14462
|
-
|
|
14387
|
+
data.company?.plan && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14463
14388
|
Flex,
|
|
14464
14389
|
{
|
|
14465
14390
|
$justifyContent: "space-between",
|
|
@@ -14478,10 +14403,10 @@ var Sidebar = ({
|
|
|
14478
14403
|
$size: theme.typography.heading4.fontSize,
|
|
14479
14404
|
$weight: theme.typography.heading4.fontWeight,
|
|
14480
14405
|
$color: theme.typography.heading4.color,
|
|
14481
|
-
children:
|
|
14406
|
+
children: data.company.plan.name
|
|
14482
14407
|
}
|
|
14483
14408
|
) }),
|
|
14484
|
-
typeof
|
|
14409
|
+
typeof data.company.plan.planPrice === "number" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14485
14410
|
Text,
|
|
14486
14411
|
{
|
|
14487
14412
|
$font: theme.typography.text.fontFamily,
|
|
@@ -14489,10 +14414,12 @@ var Sidebar = ({
|
|
|
14489
14414
|
$weight: theme.typography.text.fontWeight,
|
|
14490
14415
|
$color: theme.typography.text.color,
|
|
14491
14416
|
children: [
|
|
14492
|
-
formatCurrency(
|
|
14417
|
+
formatCurrency(data.company.plan.planPrice),
|
|
14493
14418
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14494
14419
|
"/",
|
|
14495
|
-
shortenPeriod(
|
|
14420
|
+
shortenPeriod(
|
|
14421
|
+
data.company.plan.planPeriod || planPeriod
|
|
14422
|
+
)
|
|
14496
14423
|
] })
|
|
14497
14424
|
]
|
|
14498
14425
|
}
|
|
@@ -14572,9 +14499,10 @@ var Sidebar = ({
|
|
|
14572
14499
|
children: t2("Usage-based")
|
|
14573
14500
|
}
|
|
14574
14501
|
) }),
|
|
14575
|
-
|
|
14576
|
-
(acc, {
|
|
14577
|
-
if (entitlement
|
|
14502
|
+
removedUsageBasedEntitlements.reduce(
|
|
14503
|
+
(acc, { allocation, quantity, entitlement }) => {
|
|
14504
|
+
if (typeof allocation === "number" && entitlement.feature?.name) {
|
|
14505
|
+
const price = (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price;
|
|
14578
14506
|
acc.push(
|
|
14579
14507
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14580
14508
|
Flex,
|
|
@@ -14585,60 +14513,6 @@ var Sidebar = ({
|
|
|
14585
14513
|
$opacity: "0.625",
|
|
14586
14514
|
$textDecoration: "line-through",
|
|
14587
14515
|
$color: theme.typography.heading4.color,
|
|
14588
|
-
children: [
|
|
14589
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14590
|
-
Text,
|
|
14591
|
-
{
|
|
14592
|
-
$font: theme.typography.heading4.fontFamily,
|
|
14593
|
-
$size: theme.typography.heading4.fontSize,
|
|
14594
|
-
$weight: theme.typography.heading4.fontWeight,
|
|
14595
|
-
$color: theme.typography.heading4.color,
|
|
14596
|
-
children: [
|
|
14597
|
-
quantity,
|
|
14598
|
-
" ",
|
|
14599
|
-
(0, import_pluralize.default)(entitlement.feature.name)
|
|
14600
|
-
]
|
|
14601
|
-
}
|
|
14602
|
-
) }),
|
|
14603
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14604
|
-
Text,
|
|
14605
|
-
{
|
|
14606
|
-
$font: theme.typography.text.fontFamily,
|
|
14607
|
-
$size: theme.typography.text.fontSize,
|
|
14608
|
-
$weight: theme.typography.text.fontWeight,
|
|
14609
|
-
$color: theme.typography.text.color,
|
|
14610
|
-
children: [
|
|
14611
|
-
formatCurrency(
|
|
14612
|
-
((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * quantity
|
|
14613
|
-
),
|
|
14614
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14615
|
-
"/",
|
|
14616
|
-
shortenPeriod(planPeriod)
|
|
14617
|
-
] })
|
|
14618
|
-
]
|
|
14619
|
-
}
|
|
14620
|
-
) })
|
|
14621
|
-
]
|
|
14622
|
-
},
|
|
14623
|
-
entitlement.feature.id
|
|
14624
|
-
)
|
|
14625
|
-
);
|
|
14626
|
-
}
|
|
14627
|
-
return acc;
|
|
14628
|
-
},
|
|
14629
|
-
[]
|
|
14630
|
-
),
|
|
14631
|
-
addedUsageBasedEntitlements.reduce(
|
|
14632
|
-
(acc, { entitlement, quantity }) => {
|
|
14633
|
-
if (entitlement.feature?.name) {
|
|
14634
|
-
const price = (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price;
|
|
14635
|
-
acc.push(
|
|
14636
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14637
|
-
Flex,
|
|
14638
|
-
{
|
|
14639
|
-
$justifyContent: "space-between",
|
|
14640
|
-
$alignItems: "center",
|
|
14641
|
-
$gap: "1rem",
|
|
14642
14516
|
children: [
|
|
14643
14517
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
14644
14518
|
Text,
|
|
@@ -14691,13 +14565,176 @@ var Sidebar = ({
|
|
|
14691
14565
|
return acc;
|
|
14692
14566
|
},
|
|
14693
14567
|
[]
|
|
14694
|
-
)
|
|
14695
|
-
|
|
14696
|
-
|
|
14697
|
-
|
|
14698
|
-
|
|
14699
|
-
|
|
14700
|
-
|
|
14568
|
+
),
|
|
14569
|
+
changedUsageBasedEntitlements.reduce(
|
|
14570
|
+
(acc, { entitlement, previous, next: next2 }) => {
|
|
14571
|
+
if (entitlement?.feature?.name) {
|
|
14572
|
+
acc.push(
|
|
14573
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Box, { children: [
|
|
14574
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14575
|
+
Flex,
|
|
14576
|
+
{
|
|
14577
|
+
$justifyContent: "space-between",
|
|
14578
|
+
$alignItems: "center",
|
|
14579
|
+
$gap: "1rem",
|
|
14580
|
+
$opacity: "0.625",
|
|
14581
|
+
$textDecoration: "line-through",
|
|
14582
|
+
$color: theme.typography.heading4.color,
|
|
14583
|
+
children: [
|
|
14584
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14585
|
+
Text,
|
|
14586
|
+
{
|
|
14587
|
+
$font: theme.typography.heading4.fontFamily,
|
|
14588
|
+
$size: theme.typography.heading4.fontSize,
|
|
14589
|
+
$weight: theme.typography.heading4.fontWeight,
|
|
14590
|
+
$color: theme.typography.heading4.color,
|
|
14591
|
+
children: [
|
|
14592
|
+
previous.quantity,
|
|
14593
|
+
" ",
|
|
14594
|
+
(0, import_pluralize.default)(entitlement.feature.name)
|
|
14595
|
+
]
|
|
14596
|
+
}
|
|
14597
|
+
) }),
|
|
14598
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14599
|
+
Text,
|
|
14600
|
+
{
|
|
14601
|
+
$font: theme.typography.text.fontFamily,
|
|
14602
|
+
$size: theme.typography.text.fontSize,
|
|
14603
|
+
$weight: theme.typography.text.fontWeight,
|
|
14604
|
+
$color: theme.typography.text.color,
|
|
14605
|
+
children: [
|
|
14606
|
+
formatCurrency(
|
|
14607
|
+
((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * previous.quantity
|
|
14608
|
+
),
|
|
14609
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14610
|
+
"/",
|
|
14611
|
+
shortenPeriod(planPeriod)
|
|
14612
|
+
] })
|
|
14613
|
+
]
|
|
14614
|
+
}
|
|
14615
|
+
) })
|
|
14616
|
+
]
|
|
14617
|
+
}
|
|
14618
|
+
),
|
|
14619
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14620
|
+
Flex,
|
|
14621
|
+
{
|
|
14622
|
+
$justifyContent: "space-between",
|
|
14623
|
+
$alignItems: "center",
|
|
14624
|
+
$gap: "1rem",
|
|
14625
|
+
children: [
|
|
14626
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14627
|
+
Text,
|
|
14628
|
+
{
|
|
14629
|
+
$font: theme.typography.heading4.fontFamily,
|
|
14630
|
+
$size: theme.typography.heading4.fontSize,
|
|
14631
|
+
$weight: theme.typography.heading4.fontWeight,
|
|
14632
|
+
$color: theme.typography.heading4.color,
|
|
14633
|
+
children: [
|
|
14634
|
+
next2.quantity,
|
|
14635
|
+
" ",
|
|
14636
|
+
(0, import_pluralize.default)(entitlement.feature.name)
|
|
14637
|
+
]
|
|
14638
|
+
}
|
|
14639
|
+
) }),
|
|
14640
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14641
|
+
Text,
|
|
14642
|
+
{
|
|
14643
|
+
$font: theme.typography.text.fontFamily,
|
|
14644
|
+
$size: theme.typography.text.fontSize,
|
|
14645
|
+
$weight: theme.typography.text.fontWeight,
|
|
14646
|
+
$color: theme.typography.text.color,
|
|
14647
|
+
children: [
|
|
14648
|
+
formatCurrency(
|
|
14649
|
+
((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * next2.quantity
|
|
14650
|
+
),
|
|
14651
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14652
|
+
"/",
|
|
14653
|
+
shortenPeriod(planPeriod)
|
|
14654
|
+
] })
|
|
14655
|
+
]
|
|
14656
|
+
}
|
|
14657
|
+
) })
|
|
14658
|
+
]
|
|
14659
|
+
}
|
|
14660
|
+
)
|
|
14661
|
+
] }, entitlement.feature.id)
|
|
14662
|
+
);
|
|
14663
|
+
}
|
|
14664
|
+
return acc;
|
|
14665
|
+
},
|
|
14666
|
+
[]
|
|
14667
|
+
),
|
|
14668
|
+
addedUsageBasedEntitlements.reduce(
|
|
14669
|
+
(acc, { entitlement, quantity }) => {
|
|
14670
|
+
if (entitlement.feature?.name) {
|
|
14671
|
+
const price = (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price;
|
|
14672
|
+
acc.push(
|
|
14673
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14674
|
+
Flex,
|
|
14675
|
+
{
|
|
14676
|
+
$justifyContent: "space-between",
|
|
14677
|
+
$alignItems: "center",
|
|
14678
|
+
$gap: "1rem",
|
|
14679
|
+
children: [
|
|
14680
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
14681
|
+
Text,
|
|
14682
|
+
{
|
|
14683
|
+
$font: theme.typography.heading4.fontFamily,
|
|
14684
|
+
$size: theme.typography.heading4.fontSize,
|
|
14685
|
+
$weight: theme.typography.heading4.fontWeight,
|
|
14686
|
+
$color: theme.typography.heading4.color,
|
|
14687
|
+
children: entitlement.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
14688
|
+
quantity,
|
|
14689
|
+
" ",
|
|
14690
|
+
(0, import_pluralize.default)(entitlement.feature.name, quantity)
|
|
14691
|
+
] }) : entitlement.feature.name
|
|
14692
|
+
}
|
|
14693
|
+
) }),
|
|
14694
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14695
|
+
Text,
|
|
14696
|
+
{
|
|
14697
|
+
$font: theme.typography.text.fontFamily,
|
|
14698
|
+
$size: theme.typography.text.fontSize,
|
|
14699
|
+
$weight: theme.typography.text.fontWeight,
|
|
14700
|
+
$color: theme.typography.text.color,
|
|
14701
|
+
children: [
|
|
14702
|
+
entitlement.priceBehavior === "pay_in_advance" && typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
14703
|
+
formatCurrency(price * quantity),
|
|
14704
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14705
|
+
"/",
|
|
14706
|
+
shortenPeriod(planPeriod)
|
|
14707
|
+
] })
|
|
14708
|
+
] }),
|
|
14709
|
+
entitlement.priceBehavior === "pay_as_you_go" && typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
14710
|
+
formatCurrency(price),
|
|
14711
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14712
|
+
"/",
|
|
14713
|
+
(0, import_pluralize.default)(
|
|
14714
|
+
entitlement.feature.name.toLowerCase(),
|
|
14715
|
+
1
|
|
14716
|
+
)
|
|
14717
|
+
] })
|
|
14718
|
+
] })
|
|
14719
|
+
]
|
|
14720
|
+
}
|
|
14721
|
+
) })
|
|
14722
|
+
]
|
|
14723
|
+
},
|
|
14724
|
+
entitlement.id
|
|
14725
|
+
)
|
|
14726
|
+
);
|
|
14727
|
+
}
|
|
14728
|
+
return acc;
|
|
14729
|
+
},
|
|
14730
|
+
[]
|
|
14731
|
+
)
|
|
14732
|
+
] }),
|
|
14733
|
+
selectedPlan && isTrialable && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Box, { children: [
|
|
14734
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { $opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
14735
|
+
Text,
|
|
14736
|
+
{
|
|
14737
|
+
$font: theme.typography.text.fontFamily,
|
|
14701
14738
|
$size: 14,
|
|
14702
14739
|
$weight: theme.typography.text.fontWeight,
|
|
14703
14740
|
$color: theme.typography.text.color,
|
|
@@ -14844,7 +14881,7 @@ var Sidebar = ({
|
|
|
14844
14881
|
children: charges.proration > 0 ? t2("Proration") : !selectedPlan?.companyCanTrial && t2("Credits")
|
|
14845
14882
|
}
|
|
14846
14883
|
) }),
|
|
14847
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: currentPlan && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14884
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: currentPlan?.current && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14848
14885
|
Flex,
|
|
14849
14886
|
{
|
|
14850
14887
|
$justifyContent: "space-between",
|
|
@@ -14976,11 +15013,12 @@ var Sidebar = ({
|
|
|
14976
15013
|
canUpdateSubscription,
|
|
14977
15014
|
checkout,
|
|
14978
15015
|
checkoutStage,
|
|
15016
|
+
checkoutStages,
|
|
14979
15017
|
hasAddOns: addOns.length > 0,
|
|
14980
15018
|
hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
|
|
14981
15019
|
isLoading,
|
|
15020
|
+
requiresPayment,
|
|
14982
15021
|
setCheckoutStage,
|
|
14983
|
-
setSetupIntent,
|
|
14984
15022
|
trialPaymentMethodRequired: data.trialPaymentMethodRequired === true
|
|
14985
15023
|
}
|
|
14986
15024
|
),
|
|
@@ -15015,13 +15053,12 @@ var Sidebar = ({
|
|
|
15015
15053
|
};
|
|
15016
15054
|
|
|
15017
15055
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
15056
|
+
var import_react22 = require("react");
|
|
15018
15057
|
var import_pluralize2 = __toESM(require_pluralize());
|
|
15019
|
-
var import_react21 = require("react");
|
|
15020
15058
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
15021
15059
|
var Plan = ({
|
|
15022
15060
|
isLoading,
|
|
15023
15061
|
plans,
|
|
15024
|
-
currentPlan,
|
|
15025
15062
|
selectedPlan,
|
|
15026
15063
|
period,
|
|
15027
15064
|
selectPlan
|
|
@@ -15029,7 +15066,7 @@ var Plan = ({
|
|
|
15029
15066
|
const { t: t2 } = useTranslation();
|
|
15030
15067
|
const theme = nt();
|
|
15031
15068
|
const isLightBackground = useIsLightBackground();
|
|
15032
|
-
const [entitlementCounts, setEntitlementCounts] = (0,
|
|
15069
|
+
const [entitlementCounts, setEntitlementCounts] = (0, import_react22.useState)(
|
|
15033
15070
|
() => plans.reduce(
|
|
15034
15071
|
(acc, plan) => {
|
|
15035
15072
|
acc[plan.id] = {
|
|
@@ -15042,7 +15079,6 @@ var Plan = ({
|
|
|
15042
15079
|
)
|
|
15043
15080
|
);
|
|
15044
15081
|
const cardPadding = theme.card.padding / TEXT_BASE_SIZE;
|
|
15045
|
-
const currentPlanIndex = plans.findIndex((plan) => plan.current);
|
|
15046
15082
|
const handleToggleShowAll = (id) => {
|
|
15047
15083
|
setEntitlementCounts((prev2) => {
|
|
15048
15084
|
const count = { ...prev2[id] };
|
|
@@ -15062,8 +15098,7 @@ var Plan = ({
|
|
|
15062
15098
|
$gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))",
|
|
15063
15099
|
$gap: "1rem",
|
|
15064
15100
|
$flexGrow: "1",
|
|
15065
|
-
children: plans.map((plan
|
|
15066
|
-
const isActivePlan = plan.current && currentPlan?.planPeriod === period;
|
|
15101
|
+
children: plans.map((plan) => {
|
|
15067
15102
|
const count = entitlementCounts[plan.id];
|
|
15068
15103
|
let isExpanded = false;
|
|
15069
15104
|
if (count?.limit && count.limit > VISIBLE_ENTITLEMENT_COUNT) {
|
|
@@ -15144,7 +15179,7 @@ var Plan = ({
|
|
|
15144
15179
|
}
|
|
15145
15180
|
)
|
|
15146
15181
|
] }),
|
|
15147
|
-
|
|
15182
|
+
plan.current && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
15148
15183
|
Flex,
|
|
15149
15184
|
{
|
|
15150
15185
|
$position: "absolute",
|
|
@@ -15234,11 +15269,11 @@ var Plan = ({
|
|
|
15234
15269
|
period
|
|
15235
15270
|
] })
|
|
15236
15271
|
] }) : hasNumericValue ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15237
|
-
|
|
15272
|
+
entitlement.valueType === "unlimited" ? t2("Unlimited", {
|
|
15238
15273
|
item: (0, import_pluralize2.default)(
|
|
15239
15274
|
entitlement.feature.name
|
|
15240
15275
|
)
|
|
15241
|
-
}),
|
|
15276
|
+
}) : typeof entitlement.valueNumeric === "number" && `${formatNumber(entitlement.valueNumeric)} ${(0, import_pluralize2.default)(entitlement.feature.name, entitlement.valueNumeric)}`,
|
|
15242
15277
|
metricPeriodText && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15243
15278
|
" ",
|
|
15244
15279
|
t2("per"),
|
|
@@ -15316,7 +15351,7 @@ var Plan = ({
|
|
|
15316
15351
|
$size: 15,
|
|
15317
15352
|
$leading: 1,
|
|
15318
15353
|
$color: theme.typography.text.color,
|
|
15319
|
-
children:
|
|
15354
|
+
children: plan.current ? t2("Current plan") : t2("Selected")
|
|
15320
15355
|
}
|
|
15321
15356
|
)
|
|
15322
15357
|
]
|
|
@@ -15330,7 +15365,7 @@ var Plan = ({
|
|
|
15330
15365
|
},
|
|
15331
15366
|
$size: "sm",
|
|
15332
15367
|
$color: "primary",
|
|
15333
|
-
$variant:
|
|
15368
|
+
$variant: plan.current ? "outline" : "filled",
|
|
15334
15369
|
children: !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
15335
15370
|
Tooltip,
|
|
15336
15371
|
{
|
|
@@ -15545,8 +15580,10 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
15545
15580
|
Input,
|
|
15546
15581
|
{
|
|
15547
15582
|
type: "number",
|
|
15548
|
-
min: usage,
|
|
15549
15583
|
value: quantity,
|
|
15584
|
+
min: usage,
|
|
15585
|
+
autoFocus: true,
|
|
15586
|
+
onFocus: (event) => event.target.select(),
|
|
15550
15587
|
onChange: (event) => {
|
|
15551
15588
|
event.preventDefault();
|
|
15552
15589
|
const value = parseInt(event.target.value);
|
|
@@ -15628,19 +15665,182 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
15628
15665
|
}, []) }) });
|
|
15629
15666
|
};
|
|
15630
15667
|
|
|
15668
|
+
// src/components/shared/checkout-dialog/Checkout.tsx
|
|
15669
|
+
var import_react23 = require("react");
|
|
15670
|
+
|
|
15671
|
+
// node_modules/@stripe/stripe-js/dist/index.mjs
|
|
15672
|
+
var V3_URL = "https://js.stripe.com/v3";
|
|
15673
|
+
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
15674
|
+
var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
|
|
15675
|
+
var findScript = function findScript2() {
|
|
15676
|
+
var scripts = document.querySelectorAll('script[src^="'.concat(V3_URL, '"]'));
|
|
15677
|
+
for (var i2 = 0; i2 < scripts.length; i2++) {
|
|
15678
|
+
var script = scripts[i2];
|
|
15679
|
+
if (!V3_URL_REGEX.test(script.src)) {
|
|
15680
|
+
continue;
|
|
15681
|
+
}
|
|
15682
|
+
return script;
|
|
15683
|
+
}
|
|
15684
|
+
return null;
|
|
15685
|
+
};
|
|
15686
|
+
var injectScript = function injectScript2(params) {
|
|
15687
|
+
var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
|
|
15688
|
+
var script = document.createElement("script");
|
|
15689
|
+
script.src = "".concat(V3_URL).concat(queryString);
|
|
15690
|
+
var headOrBody = document.head || document.body;
|
|
15691
|
+
if (!headOrBody) {
|
|
15692
|
+
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
|
|
15693
|
+
}
|
|
15694
|
+
headOrBody.appendChild(script);
|
|
15695
|
+
return script;
|
|
15696
|
+
};
|
|
15697
|
+
var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
15698
|
+
if (!stripe || !stripe._registerWrapper) {
|
|
15699
|
+
return;
|
|
15700
|
+
}
|
|
15701
|
+
stripe._registerWrapper({
|
|
15702
|
+
name: "stripe-js",
|
|
15703
|
+
version: "5.5.0",
|
|
15704
|
+
startTime
|
|
15705
|
+
});
|
|
15706
|
+
};
|
|
15707
|
+
var stripePromise$1 = null;
|
|
15708
|
+
var onErrorListener = null;
|
|
15709
|
+
var onLoadListener = null;
|
|
15710
|
+
var onError = function onError2(reject) {
|
|
15711
|
+
return function() {
|
|
15712
|
+
reject(new Error("Failed to load Stripe.js"));
|
|
15713
|
+
};
|
|
15714
|
+
};
|
|
15715
|
+
var onLoad = function onLoad2(resolve, reject) {
|
|
15716
|
+
return function() {
|
|
15717
|
+
if (window.Stripe) {
|
|
15718
|
+
resolve(window.Stripe);
|
|
15719
|
+
} else {
|
|
15720
|
+
reject(new Error("Stripe.js not available"));
|
|
15721
|
+
}
|
|
15722
|
+
};
|
|
15723
|
+
};
|
|
15724
|
+
var loadScript = function loadScript2(params) {
|
|
15725
|
+
if (stripePromise$1 !== null) {
|
|
15726
|
+
return stripePromise$1;
|
|
15727
|
+
}
|
|
15728
|
+
stripePromise$1 = new Promise(function(resolve, reject) {
|
|
15729
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
15730
|
+
resolve(null);
|
|
15731
|
+
return;
|
|
15732
|
+
}
|
|
15733
|
+
if (window.Stripe && params) {
|
|
15734
|
+
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
15735
|
+
}
|
|
15736
|
+
if (window.Stripe) {
|
|
15737
|
+
resolve(window.Stripe);
|
|
15738
|
+
return;
|
|
15739
|
+
}
|
|
15740
|
+
try {
|
|
15741
|
+
var script = findScript();
|
|
15742
|
+
if (script && params) {
|
|
15743
|
+
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
15744
|
+
} else if (!script) {
|
|
15745
|
+
script = injectScript(params);
|
|
15746
|
+
} else if (script && onLoadListener !== null && onErrorListener !== null) {
|
|
15747
|
+
var _script$parentNode;
|
|
15748
|
+
script.removeEventListener("load", onLoadListener);
|
|
15749
|
+
script.removeEventListener("error", onErrorListener);
|
|
15750
|
+
(_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
|
|
15751
|
+
script = injectScript(params);
|
|
15752
|
+
}
|
|
15753
|
+
onLoadListener = onLoad(resolve, reject);
|
|
15754
|
+
onErrorListener = onError(reject);
|
|
15755
|
+
script.addEventListener("load", onLoadListener);
|
|
15756
|
+
script.addEventListener("error", onErrorListener);
|
|
15757
|
+
} catch (error) {
|
|
15758
|
+
reject(error);
|
|
15759
|
+
return;
|
|
15760
|
+
}
|
|
15761
|
+
});
|
|
15762
|
+
return stripePromise$1["catch"](function(error) {
|
|
15763
|
+
stripePromise$1 = null;
|
|
15764
|
+
return Promise.reject(error);
|
|
15765
|
+
});
|
|
15766
|
+
};
|
|
15767
|
+
var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
15768
|
+
if (maybeStripe === null) {
|
|
15769
|
+
return null;
|
|
15770
|
+
}
|
|
15771
|
+
var stripe = maybeStripe.apply(void 0, args);
|
|
15772
|
+
registerWrapper(stripe, startTime);
|
|
15773
|
+
return stripe;
|
|
15774
|
+
};
|
|
15775
|
+
var stripePromise;
|
|
15776
|
+
var loadCalled = false;
|
|
15777
|
+
var getStripePromise = function getStripePromise2() {
|
|
15778
|
+
if (stripePromise) {
|
|
15779
|
+
return stripePromise;
|
|
15780
|
+
}
|
|
15781
|
+
stripePromise = loadScript(null)["catch"](function(error) {
|
|
15782
|
+
stripePromise = null;
|
|
15783
|
+
return Promise.reject(error);
|
|
15784
|
+
});
|
|
15785
|
+
return stripePromise;
|
|
15786
|
+
};
|
|
15787
|
+
Promise.resolve().then(function() {
|
|
15788
|
+
return getStripePromise();
|
|
15789
|
+
})["catch"](function(error) {
|
|
15790
|
+
if (!loadCalled) {
|
|
15791
|
+
console.warn(error);
|
|
15792
|
+
}
|
|
15793
|
+
});
|
|
15794
|
+
var loadStripe = function loadStripe2() {
|
|
15795
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15796
|
+
args[_key] = arguments[_key];
|
|
15797
|
+
}
|
|
15798
|
+
loadCalled = true;
|
|
15799
|
+
var startTime = Date.now();
|
|
15800
|
+
return getStripePromise().then(function(maybeStripe) {
|
|
15801
|
+
return initStripe(maybeStripe, args, startTime);
|
|
15802
|
+
});
|
|
15803
|
+
};
|
|
15804
|
+
|
|
15631
15805
|
// src/components/shared/checkout-dialog/Checkout.tsx
|
|
15632
15806
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
15633
15807
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
15634
15808
|
var Checkout = ({
|
|
15809
|
+
requiresPayment,
|
|
15635
15810
|
setPaymentMethodId,
|
|
15636
15811
|
togglePaymentForm,
|
|
15637
|
-
|
|
15638
|
-
showPaymentForm,
|
|
15639
|
-
stripe
|
|
15812
|
+
showPaymentForm
|
|
15640
15813
|
}) => {
|
|
15641
15814
|
const { t: t2 } = useTranslation();
|
|
15642
15815
|
const theme = nt();
|
|
15643
|
-
const { data } = useEmbed();
|
|
15816
|
+
const { api, data } = useEmbed();
|
|
15817
|
+
const [stripe, setStripe] = (0, import_react23.useState)(null);
|
|
15818
|
+
const [setupIntent, setSetupIntent] = (0, import_react23.useState)();
|
|
15819
|
+
(0, import_react23.useEffect)(() => {
|
|
15820
|
+
if (api && data.component?.id) {
|
|
15821
|
+
api.getSetupIntent({ componentId: data.component.id }).then((res) => setSetupIntent(res.data));
|
|
15822
|
+
}
|
|
15823
|
+
}, [api, data.component?.id]);
|
|
15824
|
+
(0, import_react23.useEffect)(() => {
|
|
15825
|
+
if (setupIntent?.publishableKey) {
|
|
15826
|
+
setStripe(loadStripe(setupIntent.publishableKey));
|
|
15827
|
+
}
|
|
15828
|
+
}, [setupIntent?.publishableKey]);
|
|
15829
|
+
if (!requiresPayment) {
|
|
15830
|
+
return null;
|
|
15831
|
+
}
|
|
15832
|
+
if (!stripe) {
|
|
15833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
15834
|
+
Flex,
|
|
15835
|
+
{
|
|
15836
|
+
$justifyContent: "center",
|
|
15837
|
+
$alignItems: "center",
|
|
15838
|
+
$flexGrow: 1,
|
|
15839
|
+
$marginTop: "-3.5rem",
|
|
15840
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Loader, { $size: "3xl" })
|
|
15841
|
+
}
|
|
15842
|
+
);
|
|
15843
|
+
}
|
|
15644
15844
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: showPaymentForm && setupIntent?.setupIntentClientSecret ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
15645
15845
|
import_react_stripe_js.Elements,
|
|
15646
15846
|
{
|
|
@@ -15710,41 +15910,32 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15710
15910
|
const { t: t2 } = useTranslation();
|
|
15711
15911
|
const theme = nt();
|
|
15712
15912
|
const { api, data, selected } = useEmbed();
|
|
15713
|
-
const modalRef = (0,
|
|
15714
|
-
const contentRef = (0,
|
|
15715
|
-
const checkoutRef = (0,
|
|
15716
|
-
const [checkoutStage, setCheckoutStage] = (0,
|
|
15913
|
+
const modalRef = (0, import_react24.useRef)(null);
|
|
15914
|
+
const contentRef = (0, import_react24.useRef)(null);
|
|
15915
|
+
const checkoutRef = (0, import_react24.useRef)(null);
|
|
15916
|
+
const [checkoutStage, setCheckoutStage] = (0, import_react24.useState)(
|
|
15717
15917
|
() => selected.addOnId ? "addons" : selected.usage ? "usage" : "plan"
|
|
15718
15918
|
);
|
|
15719
|
-
const [planPeriod, setPlanPeriod] = (0,
|
|
15919
|
+
const [planPeriod, setPlanPeriod] = (0, import_react24.useState)(
|
|
15720
15920
|
selected.period || data.company?.plan?.planPeriod || "month"
|
|
15721
15921
|
);
|
|
15722
|
-
const [charges, setCharges] = (0,
|
|
15723
|
-
const [paymentMethodId, setPaymentMethodId] = (0,
|
|
15724
|
-
const [isLoading, setIsLoading] = (0,
|
|
15725
|
-
const [error, setError] = (0,
|
|
15726
|
-
const [showPaymentForm, setShowPaymentForm] = (0,
|
|
15922
|
+
const [charges, setCharges] = (0, import_react24.useState)();
|
|
15923
|
+
const [paymentMethodId, setPaymentMethodId] = (0, import_react24.useState)();
|
|
15924
|
+
const [isLoading, setIsLoading] = (0, import_react24.useState)(false);
|
|
15925
|
+
const [error, setError] = (0, import_react24.useState)();
|
|
15926
|
+
const [showPaymentForm, setShowPaymentForm] = (0, import_react24.useState)(
|
|
15727
15927
|
!data.subscription?.paymentMethod
|
|
15728
15928
|
);
|
|
15729
|
-
const [stripe, setStripe] = (0, import_react22.useState)(null);
|
|
15730
|
-
const [setupIntent, setSetupIntent] = (0, import_react22.useState)();
|
|
15731
15929
|
const {
|
|
15732
15930
|
plans: availablePlans,
|
|
15733
15931
|
addOns: availableAddOns,
|
|
15734
15932
|
periods: availablePeriods
|
|
15735
15933
|
} = useAvailablePlans(planPeriod);
|
|
15736
|
-
const
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
(plan) => plan.id === (typeof selected.planId !== "undefined" ? selected.planId : currentPlan?.id)
|
|
15740
|
-
);
|
|
15741
|
-
if (!p2) {
|
|
15742
|
-
return void 0;
|
|
15743
|
-
}
|
|
15744
|
-
return p2;
|
|
15745
|
-
});
|
|
15934
|
+
const [selectedPlan, setSelectedPlan] = (0, import_react24.useState)(
|
|
15935
|
+
() => availablePlans.find((plan) => plan.current)
|
|
15936
|
+
);
|
|
15746
15937
|
const currentAddOns = data.company?.addOns || [];
|
|
15747
|
-
const [addOns, setAddOns] = (0,
|
|
15938
|
+
const [addOns, setAddOns] = (0, import_react24.useState)(
|
|
15748
15939
|
() => availableAddOns.map((addOn) => ({
|
|
15749
15940
|
...addOn,
|
|
15750
15941
|
isSelected: typeof selected.addOnId !== "undefined" ? addOn.id === selected.addOnId : currentAddOns.some((currentAddOn) => addOn.id === currentAddOn.id)
|
|
@@ -15757,37 +15948,59 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15757
15948
|
);
|
|
15758
15949
|
const allocation = featureUsage?.allocation || 0;
|
|
15759
15950
|
const usage = featureUsage?.usage || 0;
|
|
15760
|
-
acc.push({
|
|
15951
|
+
acc.push({
|
|
15952
|
+
usageData,
|
|
15953
|
+
allocation,
|
|
15954
|
+
quantity: allocation ?? usage,
|
|
15955
|
+
usage
|
|
15956
|
+
});
|
|
15761
15957
|
return acc;
|
|
15762
15958
|
},
|
|
15763
15959
|
[]
|
|
15764
15960
|
);
|
|
15765
|
-
const createActiveUsageBasedEntitlementsReducer = (0,
|
|
15961
|
+
const createActiveUsageBasedEntitlementsReducer = (0, import_react24.useCallback)(
|
|
15766
15962
|
(period = planPeriod) => (acc, entitlement) => {
|
|
15767
15963
|
if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice)) {
|
|
15768
15964
|
const featureUsage = data.featureUsage?.features.find(
|
|
15769
15965
|
(usage2) => usage2.feature?.id === entitlement.feature?.id
|
|
15770
15966
|
);
|
|
15771
|
-
const allocation = featureUsage?.allocation
|
|
15772
|
-
const usage = featureUsage?.usage
|
|
15773
|
-
acc.push({
|
|
15967
|
+
const allocation = featureUsage?.allocation ?? 0;
|
|
15968
|
+
const usage = featureUsage?.usage ?? 0;
|
|
15969
|
+
acc.push({
|
|
15970
|
+
entitlement,
|
|
15971
|
+
allocation,
|
|
15972
|
+
quantity: allocation,
|
|
15973
|
+
usage
|
|
15974
|
+
});
|
|
15774
15975
|
}
|
|
15775
15976
|
return acc;
|
|
15776
15977
|
},
|
|
15777
15978
|
[planPeriod, data.featureUsage?.features]
|
|
15778
15979
|
);
|
|
15779
|
-
const [usageBasedEntitlements, setUsageBasedEntitlements] = (0,
|
|
15780
|
-
|
|
15980
|
+
const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react24.useState)(
|
|
15981
|
+
() => (selectedPlan?.entitlements || []).reduce(
|
|
15781
15982
|
createActiveUsageBasedEntitlementsReducer(),
|
|
15782
15983
|
[]
|
|
15783
|
-
)
|
|
15784
|
-
|
|
15785
|
-
const
|
|
15786
|
-
|
|
15984
|
+
)
|
|
15985
|
+
);
|
|
15986
|
+
const currentPlan = (0, import_react24.useMemo)(
|
|
15987
|
+
() => availablePlans.find(
|
|
15988
|
+
(plan) => plan.id === data.company?.plan?.id && data.company?.plan.planPeriod === planPeriod
|
|
15989
|
+
),
|
|
15990
|
+
[data.company?.plan, planPeriod, availablePlans]
|
|
15991
|
+
);
|
|
15992
|
+
const payInAdvanceEntitlements = (0, import_react24.useMemo)(
|
|
15993
|
+
() => usageBasedEntitlements.filter(
|
|
15787
15994
|
({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
|
|
15788
|
-
)
|
|
15789
|
-
|
|
15790
|
-
|
|
15995
|
+
),
|
|
15996
|
+
[usageBasedEntitlements]
|
|
15997
|
+
);
|
|
15998
|
+
const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected === true);
|
|
15999
|
+
const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
|
|
16000
|
+
({ quantity }) => quantity > 0
|
|
16001
|
+
);
|
|
16002
|
+
const requiresPayment = (!selectedPlan?.companyCanTrial || !!data.trialPaymentMethodRequired) && (!selectedPlan?.isFree || hasActiveAddOns || hasActivePayInAdvanceEntitlements);
|
|
16003
|
+
const checkoutStages = (0, import_react24.useMemo)(() => {
|
|
15791
16004
|
const stages = [
|
|
15792
16005
|
{
|
|
15793
16006
|
id: "plan",
|
|
@@ -15810,7 +16023,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15810
16023
|
description: t2("Optionally add features to your subscription")
|
|
15811
16024
|
});
|
|
15812
16025
|
}
|
|
15813
|
-
if (
|
|
16026
|
+
if (requiresPayment) {
|
|
15814
16027
|
stages.push({
|
|
15815
16028
|
id: "checkout",
|
|
15816
16029
|
name: t2("Checkout"),
|
|
@@ -15823,45 +16036,66 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15823
16036
|
payInAdvanceEntitlements,
|
|
15824
16037
|
availableAddOns,
|
|
15825
16038
|
selectedPlan?.companyCanTrial,
|
|
15826
|
-
|
|
16039
|
+
requiresPayment
|
|
15827
16040
|
]);
|
|
15828
16041
|
const isLightBackground = useIsLightBackground();
|
|
15829
|
-
const
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
16042
|
+
const selectPlan = (0, import_react24.useCallback)(
|
|
16043
|
+
(updatedPlan, updatedPeriod) => {
|
|
16044
|
+
const entitlements = updatedPlan.entitlements.reduce(
|
|
16045
|
+
createActiveUsageBasedEntitlementsReducer(updatedPeriod),
|
|
16046
|
+
[]
|
|
16047
|
+
);
|
|
16048
|
+
setSelectedPlan(updatedPlan);
|
|
16049
|
+
setUsageBasedEntitlements(entitlements);
|
|
16050
|
+
},
|
|
16051
|
+
[createActiveUsageBasedEntitlementsReducer]
|
|
16052
|
+
);
|
|
16053
|
+
const toggleAddOn = (id) => {
|
|
16054
|
+
setAddOns(
|
|
16055
|
+
(prev2) => prev2.map((addOn) => ({
|
|
16056
|
+
...addOn,
|
|
16057
|
+
...addOn.id === id && { isSelected: !addOn.isSelected }
|
|
16058
|
+
}))
|
|
16059
|
+
);
|
|
16060
|
+
};
|
|
16061
|
+
const changePlanPeriod = (0, import_react24.useCallback)(
|
|
16062
|
+
(period) => {
|
|
16063
|
+
if (selectedPlan) {
|
|
16064
|
+
selectPlan(selectedPlan, period);
|
|
16065
|
+
}
|
|
16066
|
+
setPlanPeriod(period);
|
|
16067
|
+
},
|
|
16068
|
+
[selectedPlan, selectPlan, setPlanPeriod]
|
|
16069
|
+
);
|
|
16070
|
+
const updateUsageBasedEntitlementQuantity = (id, updatedQuantity) => {
|
|
16071
|
+
setUsageBasedEntitlements(
|
|
16072
|
+
(prev2) => prev2.map(
|
|
16073
|
+
({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
|
|
16074
|
+
entitlement,
|
|
16075
|
+
allocation,
|
|
16076
|
+
quantity: updatedQuantity,
|
|
16077
|
+
usage
|
|
16078
|
+
} : { entitlement, allocation, quantity, usage }
|
|
16079
|
+
)
|
|
16080
|
+
);
|
|
16081
|
+
};
|
|
16082
|
+
(0, import_react24.useEffect)(() => {
|
|
16083
|
+
async function previewCheckout() {
|
|
16084
|
+
const planPriceId = planPeriod === "month" ? selectedPlan?.monthlyPrice?.id : selectedPlan?.yearlyPrice?.id;
|
|
16085
|
+
if (!api || !selectedPlan || !planPriceId) {
|
|
15839
16086
|
return;
|
|
15840
16087
|
}
|
|
16088
|
+
setError(void 0);
|
|
16089
|
+
setCharges(void 0);
|
|
16090
|
+
setIsLoading(true);
|
|
15841
16091
|
try {
|
|
15842
|
-
setError(void 0);
|
|
15843
|
-
setCharges(void 0);
|
|
15844
|
-
setIsLoading(true);
|
|
15845
|
-
const payInAdvance = entitlements.reduce(
|
|
15846
|
-
(acc, { entitlement, quantity }) => {
|
|
15847
|
-
const priceId = (periodValue === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.priceId;
|
|
15848
|
-
if (priceId) {
|
|
15849
|
-
acc.push({
|
|
15850
|
-
priceId,
|
|
15851
|
-
quantity
|
|
15852
|
-
});
|
|
15853
|
-
}
|
|
15854
|
-
return acc;
|
|
15855
|
-
},
|
|
15856
|
-
[]
|
|
15857
|
-
);
|
|
15858
16092
|
const { data: data2 } = await api.previewCheckout({
|
|
15859
16093
|
changeSubscriptionRequestBody: {
|
|
15860
|
-
newPlanId:
|
|
16094
|
+
newPlanId: selectedPlan.id,
|
|
15861
16095
|
newPriceId: planPriceId,
|
|
15862
|
-
addOnIds:
|
|
16096
|
+
addOnIds: addOns.reduce((acc, addOn) => {
|
|
15863
16097
|
if (addOn.isSelected) {
|
|
15864
|
-
const addOnPriceId = (
|
|
16098
|
+
const addOnPriceId = (planPeriod === "month" ? addOn?.monthlyPrice : addOn?.yearlyPrice)?.id;
|
|
15865
16099
|
if (addOnPriceId) {
|
|
15866
16100
|
acc.push({
|
|
15867
16101
|
addOnId: addOn.id,
|
|
@@ -15871,133 +16105,49 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15871
16105
|
}
|
|
15872
16106
|
return acc;
|
|
15873
16107
|
}, []),
|
|
15874
|
-
payInAdvance
|
|
16108
|
+
payInAdvance: payInAdvanceEntitlements.reduce(
|
|
16109
|
+
(acc, { entitlement, quantity }) => {
|
|
16110
|
+
const priceId = (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.priceId;
|
|
16111
|
+
if (priceId) {
|
|
16112
|
+
acc.push({
|
|
16113
|
+
priceId,
|
|
16114
|
+
quantity
|
|
16115
|
+
});
|
|
16116
|
+
}
|
|
16117
|
+
return acc;
|
|
16118
|
+
},
|
|
16119
|
+
[]
|
|
16120
|
+
)
|
|
15875
16121
|
}
|
|
15876
16122
|
});
|
|
15877
16123
|
setCharges(data2);
|
|
15878
|
-
} catch {
|
|
16124
|
+
} catch (error2) {
|
|
16125
|
+
if (error2 instanceof ResponseError && error2.response.status === 401) {
|
|
16126
|
+
const data2 = await error2.response.json();
|
|
16127
|
+
if (data2.error === "Access Token Invalid") {
|
|
16128
|
+
return setError(
|
|
16129
|
+
t2("Session expired. Please refresh and try again.")
|
|
16130
|
+
);
|
|
16131
|
+
}
|
|
16132
|
+
}
|
|
15879
16133
|
setError(
|
|
15880
16134
|
t2("Error retrieving plan details. Please try again in a moment.")
|
|
15881
16135
|
);
|
|
15882
16136
|
} finally {
|
|
15883
16137
|
setIsLoading(false);
|
|
15884
|
-
if (!period) {
|
|
15885
|
-
checkoutRef.current?.scrollIntoView({
|
|
15886
|
-
behavior: "smooth",
|
|
15887
|
-
block: "nearest"
|
|
15888
|
-
});
|
|
15889
|
-
}
|
|
15890
|
-
}
|
|
15891
|
-
},
|
|
15892
|
-
[t2, api, planPeriod]
|
|
15893
|
-
);
|
|
15894
|
-
const selectPlan = (0, import_react22.useCallback)(
|
|
15895
|
-
(updatedPlan, updatedPeriod) => {
|
|
15896
|
-
const entitlements = updatedPlan.entitlements.reduce(
|
|
15897
|
-
createActiveUsageBasedEntitlementsReducer(updatedPeriod),
|
|
15898
|
-
[]
|
|
15899
|
-
);
|
|
15900
|
-
const updatedPayInAdvanceEntitlements = entitlements.filter(
|
|
15901
|
-
({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
|
|
15902
|
-
);
|
|
15903
|
-
setSelectedPlan(updatedPlan);
|
|
15904
|
-
setUsageBasedEntitlements(entitlements);
|
|
15905
|
-
previewCheckout({
|
|
15906
|
-
plan: updatedPlan,
|
|
15907
|
-
addOns,
|
|
15908
|
-
entitlements: updatedPayInAdvanceEntitlements,
|
|
15909
|
-
period: updatedPeriod
|
|
15910
|
-
});
|
|
15911
|
-
},
|
|
15912
|
-
[addOns, previewCheckout, createActiveUsageBasedEntitlementsReducer]
|
|
15913
|
-
);
|
|
15914
|
-
const toggleAddOn = (0, import_react22.useCallback)(
|
|
15915
|
-
(id, updatedPeriod) => {
|
|
15916
|
-
const updatedAddOns = addOns.map((addOn) => ({
|
|
15917
|
-
...addOn,
|
|
15918
|
-
...addOn.id === id && { isSelected: !addOn.isSelected }
|
|
15919
|
-
}));
|
|
15920
|
-
setAddOns(updatedAddOns);
|
|
15921
|
-
if (!selectedPlan) {
|
|
15922
|
-
return;
|
|
15923
|
-
}
|
|
15924
|
-
previewCheckout({
|
|
15925
|
-
plan: selectedPlan,
|
|
15926
|
-
addOns: updatedAddOns,
|
|
15927
|
-
entitlements: payInAdvanceEntitlements,
|
|
15928
|
-
period: updatedPeriod || planPeriod
|
|
15929
|
-
});
|
|
15930
|
-
},
|
|
15931
|
-
[
|
|
15932
|
-
selectedPlan,
|
|
15933
|
-
addOns,
|
|
15934
|
-
payInAdvanceEntitlements,
|
|
15935
|
-
planPeriod,
|
|
15936
|
-
previewCheckout
|
|
15937
|
-
]
|
|
15938
|
-
);
|
|
15939
|
-
const changePlanPeriod = (0, import_react22.useCallback)(
|
|
15940
|
-
(period) => {
|
|
15941
|
-
if (selectedPlan) {
|
|
15942
|
-
selectPlan(selectedPlan, period);
|
|
15943
16138
|
}
|
|
15944
|
-
|
|
15945
|
-
|
|
15946
|
-
|
|
15947
|
-
)
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
({ entitlement, allocation, quantity, usage }) => {
|
|
15953
|
-
if (entitlement.id === id) {
|
|
15954
|
-
if (updatedQuantity < usage) {
|
|
15955
|
-
shouldPreview = false;
|
|
15956
|
-
}
|
|
15957
|
-
return {
|
|
15958
|
-
entitlement,
|
|
15959
|
-
allocation,
|
|
15960
|
-
quantity: updatedQuantity,
|
|
15961
|
-
usage
|
|
15962
|
-
};
|
|
15963
|
-
}
|
|
15964
|
-
return { entitlement, allocation, quantity, usage };
|
|
15965
|
-
}
|
|
15966
|
-
);
|
|
15967
|
-
setUsageBasedEntitlements(
|
|
15968
|
-
(prev2) => prev2.map(
|
|
15969
|
-
({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
|
|
15970
|
-
entitlement,
|
|
15971
|
-
allocation,
|
|
15972
|
-
quantity: updatedQuantity,
|
|
15973
|
-
usage
|
|
15974
|
-
} : { entitlement, allocation, quantity, usage }
|
|
15975
|
-
)
|
|
15976
|
-
);
|
|
15977
|
-
if (!selectedPlan || !shouldPreview) {
|
|
15978
|
-
return;
|
|
15979
|
-
}
|
|
15980
|
-
previewCheckout({
|
|
15981
|
-
plan: selectedPlan,
|
|
15982
|
-
addOns,
|
|
15983
|
-
entitlements,
|
|
15984
|
-
period: planPeriod
|
|
16139
|
+
}
|
|
16140
|
+
previewCheckout();
|
|
16141
|
+
}, [t2, api, planPeriod, selectedPlan, addOns, payInAdvanceEntitlements]);
|
|
16142
|
+
(0, import_react24.useEffect)(() => {
|
|
16143
|
+
if (charges) {
|
|
16144
|
+
checkoutRef.current?.scrollIntoView({
|
|
16145
|
+
behavior: "smooth",
|
|
16146
|
+
block: "nearest"
|
|
15985
16147
|
});
|
|
15986
|
-
},
|
|
15987
|
-
[
|
|
15988
|
-
selectedPlan,
|
|
15989
|
-
addOns,
|
|
15990
|
-
payInAdvanceEntitlements,
|
|
15991
|
-
planPeriod,
|
|
15992
|
-
previewCheckout
|
|
15993
|
-
]
|
|
15994
|
-
);
|
|
15995
|
-
(0, import_react22.useEffect)(() => {
|
|
15996
|
-
if (!stripe && setupIntent?.publishableKey) {
|
|
15997
|
-
setStripe(loadStripe(setupIntent.publishableKey));
|
|
15998
16148
|
}
|
|
15999
|
-
}, [
|
|
16000
|
-
(0,
|
|
16149
|
+
}, [charges]);
|
|
16150
|
+
(0, import_react24.useLayoutEffect)(() => {
|
|
16001
16151
|
if (contentRef.current) {
|
|
16002
16152
|
contentRef.current.scrollTo({
|
|
16003
16153
|
top: 0,
|
|
@@ -16124,7 +16274,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16124
16274
|
]
|
|
16125
16275
|
}
|
|
16126
16276
|
),
|
|
16127
|
-
|
|
16277
|
+
checkoutStage === "plan" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
16128
16278
|
PeriodToggle,
|
|
16129
16279
|
{
|
|
16130
16280
|
layerRef: modalRef,
|
|
@@ -16143,7 +16293,6 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16143
16293
|
isLoading,
|
|
16144
16294
|
period: planPeriod,
|
|
16145
16295
|
plans: availablePlans,
|
|
16146
|
-
currentPlan,
|
|
16147
16296
|
selectedPlan,
|
|
16148
16297
|
selectPlan
|
|
16149
16298
|
}
|
|
@@ -16170,9 +16319,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16170
16319
|
checkoutStage === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
16171
16320
|
Checkout,
|
|
16172
16321
|
{
|
|
16173
|
-
|
|
16322
|
+
requiresPayment,
|
|
16174
16323
|
showPaymentForm,
|
|
16175
|
-
stripe,
|
|
16176
16324
|
setPaymentMethodId: (id) => setPaymentMethodId(id),
|
|
16177
16325
|
togglePaymentForm: () => setShowPaymentForm((prev2) => !prev2)
|
|
16178
16326
|
}
|
|
@@ -16187,17 +16335,18 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16187
16335
|
charges,
|
|
16188
16336
|
checkoutRef,
|
|
16189
16337
|
checkoutStage,
|
|
16338
|
+
checkoutStages,
|
|
16190
16339
|
currentAddOns,
|
|
16191
|
-
currentPlan,
|
|
16192
16340
|
currentUsageBasedEntitlements,
|
|
16193
16341
|
error,
|
|
16342
|
+
currentPlan,
|
|
16194
16343
|
isLoading,
|
|
16195
16344
|
paymentMethodId,
|
|
16196
16345
|
planPeriod,
|
|
16346
|
+
requiresPayment,
|
|
16197
16347
|
selectedPlan,
|
|
16198
16348
|
setCheckoutStage: (stage) => setCheckoutStage(stage),
|
|
16199
16349
|
setError: (msg) => setError(msg),
|
|
16200
|
-
setSetupIntent: (intent) => setSetupIntent(intent),
|
|
16201
16350
|
showPaymentForm,
|
|
16202
16351
|
toggleLoading: () => setIsLoading((prev2) => !prev2),
|
|
16203
16352
|
usageBasedEntitlements
|
|
@@ -16212,7 +16361,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16212
16361
|
};
|
|
16213
16362
|
|
|
16214
16363
|
// src/components/shared/payment-form/PaymentForm.tsx
|
|
16215
|
-
var
|
|
16364
|
+
var import_react25 = require("react");
|
|
16216
16365
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
16217
16366
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
16218
16367
|
var PaymentForm = ({ onConfirm }) => {
|
|
@@ -16220,9 +16369,9 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
16220
16369
|
const stripe = (0, import_react_stripe_js2.useStripe)();
|
|
16221
16370
|
const elements = (0, import_react_stripe_js2.useElements)();
|
|
16222
16371
|
const { api } = useEmbed();
|
|
16223
|
-
const [message, setMessage] = (0,
|
|
16224
|
-
const [isLoading, setIsLoading] = (0,
|
|
16225
|
-
const [isConfirmed, setIsConfirmed] = (0,
|
|
16372
|
+
const [message, setMessage] = (0, import_react25.useState)(null);
|
|
16373
|
+
const [isLoading, setIsLoading] = (0, import_react25.useState)(false);
|
|
16374
|
+
const [isConfirmed, setIsConfirmed] = (0, import_react25.useState)(false);
|
|
16226
16375
|
const handleSubmit = async (event) => {
|
|
16227
16376
|
event.preventDefault();
|
|
16228
16377
|
if (!api || !stripe || !elements) {
|
|
@@ -16284,7 +16433,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
16284
16433
|
};
|
|
16285
16434
|
|
|
16286
16435
|
// src/components/shared/period-toggle/PeriodToggle.tsx
|
|
16287
|
-
var
|
|
16436
|
+
var import_react26 = require("react");
|
|
16288
16437
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
16289
16438
|
var PeriodToggle = ({
|
|
16290
16439
|
options,
|
|
@@ -16296,8 +16445,8 @@ var PeriodToggle = ({
|
|
|
16296
16445
|
const { t: t2 } = useTranslation();
|
|
16297
16446
|
const theme = nt();
|
|
16298
16447
|
const isLightBackground = useIsLightBackground();
|
|
16299
|
-
const [tooltipZIndex, setTooltipZIndex] = (0,
|
|
16300
|
-
const savingsPercentage = (0,
|
|
16448
|
+
const [tooltipZIndex, setTooltipZIndex] = (0, import_react26.useState)(1);
|
|
16449
|
+
const savingsPercentage = (0, import_react26.useMemo)(() => {
|
|
16301
16450
|
if (selectedPlan) {
|
|
16302
16451
|
const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
|
|
16303
16452
|
const yearly = selectedPlan?.yearlyPrice?.price || 0;
|
|
@@ -16305,7 +16454,7 @@ var PeriodToggle = ({
|
|
|
16305
16454
|
}
|
|
16306
16455
|
return 0;
|
|
16307
16456
|
}, [selectedPlan]);
|
|
16308
|
-
(0,
|
|
16457
|
+
(0, import_react26.useLayoutEffect)(() => {
|
|
16309
16458
|
const element = layerRef?.current;
|
|
16310
16459
|
if (element) {
|
|
16311
16460
|
const style = getComputedStyle(element);
|
|
@@ -16501,7 +16650,7 @@ var Badge = () => {
|
|
|
16501
16650
|
};
|
|
16502
16651
|
|
|
16503
16652
|
// src/components/layout/RenderLayout.tsx
|
|
16504
|
-
var
|
|
16653
|
+
var import_react27 = require("react");
|
|
16505
16654
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
16506
16655
|
var Disabled = () => {
|
|
16507
16656
|
const theme = nt();
|
|
@@ -16543,14 +16692,14 @@ var Disabled = () => {
|
|
|
16543
16692
|
var Success = () => {
|
|
16544
16693
|
const theme = nt();
|
|
16545
16694
|
const { hydrate, data, api, setLayout, isPending } = useEmbed();
|
|
16546
|
-
const [isOpen, setIsOpen] = (0,
|
|
16547
|
-
(0,
|
|
16695
|
+
const [isOpen, setIsOpen] = (0, import_react27.useState)(true);
|
|
16696
|
+
(0, import_react27.useEffect)(() => {
|
|
16548
16697
|
if (api && data.component?.id) {
|
|
16549
16698
|
hydrate();
|
|
16550
16699
|
setTimeout(() => setIsOpen(false), 2e3);
|
|
16551
16700
|
}
|
|
16552
16701
|
}, [api, data.component?.id, hydrate]);
|
|
16553
|
-
(0,
|
|
16702
|
+
(0, import_react27.useEffect)(() => {
|
|
16554
16703
|
if (!isPending && !isOpen) {
|
|
16555
16704
|
setLayout("portal");
|
|
16556
16705
|
}
|
|
@@ -16630,12 +16779,12 @@ var StyledViewport = dt(Box).attrs(({ theme }) => ({
|
|
|
16630
16779
|
|
|
16631
16780
|
// src/components/layout/viewport/Viewport.tsx
|
|
16632
16781
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
16633
|
-
var Viewport = (0,
|
|
16782
|
+
var Viewport = (0, import_react28.forwardRef)(
|
|
16634
16783
|
({ children, portal, ...props }, ref) => {
|
|
16635
16784
|
const { data, layout } = useEmbed();
|
|
16636
|
-
const [top, setTop] = (0,
|
|
16785
|
+
const [top, setTop] = (0, import_react28.useState)(0);
|
|
16637
16786
|
const canCheckout = data.capabilities?.checkout ?? true;
|
|
16638
|
-
(0,
|
|
16787
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
16639
16788
|
if (layout !== "checkout") {
|
|
16640
16789
|
return;
|
|
16641
16790
|
}
|
|
@@ -16661,10 +16810,10 @@ var Viewport = (0, import_react26.forwardRef)(
|
|
|
16661
16810
|
Viewport.displayName = "Viewport";
|
|
16662
16811
|
|
|
16663
16812
|
// src/components/layout/column/Column.tsx
|
|
16664
|
-
var
|
|
16813
|
+
var import_react30 = require("react");
|
|
16665
16814
|
|
|
16666
16815
|
// src/components/layout/card/Card.tsx
|
|
16667
|
-
var
|
|
16816
|
+
var import_react29 = require("react");
|
|
16668
16817
|
|
|
16669
16818
|
// src/components/layout/card/styles.ts
|
|
16670
16819
|
var Element = dt(Box)``;
|
|
@@ -16708,7 +16857,7 @@ var StyledCard = dt.div(({ theme }) => {
|
|
|
16708
16857
|
|
|
16709
16858
|
// src/components/layout/card/Card.tsx
|
|
16710
16859
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
16711
|
-
var Card = (0,
|
|
16860
|
+
var Card = (0, import_react29.forwardRef)(
|
|
16712
16861
|
({ children, className }, ref) => {
|
|
16713
16862
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(StyledCard, { ref, className, children });
|
|
16714
16863
|
}
|
|
@@ -16722,7 +16871,7 @@ var StyledColumn = dt.div`
|
|
|
16722
16871
|
|
|
16723
16872
|
// src/components/layout/column/Column.tsx
|
|
16724
16873
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
16725
|
-
var Column = (0,
|
|
16874
|
+
var Column = (0, import_react30.forwardRef)(
|
|
16726
16875
|
({ children, basis, ...props }, ref) => {
|
|
16727
16876
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(StyledColumn, { ref, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Card, { children }) });
|
|
16728
16877
|
}
|
|
@@ -16730,7 +16879,7 @@ var Column = (0, import_react28.forwardRef)(
|
|
|
16730
16879
|
Column.displayName = "Column";
|
|
16731
16880
|
|
|
16732
16881
|
// src/components/elements/included-features/Details.tsx
|
|
16733
|
-
var
|
|
16882
|
+
var import_react31 = require("react");
|
|
16734
16883
|
var import_pluralize4 = __toESM(require_pluralize());
|
|
16735
16884
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
16736
16885
|
var Details = ({
|
|
@@ -16750,7 +16899,7 @@ var Details = ({
|
|
|
16750
16899
|
const { t: t2 } = useTranslation();
|
|
16751
16900
|
const theme = nt();
|
|
16752
16901
|
const { data } = useEmbed();
|
|
16753
|
-
const price = (0,
|
|
16902
|
+
const price = (0, import_react31.useMemo)(() => {
|
|
16754
16903
|
if (data.company?.plan?.planPeriod === "month") {
|
|
16755
16904
|
return monthlyUsageBasedPrice?.price;
|
|
16756
16905
|
}
|
|
@@ -16762,7 +16911,7 @@ var Details = ({
|
|
|
16762
16911
|
monthlyUsageBasedPrice,
|
|
16763
16912
|
yearlyUsageBasedPrice
|
|
16764
16913
|
]);
|
|
16765
|
-
const text = (0,
|
|
16914
|
+
const text = (0, import_react31.useMemo)(() => {
|
|
16766
16915
|
if (!feature?.name) {
|
|
16767
16916
|
return;
|
|
16768
16917
|
}
|
|
@@ -16779,7 +16928,7 @@ var Details = ({
|
|
|
16779
16928
|
t2("Unlimited", { item: (0, import_pluralize4.default)(feature.name) });
|
|
16780
16929
|
}
|
|
16781
16930
|
}, [allocation, feature?.name, price, priceBehavior, t2]);
|
|
16782
|
-
const usageText = (0,
|
|
16931
|
+
const usageText = (0, import_react31.useMemo)(() => {
|
|
16783
16932
|
if (!feature?.name) {
|
|
16784
16933
|
return;
|
|
16785
16934
|
}
|
|
@@ -16884,16 +17033,24 @@ function resolveDesignProps(props) {
|
|
|
16884
17033
|
visibleFeatures: props.visibleFeatures
|
|
16885
17034
|
};
|
|
16886
17035
|
}
|
|
16887
|
-
var IncludedFeatures = (0,
|
|
17036
|
+
var IncludedFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, ref) => {
|
|
16888
17037
|
const props = resolveDesignProps(rest);
|
|
16889
17038
|
const { t: t2 } = useTranslation();
|
|
16890
17039
|
const theme = nt();
|
|
16891
17040
|
const { data } = useEmbed();
|
|
16892
|
-
const elements = (0,
|
|
17041
|
+
const elements = (0, import_react32.useRef)([]);
|
|
16893
17042
|
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
16894
17043
|
const isLightBackground = useIsLightBackground();
|
|
16895
|
-
const [showCount, setShowCount] = (0,
|
|
16896
|
-
const entitlements = (props.visibleFeatures ? props.visibleFeatures : data.featureUsage?.features.
|
|
17044
|
+
const [showCount, setShowCount] = (0, import_react32.useState)(VISIBLE_ENTITLEMENT_COUNT);
|
|
17045
|
+
const entitlements = (props.visibleFeatures ? props.visibleFeatures : data.featureUsage?.features.sort((a2, b2) => {
|
|
17046
|
+
if (a2.feature?.name && b2.feature?.name && a2.feature?.name > b2.feature?.name) {
|
|
17047
|
+
return 1;
|
|
17048
|
+
}
|
|
17049
|
+
if (a2.feature?.name && b2.feature?.name && a2.feature?.name < b2.feature?.name) {
|
|
17050
|
+
return -1;
|
|
17051
|
+
}
|
|
17052
|
+
return 0;
|
|
17053
|
+
}).reduce((acc, usage) => {
|
|
16897
17054
|
if (usage.feature?.id) {
|
|
16898
17055
|
acc.push(usage.feature.id);
|
|
16899
17056
|
}
|
|
@@ -16906,10 +17063,12 @@ var IncludedFeatures = (0, import_react30.forwardRef)(({ className, ...rest }, r
|
|
|
16906
17063
|
const mappedUsageData = data.activeUsageBasedEntitlements.find(
|
|
16907
17064
|
(entitlement) => entitlement.featureId === id
|
|
16908
17065
|
);
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
|
|
17066
|
+
if (mappedFeatureUsage) {
|
|
17067
|
+
acc.push({
|
|
17068
|
+
featureUsage: mappedFeatureUsage,
|
|
17069
|
+
usageData: mappedUsageData
|
|
17070
|
+
});
|
|
17071
|
+
}
|
|
16913
17072
|
return acc;
|
|
16914
17073
|
},
|
|
16915
17074
|
[]
|
|
@@ -16945,15 +17104,7 @@ var IncludedFeatures = (0, import_react30.forwardRef)(({ className, ...rest }, r
|
|
|
16945
17104
|
children: props.header.text
|
|
16946
17105
|
}
|
|
16947
17106
|
) }),
|
|
16948
|
-
entitlements.slice().
|
|
16949
|
-
if (a2.featureUsage?.feature?.name && b2.featureUsage?.feature?.name && a2.featureUsage?.feature?.name > b2.featureUsage?.feature?.name) {
|
|
16950
|
-
return 1;
|
|
16951
|
-
}
|
|
16952
|
-
if (a2.featureUsage?.feature?.name && b2.featureUsage?.feature?.name && a2.featureUsage?.feature?.name < b2.featureUsage?.feature?.name) {
|
|
16953
|
-
return -1;
|
|
16954
|
-
}
|
|
16955
|
-
return 0;
|
|
16956
|
-
}).slice(0, showCount).map((entitlement, index) => {
|
|
17107
|
+
entitlements.slice(0, showCount).map((entitlement, index) => {
|
|
16957
17108
|
const { entitlementExpirationDate, feature } = entitlement.featureUsage || {};
|
|
16958
17109
|
const shouldShowDetails = feature?.name && (feature?.featureType === "event" || feature?.featureType === "trait");
|
|
16959
17110
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
@@ -17061,7 +17212,7 @@ var IncludedFeatures = (0, import_react30.forwardRef)(({ className, ...rest }, r
|
|
|
17061
17212
|
IncludedFeatures.displayName = "IncludedFeatures";
|
|
17062
17213
|
|
|
17063
17214
|
// src/components/elements/invoices/Invoices.tsx
|
|
17064
|
-
var
|
|
17215
|
+
var import_react33 = require("react");
|
|
17065
17216
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
17066
17217
|
function resolveDesignProps2(props) {
|
|
17067
17218
|
return {
|
|
@@ -17115,19 +17266,19 @@ var InvoiceDate = ({ date, fontStyle, url }) => {
|
|
|
17115
17266
|
}
|
|
17116
17267
|
return dateText;
|
|
17117
17268
|
};
|
|
17118
|
-
var Invoices = (0,
|
|
17269
|
+
var Invoices = (0, import_react33.forwardRef)(({ className, data, ...rest }, ref) => {
|
|
17119
17270
|
const props = resolveDesignProps2(rest);
|
|
17120
17271
|
const { t: t2 } = useTranslation();
|
|
17121
17272
|
const theme = nt();
|
|
17122
17273
|
const { api } = useEmbed();
|
|
17123
|
-
const [invoices, setInvoices] = (0,
|
|
17124
|
-
const [listSize, setListSize] = (0,
|
|
17274
|
+
const [invoices, setInvoices] = (0, import_react33.useState)(() => formatInvoices(data));
|
|
17275
|
+
const [listSize, setListSize] = (0, import_react33.useState)(props.limit.number);
|
|
17125
17276
|
const toggleListSize = () => {
|
|
17126
17277
|
setListSize(
|
|
17127
17278
|
(prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
|
|
17128
17279
|
);
|
|
17129
17280
|
};
|
|
17130
|
-
(0,
|
|
17281
|
+
(0, import_react33.useEffect)(() => {
|
|
17131
17282
|
api?.listInvoices().then(({ data: data2 }) => {
|
|
17132
17283
|
setInvoices(formatInvoices(data2));
|
|
17133
17284
|
});
|
|
@@ -17193,7 +17344,7 @@ var Invoices = (0, import_react31.forwardRef)(({ className, data, ...rest }, ref
|
|
|
17193
17344
|
Invoices.displayName = "Invoices";
|
|
17194
17345
|
|
|
17195
17346
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
|
17196
|
-
var
|
|
17347
|
+
var import_react34 = require("react");
|
|
17197
17348
|
var import_pluralize5 = __toESM(require_pluralize());
|
|
17198
17349
|
|
|
17199
17350
|
// src/components/elements/metered-features/styles.ts
|
|
@@ -17240,20 +17391,15 @@ function resolveDesignProps3(props) {
|
|
|
17240
17391
|
visibleFeatures: props.visibleFeatures
|
|
17241
17392
|
};
|
|
17242
17393
|
}
|
|
17243
|
-
var MeteredFeatures = (0,
|
|
17394
|
+
var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, ref) => {
|
|
17244
17395
|
const props = resolveDesignProps3(rest);
|
|
17245
|
-
const elements = (0,
|
|
17396
|
+
const elements = (0, import_react34.useRef)([]);
|
|
17246
17397
|
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
17247
17398
|
const { t: t2 } = useTranslation();
|
|
17248
17399
|
const theme = nt();
|
|
17249
17400
|
const { data, setLayout, setSelected } = useEmbed();
|
|
17250
17401
|
const isLightBackground = useIsLightBackground();
|
|
17251
17402
|
const { planPeriod } = data.company?.plan || {};
|
|
17252
|
-
let resetDate;
|
|
17253
|
-
if (data.subscription?.expiredAt) {
|
|
17254
|
-
resetDate = new Date(data.subscription?.expiredAt);
|
|
17255
|
-
resetDate.setDate(resetDate.getDate() + 1);
|
|
17256
|
-
}
|
|
17257
17403
|
const featureUsage = (props.visibleFeatures ? props.visibleFeatures.reduce((acc, id) => {
|
|
17258
17404
|
const mappedFeatureUsage = data.featureUsage?.features.find(
|
|
17259
17405
|
(usage) => usage.feature?.id === id
|
|
@@ -17275,6 +17421,7 @@ var MeteredFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, re
|
|
|
17275
17421
|
feature,
|
|
17276
17422
|
usage,
|
|
17277
17423
|
priceBehavior,
|
|
17424
|
+
metricResetAt,
|
|
17278
17425
|
monthlyUsageBasedPrice,
|
|
17279
17426
|
yearlyUsageBasedPrice
|
|
17280
17427
|
}, index) => {
|
|
@@ -17366,8 +17513,8 @@ var MeteredFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, re
|
|
|
17366
17513
|
$size: theme.typography[props.allocation.fontStyle].fontSize,
|
|
17367
17514
|
$weight: theme.typography[props.allocation.fontStyle].fontWeight,
|
|
17368
17515
|
$color: theme.typography[props.allocation.fontStyle].color,
|
|
17369
|
-
children: priceBehavior &&
|
|
17370
|
-
date: toPrettyDate(
|
|
17516
|
+
children: priceBehavior && metricResetAt ? t2("Resets", {
|
|
17517
|
+
date: toPrettyDate(metricResetAt, {
|
|
17371
17518
|
month: "short",
|
|
17372
17519
|
day: "numeric",
|
|
17373
17520
|
year: void 0
|
|
@@ -17419,7 +17566,7 @@ var MeteredFeatures = (0, import_react32.forwardRef)(({ className, ...rest }, re
|
|
|
17419
17566
|
MeteredFeatures.displayName = "MeteredFeatures";
|
|
17420
17567
|
|
|
17421
17568
|
// src/components/elements/payment-method/PaymentMethod.tsx
|
|
17422
|
-
var
|
|
17569
|
+
var import_react35 = require("react");
|
|
17423
17570
|
var import_react_dom3 = require("react-dom");
|
|
17424
17571
|
var import_react_stripe_js3 = require("@stripe/react-stripe-js");
|
|
17425
17572
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
@@ -17495,21 +17642,21 @@ var PaymentMethodElement = ({
|
|
|
17495
17642
|
)
|
|
17496
17643
|
] });
|
|
17497
17644
|
};
|
|
17498
|
-
var PaymentMethod = (0,
|
|
17645
|
+
var PaymentMethod = (0, import_react35.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
|
|
17499
17646
|
const props = resolveDesignProps4(rest);
|
|
17500
17647
|
const { t: t2 } = useTranslation();
|
|
17501
17648
|
const theme = nt();
|
|
17502
17649
|
const { api, data, layout, setLayout } = useEmbed();
|
|
17503
17650
|
const isLightBackground = useIsLightBackground();
|
|
17504
|
-
const [isLoading, setIsLoading] = (0,
|
|
17505
|
-
const [error, setError] = (0,
|
|
17506
|
-
const [showPaymentForm, setShowPaymentForm] = (0,
|
|
17651
|
+
const [isLoading, setIsLoading] = (0, import_react35.useState)(false);
|
|
17652
|
+
const [error, setError] = (0, import_react35.useState)();
|
|
17653
|
+
const [showPaymentForm, setShowPaymentForm] = (0, import_react35.useState)(
|
|
17507
17654
|
() => typeof data.subscription?.paymentMethod === "undefined"
|
|
17508
17655
|
);
|
|
17509
|
-
const [stripe, setStripe] = (0,
|
|
17510
|
-
const [setupIntent, setSetupIntent] = (0,
|
|
17511
|
-
const [top, setTop] = (0,
|
|
17512
|
-
const paymentMethod = (0,
|
|
17656
|
+
const [stripe, setStripe] = (0, import_react35.useState)(null);
|
|
17657
|
+
const [setupIntent, setSetupIntent] = (0, import_react35.useState)();
|
|
17658
|
+
const [top, setTop] = (0, import_react35.useState)(0);
|
|
17659
|
+
const paymentMethod = (0, import_react35.useMemo)(() => {
|
|
17513
17660
|
const { paymentMethodType, cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
|
|
17514
17661
|
let monthsToExpiration;
|
|
17515
17662
|
if (typeof cardExpYear === "number" && typeof cardExpMonth === "number") {
|
|
@@ -17529,7 +17676,7 @@ var PaymentMethod = (0, import_react33.forwardRef)(({ children, className, porta
|
|
|
17529
17676
|
monthsToExpiration
|
|
17530
17677
|
};
|
|
17531
17678
|
}, [data.subscription?.paymentMethod]);
|
|
17532
|
-
const createSetupIntent = (0,
|
|
17679
|
+
const createSetupIntent = (0, import_react35.useCallback)(async () => {
|
|
17533
17680
|
if (!api || !data.component?.id) {
|
|
17534
17681
|
return;
|
|
17535
17682
|
}
|
|
@@ -17548,7 +17695,7 @@ var PaymentMethod = (0, import_react33.forwardRef)(({ children, className, porta
|
|
|
17548
17695
|
setIsLoading(false);
|
|
17549
17696
|
}
|
|
17550
17697
|
}, [t2, api, data.component?.id]);
|
|
17551
|
-
const updatePaymentMethod = (0,
|
|
17698
|
+
const updatePaymentMethod = (0, import_react35.useCallback)(
|
|
17552
17699
|
async (id) => {
|
|
17553
17700
|
if (!api || !id) {
|
|
17554
17701
|
return;
|
|
@@ -17569,12 +17716,12 @@ var PaymentMethod = (0, import_react33.forwardRef)(({ children, className, porta
|
|
|
17569
17716
|
},
|
|
17570
17717
|
[t2, api, setLayout]
|
|
17571
17718
|
);
|
|
17572
|
-
(0,
|
|
17719
|
+
(0, import_react35.useEffect)(() => {
|
|
17573
17720
|
if (!stripe && setupIntent?.publishableKey) {
|
|
17574
17721
|
setStripe(loadStripe(setupIntent.publishableKey));
|
|
17575
17722
|
}
|
|
17576
17723
|
}, [stripe, setupIntent?.publishableKey]);
|
|
17577
|
-
(0,
|
|
17724
|
+
(0, import_react35.useLayoutEffect)(() => {
|
|
17578
17725
|
const parent = portal || document.body;
|
|
17579
17726
|
const value = Math.abs(
|
|
17580
17727
|
(parent === document.body ? window.scrollY : parent.scrollTop) ?? 0
|
|
@@ -17699,7 +17846,7 @@ var PaymentMethod = (0, import_react33.forwardRef)(({ children, className, porta
|
|
|
17699
17846
|
PaymentMethod.displayName = "PaymentMethod";
|
|
17700
17847
|
|
|
17701
17848
|
// src/components/elements/plan-manager/PlanManager.tsx
|
|
17702
|
-
var
|
|
17849
|
+
var import_react36 = require("react");
|
|
17703
17850
|
var import_pluralize6 = __toESM(require_pluralize());
|
|
17704
17851
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
17705
17852
|
var resolveDesignProps5 = (props) => {
|
|
@@ -17730,16 +17877,17 @@ var resolveDesignProps5 = (props) => {
|
|
|
17730
17877
|
}
|
|
17731
17878
|
};
|
|
17732
17879
|
};
|
|
17733
|
-
var PlanManager = (0,
|
|
17880
|
+
var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal, ...rest }, ref) => {
|
|
17734
17881
|
const props = resolveDesignProps5(rest);
|
|
17735
17882
|
const theme = nt();
|
|
17736
17883
|
const { t: t2 } = useTranslation();
|
|
17737
17884
|
const { data, setLayout, setSelected } = useEmbed();
|
|
17738
17885
|
const isLightBackground = useIsLightBackground();
|
|
17739
|
-
const { addOns, canCheckout, currentPlan, featureUsage } = {
|
|
17886
|
+
const { addOns, canCheckout, currentPlan, defaultPlan, featureUsage } = {
|
|
17740
17887
|
addOns: data.company?.addOns || [],
|
|
17741
17888
|
currentPlan: data.company?.plan,
|
|
17742
17889
|
canCheckout: data.capabilities?.checkout ?? true,
|
|
17890
|
+
defaultPlan: data.defaultPlan,
|
|
17743
17891
|
featureUsage: data.featureUsage
|
|
17744
17892
|
};
|
|
17745
17893
|
const usageBasedEntitlements = (featureUsage?.features || []).reduce(
|
|
@@ -17792,7 +17940,11 @@ var PlanManager = (0, import_react34.forwardRef)(({ children, className, portal,
|
|
|
17792
17940
|
$size: theme.typography.text.fontSize * 0.8125,
|
|
17793
17941
|
$weight: theme.typography.text.fontWeight,
|
|
17794
17942
|
$color: theme.typography.text.color,
|
|
17795
|
-
children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : t2("After the trial, cancel"
|
|
17943
|
+
children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
|
|
17944
|
+
defaultPlanName: defaultPlan?.name
|
|
17945
|
+
}) : t2("After the trial, cancel no default", {
|
|
17946
|
+
planName: currentPlan?.name
|
|
17947
|
+
})
|
|
17796
17948
|
}
|
|
17797
17949
|
)
|
|
17798
17950
|
]
|
|
@@ -18039,7 +18191,7 @@ var PlanManager = (0, import_react34.forwardRef)(({ children, className, portal,
|
|
|
18039
18191
|
PlanManager.displayName = "PlanManager";
|
|
18040
18192
|
|
|
18041
18193
|
// src/components/elements/pricing-table/PricingTable.tsx
|
|
18042
|
-
var
|
|
18194
|
+
var import_react37 = require("react");
|
|
18043
18195
|
var import_pluralize7 = __toESM(require_pluralize());
|
|
18044
18196
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
18045
18197
|
var resolveDesignProps6 = (props) => {
|
|
@@ -18081,17 +18233,18 @@ var resolveDesignProps6 = (props) => {
|
|
|
18081
18233
|
}
|
|
18082
18234
|
};
|
|
18083
18235
|
};
|
|
18084
|
-
var PricingTable = (0,
|
|
18236
|
+
var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...rest }, ref) => {
|
|
18085
18237
|
const props = resolveDesignProps6(rest);
|
|
18086
18238
|
const { t: t2 } = useTranslation();
|
|
18087
18239
|
const theme = nt();
|
|
18088
18240
|
const { data, setLayout, setSelected } = useEmbed();
|
|
18089
|
-
const
|
|
18241
|
+
const trialEndDays = useTrialEnd();
|
|
18242
|
+
const [selectedPeriod, setSelectedPeriod] = (0, import_react37.useState)(
|
|
18090
18243
|
() => data.company?.plan?.planPeriod || "month"
|
|
18091
18244
|
);
|
|
18092
18245
|
const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
|
|
18093
18246
|
const isLightBackground = useIsLightBackground();
|
|
18094
|
-
const [entitlementCounts, setEntitlementCounts] = (0,
|
|
18247
|
+
const [entitlementCounts, setEntitlementCounts] = (0, import_react37.useState)(
|
|
18095
18248
|
() => plans.reduce(
|
|
18096
18249
|
(acc, plan) => {
|
|
18097
18250
|
acc[plan.id] = {
|
|
@@ -18258,7 +18411,7 @@ var PricingTable = (0, import_react35.forwardRef)(({ children, className, ...res
|
|
|
18258
18411
|
$backgroundColor: theme.primary,
|
|
18259
18412
|
$borderRadius: "9999px",
|
|
18260
18413
|
$padding: "0.125rem 0.85rem",
|
|
18261
|
-
children: t2("Active")
|
|
18414
|
+
children: trialEndDays ? t2("Trial ends in", { days: trialEndDays }) : t2("Active")
|
|
18262
18415
|
}
|
|
18263
18416
|
)
|
|
18264
18417
|
]
|
|
@@ -18341,11 +18494,11 @@ var PricingTable = (0, import_react35.forwardRef)(({ children, className, ...res
|
|
|
18341
18494
|
selectedPeriod
|
|
18342
18495
|
] })
|
|
18343
18496
|
] }) : entitlement.valueType === "numeric" || entitlement.valueType === "unlimited" || entitlement.valueType === "trait" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
18344
|
-
|
|
18497
|
+
entitlement.valueType === "unlimited" ? t2("Unlimited", {
|
|
18345
18498
|
item: (0, import_pluralize7.default)(
|
|
18346
18499
|
entitlement.feature.name
|
|
18347
18500
|
)
|
|
18348
|
-
}),
|
|
18501
|
+
}) : typeof entitlement.valueNumeric === "number" && `${formatNumber(entitlement.valueNumeric)} ${(0, import_pluralize7.default)(entitlement.feature.name, entitlement.valueNumeric)}`,
|
|
18349
18502
|
entitlement.metricPeriod && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
18350
18503
|
" ",
|
|
18351
18504
|
t2("per"),
|
|
@@ -18620,11 +18773,11 @@ var PricingTable = (0, import_react35.forwardRef)(({ children, className, ...res
|
|
|
18620
18773
|
$weight: theme.typography.text.fontWeight,
|
|
18621
18774
|
$color: theme.typography.text.color,
|
|
18622
18775
|
children: entitlement.valueType === "numeric" || entitlement.valueType === "unlimited" || entitlement.valueType === "trait" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
18623
|
-
|
|
18776
|
+
entitlement.valueType === "unlimited" ? t2("Unlimited", {
|
|
18624
18777
|
item: (0, import_pluralize7.default)(
|
|
18625
18778
|
entitlement.feature.name
|
|
18626
18779
|
)
|
|
18627
|
-
}),
|
|
18780
|
+
}) : typeof entitlement.valueNumeric === "number" && `${formatNumber(entitlement.valueNumeric)} ${(0, import_pluralize7.default)(entitlement.feature.name, entitlement.valueNumeric)}`,
|
|
18628
18781
|
entitlement.metricPeriod && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
18629
18782
|
" ",
|
|
18630
18783
|
t2("per"),
|
|
@@ -18682,7 +18835,7 @@ var PricingTable = (0, import_react35.forwardRef)(({ children, className, ...res
|
|
|
18682
18835
|
PricingTable.displayName = "PricingTable";
|
|
18683
18836
|
|
|
18684
18837
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
|
18685
|
-
var
|
|
18838
|
+
var import_react38 = require("react");
|
|
18686
18839
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
18687
18840
|
function resolveDesignProps7(props) {
|
|
18688
18841
|
return {
|
|
@@ -18702,12 +18855,12 @@ function resolveDesignProps7(props) {
|
|
|
18702
18855
|
}
|
|
18703
18856
|
};
|
|
18704
18857
|
}
|
|
18705
|
-
var UpcomingBill = (0,
|
|
18858
|
+
var UpcomingBill = (0, import_react38.forwardRef)(({ className, ...rest }, ref) => {
|
|
18706
18859
|
const props = resolveDesignProps7(rest);
|
|
18707
18860
|
const { t: t2 } = useTranslation();
|
|
18708
18861
|
const theme = nt();
|
|
18709
18862
|
const { data } = useEmbed();
|
|
18710
|
-
const { upcomingInvoice } = (0,
|
|
18863
|
+
const { upcomingInvoice } = (0, import_react38.useMemo)(() => {
|
|
18711
18864
|
return {
|
|
18712
18865
|
upcomingInvoice: {
|
|
18713
18866
|
...typeof data.upcomingInvoice?.amountDue === "number" && {
|
|
@@ -18777,10 +18930,10 @@ var UpcomingBill = (0, import_react36.forwardRef)(({ className, ...rest }, ref)
|
|
|
18777
18930
|
UpcomingBill.displayName = "UpcomingBill";
|
|
18778
18931
|
|
|
18779
18932
|
// src/components/embed/ComponentTree.tsx
|
|
18780
|
-
var
|
|
18933
|
+
var import_react40 = require("react");
|
|
18781
18934
|
|
|
18782
18935
|
// src/components/embed/renderer.ts
|
|
18783
|
-
var
|
|
18936
|
+
var import_react39 = require("react");
|
|
18784
18937
|
var components = {
|
|
18785
18938
|
Root,
|
|
18786
18939
|
Viewport,
|
|
@@ -18812,7 +18965,7 @@ function createRenderer(options) {
|
|
|
18812
18965
|
const { className, ...rest } = props;
|
|
18813
18966
|
const resolvedProps = component === "div" ? rest : props;
|
|
18814
18967
|
const resolvedChildren = children.map(renderNode);
|
|
18815
|
-
return (0,
|
|
18968
|
+
return (0, import_react39.createElement)(
|
|
18816
18969
|
component,
|
|
18817
18970
|
{
|
|
18818
18971
|
key: index,
|
|
@@ -18881,8 +19034,8 @@ var Error2 = ({ message }) => {
|
|
|
18881
19034
|
};
|
|
18882
19035
|
var ComponentTree = () => {
|
|
18883
19036
|
const { error, nodes } = useEmbed();
|
|
18884
|
-
const [children, setChildren] = (0,
|
|
18885
|
-
(0,
|
|
19037
|
+
const [children, setChildren] = (0, import_react40.useState)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loading, {}));
|
|
19038
|
+
(0, import_react40.useEffect)(() => {
|
|
18886
19039
|
const renderer = createRenderer();
|
|
18887
19040
|
setChildren(nodes.map(renderer));
|
|
18888
19041
|
}, [nodes]);
|
|
@@ -18890,7 +19043,7 @@ var ComponentTree = () => {
|
|
|
18890
19043
|
console.error(error);
|
|
18891
19044
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Error2, { message: error.message });
|
|
18892
19045
|
}
|
|
18893
|
-
if (
|
|
19046
|
+
if (import_react40.Children.count(children) === 0) {
|
|
18894
19047
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loading, {});
|
|
18895
19048
|
}
|
|
18896
19049
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|