@bunnyapp/components 1.3.0-beta.3 → 1.3.0-beta.4

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.
Files changed (44) hide show
  1. package/dist/cjs/index.js +521 -600
  2. package/dist/cjs/src/components/BillingDetails/BillingDetails.d.ts +1 -1
  3. package/dist/cjs/src/components/PaymentForm/DemoPay/demoPayUtils.d.ts +2 -2
  4. package/dist/cjs/src/components/PaymentForm/PaymentForm.d.ts +3 -2
  5. package/dist/cjs/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -1
  6. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/priceListCard/priceListCardUtils.d.ts +2 -1
  7. package/dist/cjs/src/components/Subscriptions/SubscriptionRequests.d.ts +1 -0
  8. package/dist/cjs/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +0 -1
  9. package/dist/cjs/src/components/TaxationForm.d.ts +2 -2
  10. package/dist/cjs/src/components/UpgradeFromTrial.d.ts +6 -0
  11. package/dist/cjs/src/graphql/QuoteRequests.d.ts +0 -1
  12. package/dist/cjs/src/graphql/queries/getFeatureUsage.d.ts +4 -1
  13. package/dist/cjs/src/graphql/queries/getFormattedQuote.d.ts +4 -2
  14. package/dist/cjs/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -2
  15. package/dist/cjs/src/hooks/useCurrentUserData.d.ts +1 -10
  16. package/dist/cjs/src/hooks/usePaymentPlugins.d.ts +2 -2
  17. package/dist/cjs/src/mocks/handlers.d.ts +1 -1
  18. package/dist/esm/index.js +522 -601
  19. package/dist/esm/src/components/BillingDetails/BillingDetails.d.ts +1 -1
  20. package/dist/esm/src/components/PaymentForm/DemoPay/demoPayUtils.d.ts +2 -2
  21. package/dist/esm/src/components/PaymentForm/PaymentForm.d.ts +3 -2
  22. package/dist/esm/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -1
  23. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/priceListCard/priceListCardUtils.d.ts +2 -1
  24. package/dist/esm/src/components/Subscriptions/SubscriptionRequests.d.ts +1 -0
  25. package/dist/esm/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +0 -1
  26. package/dist/esm/src/components/TaxationForm.d.ts +2 -2
  27. package/dist/esm/src/components/UpgradeFromTrial.d.ts +6 -0
  28. package/dist/esm/src/graphql/QuoteRequests.d.ts +0 -1
  29. package/dist/esm/src/graphql/queries/getFeatureUsage.d.ts +4 -1
  30. package/dist/esm/src/graphql/queries/getFormattedQuote.d.ts +4 -2
  31. package/dist/esm/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -2
  32. package/dist/esm/src/hooks/useCurrentUserData.d.ts +1 -10
  33. package/dist/esm/src/hooks/usePaymentPlugins.d.ts +2 -2
  34. package/dist/esm/src/mocks/handlers.d.ts +1 -1
  35. package/dist/index.d.ts +4 -3
  36. package/package.json +1 -1
  37. package/dist/cjs/src/graphql/mutations/subscriptionTrialConvert.d.ts +0 -7
  38. package/dist/cjs/src/graphql/queries/getCurrentUserData.d.ts +0 -13
  39. package/dist/cjs/src/utils/couponUtils.d.ts +0 -2
  40. package/dist/esm/src/graphql/mutations/subscriptionTrialConvert.d.ts +0 -7
  41. package/dist/esm/src/graphql/queries/getCurrentUserData.d.ts +0 -13
  42. package/dist/esm/src/utils/couponUtils.d.ts +0 -2
  43. /package/dist/cjs/src/components/icons/{IDeal.d.ts → iDeal.d.ts} +0 -0
  44. /package/dist/esm/src/components/icons/{IDeal.d.ts → iDeal.d.ts} +0 -0
package/dist/cjs/index.js CHANGED
@@ -154,7 +154,7 @@ var BrandContext = react.createContext({
154
154
  });
155
155
 
156
156
  // This will be replaced at build time by rollup-plugin-replace
157
- var PACKAGE_VERSION = '1.3.0-beta.2';
157
+ var PACKAGE_VERSION = '1.0.76-beta.15';
158
158
  var createRequestHeaders = function (token) {
159
159
  var headers = common.createClientDevHeaders(token);
160
160
  // Add the components version header
@@ -430,7 +430,6 @@ var DocumentTemplatePreview = function (_a) {
430
430
  URL.revokeObjectURL(url_1);
431
431
  };
432
432
  }
433
- return undefined;
434
433
  }, [data]);
435
434
  if (isLoading) {
436
435
  return (jsxRuntime.jsx("div", __assign({ className: "flex items-center justify-center h-96" }, { children: jsxRuntime.jsx(antd.Spin, {}) })));
@@ -502,7 +501,6 @@ function LegacyDocument(_a) {
502
501
  setPdfUrl(url_1);
503
502
  return function () { return URL.revokeObjectURL(url_1); };
504
503
  }
505
- return undefined;
506
504
  }, [pdfBlob]);
507
505
  if (isLoading || !pdfUrl)
508
506
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
@@ -549,7 +547,7 @@ var checkout = function (_a) {
549
547
  });
550
548
  };
551
549
 
552
- var paymentMethodsQuery = function () { return "query PaymentMethods($accountId: ID) {\n paymentMethods (accountId: $accountId) {\n nodes {\n id\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n type\n }\n isDefault\n }\n }\n}"; };
550
+ var paymentMethodsQuery = function (filter) { return "query paymentMethods {\n paymentMethods ".concat(filter ? "(".concat(filter, ")") : '', " {\n nodes {\n id\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n type\n }\n isDefault\n }\n }\n}"); };
553
551
  var getPaymentMethods = function (_a) {
554
552
  var apiHost = _a.apiHost, token = _a.token, accountId = _a.accountId;
555
553
  return __awaiter(void 0, void 0, void 0, function () {
@@ -558,10 +556,9 @@ var getPaymentMethods = function (_a) {
558
556
  return __generator(this, function (_c) {
559
557
  switch (_c.label) {
560
558
  case 0: return [4 /*yield*/, gqlRequest({
561
- query: paymentMethodsQuery(),
559
+ query: paymentMethodsQuery(accountId ? "filter: \"accountId is ".concat(accountId, "\"") : ''),
562
560
  token: token,
563
561
  apiHost: apiHost,
564
- vars: { accountId: accountId },
565
562
  })];
566
563
  case 1:
567
564
  response = _c.sent();
@@ -589,11 +586,20 @@ var usePaymentMethod = function (_a) {
589
586
  };
590
587
 
591
588
  var filterPaymentPlugins = function (plugins) {
592
- return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) { var _a, _b; return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'payment' && ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'valid'; });
589
+ return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) { var _a, _b; return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'payment' && ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'valid'; }).filter(function (plugin) { return plugin.name !== 'Manual Payment'; });
590
+ };
591
+ var filterPaymentPluginsByEntity = function (plugins, selectedEntityId) {
592
+ return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
593
+ var _a, _b;
594
+ return selectedEntityId === undefined ||
595
+ selectedEntityId === null ||
596
+ ((_a = plugin.entities) === null || _a === void 0 ? void 0 : _a.includes(selectedEntityId)) ||
597
+ ((_b = plugin.entities) === null || _b === void 0 ? void 0 : _b.length) === 0;
598
+ });
593
599
  };
594
- var MUTATION$9 = "query PaymentPlugins($accountId: ID) {\n paymentPlugins (accountId: $accountId) {\n enabled\n entities\n guid\n hidden\n id\n name\n status\n type\n webhookEnabled\n components\n }\n}";
600
+ var MUTATION$9 = "{\n paymentPlugins {\n enabled\n entities\n guid\n hidden\n id\n name\n status\n type\n webhookEnabled\n components\n }\n}";
595
601
  var getPaymentPlugins = function (_a) {
596
- var apiHost = _a.apiHost, token = _a.token, accountId = _a.accountId;
602
+ var apiHost = _a.apiHost, token = _a.token;
597
603
  return __awaiter(void 0, void 0, void 0, function () {
598
604
  var response;
599
605
  return __generator(this, function (_b) {
@@ -604,7 +610,6 @@ var getPaymentPlugins = function (_a) {
604
610
  query: MUTATION$9,
605
611
  token: token,
606
612
  apiHost: apiHost,
607
- vars: { accountId: accountId },
608
613
  })];
609
614
  case 1:
610
615
  response = _b.sent();
@@ -618,15 +623,18 @@ var getPaymentPlugins = function (_a) {
618
623
  });
619
624
  };
620
625
  var usePaymentPlugins = function (_a) {
621
- var apiHost = _a.apiHost, token = _a.token, accountId = _a.accountId;
626
+ var apiHost = _a.apiHost, token = _a.token, selectedEntityId = _a.selectedEntityId;
622
627
  var _b = reactQuery.useQuery({
623
628
  queryKey: ['paymentPlugins', token],
624
- queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token, accountId: accountId }); },
629
+ queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token }); },
625
630
  staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
626
631
  }), paymentPlugins = _b.data, isFetched = _b.isFetched;
627
632
  var filteredPaymentPlugins = filterPaymentPlugins(paymentPlugins);
633
+ var filteredPaymentPluginsByEntity = selectedEntityId
634
+ ? filterPaymentPluginsByEntity(filteredPaymentPlugins, selectedEntityId)
635
+ : filteredPaymentPlugins;
628
636
  return {
629
- paymentPlugins: filteredPaymentPlugins,
637
+ paymentPlugins: filteredPaymentPluginsByEntity,
630
638
  isFetched: isFetched,
631
639
  };
632
640
  };
@@ -18605,13 +18613,13 @@ var isCardExpired = function (expiry) {
18605
18613
  var formatCardExpiry = function (cardExpiry) {
18606
18614
  if (cardExpiry.length <= 2)
18607
18615
  return cardExpiry;
18608
- return cardExpiry.substring(0, 2) + '/' + cardExpiry.substring(2);
18616
+ return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
18609
18617
  };
18610
18618
  // removes spaces from a credit card number
18611
18619
  var unformatCardNumber = function (cardNumber) {
18612
- var cardNumberArray = cardNumber.split('');
18613
- var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== ' '; });
18614
- return unformattedCardNumberArray.join('');
18620
+ var cardNumberArray = cardNumber.split("");
18621
+ var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
18622
+ return unformattedCardNumberArray.join("");
18615
18623
  };
18616
18624
  var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
18617
18625
  var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
@@ -18620,7 +18628,7 @@ var storePayment = function (options, plugin, apiHost, accountId) { return __awa
18620
18628
  case 0:
18621
18629
  testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
18622
18630
  return [4 /*yield*/, common.invokePlugin({
18623
- method: 'store_payment_method',
18631
+ method: "store_payment_method",
18624
18632
  plugin: plugin,
18625
18633
  payload: {
18626
18634
  test_credit_card_number: testCreditCardNumber,
@@ -18633,7 +18641,7 @@ var storePayment = function (options, plugin, apiHost, accountId) { return __awa
18633
18641
  })];
18634
18642
  case 1:
18635
18643
  response = _a.sent();
18636
- if ((response === null || response === void 0 ? void 0 : response.status) !== 'success')
18644
+ if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
18637
18645
  throw new Error(response === null || response === void 0 ? void 0 : response.message);
18638
18646
  return [2 /*return*/, response];
18639
18647
  }
@@ -18950,7 +18958,7 @@ var PaymentMethodDetails = function (_a) {
18950
18958
  case 'StripePayment':
18951
18959
  return (jsxRuntime.jsx(StripeForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
18952
18960
  case 'DemoPayPayment':
18953
- return (jsxRuntime.jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: function (response) { return onSavePaymentMethod(response); }, plugin: plugin }));
18961
+ return (jsxRuntime.jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
18954
18962
  default:
18955
18963
  console.warn('Can not find form for plugin', plugin);
18956
18964
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
@@ -19096,7 +19104,7 @@ function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId, o
19096
19104
  var showErrorNotification$2 = common.useErrorNotification();
19097
19105
  var PaymentForm = function (_a) {
19098
19106
  var _b;
19099
- var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, onPaymentHoldSuccess = _a.onPaymentHoldSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, onSetDefaultPaymentMethod = _a.onSetDefaultPaymentMethod, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, paymentHoldOptions = _a.paymentHoldOptions;
19107
+ var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, onPaymentHoldSuccess = _a.onPaymentHoldSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, onSetDefaultPaymentMethod = _a.onSetDefaultPaymentMethod, entityId = _a.entityId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, paymentHoldOptions = _a.paymentHoldOptions;
19100
19108
  // Local state
19101
19109
  var _c = react.useState(false), showPaymentMethodForm = _c[0], setShowPaymentMethodForm = _c[1];
19102
19110
  // Simple hooks
@@ -19110,7 +19118,7 @@ var PaymentForm = function (_a) {
19110
19118
  apiHost: apiHost,
19111
19119
  }), storedPaymentMethods = _d.paymentMethods, defaultPaymentMethod = _d.defaultPaymentMethod, isPaymentMethodLoading = _d.isLoading;
19112
19120
  // Complex hooks
19113
- var paymentPlugins = usePaymentPlugins({ apiHost: apiHost, token: token, accountId: accountId }).paymentPlugins;
19121
+ var paymentPlugins = usePaymentPlugins({ apiHost: apiHost, selectedEntityId: entityId, token: token }).paymentPlugins;
19114
19122
  var selectedPaymentMethodPlugin = react.useMemo(function () {
19115
19123
  // TODO: consolate PluginData and PaymentPlugin into one type. Needs to be done on API side.
19116
19124
  return paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
@@ -19168,14 +19176,14 @@ var PaymentForm = function (_a) {
19168
19176
  setShowPaymentMethodForm(false);
19169
19177
  onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess();
19170
19178
  };
19171
- var handleSavePaymentMethod = function (response) {
19179
+ var handleSavePaymentMethod = function () {
19172
19180
  queryClient.invalidateQueries({
19173
19181
  queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey({
19174
19182
  accountId: accountId,
19175
19183
  token: token,
19176
19184
  }),
19177
19185
  });
19178
- onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(response);
19186
+ onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
19179
19187
  setShowPaymentMethodForm(false);
19180
19188
  };
19181
19189
  function handleClickAddPaymentMethod() {
@@ -19217,6 +19225,15 @@ function StripeWrapper(_a) {
19217
19225
  return (jsxRuntime.jsx(reactStripeJs.Elements, __assign({ options: options, stripe: stripe }, { children: children })));
19218
19226
  }
19219
19227
 
19228
+ var useCurrentUserData = function () {
19229
+ var queryClient = reactQuery.useQueryClient();
19230
+ var token = useToken();
19231
+ var currentUser = queryClient.getQueryData(common.QueryKeyFactory.default.currentUserKey(token));
19232
+ if (!currentUser)
19233
+ return {};
19234
+ return currentUser;
19235
+ };
19236
+
19220
19237
  function Invoice(_a) {
19221
19238
  var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onInvoiceDownloadError = _a.onInvoiceDownloadError, onPaymentSuccess = _a.onPaymentSuccess, _b = _a.shadow, shadow = _b === void 0 ? 'shadow-md' : _b, className = _a.className, _c = _a.hideDownloadButton, hideDownloadButton = _c === void 0 ? false : _c, onInvoiceLoaded = _a.onInvoiceLoaded;
19222
19239
  return (jsxRuntime.jsx(InvoiceQuoteContext.Provider, __assign({ value: {
@@ -19239,6 +19256,7 @@ function ActualInvoice() {
19239
19256
  var _b = react.useContext(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired;
19240
19257
  var _c = react.useContext(InvoiceQuoteContext), hideDownloadButton = _c.hideDownloadButton, onInvoiceLoaded = _c.onInvoiceLoaded;
19241
19258
  var token = useToken();
19259
+ var entityId = useCurrentUserData().entityId;
19242
19260
  // Hooks
19243
19261
  var showSuccessNotification = common.useSuccessNotification();
19244
19262
  var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
@@ -19274,12 +19292,12 @@ function ActualInvoice() {
19274
19292
  }, [formattedInvoice]);
19275
19293
  if (!formattedInvoice)
19276
19294
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
19277
- return (jsxRuntime.jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsxRuntime.jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsxRuntime.jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
19295
+ return (jsxRuntime.jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsxRuntime.jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsxRuntime.jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
19278
19296
  }
19279
19297
 
19280
- var MUTATION$8 = function () { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n quote {\n documentTemplateId\n documents { id filename size date url }\n firstInvoice {\n id\n state\n }\n payableId\n id\n payToAccept\n currentPaymentHold {\n createdAt\n expiresAt\n id\n updatedAt\n paymentMethod {\n accountId\n createdAt\n expirationDate\n failureCode\n id\n isDefault\n lastSuccess\n paymentType\n pluginId\n state\n updatedAt\n metadata {\n description\n expiration\n icon\n identifier\n issuer\n kind\n }\n }\n }\n }\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
19298
+ var MUTATION$8 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n quote {\n documentTemplateId\n documents { id filename size date url }\n firstInvoice {\n id\n state\n }\n payableId\n id\n payToAccept\n currentPaymentHold {\n createdAt\n expiresAt\n id\n updatedAt\n paymentMethod {\n accountId\n createdAt\n expirationDate\n failureCode\n id\n isDefault\n lastSuccess\n paymentType\n pluginId\n state\n updatedAt\n metadata {\n description\n expiration\n icon\n identifier\n issuer\n kind\n }\n }\n }\n }\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
19281
19299
  var getFormattedQuote = function (_a) {
19282
- var token = _a.token, apiHost = _a.apiHost;
19300
+ var id = _a.id, token = _a.token, apiHost = _a.apiHost;
19283
19301
  return __awaiter(void 0, void 0, void 0, function () {
19284
19302
  var response;
19285
19303
  return __generator(this, function (_b) {
@@ -19288,11 +19306,12 @@ var getFormattedQuote = function (_a) {
19288
19306
  query: MUTATION$8(),
19289
19307
  token: token,
19290
19308
  apiHost: apiHost,
19309
+ vars: { id: id },
19291
19310
  })];
19292
19311
  case 1:
19293
19312
  response = _b.sent();
19294
- if (response.errors && response.errors.length > 0) {
19295
- throw new Error(response.errors[0].message);
19313
+ if (response === null || response === void 0 ? void 0 : response.formattedQuote.error) {
19314
+ throw new Error(response === null || response === void 0 ? void 0 : response.formattedQuote.error);
19296
19315
  }
19297
19316
  return [2 /*return*/, response === null || response === void 0 ? void 0 : response.formattedQuote];
19298
19317
  }
@@ -19587,9 +19606,10 @@ var PaymentHoldModal = function (_a) {
19587
19606
  var visible = _a.visible, setVisible = _a.setVisible, quote = _a.quote;
19588
19607
  var queryClient = reactQuery.useQueryClient();
19589
19608
  var token = useToken();
19609
+ var entityId = useCurrentUserData().entityId;
19590
19610
  return (jsxRuntime.jsxs(StyledModal$1, __assign({ centered: true, onCancel: function () {
19591
19611
  setVisible(false);
19592
- }, footer: null, open: visible, width: 600 }, { children: [jsxRuntime.jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsxRuntime.jsx("div", __assign({ className: "mb-4" }, { children: jsxRuntime.jsx(PaymentForm, { quote: {
19612
+ }, footer: null, open: visible, width: 600 }, { children: [jsxRuntime.jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsxRuntime.jsx("div", __assign({ className: "mb-4" }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, quote: {
19593
19613
  amount: quote.amount,
19594
19614
  currencyId: quote.currency,
19595
19615
  id: quote.quote.id,
@@ -19652,10 +19672,18 @@ function ActualQuote() {
19652
19672
  var _f = reactQuery.useQuery({
19653
19673
  queryKey: common.QueryKeyFactory.default.createQuoteKey({ id: id, token: token }),
19654
19674
  queryFn: function () { return __awaiter(_this, void 0, void 0, function () {
19675
+ var error_1;
19655
19676
  return __generator(this, function (_a) {
19656
19677
  switch (_a.label) {
19657
- case 0: return [4 /*yield*/, getFormattedQuote({ token: token, apiHost: apiHost })];
19678
+ case 0:
19679
+ _a.trys.push([0, 2, , 3]);
19680
+ return [4 /*yield*/, getFormattedQuote({ token: token, apiHost: apiHost, id: id })];
19658
19681
  case 1: return [2 /*return*/, _a.sent()];
19682
+ case 2:
19683
+ error_1 = _a.sent();
19684
+ showErrorNotification(error_1.message);
19685
+ return [3 /*break*/, 3];
19686
+ case 3: return [2 /*return*/];
19659
19687
  }
19660
19688
  });
19661
19689
  }); },
@@ -19670,6 +19698,7 @@ function ActualQuote() {
19670
19698
  }), acceptBoxVisible = _g.acceptBoxVisible, isAccepting = _g.isAccepting, sendAccept = _g.sendAccept, setAcceptBoxVisible = _g.setAcceptBoxVisible, setIsAccepting = _g.setIsAccepting, startAcceptance = _g.startAcceptance, pandadocPollingModalVisible = _g.pandadocPollingModalVisible, setPandadocPollingModalVisible = _g.setPandadocPollingModalVisible, isSendAcceptPending = _g.isSendAcceptPending;
19671
19699
  useSigningComplete({ data: formattedQuote, token: token });
19672
19700
  var isMobile = common.useIsMobile();
19701
+ var showErrorNotification = common.useErrorNotification();
19673
19702
  react.useEffect(function () {
19674
19703
  if (formattedQuote) {
19675
19704
  onQuoteLoaded === null || onQuoteLoaded === void 0 ? void 0 : onQuoteLoaded(formattedQuote);
@@ -19989,7 +20018,7 @@ function Transactions(_a) {
19989
20018
  function TransactionsDisplay(_a) {
19990
20019
  var _b, _c;
19991
20020
  var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search;
19992
- var _d = react.useContext(TransactionsListContext), showSearchBar = _d.showSearchBar, showTitle = _d.showTitle, title = _d.title, transactionComponent = _d.transactionComponent, useModal = _d.useModal, suppressTransactionDisplay = _d.suppressTransactionDisplay, className = _d.className, shadow = _d.shadow, searchBarClassName = _d.searchBarClassName, style = _d.style, onTransactionClick = _d.onTransactionClick, onTransactionDisplayClose = _d.onTransactionDisplayClose, kindsToShow = _d.kindsToShow, filterTransactions = _d.filterTransactions, sortTransactions = _d.sortTransactions;
20021
+ var _d = react.useContext(TransactionsListContext), showSearchBar = _d.showSearchBar, showTitle = _d.showTitle, title = _d.title, transactionComponent = _d.transactionComponent, useModal = _d.useModal, suppressTransactionDisplay = _d.suppressTransactionDisplay, className = _d.className, shadow = _d.shadow, searchBarClassName = _d.searchBarClassName, style = _d.style, onTransactionClick = _d.onTransactionClick, onTransactionDisplayClose = _d.onTransactionDisplayClose, kindsToShow = _d.kindsToShow, filterTransactions = _d.filterTransactions, sortTransactions = _d.sortTransactions; _d.transactionDateType;
19993
20022
  var columns = react.useContext(TransactionsListContext).columns;
19994
20023
  var darkMode = react.useContext(BunnyContext).darkMode;
19995
20024
  var secondaryColor = react.useContext(BrandContext).secondaryColor;
@@ -20283,7 +20312,7 @@ var getPriceList = function (_a) {
20283
20312
  });
20284
20313
  };
20285
20314
 
20286
- var QUOTE_QUERY = function (id) { return "\n query quote {\n quote ".concat(id ? "(id: ".concat(id, ")") : '', " {\n accountId\n amount\n amountDue\n smallUnitAmountDue\n currencyId\n formattedQuote {\n html\n }\n id\n payableId\n periodAmount\n subtotal\n taxAmount\n startDate\n amountsByPeriod {\n amount\n startDate\n }\n kind\n quoteChanges {\n currencyId\n id\n kind\n charges {\n subtotal\n amountsByPeriod {\n amount\n startDate\n }\n amount\n billingPeriod\n currencyId\n feature {\n unitName\n }\n id\n name\n priceListCharge {\n id\n }\n priceList {\n id\n }\n coupon {\n couponCode\n }\n quantity\n kind\n }\n priceList {\n id\n plan {\n name\n }\n product {\n name\n }\n }\n\n }\n }\n }"); };
20315
+ var QUOTE_QUERY = function (id) { return "\n query quote {\n quote ".concat(id ? "(id: ".concat(id, ")") : '', " {\n accountId\n amount\n amountDue\n smallUnitAmountDue\n currencyId\n formattedQuote {\n html\n }\n id\n payableId\n periodAmount\n subtotal\n taxAmount\n startDate\n amountsByPeriod {\n amount\n startDate\n }\n quoteChanges {\n currencyId\n id\n kind\n charges {\n subtotal\n amountsByPeriod {\n amount\n startDate\n }\n amount\n billingPeriod\n currencyId\n feature {\n unitName\n }\n id\n name\n priceListCharge {\n id\n }\n priceList {\n id\n }\n coupon {\n couponCode\n }\n quantity\n kind\n }\n priceList {\n id\n plan {\n name\n }\n product {\n name\n }\n }\n\n }\n }\n }"); };
20287
20316
  var getQuote = function (_a) {
20288
20317
  var id = _a.id, token = _a.token, apiHost = _a.apiHost;
20289
20318
  return __awaiter(void 0, void 0, void 0, function () {
@@ -20438,45 +20467,6 @@ var useUpdateCoupons = function (_a) {
20438
20467
  };
20439
20468
  };
20440
20469
 
20441
- var CURRENT_USER_DATA_QUERY = "{\n company {\n name\n }\n currentUser {\n account {\n billingCountry\n currencyId\n }\n authObjectName\n payload {\n returnUrl\n }\n privacyUrl\n termsUrl\n entityId\n }\n }";
20442
- var getCurrentUserData = function (_a) {
20443
- var token = _a.token, apiHost = _a.apiHost;
20444
- return __awaiter(void 0, void 0, void 0, function () {
20445
- var response;
20446
- var _b, _c, _d, _e, _f, _g, _h, _j;
20447
- return __generator(this, function (_k) {
20448
- switch (_k.label) {
20449
- case 0: return [4 /*yield*/, common.gqlRequest({
20450
- query: CURRENT_USER_DATA_QUERY,
20451
- token: token,
20452
- apiHost: apiHost,
20453
- })];
20454
- case 1:
20455
- response = _k.sent();
20456
- return [2 /*return*/, {
20457
- authObjectName: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.authObjectName,
20458
- account: (_c = response === null || response === void 0 ? void 0 : response.currentUser) === null || _c === void 0 ? void 0 : _c.account,
20459
- companyName: (_d = response === null || response === void 0 ? void 0 : response.company) === null || _d === void 0 ? void 0 : _d.name,
20460
- returnUrl: (_f = (_e = response === null || response === void 0 ? void 0 : response.currentUser) === null || _e === void 0 ? void 0 : _e.payload) === null || _f === void 0 ? void 0 : _f.returnUrl,
20461
- privacyUrl: (_g = response === null || response === void 0 ? void 0 : response.currentUser) === null || _g === void 0 ? void 0 : _g.privacyUrl,
20462
- termsUrl: (_h = response === null || response === void 0 ? void 0 : response.currentUser) === null || _h === void 0 ? void 0 : _h.termsUrl,
20463
- entityId: (_j = response === null || response === void 0 ? void 0 : response.currentUser) === null || _j === void 0 ? void 0 : _j.entityId,
20464
- }];
20465
- }
20466
- });
20467
- });
20468
- };
20469
-
20470
- var useCurrentUserData = function (token) {
20471
- var apiHost = react.useContext(BunnyContext).apiHost;
20472
- var currentUserData = reactQuery.useQuery({
20473
- queryKey: common.QueryKeyFactory.default.currentUserKey(token),
20474
- queryFn: function () { return getCurrentUserData({ token: token, apiHost: apiHost }); },
20475
- enabled: Boolean(token),
20476
- }).data;
20477
- return currentUserData || {};
20478
- };
20479
-
20480
20470
  var BunnyFooterIcon = function (_a) {
20481
20471
  var color = _a.color;
20482
20472
  return (jsxRuntime.jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M14.5898 7.19708C14.5898 9.35053 13.0926 10.325 11.2495 10.325C9.39955 10.325 7.90234 9.35001 7.90234 7.18967V3.26221H10.1125V7.00052C10.1125 7.87719 10.5855 8.27725 11.2495 8.27725C11.9061 8.27725 12.3865 7.87719 12.3865 7.00052V3.26221H14.5898V7.19708Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M31.8943 12.9625H29.4793L31.8523 8.62816L28.9355 3.26221H31.4708L33.0457 6.35524L34.5924 3.26221H37.0075L31.8943 12.9625Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M15.1602 5.96827C15.1602 3.8148 16.6574 2.84033 18.5005 2.84033C20.3504 2.84033 21.8476 3.81533 21.8476 5.97568V10.1473H19.6374V6.16483C19.6374 5.28815 19.1645 4.8881 18.5005 4.8881C17.8439 4.8881 17.3634 5.28815 17.3634 6.16483V10.1473H15.1602V5.96827Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M22.4316 5.96827C22.4316 3.8148 23.9289 2.84033 25.7719 2.84033C27.6219 2.84033 29.1191 3.81533 29.1191 5.97568V10.1473H26.9089V6.16483C26.9089 5.28815 26.4359 4.8881 25.7719 4.8881C25.1154 4.8881 24.6349 5.28815 24.6349 6.16483V10.1473H22.4316V5.96827Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M7.40511 6.68957C7.40511 8.7236 6.02815 10.3227 4.17816 10.3227C3.23907 10.3227 2.61071 9.94378 2.19358 9.40371V10.1404H0.0605469V0.0405273H2.26381V3.91939C2.68041 3.42158 3.28802 3.07069 4.17763 3.07069C6.02759 3.07069 7.40511 4.66981 7.40511 6.68957ZM2.17229 6.69642C2.17229 7.60802 2.77937 8.2744 3.64823 8.2744C4.53783 8.2744 5.13107 7.59372 5.13107 6.69642C5.13107 5.79912 4.53783 5.11844 3.64823 5.11844C2.77937 5.11844 2.17229 5.78482 2.17229 6.69642Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M38.966 8.94801C38.966 9.76181 38.2668 10.4631 37.4618 10.4631C36.6499 10.4631 35.9434 9.76181 35.9434 8.94801C35.9434 8.14846 36.6494 7.46094 37.4618 7.46094C38.2668 7.46094 38.966 8.14846 38.966 8.94801Z", fill: color })] })), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsxRuntime.jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
@@ -20485,8 +20475,7 @@ var BunnyFooterIcon = function (_a) {
20485
20475
  var Text$g = antd.Typography.Text;
20486
20476
  var Footer = function (_a) {
20487
20477
  var className = _a.className;
20488
- var token = useToken();
20489
- var _b = useCurrentUserData(token), privacyUrl = _b.privacyUrl, termsUrl = _b.termsUrl;
20478
+ var _b = useCurrentUserData(), privacyUrl = _b.privacyUrl, termsUrl = _b.termsUrl;
20490
20479
  var isMobile = common.useIsMobile();
20491
20480
  return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between bunny-shrink-0 ".concat(isMobile ? 'bunny-flex-col bunny-gap-2' : '', " ").concat(className) }, { children: [(termsUrl || privacyUrl) && (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-gap-3" }, { children: [termsUrl && (jsxRuntime.jsx(StyedLink, __assign({ className: "bunny-text-xs bunny-text-slate-400", href: termsUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Terms" }))), privacyUrl && (jsxRuntime.jsx(StyedLink, __assign({ className: "bunny-text-xs bunny-text-slate-400", href: privacyUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Privacy" })))] }))), jsxRuntime.jsx(BunnyMarketingLink, {})] })));
20492
20481
  };
@@ -20499,22 +20488,6 @@ var StyedLink = styled__default["default"].a(templateObject_1$5 || (templateObje
20499
20488
  var StyledBunnyLink = styled__default["default"](StyedLink)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), common.PRIMARY_COLOR);
20500
20489
  var templateObject_1$5, templateObject_2$1;
20501
20490
 
20502
- function shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) {
20503
- var _a;
20504
- var upgradingFromTrial = ((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL;
20505
- function upgradingFromFree() {
20506
- var totalPrice = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.charges.reduce(function (acc, charge) { return acc + Number((charge === null || charge === void 0 ? void 0 : charge.discountedPrice) || 0); }, 0);
20507
- return totalPrice === 0;
20508
- }
20509
- if (quote.kind === common.QuoteChangeKind.SUBSCRIBE) {
20510
- return activeCouponsExist;
20511
- }
20512
- else if (quote.kind === common.QuoteChangeKind.ADJUSTMENT) {
20513
- return activeCouponsExist && (upgradingFromTrial || upgradingFromFree());
20514
- }
20515
- return false;
20516
- }
20517
-
20518
20491
  function CouponEditor(_a) {
20519
20492
  var className = _a.className, onAddCoupon = _a.onAddCoupon, isAddingCoupon = _a.isAddingCoupon, couponCode = _a.couponCode, setCouponCode = _a.setCouponCode;
20520
20493
  function handleAddCoupon() {
@@ -20528,12 +20501,9 @@ function CouponEditor(_a) {
20528
20501
  return (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 ".concat(className) }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-row bunny-gap-2" }, { children: [jsxRuntime.jsx(antd.Input, { value: couponCode, onChange: function (e) { return setCouponCode(e.target.value); }, placeholder: "Coupon code", disabled: isAddingCoupon, size: "small" }), jsxRuntime.jsx(antd.Button, __assign({ loading: isAddingCoupon, type: "primary", onClick: handleAddCoupon, disabled: couponCode.length === 0 }, { children: "Apply" }))] })) })));
20529
20502
  }
20530
20503
 
20531
- var SubscriptionsContext = react.createContext({});
20532
-
20533
20504
  var Text$f = antd.Typography.Text;
20534
20505
  function CheckoutSummary(_a) {
20535
20506
  var quote = _a.quote, className = _a.className, onAddCoupon = _a.onAddCoupon, onRemoveCoupon = _a.onRemoveCoupon, isRemovingCoupon = _a.isRemovingCoupon, priceListData = _a.priceListData, isAddingCoupon = _a.isAddingCoupon, couponCode = _a.couponCode, setCouponCode = _a.setCouponCode, activeCouponsExist = _a.activeCouponsExist;
20536
- var upgradingSubscription = react.useContext(SubscriptionsContext).upgradingSubscription;
20537
20507
  return (jsxRuntime.jsxs("div", __assign({ className: "".concat(className, " bunny-space-y-4") }, { children: [jsxRuntime.jsxs(Text$f, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-text-lg bunny-font-medium bunny-mb-4" }, { children: ["Checkout summary - ", priceListData === null || priceListData === void 0 ? void 0 : priceListData.product.name, " ", priceListData === null || priceListData === void 0 ? void 0 : priceListData.name] })), jsxRuntime.jsx("div", __assign({ className: "bunny-space-y-4" }, { children: quote === null || quote === void 0 ? void 0 : quote.quoteChanges.map(function (quoteChange) {
20538
20508
  return quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.map(function (charge) {
20539
20509
  var _a;
@@ -20549,8 +20519,7 @@ function CheckoutSummary(_a) {
20549
20519
  onRemoveCoupon((_b = charge.coupon) === null || _b === void 0 ? void 0 : _b.couponCode);
20550
20520
  }, className: "bunny-text-orange-500 hover:bunny-text-orange-400 bunny-cursor-pointer" }, { children: "Remove" }))) : (jsxRuntime.jsx("div", { children: charge.quantity })) })), jsxRuntime.jsx("div", __assign({ className: "bunny-col-span-1 bunny-text-right" }, { children: common.formatCurrency(multiplier * (charge.subtotal || 0), charge.currencyId) }))] }), charge.id));
20551
20521
  });
20552
- }) })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-space-y-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Subtotal" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.subtotal, quote.currencyId) })] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Taxes" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.taxAmount, quote.currencyId) })] }))] })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Total" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.amountDue, quote.currencyId) })] }))] }), upgradingSubscription &&
20553
- shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) && (jsxRuntime.jsx(CouponEditor, { className: "bunny-w-full", quote: quote, onAddCoupon: onAddCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode }))] })));
20522
+ }) })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-space-y-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Subtotal" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.subtotal, quote.currencyId) })] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Taxes" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.taxAmount, quote.currencyId) })] }))] })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Total" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.amountDue, quote.currencyId) })] }))] }), activeCouponsExist && (jsxRuntime.jsx(CouponEditor, { className: "bunny-w-full", quote: quote, onAddCoupon: onAddCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode }))] })));
20554
20523
  }
20555
20524
  var CheckoutSummaryDivider = function () {
20556
20525
  return (jsxRuntime.jsx("div", __assign({ className: "bunny-my-2" }, { children: jsxRuntime.jsx(antd.Divider, { className: "m-0" }) })));
@@ -20559,7 +20528,8 @@ var CheckoutSummaryDivider = function () {
20559
20528
  var Title$1 = antd.Typography.Title;
20560
20529
  function PaymentForms(_a) {
20561
20530
  var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, defaultValues = _a.defaultValues;
20562
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsxRuntime.jsx("div", __assign({ className: "bunny-overflow-y-auto bunny-max-h-[calc(100vh-10rem)]" }, { children: jsxRuntime.jsx(PaymentForm, { onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction }) }))] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
20531
+ var entityId = useCurrentUserData().entityId;
20532
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsxRuntime.jsx("div", __assign({ className: "bunny-overflow-y-auto bunny-max-h-[calc(100vh-10rem)]" }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction }) }))] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
20563
20533
  }
20564
20534
  function InitialSignupForm(_a) {
20565
20535
  var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting, defaultValues = _a.defaultValues;
@@ -20870,22 +20840,8 @@ var useQuoteDelete = function () {
20870
20840
  });
20871
20841
  }); };
20872
20842
  };
20873
- var useQuoteSubscriptionActivate = function () {
20874
- var graphQLRequest = useGraphQLRequest();
20875
- return function (subscriptionId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
20876
- var response;
20877
- return __generator(this, function (_a) {
20878
- switch (_a.label) {
20879
- case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteSubscriptionActivate($subscriptionId: ID!) {\n quoteSubscriptionActivate(subscriptionId: $subscriptionId) {\n quote {\n id\n }\n }\n }", apiHost, token, { subscriptionId: subscriptionId })];
20880
- case 1:
20881
- response = _a.sent();
20882
- return [2 /*return*/, response];
20883
- }
20884
- });
20885
- }); };
20886
- };
20887
20843
 
20888
- var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList { id periodMonths }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n daysLeftInTrial\n trialExpirationAction\n charges {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n featureAddon\n id\n }\n amount\n billingPeriod\n chargeType\n discount\n discountedPrice\n endDate\n expired\n feature { name }\n id\n isAmendment\n isRamp\n kind\n name\n periodPrice\n price\n priceDecimals\n priceListChargeId\n priceTiers { starts price }\n pricingModel\n quantity\n selfServiceQuantity\n startDate\n trial\n }\n }\n }\n }";
20844
+ var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList { id periodMonths }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n daysLeftInTrial\n charges {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n featureAddon\n id\n }\n amount\n billingPeriod\n chargeType\n discount\n discountedPrice\n endDate\n expired\n feature { name }\n id\n isAmendment\n isRamp\n kind\n name\n periodPrice\n price\n priceDecimals\n priceListChargeId\n priceTiers { starts price }\n pricingModel\n quantity\n selfServiceQuantity\n startDate\n trial\n }\n }\n }\n }";
20889
20845
  var getSubscriptions = function (_a) {
20890
20846
  var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
20891
20847
  return __awaiter(void 0, void 0, void 0, function () {
@@ -20971,7 +20927,7 @@ var accountUpdate = function (_a) {
20971
20927
  });
20972
20928
  };
20973
20929
 
20974
- var COUNTRIES_REQUIRING_STATE = ['US', 'CA'];
20930
+ var COUNTRIES_REQUIRING_STATE = ["US", "CA"];
20975
20931
  var TaxationForm = function (_a) {
20976
20932
  var account = _a.account, quote = _a.quote;
20977
20933
  // Hooks
@@ -20999,18 +20955,19 @@ var TaxationForm = function (_a) {
20999
20955
  }); },
21000
20956
  onSuccess: function () {
21001
20957
  queryClient.invalidateQueries({
21002
- queryKey: ['getTaxationRequiredAccountFields', token],
20958
+ queryKey: ["getTaxationRequiredAccountFields", token],
21003
20959
  });
21004
20960
  },
21005
20961
  }), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
21006
- return (jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Street" }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "City" }) })), jsxRuntime.jsx(FormBillingState, {}), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsxRuntime.jsx(antd.Select, { options: common.Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
20962
+ return (jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Street" }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "City" }) })), jsxRuntime.jsx(FormBillingState, { form: form }), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsxRuntime.jsx(antd.Select, { options: common.Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
21007
20963
  var _a, _b;
21008
- return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(input.toLowerCase()) ||
21009
- ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase());
20964
+ return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
20965
+ ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "").toLowerCase().includes(input.toLowerCase());
21010
20966
  } }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing zip", name: "billingZip" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Zip" }) })), jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "bunny-w-full", disabled: isUpdatingAccount, htmlType: "submit", type: "primary" }, { children: "Submit" })) })] })));
21011
20967
  };
21012
- var FormBillingState = function () {
21013
- var billingCountry = antd.Form.useWatch('billingCountry');
20968
+ var FormBillingState = function (_a) {
20969
+ _a.form;
20970
+ var billingCountry = antd.Form.useWatch("billingCountry");
21014
20971
  var billingStateRequired = COUNTRIES_REQUIRING_STATE.includes(billingCountry);
21015
20972
  return (jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing state", name: "billingState", rules: [{ required: billingStateRequired }] }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "State" }) })));
21016
20973
  };
@@ -21020,11 +20977,11 @@ var QuoteCheckout = function (_a) {
21020
20977
  var _b, _c;
21021
20978
  var account = _a.account, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, taxationRequiredAccountFields = _a.taxationRequiredAccountFields, onRecalculateTaxes = _a.onRecalculateTaxes;
21022
20979
  var apiHost = react.useContext(BunnyContext).apiHost;
21023
- var upgradingSubscription = react.useContext(SubscriptionsContext).upgradingSubscription;
21024
20980
  var token = useToken();
21025
20981
  var isMobile = common.useIsMobile();
21026
20982
  var _d = react.useState(false), isSaving = _d[0], setIsSaving = _d[1];
21027
20983
  var paymentRequired = getQuoteAmountDue(quote) > 0;
20984
+ var entityId = useCurrentUserData().entityId;
21028
20985
  var queryClient = reactQuery.useQueryClient();
21029
20986
  var _e = react.useState(''), couponCode = _e[0], setCouponCode = _e[1];
21030
20987
  var _f = useUpdateCoupons({
@@ -21085,8 +21042,7 @@ var QuoteCheckout = function (_a) {
21085
21042
  }
21086
21043
  if (taxationRequiredAccountFields)
21087
21044
  return (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsx(TaxationForm, { account: account, quote: quote }) })));
21088
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-w-full" }, { children: [jsxRuntime.jsx(PaymentForm, { onFail: onFail, onPaymentSuccess: onSuccess, quote: quote }), (couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.length) === 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: upgradingSubscription &&
21089
- shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) && (jsxRuntime.jsx(CouponEditor, { className: "bunny-px-4 bunny-pt-1", quote: quote, onAddCoupon: addCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode })) })) : (jsxRuntime.jsx(antd.Button, __assign({ type: "link", loading: isRemovingCoupon, onClick: function () {
21045
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-w-full" }, { children: [jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: onSuccess, quote: quote }), (couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.length) === 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: activeCouponsExist && (jsxRuntime.jsx(CouponEditor, { className: "bunny-px-4 bunny-pt-1", quote: quote, onAddCoupon: addCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode })) })) : (jsxRuntime.jsx(antd.Button, __assign({ type: "link", loading: isRemovingCoupon, onClick: function () {
21090
21046
  couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.forEach(function (couponCharge) {
21091
21047
  var _a;
21092
21048
  var couponCode = (_a = couponCharge === null || couponCharge === void 0 ? void 0 : couponCharge.coupon) === null || _a === void 0 ? void 0 : _a.couponCode;
@@ -21235,6 +21191,8 @@ var PageTitle = function (_a) {
21235
21191
  } })), title] })));
21236
21192
  };
21237
21193
 
21194
+ var SubscriptionsContext = react.createContext({});
21195
+
21238
21196
  var QUOTE_CHARGE_UPDATE = "\n mutation QuoteChargeUpdate (\n $discount: Float,\n $endDate: ISO8601Date,\n $name: String,\n $price: Float,\n $quantity: Int,\n $quoteChargeId: ID!\n $startDate: ISO8601Date\n $subtotal: Float,\n ) {\n quoteChargeUpdate(\n discount: $discount\n endDate: $endDate\n name: $name\n price: $price\n quantity: $quantity\n quoteChargeId: $quoteChargeId\n startDate: $startDate\n subtotal: $subtotal\n ) {\n quoteCharge {\n id\n }\n }\n }\n";
21239
21197
  var quoteChargeUpdate = function (_a) {
21240
21198
  var discount = _a.discount, name = _a.name, price = _a.price, quantity = _a.quantity, quoteChargeId = _a.quoteChargeId, startDate = _a.startDate, subtotal = _a.subtotal, apiHost = _a.apiHost, token = _a.token;
@@ -21326,112 +21284,10 @@ var billingPeriodConverter = function (period) {
21326
21284
  return 12;
21327
21285
  };
21328
21286
 
21329
- var canShowQuantitiesInput = function (charge, subscription) {
21330
- // Check if the subscription is active, pending, or in trial,
21331
- // the pricing model is not flat,
21332
- // and if it's not a trial, also check if the current charge is the last one in the subscription.
21333
- var _a, _b, _c;
21334
- var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE;
21335
- var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
21336
- var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL;
21337
- var isFlatPricing = charge.pricingModel === 'FLAT';
21338
- var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
21339
- !isFlatPricing &&
21340
- charge.selfServiceQuantity &&
21341
- !charge.expired;
21342
- // Now you can use the value of shouldProcessCharge to determine whether to process the charge.
21343
- return shouldProcessCharge;
21344
- };
21345
- var createQuoteParams = function (quote, subscriptionQuantity, editedSubscription) {
21346
- var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
21347
- var quoteChangeCharge = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) { return charge.priceListCharge.id === editedSubscription.chargeId; });
21348
- var charges = [
21349
- {
21350
- id: quoteChangeCharge.id,
21351
- quantity: editedSubscription.quantity - subscriptionQuantity,
21352
- },
21353
- ];
21354
- return { charges: charges, quoteChange: quoteChange };
21355
- };
21356
- var canShowChangeQuantities = function (_a) {
21357
- var subscriptions = _a.subscriptions;
21358
- return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
21359
- return subscription.charges.some(function (charge) {
21360
- return canShowQuantitiesInput(charge, subscription);
21361
- });
21362
- });
21363
- };
21364
- var canSubscriptionUpgradeFromTrial = function (subscription) {
21365
- var _a;
21366
- return (((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL &&
21367
- subscription.plan.selfServiceBuy) ||
21368
- false;
21369
- };
21370
- var isSubscriptionNotActive = function (subscription) {
21371
- var _a, _b;
21372
- return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
21373
- ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.CANCELED;
21374
- };
21375
- var isSubscriptionActiveOrPending = function (subscription) {
21376
- var _a, _b;
21377
- return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE ||
21378
- ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
21379
- };
21380
- var isSubscriptionTrial = function (subscription) { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL; };
21381
- // Helper function to check if charge is a discount
21382
- var isDiscount = function (kind) {
21383
- return kind === common.QuoteChangeKind.DISCOUNT || kind === common.QuoteChangeKind.FREE_PERIOD_DISCOUNT;
21384
- };
21385
- var hasPriceTiers = function (charge) {
21386
- var _a;
21387
- return Boolean((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length);
21388
- };
21389
- var hasMultiplePriceTiers = function (charge) {
21390
- var _a;
21391
- return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length) > 1;
21392
- };
21393
- var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
21394
- var _a;
21395
- if (!((_a = charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length))
21396
- return '';
21397
- var selectedTier;
21398
- // For TIERED pricing model: always show the first tier
21399
- if (charge.pricingModel === common.PricingModel.TIERED) {
21400
- selectedTier = charge.priceTiers[0];
21401
- }
21402
- // For VOLUME and BANDS pricing models: find the tier that contains the current quantity
21403
- else if (charge.pricingModel === common.PricingModel.VOLUME ||
21404
- charge.pricingModel === common.PricingModel.BANDS) {
21405
- // Find the appropriate tier based on quantity
21406
- selectedTier = charge.priceTiers.find(function (tier, index) {
21407
- var nextTier = charge.priceTiers[index + 1];
21408
- var tierStart = tier.starts;
21409
- var tierEnd = nextTier ? nextTier.starts - 1 : Infinity;
21410
- return charge.quantity >= tierStart && charge.quantity <= tierEnd;
21411
- });
21412
- // Fallback to first tier if no tier found (shouldn't happen with proper data)
21413
- selectedTier = selectedTier || charge.priceTiers[0];
21414
- }
21415
- // Default fallback for any other pricing models
21416
- else {
21417
- selectedTier = charge.priceTiers[0];
21418
- }
21419
- if (!selectedTier)
21420
- return '';
21421
- // Calculate the tier range for display
21422
- var tierIndex = charge.priceTiers.indexOf(selectedTier);
21423
- var starts = selectedTier.starts;
21424
- var nextTier = charge.priceTiers[tierIndex + 1];
21425
- var ends = nextTier ? nextTier.starts - 1 : '∞';
21426
- return hasMultiplePriceTiers(charge)
21427
- ? "".concat(starts, "-").concat(ends, ": ").concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals))
21428
- : "".concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals));
21429
- };
21430
-
21431
21287
  var removeHTMLTagsRegex = /<br>(?=(?:\s*<[^>]*>)*$)|(<br>)|<[^>]*>/gi;
21432
21288
  // Description is a string that can contain HTML tags. We want to remove all HTML tags except <br> tags.
21433
21289
  var createPlanDescription = function (priceList) {
21434
- return (priceList.plan.description || '').replace(removeHTMLTagsRegex, function (_, y) {
21290
+ return (priceList.plan.description || '').replace(removeHTMLTagsRegex, function (x, y) {
21435
21291
  return y ? ' & ' : '';
21436
21292
  });
21437
21293
  };
@@ -21473,17 +21329,25 @@ var getActivePlanPriceData = function (priceList, selectedPriceList) {
21473
21329
  };
21474
21330
  };
21475
21331
  var isPriceListDisabled = function (_a) {
21476
- var priceList = _a.priceList, upgradingSubscription = _a.upgradingSubscription, canPurchaseFeatureAddons = _a.canPurchaseFeatureAddons;
21477
- var existingSubscriptionInTrial = upgradingSubscription && canSubscriptionUpgradeFromTrial(upgradingSubscription);
21478
- var isUpgradingSubscriptionPriceList = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === priceList.id;
21479
- // When should priceList be disabled?
21480
- // if upgradingSubscription?.priceList.id === priceList.id
21481
- // AND the upgradingSubscription is not in trial
21482
- // AND cannot purchase feature addons
21483
- // AND cannot purchase add-on plans
21484
- // AND selfServiceBuy is false
21485
- if (isUpgradingSubscriptionPriceList) {
21486
- return !existingSubscriptionInTrial && !canPurchaseFeatureAddons;
21332
+ var priceList = _a.priceList, subscriptions = _a.subscriptions, upgradingSubscription = _a.upgradingSubscription, canPurchaseFeatureAddons = _a.canPurchaseFeatureAddons;
21333
+ // Plan already has a subscription
21334
+ var existingSubscription = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.find(function (subscription) {
21335
+ var _a, _b;
21336
+ var isCurrentUpgradingSubscription = subscription.id === (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id);
21337
+ var subscriptionAlreadyExists = isCurrentUpgradingSubscription
21338
+ ? subscription.priceList.id === priceList.id
21339
+ : subscription.plan.id === priceList.plan.id;
21340
+ return (subscriptionAlreadyExists &&
21341
+ subscription.plan.id === priceList.plan.id &&
21342
+ ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== common.SubscriptionState.CANCELED &&
21343
+ ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) !== common.SubscriptionState.EXPIRED);
21344
+ });
21345
+ var isUpgradingPriceList = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === priceList.id;
21346
+ if (existingSubscription) {
21347
+ return true;
21348
+ }
21349
+ if (isUpgradingPriceList && !canPurchaseFeatureAddons) {
21350
+ return true;
21487
21351
  }
21488
21352
  return false;
21489
21353
  };
@@ -21512,13 +21376,11 @@ var CheckoutBarSummarySection = function (_a) {
21512
21376
  // Context
21513
21377
  var apiHost = react.useContext(BunnyContext).apiHost;
21514
21378
  var quotePreviewData = react.useContext(QuotePreviewContext).quotePreviewData;
21515
- var accountId = react.useContext(PaymentContext).accountId;
21516
21379
  // Hooks
21517
21380
  var token = useToken();
21518
21381
  var paymentPlugins = usePaymentPlugins({
21519
21382
  apiHost: apiHost,
21520
21383
  token: token,
21521
- accountId: accountId,
21522
21384
  }).paymentPlugins;
21523
21385
  var queryClient = reactQuery.useQueryClient();
21524
21386
  var isMobile = common.useIsMobile();
@@ -21571,32 +21433,31 @@ var PlanPickerCheckoutBar = function (_a) {
21571
21433
  }).defaultPaymentMethod;
21572
21434
  var createSubscriptionUpgradeQuote = useQuoteSubscriptionUpgrade();
21573
21435
  var createSubscriptionUpdateQuote = useCreateSubscriptionQuote();
21574
- var quoteSubscriptionActivate = useQuoteSubscriptionActivate();
21575
21436
  // Mutations
21576
21437
  var createQuote = reactQuery.useMutation({
21577
21438
  mutationFn: function (_a) {
21578
21439
  var subscriptionId = _a.subscriptionId, priceListId = _a.priceListId;
21579
21440
  return createSubscriptionUpgradeQuote(subscriptionId, priceListId, apiHost, token);
21580
21441
  },
21581
- onSuccess: function (response) {
21442
+ onSuccess: function (subscriptionUpdateData) {
21582
21443
  var _a;
21583
- var quote = (_a = response === null || response === void 0 ? void 0 : response.quoteSubscriptionUpgrade) === null || _a === void 0 ? void 0 : _a.quote;
21444
+ var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpgrade) === null || _a === void 0 ? void 0 : _a.quote;
21584
21445
  setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
21585
21446
  handleSetEditingQuote(quote.id);
21586
21447
  },
21587
- }).mutate;
21448
+ });
21588
21449
  var createEmptyQuote = reactQuery.useMutation({
21589
21450
  mutationFn: function (_a) {
21590
21451
  var subscriptionId = _a.subscriptionId;
21591
21452
  return createSubscriptionUpdateQuote([subscriptionId], apiHost, token);
21592
21453
  },
21593
- onSuccess: function (response) {
21454
+ onSuccess: function (subscriptionUpdateData) {
21594
21455
  var _a;
21595
- var quote = (_a = response === null || response === void 0 ? void 0 : response.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
21456
+ var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
21596
21457
  setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
21597
21458
  handleSetEditingQuote(quote.id);
21598
21459
  },
21599
- }).mutate;
21460
+ });
21600
21461
  var updateCharge = reactQuery.useMutation({
21601
21462
  mutationFn: quoteChargeUpdate,
21602
21463
  onSuccess: function () {
@@ -21609,32 +21470,6 @@ var PlanPickerCheckoutBar = function (_a) {
21609
21470
  });
21610
21471
  },
21611
21472
  }).mutate;
21612
- var subscriptionActivate = reactQuery.useMutation({
21613
- mutationFn: function (_a) {
21614
- var subscriptionId = _a.subscriptionId;
21615
- return __awaiter(void 0, void 0, void 0, function () {
21616
- return __generator(this, function (_b) {
21617
- switch (_b.label) {
21618
- case 0: return [4 /*yield*/, quoteSubscriptionActivate(subscriptionId, apiHost, token)];
21619
- case 1: return [2 /*return*/, _b.sent()];
21620
- }
21621
- });
21622
- });
21623
- },
21624
- onSuccess: function (response) {
21625
- var _a;
21626
- var quote = (_a = response === null || response === void 0 ? void 0 : response.quoteSubscriptionActivate) === null || _a === void 0 ? void 0 : _a.quote;
21627
- setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
21628
- handleSetEditingQuote(quote.id);
21629
- queryClient.invalidateQueries({
21630
- queryKey: common.QueryKeyFactory.default.createObjectKey({
21631
- objectName: 'editingQuote',
21632
- id: editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id,
21633
- token: token,
21634
- }),
21635
- });
21636
- },
21637
- }).mutate;
21638
21473
  // Queries
21639
21474
  var quote = reactQuery.useQuery({
21640
21475
  queryKey: common.QueryKeyFactory.default.createObjectKey({
@@ -21664,26 +21499,18 @@ var PlanPickerCheckoutBar = function (_a) {
21664
21499
  enabled: Boolean(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id),
21665
21500
  }).data;
21666
21501
  react.useEffect(function () {
21667
- var _a;
21668
21502
  if (!(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id)) {
21669
21503
  console.error('upgradingSubscription is undefined');
21670
21504
  return;
21671
21505
  }
21672
21506
  var upgradingCurrentSubscription = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id);
21673
21507
  if (upgradingCurrentSubscription) {
21674
- if (((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL) {
21675
- subscriptionActivate({
21676
- subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
21677
- });
21678
- }
21679
- else {
21680
- createEmptyQuote({
21681
- subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
21682
- });
21683
- }
21508
+ createEmptyQuote.mutate({
21509
+ subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
21510
+ });
21684
21511
  }
21685
21512
  else {
21686
- createQuote({
21513
+ createQuote.mutate({
21687
21514
  subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
21688
21515
  priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
21689
21516
  });
@@ -21758,7 +21585,7 @@ var PlanPickerCheckoutBar = function (_a) {
21758
21585
  // WARNING: There is a preview button on APP that will need to be changed if this query is changed
21759
21586
  var PRICE_LIST_CHANGE_OPTIONS_QUERY = "\n query priceListChangeOptions($subscriptionId: ID, $productId: ID) {\n priceListChangeOptions(subscriptionId: $subscriptionId, productId: $productId) {\n products {\n everythingInPlus\n id\n name\n plansToDisplay\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n priceLists {\n showPriceAsMonthly\n basePrice\n currencyId\n id\n monthlyBasePrice\n periodMonths\n plan {\n code\n contactUsLabel\n contactUsUrl\n description\n id\n name\n position\n pricingDescription\n pricingStyle\n planFeatures {\n featureId\n value\n feature {\n name\n }\n }\n }\n product {\n id\n }\n charges {\n featureAddon\n basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n priceList {\n id\n }\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
21760
21587
  var getPriceListChangeOptions = function (_a) {
21761
- var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription, accountCurrencyId = _a.accountCurrencyId;
21588
+ var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription;
21762
21589
  return __awaiter(void 0, void 0, void 0, function () {
21763
21590
  var response, priceListChangeOptions;
21764
21591
  return __generator(this, function (_b) {
@@ -21779,8 +21606,6 @@ var getPriceListChangeOptions = function (_a) {
21779
21606
  if (priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) {
21780
21607
  priceListChangeOptions.priceLists.sort(function (a, b) { return a.plan.position - b.plan.position; });
21781
21608
  }
21782
- // Filter out price lists that don't have the same currency as the account
21783
- priceListChangeOptions.priceLists = priceListChangeOptions.priceLists.filter(function (priceList) { return priceList.currencyId === accountCurrencyId; });
21784
21609
  return [2 /*return*/, priceListChangeOptions];
21785
21610
  }
21786
21611
  });
@@ -21912,10 +21737,7 @@ var PriceListCardButton = function (_a) {
21912
21737
  subscriptionPlan &&
21913
21738
  priceListHasUnpurchasedFeatureAddons(priceList, upgradingSubscription);
21914
21739
  var isPriceListNonSubscribedCurrentPlan = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.plan.id) === priceList.plan.id && !isPriceListCurrentSubscription;
21915
- var canUpgradeFromTrial = upgradingSubscription && canSubscriptionUpgradeFromTrial(upgradingSubscription);
21916
21740
  var createButtonText = function () {
21917
- if (isPriceListCurrentSubscription && canUpgradeFromTrial)
21918
- return 'Upgrade from trial';
21919
21741
  if (isPriceListCurrentSubscription)
21920
21742
  return 'Current';
21921
21743
  if (isSelected)
@@ -22069,6 +21891,7 @@ var PriceListCard = function (_a) {
22069
21891
  var canPurchaseFeatureAddons = priceListHasUnpurchasedFeatureAddons(priceList, upgradingSubscription);
22070
21892
  var disableOnClick = isPriceListDisabled({
22071
21893
  priceList: priceList,
21894
+ subscriptions: subscriptions,
22072
21895
  upgradingSubscription: upgradingSubscription,
22073
21896
  canPurchaseFeatureAddons: canPurchaseFeatureAddons,
22074
21897
  });
@@ -22365,14 +22188,14 @@ var FeatureTitle = function (_a) {
22365
22188
 
22366
22189
  var PriceListGridDesktop = function (_a) {
22367
22190
  var availablePriceLists = _a.availablePriceLists, onChangePriceList = _a.onChangePriceList, priceListChangeOptions = _a.priceListChangeOptions, priceListStart = _a.priceListStart, selectedPriceList = _a.selectedPriceList, selectedProduct = _a.selectedProduct, setPriceListStart = _a.setPriceListStart, subscriptions = _a.subscriptions, trialRemainingDays = _a.trialRemainingDays;
22368
- var displayPriceLists = react.useMemo(function () {
22191
+ var _b = react.useMemo(function () {
22369
22192
  return getAvailablePlansAndPriceLists({
22370
22193
  availablePriceLists: availablePriceLists,
22371
22194
  priceListChangeOptions: priceListChangeOptions,
22372
22195
  priceListStart: priceListStart,
22373
22196
  plansToDisplay: (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3,
22374
22197
  });
22375
- }, [availablePriceLists, priceListChangeOptions, priceListStart]).displayPriceLists;
22198
+ }, [availablePriceLists, priceListChangeOptions, priceListStart]); _b.availablePriceListsArray; var displayPriceLists = _b.displayPriceLists;
22376
22199
  var everythingInPlus = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus;
22377
22200
  var plansToDisplay = Math.min((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3, availablePriceLists.length);
22378
22201
  var hasFeatureAddons = displayPriceLists.some(function (priceList) {
@@ -22387,7 +22210,7 @@ var PriceListGridDesktop = function (_a) {
22387
22210
  var doesPrevPriceListExist = displayPriceLists[index - 1];
22388
22211
  if (!priceList)
22389
22212
  return jsxRuntime.jsx(PlanPickerGridCell, { noBorder: !Boolean(doesPrevPriceListExist) }, index);
22390
- return (jsxRuntime.jsx(PriceListCard, { isSelected: priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), onClick: onChangePriceList, priceList: priceList, subscriptions: subscriptions, trialRemainingDays: trialRemainingDays }, index));
22213
+ return (jsxRuntime.jsx(PriceListCard, { isSelected: priceList.plan.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.plan.id), onClick: onChangePriceList, priceList: priceList, subscriptions: subscriptions, trialRemainingDays: trialRemainingDays }, index));
22391
22214
  }), (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus) ? (jsxRuntime.jsx(EverythingPlanFeatures, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(PlanFeatures, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct }), hasFeatureAddons && (jsxRuntime.jsx(PlanFeatureAddons, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay }))] }))] }))] })));
22392
22215
  };
22393
22216
 
@@ -22461,6 +22284,7 @@ var PriceListSelector = function (_a) {
22461
22284
  priceList.plan.id === ((_a = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList) === null || _a === void 0 ? void 0 : _a.plan.id) &&
22462
22285
  !isPriceListDisabled({
22463
22286
  priceList: priceList,
22287
+ subscriptions: subscriptions,
22464
22288
  upgradingSubscription: upgradingSubscription,
22465
22289
  canPurchaseFeatureAddons: priceListHasUnpurchasedFeatureAddons(quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList, upgradingSubscription),
22466
22290
  });
@@ -22478,7 +22302,13 @@ var PriceListSelector = function (_a) {
22478
22302
  });
22479
22303
  }
22480
22304
  }
22481
- }, [quotePreviewData, priceListChangeOptions, upgradingSubscription, setQuotePreviewData]);
22305
+ }, [
22306
+ quotePreviewData,
22307
+ priceListChangeOptions,
22308
+ subscriptions,
22309
+ upgradingSubscription,
22310
+ setQuotePreviewData,
22311
+ ]);
22482
22312
  var onChangeProduct = react.useCallback(function (product) {
22483
22313
  var newAvailableBillingPeriods = createAvailableBillingPeriods(priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists, product);
22484
22314
  if (!(newAvailableBillingPeriods === null || newAvailableBillingPeriods === void 0 ? void 0 : newAvailableBillingPeriods.includes(billingPeriodConverter(selectedBillingPeriod)))) {
@@ -22523,6 +22353,7 @@ var PriceListSelector = function (_a) {
22523
22353
  !isInPreviewMode &&
22524
22354
  !isPriceListDisabled({
22525
22355
  priceList: initialPriceList,
22356
+ subscriptions: subscriptions,
22526
22357
  upgradingSubscription: upgradingSubscription,
22527
22358
  canPurchaseFeatureAddons: priceListHasUnpurchasedFeatureAddons(initialPriceList, upgradingSubscription),
22528
22359
  })) {
@@ -22540,6 +22371,7 @@ var PriceListSelector = function (_a) {
22540
22371
  selectedPriceList,
22541
22372
  selectedProduct,
22542
22373
  setQuotePreviewData,
22374
+ subscriptions,
22543
22375
  upgradingSubscription,
22544
22376
  ]);
22545
22377
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(BillingPeriodSelector, { availableBillingPeriods: availableBillingPeriods, onChangeBillingPeriod: onChangeBillingPeriod, products: priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.products, selectedBillingPeriod: selectedBillingPeriod, selectedProduct: selectedProduct, onChangeProduct: onChangeProduct }), jsxRuntime.jsx(PriceListGrid, { availablePriceLists: availablePriceLists, onChangePriceList: onChangePriceList, priceListChangeOptions: priceListChangeOptions, priceListStart: priceListStart, selectedPriceList: selectedPriceList, selectedProduct: selectedProduct, setPriceListStart: setPriceListStart, subscriptions: subscriptions, upgradingSubscriptionState: upgradingSubscription })] }));
@@ -22552,7 +22384,6 @@ var PlanPicker = function () {
22552
22384
  var apiHost = react.useContext(BunnyContext).apiHost;
22553
22385
  var _b = react.useContext(SubscriptionsContext), isInPreviewMode = _b.isInPreviewMode, productId = _b.productId, upgradingSubscription = _b.upgradingSubscription;
22554
22386
  var _c = react.useContext(QuotePreviewContext), quotePreviewData = _c.quotePreviewData, setQuotePreviewData = _c.setQuotePreviewData;
22555
- var account = useCurrentUserData(token).account;
22556
22387
  // Hooks
22557
22388
  var showInfoNotification = common.useInfoNotification();
22558
22389
  // Queries
@@ -22575,7 +22406,6 @@ var PlanPicker = function () {
22575
22406
  productId: productId,
22576
22407
  token: token,
22577
22408
  upgradingSubscription: upgradingSubscription,
22578
- accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId,
22579
22409
  });
22580
22410
  },
22581
22411
  enabled: !areSubscriptionsLoading,
@@ -22738,7 +22568,7 @@ var SubscriptionState$1 = SubscriptionState;
22738
22568
 
22739
22569
  var FEATURE_USAGE_MUTATION = "\nquery GetFeatureUsage($id: ID!) {\n featureUsageHistogram(subscriptionChargeId: $id) {\n subscriptionCharge { \n id\n name\n amount\n currentPeriodPriceByTiers { \n tier { starts price } \n quantity\n amount\n }\n }\n feature { id name }\n periodRange\n dataInterval\n data {\n periodStart\n periodEnd\n intervals {\n intervalStart\n intervalUsage\n }\n intervalsTotal\n }\n }\n}\n";
22740
22570
  var getFeatureUsage = function (_a) {
22741
- var subscriptionChargeId = _a.subscriptionChargeId, token = _a.token, apiHost = _a.apiHost;
22571
+ var subscriptionChargeId = _a.subscriptionChargeId; _a.startDate; _a.endDate; _a.dataInterval; var token = _a.token, apiHost = _a.apiHost;
22742
22572
  return __awaiter(void 0, void 0, void 0, function () {
22743
22573
  var vars, response;
22744
22574
  var _b;
@@ -22858,50 +22688,386 @@ var FeatureBarChart = function (_a) {
22858
22688
  var StyledBarChart = defaultStyled(recharts.BarChart)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n .recharts-surface {\n overflow: visible;\n }\n"], ["\n .recharts-surface {\n overflow: visible;\n }\n"])));
22859
22689
  var templateObject_1$2;
22860
22690
 
22861
- var SubscriptionCardActions = function (_a) {
22862
- var _b;
22863
- var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, priceListChangeOptions = _a.priceListChangeOptions, subscription = _a.subscription;
22864
- var apiHost = react.useContext(BunnyContext).apiHost;
22865
- var token = useToken();
22866
- var isPaymentMethodLoading = usePaymentMethod({
22867
- accountId: subscription.accountId,
22868
- token: token,
22869
- apiHost: apiHost,
22870
- }).isLoading;
22871
- // Derived state
22872
- var isSelfServiceCancelable = subscription.plan.selfServiceCancel;
22873
- var productPlans = (_b = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _b === void 0 ? void 0 : _b.filter(function (priceList) { return priceList.product.id === subscription.product.id; });
22874
- var arePlansAvailable = ((productPlans === null || productPlans === void 0 ? void 0 : productPlans.length) || 0) > 0;
22875
- var isInTrial = isSubscriptionTrial(subscription);
22876
- var isActiveOrPending = isSubscriptionActiveOrPending(subscription);
22877
- if (isPaymentMethodLoading)
22878
- return null;
22879
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isSelfServiceCancelable && (isInTrial || isActiveOrPending) && (jsxRuntime.jsx(antd.Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "bunny-p-0", type: "link" }, { children: "Cancel subscription" })) }))), arePlansAvailable && (isActiveOrPending || isInTrial) && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: 'primary' }, { children: isInTrial ? 'Upgrade from trial' : 'Change plan' }))), !arePlansAvailable && isInTrial && jsxRuntime.jsx(antd.Tag, __assign({ color: "warning" }, { children: "Cannot upgrade" }))] }));
22691
+ var canShowQuantitiesInput = function (charge, subscription) {
22692
+ // Check if the subscription is active, pending, or in trial,
22693
+ // the pricing model is not flat,
22694
+ // and if it's not a trial, also check if the current charge is the last one in the subscription.
22695
+ var _a, _b, _c;
22696
+ var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE;
22697
+ var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
22698
+ var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL;
22699
+ var isFlatPricing = charge.pricingModel === 'FLAT';
22700
+ var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
22701
+ !isFlatPricing &&
22702
+ charge.selfServiceQuantity &&
22703
+ !charge.expired;
22704
+ // Now you can use the value of shouldProcessCharge to determine whether to process the charge.
22705
+ return shouldProcessCharge;
22880
22706
  };
22881
-
22882
- var Text$7 = antd.Typography.Text;
22883
- var getSubscriptionStatusText = function (subscription) {
22884
- var _a;
22885
- var cancellationDate = subscription.cancellationDate, state = subscription.state, evergreen = subscription.evergreen, endDate = subscription.endDate, trialExpirationAction = subscription.trialExpirationAction;
22886
- var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL;
22887
- if (cancellationDate &&
22888
- (state === null || state === void 0 ? void 0 : state.toUpperCase()) !== common.SubscriptionState.CANCELED &&
22889
- (state === null || state === void 0 ? void 0 : state.toUpperCase()) !== common.SubscriptionState.EXPIRED) {
22890
- return (jsxRuntime.jsxs(CustomizedTag, __assign({ color: "red" }, { children: ["Canceled - ends on ", common.formatDate(cancellationDate)] })));
22891
- }
22892
- if (isTrial) {
22893
- switch (trialExpirationAction) {
22894
- case 'ACTIVATE':
22895
- return "Activates on ".concat(common.formatDate(endDate));
22896
- case 'CANCEL':
22897
- return "Trial ends on ".concat(common.formatDate(endDate));
22898
- }
22899
- }
22900
- if (evergreen) {
22901
- return "Renews on ".concat(common.formatDate(endDate));
22902
- }
22903
- if ((state === null || state === void 0 ? void 0 : state.toUpperCase()) === common.SubscriptionState.CANCELED ||
22904
- (state === null || state === void 0 ? void 0 : state.toUpperCase()) === common.SubscriptionState.EXPIRED) {
22707
+ var createQuoteParams = function (quote, subscriptionQuantity, editedSubscription) {
22708
+ var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
22709
+ var quoteChangeCharge = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) { return charge.priceListCharge.id === editedSubscription.chargeId; });
22710
+ var charges = [
22711
+ {
22712
+ id: quoteChangeCharge.id,
22713
+ quantity: editedSubscription.quantity - subscriptionQuantity,
22714
+ },
22715
+ ];
22716
+ return { charges: charges, quoteChange: quoteChange };
22717
+ };
22718
+ var canShowChangeQuantities = function (_a) {
22719
+ var subscriptions = _a.subscriptions;
22720
+ return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
22721
+ return subscription.charges.some(function (charge, chargeIndex) {
22722
+ return canShowQuantitiesInput(charge, subscription);
22723
+ });
22724
+ });
22725
+ };
22726
+ var isSubscriptionNotActive = function (subscription) {
22727
+ var _a, _b;
22728
+ return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
22729
+ ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.CANCELED;
22730
+ };
22731
+ var isSubscriptionActiveOrPending = function (subscription) {
22732
+ var _a, _b;
22733
+ return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE ||
22734
+ ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
22735
+ };
22736
+ var isSubscriptionTrial = function (subscription) { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL; };
22737
+ // Helper function to check if charge is a discount
22738
+ var isDiscount = function (kind) {
22739
+ return kind === common.QuoteChangeKind.DISCOUNT || kind === common.QuoteChangeKind.FREE_PERIOD_DISCOUNT;
22740
+ };
22741
+ var hasPriceTiers = function (charge) {
22742
+ var _a;
22743
+ return Boolean((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length);
22744
+ };
22745
+ var hasMultiplePriceTiers = function (charge) {
22746
+ var _a;
22747
+ return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length) > 1;
22748
+ };
22749
+ var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
22750
+ var _a;
22751
+ if (!((_a = charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length))
22752
+ return '';
22753
+ var selectedTier;
22754
+ // For TIERED pricing model: always show the first tier
22755
+ if (charge.pricingModel === common.PricingModel.TIERED) {
22756
+ selectedTier = charge.priceTiers[0];
22757
+ }
22758
+ // For VOLUME and BANDS pricing models: find the tier that contains the current quantity
22759
+ else if (charge.pricingModel === common.PricingModel.VOLUME ||
22760
+ charge.pricingModel === common.PricingModel.BANDS) {
22761
+ // Find the appropriate tier based on quantity
22762
+ selectedTier = charge.priceTiers.find(function (tier, index) {
22763
+ var nextTier = charge.priceTiers[index + 1];
22764
+ var tierStart = tier.starts;
22765
+ var tierEnd = nextTier ? nextTier.starts - 1 : Infinity;
22766
+ return charge.quantity >= tierStart && charge.quantity <= tierEnd;
22767
+ });
22768
+ // Fallback to first tier if no tier found (shouldn't happen with proper data)
22769
+ selectedTier = selectedTier || charge.priceTiers[0];
22770
+ }
22771
+ // Default fallback for any other pricing models
22772
+ else {
22773
+ selectedTier = charge.priceTiers[0];
22774
+ }
22775
+ if (!selectedTier)
22776
+ return '';
22777
+ // Calculate the tier range for display
22778
+ var tierIndex = charge.priceTiers.indexOf(selectedTier);
22779
+ var starts = selectedTier.starts;
22780
+ var nextTier = charge.priceTiers[tierIndex + 1];
22781
+ var ends = nextTier ? nextTier.starts - 1 : '∞';
22782
+ return hasMultiplePriceTiers(charge)
22783
+ ? "".concat(starts, "-").concat(ends, ": ").concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals))
22784
+ : "".concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals));
22785
+ };
22786
+
22787
+ var MUTATION = "\nmutation BillingDetailsUpdate(\n $attributes: BillingDetailsAttributes!) {\n billingDetailsUpdate(\n attributes: $attributes\n ) {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n }\n errors\n }\n }\n";
22788
+ var billingDetailsUpdate = function (_a) {
22789
+ var attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
22790
+ return __awaiter(void 0, void 0, void 0, function () {
22791
+ var vars, response, errors;
22792
+ var _b;
22793
+ return __generator(this, function (_c) {
22794
+ switch (_c.label) {
22795
+ case 0:
22796
+ vars = { attributes: attributes };
22797
+ return [4 /*yield*/, gqlRequest({
22798
+ query: MUTATION,
22799
+ token: token,
22800
+ vars: vars,
22801
+ apiHost: apiHost,
22802
+ })];
22803
+ case 1:
22804
+ response = _c.sent();
22805
+ errors = (_b = response === null || response === void 0 ? void 0 : response.billingDetailsUpdate) === null || _b === void 0 ? void 0 : _b.errors;
22806
+ if (errors)
22807
+ throw errors;
22808
+ return [2 /*return*/, response.billingDetailsUpdate];
22809
+ }
22810
+ });
22811
+ });
22812
+ };
22813
+
22814
+ // TODO: move this to common
22815
+ var billingDetailsQuery = function () {
22816
+ return "\nquery BillingDetails {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n currency {\n id\n }\n }\n}";
22817
+ };
22818
+ var getBillingDetails = function (_a) {
22819
+ var token = _a.token, apiHost = _a.apiHost;
22820
+ return __awaiter(void 0, void 0, void 0, function () {
22821
+ var response;
22822
+ var _b;
22823
+ return __generator(this, function (_c) {
22824
+ switch (_c.label) {
22825
+ case 0: return [4 /*yield*/, gqlRequest({
22826
+ query: billingDetailsQuery(),
22827
+ token: token,
22828
+ apiHost: apiHost,
22829
+ })];
22830
+ case 1:
22831
+ response = _c.sent();
22832
+ if (response === null || response === void 0 ? void 0 : response.errors) {
22833
+ throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
22834
+ }
22835
+ return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
22836
+ }
22837
+ });
22838
+ });
22839
+ };
22840
+
22841
+ var Text$7 = antd.Typography.Text;
22842
+ function BillingDetailsSection(_a) {
22843
+ var _this = this;
22844
+ var hidePaymentMethodForm = _a.hidePaymentMethodForm, countryListFilter = _a.countryListFilter;
22845
+ // State
22846
+ var _b = react.useState(false), isFormEdited = _b[0], setIsFormEdited = _b[1];
22847
+ var _c = react.useState(false), formIsValid = _c[0], setFormIsValid = _c[1];
22848
+ var form = antd.Form.useForm()[0];
22849
+ var values = antd.Form.useWatch([], form);
22850
+ // Context
22851
+ var apiHost = react.useContext(BunnyContext).apiHost;
22852
+ var token = useToken();
22853
+ // Hooks
22854
+ var isMobile = common.useIsMobile();
22855
+ var queryClient = reactQuery.useQueryClient();
22856
+ var showErrorNotification = common.useErrorNotification();
22857
+ var showSuccessNotification = common.useSuccessNotification();
22858
+ // Queries
22859
+ var _d = reactQuery.useQuery({
22860
+ queryKey: common.QueryKeyFactory.default.billingDetailsKey({ token: token }),
22861
+ queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
22862
+ }), billingDetails = _d.data, isLoadingBillingDetails = _d.isLoading;
22863
+ var _e = reactQuery.useMutation({
22864
+ mutationFn: function (changedFormData) { return __awaiter(_this, void 0, void 0, function () {
22865
+ var updatedBillingDetails;
22866
+ return __generator(this, function (_a) {
22867
+ switch (_a.label) {
22868
+ case 0: return [4 /*yield*/, billingDetailsUpdate({
22869
+ attributes: {
22870
+ name: changedFormData.name,
22871
+ billingStreet: changedFormData.billingStreet,
22872
+ billingCity: changedFormData.billingCity,
22873
+ billingZip: changedFormData.billingZip,
22874
+ billingState: changedFormData.billingState,
22875
+ billingCountry: changedFormData.billingCountry,
22876
+ billingContactEmail: changedFormData.billingContactEmail,
22877
+ taxNumber: changedFormData.taxNumber,
22878
+ },
22879
+ token: token,
22880
+ apiHost: apiHost,
22881
+ })];
22882
+ case 1:
22883
+ updatedBillingDetails = _a.sent();
22884
+ queryClient.setQueryData(common.QueryKeyFactory.default.billingDetailsKey({ token: token }), function (old) {
22885
+ return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
22886
+ });
22887
+ return [2 /*return*/, updatedBillingDetails];
22888
+ }
22889
+ });
22890
+ }); },
22891
+ onSuccess: function () {
22892
+ showSuccessNotification('Your account details have been saved');
22893
+ queryClient.invalidateQueries({
22894
+ queryKey: common.QueryKeyFactory.default.taxationRequiredAccountFieldsKey({
22895
+ token: token,
22896
+ }),
22897
+ });
22898
+ },
22899
+ }), updateBillingDetails = _e.mutate, isUpdatingBillingDetails = _e.isPending;
22900
+ // Set form values when billing details are loaded
22901
+ react.useEffect(function () {
22902
+ var _a;
22903
+ if (billingDetails) {
22904
+ form.setFieldsValue({
22905
+ billingStreet: billingDetails.billingStreet,
22906
+ billingCity: billingDetails.billingCity,
22907
+ billingZip: billingDetails.billingZip,
22908
+ billingState: billingDetails.billingState,
22909
+ billingCountry: billingDetails.billingCountry,
22910
+ billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
22911
+ taxNumber: billingDetails.taxNumber,
22912
+ });
22913
+ }
22914
+ }, [billingDetails]);
22915
+ react.useEffect(function () {
22916
+ form
22917
+ .validateFields({ validateOnly: true })
22918
+ .then(function () { return setFormIsValid(true); })
22919
+ .catch(function () { return setFormIsValid(false); });
22920
+ var isFormEdited = function () {
22921
+ var _a;
22922
+ if (!billingDetails)
22923
+ return false;
22924
+ var currentValues = form.getFieldsValue();
22925
+ var accountValues = {
22926
+ billingStreet: billingDetails.billingStreet,
22927
+ billingCity: billingDetails.billingCity,
22928
+ billingZip: billingDetails.billingZip,
22929
+ billingState: billingDetails.billingState,
22930
+ billingCountry: billingDetails.billingCountry,
22931
+ billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
22932
+ taxNumber: billingDetails.taxNumber,
22933
+ };
22934
+ return Object.keys(currentValues).some(function (key) {
22935
+ var value = accountValues[key];
22936
+ return currentValues[key] !== value;
22937
+ });
22938
+ };
22939
+ setIsFormEdited(isFormEdited());
22940
+ }, [form, values, billingDetails]);
22941
+ // Validate form fields when isFormEdited changes
22942
+ react.useEffect(function () {
22943
+ var validateOnly = isFormEdited ? false : true;
22944
+ form.validateFields({ validateOnly: validateOnly });
22945
+ }, [isFormEdited]);
22946
+ var saveBillingDetails = function () { return __awaiter(_this, void 0, void 0, function () {
22947
+ var _this = this;
22948
+ return __generator(this, function (_a) {
22949
+ form.validateFields({ validateOnly: false }).then(function () { return __awaiter(_this, void 0, void 0, function () {
22950
+ var error_1;
22951
+ return __generator(this, function (_a) {
22952
+ switch (_a.label) {
22953
+ case 0:
22954
+ _a.trys.push([0, 2, 3, 4]);
22955
+ return [4 /*yield*/, form.validateFields()];
22956
+ case 1:
22957
+ _a.sent();
22958
+ updateBillingDetails(form.getFieldsValue());
22959
+ return [3 /*break*/, 4];
22960
+ case 2:
22961
+ error_1 = _a.sent();
22962
+ if (error_1 instanceof Error) {
22963
+ showErrorNotification('Failed to update account', error_1.message);
22964
+ }
22965
+ else {
22966
+ showErrorNotification('Please fill out all required fields');
22967
+ }
22968
+ return [3 /*break*/, 4];
22969
+ case 3:
22970
+ setIsFormEdited(false);
22971
+ return [7 /*endfinally*/];
22972
+ case 4: return [2 /*return*/];
22973
+ }
22974
+ });
22975
+ }); });
22976
+ return [2 /*return*/];
22977
+ });
22978
+ }); };
22979
+ var filteredCountryList = react.useMemo(function () {
22980
+ return countryListFilter ? common.Lists.COUNTRY_LIST.filter(countryListFilter) : common.Lists.COUNTRY_LIST;
22981
+ }, [countryListFilter]);
22982
+ return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hidePaymentMethodForm ? 'bunny-w-full' : 'bunny-w-1/2') }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-px-4" }, { children: [jsxRuntime.jsxs(antd.Skeleton, __assign({ loading: isLoadingBillingDetails }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-mb-2" }, { children: jsxRuntime.jsx(Text$7, __assign({ className: "bunny-font-medium bunny-text-lg" }, { children: (billingDetails === null || billingDetails === void 0 ? void 0 : billingDetails.name) || 'No company name' })) })), jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical", disabled: isUpdatingBillingDetails, autoComplete: "off" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Street address", name: "billingStreet", rules: [{ required: true, message: 'Street address is required' }] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: 'City is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: 'Zipcode is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-row bunny-pb-2' : 'bunny-flex-row', " bunny-gap-4") }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "State", name: "billingState", rules: [
22983
+ {
22984
+ required: false,
22985
+ },
22986
+ ] }, { children: jsxRuntime.jsx(antd.Input, {}) })) })), jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Country", name: "billingCountry", rules: [{ required: true, message: 'Country is required' }] }, { children: jsxRuntime.jsx(antd.Select, { className: "bunny-w-full", options: filteredCountryList, placeholder: "Select a country", popupMatchSelectWidth: false, showSearch: true, filterOption: function (input, option) {
22987
+ var _a, _b;
22988
+ return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(input.toLowerCase()) ||
22989
+ ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase());
22990
+ } }) })) }))] })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Email", name: "billingContactEmail", rules: [
22991
+ {
22992
+ required: true,
22993
+ message: 'Email is required',
22994
+ type: 'email',
22995
+ },
22996
+ ] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Tax ID", name: "taxNumber", tooltip: "Tax ID will be printed on quotes and invoices below the account's address", rules: [{ required: false }] }, { children: jsxRuntime.jsx(antd.Input, {}) }))] }))] })), jsxRuntime.jsx(antd.Button, __assign({ disabled: !isFormEdited || isUpdatingBillingDetails || !formIsValid, className: "bunny-w-full bunny-mt-4", type: "primary", onClick: saveBillingDetails }, { children: "Save" }))] })) })));
22997
+ }
22998
+
22999
+ var BillingDetails = function (_a) {
23000
+ var className = _a.className, countryListFilter = _a.countryListFilter, _b = _a.hideBillingDetailsForm, hideBillingDetailsForm = _b === void 0 ? false : _b, _c = _a.hidePaymentMethodForm, hidePaymentMethodForm = _c === void 0 ? false : _c, _d = _a.isCardEnabled, isCardEnabled = _d === void 0 ? true : _d, _e = _a.isUpgradeFromTrial, isUpgradeFromTrial = _e === void 0 ? false : _e, _f = _a.shadow, shadow = _f === void 0 ? 'shadow-md' : _f, onSavePaymentMethod = _a.onSavePaymentMethod;
23001
+ // Hooks
23002
+ var isMobile = common.useIsMobile();
23003
+ return (jsxRuntime.jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-py-2 bunny-my-2 ".concat(isMobile ? 'bunny-flex-col bunny-space-y-4' : 'bunny-flex-row', " bunny-gap-4") }, { children: [!hideBillingDetailsForm ? (jsxRuntime.jsx(BillingDetailsSection, { hidePaymentMethodForm: hidePaymentMethodForm, countryListFilter: countryListFilter })) : null, !hideBillingDetailsForm && !hidePaymentMethodForm ? jsxRuntime.jsx(ResponsiveDivider, {}) : null, !hidePaymentMethodForm ? (jsxRuntime.jsx(PaymentFormSection, { hideBillingDetailsForm: hideBillingDetailsForm, isUpgradeFromTrial: isUpgradeFromTrial, onSavePaymentMethod: onSavePaymentMethod })) : null] })) })));
23004
+ };
23005
+ var WrapperComponent = function (_a) {
23006
+ var children = _a.children, isCardEnabled = _a.isCardEnabled, shadow = _a.shadow, className = _a.className;
23007
+ return (jsxRuntime.jsx("div", __assign({ className: "".concat(className) }, { children: isCardEnabled ? jsxRuntime.jsx(Card, __assign({ className: "".concat(shadow) }, { children: children })) : jsxRuntime.jsx("div", { children: children }) })));
23008
+ };
23009
+ var ResponsiveDivider = function () {
23010
+ var isMobile = common.useIsMobile();
23011
+ return isMobile ? (jsxRuntime.jsx("div", __assign({ className: "bunny-mx-4" }, { children: jsxRuntime.jsx(antd.Divider, {}) }))) : (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(antd.Divider, { className: "bunny-h-full", type: "vertical" }) }));
23012
+ };
23013
+ var PaymentFormSection = function (_a) {
23014
+ var hideBillingDetailsForm = _a.hideBillingDetailsForm, isUpgradeFromTrial = _a.isUpgradeFromTrial, onSavePaymentMethod = _a.onSavePaymentMethod;
23015
+ var isMobile = common.useIsMobile();
23016
+ var onTokenExpired = react.useContext(BunnyContext).onTokenExpired;
23017
+ var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
23018
+ var showSuccessNotification = common.useSuccessNotification();
23019
+ var entityId = useCurrentUserData().entityId;
23020
+ return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
23021
+ handleAllErrorFormats(error);
23022
+ }, onSavePaymentMethod: function () {
23023
+ showSuccessNotification(isUpgradeFromTrial
23024
+ ? 'Payment method saved! Your trial will automatically convert to a paid subscription.'
23025
+ : 'Payment method saved successfully!');
23026
+ onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
23027
+ } }) })));
23028
+ };
23029
+
23030
+ var UpgradeFromTrial = function (_a) {
23031
+ var onClose = _a.onClose, open = _a.open;
23032
+ return (jsxRuntime.jsx(antd.Modal, __assign({ width: '80vw', open: open, onCancel: onClose, footer: null }, { children: jsxRuntime.jsx(BillingDetails, { isUpgradeFromTrial: true, onSavePaymentMethod: onClose }) })));
23033
+ };
23034
+
23035
+ var SubscriptionCardActions = function (_a) {
23036
+ var _b;
23037
+ var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, priceListChangeOptions = _a.priceListChangeOptions, subscription = _a.subscription;
23038
+ var apiHost = react.useContext(BunnyContext).apiHost;
23039
+ var token = useToken();
23040
+ var _c = usePaymentMethod({
23041
+ accountId: subscription.accountId,
23042
+ token: token,
23043
+ apiHost: apiHost,
23044
+ }), storedPaymentMethods = _c.paymentMethods, isPaymentMethodLoading = _c.isLoading;
23045
+ // Local state
23046
+ var _d = react.useState(false), isUpgradeFromTrialModalOpen = _d[0], setIsUpgradeFromTrialModalOpen = _d[1];
23047
+ // Derived state
23048
+ var isSelfServiceCancelable = subscription.plan.selfServiceCancel;
23049
+ var productPlans = (_b = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _b === void 0 ? void 0 : _b.filter(function (priceList) { return priceList.product.id === subscription.product.id; });
23050
+ var arePlansAvailable = ((productPlans === null || productPlans === void 0 ? void 0 : productPlans.length) || 0) > 0;
23051
+ var isInTrial = isSubscriptionTrial(subscription);
23052
+ var isActiveOrPending = isSubscriptionActiveOrPending(subscription);
23053
+ if (isPaymentMethodLoading)
23054
+ return null;
23055
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isSelfServiceCancelable && (isInTrial || isActiveOrPending) && (jsxRuntime.jsx(antd.Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "bunny-p-0", type: "link" }, { children: "Cancel subscription" })) }))), isInTrial && !(storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return setIsUpgradeFromTrialModalOpen(true); }, type: "primary" }, { children: "Upgrade from trial" }))), arePlansAvailable && (isInTrial || isActiveOrPending) && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: isInTrial ? 'default' : 'primary' }, { children: "Change plan" }))), jsxRuntime.jsx(UpgradeFromTrial, { onClose: function () { return setIsUpgradeFromTrialModalOpen(false); }, open: isUpgradeFromTrialModalOpen })] }));
23056
+ };
23057
+
23058
+ var Text$6 = antd.Typography.Text;
23059
+ var getSubscriptionStatusText = function (subscription) {
23060
+ var cancellationDate = subscription.cancellationDate, state = subscription.state, evergreen = subscription.evergreen, endDate = subscription.endDate;
23061
+ if (cancellationDate &&
23062
+ (state === null || state === void 0 ? void 0 : state.toUpperCase()) !== common.SubscriptionState.CANCELED &&
23063
+ (state === null || state === void 0 ? void 0 : state.toUpperCase()) !== common.SubscriptionState.EXPIRED) {
23064
+ return (jsxRuntime.jsxs(CustomizedTag, __assign({ color: "red" }, { children: ["Canceled - ends on ", common.formatDate(cancellationDate)] })));
23065
+ }
23066
+ if (evergreen) {
23067
+ return "Renews on ".concat(common.formatDate(endDate));
23068
+ }
23069
+ if ((state === null || state === void 0 ? void 0 : state.toUpperCase()) === common.SubscriptionState.CANCELED ||
23070
+ (state === null || state === void 0 ? void 0 : state.toUpperCase()) === common.SubscriptionState.EXPIRED) {
22905
23071
  return "Ended on ".concat(common.formatDate(endDate));
22906
23072
  }
22907
23073
  return "Ends on ".concat(common.formatDate(endDate));
@@ -22918,7 +23084,7 @@ var SubscriptionCardHeader = function (_a) {
22918
23084
  var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL;
22919
23085
  return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between", style: {
22920
23086
  backgroundColor: darkMode ? 'var(--row-background-dark)' : '',
22921
- } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsxRuntime.jsx(Text$7, __assign({ style: __assign({ fontSize: '11px', fontWeight: 500, color: brandColor }, subscriptionProductNameStyle) }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-grow bunny-items-center bunny-gap-2" }, { children: [((_e = subscription === null || subscription === void 0 ? void 0 : subscription.plan) === null || _e === void 0 ? void 0 : _e.name) && (jsxRuntime.jsx(Text$7, __assign({ className: "bunny-text-lg" }, { children: subscription.plan.name }))), jsxRuntime.jsxs(CustomizedTag, __assign({ color: common.TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()] }, { children: [lodashExports.capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft || 'N/A', " days left)") : ''] }))] }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-gap-6" }, { children: [jsxRuntime.jsx(Text$7, __assign({ className: "bunny-grow bunny-text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile && priceListChangeOptions && onChangePlanClick && onCancelSubscriptionClick && (jsxRuntime.jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscription: subscription }))] }))] })));
23087
+ } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsxRuntime.jsx(Text$6, __assign({ style: __assign({ fontSize: '11px', fontWeight: 500, color: brandColor }, subscriptionProductNameStyle) }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-grow bunny-items-center bunny-gap-2" }, { children: [((_e = subscription === null || subscription === void 0 ? void 0 : subscription.plan) === null || _e === void 0 ? void 0 : _e.name) && (jsxRuntime.jsx(Text$6, __assign({ className: "bunny-text-lg" }, { children: subscription.plan.name }))), jsxRuntime.jsxs(CustomizedTag, __assign({ color: common.TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()] }, { children: [lodashExports.capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft || 'N/A', " days left)") : ''] }))] }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-gap-6" }, { children: [jsxRuntime.jsx(Text$6, __assign({ className: "bunny-grow bunny-text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile && priceListChangeOptions && onChangePlanClick && onCancelSubscriptionClick && (jsxRuntime.jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscription: subscription }))] }))] })));
22922
23088
  };
22923
23089
 
22924
23090
  var SubscriptionChargeTotal = function (_a) {
@@ -22995,16 +23161,16 @@ var SubscriptionChargeUnitPrice = function (_a) {
22995
23161
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: hasPriceTiers(charge) ? (jsxRuntime.jsx(TieredDisplayDropdown, { charge: charge, currencyId: currencyId, truncatedText: "".concat(charge.kind === common.QuoteChangeKind.PRICE_UPDATE ? 'new ' : '').concat(getApplicablePriceTier(charge, currencyId, charge.priceDecimals)) })) : isChargeDiscount ? ("-".concat(price)) : (price) }));
22996
23162
  };
22997
23163
 
22998
- var Text$6 = antd.Typography.Text;
23164
+ var Text$5 = antd.Typography.Text;
22999
23165
  var SubscriptionCardColumnHeaders = function (_a) {
23000
23166
  var columns = _a.columns;
23001
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsxRuntime.jsx(Text$6, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: "11px" } }, { children: subscriptionColumn.title }), index)); }) }));
23167
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsxRuntime.jsx(Text$5, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: "11px" } }, { children: subscriptionColumn.title }), index)); }) }));
23002
23168
  };
23003
23169
 
23004
- var Text$5 = antd.Typography.Text;
23170
+ var Text$4 = antd.Typography.Text;
23005
23171
  var SubscriptionsListCell = function (_a) {
23006
23172
  var children = _a.children, className = _a.className, gridColumn = _a.gridColumn, right = _a.right, style = _a.style;
23007
- return (jsxRuntime.jsx(Text$5, __assign({ className: "bunny-flex bunny-items-center bunny-text-sm bunny-whitespace-nowrap ".concat(className), style: __assign({ gridColumn: gridColumn, textAlign: right ? "right" : "left", justifyContent: right ? "flex-end" : "flex-start" }, style) }, { children: children })));
23173
+ return (jsxRuntime.jsx(Text$4, __assign({ className: "bunny-flex bunny-items-center bunny-text-sm bunny-whitespace-nowrap ".concat(className), style: __assign({ gridColumn: gridColumn, textAlign: right ? "right" : "left", justifyContent: right ? "flex-end" : "flex-start" }, style) }, { children: children })));
23008
23174
  };
23009
23175
 
23010
23176
  var CARD_COLUMNS = [
@@ -23064,9 +23230,11 @@ var SubscriptionCardDesktopRow = function (_a) {
23064
23230
  var chargePeriod = "".concat(common.formatDate(charge.startDate), " - ").concat(common.formatDate(charge.endDate));
23065
23231
  // Queries
23066
23232
  var data = reactQuery.useQuery({
23067
- queryKey: ['getFeatureUsage', charge.id],
23233
+ queryKey: ['getFeatureUsage', charge.id, charge.startDate, charge.endDate],
23068
23234
  queryFn: function () {
23069
23235
  return getFeatureUsage({
23236
+ endDate: charge.endDate,
23237
+ startDate: charge.startDate,
23070
23238
  subscriptionChargeId: charge.id,
23071
23239
  token: token,
23072
23240
  apiHost: apiHost,
@@ -23090,10 +23258,10 @@ var SubscriptionCardDesktopRow = function (_a) {
23090
23258
  : (_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString() })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeUnitPrice, { charge: charge, currencyId: subscription.currencyId }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
23091
23259
  };
23092
23260
 
23093
- var Text$4 = antd.Typography.Text;
23261
+ var Text$3 = antd.Typography.Text;
23094
23262
  var SubscriptionCardCellMobile = function (_a) {
23095
23263
  var children = _a.children, className = _a.className, style = _a.style;
23096
- return (jsxRuntime.jsx(Text$4, __assign({ className: className, style: style }, { children: children })));
23264
+ return (jsxRuntime.jsx(Text$3, __assign({ className: className, style: style }, { children: children })));
23097
23265
  };
23098
23266
 
23099
23267
  var CHARGE_COLUMNS = [
@@ -23159,13 +23327,10 @@ var SubscriptionsListContainer = function (_a) {
23159
23327
  var apiHost = react.useContext(BunnyContext).apiHost;
23160
23328
  var gap = react.useContext(SubscriptionsContext).gap;
23161
23329
  var token = useToken();
23162
- var account = useCurrentUserData(token).account;
23163
23330
  // Queries
23164
23331
  var _c = reactQuery.useQuery({
23165
23332
  queryKey: common.QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
23166
- queryFn: function () {
23167
- return getPriceListChangeOptions({ apiHost: apiHost, token: token, accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId });
23168
- },
23333
+ queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
23169
23334
  enabled: Boolean(onChangePlanClick),
23170
23335
  }), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
23171
23336
  if (subscriptionsAreLoading ||
@@ -23174,10 +23339,10 @@ var SubscriptionsListContainer = function (_a) {
23174
23339
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-".concat(gap, " bunny-shrink bunny-overflow-auto") }, { children: jsxRuntime.jsx(SubscriptionsList, { hideExpired: hideExpired, onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions }) }))) : (noSubscriptionsComponent || (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-center bunny-w-full" }, { children: jsxRuntime.jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) })))) }));
23175
23340
  };
23176
23341
 
23177
- var Text$3 = antd.Typography.Text;
23342
+ var Text$2 = antd.Typography.Text;
23178
23343
  var DrawerHeader = function (_a) {
23179
23344
  var description = _a.description, onClose = _a.onClose, title = _a.title, closeButtonClassName = _a.closeButtonClassName;
23180
- return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between bunny-gap-2" }, { children: [jsxRuntime.jsx(Text$3, __assign({ className: "bunny-text-xl", style: { fontWeight: 400 } }, { children: title })), onClose ? (jsxRuntime.jsx("button", __assign({ id: "closePayment", onClick: onClose, className: closeButtonClassName }, { children: jsxRuntime.jsx(icons.CloseOutlined, {}) }))) : null] })), description && jsxRuntime.jsx("div", __assign({ className: "bunny-text-xs" }, { children: description }))] })));
23345
+ return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between bunny-gap-2" }, { children: [jsxRuntime.jsx(Text$2, __assign({ className: "bunny-text-xl", style: { fontWeight: 400 } }, { children: title })), onClose ? (jsxRuntime.jsx("button", __assign({ id: "closePayment", onClick: onClose, className: closeButtonClassName }, { children: jsxRuntime.jsx(icons.CloseOutlined, {}) }))) : null] })), description && jsxRuntime.jsx("div", __assign({ className: "bunny-text-xs" }, { children: description }))] })));
23181
23346
  };
23182
23347
 
23183
23348
  var formatDateForApi = function (date) {
@@ -23360,13 +23525,13 @@ var QuantityInput = function (_a) {
23360
23525
  }, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
23361
23526
  };
23362
23527
 
23363
- var Text$2 = antd.Typography.Text;
23528
+ var Text$1 = antd.Typography.Text;
23364
23529
  var QuantityChangeGridRow = function (_a) {
23365
23530
  var _b;
23366
23531
  var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, subscriptions = _a.subscriptions, subscriptionIndex = _a.subscriptionIndex, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionCharge = _a.subscriptionCharge;
23367
23532
  if (!canShowQuantitiesInput(subscriptionCharge, subscription))
23368
23533
  return null;
23369
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$2, __assign({ className: "bunny-font-medium bunny-text-orange-600 bunny-col-span-full", style: { fontSize: "11px" } }, { children: subscription.plan.name })), jsxRuntime.jsx(Text$2, __assign({ className: "bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: (_b = subscriptionCharge.name) === null || _b === void 0 ? void 0 : _b.toUpperCase() })), jsxRuntime.jsx(Text$2, __assign({ className: "bunny-flex bunny-items-center bunny-justify-end bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: subscriptionCharge.quantity })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [jsxRuntime.jsx(QuantityInput, { charge: subscriptionCharge, chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionIndex: subscriptionIndex, subscriptions: subscriptions }), jsxRuntime.jsx("div", {})] })), jsxRuntime.jsx(antd.Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
23534
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$1, __assign({ className: "bunny-font-medium bunny-text-orange-600 bunny-col-span-full", style: { fontSize: "11px" } }, { children: subscription.plan.name })), jsxRuntime.jsx(Text$1, __assign({ className: "bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: (_b = subscriptionCharge.name) === null || _b === void 0 ? void 0 : _b.toUpperCase() })), jsxRuntime.jsx(Text$1, __assign({ className: "bunny-flex bunny-items-center bunny-justify-end bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: subscriptionCharge.quantity })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [jsxRuntime.jsx(QuantityInput, { charge: subscriptionCharge, chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionIndex: subscriptionIndex, subscriptions: subscriptions }), jsxRuntime.jsx("div", {})] })), jsxRuntime.jsx(antd.Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
23370
23535
  };
23371
23536
 
23372
23537
  var QuantityChangeGridTitle = function (_a) {
@@ -23477,7 +23642,7 @@ var SubscriptionsNavigation = function (_a) {
23477
23642
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isMobile && expiredSwitchVisible && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired })), jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-grow bunny-gap-2 ".concat(isMobile ? 'bunny-flex-col' : 'bunny-justify-end') }, { children: canShowChangeQuantitiesButton && (jsxRuntime.jsx(ChangeQuantitiesButton, { canShowChangeQuantitiesButton: canShowChangeQuantitiesButton, setQuantityDrawerOpen: setQuantityDrawerOpen })) }))] }));
23478
23643
  };
23479
23644
 
23480
- var Text$1 = antd.Typography.Text;
23645
+ var Text = antd.Typography.Text;
23481
23646
  var SubscriptionsWrapper = function (_a) {
23482
23647
  var handlePortalErrors = _a.handlePortalErrors, companyName = _a.companyName, _b = _a.isInPreviewMode, isInPreviewMode = _b === void 0 ? false : _b, productId = _a.productId, className = _a.className, _c = _a.styles, userStyles = _c === void 0 ? {} : _c, noSubscriptionsComponent = _a.noSubscriptionsComponent, _d = _a.hideTitle, hideTitle = _d === void 0 ? false : _d, hideExpired = _a.hideExpired, _e = _a.hideExpiredToggle, hideExpiredToggle = _e === void 0 ? false : _e;
23483
23648
  var defaultStyles = {
@@ -23636,7 +23801,7 @@ var Subscriptions = function (_a) {
23636
23801
  setIsChangingPlan(false);
23637
23802
  }, handlePortalErrors: handlePortalErrors }));
23638
23803
  }
23639
- return (jsxRuntime.jsxs("div", __assign({ className: className }, { children: [!hideTitle ? jsxRuntime.jsx(PageTitle, { title: 'Subscriptions' }) : null, jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideExpiredToggle && (jsxRuntime.jsxs(Text$1, __assign({ className: "bunny-flex bunny-items-center bunny-justify-between", style: { minWidth: '120px' } }, { children: [hideExpired ? 'Active subscriptions' : 'All subscriptions', isMobile && expiredSwitchVisible && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpiredState }))] }))) }) }, { children: !isMobile && (jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: !hideExpiredToggle && expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) })), jsxRuntime.jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions, subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsxRuntime.jsx("div", __assign({ className: "bunny-pt-4 bunny-pb-2" }, { children: jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsxRuntime.jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsxRuntime.jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, storedPaymentMethod: defaultPaymentMethod })] })));
23804
+ return (jsxRuntime.jsxs("div", __assign({ className: className }, { children: [!hideTitle ? jsxRuntime.jsx(PageTitle, { title: 'Subscriptions' }) : null, jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideExpiredToggle && (jsxRuntime.jsxs(Text, __assign({ className: "bunny-flex bunny-items-center bunny-justify-between", style: { minWidth: '120px' } }, { children: [hideExpired ? 'Active subscriptions' : 'All subscriptions', isMobile && expiredSwitchVisible && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpiredState }))] }))) }) }, { children: !isMobile && (jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: !hideExpiredToggle && expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) })), jsxRuntime.jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions, subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsxRuntime.jsx("div", __assign({ className: "bunny-pt-4 bunny-pb-2" }, { children: jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsxRuntime.jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsxRuntime.jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, storedPaymentMethod: defaultPaymentMethod })] })));
23640
23805
  };
23641
23806
  var PageHeaderWithActions = function (_a) {
23642
23807
  var children = _a.children, title = _a.title;
@@ -23651,250 +23816,6 @@ var PageSubTitle = function (_a) {
23651
23816
  return (jsxRuntime.jsx("div", __assign({ className: "bunny-shrink-0 bunny-font-medium", style: { color: secondaryColor } }, { children: title })));
23652
23817
  };
23653
23818
 
23654
- var MUTATION = "\nmutation BillingDetailsUpdate(\n $attributes: BillingDetailsAttributes!) {\n billingDetailsUpdate(\n attributes: $attributes\n ) {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n }\n errors\n }\n }\n";
23655
- var billingDetailsUpdate = function (_a) {
23656
- var attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
23657
- return __awaiter(void 0, void 0, void 0, function () {
23658
- var vars, response, errors;
23659
- var _b;
23660
- return __generator(this, function (_c) {
23661
- switch (_c.label) {
23662
- case 0:
23663
- vars = { attributes: attributes };
23664
- return [4 /*yield*/, gqlRequest({
23665
- query: MUTATION,
23666
- token: token,
23667
- vars: vars,
23668
- apiHost: apiHost,
23669
- })];
23670
- case 1:
23671
- response = _c.sent();
23672
- errors = (_b = response === null || response === void 0 ? void 0 : response.billingDetailsUpdate) === null || _b === void 0 ? void 0 : _b.errors;
23673
- if (errors)
23674
- throw errors;
23675
- return [2 /*return*/, response.billingDetailsUpdate];
23676
- }
23677
- });
23678
- });
23679
- };
23680
-
23681
- // TODO: move this to common
23682
- var billingDetailsQuery = function () {
23683
- return "\nquery BillingDetails {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n currency {\n id\n }\n }\n}";
23684
- };
23685
- var getBillingDetails = function (_a) {
23686
- var token = _a.token, apiHost = _a.apiHost;
23687
- return __awaiter(void 0, void 0, void 0, function () {
23688
- var response;
23689
- var _b;
23690
- return __generator(this, function (_c) {
23691
- switch (_c.label) {
23692
- case 0: return [4 /*yield*/, gqlRequest({
23693
- query: billingDetailsQuery(),
23694
- token: token,
23695
- apiHost: apiHost,
23696
- })];
23697
- case 1:
23698
- response = _c.sent();
23699
- if (response === null || response === void 0 ? void 0 : response.errors) {
23700
- throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
23701
- }
23702
- return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
23703
- }
23704
- });
23705
- });
23706
- };
23707
-
23708
- var Text = antd.Typography.Text;
23709
- function BillingDetailsSection(_a) {
23710
- var _this = this;
23711
- var hidePaymentMethodForm = _a.hidePaymentMethodForm, countryListFilter = _a.countryListFilter;
23712
- // State
23713
- var _b = react.useState(false), isFormEdited = _b[0], setIsFormEdited = _b[1];
23714
- var _c = react.useState(false), formIsValid = _c[0], setFormIsValid = _c[1];
23715
- var form = antd.Form.useForm()[0];
23716
- var values = antd.Form.useWatch([], form);
23717
- // Context
23718
- var apiHost = react.useContext(BunnyContext).apiHost;
23719
- var token = useToken();
23720
- // Hooks
23721
- var isMobile = common.useIsMobile();
23722
- var queryClient = reactQuery.useQueryClient();
23723
- var showErrorNotification = common.useErrorNotification();
23724
- var showSuccessNotification = common.useSuccessNotification();
23725
- // Queries
23726
- var _d = reactQuery.useQuery({
23727
- queryKey: common.QueryKeyFactory.default.billingDetailsKey({ token: token }),
23728
- queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
23729
- }), billingDetails = _d.data, isLoadingBillingDetails = _d.isLoading;
23730
- var _e = reactQuery.useMutation({
23731
- mutationFn: function (changedFormData) { return __awaiter(_this, void 0, void 0, function () {
23732
- var updatedBillingDetails;
23733
- return __generator(this, function (_a) {
23734
- switch (_a.label) {
23735
- case 0: return [4 /*yield*/, billingDetailsUpdate({
23736
- attributes: {
23737
- name: changedFormData.name,
23738
- billingStreet: changedFormData.billingStreet,
23739
- billingCity: changedFormData.billingCity,
23740
- billingZip: changedFormData.billingZip,
23741
- billingState: changedFormData.billingState,
23742
- billingCountry: changedFormData.billingCountry,
23743
- billingContactEmail: changedFormData.billingContactEmail,
23744
- taxNumber: changedFormData.taxNumber,
23745
- },
23746
- token: token,
23747
- apiHost: apiHost,
23748
- })];
23749
- case 1:
23750
- updatedBillingDetails = _a.sent();
23751
- queryClient.setQueryData(common.QueryKeyFactory.default.billingDetailsKey({ token: token }), function (old) {
23752
- return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
23753
- });
23754
- return [2 /*return*/, updatedBillingDetails];
23755
- }
23756
- });
23757
- }); },
23758
- onSuccess: function () {
23759
- showSuccessNotification('Your account details have been saved');
23760
- queryClient.invalidateQueries({
23761
- queryKey: common.QueryKeyFactory.default.taxationRequiredAccountFieldsKey({
23762
- token: token,
23763
- }),
23764
- });
23765
- },
23766
- }), updateBillingDetails = _e.mutate, isUpdatingBillingDetails = _e.isPending;
23767
- // Set form values when billing details are loaded
23768
- react.useEffect(function () {
23769
- var _a;
23770
- if (billingDetails) {
23771
- form.setFieldsValue({
23772
- billingStreet: billingDetails.billingStreet,
23773
- billingCity: billingDetails.billingCity,
23774
- billingZip: billingDetails.billingZip,
23775
- billingState: billingDetails.billingState,
23776
- billingCountry: billingDetails.billingCountry,
23777
- billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
23778
- taxNumber: billingDetails.taxNumber,
23779
- });
23780
- }
23781
- }, [billingDetails]);
23782
- react.useEffect(function () {
23783
- form
23784
- .validateFields({ validateOnly: true })
23785
- .then(function () { return setFormIsValid(true); })
23786
- .catch(function () { return setFormIsValid(false); });
23787
- var isFormEdited = function () {
23788
- var _a;
23789
- if (!billingDetails)
23790
- return false;
23791
- var currentValues = form.getFieldsValue();
23792
- var accountValues = {
23793
- billingStreet: billingDetails.billingStreet,
23794
- billingCity: billingDetails.billingCity,
23795
- billingZip: billingDetails.billingZip,
23796
- billingState: billingDetails.billingState,
23797
- billingCountry: billingDetails.billingCountry,
23798
- billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
23799
- taxNumber: billingDetails.taxNumber,
23800
- };
23801
- return Object.keys(currentValues).some(function (key) {
23802
- var value = accountValues[key];
23803
- return currentValues[key] !== value;
23804
- });
23805
- };
23806
- setIsFormEdited(isFormEdited());
23807
- }, [form, values, billingDetails]);
23808
- // Validate form fields when isFormEdited changes
23809
- react.useEffect(function () {
23810
- var validateOnly = isFormEdited ? false : true;
23811
- form.validateFields({ validateOnly: validateOnly });
23812
- }, [isFormEdited]);
23813
- var saveBillingDetails = function () { return __awaiter(_this, void 0, void 0, function () {
23814
- var _this = this;
23815
- return __generator(this, function (_a) {
23816
- form.validateFields({ validateOnly: false }).then(function () { return __awaiter(_this, void 0, void 0, function () {
23817
- var error_1;
23818
- return __generator(this, function (_a) {
23819
- switch (_a.label) {
23820
- case 0:
23821
- _a.trys.push([0, 2, 3, 4]);
23822
- return [4 /*yield*/, form.validateFields()];
23823
- case 1:
23824
- _a.sent();
23825
- updateBillingDetails(form.getFieldsValue());
23826
- return [3 /*break*/, 4];
23827
- case 2:
23828
- error_1 = _a.sent();
23829
- if (error_1 instanceof Error) {
23830
- showErrorNotification('Failed to update account', error_1.message);
23831
- }
23832
- else {
23833
- showErrorNotification('Please fill out all required fields');
23834
- }
23835
- return [3 /*break*/, 4];
23836
- case 3:
23837
- setIsFormEdited(false);
23838
- return [7 /*endfinally*/];
23839
- case 4: return [2 /*return*/];
23840
- }
23841
- });
23842
- }); });
23843
- return [2 /*return*/];
23844
- });
23845
- }); };
23846
- var filteredCountryList = react.useMemo(function () {
23847
- return countryListFilter ? common.Lists.COUNTRY_LIST.filter(countryListFilter) : common.Lists.COUNTRY_LIST;
23848
- }, [countryListFilter]);
23849
- return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hidePaymentMethodForm ? 'bunny-w-full' : 'bunny-w-1/2') }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-px-4" }, { children: [jsxRuntime.jsxs(antd.Skeleton, __assign({ loading: isLoadingBillingDetails }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-mb-2" }, { children: jsxRuntime.jsx(Text, __assign({ className: "bunny-font-medium bunny-text-lg" }, { children: (billingDetails === null || billingDetails === void 0 ? void 0 : billingDetails.name) || 'No company name' })) })), jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical", disabled: isUpdatingBillingDetails, autoComplete: "off" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Street address", name: "billingStreet", rules: [{ required: true, message: 'Street address is required' }] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: 'City is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: 'Zipcode is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-row bunny-pb-2' : 'bunny-flex-row', " bunny-gap-4") }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "State", name: "billingState", rules: [
23850
- {
23851
- required: false,
23852
- },
23853
- ] }, { children: jsxRuntime.jsx(antd.Input, {}) })) })), jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Country", name: "billingCountry", rules: [{ required: true, message: 'Country is required' }] }, { children: jsxRuntime.jsx(antd.Select, { className: "bunny-w-full", options: filteredCountryList, placeholder: "Select a country", popupMatchSelectWidth: false, showSearch: true, filterOption: function (input, option) {
23854
- var _a, _b;
23855
- return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(input.toLowerCase()) ||
23856
- ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase());
23857
- } }) })) }))] })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Email", name: "billingContactEmail", rules: [
23858
- {
23859
- required: true,
23860
- message: 'Email is required',
23861
- type: 'email',
23862
- },
23863
- ] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Tax ID", name: "taxNumber", tooltip: "Tax ID will be printed on quotes and invoices below the account's address", rules: [{ required: false }] }, { children: jsxRuntime.jsx(antd.Input, {}) }))] }))] })), jsxRuntime.jsx(antd.Button, __assign({ disabled: !isFormEdited || isUpdatingBillingDetails || !formIsValid, className: "bunny-w-full bunny-mt-4", type: "primary", onClick: saveBillingDetails }, { children: "Save" }))] })) })));
23864
- }
23865
-
23866
- var BillingDetails = function (_a) {
23867
- var className = _a.className, countryListFilter = _a.countryListFilter, _b = _a.hideBillingDetailsForm, hideBillingDetailsForm = _b === void 0 ? false : _b, _c = _a.hidePaymentMethodForm, hidePaymentMethodForm = _c === void 0 ? false : _c, _d = _a.isCardEnabled, isCardEnabled = _d === void 0 ? true : _d, _e = _a.isUpgradeFromTrial, isUpgradeFromTrial = _e === void 0 ? false : _e, _f = _a.shadow, shadow = _f === void 0 ? 'shadow-md' : _f, onSavePaymentMethod = _a.onSavePaymentMethod;
23868
- // Hooks
23869
- var isMobile = common.useIsMobile();
23870
- return (jsxRuntime.jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-py-2 bunny-my-2 ".concat(isMobile ? 'bunny-flex-col bunny-space-y-4' : 'bunny-flex-row', " bunny-gap-4") }, { children: [!hideBillingDetailsForm ? (jsxRuntime.jsx(BillingDetailsSection, { hidePaymentMethodForm: hidePaymentMethodForm, countryListFilter: countryListFilter })) : null, !hideBillingDetailsForm && !hidePaymentMethodForm ? jsxRuntime.jsx(ResponsiveDivider, {}) : null, !hidePaymentMethodForm ? (jsxRuntime.jsx(PaymentFormSection, { hideBillingDetailsForm: hideBillingDetailsForm, isUpgradeFromTrial: isUpgradeFromTrial, onSavePaymentMethod: onSavePaymentMethod })) : null] })) })));
23871
- };
23872
- var WrapperComponent = function (_a) {
23873
- var children = _a.children, isCardEnabled = _a.isCardEnabled, shadow = _a.shadow, className = _a.className;
23874
- return (jsxRuntime.jsx("div", __assign({ className: "".concat(className) }, { children: isCardEnabled ? jsxRuntime.jsx(Card, __assign({ className: "".concat(shadow) }, { children: children })) : jsxRuntime.jsx("div", { children: children }) })));
23875
- };
23876
- var ResponsiveDivider = function () {
23877
- var isMobile = common.useIsMobile();
23878
- return isMobile ? (jsxRuntime.jsx("div", __assign({ className: "bunny-mx-4" }, { children: jsxRuntime.jsx(antd.Divider, {}) }))) : (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(antd.Divider, { className: "bunny-h-full", type: "vertical" }) }));
23879
- };
23880
- var PaymentFormSection = function (_a) {
23881
- var hideBillingDetailsForm = _a.hideBillingDetailsForm, isUpgradeFromTrial = _a.isUpgradeFromTrial, onSavePaymentMethod = _a.onSavePaymentMethod;
23882
- var isMobile = common.useIsMobile();
23883
- var onTokenExpired = react.useContext(BunnyContext).onTokenExpired;
23884
- var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
23885
- var showSuccessNotification = common.useSuccessNotification();
23886
- return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsxRuntime.jsx(PaymentForm, { onFail: function (error) {
23887
- handleAllErrorFormats(error);
23888
- }, onSavePaymentMethod: function (response) {
23889
- showSuccessNotification(isUpgradeFromTrial
23890
- ? 'Payment method saved! Your trial will automatically convert to a paid subscription.'
23891
- : 'Payment method saved successfully!');
23892
- // TODO: onSavePaymentMethod(response: any) should be cleaned up to have a response type (not any)
23893
- // and work with both stripe and demo pay requests
23894
- onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(response);
23895
- } }) })));
23896
- };
23897
-
23898
23819
  exports.BillingDetails = BillingDetails;
23899
23820
  exports.BunnyProvider = BunnyProvider;
23900
23821
  exports.Footer = Footer;