@bunnyapp/components 1.6.0-beta.19 → 1.6.0-beta.20

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 (118) hide show
  1. package/dist/cjs/index.js +1529 -1321
  2. package/dist/cjs/types/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  3. package/dist/cjs/types/src/components/PaymentForm/DemoPay/CreditCard/CreditCard.d.ts +17 -13
  4. package/dist/cjs/types/src/components/PaymentForm/DemoPay/CreditCard/MiniCreditCard.d.ts +27 -0
  5. package/dist/cjs/types/src/components/PaymentForm/DemoPay/CreditCard/components/CardImage.d.ts +14 -0
  6. package/dist/cjs/types/src/components/PaymentForm/DemoPay/CreditCard/index.d.ts +1 -1
  7. package/dist/cjs/types/src/components/PaymentForm/DemoPay/DemoPayForm.d.ts +1 -6
  8. package/dist/cjs/types/src/components/PaymentForm/DemoPay/hooks/useApproveHold.d.ts +1 -1
  9. package/dist/cjs/types/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +4 -4
  10. package/dist/cjs/types/src/components/PaymentForm/DemoPay/hooks/useSave.d.ts +7 -16
  11. package/dist/cjs/types/src/components/PaymentForm/PaymentForm.d.ts +5 -6
  12. package/dist/cjs/types/src/components/PaymentForm/Stripe/StripeForm.d.ts +1 -6
  13. package/dist/cjs/types/src/components/PaymentForm/Stripe/hooks/useApproveHold.d.ts +1 -1
  14. package/dist/cjs/types/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +4 -4
  15. package/dist/cjs/types/src/components/PaymentForm/Stripe/hooks/useSave.d.ts +4 -5
  16. package/dist/cjs/types/src/components/PaymentForm/Stripe/stripeUtils.d.ts +1 -1
  17. package/dist/cjs/types/src/components/PaymentForm/components/CheckoutFooter.d.ts +2 -0
  18. package/dist/cjs/types/src/components/PaymentForm/components/PaymentMethodDetails.d.ts +2 -0
  19. package/dist/cjs/types/src/components/PaymentForm/components/PaymentMethodFooter.d.ts +4 -0
  20. package/dist/cjs/types/src/components/PaymentForm/components/PaymentMethodSelector.d.ts +2 -0
  21. package/dist/cjs/types/src/components/PaymentForm/context/CustomCheckoutFunctionContext.d.ts +5 -0
  22. package/dist/cjs/types/src/components/PaymentForm/context/OverrideTokenContext.d.ts +4 -0
  23. package/dist/cjs/types/src/components/PaymentForm/context/PaymentProvider.d.ts +31 -0
  24. package/dist/cjs/types/src/components/PaymentForm/context/SelectedPaymentPluginContext.d.ts +6 -0
  25. package/dist/cjs/types/src/components/PaymentForm/context/SelectedPluginProvider.d.ts +16 -0
  26. package/dist/cjs/types/src/components/PaymentForm/context/ShowPaymentDetailsContext.d.ts +5 -0
  27. package/dist/cjs/types/src/components/PaymentForm/fragments/PaymentForm_PaymentMethodsFragment.d.ts +10 -0
  28. package/dist/cjs/types/src/components/PaymentForm/hooks/useAutoSetDefaultPaymentMethod.d.ts +2 -5
  29. package/dist/cjs/types/src/components/PaymentForm/hooks/useHandlePayment.d.ts +24 -0
  30. package/dist/cjs/types/src/components/PaymentForm/hooks/usePayableCurrency.d.ts +6 -0
  31. package/dist/cjs/types/src/components/PaymentForm/hooks/useRemovePaymentMethod.d.ts +2 -0
  32. package/dist/cjs/types/src/components/PaymentForm/hooks/useSetDefaultPaymentMethod.d.ts +5 -0
  33. package/dist/cjs/types/src/components/PaymentForm/types/PaymentType.d.ts +5 -0
  34. package/dist/cjs/types/src/components/Signup/PaymentForms.d.ts +3 -4
  35. package/dist/cjs/types/src/components/Subscriptions/Subscriptions.d.ts +1 -1
  36. package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/quantityInput/QuantityInput.d.ts +1 -1
  37. package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/utils/utils.d.ts +1 -1
  38. package/dist/cjs/types/src/graphql/queries/getCurrentUserData.d.ts +11 -7
  39. package/dist/cjs/types/src/hooks/useCurrentUserData.d.ts +11 -7
  40. package/dist/cjs/types/src/hooks/useIsMobile.d.ts +9 -0
  41. package/dist/cjs/types/src/hooks/usePaymentMethod.d.ts +47 -6
  42. package/dist/cjs/types/src/hooks/usePaymentPlugins.d.ts +13 -27
  43. package/dist/cjs/types/src/utils/QueryKeyFactory.d.ts +1 -0
  44. package/dist/cjs/types/src/utils/apiUtils/invokePlugin.d.ts +10 -0
  45. package/dist/esm/index.js +1549 -1341
  46. package/dist/esm/types/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  47. package/dist/esm/types/src/components/PaymentForm/DemoPay/CreditCard/CreditCard.d.ts +17 -13
  48. package/dist/esm/types/src/components/PaymentForm/DemoPay/CreditCard/MiniCreditCard.d.ts +27 -0
  49. package/dist/esm/types/src/components/PaymentForm/DemoPay/CreditCard/components/CardImage.d.ts +14 -0
  50. package/dist/esm/types/src/components/PaymentForm/DemoPay/CreditCard/index.d.ts +1 -1
  51. package/dist/esm/types/src/components/PaymentForm/DemoPay/DemoPayForm.d.ts +1 -6
  52. package/dist/esm/types/src/components/PaymentForm/DemoPay/hooks/useApproveHold.d.ts +1 -1
  53. package/dist/esm/types/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +4 -4
  54. package/dist/esm/types/src/components/PaymentForm/DemoPay/hooks/useSave.d.ts +7 -16
  55. package/dist/esm/types/src/components/PaymentForm/PaymentForm.d.ts +5 -6
  56. package/dist/esm/types/src/components/PaymentForm/Stripe/StripeForm.d.ts +1 -6
  57. package/dist/esm/types/src/components/PaymentForm/Stripe/hooks/useApproveHold.d.ts +1 -1
  58. package/dist/esm/types/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +4 -4
  59. package/dist/esm/types/src/components/PaymentForm/Stripe/hooks/useSave.d.ts +4 -5
  60. package/dist/esm/types/src/components/PaymentForm/Stripe/stripeUtils.d.ts +1 -1
  61. package/dist/esm/types/src/components/PaymentForm/components/CheckoutFooter.d.ts +2 -0
  62. package/dist/esm/types/src/components/PaymentForm/components/PaymentMethodDetails.d.ts +2 -0
  63. package/dist/esm/types/src/components/PaymentForm/components/PaymentMethodFooter.d.ts +4 -0
  64. package/dist/esm/types/src/components/PaymentForm/components/PaymentMethodSelector.d.ts +2 -0
  65. package/dist/esm/types/src/components/PaymentForm/context/CustomCheckoutFunctionContext.d.ts +5 -0
  66. package/dist/esm/types/src/components/PaymentForm/context/OverrideTokenContext.d.ts +4 -0
  67. package/dist/esm/types/src/components/PaymentForm/context/PaymentProvider.d.ts +31 -0
  68. package/dist/esm/types/src/components/PaymentForm/context/SelectedPaymentPluginContext.d.ts +6 -0
  69. package/dist/esm/types/src/components/PaymentForm/context/SelectedPluginProvider.d.ts +16 -0
  70. package/dist/esm/types/src/components/PaymentForm/context/ShowPaymentDetailsContext.d.ts +5 -0
  71. package/dist/esm/types/src/components/PaymentForm/fragments/PaymentForm_PaymentMethodsFragment.d.ts +10 -0
  72. package/dist/esm/types/src/components/PaymentForm/hooks/useAutoSetDefaultPaymentMethod.d.ts +2 -5
  73. package/dist/esm/types/src/components/PaymentForm/hooks/useHandlePayment.d.ts +24 -0
  74. package/dist/esm/types/src/components/PaymentForm/hooks/usePayableCurrency.d.ts +6 -0
  75. package/dist/esm/types/src/components/PaymentForm/hooks/useRemovePaymentMethod.d.ts +2 -0
  76. package/dist/esm/types/src/components/PaymentForm/hooks/useSetDefaultPaymentMethod.d.ts +5 -0
  77. package/dist/esm/types/src/components/PaymentForm/types/PaymentType.d.ts +5 -0
  78. package/dist/esm/types/src/components/Signup/PaymentForms.d.ts +3 -4
  79. package/dist/esm/types/src/components/Subscriptions/Subscriptions.d.ts +1 -1
  80. package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/quantityInput/QuantityInput.d.ts +1 -1
  81. package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/utils/utils.d.ts +1 -1
  82. package/dist/esm/types/src/graphql/queries/getCurrentUserData.d.ts +11 -7
  83. package/dist/esm/types/src/hooks/useCurrentUserData.d.ts +11 -7
  84. package/dist/esm/types/src/hooks/useIsMobile.d.ts +9 -0
  85. package/dist/esm/types/src/hooks/usePaymentMethod.d.ts +47 -6
  86. package/dist/esm/types/src/hooks/usePaymentPlugins.d.ts +13 -27
  87. package/dist/esm/types/src/utils/QueryKeyFactory.d.ts +1 -0
  88. package/dist/esm/types/src/utils/apiUtils/invokePlugin.d.ts +10 -0
  89. package/dist/index.d.ts +26 -9
  90. package/package.json +1 -1
  91. package/dist/cjs/types/src/components/PaymentForm/CheckoutFooter.d.ts +0 -13
  92. package/dist/cjs/types/src/components/PaymentForm/DemoPay/CreditCard/LargCardIcon.d.ts +0 -2
  93. package/dist/cjs/types/src/components/PaymentForm/DemoPay/CreditCard/PlusIcon.d.ts +0 -4
  94. package/dist/cjs/types/src/components/PaymentForm/PaymentMethodDetails.d.ts +0 -7
  95. package/dist/cjs/types/src/components/PaymentForm/PaymentMethodSelector.d.ts +0 -7
  96. package/dist/cjs/types/src/components/PaymentForm/SavePaymentMethodFooter.d.ts +0 -6
  97. package/dist/cjs/types/src/components/PaymentForm/Stripe/PaymentMethodForm.d.ts +0 -7
  98. package/dist/cjs/types/src/components/PaymentForm/hooks/usePaymentMethodSelectorPlugin.d.ts +0 -10
  99. package/dist/cjs/types/src/components/PaymentForm/useRemovePaymentMethod.d.ts +0 -3
  100. package/dist/cjs/types/src/components/PaymentForm/useSetDefaultPaymentMethod.d.ts +0 -6
  101. package/dist/cjs/types/src/contexts/PaymentContext.d.ts +0 -10
  102. package/dist/esm/types/src/components/PaymentForm/CheckoutFooter.d.ts +0 -13
  103. package/dist/esm/types/src/components/PaymentForm/DemoPay/CreditCard/LargCardIcon.d.ts +0 -2
  104. package/dist/esm/types/src/components/PaymentForm/DemoPay/CreditCard/PlusIcon.d.ts +0 -4
  105. package/dist/esm/types/src/components/PaymentForm/PaymentMethodDetails.d.ts +0 -7
  106. package/dist/esm/types/src/components/PaymentForm/PaymentMethodSelector.d.ts +0 -7
  107. package/dist/esm/types/src/components/PaymentForm/SavePaymentMethodFooter.d.ts +0 -6
  108. package/dist/esm/types/src/components/PaymentForm/Stripe/PaymentMethodForm.d.ts +0 -7
  109. package/dist/esm/types/src/components/PaymentForm/hooks/usePaymentMethodSelectorPlugin.d.ts +0 -10
  110. package/dist/esm/types/src/components/PaymentForm/useRemovePaymentMethod.d.ts +0 -3
  111. package/dist/esm/types/src/components/PaymentForm/useSetDefaultPaymentMethod.d.ts +0 -6
  112. package/dist/esm/types/src/contexts/PaymentContext.d.ts +0 -10
  113. /package/dist/cjs/types/src/components/PaymentForm/{CouponEditor.d.ts → components/CouponEditor.d.ts} +0 -0
  114. /package/dist/cjs/types/src/components/PaymentForm/{PaymentFormTypes.d.ts → types/PaymentFormTypes.d.ts} +0 -0
  115. /package/dist/cjs/types/src/utils/{apiUtils.d.ts → apiUtils/apiUtils.d.ts} +0 -0
  116. /package/dist/esm/types/src/components/PaymentForm/{CouponEditor.d.ts → components/CouponEditor.d.ts} +0 -0
  117. /package/dist/esm/types/src/components/PaymentForm/{PaymentFormTypes.d.ts → types/PaymentFormTypes.d.ts} +0 -0
  118. /package/dist/esm/types/src/utils/{apiUtils.d.ts → apiUtils/apiUtils.d.ts} +0 -0
package/dist/cjs/index.js CHANGED
@@ -143,7 +143,7 @@ const useAllErrorFormats = () => {
143
143
  };
144
144
 
145
145
  // This will be replaced at build time by rollup-plugin-replace
146
- const PACKAGE_VERSION = '1.6.0-beta.18';
146
+ const PACKAGE_VERSION = '1.6.0-beta.19';
147
147
  const createRequestHeaders = (token) => {
148
148
  const headers = createClientDevHeaders({ token });
149
149
  // Add the components version header
@@ -241,6 +241,8 @@ const useDownloadFile = (id, onError) => {
241
241
 
242
242
  const InvoiceQuoteContext = react.createContext({});
243
243
 
244
+ const OverrideTokenContext = react.createContext({});
245
+
244
246
  /**
245
247
  * Creates a context and provider for a value
246
248
  * Unlike createStateContext, this accepts a value prop directly that can be updated
@@ -927,7 +929,7 @@ function readFragment(...r) {
927
929
 
928
930
  var t = initGraphQLTada();
929
931
 
930
- const query$4 = t(`
932
+ const query$6 = t(`
931
933
  query entityBranding {
932
934
  entityBranding {
933
935
  accentColor
@@ -937,7 +939,7 @@ const query$4 = t(`
937
939
  }
938
940
  `);
939
941
  const getBranding = async ({ token, apiHost }) => {
940
- return await execute(query$4, { apiHost, token }, {});
942
+ return await execute(query$6, { apiHost, token }, {});
941
943
  };
942
944
 
943
945
  const BunnyContext = react.createContext({});
@@ -1025,14 +1027,12 @@ function ContextualWrapper({ children, darkMode, configProviderProps, }) {
1025
1027
  return (jsxRuntime.jsx(recoil.RecoilRoot, { children: jsxRuntime.jsx(BrandProvider, { value: entityBranding, children: jsxRuntime.jsx(antd.ConfigProvider, { theme: mergedTheme, children: jsxRuntime.jsx("div", { className: "bunny-components bunny-contents", children: children }) }) }) }));
1026
1028
  }
1027
1029
 
1028
- const PaymentContext = react.createContext({});
1029
-
1030
1030
  // Use this hook instead of getting the token from BunnyContext directly
1031
1031
  // Because we have overrideToken as an option, this token ensures the correct token is used
1032
1032
  function useToken() {
1033
1033
  const { token: tokenFromContext } = react.useContext(BunnyContext);
1034
- const { overrideToken } = react.useContext(PaymentContext);
1035
- return overrideToken || tokenFromContext;
1034
+ const { overrideToken } = react.useContext(OverrideTokenContext);
1035
+ return overrideToken !== null && overrideToken !== void 0 ? overrideToken : tokenFromContext;
1036
1036
  }
1037
1037
 
1038
1038
  const defaultStyled = typeof styled === "function" ? styled : styled.default;
@@ -1146,7 +1146,7 @@ const InvoiceQuoteView = ({ children, formattedInvoice, html, backButtonName, on
1146
1146
  }, children: [targetUrl ? (jsxRuntime.jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsxRuntime.jsx(interweave.Markup, { content: html })), children] }))] }));
1147
1147
  };
1148
1148
 
1149
- const MUTATION$b = `
1149
+ const MUTATION$a = `
1150
1150
  query FormattedInvoice($id: ID) {
1151
1151
  formattedInvoice(id: $id) {
1152
1152
  amount
@@ -1214,7 +1214,7 @@ query FormattedInvoice($id: ID) {
1214
1214
  const getFormattedInvoice = async ({ id, token, apiHost, }) => {
1215
1215
  const vars = { id };
1216
1216
  const response = await gqlRequest({
1217
- query: MUTATION$b,
1217
+ query: MUTATION$a,
1218
1218
  token,
1219
1219
  vars,
1220
1220
  apiHost,
@@ -1260,603 +1260,34 @@ function LegacyDocument({ documentUuid, documentType, }) {
1260
1260
  }, title: "Invoice PDF", width: "100%" }));
1261
1261
  }
1262
1262
 
1263
- const MUTATION$a = `
1264
- mutation checkout(
1265
- $invoiceId: ID,
1266
- $quoteId: ID,
1267
- $paymentMethodId: ID,
1268
- $paymentMethodData: CheckoutPaymentMethodAttributes
1269
- ) {
1270
- checkout(
1271
- invoiceId: $invoiceId,
1272
- quoteId: $quoteId,
1273
- paymentMethodId: $paymentMethodId,
1274
- paymentMethodData: $paymentMethodData
1275
- ) {
1276
- invoice {
1277
- id
1278
- state
1279
- amount
1280
- amountDue
1281
- }
1282
- payment {
1283
- id
1284
- state
1285
- amount
1286
- }
1287
- paymentApplication {
1288
- id
1289
- invoiceId
1290
- paymentId
1291
- }
1292
- transaction {
1293
- id
1294
- amount
1295
- }
1296
- }
1297
- }
1298
- `;
1299
- const checkout = async ({ quoteId, invoiceId, paymentMethodId, paymentMethodData, token, apiHost, }) => {
1300
- const mutationVars = {
1301
- quoteId,
1302
- invoiceId,
1303
- paymentMethodId,
1304
- };
1305
- if (paymentMethodData) {
1306
- mutationVars.paymentMethodData = {
1307
- ...paymentMethodData,
1308
- metadata: paymentMethodData.metadata,
1309
- };
1310
- }
1311
- const response = await gqlRequest({
1312
- query: MUTATION$a,
1313
- token,
1314
- vars: mutationVars,
1315
- apiHost: apiHost,
1316
- });
1317
- const { errors } = response === null || response === void 0 ? void 0 : response.checkout;
1318
- if (errors)
1319
- throw errors;
1320
- return {
1321
- savePaymentMethod: paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.savePaymentMethod,
1322
- };
1323
- };
1263
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1324
1264
 
1325
- const CURRENT_USER_DATA_QUERY = `{
1326
- company {
1327
- name
1328
- }
1329
- currentUser {
1330
- account {
1331
- billingCountry
1332
- currencyId
1333
- id
1334
- }
1335
- authObjectName
1336
- payload {
1337
- returnUrl
1338
- }
1339
- privacyUrl
1340
- termsUrl
1341
- entityId
1342
- }
1343
- }`;
1344
- const getCurrentUserData = async ({ token, apiHost }) => {
1345
- var _a, _b, _c, _d, _e, _f, _g, _h;
1346
- const response = await gqlRequest({
1347
- query: CURRENT_USER_DATA_QUERY,
1348
- token,
1349
- apiHost,
1350
- });
1351
- return {
1352
- authObjectName: (_a = response === null || response === void 0 ? void 0 : response.currentUser) === null || _a === void 0 ? void 0 : _a.authObjectName,
1353
- account: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.account,
1354
- companyName: (_c = response === null || response === void 0 ? void 0 : response.company) === null || _c === void 0 ? void 0 : _c.name,
1355
- returnUrl: (_e = (_d = response === null || response === void 0 ? void 0 : response.currentUser) === null || _d === void 0 ? void 0 : _d.payload) === null || _e === void 0 ? void 0 : _e.returnUrl,
1356
- privacyUrl: (_f = response === null || response === void 0 ? void 0 : response.currentUser) === null || _f === void 0 ? void 0 : _f.privacyUrl,
1357
- termsUrl: (_g = response === null || response === void 0 ? void 0 : response.currentUser) === null || _g === void 0 ? void 0 : _g.termsUrl,
1358
- entityId: (_h = response === null || response === void 0 ? void 0 : response.currentUser) === null || _h === void 0 ? void 0 : _h.entityId,
1359
- };
1360
- };
1265
+ function getDefaultExportFromCjs (x) {
1266
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1267
+ }
1361
1268
 
1362
- const useCurrentUserData = (token) => {
1363
- const { apiHost } = react.useContext(BunnyContext);
1364
- const { data: currentUserData, isLoading: isCurrentUserDataLoading } = reactQuery.useQuery({
1365
- queryKey: common.QueryKeyFactory.default.currentUserKey(token),
1366
- queryFn: () => getCurrentUserData({ token, apiHost }),
1367
- enabled: Boolean(token),
1368
- });
1369
- const currentUser = currentUserData || {};
1370
- return { currentUser, isCurrentUserDataLoading };
1371
- };
1269
+ var lodash$1 = {exports: {}};
1372
1270
 
1373
- const paymentMethodsQuery = () => `query PaymentMethods($accountId: ID) {
1374
- paymentMethods (accountId: $accountId) {
1375
- nodes {
1376
- id
1377
- pluginId
1378
- accountId
1379
- expirationDate
1380
- plugin {
1381
- guid
1382
- id
1383
- }
1384
- state
1385
- metadata {
1386
- issuer
1387
- identifier
1388
- kind
1389
- description
1390
- icon
1391
- type
1392
- }
1393
- isDefault
1394
- }
1395
- }
1396
- }`;
1397
- const getPaymentMethods = async ({ apiHost, token, accountId, }) => {
1398
- var _a;
1399
- const response = await gqlRequest({
1400
- query: paymentMethodsQuery(),
1401
- token,
1402
- apiHost,
1403
- vars: { accountId },
1404
- });
1405
- const paymentMethods = ((_a = response === null || response === void 0 ? void 0 : response.paymentMethods) === null || _a === void 0 ? void 0 : _a.nodes) || [];
1406
- return paymentMethods;
1407
- };
1408
- const usePaymentMethod = ({ accountId, token, apiHost, enabled = true, }) => {
1409
- const { data, isLoading } = reactQuery.useQuery({
1410
- queryKey: common.QueryKeyFactory.default.accountPaymentMethodsKey({
1411
- accountId,
1412
- token,
1413
- }),
1414
- queryFn: () => getPaymentMethods({ apiHost, token, accountId }),
1415
- staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
1416
- enabled,
1417
- });
1418
- return {
1419
- paymentMethods: data,
1420
- defaultPaymentMethod: data === null || data === void 0 ? void 0 : data.find((paymentMethod) => paymentMethod.isDefault),
1421
- isLoading,
1422
- };
1423
- };
1271
+ /**
1272
+ * @license
1273
+ * Lodash <https://lodash.com/>
1274
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1275
+ * Released under MIT license <https://lodash.com/license>
1276
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1277
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1278
+ */
1279
+ var lodash = lodash$1.exports;
1424
1280
 
1425
- const filterPaymentPlugins = (plugins) => plugins === null || plugins === void 0 ? void 0 : plugins.filter((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'; });
1426
- const MUTATION$9 = `query PaymentPlugins($accountId: ID) {
1427
- paymentPlugins (accountId: $accountId) {
1428
- enabled
1429
- entities
1430
- guid
1431
- hidden
1432
- id
1433
- name
1434
- status
1435
- type
1436
- webhookEnabled
1437
- components
1438
- }
1439
- }`;
1440
- const getPaymentPlugins = async ({ apiHost, token, accountId, }) => {
1441
- try {
1442
- const response = await gqlRequest({
1443
- query: MUTATION$9,
1444
- token,
1445
- apiHost,
1446
- vars: { accountId },
1447
- });
1448
- return (response === null || response === void 0 ? void 0 : response.paymentPlugins) || [];
1449
- }
1450
- catch (error) {
1451
- return [];
1452
- }
1453
- };
1454
- const usePaymentPlugins = ({ apiHost, token, accountId, }) => {
1455
- const { data: paymentPlugins, isFetched } = reactQuery.useQuery({
1456
- queryKey: ['paymentPlugins', token],
1457
- queryFn: () => getPaymentPlugins({ apiHost, token, accountId }),
1458
- staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
1459
- });
1460
- const filteredPaymentPlugins = filterPaymentPlugins(paymentPlugins);
1461
- return {
1462
- paymentPlugins: filteredPaymentPlugins,
1463
- isFetched,
1464
- };
1465
- };
1281
+ var hasRequiredLodash;
1466
1282
 
1467
- const getQuoteAmountDue = (quote) => {
1468
- return quote.amountDue || quote.amount;
1469
- };
1283
+ function requireLodash () {
1284
+ if (hasRequiredLodash) return lodash$1.exports;
1285
+ hasRequiredLodash = 1;
1286
+ (function (module, exports) {
1287
+ (function() {
1470
1288
 
1471
- function usePay$1({ onPaymentSuccess, onPaymentError, quote, invoice, storedPaymentMethod, plugin, }) {
1472
- const { apiHost } = react.useContext(BunnyContext);
1473
- const { customCheckoutFunction } = react.useContext(PaymentContext);
1474
- const token = useToken();
1475
- const pay = async () => {
1476
- const currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId);
1477
- if (!currencyId) {
1478
- throw new Error('No currencyId');
1479
- }
1480
- try {
1481
- if (customCheckoutFunction) {
1482
- const response = await customCheckoutFunction(plugin);
1483
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
1484
- }
1485
- else {
1486
- const response = await checkout({
1487
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
1488
- quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
1489
- paymentMethodId: storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.id,
1490
- token,
1491
- apiHost,
1492
- });
1493
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
1494
- }
1495
- }
1496
- catch (error) {
1497
- onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error);
1498
- }
1499
- };
1500
- return { pay };
1501
- }
1502
-
1503
- const { useToken: useAntdToken } = antd.theme;
1504
- const createPaymentMethod = async ({ paymentMethodId, plugin, token, apiHost, accountId, }) => {
1505
- const response = await common.invokePlugin({
1506
- plugin,
1507
- method: 'store_payment_method',
1508
- payload: {
1509
- payment_method_id: paymentMethodId,
1510
- account_id: accountId,
1511
- },
1512
- token,
1513
- apiHost,
1514
- });
1515
- if (response.status !== 'success')
1516
- throw new Error(response.message || 'Unknown error');
1517
- return response;
1518
- };
1519
- const createSetupIntent = (plugin, apiHost, token, accountId) => {
1520
- return common.invokePlugin({
1521
- plugin,
1522
- method: 'create_setup_intent',
1523
- token,
1524
- apiHost,
1525
- payload: {
1526
- account_id: accountId,
1527
- },
1528
- });
1529
- };
1530
- const createPaymentHold = async ({ quote, plugin, token, apiHost, paymentMethodId, }) => {
1531
- const payload = {
1532
- quote_id: quote.id,
1533
- amount: quote.amount,
1534
- payment_method_id: paymentMethodId,
1535
- };
1536
- const response = await common.invokePlugin({
1537
- plugin,
1538
- method: 'create_payment_hold',
1539
- payload,
1540
- token,
1541
- apiHost,
1542
- });
1543
- if (response.status !== 'success')
1544
- throw new Error(response.message || 'Unknown error');
1545
- return response;
1546
- };
1547
- const fetchStripeKey = async (plugin, apiHost, token, accountId) => {
1548
- const response = await common.invokePlugin({
1549
- plugin,
1550
- method: 'retrieve_config',
1551
- token,
1552
- apiHost,
1553
- payload: {
1554
- account_id: accountId,
1555
- },
1556
- });
1557
- return response;
1558
- };
1559
- index_js.loadStripe.setLoadParameters({ advancedFraudSignals: false });
1560
- const useStripePlugin = (plugin, apiHost, currencyId, token, accountId) => {
1561
- const [stripe, setStripe] = react.useState(null);
1562
- const showErrorNotification = common.useErrorNotification();
1563
- const { token: antdToken } = useAntdToken();
1564
- function getFontFamily() {
1565
- if (antdToken.fontFamily === 'Inter') {
1566
- return 'var(--font-inter, Inter), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
1567
- }
1568
- return antdToken.fontFamily;
1569
- }
1570
- const fontFamily = getFontFamily();
1571
- const appearance = {
1572
- variables: {
1573
- fontFamily: fontFamily,
1574
- fontLineHeight: antdToken.lineHeight.toString(),
1575
- borderRadius: antdToken.borderRadius.toString() + 'px',
1576
- colorBackground: 'white',
1577
- colorPrimary: antdToken.colorPrimary,
1578
- },
1579
- rules: {
1580
- '.Input': {
1581
- fontFamily: fontFamily,
1582
- },
1583
- '.Label': {
1584
- fontFamily: fontFamily,
1585
- },
1586
- },
1587
- };
1588
- const options = {
1589
- mode: 'setup',
1590
- currency: currencyId,
1591
- setupFutureUsage: 'off_session',
1592
- appearance,
1593
- };
1594
- react.useEffect(() => {
1595
- var _a, _b;
1596
- if (!plugin)
1597
- return;
1598
- if (((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) !== 'StripePayment')
1599
- return;
1600
- fetchStripeKey(plugin, apiHost || '', token, accountId)
1601
- .then(({ payload }) => index_js.loadStripe(payload.publishable_key).then(setStripe))
1602
- .catch(error => {
1603
- console.error('Caught Error in fetching stripe key: ', error);
1604
- showErrorNotification(error.message, 'Unexpected Error fetching key');
1605
- });
1606
- // eslint-disable-next-line
1607
- }, [plugin, token]);
1608
- return { stripe, options };
1609
- };
1610
-
1611
- function useApproveHold$1({ onApproveHoldSuccess, onApproveHoldError, }) {
1612
- // Hooks
1613
- const [isSaving, setIsSaving] = react.useState(false);
1614
- const { apiHost } = react.useContext(BunnyContext);
1615
- const token = useToken();
1616
- const approveHold = async ({ plugin, quote, paymentMethodId, }) => {
1617
- try {
1618
- if (!token)
1619
- throw new Error("Token couldn't be retrieved");
1620
- setIsSaving(true);
1621
- const response = await createPaymentHold({
1622
- quote,
1623
- plugin,
1624
- token,
1625
- apiHost,
1626
- paymentMethodId,
1627
- });
1628
- if (response.status !== 'success')
1629
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
1630
- onApproveHoldSuccess === null || onApproveHoldSuccess === void 0 ? void 0 : onApproveHoldSuccess(response);
1631
- }
1632
- catch (error) {
1633
- console.error(error);
1634
- onApproveHoldError === null || onApproveHoldError === void 0 ? void 0 : onApproveHoldError(error);
1635
- }
1636
- finally {
1637
- setIsSaving(false);
1638
- }
1639
- };
1640
- return { approveHold, isSaving };
1641
- }
1642
-
1643
- function useApproveHold({ onApproveHoldSuccess, onApproveHoldError, }) {
1644
- // Hooks
1645
- const [isSaving, setIsSaving] = react.useState(false);
1646
- const { apiHost } = react.useContext(BunnyContext);
1647
- const token = useToken();
1648
- const approveHold = async ({ plugin, quote, paymentMethodId, }) => {
1649
- try {
1650
- if (!token)
1651
- throw new Error("Token couldn't be retrieved");
1652
- setIsSaving(true);
1653
- const response = await createPaymentHold({
1654
- quote,
1655
- plugin,
1656
- token,
1657
- apiHost,
1658
- paymentMethodId,
1659
- });
1660
- if (response.status !== 'success')
1661
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
1662
- onApproveHoldSuccess === null || onApproveHoldSuccess === void 0 ? void 0 : onApproveHoldSuccess(response);
1663
- }
1664
- catch (error) {
1665
- console.error(error);
1666
- onApproveHoldError === null || onApproveHoldError === void 0 ? void 0 : onApproveHoldError(error);
1667
- }
1668
- finally {
1669
- setIsSaving(false);
1670
- }
1671
- };
1672
- return { approveHold, isSaving };
1673
- }
1674
-
1675
- function usePay({ onPaymentSuccess, onPaymentError, quote, invoice, storedPaymentMethod, plugin, }) {
1676
- // Hooks
1677
- const { apiHost } = react.useContext(BunnyContext);
1678
- const { customCheckoutFunction } = react.useContext(PaymentContext);
1679
- const token = useToken();
1680
- const pay = async () => {
1681
- try {
1682
- if (customCheckoutFunction) {
1683
- const response = await customCheckoutFunction(plugin);
1684
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
1685
- }
1686
- else {
1687
- const response = await checkout({
1688
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
1689
- quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
1690
- paymentMethodId: storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.id,
1691
- token,
1692
- apiHost,
1693
- });
1694
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
1695
- }
1696
- }
1697
- catch (error) {
1698
- onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error);
1699
- }
1700
- };
1701
- return { pay };
1702
- }
1703
-
1704
- const handleAllErrorFormats = common.useAllErrorFormats();
1705
- const showErrorNotification$5 = common.useErrorNotification();
1706
- const ActualCheckoutFooter = ({ quote, invoice, onPaymentSuccess, onPaymentHoldSuccess, plugin, paymentHoldOptions, }) => {
1707
- const isMobile = common.useIsMobile();
1708
- const [isPaying, setIsPaying] = react.useState(false);
1709
- const { defaultPaymentMethod } = react.useContext(PaymentContext);
1710
- const amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
1711
- const currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId);
1712
- // Payment hooks
1713
- const { pay: payDemoPay } = usePay$1({
1714
- onPaymentSuccess,
1715
- onPaymentError: error => {
1716
- setIsPaying(false);
1717
- handleAllErrorFormats(error);
1718
- },
1719
- quote: quote,
1720
- invoice: invoice,
1721
- storedPaymentMethod: defaultPaymentMethod,
1722
- plugin,
1723
- });
1724
- const { pay: payStripe } = usePay({
1725
- onPaymentSuccess,
1726
- onPaymentError: error => {
1727
- setIsPaying(false);
1728
- handleAllErrorFormats(error);
1729
- },
1730
- quote: quote,
1731
- invoice: invoice,
1732
- storedPaymentMethod: defaultPaymentMethod,
1733
- plugin,
1734
- });
1735
- // Approve hold hooks
1736
- const { approveHold: approveHoldStripe } = useApproveHold$1({
1737
- onApproveHoldSuccess: response => {
1738
- onPaymentHoldSuccess === null || onPaymentHoldSuccess === void 0 ? void 0 : onPaymentHoldSuccess(response);
1739
- },
1740
- onApproveHoldError: error => {
1741
- setIsPaying(false);
1742
- handleAllErrorFormats(error);
1743
- },
1744
- });
1745
- const { approveHold: approveHoldDemoPay } = useApproveHold({
1746
- onApproveHoldSuccess: response => {
1747
- onPaymentHoldSuccess === null || onPaymentHoldSuccess === void 0 ? void 0 : onPaymentHoldSuccess(response);
1748
- },
1749
- onApproveHoldError: error => {
1750
- setIsPaying(false);
1751
- handleAllErrorFormats(error);
1752
- },
1753
- });
1754
- const handleApproveHold = async () => {
1755
- var _a, _b, _c, _d;
1756
- if (!plugin)
1757
- return console.error('plugin is undefined');
1758
- if (!quote)
1759
- return console.error('quote is undefined');
1760
- if (!(defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id))
1761
- return console.error('defaultPaymentMethod is undefined');
1762
- switch ((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) {
1763
- case 'StripePayment':
1764
- setIsPaying(true);
1765
- await approveHoldStripe({
1766
- plugin,
1767
- quote,
1768
- paymentMethodId: defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id,
1769
- });
1770
- break;
1771
- case 'DemoPayPayment':
1772
- setIsPaying(true);
1773
- await approveHoldDemoPay({
1774
- plugin,
1775
- quote,
1776
- paymentMethodId: defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id,
1777
- });
1778
- break;
1779
- default:
1780
- showErrorNotification$5(`Payment holds are not supported by ${(_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d[0].name}`);
1781
- break;
1782
- }
1783
- };
1784
- const handlePaymentSubmit = async () => {
1785
- var _a, _b;
1786
- setIsPaying(true);
1787
- if (!plugin)
1788
- return;
1789
- switch ((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) {
1790
- case 'StripePayment':
1791
- await payStripe();
1792
- break;
1793
- case 'DemoPayPayment':
1794
- await payDemoPay();
1795
- break;
1796
- }
1797
- };
1798
- if (paymentHoldOptions === null || paymentHoldOptions === void 0 ? void 0 : paymentHoldOptions.payToAccept) {
1799
- return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isPaying, onClick: () => {
1800
- handleApproveHold();
1801
- }, size: isMobile ? 'large' : 'middle', type: "primary", children: `${isPaying ? 'Approving hold for' : 'Approve hold for'} ${amountDue && currencyId ? common.formatCurrency(amountDue, currencyId) : ''}` }));
1802
- }
1803
- return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isPaying, onClick: () => {
1804
- setIsPaying(true);
1805
- handlePaymentSubmit();
1806
- }, size: isMobile ? 'large' : 'middle', type: "primary", children: `${isPaying ? 'Paying' : 'Pay'} ${amountDue && currencyId ? common.formatCurrency(amountDue, currencyId) : ''}` }));
1807
- };
1808
- const CheckoutFooter = ({ quote, invoice, onPaymentSuccess, onPaymentHoldSuccess, plugin, paymentHoldOptions, }) => {
1809
- if (!plugin)
1810
- return null;
1811
- return (jsxRuntime.jsx(ActualCheckoutFooter, { paymentHoldOptions: paymentHoldOptions, plugin: plugin, invoice: invoice, quote: quote, onPaymentSuccess: onPaymentSuccess, onPaymentHoldSuccess: onPaymentHoldSuccess }));
1812
- };
1813
-
1814
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1815
-
1816
- function getDefaultExportFromCjs (x) {
1817
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1818
- }
1819
-
1820
- var dayjs_min$1 = {exports: {}};
1821
-
1822
- var dayjs_min = dayjs_min$1.exports;
1823
-
1824
- var hasRequiredDayjs_min;
1825
-
1826
- function requireDayjs_min () {
1827
- if (hasRequiredDayjs_min) return dayjs_min$1.exports;
1828
- hasRequiredDayjs_min = 1;
1829
- (function (module, exports) {
1830
- !function(t,e){module.exports=e();}(dayjs_min,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
1831
- } (dayjs_min$1));
1832
- return dayjs_min$1.exports;
1833
- }
1834
-
1835
- var dayjs_minExports = requireDayjs_min();
1836
- var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
1837
-
1838
- var lodash$1 = {exports: {}};
1839
-
1840
- /**
1841
- * @license
1842
- * Lodash <https://lodash.com/>
1843
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1844
- * Released under MIT license <https://lodash.com/license>
1845
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1846
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1847
- */
1848
- var lodash = lodash$1.exports;
1849
-
1850
- var hasRequiredLodash;
1851
-
1852
- function requireLodash () {
1853
- if (hasRequiredLodash) return lodash$1.exports;
1854
- hasRequiredLodash = 1;
1855
- (function (module, exports) {
1856
- (function() {
1857
-
1858
- /** Used as a safe reference for `undefined` in pre-ES5 environments. */
1859
- var undefined$1;
1289
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
1290
+ var undefined$1;
1860
1291
 
1861
1292
  /** Used as the semantic version number. */
1862
1293
  var VERSION = '4.17.21';
@@ -19046,311 +18477,1234 @@ function requireLodash () {
19046
18477
 
19047
18478
  var lodashExports = requireLodash();
19048
18479
 
19049
- const Card = ({ children, className, style, }) => {
18480
+ const Amex = ({ className }) => {
18481
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "#1F72CD", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", clipRule: "evenodd", d: "M12.5493 17L6 31.4935H13.8405L14.8125 29.1826H17.0342L18.0062 31.4935H26.6364V29.7298L27.4054 31.4935H31.8696L32.6386 29.6925V31.4935H50.587L52.7695 29.2426L54.813 31.4935L64.0317 31.5121L57.4617 24.2872L64.0317 17H54.956L52.8315 19.2093L50.8523 17H31.3268L29.6501 20.7409L27.9341 17H20.11V18.7037L19.2396 17H12.5493ZM39.3516 19.0581H49.6584L52.8108 22.4633L56.0648 19.0581H59.2172L54.4275 24.2852L59.2172 29.452H55.9218L52.7695 26.0073L49.4989 29.452H39.3516V19.0581ZM41.8968 23.1099V21.2114V21.2096H48.328L51.1342 24.2458L48.2036 27.2986H41.8968V25.226H47.5197V23.1099H41.8968ZM14.0664 19.0581H17.8883L22.2324 28.8862V19.0581H26.4191L29.7745 26.1048L32.8668 19.0581H37.0326V29.4581H34.4978L34.4771 21.3087L30.7817 29.4581H28.5142L24.7981 21.3087V29.4581H19.5836L18.595 27.1266H13.254L12.2675 29.4561H9.47358L14.0664 19.0581ZM14.166 24.9712L15.9256 20.8177L17.6832 24.9712H14.166Z", fill: "white" })] }));
18482
+ };
18483
+
18484
+ const Bancontact = ({ className }) => {
18485
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M18.2243 35.1715C18.2243 34.882 18.156 34.6314 18.0199 34.4199C17.8835 34.2083 17.7043 34.0468 17.4819 33.9355C17.7043 33.8242 17.8766 33.6597 17.9991 33.4426C18.1214 33.2255 18.1825 32.9806 18.1825 32.7078V32.5575C18.1825 32.2233 18.1186 31.9451 17.9908 31.7223C17.8628 31.4996 17.6833 31.3213 17.4526 31.1878C17.2219 31.0541 16.9451 30.9582 16.6227 30.8995C16.3 30.8411 15.9414 30.812 15.5465 30.812C15.4131 30.812 15.274 30.8147 15.1296 30.8203C14.9848 30.8258 14.8445 30.8328 14.7083 30.8411C14.572 30.8494 14.4468 30.8593 14.3329 30.8704C14.2188 30.8817 14.1256 30.8928 14.0534 30.9037C13.8921 30.9318 13.7781 30.9817 13.7114 31.0541C13.6448 31.1266 13.6113 31.2575 13.6113 31.4467V36.5245C13.6113 36.7139 13.646 36.8447 13.7156 36.917C13.7851 36.9895 13.9032 37.0394 14.0702 37.0673C14.1535 37.084 14.2536 37.0979 14.3704 37.1091C14.4871 37.1202 14.6136 37.1299 14.7499 37.1383C14.8862 37.1466 15.0265 37.1535 15.1711 37.1593C15.3158 37.1646 15.4575 37.1676 15.5966 37.1676C15.9581 37.1676 16.2986 37.1397 16.6185 37.084C16.9381 37.0285 17.2161 36.9295 17.4526 36.7874C17.689 36.6456 17.8766 36.4534 18.0157 36.2113C18.1546 35.969 18.2243 35.6642 18.2243 35.2967V35.1715ZM16.8063 32.7746C16.8063 32.8637 16.7924 32.9487 16.7645 33.0293C16.7366 33.11 16.6909 33.1795 16.627 33.2383C16.5629 33.2966 16.4768 33.3439 16.3684 33.38C16.2599 33.4162 16.1222 33.4343 15.9554 33.4343H15.0213V31.9895C15.049 31.9895 15.0921 31.9883 15.1505 31.9853C15.2089 31.9825 15.27 31.9812 15.3339 31.9812H15.6551C16.0833 31.9812 16.3822 32.0354 16.5518 32.144C16.7214 32.2526 16.8063 32.421 16.8063 32.6492V32.7746ZM16.5935 35.8062C16.7576 35.6782 16.8397 35.4971 16.8397 35.2634V35.1714C16.8397 34.971 16.7756 34.797 16.6478 34.6494C16.5198 34.502 16.289 34.4282 15.9554 34.4282H15.0213V35.9898H15.1671C15.231 35.9898 15.2977 35.9916 15.3673 35.9942C15.4368 35.9969 15.5035 35.9985 15.5676 35.9985H15.7051C16.1333 35.9985 16.4295 35.9343 16.5935 35.8062ZM22.7955 33.9438C22.7955 33.6377 22.7496 33.3772 22.6578 33.1629C22.5662 32.9487 22.4368 32.7732 22.27 32.6367C22.1032 32.5004 21.8988 32.4003 21.6568 32.3362C21.415 32.2722 21.1439 32.2401 20.8436 32.2401C20.5654 32.2401 20.2943 32.2597 20.0303 32.2987C19.766 32.3375 19.556 32.3766 19.4005 32.4154C19.2948 32.4435 19.242 32.5046 19.242 32.5991V33.2756C19.242 33.3314 19.2559 33.3705 19.2837 33.3925C19.3115 33.4149 19.3475 33.4261 19.3922 33.4261H19.4337C19.5006 33.4204 19.5839 33.4135 19.684 33.4051C19.7842 33.3968 19.8968 33.3901 20.022 33.3842C20.1471 33.3788 20.2777 33.3746 20.414 33.3717C20.5501 33.3689 20.6851 33.3675 20.8186 33.3675C21.0131 33.3675 21.1661 33.4038 21.2773 33.4761C21.3885 33.5486 21.4441 33.7045 21.4441 33.9438V34.2445H20.9937C20.2763 34.2445 19.7549 34.3572 19.4296 34.5827C19.1043 34.8081 18.9416 35.1659 18.9416 35.6558V35.7313C18.9416 36.0039 18.982 36.2321 19.0625 36.4158C19.1431 36.5996 19.2503 36.7472 19.3837 36.8587C19.5172 36.9699 19.6686 37.0493 19.8384 37.0964C20.008 37.1438 20.1846 37.1676 20.3681 37.1676C20.6184 37.1676 20.8339 37.1341 21.0145 37.0673C21.1952 37.0005 21.3662 36.9086 21.5276 36.7917V36.9253C21.5276 36.9699 21.5442 37.0089 21.5776 37.0422C21.6111 37.0756 21.6499 37.0923 21.6944 37.0923H22.6287C22.6731 37.0923 22.712 37.0756 22.7455 37.0422C22.7789 37.0089 22.7955 36.9699 22.7955 36.9253V33.9438ZM21.1481 36.0942C21.2619 36.0581 21.3691 36.015 21.4692 35.9648V35.0462H20.9937C20.8491 35.0462 20.7296 35.0587 20.635 35.0837C20.5404 35.1088 20.4653 35.1465 20.4098 35.1966C20.3542 35.2465 20.3152 35.3107 20.2931 35.3886C20.2707 35.4666 20.2596 35.5556 20.2596 35.6558V35.7312C20.2596 35.9092 20.3026 36.0233 20.3889 36.0734C20.4751 36.1235 20.6071 36.1485 20.7852 36.1485C20.913 36.1485 21.0339 36.1306 21.1481 36.0942ZM27.9007 36.917V34.1358C27.9007 33.8744 27.8799 33.6278 27.8381 33.3968C27.7964 33.166 27.7214 32.9653 27.6129 32.7954C27.5045 32.6256 27.3543 32.4905 27.1624 32.3904C26.9707 32.2902 26.7245 32.2401 26.4242 32.2401C26.1572 32.2401 25.9208 32.2723 25.7152 32.3369C25.5094 32.4014 25.2925 32.515 25.0646 32.6776V32.4752C25.0646 32.4305 25.0478 32.3911 25.0145 32.3575C24.9811 32.3238 24.9421 32.3068 24.8976 32.3068H23.9634C23.9187 32.3068 23.8799 32.3235 23.8467 32.357C23.8133 32.3904 23.7966 32.4295 23.7966 32.4739V36.917C23.7966 36.9615 23.8145 37.0019 23.8508 37.038C23.8869 37.0743 23.9272 37.0923 23.9717 37.0923H24.9811C25.0256 37.0923 25.0646 37.0743 25.0978 37.0382C25.1313 37.0021 25.1479 36.9619 25.1479 36.9173V33.6341C25.2925 33.5564 25.4287 33.4925 25.5567 33.4426C25.6845 33.3925 25.8096 33.3675 25.932 33.3675C26.0599 33.3675 26.1642 33.38 26.2449 33.4051C26.3254 33.4301 26.388 33.4731 26.4325 33.5345C26.477 33.5954 26.5076 33.6759 26.5243 33.7757C26.5409 33.8758 26.5494 33.9981 26.5494 34.1425V36.9173C26.5494 36.9619 26.566 37.0021 26.5994 37.0382C26.6327 37.0743 26.6715 37.0923 26.7162 37.0923H27.7255C27.7699 37.0923 27.8102 37.0743 27.8464 37.038C27.8826 37.0019 27.9007 36.9615 27.9007 36.917ZM32.0047 36.1071V36.8502C32.0047 36.9114 31.9907 36.9546 31.963 36.9796C31.9351 37.0047 31.8906 37.0255 31.8294 37.0422C31.7127 37.0701 31.5611 37.0978 31.3749 37.1259C31.1885 37.1535 30.9703 37.1676 30.72 37.1676C30.1305 37.1676 29.6592 36.9867 29.3062 36.6246C28.953 36.2628 28.7765 35.7394 28.7765 35.0546V34.3531C28.7765 33.6682 28.953 33.1448 29.3062 32.7831C29.6592 32.421 30.1305 32.2401 30.72 32.2401C30.9703 32.2401 31.1885 32.254 31.3749 32.2817C31.5611 32.3098 31.7127 32.3375 31.8294 32.3653C31.8906 32.3819 31.9351 32.4029 31.963 32.4279C31.9907 32.453 32.0047 32.4962 32.0047 32.5574V33.3007C32.0047 33.3453 31.9893 33.38 31.9588 33.4051C31.9281 33.4301 31.8906 33.4426 31.8462 33.4426H31.8294C31.6737 33.4261 31.5251 33.4121 31.3832 33.401C31.2413 33.3901 31.0508 33.3842 30.8118 33.3842C30.7172 33.3842 30.6283 33.3996 30.5448 33.4301C30.4613 33.4608 30.3891 33.5137 30.328 33.5888C30.2666 33.6641 30.2181 33.7641 30.1819 33.8895C30.1457 34.0147 30.1277 34.1692 30.1277 34.3531V35.0546C30.1277 35.2382 30.1457 35.3927 30.1819 35.5181C30.2181 35.6433 30.2666 35.7436 30.328 35.8187C30.3891 35.8939 30.4613 35.9468 30.5448 35.9774C30.6283 36.008 30.7172 36.0233 30.8118 36.0233C31.0508 36.0233 31.2413 36.0178 31.3832 36.0067C31.5251 35.9956 31.6737 35.9815 31.8294 35.9649H31.8462C31.8906 35.9649 31.9281 35.9774 31.9588 36.0025C31.9893 36.0276 32.0047 36.0623 32.0047 36.1071ZM36.6346 34.4115C36.6346 34.0773 36.5885 33.7768 36.4966 33.5095C36.4046 33.2423 36.2709 33.0155 36.0954 32.8289C35.9199 32.6424 35.7025 32.4976 35.4436 32.3946C35.1844 32.2918 34.8848 32.2401 34.5449 32.2401C34.2051 32.2401 33.9056 32.2918 33.6465 32.3946C33.3873 32.4976 33.1685 32.6424 32.9903 32.8289C32.8119 33.0155 32.6768 33.2423 32.585 33.5095C32.4928 33.7768 32.4469 34.0773 32.4469 34.4115V34.9961C32.4469 35.3301 32.4928 35.6309 32.585 35.8981C32.6768 36.1653 32.8119 36.3922 32.9903 36.5788C33.1685 36.7654 33.3873 36.91 33.6465 37.013C33.9056 37.1159 34.2051 37.1676 34.5449 37.1676C34.8848 37.1676 35.1844 37.1159 35.4436 37.013C35.7025 36.91 35.9199 36.7654 36.0954 36.5788C36.2709 36.3922 36.4046 36.1653 36.4966 35.8981C36.5885 35.6309 36.6346 35.3301 36.6346 34.9961V34.4115ZM34.5449 36.0233C35.037 36.0233 35.2832 35.6809 35.2832 34.9961V34.4115C35.2832 33.7322 35.037 33.3925 34.5449 33.3925C34.3016 33.3925 34.1164 33.4774 33.9893 33.6472C33.8619 33.8172 33.7984 34.0719 33.7984 34.4115V34.9961C33.7984 35.3357 33.8619 35.5918 33.9893 35.7644C34.1164 35.9371 34.3016 36.0233 34.5449 36.0233ZM41.5976 36.917V34.1358C41.5976 33.8744 41.5765 33.6278 41.5351 33.3968C41.4933 33.166 41.4181 32.9653 41.3095 32.7954C41.2011 32.6256 41.0511 32.4905 40.8593 32.3904C40.6674 32.2902 40.4213 32.2401 40.1211 32.2401C39.8542 32.2401 39.6177 32.2723 39.4119 32.3369C39.2062 32.4014 38.9893 32.515 38.7613 32.6776V32.4752C38.7613 32.4305 38.7447 32.3911 38.7111 32.3575C38.678 32.3238 38.6389 32.3068 38.5945 32.3068H37.6602C37.6157 32.3068 37.5769 32.3235 37.5434 32.357C37.5102 32.3904 37.4934 32.4295 37.4934 32.4739V36.917C37.4934 36.9615 37.5114 37.0019 37.5476 37.038C37.5838 37.0743 37.624 37.0923 37.6687 37.0923H38.678C38.7224 37.0923 38.7613 37.0743 38.7948 37.0382C38.828 37.0021 38.8448 36.9619 38.8448 36.9173V33.6341C38.9893 33.5564 39.1256 33.4925 39.2534 33.4426C39.3815 33.3925 39.5065 33.3675 39.629 33.3675C39.7568 33.3675 39.8611 33.38 39.9416 33.4051C40.0222 33.4301 40.0849 33.4731 40.1294 33.5345C40.1739 33.5954 40.2044 33.6759 40.2212 33.7757C40.2378 33.8758 40.2462 33.9981 40.2462 34.1425V36.9173C40.2462 36.9619 40.2628 37.0021 40.2962 37.0382C40.3296 37.0743 40.3684 37.0923 40.413 37.0923H41.4223C41.4668 37.0923 41.5072 37.0743 41.5434 37.038C41.5794 37.0019 41.5976 36.9615 41.5976 36.917ZM45.2348 36.2893V36.9357C45.2348 37.0295 45.182 37.0848 45.0763 37.1011C44.9483 37.1233 44.8371 37.1398 44.7427 37.1509C44.6481 37.162 44.5395 37.1675 44.4174 37.1675C44.1905 37.1675 43.9901 37.1493 43.816 37.1133C43.6419 37.077 43.4966 37.0061 43.3805 36.9003C43.2646 36.7945 43.1761 36.6483 43.1153 36.4617C43.0547 36.2753 43.0242 36.0347 43.0242 35.7394V33.3175L42.357 33.2088C42.3123 33.1977 42.2721 33.1769 42.2359 33.1462C42.1997 33.1157 42.1817 33.0781 42.1817 33.0335V32.4822C42.1817 32.4378 42.1997 32.3974 42.2359 32.3611C42.2721 32.325 42.3123 32.3068 42.357 32.3068H43.0242V31.622C43.0242 31.5774 43.0409 31.5414 43.0739 31.5134C43.1068 31.4857 43.1458 31.4663 43.1902 31.455L44.2016 31.2798H44.2263C44.2705 31.2798 44.3065 31.2921 44.3343 31.3171C44.3618 31.3423 44.3757 31.3771 44.3757 31.4215V32.3068H45.0597C45.104 32.3068 45.143 32.3237 45.1764 32.3573C45.2099 32.3909 45.2265 32.4305 45.2265 32.4752V33.1573C45.2265 33.2024 45.2099 33.2416 45.1764 33.2752C45.143 33.3089 45.104 33.3257 45.0597 33.3257H44.3757V35.7561C44.3757 35.9231 44.3895 36.0304 44.4174 36.0776C44.4451 36.1249 44.5229 36.1485 44.6507 36.1485H45.0597C45.1764 36.1485 45.2348 36.1955 45.2348 36.2893ZM49.6891 33.9438C49.6891 33.6377 49.6433 33.3772 49.5514 33.1629C49.4597 32.9487 49.3305 32.7732 49.1637 32.6367C48.9969 32.5004 48.7925 32.4003 48.5505 32.3362C48.3087 32.2722 48.0376 32.2401 47.7373 32.2401C47.4589 32.2401 47.188 32.2597 46.924 32.2987C46.6597 32.3375 46.4497 32.3766 46.2942 32.4154C46.1882 32.4435 46.1357 32.5046 46.1357 32.5991V33.2756C46.1357 33.3314 46.1494 33.3705 46.1773 33.3925C46.2052 33.4149 46.2412 33.4261 46.2857 33.4261H46.3274C46.3943 33.4204 46.4776 33.4135 46.5777 33.4051C46.6779 33.3968 46.7905 33.3901 46.9155 33.3842C47.0408 33.3788 47.1714 33.3746 47.3077 33.3717C47.4438 33.3689 47.5788 33.3675 47.7121 33.3675C47.9068 33.3675 48.0598 33.4038 48.171 33.4761C48.2822 33.5486 48.3378 33.7045 48.3378 33.9438V34.2445H47.8874C47.1698 34.2445 46.6486 34.3572 46.3233 34.5827C45.998 34.8081 45.8353 35.1659 45.8353 35.6558V35.7313C45.8353 36.0039 45.8755 36.2321 45.9562 36.4158C46.0366 36.5996 46.144 36.7472 46.2774 36.8587C46.4109 36.9699 46.5623 37.0493 46.7321 37.0964C46.9017 37.1438 47.0782 37.1676 47.2618 37.1676C47.5121 37.1676 47.7274 37.1341 47.9082 37.0673C48.0889 37.0005 48.2597 36.9086 48.4213 36.7917V36.9253C48.4213 36.9699 48.4379 37.0089 48.4713 37.0422C48.5046 37.0756 48.5436 37.0923 48.5881 37.0923H49.5224C49.5668 37.0923 49.6057 37.0756 49.6392 37.0422C49.6724 37.0089 49.6891 36.9699 49.6891 36.9253V33.9438ZM48.0418 36.0942C48.1556 36.0581 48.2628 36.015 48.3629 35.9648V35.0462H47.8874C47.7428 35.0462 47.6233 35.0587 47.5287 35.0837C47.4341 35.1088 47.359 35.1465 47.3035 35.1966C47.2477 35.2465 47.2088 35.3107 47.1868 35.3886C47.1644 35.4666 47.1533 35.5556 47.1533 35.6558V35.7312C47.1533 35.9092 47.1963 36.0233 47.2826 36.0734C47.3688 36.1235 47.5008 36.1485 47.6789 36.1485C47.8067 36.1485 47.9274 36.1306 48.0418 36.0942ZM53.7933 36.8502V36.1071C53.7933 36.0623 53.7779 36.0276 53.7474 36.0025C53.7167 35.9774 53.6793 35.9649 53.6348 35.9649H53.6181C53.4624 35.9815 53.3136 35.9956 53.1718 36.0067C53.0301 36.0178 52.8395 36.0233 52.6005 36.0233C52.5057 36.0233 52.4167 36.008 52.3336 35.9774C52.2501 35.9468 52.1777 35.8939 52.1165 35.8187C52.0554 35.7436 52.0067 35.6433 51.9707 35.5181C51.9343 35.3927 51.9165 35.2382 51.9165 35.0546V34.3531C51.9165 34.1692 51.9343 34.0147 51.9707 33.8895C52.0067 33.7641 52.0554 33.6641 52.1165 33.5888C52.1777 33.5137 52.2501 33.4608 52.3336 33.4301C52.4167 33.3996 52.5057 33.3842 52.6005 33.3842C52.8395 33.3842 53.0301 33.3901 53.1718 33.401C53.3136 33.4121 53.4624 33.4261 53.6181 33.4426H53.6348C53.6793 33.4426 53.7167 33.4301 53.7474 33.4051C53.7779 33.38 53.7933 33.3453 53.7933 33.3007V32.5574C53.7933 32.4962 53.7794 32.453 53.7515 32.4279C53.7235 32.4029 53.6793 32.3819 53.6181 32.3653C53.5014 32.3375 53.3497 32.3098 53.1635 32.2817C52.9771 32.254 52.759 32.2401 52.5087 32.2401C51.9189 32.2401 51.4479 32.421 51.0947 32.7831C50.7415 33.1448 50.565 33.6682 50.565 34.3531V35.0546C50.565 35.7394 50.7415 36.2628 51.0947 36.6246C51.4479 36.9867 51.9189 37.1676 52.5087 37.1676C52.759 37.1676 52.9771 37.1535 53.1635 37.1259C53.3497 37.0978 53.5014 37.0701 53.6181 37.0422C53.6793 37.0255 53.7235 37.0047 53.7515 36.9796C53.7794 36.9546 53.7933 36.9114 53.7933 36.8502ZM57.3884 36.2893V36.9357C57.3884 37.0295 57.3354 37.0848 57.2299 37.1011C57.1019 37.1233 56.9907 37.1398 56.8963 37.1509C56.8016 37.162 56.6931 37.1675 56.571 37.1675C56.3441 37.1675 56.1437 37.1493 55.9696 37.1133C55.7954 37.077 55.6502 37.0061 55.5343 36.9003C55.4183 36.7945 55.3298 36.6483 55.269 36.4617C55.2083 36.2753 55.1778 36.0347 55.1778 35.7394V33.3175L54.5106 33.2088C54.4659 33.1977 54.4257 33.1769 54.3895 33.1462C54.3533 33.1157 54.3353 33.0781 54.3353 33.0335V32.4822C54.3353 32.4378 54.3533 32.3974 54.3895 32.3611C54.4257 32.325 54.4659 32.3068 54.5106 32.3068H55.1778V31.622C55.1778 31.5774 55.1945 31.5414 55.2276 31.5134C55.2605 31.4857 55.2993 31.4663 55.3436 31.455L56.355 31.2798H56.38C56.4241 31.2798 56.4602 31.2921 56.4875 31.3171C56.5154 31.3423 56.5293 31.3771 56.5293 31.4215V32.3068H57.2133C57.2577 32.3068 57.2966 32.3237 57.3301 32.3573C57.3633 32.3909 57.3801 32.4305 57.3801 32.4752V33.1573C57.3801 33.2024 57.3633 33.2416 57.3301 33.2752C57.2966 33.3089 57.2577 33.3257 57.2133 33.3257H56.5293V35.7561C56.5293 35.9231 56.5431 36.0304 56.571 36.0776C56.5987 36.1249 56.6765 36.1485 56.8045 36.1485H57.2133C57.3301 36.1485 57.3884 36.1955 57.3884 36.2893Z", fill: "#005697" }), jsxRuntime.jsx("path", { d: "M52.6187 14.7398H39.0664L37.6881 16.2935L33.2155 21.3349V21.3351L31.8372 22.8886H18.464L19.821 21.3153L20.4633 20.5706L21.8202 18.9973H15.6582C14.5325 18.9973 13.6113 19.943 13.6113 21.0987V25.5326C13.6113 26.6885 14.5325 27.6342 15.6582 27.6342H39.2492C40.3749 27.6342 41.9127 26.9318 42.6665 26.0733L46.235 22.0097L52.6187 14.7398Z", fill: "#005697" }), jsxRuntime.jsx("path", { d: "M55.3418 10C56.4676 10 57.3887 10.9457 57.3887 12.1015V16.5353C57.3887 17.691 56.4676 18.6368 55.3418 18.6368H49.1999L50.5697 17.0753H50.5699L51.2491 16.3012L52.6189 14.7398H39.0667L31.8375 22.8945H18.3813L28.0314 11.9701L28.3966 11.5566C29.153 10.7005 30.6929 10 31.8186 10H55.3418V10Z", fill: "#FBD500" })] }));
18486
+ };
18487
+
18488
+ const Cashapp$1 = ({ className }) => {
18489
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsxs("g", { "clip-path": "url(#clip0_550_235)", children: [jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M26.4382 8C22.3647 8 19.0625 11.3022 19.0625 15.3758V32.6242C19.0625 36.6978 22.3647 40 26.4382 40H43.5153C47.5889 40 50.8911 36.6978 50.8911 32.6242V15.3758C50.8911 11.3022 47.5889 8 43.5153 8H26.4382Z", fill: "#00D632" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M40.1482 19.902C38.9333 18.8737 37.3938 18.3084 35.8022 18.3059C34.4908 18.3059 33.1795 18.7405 33.1795 19.9469C33.1795 21.0467 34.347 21.4771 35.7853 22.0072C35.9248 22.0586 36.0668 22.111 36.2105 22.1649C39.0542 23.1241 41.3959 24.3005 41.3959 27.088C41.3959 30.1153 39.0467 32.1835 35.2026 32.4195L34.8542 34.0418C34.7887 34.3448 34.5199 34.5605 34.2098 34.5589H31.7932C31.5955 34.554 31.4102 34.4618 31.2872 34.307C31.1642 34.1521 31.1163 33.9507 31.1563 33.7571L31.531 32.0448C30.08 31.6748 28.7461 30.9441 27.6532 29.9205C27.5265 29.7983 27.4551 29.63 27.4551 29.454C27.4551 29.2781 27.5265 29.1097 27.6532 28.9876L28.9945 27.6763C29.2482 27.4268 29.655 27.4268 29.9086 27.6763C31.1374 28.8485 32.7778 29.4904 34.4758 29.4634C36.2255 29.4634 37.4132 28.7215 37.4132 27.5451C37.4132 26.4815 36.4394 26.1253 34.5914 25.4494C34.3953 25.3776 34.1894 25.3024 33.9738 25.2222C31.5984 24.3755 29.3504 23.1653 29.3504 20.3516C29.3504 17.0958 32.0705 15.5072 35.2776 15.3498L35.6148 13.6975C35.6816 13.3974 35.948 13.1839 36.2555 13.1842H38.6646C38.8609 13.1836 39.0469 13.2714 39.1712 13.4233C39.2955 13.5752 39.3447 13.775 39.3052 13.9673L38.9306 15.8144C40.157 16.2153 41.2935 16.8516 42.2764 17.6877C42.4118 17.8042 42.4925 17.972 42.4989 18.1505C42.5053 18.3291 42.4368 18.5022 42.31 18.6281L41.0587 19.8833C40.8081 20.1298 40.4087 20.138 40.1482 19.902Z", fill: "white" })] }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_550_235", children: jsxRuntime.jsx("rect", { width: "32", height: "32", fill: "white", transform: "translate(19 8)" }) }) })] }));
18490
+ };
18491
+
18492
+ const ChinaUnionPay = ({ className }) => {
18493
+ return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M18.2466 6.855H27.4811C28.7703 6.855 29.5728 7.90603 29.272 9.20036L24.972 27.6585C24.6682 28.949 23.3782 30 22.0886 30H12.8537C11.5641 30 10.7624 28.949 11.0632 27.6585L15.3654 9.20036C15.6653 7.90603 16.9545 6.855 18.2466 6.855Z", fill: "#ED171F" }), jsxRuntime.jsx("path", { d: "M26.7132 6.855H37.3336C38.6223 6.855 38.0411 7.90603 37.7381 9.20036L33.4385 27.6585C33.1382 28.949 33.2324 30 31.9402 30H21.3206C20.0298 30 19.2303 28.949 19.5336 27.6585L23.8315 9.20036C24.1353 7.90603 25.424 6.855 26.7132 6.855Z", fill: "#082F67" }), jsxRuntime.jsx("path", { d: "M36.9136 6.855H46.1468C47.4368 6.855 48.2384 7.90603 47.9364 9.20036L43.6372 27.6585C43.3351 28.949 42.0455 30 40.7516 30H31.521C30.2288 30 29.4285 28.949 29.7314 27.6585L34.0293 9.20036C34.3318 7.90603 35.621 6.855 36.9136 6.855Z", fill: "#006A65" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M38.4247 20.4849L37.2994 24.2089H37.6019L37.3681 24.979H37.0656L36.9951 25.218H35.9242L35.9968 24.979H33.82L34.0387 24.2664H34.2587L35.4005 20.4849L35.6286 19.7209H36.7212L36.6071 20.1072C36.6071 20.1072 36.8979 19.8972 37.1741 19.8254C37.4502 19.7528 39.0337 19.7265 39.0337 19.7265L38.799 20.4849H38.4247ZM36.4995 20.4849L36.2103 21.4365C36.2103 21.4365 36.5336 21.2909 36.7112 21.2421C36.8901 21.1958 37.1589 21.1777 37.1589 21.1777L37.3681 20.4849H36.4995ZM36.0669 21.9098L35.7678 22.8994C35.7678 22.8994 36.0984 22.73 36.276 22.6773C36.4549 22.6358 36.7255 22.6021 36.7255 22.6021L36.9377 21.9098H36.0669ZM35.3702 24.2197H36.241L36.4925 23.383H35.6217L35.3702 24.2197Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M38.9076 19.7265H40.0736L40.0866 20.1613C40.0797 20.2343 40.1427 20.2689 40.2776 20.2689H40.5144L40.2979 20.9863H39.6687C39.1224 21.0265 38.9163 20.7918 38.9284 20.5286L38.9076 19.7265Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M39.0602 23.1305H37.9487L38.1397 22.4909H39.4099L39.5918 21.9079H38.3368L38.5525 21.1875H42.0439L41.8252 21.9079H40.6545L40.4713 22.4909H41.6446L41.4514 23.1305H40.1808L39.9561 23.3998H40.4713L40.5962 24.2049C40.6096 24.284 40.6121 24.3363 40.6372 24.3708C40.6631 24.4006 40.8174 24.4145 40.9069 24.4145H41.0633L40.8256 25.198H40.4293C40.368 25.198 40.2772 25.1928 40.1532 25.1863C40.033 25.1759 39.9479 25.1064 39.8684 25.0683C39.7958 25.032 39.6869 24.9439 39.6618 24.7939L39.5374 23.9905L38.9608 24.7831C38.7772 25.032 38.5291 25.2226 38.1108 25.2226H37.3009L37.5131 24.5238H37.8221C37.9116 24.5238 37.9906 24.4888 38.0485 24.4586C38.1082 24.4335 38.1605 24.4037 38.2201 24.3155L39.0602 23.1305Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M26.8864 21.3815H29.8294L29.612 22.0842H28.4348L28.252 22.6818H29.456L29.2365 23.4075H28.0333L27.7416 24.3811C27.7057 24.4892 28.026 24.5043 28.1418 24.5043L28.7451 24.4209L28.5035 25.223H27.1457C27.0389 25.223 26.9555 25.2079 26.8371 25.1811C26.7226 25.1525 26.672 25.1015 26.6214 25.0237C26.5722 24.9438 26.497 24.879 26.548 24.7096L26.9374 23.42H26.2692L26.4909 22.6818H27.1629L27.3414 22.0842H26.672L26.8864 21.3815Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M28.8682 20.1195H30.0752L29.8544 20.8541H28.2052L28.0259 21.0084C27.9498 21.0832 27.923 21.0516 27.8232 21.1057C27.7303 21.1532 27.5337 21.2461 27.28 21.2461H26.7506L26.9658 20.5395H27.1244C27.2588 20.5395 27.35 20.5283 27.3962 20.4985C27.449 20.4656 27.5073 20.3909 27.5751 20.269L27.8777 19.718H29.0786L28.8682 20.1195Z", fill: "white" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M30.5938 19.7264H31.6223L31.4728 20.2437C31.4728 20.2437 31.7969 19.9848 32.0247 19.8923C32.2511 19.8072 32.7641 19.7311 32.7641 19.7311L34.428 19.7225L33.861 21.6106C33.7659 21.9347 33.6548 22.1439 33.5852 22.239C33.5217 22.3366 33.4482 22.4183 33.3026 22.4974C33.1626 22.5722 33.0351 22.6154 32.9175 22.6275C32.8073 22.6357 32.6388 22.64 32.4046 22.6422H30.8025L30.3501 24.1366C30.3073 24.284 30.2865 24.354 30.3146 24.3937C30.3384 24.43 30.3928 24.4702 30.468 24.4702L31.1746 24.4037L30.9339 25.2226H30.1413C29.8898 25.2226 29.7066 25.2174 29.5778 25.2075C29.4559 25.198 29.3284 25.2075 29.2441 25.1414C29.1694 25.0766 29.0574 24.9918 29.06 24.9041C29.0683 24.8229 29.1011 24.688 29.1534 24.5039L30.5938 19.7264ZM32.7775 21.6344H31.0912L30.9884 21.9749H32.4473C32.6198 21.9533 32.6552 21.9779 32.669 21.9697L32.7775 21.6344ZM31.185 21.3271C31.185 21.3271 31.5139 21.0263 32.0778 20.9286C32.2062 20.9036 33.0083 20.9118 33.0083 20.9118L33.1297 20.5081H31.4305L31.185 21.3271Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M33.5921 22.7747L33.4979 23.2285C33.4559 23.3693 33.4209 23.4778 33.3138 23.5686C33.2027 23.6632 33.0696 23.763 32.7606 23.763L32.191 23.7859L32.1862 24.2998C32.1785 24.4459 32.2178 24.4303 32.2411 24.4541C32.2675 24.4787 32.2904 24.4904 32.3168 24.4986L32.4961 24.4904L33.0415 24.4584L32.8168 25.2078H32.191C31.7524 25.2078 31.4274 25.1983 31.3202 25.1127C31.2156 25.0466 31.2018 24.9619 31.2048 24.8188L31.2441 22.8201H32.242L32.2295 23.2285H32.4702C32.5523 23.2285 32.6063 23.2198 32.6417 23.1986C32.6707 23.1749 32.6936 23.1437 32.7096 23.0932L32.8068 22.7747H33.5921Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M19.3395 12.7519C19.3032 12.9127 18.6632 15.8704 18.6606 15.8722C18.5219 16.4698 18.4238 16.8985 18.0824 17.1721C17.8887 17.3311 17.6623 17.4094 17.4008 17.4094C16.9808 17.4094 16.734 17.2006 16.6921 16.8035L16.6843 16.6678C16.6843 16.6678 16.8122 15.8652 16.814 15.8622C16.814 15.8622 17.486 13.1664 17.6065 12.8116C17.6117 12.7917 17.6143 12.7817 17.6169 12.7714C16.3075 12.783 16.0745 12.7714 16.0594 12.7519C16.052 12.7783 16.017 12.946 16.017 12.946L15.3299 15.9815L15.2703 16.2408L15.1579 17.0826C15.1579 17.3311 15.2072 17.536 15.3044 17.7084C15.6177 18.2564 16.511 18.3377 17.0149 18.3377C17.6662 18.3377 18.2751 18.1985 18.6874 17.9478C19.4026 17.5243 19.591 16.8614 19.7583 16.2754L19.8352 15.975C19.8352 15.975 20.5288 13.1759 20.6473 12.8116C20.6507 12.7917 20.6529 12.7817 20.6576 12.7714C19.709 12.7817 19.4298 12.7714 19.3395 12.7519Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M23.1723 18.3077C22.7073 18.3012 22.5444 18.3012 22.0011 18.3289L21.98 18.2887C22.0279 18.0821 22.0794 17.8785 22.1252 17.6689L22.1917 17.3867C22.2924 16.9464 22.3909 16.4347 22.4026 16.2804C22.4121 16.1862 22.4432 15.952 22.1757 15.952C22.0625 15.952 21.9449 16.0073 21.8265 16.0613C21.7608 16.2955 21.6282 16.9515 21.5672 17.2519C21.432 17.8829 21.4233 17.9542 21.3633 18.2666L21.3244 18.3077C20.8451 18.3012 20.6796 18.3012 20.1286 18.3289L20.1026 18.283C20.1951 17.9079 20.2867 17.5298 20.3749 17.1555C20.6057 16.1395 20.6601 15.7501 20.7245 15.2337L20.7677 15.203C21.3049 15.1278 21.435 15.1131 22.0163 14.9934L22.0655 15.0483L21.9778 15.372C22.0759 15.3141 22.1688 15.2549 22.2704 15.203C22.5444 15.0682 22.8495 15.0284 23.0176 15.0284C23.2713 15.0284 23.5496 15.0997 23.6663 15.394C23.7769 15.6564 23.7039 15.9805 23.5586 16.6175L23.4835 16.9412C23.3344 17.6504 23.3102 17.78 23.2267 18.2666L23.1723 18.3077Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M25.0585 18.3077C24.7793 18.3064 24.5995 18.3012 24.4232 18.3064C24.2486 18.3077 24.0779 18.3168 23.8182 18.3289L23.8026 18.3064L23.7853 18.283C23.8562 18.0142 23.8964 17.92 23.9309 17.8245C23.9664 17.7299 24.001 17.6339 24.0623 17.3612C24.1436 17.006 24.1937 16.7571 24.2296 16.5397C24.2667 16.3284 24.2879 16.1495 24.3143 15.9416L24.3359 15.9252L24.3592 15.9053C24.6371 15.866 24.8147 15.84 24.9945 15.8124C25.1769 15.786 25.3605 15.7501 25.6488 15.6957L25.66 15.7207L25.6678 15.7462C25.6142 15.9662 25.5598 16.1862 25.5075 16.41C25.4561 16.6326 25.4016 16.8513 25.3532 17.073C25.2478 17.541 25.2067 17.7148 25.1816 17.8396C25.1587 17.9589 25.1509 18.0237 25.1095 18.2666L25.0844 18.2887L25.0585 18.3077Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M29.2305 16.7091C29.3935 15.9948 29.2686 15.6607 29.1091 15.4563C28.8658 15.1477 28.4397 15.0479 27.9958 15.0479C27.7301 15.0479 27.0952 15.0751 26.5987 15.5332C26.2443 15.8621 26.0779 16.3107 25.9781 16.7389C25.8782 17.175 25.7628 17.9641 26.4867 18.2567C26.7114 18.3509 27.0313 18.3777 27.2396 18.3777C27.7698 18.3777 28.3135 18.2312 28.7206 17.7982C29.0382 17.446 29.1813 16.923 29.2305 16.7091ZM28.0166 16.6573C27.9911 16.777 27.8865 17.2256 27.7426 17.4161C27.6432 17.5562 27.5252 17.6404 27.3947 17.6404C27.358 17.6404 27.1285 17.6404 27.1242 17.2999C27.1216 17.1322 27.1566 16.9576 27.1985 16.7718C27.3208 16.2307 27.4651 15.7769 27.8329 15.7769C28.1225 15.7769 28.1415 16.1145 28.0166 16.6573Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M40.5855 18.3561C40.0254 18.3509 39.8642 18.3509 39.3465 18.373L39.3115 18.331C39.4532 17.7982 39.595 17.267 39.7199 16.7286C39.8819 16.0298 39.9191 15.7329 39.9736 15.324L40.0155 15.2895C40.5713 15.2095 40.726 15.1875 41.3059 15.0803L41.3241 15.1278C41.2178 15.566 41.1115 16.0047 41.0103 16.4446C40.7964 17.3664 40.7186 17.8349 40.6365 18.3163L40.5855 18.3561Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M40.8523 16.7721C41.0152 16.0612 40.3601 16.7094 40.2551 16.4748C40.0943 16.1092 40.195 15.3671 39.5493 15.1195C39.3017 15.0231 38.7183 15.148 38.2204 15.6031C37.8682 15.9307 37.7005 16.3736 37.6016 16.8015C37.5013 17.2315 37.3864 18.0189 38.1063 18.3015C38.3337 18.3979 38.5424 18.4256 38.7498 18.4173C39.4741 18.378 40.0265 17.2855 40.434 16.852C40.749 16.5098 40.8043 16.9808 40.8523 16.7721ZM39.7442 16.7189C39.717 16.833 39.612 17.2868 39.4681 17.4744C39.373 17.6088 39.1466 17.6939 39.0169 17.6939C38.9802 17.6939 38.7524 17.6939 38.7442 17.3564C38.7425 17.1904 38.7775 17.0158 38.8207 16.8283C38.943 16.2989 39.0874 15.8468 39.4551 15.8468C39.7451 15.8468 39.8687 16.1761 39.7442 16.7189Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M32.4031 18.3077C31.9372 18.3012 31.7795 18.3012 31.2319 18.3289L31.2125 18.2887C31.2587 18.0821 31.3114 17.8785 31.3598 17.6689L31.4251 17.3867C31.5262 16.9464 31.6243 16.4347 31.6355 16.2804C31.6446 16.1862 31.6757 15.952 31.4104 15.952C31.2954 15.952 31.1792 16.0073 31.0599 16.0613C30.9951 16.2955 30.862 16.9515 30.798 17.2519C30.6653 17.8829 30.6563 17.9542 30.5962 18.2666L30.5564 18.3077C30.0776 18.3012 29.9134 18.3012 29.3637 18.3289L29.3386 18.283C29.4302 17.9079 29.5201 17.5298 29.6083 17.1555C29.8386 16.1395 29.8935 15.7501 29.9575 15.2337L30.0007 15.203C30.5378 15.1278 30.6684 15.1131 31.2496 14.9934L31.2954 15.0483L31.2112 15.372C31.3067 15.3141 31.4039 15.2549 31.5029 15.203C31.7751 15.0682 32.0828 15.0284 32.2475 15.0284C32.502 15.0284 32.7808 15.0997 32.9005 15.394C33.0098 15.6564 32.9359 15.9805 32.7894 16.6175L32.7164 16.9412C32.5643 17.6504 32.5409 17.78 32.4605 18.2666L32.4031 18.3077Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M36.9307 14.4822C36.8486 14.8504 36.6096 15.1629 36.3006 15.3137C36.0452 15.4421 35.7344 15.4516 35.4129 15.4516H35.2059L35.2215 15.369C35.2215 15.369 35.6048 13.7048 35.6031 13.71L35.6143 13.6248L35.6212 13.5591L35.7742 13.5751C35.7742 13.5751 36.5616 13.6434 36.5815 13.6456C36.8931 13.764 37.0201 14.0769 36.9307 14.4822ZM36.4276 12.7467C36.4255 12.7467 36.0417 12.7518 36.0417 12.7518C35.0378 12.7631 34.6354 12.7583 34.4703 12.7385C34.4531 12.8119 34.428 12.9424 34.428 12.9424L34.0693 14.6115C34.0693 14.6115 33.2097 18.1565 33.1687 18.3229C34.0447 18.3134 34.4042 18.3134 34.5542 18.3285C34.5883 18.1621 34.7932 17.172 34.7932 17.172C34.7932 17.172 34.9682 16.4447 34.9786 16.4179C34.9786 16.4179 35.0326 16.3436 35.0883 16.3137H35.1683C35.9233 16.3137 36.7781 16.3137 37.4462 15.8206C37.9004 15.4831 38.2138 14.9848 38.3516 14.3802C38.3888 14.2316 38.4147 14.0535 38.4147 13.8772C38.4147 13.6456 38.368 13.4161 38.2323 13.2363C37.8918 12.7583 37.2142 12.7518 36.4276 12.7467Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M45.1748 15.0751L45.1303 15.0254C44.5581 15.1399 44.4535 15.1598 43.9263 15.2293L43.8865 15.2674C43.8848 15.2739 43.8831 15.2842 43.8818 15.2924L43.8792 15.2842C43.4868 16.1913 43.4993 15.9951 43.1791 16.7073C43.1769 16.6736 43.1765 16.6525 43.1756 16.6187L43.0961 15.0751L43.0455 15.0254C42.4466 15.1399 42.4306 15.1598 41.8761 15.2293L41.8316 15.2674C41.8277 15.2877 41.8264 15.3076 41.8234 15.3292L41.8277 15.3374C41.8968 15.6931 41.8809 15.6131 41.9496 16.171C41.982 16.445 42.0243 16.7225 42.0567 16.9926C42.1121 17.4463 42.1423 17.6706 42.208 18.3612C41.835 18.981 41.7447 19.2148 41.3882 19.7584L41.4072 19.8077C41.9496 19.7874 42.0745 19.7874 42.4755 19.7874L42.5641 19.6884C42.8671 19.0354 45.1748 15.0751 45.1748 15.0751Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M25.5693 15.4586C25.8753 15.2447 25.9146 14.9491 25.6553 14.7957C25.3926 14.6414 24.9353 14.6898 24.6259 14.9042C24.3143 15.1151 24.2802 15.4115 24.5399 15.5662C24.8001 15.7171 25.2595 15.673 25.5693 15.4586Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M42.5238 19.7429L42.0727 20.5152C41.93 20.7788 41.6651 20.9771 41.2442 20.9784L40.5255 20.9668L40.7347 20.2706H40.8738C40.9477 20.2706 41.0018 20.2658 41.0432 20.2455C41.0787 20.2343 41.105 20.2062 41.1344 20.1647L41.3993 19.7429H42.5238Z", fill: "white" })] }));
18494
+ };
18495
+
18496
+ const CreditCard = ({ className }) => {
18497
+ return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M1 10L59 10", stroke: "#D3D3D3", strokeWidth: "7" }), jsxRuntime.jsx("path", { d: "M5 20H34", stroke: "#D3D3D3", strokeWidth: "2", strokeLinecap: "round" }), jsxRuntime.jsx("path", { d: "M5 27H25", stroke: "#D3D3D3", strokeWidth: "2", strokeLinecap: "round" }), jsxRuntime.jsx("rect", { x: "46", y: "21", width: "10", height: "7", rx: "2", fill: "#D9D9D9" })] }));
18498
+ };
18499
+
18500
+ const DinersClub = ({ className }) => {
18501
+ return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M16.5247 19.2244C16.5247 12.2923 21.9422 6.67337 28.6257 6.67337C35.309 6.67337 40.7267 12.2923 40.7267 19.2244C40.7267 26.1563 35.309 31.7755 28.6257 31.7755C21.9422 31.7755 16.5247 26.1563 16.5247 19.2244Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M35.9447 18.977C35.9391 15.7623 34.0025 13.0219 31.2728 11.9361V26.0177C34.0025 24.9305 35.9391 22.1925 35.9447 18.977ZM26.0659 26.0146V11.937C23.3393 13.0268 21.4049 15.7642 21.3979 18.977C21.4049 22.1892 23.3393 24.9272 26.0659 26.0146ZM28.6708 7.07501C22.3335 7.07748 17.1989 12.404 17.1981 18.977C17.1989 25.5492 22.3335 30.8749 28.6708 30.8758C35.0083 30.8749 40.1444 25.5492 40.146 18.977C40.1444 12.404 35.0083 7.07748 28.6708 7.07501ZM28.6426 31.9999C21.7077 32.0333 16 26.2067 16 19.1126C16 11.3606 21.7077 5.99835 28.6426 6H31.8932C38.7455 5.99835 45 11.3575 45 19.1126C45 26.2034 38.7455 31.9999 31.8932 31.9999H28.6426Z", fill: "#264B9A" })] }));
18502
+ };
18503
+
18504
+ const Discover = ({ className }) => {
18505
+ return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("path", { d: "M0.5 8C0.5 3.85786 3.85786 0.5 8 0.5H52C56.1421 0.5 59.5 3.85786 59.5 8V30C59.5 34.1421 56.1421 37.5 52 37.5H8C3.85786 37.5 0.5 34.1421 0.5 30V8Z", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M9.19232 21.3753C8.69269 21.8265 8.04327 22.0234 7.01615 22.0234H6.58905V16.6315H7.01615C8.04327 16.6315 8.66695 16.8153 9.19232 17.2909C9.74271 17.7809 10.0728 18.539 10.0728 19.3202C10.0728 20.1034 9.74271 20.8859 9.19232 21.3753ZM7.33469 15.2496H5V23.404H7.32208C8.55684 23.404 9.44888 23.1129 10.2316 22.4621C11.1617 21.6921 11.7116 20.5322 11.7116 19.3327C11.7116 16.926 9.91383 15.2496 7.33469 15.2496Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M12.4438 23.404H14.0339V15.2496H12.4438V23.404Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M17.9229 18.379C16.9683 18.0253 16.6881 17.7928 16.6881 17.3521C16.6881 16.8383 17.1875 16.4484 17.8729 16.4484C18.3498 16.4484 18.7411 16.644 19.1556 17.1091L19.9879 16.019C19.3038 15.4209 18.4856 15.1153 17.592 15.1153C16.1491 15.1153 15.0487 16.1171 15.0487 17.4516C15.0487 18.5746 15.5612 19.1496 17.0551 19.6871C17.6774 19.9071 17.9941 20.0533 18.1542 20.1521C18.4717 20.359 18.6312 20.6527 18.6312 20.9952C18.6312 21.6559 18.1058 22.1453 17.3959 22.1453C16.6379 22.1453 16.0266 21.7665 15.6605 21.0585L14.6329 22.0471C15.3656 23.1227 16.2456 23.5996 17.4559 23.5996C19.1087 23.5996 20.2684 22.501 20.2684 20.9228C20.2684 19.6265 19.7324 19.0403 17.9229 18.379Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M20.7702 19.3328C20.7702 21.729 22.652 23.5871 25.0739 23.5871C25.7583 23.5871 26.3445 23.4528 27.0677 23.1129V21.2403C26.4317 21.8766 25.8684 22.1328 25.1475 22.1328C23.5456 22.1328 22.4089 20.9715 22.4089 19.3203C22.4089 17.7552 23.5821 16.5202 25.0739 16.5202C25.8321 16.5202 26.407 16.7909 27.0677 17.4378V15.5665C26.3697 15.2121 25.7957 15.0659 25.1112 15.0659C22.7019 15.0659 20.7702 16.9615 20.7702 19.3328Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M39.6784 20.7265L37.5033 15.2497H35.7663L39.2264 23.6135H40.0824L43.605 15.2497H41.8806L39.6784 20.7265Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M44.3237 23.404H48.8345V22.0234H45.9135V19.8221H48.7263V18.4409H45.9135V16.6315H48.8345V15.2496H44.3237V23.404Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M51.9414 19.0041H51.4762V16.534H51.9658C52.9569 16.534 53.4954 16.949 53.4954 17.7427C53.4954 18.5628 52.9569 19.0041 51.9414 19.0041ZM55.1326 17.6571C55.1326 16.1303 54.0803 15.2496 52.246 15.2496H49.8879V23.404H51.4762V20.1284H51.6841L53.8855 23.404H55.8412L53.2739 19.9684C54.4724 19.7246 55.1326 18.9059 55.1326 17.6571Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M56.0974 15.7753H56.0678V15.5875H56.0989C56.1836 15.5875 56.2281 15.6178 56.2281 15.6797C56.2281 15.7436 56.1831 15.7753 56.0974 15.7753ZM56.4 15.6778C56.4 15.5342 56.3007 15.4558 56.1273 15.4558H55.8967V16.1744H56.0678V15.8958L56.269 16.1744H56.479L56.2425 15.878C56.3434 15.851 56.4 15.7772 56.4 15.6778Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M56.1591 16.3292C55.8843 16.3292 55.6597 16.1 55.6597 15.8148C55.6597 15.5283 55.8823 15.2997 56.1591 15.2997C56.4328 15.2997 56.6554 15.5335 56.6554 15.8148C56.6554 16.0974 56.4328 16.3292 56.1591 16.3292ZM56.1617 15.1871C55.8128 15.1871 55.5354 15.4657 55.5354 15.8135C55.5354 16.1619 55.8159 16.4412 56.1617 16.4412C56.5018 16.4412 56.7808 16.1586 56.7808 15.8135C56.7808 15.4703 56.5018 15.1871 56.1617 15.1871Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M36.2191 19.3183C36.2191 21.7027 34.2863 23.6359 31.9014 23.6359C29.5166 23.6359 27.5835 21.7027 27.5835 19.3183C27.5835 16.9332 29.5166 15 31.9014 15C34.2863 15 36.2191 16.9332 36.2191 19.3183Z", fill: "#F36719" })] }));
18506
+ };
18507
+
18508
+ const IDeal = ({ className }) => {
18509
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M19.0266 9.91185H35.684C47.003 9.91185 51.3527 16.0977 51.3527 23.9167C51.3527 33.2698 45.273 37.9711 35.684 37.9711H19.0266V9.91185ZM20.6082 11.5944V36.3875H35.6838C44.7786 36.3875 49.7215 32.1316 49.7215 23.9662C49.7215 15.5534 44.3832 11.5944 35.6838 11.5944H20.6082ZM25.0568 24.4115C26.722 24.4115 28.072 23.06 28.072 21.3928C28.072 19.7256 26.722 18.3741 25.0568 18.3741C23.3916 18.3741 22.0417 19.7256 22.0417 21.3928C22.0417 23.06 23.3916 24.4115 25.0568 24.4115ZM22.635 25.6982H27.479V34.309H22.635V25.6982Z", fill: "black" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M44.2351 18.6216H45.6191V22.7785H47.6456C47.1019 15.207 41.1211 13.5244 35.684 13.5244H29.9009V18.6216H30.7412C32.3229 18.6216 33.262 19.6608 33.262 21.3929C33.262 23.1249 32.3229 24.1641 30.7906 24.1641H29.9009V34.309H35.684C44.5317 34.309 47.5468 30.2016 47.6951 24.1641H44.2351V18.6216ZM37.5623 22.7785V24.1641H34.1023V18.6216H37.4634V20.0072H35.4863V20.6505H37.3646V22.0362H35.5357V22.7785H37.5623ZM39.8358 18.6216H41.813L43.4935 24.1641H42.0601L41.7635 23.1249H39.9347L39.6381 24.1641H38.1553L39.8358 18.6216ZM40.3456 21.6898H40.3302V21.7393L40.3456 21.6898ZM40.3456 21.6898H41.3188L40.8739 20.1557H40.8245L40.3456 21.6898ZM29.9009 22.7785V20.0072H30.7412C31.2849 20.0072 31.878 20.1557 31.878 21.3929C31.878 22.63 31.3343 22.7785 30.7412 22.7785H29.9009Z", fill: "#D50072" })] }));
18510
+ };
18511
+
18512
+ const JCB = ({ className }) => {
18513
+ return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M48 27.522C48 30.5171 45.5611 32.956 42.566 32.956H13V11.434C13 8.43887 15.4389 6 18.434 6H48V27.522Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M38.3728 22.0024H40.6191C40.6833 22.0024 40.833 21.981 40.8972 21.981C41.3251 21.8954 41.6888 21.5104 41.6888 20.9755C41.6888 20.4621 41.3251 20.077 40.8972 19.97C40.833 19.9486 40.7047 19.9486 40.6191 19.9486H38.3728V22.0024Z", fill: "url(#paint0_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M40.3625 7.81844C38.2231 7.81844 36.4688 9.55132 36.4688 11.7121V15.7555H41.967C42.0953 15.7555 42.2451 15.7555 42.3521 15.7769C43.5929 15.8411 44.5128 16.4829 44.5128 17.5953C44.5128 18.4725 43.8924 19.2212 42.7371 19.371V19.4138C43.9994 19.4994 44.9621 20.2054 44.9621 21.2964C44.9621 22.4731 43.8924 23.2433 42.4804 23.2433H36.4474V31.1589H42.1595C44.2989 31.1589 46.0532 29.426 46.0532 27.2653V7.81844H40.3625Z", fill: "url(#paint1_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M41.4107 17.852C41.4107 17.3386 41.047 16.9963 40.6191 16.9321C40.5763 16.9321 40.4693 16.9107 40.4052 16.9107H38.3728V18.7933H40.4052C40.4693 18.7933 40.5977 18.7933 40.6191 18.7719C41.047 18.7078 41.4107 18.3655 41.4107 17.852Z", fill: "url(#paint2_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M18.8405 7.81844C16.7011 7.81844 14.9468 9.55132 14.9468 11.7121V21.3178C16.0379 21.8527 17.1718 22.195 18.3056 22.195C19.6534 22.195 20.3808 21.382 20.3808 20.2695V15.7341H23.7182V20.2481C23.7182 22.0024 22.6272 23.4358 18.9261 23.4358C16.6797 23.4358 14.9254 22.9437 14.9254 22.9437V31.1375H20.6375C22.7769 31.1375 24.5312 29.4046 24.5312 27.2439V7.81844H18.8405Z", fill: "url(#paint3_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M29.6015 7.81844C27.4621 7.81844 25.7079 9.55132 25.7079 11.7121V16.8038C26.692 15.9694 28.4035 15.4346 31.1632 15.5629C32.6394 15.6271 34.2225 16.0336 34.2225 16.0336V17.6809C33.431 17.2744 32.4896 16.9107 31.2702 16.8252C29.1736 16.6754 27.9114 17.7023 27.9114 19.4994C27.9114 21.3178 29.1736 22.3447 31.2702 22.1736C32.4896 22.088 33.431 21.7029 34.2225 21.3178V22.9651C34.2225 22.9651 32.6608 23.3716 31.1632 23.4358C28.4035 23.5642 26.692 23.0293 25.7079 22.195V31.1803H31.42C33.5593 31.1803 35.3136 29.4474 35.3136 27.2867V7.81844H29.6015Z", fill: "url(#paint4_linear_1_133)" }), jsxRuntime.jsxs("defs", { children: [jsxRuntime.jsxs("linearGradient", { id: "paint0_linear_1_133", x1: "36.4652", y1: "20.9781", x2: "46.0789", y2: "20.9781", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#007940" }), jsxRuntime.jsx("stop", { offset: "0.2285", "stop-color": "#00873F" }), jsxRuntime.jsx("stop", { offset: "0.7433", "stop-color": "#40A737" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#5CB531" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint1_linear_1_133", x1: "36.465", y1: "19.4793", x2: "46.0794", y2: "19.4793", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#007940" }), jsxRuntime.jsx("stop", { offset: "0.2285", "stop-color": "#00873F" }), jsxRuntime.jsx("stop", { offset: "0.7433", "stop-color": "#40A737" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#5CB531" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint2_linear_1_133", x1: "36.4649", y1: "17.8493", x2: "46.079", y2: "17.8493", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#007940" }), jsxRuntime.jsx("stop", { offset: "0.2285", "stop-color": "#00873F" }), jsxRuntime.jsx("stop", { offset: "0.7433", "stop-color": "#40A737" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#5CB531" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint3_linear_1_133", x1: "14.9423", y1: "19.4793", x2: "24.7049", y2: "19.4793", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#1F286F" }), jsxRuntime.jsx("stop", { offset: "0.4751", "stop-color": "#004E94" }), jsxRuntime.jsx("stop", { offset: "0.8261", "stop-color": "#0066B1" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#006FBC" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint4_linear_1_133", x1: "25.6525", y1: "19.4793", x2: "35.1343", y2: "19.4793", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#6C2C2F" }), jsxRuntime.jsx("stop", { offset: "0.1735", "stop-color": "#882730" }), jsxRuntime.jsx("stop", { offset: "0.5731", "stop-color": "#BE1833" }), jsxRuntime.jsx("stop", { offset: "0.8585", "stop-color": "#DC0436" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#E60039" })] })] })] }));
18514
+ };
18515
+
18516
+ const Cashapp = ({ className }) => {
18517
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { d: "M34.1572 17.6958C34.1572 16.7565 34.9551 16 35.8958 16C36.8366 16 37.6345 16.7648 37.6345 17.6958C37.6345 18.6269 36.8618 19.4166 35.8958 19.4166C34.9299 19.4166 34.1572 18.6518 34.1572 17.6958ZM29 16.2328H32.0238V32.9917H29V16.2328ZM37.4245 21.021H34.3756V32.9917H37.4245V21.021ZM59.3384 26.599C61.6314 25.2024 63.1937 23.1242 63.8068 21.0127H60.7579C59.9599 23.0244 58.1373 24.5374 56.1382 25.1775V16.2328H53.0893V32.9917H56.1382V28.0039C58.4648 28.5775 60.3043 30.5726 60.9342 32.9917H64C63.5296 30.4562 61.7826 28.0787 59.3384 26.6073V26.599ZM42.8253 22.3594C43.6232 21.312 45.1771 20.6968 46.4454 20.6968C48.7972 20.6968 50.7459 22.401 50.7543 24.978V32.9834H47.7053V25.643C47.7053 24.5873 47.2265 23.3653 45.6895 23.3653C43.8752 23.3653 42.8337 24.9614 42.8337 26.8235V33H39.7847V21.0293H42.8337V22.3594H42.8253Z", fill: "black" }), jsxRuntime.jsx("path", { d: "M14.5 34C19.7488 34 24 29.7488 24 24.5C24 19.2513 19.7488 15 14.5 15C9.25125 15 5 19.2513 5 24.5C5 29.7488 9.25125 34 14.5 34Z", fill: "#00D66F" }), jsxRuntime.jsx("path", { d: "M13.8794 19H11C11.5603 21.2993 13.1946 23.2625 15.2412 24.5C13.1868 25.7375 11.5603 27.7007 11 30H13.8794C14.5953 27.8764 16.572 26.0278 19 25.6458V23.3465C16.572 22.9722 14.5953 21.1236 13.8794 19Z", fill: "#011E0F" })] }));
18518
+ };
18519
+
18520
+ const Mastercard = ({ className }) => {
18521
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M35.5 34.3139C33.1169 36.3704 30.0255 37.6119 26.6475 37.6119C19.1102 37.6119 13 31.4308 13 23.806C13 16.1811 19.1102 10 26.6475 10C30.0255 10 33.1169 11.2415 35.5 13.2981C37.8831 11.2415 40.9745 10 44.3525 10C51.8898 10 58 16.1811 58 23.806C58 31.4308 51.8898 37.6119 44.3525 37.6119C40.9745 37.6119 37.8831 36.3704 35.5 34.3139Z", fill: "#ED0006" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M35.5 34.3139C38.4344 31.7816 40.2951 28.0136 40.2951 23.806C40.2951 19.5983 38.4344 15.8303 35.5 13.2981C37.8831 11.2415 40.9745 10 44.3525 10C51.8898 10 58 16.1811 58 23.806C58 31.4308 51.8898 37.6119 44.3525 37.6119C40.9745 37.6119 37.8831 36.3704 35.5 34.3139Z", fill: "#F9A000" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M35.5 13.2981C38.4344 15.8304 40.2951 19.5984 40.2951 23.806C40.2951 28.0136 38.4344 31.7816 35.5 34.3138C32.5657 31.7816 30.705 28.0136 30.705 23.806C30.705 19.5984 32.5657 15.8304 35.5 13.2981Z", fill: "#FF5E00" })] }));
18522
+ };
18523
+
18524
+ const Sepa = ({ className }) => {
18525
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "#10298E", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { d: "M12.7744 16.084C14.4396 16.084 15.6264 16.1801 16.334 16.3701C18.0609 16.8349 18.9248 18.137 18.9248 20.2764C18.9248 20.4518 18.9113 20.714 18.8857 21.0645H14.918C14.918 20.4123 14.8407 19.9748 14.6885 19.752C14.4524 19.4222 13.801 19.2569 12.7344 19.2568C11.6983 19.2568 11.0109 19.3519 10.6758 19.542C10.3409 19.7327 10.1729 20.1477 10.1729 20.7861C10.1729 21.3638 10.3217 21.7443 10.6191 21.9268C10.8324 22.0562 11.1145 22.1325 11.4658 22.1553L12.2656 22.2119C13.9806 22.3259 15.0521 22.4065 15.4795 22.4521C16.8358 22.5891 17.8195 22.9497 18.4297 23.5352C18.9098 23.992 19.1958 24.5898 19.2871 25.3271C19.3405 25.7681 19.3672 26.267 19.3672 26.8213C19.3672 28.0993 19.2457 29.0356 19.002 29.6289C18.5601 30.7174 17.5669 31.4046 16.0225 31.6934C15.3754 31.8154 14.3858 31.8769 13.0547 31.877C10.8322 31.877 9.28274 31.7449 8.4082 31.4785C7.33499 31.1522 6.6276 30.4905 6.28516 29.4951C6.09445 28.941 6.00001 28.0182 6 26.7266H9.96875C9.96875 26.8706 9.96875 26.9808 9.96875 27.0566C9.96876 27.746 10.1668 28.1893 10.5615 28.3867C10.8351 28.5229 11.1654 28.594 11.5537 28.6025H13.0127C13.7572 28.6025 14.2325 28.5649 14.4375 28.4883C14.8023 28.3446 15.0418 28.1131 15.1562 27.793C15.217 27.596 15.247 27.3411 15.2471 27.0293C15.2471 26.3303 14.992 25.9045 14.4834 25.752C14.2928 25.6917 13.4079 25.6075 11.8291 25.501C10.5609 25.4103 9.67998 25.3228 9.18652 25.2383C7.88722 24.9948 7.02094 24.4944 6.58887 23.7344C6.20918 23.0886 6.01956 22.1116 6.01953 20.8047C6.01953 19.8092 6.12198 19.0105 6.32715 18.4102C6.53252 17.8097 6.86368 17.3538 7.32031 17.042C7.98917 16.5635 8.84498 16.2823 9.88672 16.1982C10.7538 16.1225 11.7164 16.084 12.7744 16.084ZM44.2861 16C45.3761 16 46.2079 16.0894 46.7793 16.2676C48.0865 16.6779 48.9639 17.5176 49.4131 18.7871C49.645 19.4533 49.7607 20.4565 49.7607 21.7959C49.7607 23.4063 49.6323 24.564 49.3779 25.2686C48.8682 26.6618 47.8187 27.4648 46.2344 27.6729C46.048 27.7041 45.2548 27.7316 43.8555 27.7539L43.1475 27.7773H40.6045V31.877H36.3389V16H44.2861ZM64 31.877H59.6787L58.8652 29.1328H53.1621L52.3955 31.877H47.9824L52.7441 16H59.1787L64 31.877ZM54.0801 26.04H58.0186L56.0195 19.1572L54.0801 26.04ZM40.6035 24.0947H43.2627C44.1059 24.0643 44.6191 23.9992 44.8037 23.8975C45.0556 23.7585 45.2244 23.4803 45.3086 23.0635C45.3624 22.7859 45.3896 22.3732 45.3896 21.8252C45.3896 21.1539 45.336 20.6561 45.2285 20.3311C45.0751 19.8759 44.7078 19.5988 44.126 19.498C44.011 19.4828 43.7353 19.4746 43.2988 19.4746H40.6035V24.0947Z", fill: "white" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M30.45 18.2337C32.2095 18.2337 33.7797 19.0456 34.8119 20.3173L35.7314 18.3424C34.2933 16.9808 32.336 16.1413 30.1772 16.1413C26.8159 16.1413 23.9406 18.1748 22.7605 21.0533H20.9674L19.9087 23.3269H22.2154C22.1981 23.5378 22.1869 23.7489 22.1869 23.9643C22.1869 24.2249 22.2004 24.4824 22.2262 24.7369H21.0669L20.0083 27.0113H22.8155C24.0293 29.8169 26.8686 31.7866 30.1772 31.7866C31.8445 31.7866 33.3917 31.2862 34.6727 30.4314V27.644C33.6411 28.8205 32.1322 29.564 30.45 29.564C28.4837 29.564 26.754 28.5484 25.7468 27.0113H31.6253L32.6838 24.7369H24.8819C24.8417 24.4632 24.8202 24.1835 24.8202 23.8986C24.8202 23.706 24.8302 23.5153 24.8486 23.3269H33.3399L34.3985 21.0533H25.583C26.5579 19.3679 28.3721 18.2337 30.45 18.2337", fill: "#FFBE00" })] }));
18526
+ };
18527
+
18528
+ const Visa = ({ className }) => {
18529
+ return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M21.2505 32.5165H17.0099L13.8299 20.3847C13.679 19.8267 13.3585 19.3333 12.8871 19.1008C11.7106 18.5165 10.4142 18.0514 9 17.8169V17.3498H15.8313C16.7742 17.3498 17.4813 18.0514 17.5991 18.8663L19.2491 27.6173L23.4877 17.3498H27.6104L21.2505 32.5165ZM29.9675 32.5165H25.9626L29.2604 17.3498H33.2653L29.9675 32.5165ZM38.4467 21.5514C38.5646 20.7346 39.2717 20.2675 40.0967 20.2675C41.3931 20.1502 42.8052 20.3848 43.9838 20.9671L44.6909 17.7016C43.5123 17.2345 42.216 17 41.0395 17C37.1524 17 34.3239 19.1008 34.3239 22.0165C34.3239 24.2346 36.3274 25.3992 37.7417 26.1008C39.2717 26.8004 39.861 27.2675 39.7431 27.9671C39.7431 29.0165 38.5646 29.4836 37.3881 29.4836C35.9739 29.4836 34.5596 29.1338 33.2653 28.5494L32.5582 31.8169C33.9724 32.3992 35.5025 32.6338 36.9167 32.6338C41.2752 32.749 43.9838 30.6502 43.9838 27.5C43.9838 23.5329 38.4467 23.3004 38.4467 21.5514ZM58 32.5165L54.82 17.3498H51.4044C50.6972 17.3498 49.9901 17.8169 49.7544 18.5165L43.8659 32.5165H47.9887L48.8116 30.3004H53.8772L54.3486 32.5165H58ZM51.9936 21.4342L53.1701 27.1502H49.8723L51.9936 21.4342Z", fill: "#172B85" })] }));
18530
+ };
18531
+
18532
+ const CardImage_PaymentMethodFragment = t(`
18533
+ fragment CardImage_PaymentMethodFragment on PaymentMethod {
18534
+ metadata {
18535
+ issuer
18536
+ type
18537
+ }
18538
+ }
18539
+ `);
18540
+ function CardImage({ paymentMethod: maskedPaymentMethod, }) {
18541
+ var _a, _b, _c, _d;
18542
+ // Read fragment
18543
+ const paymentMethod = readFragment(CardImage_PaymentMethodFragment, maskedPaymentMethod);
18544
+ const issuer = (_b = (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.metadata) === null || _a === void 0 ? void 0 : _a.issuer) === null || _b === void 0 ? void 0 : _b.toLowerCase();
18545
+ const type = (_d = (_c = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.metadata) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.toLowerCase();
18546
+ const className = 'w-12 h-8';
18547
+ if (type === 'cashapp') {
18548
+ return jsxRuntime.jsx(Cashapp$1, { className: className });
18549
+ }
18550
+ if (type === 'link') {
18551
+ return jsxRuntime.jsx(Cashapp, { className: className });
18552
+ }
18553
+ switch (issuer) {
18554
+ case 'visa':
18555
+ return jsxRuntime.jsx(Visa, { className: className });
18556
+ case 'mastercard':
18557
+ return jsxRuntime.jsx(Mastercard, { className: className });
18558
+ case 'amex':
18559
+ return jsxRuntime.jsx(Amex, { className: className });
18560
+ case 'jcb':
18561
+ return jsxRuntime.jsx(JCB, { className: className });
18562
+ case 'diners_club':
18563
+ case 'diners':
18564
+ return jsxRuntime.jsx(DinersClub, { className: className });
18565
+ case 'discover':
18566
+ return jsxRuntime.jsx(Discover, { className: className });
18567
+ case 'unionpay':
18568
+ case 'union_pay':
18569
+ case 'china_union_pay':
18570
+ case 'china_unionpay':
18571
+ return jsxRuntime.jsx(ChinaUnionPay, { className: className });
18572
+ case 'sepa':
18573
+ return jsxRuntime.jsx(Sepa, { className: className });
18574
+ case 'ideal':
18575
+ return jsxRuntime.jsx(IDeal, { className: className });
18576
+ case 'bancontact':
18577
+ return jsxRuntime.jsx(Bancontact, { className: className });
18578
+ default:
18579
+ return jsxRuntime.jsx(CreditCard, { className: className });
18580
+ }
18581
+ }
18582
+
18583
+ const { Text: Text$z } = antd.Typography;
18584
+ const MiniCreditCard_PaymentMethodFragment = t(`
18585
+ fragment MiniCreditCard_PaymentMethodFragment on PaymentMethod {
18586
+ ...CardImage_PaymentMethodFragment
18587
+ isDefault
18588
+ metadata {
18589
+ issuer
18590
+ type
18591
+ identifier
18592
+ }
18593
+ id
18594
+ }
18595
+ `, [CardImage_PaymentMethodFragment]);
18596
+ function MiniCreditCard({ className, buttons, hideDropdownMenu = false, hideDefaultTag = false, onClickRemove, paymentMethod: maskedPaymentMethod, onClickSetDefault, id, }) {
18597
+ var _a, _b, _c;
19050
18598
  const { darkMode } = react.useContext(BunnyContext);
19051
- return (jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-col bunny-rounded-md ${className}`, style: {
19052
- ...style,
19053
- backgroundColor: darkMode ? 'var(--row-background-dark)' : 'var(--row-background)',
19054
- }, children: children }));
18599
+ const { brandColor } = useBrand();
18600
+ // Read fragment
18601
+ const paymentMethod = readFragment(MiniCreditCard_PaymentMethodFragment, maskedPaymentMethod);
18602
+ const borderColor = react.useMemo(() => {
18603
+ return darkMode ? 'border-slate-700' : 'border-slate-200';
18604
+ }, [darkMode]);
18605
+ const backgroundColor = react.useMemo(() => {
18606
+ return darkMode ? 'var(--row-background-alternate)' : 'bg-slate-50';
18607
+ }, [darkMode]);
18608
+ const isDefault = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.isDefault;
18609
+ return (jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-row bunny-justify-between bunny-items-center bunny-p-1 bunny-px-3 bunny-border-solid ${backgroundColor} bunny-${borderColor} bunny-rounded-md bunny-border ${className}`, id: id, children: paymentMethod ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-row bunny-gap-4", children: jsxRuntime.jsxs("div", { className: "bunny-flex bunny-items-center bunny-gap-2 bunny-space-between bunny-w-full", children: [jsxRuntime.jsx(CardImage, { paymentMethod: paymentMethod }), jsxRuntime.jsx(Issuer, { issuer: (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.metadata) === null || _a === void 0 ? void 0 : _a.issuer }), jsxRuntime.jsx(Identifier, { type: (_b = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.metadata) === null || _b === void 0 ? void 0 : _b.type, identifier: (_c = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.metadata) === null || _c === void 0 ? void 0 : _c.identifier }), !hideDefaultTag && (jsxRuntime.jsx("div", { children: isDefault ? (jsxRuntime.jsx(antd.Tag, { bordered: false, style: { color: brandColor, backgroundColor: `${brandColor}30` }, children: "Default" })) : null }))] }) }), buttons ? (buttons) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideDropdownMenu && (jsxRuntime.jsx(DropdownMenu, { setDefault: onClickSetDefault, remove: onClickRemove, isDefault: isDefault !== null && isDefault !== void 0 ? isDefault : false, id: `credit-card-dropdown-${paymentMethod.id}` })) }))] })) : (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-row bunny-items-center justify-between w-full", children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-2 bunny-items-center", children: [jsxRuntime.jsx(icons.CreditCardOutlined, {}), jsxRuntime.jsx(Text$z, { className: "bunny-text-slate-400 bunny-text-sm", children: "No payment methods" })] }), jsxRuntime.jsx(antd.Button, { disabled: true, type: "link" }), buttons] })) }));
18610
+ }
18611
+ const Identifier = ({ type, identifier, }) => {
18612
+ if (type === 'link') {
18613
+ return null;
18614
+ }
18615
+ if (type === 'cashapp') {
18616
+ return jsxRuntime.jsx(Text$z, { children: "Cashapp" });
18617
+ }
18618
+ return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Text$z, { className: "relative -top-0.5", children: "****" }), jsxRuntime.jsx(Text$z, { children: identifier })] }));
18619
+ };
18620
+ const Issuer = ({ issuer }) => {
18621
+ const list = ['visa', 'link', 'jcb', 'discover', 'sepa'];
18622
+ if (!issuer || issuer.length == 0 || list.includes(issuer === null || issuer === void 0 ? void 0 : issuer.toLowerCase()))
18623
+ return null;
18624
+ return jsxRuntime.jsx(Text$z, { children: lodashExports.capitalize(issuer) });
18625
+ };
18626
+ const DropdownMenu = ({ setDefault, remove, isDefault, id, }) => {
18627
+ const { brandColor } = useBrand();
18628
+ // Define the menu items
18629
+ const items = [
18630
+ {
18631
+ key: '1',
18632
+ label: 'Remove',
18633
+ disabled: !remove,
18634
+ onClick: () => {
18635
+ remove === null || remove === void 0 ? void 0 : remove();
18636
+ },
18637
+ },
18638
+ {
18639
+ key: '2',
18640
+ label: 'Set as default',
18641
+ onClick: () => {
18642
+ setDefault === null || setDefault === void 0 ? void 0 : setDefault();
18643
+ },
18644
+ disabled: isDefault,
18645
+ },
18646
+ ];
18647
+ return (jsxRuntime.jsx(antd.Dropdown, { menu: { items }, trigger: ['click'], children: jsxRuntime.jsx("a", { onClick: e => e.preventDefault(), id: id, className: "cursor-pointer hover:bg-gray-100 rounded-md p-1", children: jsxRuntime.jsx(icons.EllipsisOutlined, { style: { fontSize: '20px', color: brandColor } }) }) }));
18648
+ };
18649
+
18650
+ const PaymentForm_PaymentMethodsFragment = t(`
18651
+ fragment PaymentForm_PaymentMethodsFragment on PaymentMethod {
18652
+ ...MiniCreditCard_PaymentMethodFragment
18653
+ id
18654
+ }
18655
+ `, [MiniCreditCard_PaymentMethodFragment]);
18656
+
18657
+ const QueryKeyFactory = {
18658
+ accountPaymentMethodsKey: ({ accountId, entityId, token }) => [
18659
+ 'accountPaymentMethods',
18660
+ ...(entityId ? [entityId] : []),
18661
+ ...(accountId ? [accountId] : []),
18662
+ ...(token ? [token] : []),
18663
+ ],
18664
+ billingDetailsKey: ({ entityId, token }) => [
18665
+ 'billingDetails',
18666
+ ...(entityId ? [entityId] : []),
18667
+ ...(token ? [token] : []),
18668
+ ],
18669
+ brandingKey: (token) => ['branding', ...(token ? [token] : [])],
18670
+ calculatedPricesKey: ({ priceListId, quantity, token }) => [
18671
+ 'calculatedPrices',
18672
+ ...(priceListId ? [priceListId] : []),
18673
+ ...(quantity ? [quantity] : []),
18674
+ ...(token ? [token] : []),
18675
+ ],
18676
+ createEventsKey: ({ entityId, pluralType, token }) => [
18677
+ pluralType,
18678
+ 'events',
18679
+ entityId,
18680
+ ...(token ? [token] : []),
18681
+ ],
18682
+ createFormattedInvoiceKey: ({ id, token }) => [
18683
+ 'formattedInvoice',
18684
+ id,
18685
+ ...(token ? [token] : []),
18686
+ ],
18687
+ createInvoiceKey: ({ id, token }) => ['invoice', id, token],
18688
+ createObjectKey: ({ id, objectName, token }) => [
18689
+ objectName,
18690
+ ...(id ? [id] : []),
18691
+ ...(token ? [token] : []),
18692
+ ],
18693
+ createQuoteKey: ({ id, token }) => ['quote', id, token],
18694
+ createQuoteTaxCalculateKey: ({ id, token }) => [
18695
+ 'quoteTaxCalculate',
18696
+ ...(id ? [id] : []),
18697
+ ...(token ? [token] : []),
18698
+ ],
18699
+ createTableKey: ({ filterString, pluralType, token }) => filterString ? [pluralType, 'list', filterString, token] : [pluralType, 'list', token],
18700
+ currentUserKey: (token) => ['currentUser', ...(token ? [token] : [])],
18701
+ editingQuoteKey: (token) => ['editingQuote', ...(token ? [token] : [])],
18702
+ finixAchKey: (token) => ['finixAchKey', ...(token ? [token] : [])],
18703
+ finixKey: (token) => ['finixKey', ...(token ? [token] : [])],
18704
+ planChangeOptionsKey: ({ subscriptionId, productId, token }) => [
18705
+ 'planChangeOptions',
18706
+ ...(subscriptionId ? [subscriptionId] : []),
18707
+ ...(productId ? [productId] : []),
18708
+ ...(token ? [token] : []),
18709
+ ],
18710
+ pluginsKey: (token) => ['plugins', ...(token ? [token] : [])],
18711
+ portalPreviewDataKey: ({ productId, token }) => [
18712
+ 'portalPreviewData',
18713
+ ...(productId ? [productId] : []),
18714
+ ...(token ? [token] : []),
18715
+ ],
18716
+ taxationRequiredAccountFieldsKey: ({ entityId, token, }) => [
18717
+ 'taxationRequiredAccountFields',
18718
+ ...(entityId ? [entityId] : []),
18719
+ ...(token ? [token] : []),
18720
+ ],
18721
+ transactionsKey: ({ filter, token }) => [
18722
+ 'transactions',
18723
+ ...(filter ? [filter] : []),
18724
+ ...(token ? [token] : []),
18725
+ ],
18726
+ availableAddonPlansKey: ({ priceListId, token, }) => ['availableAddonPlans', priceListId, ...(token ? [token] : [])],
18727
+ addonPlansKey: ({ priceListId, token }) => [
18728
+ 'addonPlans',
18729
+ priceListId,
18730
+ ...(token ? [token] : []),
18731
+ ],
18732
+ paymentPluginsKey: (token) => ['paymentPlugins', ...(token ? [token] : [])],
19055
18733
  };
19056
18734
 
19057
- const tagStyleMap = {
19058
- blue: { color: 'var(--bunny-blue-500)', background: 'var(--bunny-blue-200)' },
19059
- green: {
19060
- color: 'var(--bunny-green-600)',
19061
- background: 'var(--bunny-green-200)',
19062
- },
19063
- red: { color: 'var(--bunny-red-500)', background: 'var(--bunny-red-200)' },
19064
- orange: {
19065
- color: 'var(--bunny-orange-500)',
19066
- background: 'var(--bunny-orange-200)',
19067
- },
19068
- yellow: {
19069
- color: 'var(--bunny-yellow-500)',
19070
- background: 'var(--bunny-yellow-200)',
19071
- },
19072
- purple: {
19073
- color: 'var(--bunny-purple-500)',
19074
- background: 'var(--bunny-purple-200)',
19075
- },
19076
- black: { color: 'white', background: 'var(--bunny-black)' },
18735
+ const query$5 = t(`
18736
+ query PaymentMethods($accountId: ID) {
18737
+ paymentMethods(accountId: $accountId) {
18738
+ nodes {
18739
+ id
18740
+ pluginId
18741
+ accountId
18742
+ expirationDate
18743
+ plugin {
18744
+ guid
18745
+ id
18746
+ }
18747
+ state
18748
+ metadata {
18749
+ issuer
18750
+ identifier
18751
+ kind
18752
+ description
18753
+ icon
18754
+ type
18755
+ }
18756
+ isDefault
18757
+ ...PaymentForm_PaymentMethodsFragment
18758
+ }
18759
+ }
18760
+ }
18761
+ `, [PaymentForm_PaymentMethodsFragment]);
18762
+ const getPaymentMethods = async ({ apiHost, token, accountId, }) => {
18763
+ var _a, _b, _c;
18764
+ const response = await execute(query$5, { apiHost, token }, { accountId });
18765
+ // Filter out null values that are technically possible due to api schema
18766
+ return (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.paymentMethods) === null || _a === void 0 ? void 0 : _a.nodes) === null || _b === void 0 ? void 0 : _b.filter(paymentMethod => paymentMethod !== null)) !== null && _c !== void 0 ? _c : [];
19077
18767
  };
19078
- // This component provides custom styling for antd Tag components without using antd overwrites.
19079
- // Please use this component instead of the antd Tag component directly to maintain consistent styling.
19080
- const CustomizedTag = ({ children, color, className, style, }) => {
19081
- return (jsxRuntime.jsx(antd.Tag, { color: color, style: { ...(color ? tagStyleMap[color] : undefined), ...style }, className: `bunny-m-0 bunny-rounded-full bunny-border-none bunny-whitespace-nowrap ${className}`, children: children }));
18768
+ const usePaymentMethod = ({ accountId, enabled = true, }) => {
18769
+ // Context
18770
+ const { apiHost } = react.useContext(BunnyContext);
18771
+ const token = useToken();
18772
+ // Query
18773
+ const { data, isLoading } = reactQuery.useQuery({
18774
+ queryKey: QueryKeyFactory.accountPaymentMethodsKey({
18775
+ accountId,
18776
+ token,
18777
+ }),
18778
+ queryFn: () => getPaymentMethods({ apiHost, token, accountId }),
18779
+ staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
18780
+ enabled,
18781
+ });
18782
+ return {
18783
+ paymentMethods: data,
18784
+ defaultPaymentMethod: data === null || data === void 0 ? void 0 : data.find(paymentMethod => paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.isDefault),
18785
+ isLoading,
18786
+ };
19082
18787
  };
19083
18788
 
19084
- const Amex = ({ className }) => {
19085
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "#1F72CD", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M12.5493 17L6 31.4935H13.8405L14.8125 29.1826H17.0342L18.0062 31.4935H26.6364V29.7298L27.4054 31.4935H31.8696L32.6386 29.6925V31.4935H50.587L52.7695 29.2426L54.813 31.4935L64.0317 31.5121L57.4617 24.2872L64.0317 17H54.956L52.8315 19.2093L50.8523 17H31.3268L29.6501 20.7409L27.9341 17H20.11V18.7037L19.2396 17H12.5493ZM39.3516 19.0581H49.6584L52.8108 22.4633L56.0648 19.0581H59.2172L54.4275 24.2852L59.2172 29.452H55.9218L52.7695 26.0073L49.4989 29.452H39.3516V19.0581ZM41.8968 23.1099V21.2114V21.2096H48.328L51.1342 24.2458L48.2036 27.2986H41.8968V25.226H47.5197V23.1099H41.8968ZM14.0664 19.0581H17.8883L22.2324 28.8862V19.0581H26.4191L29.7745 26.1048L32.8668 19.0581H37.0326V29.4581H34.4978L34.4771 21.3087L30.7817 29.4581H28.5142L24.7981 21.3087V29.4581H19.5836L18.595 27.1266H13.254L12.2675 29.4561H9.47358L14.0664 19.0581ZM14.166 24.9712L15.9256 20.8177L17.6832 24.9712H14.166Z", fill: "white" })] }));
18789
+ const mutation$5 = t(`
18790
+ query PaymentPlugins($accountId: ID) {
18791
+ paymentPlugins(accountId: $accountId) {
18792
+ enabled
18793
+ entities
18794
+ guid
18795
+ hidden
18796
+ id
18797
+ name
18798
+ status
18799
+ type
18800
+ webhookEnabled
18801
+ components
18802
+ }
18803
+ }
18804
+ `);
18805
+ // components is json, but will look like this
18806
+ // components: {
18807
+ // frontend: {
18808
+ // name: string;
18809
+ // scenarios: string[];
18810
+ // }[];
18811
+ // backend: {
18812
+ // name: string;
18813
+ // access: string[];
18814
+ // }[];
18815
+ // };
18816
+ const getPaymentPlugins = async ({ apiHost, token, accountId, }) => {
18817
+ const response = await execute(mutation$5, { apiHost, token }, { accountId });
18818
+ return response === null || response === void 0 ? void 0 : response.paymentPlugins;
19086
18819
  };
19087
-
19088
- const Cashapp$1 = ({ className }) => {
19089
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsxs("g", { "clip-path": "url(#clip0_550_235)", children: [jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M26.4382 8C22.3647 8 19.0625 11.3022 19.0625 15.3758V32.6242C19.0625 36.6978 22.3647 40 26.4382 40H43.5153C47.5889 40 50.8911 36.6978 50.8911 32.6242V15.3758C50.8911 11.3022 47.5889 8 43.5153 8H26.4382Z", fill: "#00D632" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M40.1482 19.902C38.9333 18.8737 37.3938 18.3084 35.8022 18.3059C34.4908 18.3059 33.1795 18.7405 33.1795 19.9469C33.1795 21.0467 34.347 21.4771 35.7853 22.0072C35.9248 22.0586 36.0668 22.111 36.2105 22.1649C39.0542 23.1241 41.3959 24.3005 41.3959 27.088C41.3959 30.1153 39.0467 32.1835 35.2026 32.4195L34.8542 34.0418C34.7887 34.3448 34.5199 34.5605 34.2098 34.5589H31.7932C31.5955 34.554 31.4102 34.4618 31.2872 34.307C31.1642 34.1521 31.1163 33.9507 31.1563 33.7571L31.531 32.0448C30.08 31.6748 28.7461 30.9441 27.6532 29.9205C27.5265 29.7983 27.4551 29.63 27.4551 29.454C27.4551 29.2781 27.5265 29.1097 27.6532 28.9876L28.9945 27.6763C29.2482 27.4268 29.655 27.4268 29.9086 27.6763C31.1374 28.8485 32.7778 29.4904 34.4758 29.4634C36.2255 29.4634 37.4132 28.7215 37.4132 27.5451C37.4132 26.4815 36.4394 26.1253 34.5914 25.4494C34.3953 25.3776 34.1894 25.3024 33.9738 25.2222C31.5984 24.3755 29.3504 23.1653 29.3504 20.3516C29.3504 17.0958 32.0705 15.5072 35.2776 15.3498L35.6148 13.6975C35.6816 13.3974 35.948 13.1839 36.2555 13.1842H38.6646C38.8609 13.1836 39.0469 13.2714 39.1712 13.4233C39.2955 13.5752 39.3447 13.775 39.3052 13.9673L38.9306 15.8144C40.157 16.2153 41.2935 16.8516 42.2764 17.6877C42.4118 17.8042 42.4925 17.972 42.4989 18.1505C42.5053 18.3291 42.4368 18.5022 42.31 18.6281L41.0587 19.8833C40.8081 20.1298 40.4087 20.138 40.1482 19.902Z", fill: "white" })] }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_550_235", children: jsxRuntime.jsx("rect", { width: "32", height: "32", fill: "white", transform: "translate(19 8)" }) }) })] }));
18820
+ const usePaymentPlugins = (accountId) => {
18821
+ var _a;
18822
+ // Context
18823
+ const { apiHost } = react.useContext(BunnyContext);
18824
+ const token = useToken();
18825
+ // Query
18826
+ const { data: paymentPlugins, isFetched } = reactQuery.useQuery({
18827
+ queryKey: QueryKeyFactory.paymentPluginsKey(token),
18828
+ queryFn: () => getPaymentPlugins({ apiHost, token, accountId }),
18829
+ staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
18830
+ });
18831
+ // filter plugins
18832
+ const filteredPaymentPlugins = (_a = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.filter(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'; })) !== null && _a !== void 0 ? _a : [];
18833
+ return {
18834
+ paymentPlugins: filteredPaymentPlugins,
18835
+ isFetched,
18836
+ };
19090
18837
  };
19091
18838
 
19092
- const ChinaUnionPay = ({ className }) => {
19093
- return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M18.2466 6.855H27.4811C28.7703 6.855 29.5728 7.90603 29.272 9.20036L24.972 27.6585C24.6682 28.949 23.3782 30 22.0886 30H12.8537C11.5641 30 10.7624 28.949 11.0632 27.6585L15.3654 9.20036C15.6653 7.90603 16.9545 6.855 18.2466 6.855Z", fill: "#ED171F" }), jsxRuntime.jsx("path", { d: "M26.7132 6.855H37.3336C38.6223 6.855 38.0411 7.90603 37.7381 9.20036L33.4385 27.6585C33.1382 28.949 33.2324 30 31.9402 30H21.3206C20.0298 30 19.2303 28.949 19.5336 27.6585L23.8315 9.20036C24.1353 7.90603 25.424 6.855 26.7132 6.855Z", fill: "#082F67" }), jsxRuntime.jsx("path", { d: "M36.9136 6.855H46.1468C47.4368 6.855 48.2384 7.90603 47.9364 9.20036L43.6372 27.6585C43.3351 28.949 42.0455 30 40.7516 30H31.521C30.2288 30 29.4285 28.949 29.7314 27.6585L34.0293 9.20036C34.3318 7.90603 35.621 6.855 36.9136 6.855Z", fill: "#006A65" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M38.4247 20.4849L37.2994 24.2089H37.6019L37.3681 24.979H37.0656L36.9951 25.218H35.9242L35.9968 24.979H33.82L34.0387 24.2664H34.2587L35.4005 20.4849L35.6286 19.7209H36.7212L36.6071 20.1072C36.6071 20.1072 36.8979 19.8972 37.1741 19.8254C37.4502 19.7528 39.0337 19.7265 39.0337 19.7265L38.799 20.4849H38.4247ZM36.4995 20.4849L36.2103 21.4365C36.2103 21.4365 36.5336 21.2909 36.7112 21.2421C36.8901 21.1958 37.1589 21.1777 37.1589 21.1777L37.3681 20.4849H36.4995ZM36.0669 21.9098L35.7678 22.8994C35.7678 22.8994 36.0984 22.73 36.276 22.6773C36.4549 22.6358 36.7255 22.6021 36.7255 22.6021L36.9377 21.9098H36.0669ZM35.3702 24.2197H36.241L36.4925 23.383H35.6217L35.3702 24.2197Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M38.9076 19.7265H40.0736L40.0866 20.1613C40.0797 20.2343 40.1427 20.2689 40.2776 20.2689H40.5144L40.2979 20.9863H39.6687C39.1224 21.0265 38.9163 20.7918 38.9284 20.5286L38.9076 19.7265Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M39.0602 23.1305H37.9487L38.1397 22.4909H39.4099L39.5918 21.9079H38.3368L38.5525 21.1875H42.0439L41.8252 21.9079H40.6545L40.4713 22.4909H41.6446L41.4514 23.1305H40.1808L39.9561 23.3998H40.4713L40.5962 24.2049C40.6096 24.284 40.6121 24.3363 40.6372 24.3708C40.6631 24.4006 40.8174 24.4145 40.9069 24.4145H41.0633L40.8256 25.198H40.4293C40.368 25.198 40.2772 25.1928 40.1532 25.1863C40.033 25.1759 39.9479 25.1064 39.8684 25.0683C39.7958 25.032 39.6869 24.9439 39.6618 24.7939L39.5374 23.9905L38.9608 24.7831C38.7772 25.032 38.5291 25.2226 38.1108 25.2226H37.3009L37.5131 24.5238H37.8221C37.9116 24.5238 37.9906 24.4888 38.0485 24.4586C38.1082 24.4335 38.1605 24.4037 38.2201 24.3155L39.0602 23.1305Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M26.8864 21.3815H29.8294L29.612 22.0842H28.4348L28.252 22.6818H29.456L29.2365 23.4075H28.0333L27.7416 24.3811C27.7057 24.4892 28.026 24.5043 28.1418 24.5043L28.7451 24.4209L28.5035 25.223H27.1457C27.0389 25.223 26.9555 25.2079 26.8371 25.1811C26.7226 25.1525 26.672 25.1015 26.6214 25.0237C26.5722 24.9438 26.497 24.879 26.548 24.7096L26.9374 23.42H26.2692L26.4909 22.6818H27.1629L27.3414 22.0842H26.672L26.8864 21.3815Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M28.8682 20.1195H30.0752L29.8544 20.8541H28.2052L28.0259 21.0084C27.9498 21.0832 27.923 21.0516 27.8232 21.1057C27.7303 21.1532 27.5337 21.2461 27.28 21.2461H26.7506L26.9658 20.5395H27.1244C27.2588 20.5395 27.35 20.5283 27.3962 20.4985C27.449 20.4656 27.5073 20.3909 27.5751 20.269L27.8777 19.718H29.0786L28.8682 20.1195Z", fill: "white" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M30.5938 19.7264H31.6223L31.4728 20.2437C31.4728 20.2437 31.7969 19.9848 32.0247 19.8923C32.2511 19.8072 32.7641 19.7311 32.7641 19.7311L34.428 19.7225L33.861 21.6106C33.7659 21.9347 33.6548 22.1439 33.5852 22.239C33.5217 22.3366 33.4482 22.4183 33.3026 22.4974C33.1626 22.5722 33.0351 22.6154 32.9175 22.6275C32.8073 22.6357 32.6388 22.64 32.4046 22.6422H30.8025L30.3501 24.1366C30.3073 24.284 30.2865 24.354 30.3146 24.3937C30.3384 24.43 30.3928 24.4702 30.468 24.4702L31.1746 24.4037L30.9339 25.2226H30.1413C29.8898 25.2226 29.7066 25.2174 29.5778 25.2075C29.4559 25.198 29.3284 25.2075 29.2441 25.1414C29.1694 25.0766 29.0574 24.9918 29.06 24.9041C29.0683 24.8229 29.1011 24.688 29.1534 24.5039L30.5938 19.7264ZM32.7775 21.6344H31.0912L30.9884 21.9749H32.4473C32.6198 21.9533 32.6552 21.9779 32.669 21.9697L32.7775 21.6344ZM31.185 21.3271C31.185 21.3271 31.5139 21.0263 32.0778 20.9286C32.2062 20.9036 33.0083 20.9118 33.0083 20.9118L33.1297 20.5081H31.4305L31.185 21.3271Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M33.5921 22.7747L33.4979 23.2285C33.4559 23.3693 33.4209 23.4778 33.3138 23.5686C33.2027 23.6632 33.0696 23.763 32.7606 23.763L32.191 23.7859L32.1862 24.2998C32.1785 24.4459 32.2178 24.4303 32.2411 24.4541C32.2675 24.4787 32.2904 24.4904 32.3168 24.4986L32.4961 24.4904L33.0415 24.4584L32.8168 25.2078H32.191C31.7524 25.2078 31.4274 25.1983 31.3202 25.1127C31.2156 25.0466 31.2018 24.9619 31.2048 24.8188L31.2441 22.8201H32.242L32.2295 23.2285H32.4702C32.5523 23.2285 32.6063 23.2198 32.6417 23.1986C32.6707 23.1749 32.6936 23.1437 32.7096 23.0932L32.8068 22.7747H33.5921Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M19.3395 12.7519C19.3032 12.9127 18.6632 15.8704 18.6606 15.8722C18.5219 16.4698 18.4238 16.8985 18.0824 17.1721C17.8887 17.3311 17.6623 17.4094 17.4008 17.4094C16.9808 17.4094 16.734 17.2006 16.6921 16.8035L16.6843 16.6678C16.6843 16.6678 16.8122 15.8652 16.814 15.8622C16.814 15.8622 17.486 13.1664 17.6065 12.8116C17.6117 12.7917 17.6143 12.7817 17.6169 12.7714C16.3075 12.783 16.0745 12.7714 16.0594 12.7519C16.052 12.7783 16.017 12.946 16.017 12.946L15.3299 15.9815L15.2703 16.2408L15.1579 17.0826C15.1579 17.3311 15.2072 17.536 15.3044 17.7084C15.6177 18.2564 16.511 18.3377 17.0149 18.3377C17.6662 18.3377 18.2751 18.1985 18.6874 17.9478C19.4026 17.5243 19.591 16.8614 19.7583 16.2754L19.8352 15.975C19.8352 15.975 20.5288 13.1759 20.6473 12.8116C20.6507 12.7917 20.6529 12.7817 20.6576 12.7714C19.709 12.7817 19.4298 12.7714 19.3395 12.7519Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M23.1723 18.3077C22.7073 18.3012 22.5444 18.3012 22.0011 18.3289L21.98 18.2887C22.0279 18.0821 22.0794 17.8785 22.1252 17.6689L22.1917 17.3867C22.2924 16.9464 22.3909 16.4347 22.4026 16.2804C22.4121 16.1862 22.4432 15.952 22.1757 15.952C22.0625 15.952 21.9449 16.0073 21.8265 16.0613C21.7608 16.2955 21.6282 16.9515 21.5672 17.2519C21.432 17.8829 21.4233 17.9542 21.3633 18.2666L21.3244 18.3077C20.8451 18.3012 20.6796 18.3012 20.1286 18.3289L20.1026 18.283C20.1951 17.9079 20.2867 17.5298 20.3749 17.1555C20.6057 16.1395 20.6601 15.7501 20.7245 15.2337L20.7677 15.203C21.3049 15.1278 21.435 15.1131 22.0163 14.9934L22.0655 15.0483L21.9778 15.372C22.0759 15.3141 22.1688 15.2549 22.2704 15.203C22.5444 15.0682 22.8495 15.0284 23.0176 15.0284C23.2713 15.0284 23.5496 15.0997 23.6663 15.394C23.7769 15.6564 23.7039 15.9805 23.5586 16.6175L23.4835 16.9412C23.3344 17.6504 23.3102 17.78 23.2267 18.2666L23.1723 18.3077Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M25.0585 18.3077C24.7793 18.3064 24.5995 18.3012 24.4232 18.3064C24.2486 18.3077 24.0779 18.3168 23.8182 18.3289L23.8026 18.3064L23.7853 18.283C23.8562 18.0142 23.8964 17.92 23.9309 17.8245C23.9664 17.7299 24.001 17.6339 24.0623 17.3612C24.1436 17.006 24.1937 16.7571 24.2296 16.5397C24.2667 16.3284 24.2879 16.1495 24.3143 15.9416L24.3359 15.9252L24.3592 15.9053C24.6371 15.866 24.8147 15.84 24.9945 15.8124C25.1769 15.786 25.3605 15.7501 25.6488 15.6957L25.66 15.7207L25.6678 15.7462C25.6142 15.9662 25.5598 16.1862 25.5075 16.41C25.4561 16.6326 25.4016 16.8513 25.3532 17.073C25.2478 17.541 25.2067 17.7148 25.1816 17.8396C25.1587 17.9589 25.1509 18.0237 25.1095 18.2666L25.0844 18.2887L25.0585 18.3077Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M29.2305 16.7091C29.3935 15.9948 29.2686 15.6607 29.1091 15.4563C28.8658 15.1477 28.4397 15.0479 27.9958 15.0479C27.7301 15.0479 27.0952 15.0751 26.5987 15.5332C26.2443 15.8621 26.0779 16.3107 25.9781 16.7389C25.8782 17.175 25.7628 17.9641 26.4867 18.2567C26.7114 18.3509 27.0313 18.3777 27.2396 18.3777C27.7698 18.3777 28.3135 18.2312 28.7206 17.7982C29.0382 17.446 29.1813 16.923 29.2305 16.7091ZM28.0166 16.6573C27.9911 16.777 27.8865 17.2256 27.7426 17.4161C27.6432 17.5562 27.5252 17.6404 27.3947 17.6404C27.358 17.6404 27.1285 17.6404 27.1242 17.2999C27.1216 17.1322 27.1566 16.9576 27.1985 16.7718C27.3208 16.2307 27.4651 15.7769 27.8329 15.7769C28.1225 15.7769 28.1415 16.1145 28.0166 16.6573Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M40.5855 18.3561C40.0254 18.3509 39.8642 18.3509 39.3465 18.373L39.3115 18.331C39.4532 17.7982 39.595 17.267 39.7199 16.7286C39.8819 16.0298 39.9191 15.7329 39.9736 15.324L40.0155 15.2895C40.5713 15.2095 40.726 15.1875 41.3059 15.0803L41.3241 15.1278C41.2178 15.566 41.1115 16.0047 41.0103 16.4446C40.7964 17.3664 40.7186 17.8349 40.6365 18.3163L40.5855 18.3561Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M40.8523 16.7721C41.0152 16.0612 40.3601 16.7094 40.2551 16.4748C40.0943 16.1092 40.195 15.3671 39.5493 15.1195C39.3017 15.0231 38.7183 15.148 38.2204 15.6031C37.8682 15.9307 37.7005 16.3736 37.6016 16.8015C37.5013 17.2315 37.3864 18.0189 38.1063 18.3015C38.3337 18.3979 38.5424 18.4256 38.7498 18.4173C39.4741 18.378 40.0265 17.2855 40.434 16.852C40.749 16.5098 40.8043 16.9808 40.8523 16.7721ZM39.7442 16.7189C39.717 16.833 39.612 17.2868 39.4681 17.4744C39.373 17.6088 39.1466 17.6939 39.0169 17.6939C38.9802 17.6939 38.7524 17.6939 38.7442 17.3564C38.7425 17.1904 38.7775 17.0158 38.8207 16.8283C38.943 16.2989 39.0874 15.8468 39.4551 15.8468C39.7451 15.8468 39.8687 16.1761 39.7442 16.7189Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M32.4031 18.3077C31.9372 18.3012 31.7795 18.3012 31.2319 18.3289L31.2125 18.2887C31.2587 18.0821 31.3114 17.8785 31.3598 17.6689L31.4251 17.3867C31.5262 16.9464 31.6243 16.4347 31.6355 16.2804C31.6446 16.1862 31.6757 15.952 31.4104 15.952C31.2954 15.952 31.1792 16.0073 31.0599 16.0613C30.9951 16.2955 30.862 16.9515 30.798 17.2519C30.6653 17.8829 30.6563 17.9542 30.5962 18.2666L30.5564 18.3077C30.0776 18.3012 29.9134 18.3012 29.3637 18.3289L29.3386 18.283C29.4302 17.9079 29.5201 17.5298 29.6083 17.1555C29.8386 16.1395 29.8935 15.7501 29.9575 15.2337L30.0007 15.203C30.5378 15.1278 30.6684 15.1131 31.2496 14.9934L31.2954 15.0483L31.2112 15.372C31.3067 15.3141 31.4039 15.2549 31.5029 15.203C31.7751 15.0682 32.0828 15.0284 32.2475 15.0284C32.502 15.0284 32.7808 15.0997 32.9005 15.394C33.0098 15.6564 32.9359 15.9805 32.7894 16.6175L32.7164 16.9412C32.5643 17.6504 32.5409 17.78 32.4605 18.2666L32.4031 18.3077Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M36.9307 14.4822C36.8486 14.8504 36.6096 15.1629 36.3006 15.3137C36.0452 15.4421 35.7344 15.4516 35.4129 15.4516H35.2059L35.2215 15.369C35.2215 15.369 35.6048 13.7048 35.6031 13.71L35.6143 13.6248L35.6212 13.5591L35.7742 13.5751C35.7742 13.5751 36.5616 13.6434 36.5815 13.6456C36.8931 13.764 37.0201 14.0769 36.9307 14.4822ZM36.4276 12.7467C36.4255 12.7467 36.0417 12.7518 36.0417 12.7518C35.0378 12.7631 34.6354 12.7583 34.4703 12.7385C34.4531 12.8119 34.428 12.9424 34.428 12.9424L34.0693 14.6115C34.0693 14.6115 33.2097 18.1565 33.1687 18.3229C34.0447 18.3134 34.4042 18.3134 34.5542 18.3285C34.5883 18.1621 34.7932 17.172 34.7932 17.172C34.7932 17.172 34.9682 16.4447 34.9786 16.4179C34.9786 16.4179 35.0326 16.3436 35.0883 16.3137H35.1683C35.9233 16.3137 36.7781 16.3137 37.4462 15.8206C37.9004 15.4831 38.2138 14.9848 38.3516 14.3802C38.3888 14.2316 38.4147 14.0535 38.4147 13.8772C38.4147 13.6456 38.368 13.4161 38.2323 13.2363C37.8918 12.7583 37.2142 12.7518 36.4276 12.7467Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M45.1748 15.0751L45.1303 15.0254C44.5581 15.1399 44.4535 15.1598 43.9263 15.2293L43.8865 15.2674C43.8848 15.2739 43.8831 15.2842 43.8818 15.2924L43.8792 15.2842C43.4868 16.1913 43.4993 15.9951 43.1791 16.7073C43.1769 16.6736 43.1765 16.6525 43.1756 16.6187L43.0961 15.0751L43.0455 15.0254C42.4466 15.1399 42.4306 15.1598 41.8761 15.2293L41.8316 15.2674C41.8277 15.2877 41.8264 15.3076 41.8234 15.3292L41.8277 15.3374C41.8968 15.6931 41.8809 15.6131 41.9496 16.171C41.982 16.445 42.0243 16.7225 42.0567 16.9926C42.1121 17.4463 42.1423 17.6706 42.208 18.3612C41.835 18.981 41.7447 19.2148 41.3882 19.7584L41.4072 19.8077C41.9496 19.7874 42.0745 19.7874 42.4755 19.7874L42.5641 19.6884C42.8671 19.0354 45.1748 15.0751 45.1748 15.0751Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M25.5693 15.4586C25.8753 15.2447 25.9146 14.9491 25.6553 14.7957C25.3926 14.6414 24.9353 14.6898 24.6259 14.9042C24.3143 15.1151 24.2802 15.4115 24.5399 15.5662C24.8001 15.7171 25.2595 15.673 25.5693 15.4586Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M42.5238 19.7429L42.0727 20.5152C41.93 20.7788 41.6651 20.9771 41.2442 20.9784L40.5255 20.9668L40.7347 20.2706H40.8738C40.9477 20.2706 41.0018 20.2658 41.0432 20.2455C41.0787 20.2343 41.105 20.2062 41.1344 20.1647L41.3993 19.7429H42.5238Z", fill: "white" })] }));
18839
+ var BreakpointNumbers;
18840
+ (function (BreakpointNumbers) {
18841
+ BreakpointNumbers[BreakpointNumbers["xs"] = 480] = "xs";
18842
+ BreakpointNumbers[BreakpointNumbers["sm"] = 768] = "sm";
18843
+ BreakpointNumbers[BreakpointNumbers["md"] = 992] = "md";
18844
+ BreakpointNumbers[BreakpointNumbers["lg"] = 1200] = "lg";
18845
+ BreakpointNumbers[BreakpointNumbers["xl"] = 1400] = "xl";
18846
+ BreakpointNumbers[BreakpointNumbers["xxl"] = 2000] = "xxl";
18847
+ })(BreakpointNumbers || (BreakpointNumbers = {}));
18848
+ const useIsMobile = (breakpointSize = BreakpointNumbers.sm) => {
18849
+ const [isMobile, setIsMobile] = react.useState(() => window.innerWidth < breakpointSize);
18850
+ react.useEffect(() => {
18851
+ const handleResize = () => {
18852
+ const newIsMobile = window.innerWidth < breakpointSize;
18853
+ setIsMobile(prev => (prev !== newIsMobile ? newIsMobile : prev));
18854
+ };
18855
+ window.addEventListener('resize', handleResize);
18856
+ return () => window.removeEventListener('resize', handleResize);
18857
+ }, [breakpointSize]);
18858
+ return isMobile;
19094
18859
  };
19095
18860
 
19096
- const CreditCard = ({ className }) => {
19097
- return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M1 10L59 10", stroke: "#D3D3D3", "stroke-width": "7" }), jsxRuntime.jsx("path", { d: "M5 20H34", stroke: "#D3D3D3", "stroke-width": "2", strokeLinecap: "round" }), jsxRuntime.jsx("path", { d: "M5 27H25", stroke: "#D3D3D3", "stroke-width": "2", strokeLinecap: "round" }), jsxRuntime.jsx("rect", { x: "46", y: "21", width: "10", height: "7", rx: "2", fill: "#D9D9D9" })] }));
18861
+ /**
18862
+ * Creates a context and provider for a state value
18863
+ * @param useValue - A function that returns the state value
18864
+ * @returns A tuple containing the provider and the context value
18865
+ * @example take a look at how this is used in the quoteIdContext in the QuantityDrawer
18866
+ */
18867
+ const createStateContext = (useValue) => {
18868
+ const StateContext = react.createContext(null);
18869
+ const StateProvider = ({ initialValue, children, }) => jsxRuntime.jsxs(StateContext.Provider, { value: useValue(initialValue), children: [" ", children, " "] });
18870
+ const useContextState = () => {
18871
+ const value = react.useContext(StateContext);
18872
+ if (value === null) {
18873
+ throw new Error('Provider missing');
18874
+ }
18875
+ return value;
18876
+ };
18877
+ return [StateProvider, useContextState];
19098
18878
  };
19099
18879
 
19100
- const DinersClub = ({ className }) => {
19101
- return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M16.5247 19.2244C16.5247 12.2923 21.9422 6.67337 28.6257 6.67337C35.309 6.67337 40.7267 12.2923 40.7267 19.2244C40.7267 26.1563 35.309 31.7755 28.6257 31.7755C21.9422 31.7755 16.5247 26.1563 16.5247 19.2244Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M35.9447 18.977C35.9391 15.7623 34.0025 13.0219 31.2728 11.9361V26.0177C34.0025 24.9305 35.9391 22.1925 35.9447 18.977ZM26.0659 26.0146V11.937C23.3393 13.0268 21.4049 15.7642 21.3979 18.977C21.4049 22.1892 23.3393 24.9272 26.0659 26.0146ZM28.6708 7.07501C22.3335 7.07748 17.1989 12.404 17.1981 18.977C17.1989 25.5492 22.3335 30.8749 28.6708 30.8758C35.0083 30.8749 40.1444 25.5492 40.146 18.977C40.1444 12.404 35.0083 7.07748 28.6708 7.07501ZM28.6426 31.9999C21.7077 32.0333 16 26.2067 16 19.1126C16 11.3606 21.7077 5.99835 28.6426 6H31.8932C38.7455 5.99835 45 11.3575 45 19.1126C45 26.2034 38.7455 31.9999 31.8932 31.9999H28.6426Z", fill: "#264B9A" })] }));
19102
- };
18880
+ // Contexts
18881
+ const useSelectedPluginIdState = (id) => react.useState(id);
18882
+ const [SelectedPluginIdProvider, useSelectedPluginId] = createStateContext(useSelectedPluginIdState);
18883
+ const [SelectedPluginDataProvider, useSelectedPlugin] = createValueContext(); // TODO: type the response to PluginData
18884
+ /**
18885
+ * SelectedPluginProvider manages the selected payment plugin state.
18886
+ *
18887
+ * Data Flow Pattern:
18888
+ * - Children components should set the plugin ID using `setSelectedPluginId` from `useSelectedPluginId`
18889
+ * - This provider then derives the `selectedPlugin` from that ID and provides it via `useSelectedPlugin`
18890
+ * - This ensures that data flows only downward: children control the ID, and the provider computes and provides the data
18891
+ */
18892
+ function SelectedPluginProvider({ children, accountId, }) {
18893
+ return (jsxRuntime.jsx(SelectedPluginIdProvider, { initialValue: undefined, children: jsxRuntime.jsx(Content, { accountId: accountId, children: children }) }));
18894
+ }
18895
+ function Content({ children, accountId }) {
18896
+ // Context
18897
+ const { paymentPlugins } = usePaymentPlugins(accountId);
18898
+ const { defaultPaymentMethod } = usePaymentMethod({ accountId });
18899
+ const [selectedPluginId, setSelectedPluginId] = useSelectedPluginId();
18900
+ // Derived state
18901
+ const selectedPlugin = react.useMemo(() => {
18902
+ return paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(plugin => plugin.id === selectedPluginId);
18903
+ }, [paymentPlugins, selectedPluginId]);
18904
+ react.useEffect(() => {
18905
+ var _a, _b;
18906
+ if (selectedPluginId) {
18907
+ return;
18908
+ }
18909
+ if (defaultPaymentMethod) {
18910
+ setSelectedPluginId((_a = defaultPaymentMethod.plugin) === null || _a === void 0 ? void 0 : _a.id);
18911
+ }
18912
+ else {
18913
+ setSelectedPluginId((_b = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins[0]) === null || _b === void 0 ? void 0 : _b.id);
18914
+ }
18915
+ }, [defaultPaymentMethod, paymentPlugins]);
18916
+ return jsxRuntime.jsx(SelectedPluginDataProvider, { value: selectedPlugin, children: children });
18917
+ }
19103
18918
 
19104
- const Discover = ({ className }) => {
19105
- return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("path", { d: "M0.5 8C0.5 3.85786 3.85786 0.5 8 0.5H52C56.1421 0.5 59.5 3.85786 59.5 8V30C59.5 34.1421 56.1421 37.5 52 37.5H8C3.85786 37.5 0.5 34.1421 0.5 30V8Z", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M9.19232 21.3753C8.69269 21.8265 8.04327 22.0234 7.01615 22.0234H6.58905V16.6315H7.01615C8.04327 16.6315 8.66695 16.8153 9.19232 17.2909C9.74271 17.7809 10.0728 18.539 10.0728 19.3202C10.0728 20.1034 9.74271 20.8859 9.19232 21.3753ZM7.33469 15.2496H5V23.404H7.32208C8.55684 23.404 9.44888 23.1129 10.2316 22.4621C11.1617 21.6921 11.7116 20.5322 11.7116 19.3327C11.7116 16.926 9.91383 15.2496 7.33469 15.2496Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M12.4438 23.404H14.0339V15.2496H12.4438V23.404Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M17.9229 18.379C16.9683 18.0253 16.6881 17.7928 16.6881 17.3521C16.6881 16.8383 17.1875 16.4484 17.8729 16.4484C18.3498 16.4484 18.7411 16.644 19.1556 17.1091L19.9879 16.019C19.3038 15.4209 18.4856 15.1153 17.592 15.1153C16.1491 15.1153 15.0487 16.1171 15.0487 17.4516C15.0487 18.5746 15.5612 19.1496 17.0551 19.6871C17.6774 19.9071 17.9941 20.0533 18.1542 20.1521C18.4717 20.359 18.6312 20.6527 18.6312 20.9952C18.6312 21.6559 18.1058 22.1453 17.3959 22.1453C16.6379 22.1453 16.0266 21.7665 15.6605 21.0585L14.6329 22.0471C15.3656 23.1227 16.2456 23.5996 17.4559 23.5996C19.1087 23.5996 20.2684 22.501 20.2684 20.9228C20.2684 19.6265 19.7324 19.0403 17.9229 18.379Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M20.7702 19.3328C20.7702 21.729 22.652 23.5871 25.0739 23.5871C25.7583 23.5871 26.3445 23.4528 27.0677 23.1129V21.2403C26.4317 21.8766 25.8684 22.1328 25.1475 22.1328C23.5456 22.1328 22.4089 20.9715 22.4089 19.3203C22.4089 17.7552 23.5821 16.5202 25.0739 16.5202C25.8321 16.5202 26.407 16.7909 27.0677 17.4378V15.5665C26.3697 15.2121 25.7957 15.0659 25.1112 15.0659C22.7019 15.0659 20.7702 16.9615 20.7702 19.3328Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M39.6784 20.7265L37.5033 15.2497H35.7663L39.2264 23.6135H40.0824L43.605 15.2497H41.8806L39.6784 20.7265Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M44.3237 23.404H48.8345V22.0234H45.9135V19.8221H48.7263V18.4409H45.9135V16.6315H48.8345V15.2496H44.3237V23.404Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M51.9414 19.0041H51.4762V16.534H51.9658C52.9569 16.534 53.4954 16.949 53.4954 17.7427C53.4954 18.5628 52.9569 19.0041 51.9414 19.0041ZM55.1326 17.6571C55.1326 16.1303 54.0803 15.2496 52.246 15.2496H49.8879V23.404H51.4762V20.1284H51.6841L53.8855 23.404H55.8412L53.2739 19.9684C54.4724 19.7246 55.1326 18.9059 55.1326 17.6571Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M56.0974 15.7753H56.0678V15.5875H56.0989C56.1836 15.5875 56.2281 15.6178 56.2281 15.6797C56.2281 15.7436 56.1831 15.7753 56.0974 15.7753ZM56.4 15.6778C56.4 15.5342 56.3007 15.4558 56.1273 15.4558H55.8967V16.1744H56.0678V15.8958L56.269 16.1744H56.479L56.2425 15.878C56.3434 15.851 56.4 15.7772 56.4 15.6778Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M56.1591 16.3292C55.8843 16.3292 55.6597 16.1 55.6597 15.8148C55.6597 15.5283 55.8823 15.2997 56.1591 15.2997C56.4328 15.2997 56.6554 15.5335 56.6554 15.8148C56.6554 16.0974 56.4328 16.3292 56.1591 16.3292ZM56.1617 15.1871C55.8128 15.1871 55.5354 15.4657 55.5354 15.8135C55.5354 16.1619 55.8159 16.4412 56.1617 16.4412C56.5018 16.4412 56.7808 16.1586 56.7808 15.8135C56.7808 15.4703 56.5018 15.1871 56.1617 15.1871Z", fill: "#231F20" }), jsxRuntime.jsx("path", { d: "M36.2191 19.3183C36.2191 21.7027 34.2863 23.6359 31.9014 23.6359C29.5166 23.6359 27.5835 21.7027 27.5835 19.3183C27.5835 16.9332 29.5166 15 31.9014 15C34.2863 15 36.2191 16.9332 36.2191 19.3183Z", fill: "#F36719" })] }));
18919
+ const DIGIT_REGEX = /\d/;
18920
+ const isDigit = (char) => DIGIT_REGEX.test(char);
18921
+ const isDeletion = (char) => [8, 46].includes(char); // Backspace or Delete
18922
+ const isNavigation = (char) => [9, 37, 38, 39, 40].includes(char); // Tab, Arrows
18923
+ const isModifier = (char) => [16, 17, 18].includes(char); // Shift, Ctrl, Alt
18924
+ const isValidKey = (code) => isDeletion(code) || isNavigation(code) || isModifier(code);
18925
+ const isValidExpiry = (expiry) => {
18926
+ const month = parseInt(expiry.substring(0, 2), 10);
18927
+ const year = parseInt(expiry.substring(2, 4), 10) + 2000;
18928
+ if (isNaN(month) || isNaN(year))
18929
+ return false;
18930
+ if (month < 1 || month > 12)
18931
+ return false;
18932
+ return true;
19106
18933
  };
19107
-
19108
- const JCB = ({ className }) => {
19109
- return (jsxRuntime.jsxs("svg", { className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsxRuntime.jsx("path", { d: "M48 27.522C48 30.5171 45.5611 32.956 42.566 32.956H13V11.434C13 8.43887 15.4389 6 18.434 6H48V27.522Z", fill: "white" }), jsxRuntime.jsx("path", { d: "M38.3728 22.0024H40.6191C40.6833 22.0024 40.833 21.981 40.8972 21.981C41.3251 21.8954 41.6888 21.5104 41.6888 20.9755C41.6888 20.4621 41.3251 20.077 40.8972 19.97C40.833 19.9486 40.7047 19.9486 40.6191 19.9486H38.3728V22.0024Z", fill: "url(#paint0_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M40.3625 7.81844C38.2231 7.81844 36.4688 9.55132 36.4688 11.7121V15.7555H41.967C42.0953 15.7555 42.2451 15.7555 42.3521 15.7769C43.5929 15.8411 44.5128 16.4829 44.5128 17.5953C44.5128 18.4725 43.8924 19.2212 42.7371 19.371V19.4138C43.9994 19.4994 44.9621 20.2054 44.9621 21.2964C44.9621 22.4731 43.8924 23.2433 42.4804 23.2433H36.4474V31.1589H42.1595C44.2989 31.1589 46.0532 29.426 46.0532 27.2653V7.81844H40.3625Z", fill: "url(#paint1_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M41.4107 17.852C41.4107 17.3386 41.047 16.9963 40.6191 16.9321C40.5763 16.9321 40.4693 16.9107 40.4052 16.9107H38.3728V18.7933H40.4052C40.4693 18.7933 40.5977 18.7933 40.6191 18.7719C41.047 18.7078 41.4107 18.3655 41.4107 17.852Z", fill: "url(#paint2_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M18.8405 7.81844C16.7011 7.81844 14.9468 9.55132 14.9468 11.7121V21.3178C16.0379 21.8527 17.1718 22.195 18.3056 22.195C19.6534 22.195 20.3808 21.382 20.3808 20.2695V15.7341H23.7182V20.2481C23.7182 22.0024 22.6272 23.4358 18.9261 23.4358C16.6797 23.4358 14.9254 22.9437 14.9254 22.9437V31.1375H20.6375C22.7769 31.1375 24.5312 29.4046 24.5312 27.2439V7.81844H18.8405Z", fill: "url(#paint3_linear_1_133)" }), jsxRuntime.jsx("path", { d: "M29.6015 7.81844C27.4621 7.81844 25.7079 9.55132 25.7079 11.7121V16.8038C26.692 15.9694 28.4035 15.4346 31.1632 15.5629C32.6394 15.6271 34.2225 16.0336 34.2225 16.0336V17.6809C33.431 17.2744 32.4896 16.9107 31.2702 16.8252C29.1736 16.6754 27.9114 17.7023 27.9114 19.4994C27.9114 21.3178 29.1736 22.3447 31.2702 22.1736C32.4896 22.088 33.431 21.7029 34.2225 21.3178V22.9651C34.2225 22.9651 32.6608 23.3716 31.1632 23.4358C28.4035 23.5642 26.692 23.0293 25.7079 22.195V31.1803H31.42C33.5593 31.1803 35.3136 29.4474 35.3136 27.2867V7.81844H29.6015Z", fill: "url(#paint4_linear_1_133)" }), jsxRuntime.jsxs("defs", { children: [jsxRuntime.jsxs("linearGradient", { id: "paint0_linear_1_133", x1: "36.4652", y1: "20.9781", x2: "46.0789", y2: "20.9781", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#007940" }), jsxRuntime.jsx("stop", { offset: "0.2285", "stop-color": "#00873F" }), jsxRuntime.jsx("stop", { offset: "0.7433", "stop-color": "#40A737" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#5CB531" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint1_linear_1_133", x1: "36.465", y1: "19.4793", x2: "46.0794", y2: "19.4793", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#007940" }), jsxRuntime.jsx("stop", { offset: "0.2285", "stop-color": "#00873F" }), jsxRuntime.jsx("stop", { offset: "0.7433", "stop-color": "#40A737" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#5CB531" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint2_linear_1_133", x1: "36.4649", y1: "17.8493", x2: "46.079", y2: "17.8493", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#007940" }), jsxRuntime.jsx("stop", { offset: "0.2285", "stop-color": "#00873F" }), jsxRuntime.jsx("stop", { offset: "0.7433", "stop-color": "#40A737" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#5CB531" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint3_linear_1_133", x1: "14.9423", y1: "19.4793", x2: "24.7049", y2: "19.4793", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#1F286F" }), jsxRuntime.jsx("stop", { offset: "0.4751", "stop-color": "#004E94" }), jsxRuntime.jsx("stop", { offset: "0.8261", "stop-color": "#0066B1" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#006FBC" })] }), jsxRuntime.jsxs("linearGradient", { id: "paint4_linear_1_133", x1: "25.6525", y1: "19.4793", x2: "35.1343", y2: "19.4793", gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { "stop-color": "#6C2C2F" }), jsxRuntime.jsx("stop", { offset: "0.1735", "stop-color": "#882730" }), jsxRuntime.jsx("stop", { offset: "0.5731", "stop-color": "#BE1833" }), jsxRuntime.jsx("stop", { offset: "0.8585", "stop-color": "#DC0436" }), jsxRuntime.jsx("stop", { offset: "1", "stop-color": "#E60039" })] })] })] }));
18934
+ const isCardExpired = (expiry) => {
18935
+ const month = parseInt(expiry.substring(0, 2), 10);
18936
+ const year = parseInt(expiry.substring(2, 4), 10) + 2000;
18937
+ const expiryDate = new Date(year, month, 1);
18938
+ return expiryDate < new Date();
19110
18939
  };
19111
-
19112
- const Cashapp = ({ className }) => {
19113
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { d: "M34.1572 17.6958C34.1572 16.7565 34.9551 16 35.8958 16C36.8366 16 37.6345 16.7648 37.6345 17.6958C37.6345 18.6269 36.8618 19.4166 35.8958 19.4166C34.9299 19.4166 34.1572 18.6518 34.1572 17.6958ZM29 16.2328H32.0238V32.9917H29V16.2328ZM37.4245 21.021H34.3756V32.9917H37.4245V21.021ZM59.3384 26.599C61.6314 25.2024 63.1937 23.1242 63.8068 21.0127H60.7579C59.9599 23.0244 58.1373 24.5374 56.1382 25.1775V16.2328H53.0893V32.9917H56.1382V28.0039C58.4648 28.5775 60.3043 30.5726 60.9342 32.9917H64C63.5296 30.4562 61.7826 28.0787 59.3384 26.6073V26.599ZM42.8253 22.3594C43.6232 21.312 45.1771 20.6968 46.4454 20.6968C48.7972 20.6968 50.7459 22.401 50.7543 24.978V32.9834H47.7053V25.643C47.7053 24.5873 47.2265 23.3653 45.6895 23.3653C43.8752 23.3653 42.8337 24.9614 42.8337 26.8235V33H39.7847V21.0293H42.8337V22.3594H42.8253Z", fill: "black" }), jsxRuntime.jsx("path", { d: "M14.5 34C19.7488 34 24 29.7488 24 24.5C24 19.2513 19.7488 15 14.5 15C9.25125 15 5 19.2513 5 24.5C5 29.7488 9.25125 34 14.5 34Z", fill: "#00D66F" }), jsxRuntime.jsx("path", { d: "M13.8794 19H11C11.5603 21.2993 13.1946 23.2625 15.2412 24.5C13.1868 25.7375 11.5603 27.7007 11 30H13.8794C14.5953 27.8764 16.572 26.0278 19 25.6458V23.3465C16.572 22.9722 14.5953 21.1236 13.8794 19Z", fill: "#011E0F" })] }));
18940
+ const formatCardExpiry = (cardExpiry) => {
18941
+ if (cardExpiry.length <= 2)
18942
+ return cardExpiry;
18943
+ return cardExpiry.substring(0, 2) + '/' + cardExpiry.substring(2);
18944
+ };
18945
+ // removes spaces from a credit card number
18946
+ const unformatCardNumber = (cardNumber) => {
18947
+ const cardNumberArray = cardNumber.split('');
18948
+ const unformattedCardNumberArray = cardNumberArray.filter(character => character !== ' ');
18949
+ return unformattedCardNumberArray.join('');
18950
+ };
18951
+ const storePayment = async (options, plugin, apiHost, accountId) => {
18952
+ const { testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token } = options;
18953
+ const response = await common.invokePlugin({
18954
+ method: 'store_payment_method',
18955
+ plugin,
18956
+ payload: {
18957
+ test_credit_card_number: testCreditCardNumber,
18958
+ test_credit_card_cvc: testCreditCardCvc,
18959
+ test_credit_card_expiration_date: testCreditCardExpirationDate,
18960
+ account_id: accountId,
18961
+ },
18962
+ token,
18963
+ apiHost,
18964
+ });
18965
+ if ((response === null || response === void 0 ? void 0 : response.status) !== 'success')
18966
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
18967
+ return response;
19114
18968
  };
19115
18969
 
19116
- const Mastercard = ({ className }) => {
19117
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M35.5 34.3139C33.1169 36.3704 30.0255 37.6119 26.6475 37.6119C19.1102 37.6119 13 31.4308 13 23.806C13 16.1811 19.1102 10 26.6475 10C30.0255 10 33.1169 11.2415 35.5 13.2981C37.8831 11.2415 40.9745 10 44.3525 10C51.8898 10 58 16.1811 58 23.806C58 31.4308 51.8898 37.6119 44.3525 37.6119C40.9745 37.6119 37.8831 36.3704 35.5 34.3139Z", fill: "#ED0006" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M35.5 34.3139C38.4344 31.7816 40.2951 28.0136 40.2951 23.806C40.2951 19.5983 38.4344 15.8303 35.5 13.2981C37.8831 11.2415 40.9745 10 44.3525 10C51.8898 10 58 16.1811 58 23.806C58 31.4308 51.8898 37.6119 44.3525 37.6119C40.9745 37.6119 37.8831 36.3704 35.5 34.3139Z", fill: "#F9A000" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M35.5 13.2981C38.4344 15.8304 40.2951 19.5984 40.2951 23.806C40.2951 28.0136 38.4344 31.7816 35.5 34.3138C32.5657 31.7816 30.705 28.0136 30.705 23.806C30.705 19.5984 32.5657 15.8304 35.5 13.2981Z", fill: "#FF5E00" })] }));
18970
+ function useSave$1({ onSaveSuccess, onSaveError, accountId, }) {
18971
+ const [isSaving, setIsSaving] = react.useState(false);
18972
+ const { apiHost } = react.useContext(BunnyContext);
18973
+ const token = useToken();
18974
+ const plugin = useSelectedPlugin();
18975
+ const save = async (cardDetails) => {
18976
+ try {
18977
+ setIsSaving(true);
18978
+ const response = await storePayment({
18979
+ testCreditCardNumber: unformatCardNumber(cardDetails.number),
18980
+ testCreditCardCvc: cardDetails.cvc.toString(),
18981
+ testCreditCardExpirationDate: cardDetails.expiry,
18982
+ token,
18983
+ }, plugin, apiHost, accountId);
18984
+ const paymentMethodId = response.payload[0].id;
18985
+ if (response.status !== 'success')
18986
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
18987
+ onSaveSuccess === null || onSaveSuccess === void 0 ? void 0 : onSaveSuccess({
18988
+ pluginPaymentResponse: {
18989
+ plugin,
18990
+ token: response.token,
18991
+ savePaymentMethod: true,
18992
+ },
18993
+ savedPaymentMethodResponse: {
18994
+ paymentMethodId,
18995
+ },
18996
+ });
18997
+ return paymentMethodId;
18998
+ }
18999
+ catch (error) {
19000
+ onSaveError === null || onSaveError === void 0 ? void 0 : onSaveError(error);
19001
+ }
19002
+ finally {
19003
+ setIsSaving(false);
19004
+ }
19005
+ return undefined;
19006
+ };
19007
+ return { save, isSaving };
19008
+ }
19009
+
19010
+ const MUTATION$9 = `
19011
+ mutation checkout(
19012
+ $invoiceId: ID,
19013
+ $quoteId: ID,
19014
+ $paymentMethodId: ID,
19015
+ $paymentMethodData: CheckoutPaymentMethodAttributes
19016
+ ) {
19017
+ checkout(
19018
+ invoiceId: $invoiceId,
19019
+ quoteId: $quoteId,
19020
+ paymentMethodId: $paymentMethodId,
19021
+ paymentMethodData: $paymentMethodData
19022
+ ) {
19023
+ invoice {
19024
+ id
19025
+ state
19026
+ amount
19027
+ amountDue
19028
+ }
19029
+ payment {
19030
+ id
19031
+ state
19032
+ amount
19033
+ }
19034
+ paymentApplication {
19035
+ id
19036
+ invoiceId
19037
+ paymentId
19038
+ }
19039
+ transaction {
19040
+ id
19041
+ amount
19042
+ }
19043
+ }
19044
+ }
19045
+ `;
19046
+ const checkout = async ({ quoteId, invoiceId, paymentMethodId, paymentMethodData, token, apiHost, }) => {
19047
+ const mutationVars = {
19048
+ quoteId,
19049
+ invoiceId,
19050
+ paymentMethodId,
19051
+ };
19052
+ if (paymentMethodData) {
19053
+ mutationVars.paymentMethodData = {
19054
+ ...paymentMethodData,
19055
+ metadata: paymentMethodData.metadata,
19056
+ };
19057
+ }
19058
+ const response = await gqlRequest({
19059
+ query: MUTATION$9,
19060
+ token,
19061
+ vars: mutationVars,
19062
+ apiHost: apiHost,
19063
+ });
19064
+ const { errors } = response === null || response === void 0 ? void 0 : response.checkout;
19065
+ if (errors)
19066
+ throw errors;
19067
+ return {
19068
+ savePaymentMethod: paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.savePaymentMethod,
19069
+ };
19118
19070
  };
19119
19071
 
19120
- const Visa = ({ className }) => {
19121
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M21.2505 32.5165H17.0099L13.8299 20.3847C13.679 19.8267 13.3585 19.3333 12.8871 19.1008C11.7106 18.5165 10.4142 18.0514 9 17.8169V17.3498H15.8313C16.7742 17.3498 17.4813 18.0514 17.5991 18.8663L19.2491 27.6173L23.4877 17.3498H27.6104L21.2505 32.5165ZM29.9675 32.5165H25.9626L29.2604 17.3498H33.2653L29.9675 32.5165ZM38.4467 21.5514C38.5646 20.7346 39.2717 20.2675 40.0967 20.2675C41.3931 20.1502 42.8052 20.3848 43.9838 20.9671L44.6909 17.7016C43.5123 17.2345 42.216 17 41.0395 17C37.1524 17 34.3239 19.1008 34.3239 22.0165C34.3239 24.2346 36.3274 25.3992 37.7417 26.1008C39.2717 26.8004 39.861 27.2675 39.7431 27.9671C39.7431 29.0165 38.5646 29.4836 37.3881 29.4836C35.9739 29.4836 34.5596 29.1338 33.2653 28.5494L32.5582 31.8169C33.9724 32.3992 35.5025 32.6338 36.9167 32.6338C41.2752 32.749 43.9838 30.6502 43.9838 27.5C43.9838 23.5329 38.4467 23.3004 38.4467 21.5514ZM58 32.5165L54.82 17.3498H51.4044C50.6972 17.3498 49.9901 17.8169 49.7544 18.5165L43.8659 32.5165H47.9887L48.8116 30.3004H53.8772L54.3486 32.5165H58ZM51.9936 21.4342L53.1701 27.1502H49.8723L51.9936 21.4342Z", fill: "#172B85" })] }));
19072
+ const getQuoteAmountDue = (quote) => {
19073
+ return quote.amountDue || quote.amount;
19122
19074
  };
19123
19075
 
19124
- const Sepa = ({ className }) => {
19125
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "#10298E", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { d: "M12.7744 16.084C14.4396 16.084 15.6264 16.1801 16.334 16.3701C18.0609 16.8349 18.9248 18.137 18.9248 20.2764C18.9248 20.4518 18.9113 20.714 18.8857 21.0645H14.918C14.918 20.4123 14.8407 19.9748 14.6885 19.752C14.4524 19.4222 13.801 19.2569 12.7344 19.2568C11.6983 19.2568 11.0109 19.3519 10.6758 19.542C10.3409 19.7327 10.1729 20.1477 10.1729 20.7861C10.1729 21.3638 10.3217 21.7443 10.6191 21.9268C10.8324 22.0562 11.1145 22.1325 11.4658 22.1553L12.2656 22.2119C13.9806 22.3259 15.0521 22.4065 15.4795 22.4521C16.8358 22.5891 17.8195 22.9497 18.4297 23.5352C18.9098 23.992 19.1958 24.5898 19.2871 25.3271C19.3405 25.7681 19.3672 26.267 19.3672 26.8213C19.3672 28.0993 19.2457 29.0356 19.002 29.6289C18.5601 30.7174 17.5669 31.4046 16.0225 31.6934C15.3754 31.8154 14.3858 31.8769 13.0547 31.877C10.8322 31.877 9.28274 31.7449 8.4082 31.4785C7.33499 31.1522 6.6276 30.4905 6.28516 29.4951C6.09445 28.941 6.00001 28.0182 6 26.7266H9.96875C9.96875 26.8706 9.96875 26.9808 9.96875 27.0566C9.96876 27.746 10.1668 28.1893 10.5615 28.3867C10.8351 28.5229 11.1654 28.594 11.5537 28.6025H13.0127C13.7572 28.6025 14.2325 28.5649 14.4375 28.4883C14.8023 28.3446 15.0418 28.1131 15.1562 27.793C15.217 27.596 15.247 27.3411 15.2471 27.0293C15.2471 26.3303 14.992 25.9045 14.4834 25.752C14.2928 25.6917 13.4079 25.6075 11.8291 25.501C10.5609 25.4103 9.67998 25.3228 9.18652 25.2383C7.88722 24.9948 7.02094 24.4944 6.58887 23.7344C6.20918 23.0886 6.01956 22.1116 6.01953 20.8047C6.01953 19.8092 6.12198 19.0105 6.32715 18.4102C6.53252 17.8097 6.86368 17.3538 7.32031 17.042C7.98917 16.5635 8.84498 16.2823 9.88672 16.1982C10.7538 16.1225 11.7164 16.084 12.7744 16.084ZM44.2861 16C45.3761 16 46.2079 16.0894 46.7793 16.2676C48.0865 16.6779 48.9639 17.5176 49.4131 18.7871C49.645 19.4533 49.7607 20.4565 49.7607 21.7959C49.7607 23.4063 49.6323 24.564 49.3779 25.2686C48.8682 26.6618 47.8187 27.4648 46.2344 27.6729C46.048 27.7041 45.2548 27.7316 43.8555 27.7539L43.1475 27.7773H40.6045V31.877H36.3389V16H44.2861ZM64 31.877H59.6787L58.8652 29.1328H53.1621L52.3955 31.877H47.9824L52.7441 16H59.1787L64 31.877ZM54.0801 26.04H58.0186L56.0195 19.1572L54.0801 26.04ZM40.6035 24.0947H43.2627C44.1059 24.0643 44.6191 23.9992 44.8037 23.8975C45.0556 23.7585 45.2244 23.4803 45.3086 23.0635C45.3624 22.7859 45.3896 22.3732 45.3896 21.8252C45.3896 21.1539 45.336 20.6561 45.2285 20.3311C45.0751 19.8759 44.7078 19.5988 44.126 19.498C44.011 19.4828 43.7353 19.4746 43.2988 19.4746H40.6035V24.0947Z", fill: "white" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M30.45 18.2337C32.2095 18.2337 33.7797 19.0456 34.8119 20.3173L35.7314 18.3424C34.2933 16.9808 32.336 16.1413 30.1772 16.1413C26.8159 16.1413 23.9406 18.1748 22.7605 21.0533H20.9674L19.9087 23.3269H22.2154C22.1981 23.5378 22.1869 23.7489 22.1869 23.9643C22.1869 24.2249 22.2004 24.4824 22.2262 24.7369H21.0669L20.0083 27.0113H22.8155C24.0293 29.8169 26.8686 31.7866 30.1772 31.7866C31.8445 31.7866 33.3917 31.2862 34.6727 30.4314V27.644C33.6411 28.8205 32.1322 29.564 30.45 29.564C28.4837 29.564 26.754 28.5484 25.7468 27.0113H31.6253L32.6838 24.7369H24.8819C24.8417 24.4632 24.8202 24.1835 24.8202 23.8986C24.8202 23.706 24.8302 23.5153 24.8486 23.3269H33.3399L34.3985 21.0533H25.583C26.5579 19.3679 28.3721 18.2337 30.45 18.2337", fill: "#FFBE00" })] }));
19076
+ const { useToken: useAntdToken } = antd.theme;
19077
+ const createPaymentMethod = async ({ paymentMethodId, plugin, token, apiHost, accountId, }) => {
19078
+ const response = await common.invokePlugin({
19079
+ plugin,
19080
+ method: 'store_payment_method',
19081
+ payload: {
19082
+ payment_method_id: paymentMethodId,
19083
+ account_id: accountId,
19084
+ },
19085
+ token,
19086
+ apiHost,
19087
+ });
19088
+ if (response.status !== 'success')
19089
+ throw new Error(response.message || 'Unknown error');
19090
+ return response;
19126
19091
  };
19127
-
19128
- const IDeal = ({ className }) => {
19129
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M19.0266 9.91185H35.684C47.003 9.91185 51.3527 16.0977 51.3527 23.9167C51.3527 33.2698 45.273 37.9711 35.684 37.9711H19.0266V9.91185ZM20.6082 11.5944V36.3875H35.6838C44.7786 36.3875 49.7215 32.1316 49.7215 23.9662C49.7215 15.5534 44.3832 11.5944 35.6838 11.5944H20.6082ZM25.0568 24.4115C26.722 24.4115 28.072 23.06 28.072 21.3928C28.072 19.7256 26.722 18.3741 25.0568 18.3741C23.3916 18.3741 22.0417 19.7256 22.0417 21.3928C22.0417 23.06 23.3916 24.4115 25.0568 24.4115ZM22.635 25.6982H27.479V34.309H22.635V25.6982Z", fill: "black" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M44.2351 18.6216H45.6191V22.7785H47.6456C47.1019 15.207 41.1211 13.5244 35.684 13.5244H29.9009V18.6216H30.7412C32.3229 18.6216 33.262 19.6608 33.262 21.3929C33.262 23.1249 32.3229 24.1641 30.7906 24.1641H29.9009V34.309H35.684C44.5317 34.309 47.5468 30.2016 47.6951 24.1641H44.2351V18.6216ZM37.5623 22.7785V24.1641H34.1023V18.6216H37.4634V20.0072H35.4863V20.6505H37.3646V22.0362H35.5357V22.7785H37.5623ZM39.8358 18.6216H41.813L43.4935 24.1641H42.0601L41.7635 23.1249H39.9347L39.6381 24.1641H38.1553L39.8358 18.6216ZM40.3456 21.6898H40.3302V21.7393L40.3456 21.6898ZM40.3456 21.6898H41.3188L40.8739 20.1557H40.8245L40.3456 21.6898ZM29.9009 22.7785V20.0072H30.7412C31.2849 20.0072 31.878 20.1557 31.878 21.3929C31.878 22.63 31.3343 22.7785 30.7412 22.7785H29.9009Z", fill: "#D50072" })] }));
19092
+ const createSetupIntent = (plugin, apiHost, token, accountId) => {
19093
+ return common.invokePlugin({
19094
+ plugin,
19095
+ method: 'create_setup_intent',
19096
+ token,
19097
+ apiHost,
19098
+ payload: {
19099
+ account_id: accountId,
19100
+ },
19101
+ });
19130
19102
  };
19131
-
19132
- const Bancontact = ({ className }) => {
19133
- return (jsxRuntime.jsxs("svg", { className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M18.2243 35.1715C18.2243 34.882 18.156 34.6314 18.0199 34.4199C17.8835 34.2083 17.7043 34.0468 17.4819 33.9355C17.7043 33.8242 17.8766 33.6597 17.9991 33.4426C18.1214 33.2255 18.1825 32.9806 18.1825 32.7078V32.5575C18.1825 32.2233 18.1186 31.9451 17.9908 31.7223C17.8628 31.4996 17.6833 31.3213 17.4526 31.1878C17.2219 31.0541 16.9451 30.9582 16.6227 30.8995C16.3 30.8411 15.9414 30.812 15.5465 30.812C15.4131 30.812 15.274 30.8147 15.1296 30.8203C14.9848 30.8258 14.8445 30.8328 14.7083 30.8411C14.572 30.8494 14.4468 30.8593 14.3329 30.8704C14.2188 30.8817 14.1256 30.8928 14.0534 30.9037C13.8921 30.9318 13.7781 30.9817 13.7114 31.0541C13.6448 31.1266 13.6113 31.2575 13.6113 31.4467V36.5245C13.6113 36.7139 13.646 36.8447 13.7156 36.917C13.7851 36.9895 13.9032 37.0394 14.0702 37.0673C14.1535 37.084 14.2536 37.0979 14.3704 37.1091C14.4871 37.1202 14.6136 37.1299 14.7499 37.1383C14.8862 37.1466 15.0265 37.1535 15.1711 37.1593C15.3158 37.1646 15.4575 37.1676 15.5966 37.1676C15.9581 37.1676 16.2986 37.1397 16.6185 37.084C16.9381 37.0285 17.2161 36.9295 17.4526 36.7874C17.689 36.6456 17.8766 36.4534 18.0157 36.2113C18.1546 35.969 18.2243 35.6642 18.2243 35.2967V35.1715ZM16.8063 32.7746C16.8063 32.8637 16.7924 32.9487 16.7645 33.0293C16.7366 33.11 16.6909 33.1795 16.627 33.2383C16.5629 33.2966 16.4768 33.3439 16.3684 33.38C16.2599 33.4162 16.1222 33.4343 15.9554 33.4343H15.0213V31.9895C15.049 31.9895 15.0921 31.9883 15.1505 31.9853C15.2089 31.9825 15.27 31.9812 15.3339 31.9812H15.6551C16.0833 31.9812 16.3822 32.0354 16.5518 32.144C16.7214 32.2526 16.8063 32.421 16.8063 32.6492V32.7746ZM16.5935 35.8062C16.7576 35.6782 16.8397 35.4971 16.8397 35.2634V35.1714C16.8397 34.971 16.7756 34.797 16.6478 34.6494C16.5198 34.502 16.289 34.4282 15.9554 34.4282H15.0213V35.9898H15.1671C15.231 35.9898 15.2977 35.9916 15.3673 35.9942C15.4368 35.9969 15.5035 35.9985 15.5676 35.9985H15.7051C16.1333 35.9985 16.4295 35.9343 16.5935 35.8062ZM22.7955 33.9438C22.7955 33.6377 22.7496 33.3772 22.6578 33.1629C22.5662 32.9487 22.4368 32.7732 22.27 32.6367C22.1032 32.5004 21.8988 32.4003 21.6568 32.3362C21.415 32.2722 21.1439 32.2401 20.8436 32.2401C20.5654 32.2401 20.2943 32.2597 20.0303 32.2987C19.766 32.3375 19.556 32.3766 19.4005 32.4154C19.2948 32.4435 19.242 32.5046 19.242 32.5991V33.2756C19.242 33.3314 19.2559 33.3705 19.2837 33.3925C19.3115 33.4149 19.3475 33.4261 19.3922 33.4261H19.4337C19.5006 33.4204 19.5839 33.4135 19.684 33.4051C19.7842 33.3968 19.8968 33.3901 20.022 33.3842C20.1471 33.3788 20.2777 33.3746 20.414 33.3717C20.5501 33.3689 20.6851 33.3675 20.8186 33.3675C21.0131 33.3675 21.1661 33.4038 21.2773 33.4761C21.3885 33.5486 21.4441 33.7045 21.4441 33.9438V34.2445H20.9937C20.2763 34.2445 19.7549 34.3572 19.4296 34.5827C19.1043 34.8081 18.9416 35.1659 18.9416 35.6558V35.7313C18.9416 36.0039 18.982 36.2321 19.0625 36.4158C19.1431 36.5996 19.2503 36.7472 19.3837 36.8587C19.5172 36.9699 19.6686 37.0493 19.8384 37.0964C20.008 37.1438 20.1846 37.1676 20.3681 37.1676C20.6184 37.1676 20.8339 37.1341 21.0145 37.0673C21.1952 37.0005 21.3662 36.9086 21.5276 36.7917V36.9253C21.5276 36.9699 21.5442 37.0089 21.5776 37.0422C21.6111 37.0756 21.6499 37.0923 21.6944 37.0923H22.6287C22.6731 37.0923 22.712 37.0756 22.7455 37.0422C22.7789 37.0089 22.7955 36.9699 22.7955 36.9253V33.9438ZM21.1481 36.0942C21.2619 36.0581 21.3691 36.015 21.4692 35.9648V35.0462H20.9937C20.8491 35.0462 20.7296 35.0587 20.635 35.0837C20.5404 35.1088 20.4653 35.1465 20.4098 35.1966C20.3542 35.2465 20.3152 35.3107 20.2931 35.3886C20.2707 35.4666 20.2596 35.5556 20.2596 35.6558V35.7312C20.2596 35.9092 20.3026 36.0233 20.3889 36.0734C20.4751 36.1235 20.6071 36.1485 20.7852 36.1485C20.913 36.1485 21.0339 36.1306 21.1481 36.0942ZM27.9007 36.917V34.1358C27.9007 33.8744 27.8799 33.6278 27.8381 33.3968C27.7964 33.166 27.7214 32.9653 27.6129 32.7954C27.5045 32.6256 27.3543 32.4905 27.1624 32.3904C26.9707 32.2902 26.7245 32.2401 26.4242 32.2401C26.1572 32.2401 25.9208 32.2723 25.7152 32.3369C25.5094 32.4014 25.2925 32.515 25.0646 32.6776V32.4752C25.0646 32.4305 25.0478 32.3911 25.0145 32.3575C24.9811 32.3238 24.9421 32.3068 24.8976 32.3068H23.9634C23.9187 32.3068 23.8799 32.3235 23.8467 32.357C23.8133 32.3904 23.7966 32.4295 23.7966 32.4739V36.917C23.7966 36.9615 23.8145 37.0019 23.8508 37.038C23.8869 37.0743 23.9272 37.0923 23.9717 37.0923H24.9811C25.0256 37.0923 25.0646 37.0743 25.0978 37.0382C25.1313 37.0021 25.1479 36.9619 25.1479 36.9173V33.6341C25.2925 33.5564 25.4287 33.4925 25.5567 33.4426C25.6845 33.3925 25.8096 33.3675 25.932 33.3675C26.0599 33.3675 26.1642 33.38 26.2449 33.4051C26.3254 33.4301 26.388 33.4731 26.4325 33.5345C26.477 33.5954 26.5076 33.6759 26.5243 33.7757C26.5409 33.8758 26.5494 33.9981 26.5494 34.1425V36.9173C26.5494 36.9619 26.566 37.0021 26.5994 37.0382C26.6327 37.0743 26.6715 37.0923 26.7162 37.0923H27.7255C27.7699 37.0923 27.8102 37.0743 27.8464 37.038C27.8826 37.0019 27.9007 36.9615 27.9007 36.917ZM32.0047 36.1071V36.8502C32.0047 36.9114 31.9907 36.9546 31.963 36.9796C31.9351 37.0047 31.8906 37.0255 31.8294 37.0422C31.7127 37.0701 31.5611 37.0978 31.3749 37.1259C31.1885 37.1535 30.9703 37.1676 30.72 37.1676C30.1305 37.1676 29.6592 36.9867 29.3062 36.6246C28.953 36.2628 28.7765 35.7394 28.7765 35.0546V34.3531C28.7765 33.6682 28.953 33.1448 29.3062 32.7831C29.6592 32.421 30.1305 32.2401 30.72 32.2401C30.9703 32.2401 31.1885 32.254 31.3749 32.2817C31.5611 32.3098 31.7127 32.3375 31.8294 32.3653C31.8906 32.3819 31.9351 32.4029 31.963 32.4279C31.9907 32.453 32.0047 32.4962 32.0047 32.5574V33.3007C32.0047 33.3453 31.9893 33.38 31.9588 33.4051C31.9281 33.4301 31.8906 33.4426 31.8462 33.4426H31.8294C31.6737 33.4261 31.5251 33.4121 31.3832 33.401C31.2413 33.3901 31.0508 33.3842 30.8118 33.3842C30.7172 33.3842 30.6283 33.3996 30.5448 33.4301C30.4613 33.4608 30.3891 33.5137 30.328 33.5888C30.2666 33.6641 30.2181 33.7641 30.1819 33.8895C30.1457 34.0147 30.1277 34.1692 30.1277 34.3531V35.0546C30.1277 35.2382 30.1457 35.3927 30.1819 35.5181C30.2181 35.6433 30.2666 35.7436 30.328 35.8187C30.3891 35.8939 30.4613 35.9468 30.5448 35.9774C30.6283 36.008 30.7172 36.0233 30.8118 36.0233C31.0508 36.0233 31.2413 36.0178 31.3832 36.0067C31.5251 35.9956 31.6737 35.9815 31.8294 35.9649H31.8462C31.8906 35.9649 31.9281 35.9774 31.9588 36.0025C31.9893 36.0276 32.0047 36.0623 32.0047 36.1071ZM36.6346 34.4115C36.6346 34.0773 36.5885 33.7768 36.4966 33.5095C36.4046 33.2423 36.2709 33.0155 36.0954 32.8289C35.9199 32.6424 35.7025 32.4976 35.4436 32.3946C35.1844 32.2918 34.8848 32.2401 34.5449 32.2401C34.2051 32.2401 33.9056 32.2918 33.6465 32.3946C33.3873 32.4976 33.1685 32.6424 32.9903 32.8289C32.8119 33.0155 32.6768 33.2423 32.585 33.5095C32.4928 33.7768 32.4469 34.0773 32.4469 34.4115V34.9961C32.4469 35.3301 32.4928 35.6309 32.585 35.8981C32.6768 36.1653 32.8119 36.3922 32.9903 36.5788C33.1685 36.7654 33.3873 36.91 33.6465 37.013C33.9056 37.1159 34.2051 37.1676 34.5449 37.1676C34.8848 37.1676 35.1844 37.1159 35.4436 37.013C35.7025 36.91 35.9199 36.7654 36.0954 36.5788C36.2709 36.3922 36.4046 36.1653 36.4966 35.8981C36.5885 35.6309 36.6346 35.3301 36.6346 34.9961V34.4115ZM34.5449 36.0233C35.037 36.0233 35.2832 35.6809 35.2832 34.9961V34.4115C35.2832 33.7322 35.037 33.3925 34.5449 33.3925C34.3016 33.3925 34.1164 33.4774 33.9893 33.6472C33.8619 33.8172 33.7984 34.0719 33.7984 34.4115V34.9961C33.7984 35.3357 33.8619 35.5918 33.9893 35.7644C34.1164 35.9371 34.3016 36.0233 34.5449 36.0233ZM41.5976 36.917V34.1358C41.5976 33.8744 41.5765 33.6278 41.5351 33.3968C41.4933 33.166 41.4181 32.9653 41.3095 32.7954C41.2011 32.6256 41.0511 32.4905 40.8593 32.3904C40.6674 32.2902 40.4213 32.2401 40.1211 32.2401C39.8542 32.2401 39.6177 32.2723 39.4119 32.3369C39.2062 32.4014 38.9893 32.515 38.7613 32.6776V32.4752C38.7613 32.4305 38.7447 32.3911 38.7111 32.3575C38.678 32.3238 38.6389 32.3068 38.5945 32.3068H37.6602C37.6157 32.3068 37.5769 32.3235 37.5434 32.357C37.5102 32.3904 37.4934 32.4295 37.4934 32.4739V36.917C37.4934 36.9615 37.5114 37.0019 37.5476 37.038C37.5838 37.0743 37.624 37.0923 37.6687 37.0923H38.678C38.7224 37.0923 38.7613 37.0743 38.7948 37.0382C38.828 37.0021 38.8448 36.9619 38.8448 36.9173V33.6341C38.9893 33.5564 39.1256 33.4925 39.2534 33.4426C39.3815 33.3925 39.5065 33.3675 39.629 33.3675C39.7568 33.3675 39.8611 33.38 39.9416 33.4051C40.0222 33.4301 40.0849 33.4731 40.1294 33.5345C40.1739 33.5954 40.2044 33.6759 40.2212 33.7757C40.2378 33.8758 40.2462 33.9981 40.2462 34.1425V36.9173C40.2462 36.9619 40.2628 37.0021 40.2962 37.0382C40.3296 37.0743 40.3684 37.0923 40.413 37.0923H41.4223C41.4668 37.0923 41.5072 37.0743 41.5434 37.038C41.5794 37.0019 41.5976 36.9615 41.5976 36.917ZM45.2348 36.2893V36.9357C45.2348 37.0295 45.182 37.0848 45.0763 37.1011C44.9483 37.1233 44.8371 37.1398 44.7427 37.1509C44.6481 37.162 44.5395 37.1675 44.4174 37.1675C44.1905 37.1675 43.9901 37.1493 43.816 37.1133C43.6419 37.077 43.4966 37.0061 43.3805 36.9003C43.2646 36.7945 43.1761 36.6483 43.1153 36.4617C43.0547 36.2753 43.0242 36.0347 43.0242 35.7394V33.3175L42.357 33.2088C42.3123 33.1977 42.2721 33.1769 42.2359 33.1462C42.1997 33.1157 42.1817 33.0781 42.1817 33.0335V32.4822C42.1817 32.4378 42.1997 32.3974 42.2359 32.3611C42.2721 32.325 42.3123 32.3068 42.357 32.3068H43.0242V31.622C43.0242 31.5774 43.0409 31.5414 43.0739 31.5134C43.1068 31.4857 43.1458 31.4663 43.1902 31.455L44.2016 31.2798H44.2263C44.2705 31.2798 44.3065 31.2921 44.3343 31.3171C44.3618 31.3423 44.3757 31.3771 44.3757 31.4215V32.3068H45.0597C45.104 32.3068 45.143 32.3237 45.1764 32.3573C45.2099 32.3909 45.2265 32.4305 45.2265 32.4752V33.1573C45.2265 33.2024 45.2099 33.2416 45.1764 33.2752C45.143 33.3089 45.104 33.3257 45.0597 33.3257H44.3757V35.7561C44.3757 35.9231 44.3895 36.0304 44.4174 36.0776C44.4451 36.1249 44.5229 36.1485 44.6507 36.1485H45.0597C45.1764 36.1485 45.2348 36.1955 45.2348 36.2893ZM49.6891 33.9438C49.6891 33.6377 49.6433 33.3772 49.5514 33.1629C49.4597 32.9487 49.3305 32.7732 49.1637 32.6367C48.9969 32.5004 48.7925 32.4003 48.5505 32.3362C48.3087 32.2722 48.0376 32.2401 47.7373 32.2401C47.4589 32.2401 47.188 32.2597 46.924 32.2987C46.6597 32.3375 46.4497 32.3766 46.2942 32.4154C46.1882 32.4435 46.1357 32.5046 46.1357 32.5991V33.2756C46.1357 33.3314 46.1494 33.3705 46.1773 33.3925C46.2052 33.4149 46.2412 33.4261 46.2857 33.4261H46.3274C46.3943 33.4204 46.4776 33.4135 46.5777 33.4051C46.6779 33.3968 46.7905 33.3901 46.9155 33.3842C47.0408 33.3788 47.1714 33.3746 47.3077 33.3717C47.4438 33.3689 47.5788 33.3675 47.7121 33.3675C47.9068 33.3675 48.0598 33.4038 48.171 33.4761C48.2822 33.5486 48.3378 33.7045 48.3378 33.9438V34.2445H47.8874C47.1698 34.2445 46.6486 34.3572 46.3233 34.5827C45.998 34.8081 45.8353 35.1659 45.8353 35.6558V35.7313C45.8353 36.0039 45.8755 36.2321 45.9562 36.4158C46.0366 36.5996 46.144 36.7472 46.2774 36.8587C46.4109 36.9699 46.5623 37.0493 46.7321 37.0964C46.9017 37.1438 47.0782 37.1676 47.2618 37.1676C47.5121 37.1676 47.7274 37.1341 47.9082 37.0673C48.0889 37.0005 48.2597 36.9086 48.4213 36.7917V36.9253C48.4213 36.9699 48.4379 37.0089 48.4713 37.0422C48.5046 37.0756 48.5436 37.0923 48.5881 37.0923H49.5224C49.5668 37.0923 49.6057 37.0756 49.6392 37.0422C49.6724 37.0089 49.6891 36.9699 49.6891 36.9253V33.9438ZM48.0418 36.0942C48.1556 36.0581 48.2628 36.015 48.3629 35.9648V35.0462H47.8874C47.7428 35.0462 47.6233 35.0587 47.5287 35.0837C47.4341 35.1088 47.359 35.1465 47.3035 35.1966C47.2477 35.2465 47.2088 35.3107 47.1868 35.3886C47.1644 35.4666 47.1533 35.5556 47.1533 35.6558V35.7312C47.1533 35.9092 47.1963 36.0233 47.2826 36.0734C47.3688 36.1235 47.5008 36.1485 47.6789 36.1485C47.8067 36.1485 47.9274 36.1306 48.0418 36.0942ZM53.7933 36.8502V36.1071C53.7933 36.0623 53.7779 36.0276 53.7474 36.0025C53.7167 35.9774 53.6793 35.9649 53.6348 35.9649H53.6181C53.4624 35.9815 53.3136 35.9956 53.1718 36.0067C53.0301 36.0178 52.8395 36.0233 52.6005 36.0233C52.5057 36.0233 52.4167 36.008 52.3336 35.9774C52.2501 35.9468 52.1777 35.8939 52.1165 35.8187C52.0554 35.7436 52.0067 35.6433 51.9707 35.5181C51.9343 35.3927 51.9165 35.2382 51.9165 35.0546V34.3531C51.9165 34.1692 51.9343 34.0147 51.9707 33.8895C52.0067 33.7641 52.0554 33.6641 52.1165 33.5888C52.1777 33.5137 52.2501 33.4608 52.3336 33.4301C52.4167 33.3996 52.5057 33.3842 52.6005 33.3842C52.8395 33.3842 53.0301 33.3901 53.1718 33.401C53.3136 33.4121 53.4624 33.4261 53.6181 33.4426H53.6348C53.6793 33.4426 53.7167 33.4301 53.7474 33.4051C53.7779 33.38 53.7933 33.3453 53.7933 33.3007V32.5574C53.7933 32.4962 53.7794 32.453 53.7515 32.4279C53.7235 32.4029 53.6793 32.3819 53.6181 32.3653C53.5014 32.3375 53.3497 32.3098 53.1635 32.2817C52.9771 32.254 52.759 32.2401 52.5087 32.2401C51.9189 32.2401 51.4479 32.421 51.0947 32.7831C50.7415 33.1448 50.565 33.6682 50.565 34.3531V35.0546C50.565 35.7394 50.7415 36.2628 51.0947 36.6246C51.4479 36.9867 51.9189 37.1676 52.5087 37.1676C52.759 37.1676 52.9771 37.1535 53.1635 37.1259C53.3497 37.0978 53.5014 37.0701 53.6181 37.0422C53.6793 37.0255 53.7235 37.0047 53.7515 36.9796C53.7794 36.9546 53.7933 36.9114 53.7933 36.8502ZM57.3884 36.2893V36.9357C57.3884 37.0295 57.3354 37.0848 57.2299 37.1011C57.1019 37.1233 56.9907 37.1398 56.8963 37.1509C56.8016 37.162 56.6931 37.1675 56.571 37.1675C56.3441 37.1675 56.1437 37.1493 55.9696 37.1133C55.7954 37.077 55.6502 37.0061 55.5343 36.9003C55.4183 36.7945 55.3298 36.6483 55.269 36.4617C55.2083 36.2753 55.1778 36.0347 55.1778 35.7394V33.3175L54.5106 33.2088C54.4659 33.1977 54.4257 33.1769 54.3895 33.1462C54.3533 33.1157 54.3353 33.0781 54.3353 33.0335V32.4822C54.3353 32.4378 54.3533 32.3974 54.3895 32.3611C54.4257 32.325 54.4659 32.3068 54.5106 32.3068H55.1778V31.622C55.1778 31.5774 55.1945 31.5414 55.2276 31.5134C55.2605 31.4857 55.2993 31.4663 55.3436 31.455L56.355 31.2798H56.38C56.4241 31.2798 56.4602 31.2921 56.4875 31.3171C56.5154 31.3423 56.5293 31.3771 56.5293 31.4215V32.3068H57.2133C57.2577 32.3068 57.2966 32.3237 57.3301 32.3573C57.3633 32.3909 57.3801 32.4305 57.3801 32.4752V33.1573C57.3801 33.2024 57.3633 33.2416 57.3301 33.2752C57.2966 33.3089 57.2577 33.3257 57.2133 33.3257H56.5293V35.7561C56.5293 35.9231 56.5431 36.0304 56.571 36.0776C56.5987 36.1249 56.6765 36.1485 56.8045 36.1485H57.2133C57.3301 36.1485 57.3884 36.1955 57.3884 36.2893Z", fill: "#005697" }), jsxRuntime.jsx("path", { d: "M52.6187 14.7398H39.0664L37.6881 16.2935L33.2155 21.3349V21.3351L31.8372 22.8886H18.464L19.821 21.3153L20.4633 20.5706L21.8202 18.9973H15.6582C14.5325 18.9973 13.6113 19.943 13.6113 21.0987V25.5326C13.6113 26.6885 14.5325 27.6342 15.6582 27.6342H39.2492C40.3749 27.6342 41.9127 26.9318 42.6665 26.0733L46.235 22.0097L52.6187 14.7398Z", fill: "#005697" }), jsxRuntime.jsx("path", { d: "M55.3418 10C56.4676 10 57.3887 10.9457 57.3887 12.1015V16.5353C57.3887 17.691 56.4676 18.6368 55.3418 18.6368H49.1999L50.5697 17.0753H50.5699L51.2491 16.3012L52.6189 14.7398H39.0667L31.8375 22.8945H18.3813L28.0314 11.9701L28.3966 11.5566C29.153 10.7005 30.6929 10 31.8186 10H55.3418V10Z", fill: "#FBD500" })] }));
19103
+ const createPaymentHold = async ({ quote, plugin, token, apiHost, paymentMethodId, }) => {
19104
+ const payload = {
19105
+ quote_id: quote.id,
19106
+ amount: quote.amount,
19107
+ payment_method_id: paymentMethodId,
19108
+ };
19109
+ const response = await common.invokePlugin({
19110
+ plugin,
19111
+ method: 'create_payment_hold',
19112
+ payload,
19113
+ token,
19114
+ apiHost,
19115
+ });
19116
+ if (response.status !== 'success')
19117
+ throw new Error(response.message || 'Unknown error');
19118
+ return response;
19134
19119
  };
19135
-
19136
- const { Text: Text$z } = antd.Typography;
19137
- const MiniCreditCard = ({ className, buttons, hideDropdownMenu = false, hideDefaultTag = false, onClickRemove, paymentMethodData, onClickSetDefault, id, }) => {
19138
- const { darkMode } = react.useContext(BunnyContext);
19139
- const { brandColor } = useBrand();
19140
- const borderColor = react.useMemo(() => {
19141
- return darkMode ? 'border-slate-700' : 'border-slate-200';
19142
- }, [darkMode]);
19143
- const backgroundColor = react.useMemo(() => {
19144
- return darkMode ? 'var(--row-background-alternate)' : 'bg-slate-50';
19145
- }, [darkMode]);
19146
- const isDefault = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.isDefault;
19147
- return (jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-row bunny-justify-between bunny-items-center bunny-p-1 bunny-px-3 bunny-border-solid ${backgroundColor} bunny-${borderColor} bunny-rounded-md bunny-border ${className}`, id: id, children: paymentMethodData ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-row bunny-gap-4", children: jsxRuntime.jsxs("div", { className: "bunny-flex bunny-items-center bunny-gap-2 bunny-space-between bunny-w-full", children: [jsxRuntime.jsx(CardImage, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Issuer, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Identifier, { paymentMethodData: paymentMethodData }), !hideDefaultTag && (jsxRuntime.jsx("div", { children: isDefault ? (jsxRuntime.jsx(antd.Tag, { bordered: false, style: { color: brandColor, backgroundColor: `${brandColor}30` }, children: "Default" })) : null }))] }) }), buttons ? (buttons) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideDropdownMenu && (jsxRuntime.jsx(DropdownMenu, { setDefault: onClickSetDefault, remove: onClickRemove, isDefault: isDefault !== null && isDefault !== void 0 ? isDefault : false, id: `credit-card-dropdown-${paymentMethodData.id}` })) }))] })) : (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-row bunny-items-center justify-between w-full", children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-2 bunny-items-center", children: [jsxRuntime.jsx(icons.CreditCardOutlined, {}), jsxRuntime.jsx(Text$z, { className: "bunny-text-slate-400 bunny-text-sm", children: "No payment methods" })] }), jsxRuntime.jsx(antd.Button, { disabled: true, type: "link" }), buttons] })) }));
19120
+ const fetchStripeKey = async (plugin, apiHost, token, accountId) => {
19121
+ const response = await common.invokePlugin({
19122
+ plugin,
19123
+ method: 'retrieve_config',
19124
+ token,
19125
+ apiHost,
19126
+ payload: {
19127
+ account_id: accountId,
19128
+ },
19129
+ });
19130
+ return response;
19148
19131
  };
19149
- const Identifier = ({ paymentMethodData }) => {
19150
- var _a, _b, _c;
19151
- if (((_a = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _a === void 0 ? void 0 : _a.type) === 'link') {
19152
- return null;
19153
- }
19154
- if (((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.type) === 'cashapp') {
19155
- return jsxRuntime.jsx(Text$z, { children: "Cashapp" });
19132
+ index_js.loadStripe.setLoadParameters({ advancedFraudSignals: false });
19133
+ const useStripePlugin = (plugin, currencyId, accountId) => {
19134
+ // Context
19135
+ const { apiHost } = react.useContext(BunnyContext);
19136
+ const token = useToken();
19137
+ // State
19138
+ const [stripe, setStripe] = react.useState(null);
19139
+ // Hooks
19140
+ const showErrorNotification = common.useErrorNotification();
19141
+ const { token: antdToken } = useAntdToken();
19142
+ function getFontFamily() {
19143
+ if (antdToken.fontFamily === 'Inter') {
19144
+ return 'var(--font-inter, Inter), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
19145
+ }
19146
+ return antdToken.fontFamily;
19156
19147
  }
19157
- return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Text$z, { className: "relative -top-0.5", children: "****" }), jsxRuntime.jsx(Text$z, { children: (_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.identifier })] }));
19158
- };
19159
- const Issuer = ({ paymentMethodData }) => {
19160
- var _a;
19161
- const list = ['visa', 'link', 'jcb', 'discover', 'sepa'];
19162
- const issuer = (_a = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _a === void 0 ? void 0 : _a.issuer;
19163
- if (issuer.length == 0 || list.includes(issuer.toLowerCase()))
19164
- return null;
19165
- return jsxRuntime.jsx(Text$z, { children: lodashExports.capitalize(issuer) });
19166
- };
19167
- const DropdownMenu = ({ setDefault, remove, isDefault, id, }) => {
19168
- const { brandColor } = useBrand();
19169
- // Define the menu items
19170
- const items = [
19171
- {
19172
- key: '1',
19173
- label: 'Remove',
19174
- disabled: !remove,
19175
- onClick: () => {
19176
- remove === null || remove === void 0 ? void 0 : remove();
19177
- },
19148
+ const fontFamily = getFontFamily();
19149
+ const appearance = {
19150
+ variables: {
19151
+ fontFamily: fontFamily,
19152
+ fontLineHeight: antdToken.lineHeight.toString(),
19153
+ borderRadius: antdToken.borderRadius.toString() + 'px',
19154
+ colorBackground: 'white',
19155
+ colorPrimary: antdToken.colorPrimary,
19178
19156
  },
19179
- {
19180
- key: '2',
19181
- label: 'Set as default',
19182
- onClick: () => {
19183
- setDefault === null || setDefault === void 0 ? void 0 : setDefault();
19157
+ rules: {
19158
+ '.Input': {
19159
+ fontFamily: fontFamily,
19160
+ },
19161
+ '.Label': {
19162
+ fontFamily: fontFamily,
19184
19163
  },
19185
- disabled: isDefault,
19186
19164
  },
19187
- ];
19188
- return (jsxRuntime.jsx(antd.Dropdown, { menu: { items }, trigger: ['click'], children: jsxRuntime.jsx("a", { onClick: e => e.preventDefault(), id: id, className: "cursor-pointer hover:bg-gray-100 rounded-md p-1", children: jsxRuntime.jsx(icons.EllipsisOutlined, { style: { fontSize: '20px', color: brandColor } }) }) }));
19189
- };
19190
- const CardImage = ({ paymentMethodData }) => {
19191
- var _a, _b;
19192
- const issuer = (((_a = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _a === void 0 ? void 0 : _a.issuer) || '').toLowerCase();
19193
- const type = (((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.type) || '').toLowerCase();
19194
- const className = 'w-12 h-8';
19195
- if (type === 'cashapp') {
19196
- return jsxRuntime.jsx(Cashapp$1, { className: className });
19197
- }
19198
- if (type === 'link') {
19199
- return jsxRuntime.jsx(Cashapp, { className: className });
19200
- }
19201
- switch (issuer) {
19202
- case 'visa':
19203
- return jsxRuntime.jsx(Visa, { className: className });
19204
- case 'mastercard':
19205
- return jsxRuntime.jsx(Mastercard, { className: className });
19206
- case 'amex':
19207
- return jsxRuntime.jsx(Amex, { className: className });
19208
- case 'jcb':
19209
- return jsxRuntime.jsx(JCB, { className: className });
19210
- case 'diners_club':
19211
- case 'diners':
19212
- return jsxRuntime.jsx(DinersClub, { className: className });
19213
- case 'discover':
19214
- return jsxRuntime.jsx(Discover, { className: className });
19215
- case 'unionpay':
19216
- case 'union_pay':
19217
- case 'china_union_pay':
19218
- case 'china_unionpay':
19219
- return jsxRuntime.jsx(ChinaUnionPay, { className: className });
19220
- case 'sepa':
19221
- return jsxRuntime.jsx(Sepa, { className: className });
19222
- case 'ideal':
19223
- return jsxRuntime.jsx(IDeal, { className: className });
19224
- case 'bancontact':
19225
- return jsxRuntime.jsx(Bancontact, { className: className });
19226
- default:
19227
- return jsxRuntime.jsx(CreditCard, { className: className });
19228
- }
19165
+ };
19166
+ const options = {
19167
+ mode: 'setup',
19168
+ currency: currencyId,
19169
+ setupFutureUsage: 'off_session',
19170
+ appearance,
19171
+ };
19172
+ react.useEffect(() => {
19173
+ var _a, _b;
19174
+ if (!plugin)
19175
+ return;
19176
+ if (((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) !== 'StripePayment')
19177
+ return;
19178
+ fetchStripeKey(plugin, apiHost || '', token, accountId)
19179
+ .then(({ payload }) => index_js.loadStripe(payload.publishable_key).then(setStripe))
19180
+ .catch(error => {
19181
+ console.error('Caught Error in fetching stripe key: ', error);
19182
+ showErrorNotification(error.message, 'Unexpected Error fetching key');
19183
+ });
19184
+ // eslint-disable-next-line
19185
+ }, [plugin, token]);
19186
+ return { stripe, options };
19229
19187
  };
19230
19188
 
19231
- // Automatically sets the default payment method if there is none currently set
19232
- const useAutoSetDefaultPaymentMethod = ({ accountId, token, handleSetDefault, setDefaultPaymentMethodLoading, enabled = true, }) => {
19233
- const queryClient = reactQuery.useQueryClient();
19189
+ function useApproveHold$1({ onApproveHoldSuccess, onApproveHoldError, }) {
19190
+ // Hooks
19191
+ const [isApprovingHold, setIsApprovingHold] = react.useState(false);
19192
+ const { apiHost } = react.useContext(BunnyContext);
19193
+ const token = useToken();
19194
+ const approveHold = async ({ plugin, quote, paymentMethodId, }) => {
19195
+ try {
19196
+ if (!token)
19197
+ throw new Error("Token couldn't be retrieved");
19198
+ setIsApprovingHold(true);
19199
+ const response = await createPaymentHold({
19200
+ quote,
19201
+ plugin,
19202
+ token,
19203
+ apiHost,
19204
+ paymentMethodId,
19205
+ });
19206
+ if (response.status !== 'success')
19207
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
19208
+ onApproveHoldSuccess === null || onApproveHoldSuccess === void 0 ? void 0 : onApproveHoldSuccess(response);
19209
+ }
19210
+ catch (error) {
19211
+ console.error(error);
19212
+ onApproveHoldError === null || onApproveHoldError === void 0 ? void 0 : onApproveHoldError(error);
19213
+ }
19214
+ finally {
19215
+ setIsApprovingHold(false);
19216
+ }
19217
+ };
19218
+ return { approveHold, isApprovingHold };
19219
+ }
19220
+
19221
+ // Used for Signup component. Signup needs a custom checkout function
19222
+ const [CustomCheckoutFunctionProvider, useCustomCheckoutFunction] = createValueContext();
19223
+
19224
+ const showErrorNotification$8 = common.useErrorNotification();
19225
+ function usePay$1({ onPaymentSuccess, onPaymentError, quote, invoice, plugin, }) {
19226
+ const { apiHost } = react.useContext(BunnyContext);
19227
+ const customCheckoutFunction = useCustomCheckoutFunction();
19228
+ const token = useToken();
19229
+ const [isPaying, setIsPaying] = react.useState(false);
19230
+ const pay = async (paymentMethodId) => {
19231
+ try {
19232
+ setIsPaying(true);
19233
+ if (customCheckoutFunction) {
19234
+ if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
19235
+ showErrorNotification$8('Plugin ID is required');
19236
+ return;
19237
+ }
19238
+ const response = await customCheckoutFunction(plugin === null || plugin === void 0 ? void 0 : plugin.id.toString(), paymentMethodId.toString());
19239
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
19240
+ }
19241
+ else {
19242
+ const response = await checkout({
19243
+ invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
19244
+ quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
19245
+ paymentMethodId,
19246
+ token,
19247
+ apiHost,
19248
+ });
19249
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
19250
+ }
19251
+ }
19252
+ catch (error) {
19253
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error);
19254
+ }
19255
+ finally {
19256
+ setIsPaying(false);
19257
+ }
19258
+ };
19259
+ return { pay, isPaying };
19260
+ }
19261
+
19262
+ function useApproveHold({ onApproveHoldSuccess, onApproveHoldError, }) {
19263
+ // Hooks
19264
+ const [isApprovingHold, setIsApprovingHold] = react.useState(false);
19265
+ const { apiHost } = react.useContext(BunnyContext);
19266
+ const token = useToken();
19267
+ const approveHold = async ({ plugin, quote, paymentMethodId, }) => {
19268
+ try {
19269
+ if (!token)
19270
+ throw new Error("Token couldn't be retrieved");
19271
+ setIsApprovingHold(true);
19272
+ const response = await createPaymentHold({
19273
+ quote,
19274
+ plugin,
19275
+ token,
19276
+ apiHost,
19277
+ paymentMethodId,
19278
+ });
19279
+ if (response.status !== 'success')
19280
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
19281
+ onApproveHoldSuccess === null || onApproveHoldSuccess === void 0 ? void 0 : onApproveHoldSuccess(response);
19282
+ }
19283
+ catch (error) {
19284
+ console.error(error);
19285
+ onApproveHoldError === null || onApproveHoldError === void 0 ? void 0 : onApproveHoldError(error);
19286
+ }
19287
+ finally {
19288
+ setIsApprovingHold(false);
19289
+ }
19290
+ };
19291
+ return { approveHold, isApprovingHold };
19292
+ }
19293
+
19294
+ const showErrorNotification$7 = common.useErrorNotification();
19295
+ function usePay({ onPaymentSuccess, onPaymentError, quote, invoice, plugin, }) {
19296
+ // Hooks
19234
19297
  const { apiHost } = react.useContext(BunnyContext);
19235
- const { paymentMethods: storedPaymentMethods, defaultPaymentMethod } = usePaymentMethod({
19236
- accountId,
19237
- token,
19238
- apiHost,
19239
- });
19240
- // Set the default payment method on the cache. Prevents 'handleSetDefault' from being called too many times.
19241
- function setDefaultPaymentMethodOnCache(targetPaymentMethod) {
19242
- let cachedPaymentMethods = queryClient.getQueryData(common.QueryKeyFactory.default.accountPaymentMethodsKey({
19243
- accountId,
19244
- token,
19245
- }));
19246
- if (cachedPaymentMethods) {
19247
- for (const paymentMethod of cachedPaymentMethods) {
19248
- paymentMethod.isDefault = paymentMethod.id === targetPaymentMethod.id;
19298
+ const customCheckoutFunction = useCustomCheckoutFunction();
19299
+ const token = useToken();
19300
+ const [isPaying, setIsPaying] = react.useState(false);
19301
+ const pay = async (paymentMethodId) => {
19302
+ try {
19303
+ setIsPaying(true);
19304
+ if (customCheckoutFunction) {
19305
+ if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
19306
+ showErrorNotification$7('Plugin ID is required');
19307
+ return;
19308
+ }
19309
+ const response = await customCheckoutFunction(plugin === null || plugin === void 0 ? void 0 : plugin.id.toString(), paymentMethodId.toString());
19310
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
19311
+ }
19312
+ else {
19313
+ const response = await checkout({
19314
+ invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
19315
+ quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
19316
+ paymentMethodId,
19317
+ token,
19318
+ apiHost,
19319
+ });
19320
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
19249
19321
  }
19250
- queryClient.setQueryData(common.QueryKeyFactory.default.accountPaymentMethodsKey({
19251
- accountId,
19252
- token,
19253
- }), cachedPaymentMethods);
19254
19322
  }
19255
- }
19256
- react.useEffect(() => {
19257
- if (setDefaultPaymentMethodLoading || !enabled)
19323
+ catch (error) {
19324
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error);
19325
+ }
19326
+ finally {
19327
+ setIsPaying(false);
19328
+ }
19329
+ };
19330
+ return { pay, isPaying };
19331
+ }
19332
+
19333
+ var PaymentType;
19334
+ (function (PaymentType) {
19335
+ PaymentType["PAY"] = "PAY";
19336
+ PaymentType["APPROVE_HOLD"] = "APPROVE_HOLD";
19337
+ PaymentType["CHECKOUT_NO_PAYMENT"] = "CHECKOUT_NO_PAYMENT";
19338
+ })(PaymentType || (PaymentType = {}));
19339
+
19340
+ const handleAllErrorFormats$2 = common.useAllErrorFormats();
19341
+ const showErrorNotification$6 = common.useErrorNotification();
19342
+ const useHandlePayment = ({ quote, invoice, onPaymentSuccess, onPaymentHoldSuccess, plugin, paymentHoldOptions, accountId, }) => {
19343
+ // Context
19344
+ const { defaultPaymentMethod } = usePaymentMethod({ accountId });
19345
+ const { apiHost } = react.useContext(BunnyContext);
19346
+ const token = useToken();
19347
+ const formattedAmountDue = () => {
19348
+ const amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
19349
+ const currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId);
19350
+ return amountDue && currencyId ? common.formatCurrency(amountDue, currencyId).toString() : undefined;
19351
+ };
19352
+ // Payment hooks
19353
+ const { pay: payDemoPay, isPaying: isPayingDemoPay } = usePay$1({
19354
+ onPaymentSuccess,
19355
+ onPaymentError: error => {
19356
+ handleAllErrorFormats$2(error);
19357
+ },
19358
+ quote: quote,
19359
+ invoice: invoice,
19360
+ plugin,
19361
+ });
19362
+ const { pay: payStripe, isPaying: isPayingStripe } = usePay({
19363
+ onPaymentSuccess,
19364
+ onPaymentError: error => {
19365
+ handleAllErrorFormats$2(error);
19366
+ },
19367
+ quote: quote,
19368
+ invoice: invoice,
19369
+ plugin,
19370
+ });
19371
+ // Approve hold hooks
19372
+ const { approveHold: approveHoldStripe, isApprovingHold: isApprovingHoldStripe } = useApproveHold({
19373
+ onApproveHoldSuccess: response => {
19374
+ onPaymentHoldSuccess === null || onPaymentHoldSuccess === void 0 ? void 0 : onPaymentHoldSuccess(response);
19375
+ },
19376
+ onApproveHoldError: error => {
19377
+ handleAllErrorFormats$2(error);
19378
+ },
19379
+ });
19380
+ const { approveHold: approveHoldDemoPay, isApprovingHold: isApprovingHoldDemoPay } = useApproveHold$1({
19381
+ onApproveHoldSuccess: response => {
19382
+ onPaymentHoldSuccess === null || onPaymentHoldSuccess === void 0 ? void 0 : onPaymentHoldSuccess(response);
19383
+ },
19384
+ onApproveHoldError: error => {
19385
+ handleAllErrorFormats$2(error);
19386
+ },
19387
+ });
19388
+ // Mutations
19389
+ const { mutate: checkoutNoPayment, isPending: isCheckingOutNoPayment } = reactQuery.useMutation({
19390
+ mutationFn: async () => {
19391
+ const amountDue = formattedAmountDue();
19392
+ const paymentRequired = amountDue ? parseFloat(amountDue) > 0 : true;
19393
+ if (!quote)
19394
+ throw new Error('Quote is required');
19395
+ if (paymentRequired)
19396
+ throw new Error('Payment is required');
19397
+ return await checkout({ quoteId: quote.id, token, apiHost });
19398
+ },
19399
+ onSuccess: () => {
19400
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess({});
19401
+ },
19402
+ onError: error => {
19403
+ handleAllErrorFormats$2(error);
19404
+ },
19405
+ });
19406
+ const handleApproveHold = async (overridePaymentMethodId) => {
19407
+ var _a, _b, _c, _d;
19408
+ const paymentMethodId = overridePaymentMethodId || (defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id);
19409
+ if (!plugin)
19410
+ return showErrorNotification$6('plugin is undefined');
19411
+ if (!quote)
19412
+ return showErrorNotification$6('quote is undefined');
19413
+ if (!paymentMethodId)
19414
+ return showErrorNotification$6('payment method id is undefined');
19415
+ switch ((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) {
19416
+ case 'StripePayment':
19417
+ await approveHoldStripe({
19418
+ plugin,
19419
+ quote,
19420
+ paymentMethodId,
19421
+ });
19422
+ break;
19423
+ case 'DemoPayPayment':
19424
+ await approveHoldDemoPay({
19425
+ plugin,
19426
+ quote,
19427
+ paymentMethodId,
19428
+ });
19429
+ break;
19430
+ default:
19431
+ showErrorNotification$6(`Payment holds are not supported by ${(_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d[0].name}`);
19432
+ break;
19433
+ }
19434
+ };
19435
+ const handlePayment = async (overridePaymentMethodId) => {
19436
+ var _a, _b;
19437
+ if (!plugin)
19258
19438
  return;
19259
- if ((storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) > 0 && !defaultPaymentMethod) {
19260
- handleSetDefault(storedPaymentMethods[0]);
19261
- setDefaultPaymentMethodOnCache(storedPaymentMethods[0]);
19439
+ switch ((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) {
19440
+ case 'StripePayment':
19441
+ await payStripe(overridePaymentMethodId);
19442
+ break;
19443
+ case 'DemoPayPayment':
19444
+ await payDemoPay(overridePaymentMethodId);
19445
+ break;
19262
19446
  }
19263
- }, [
19264
- storedPaymentMethods,
19265
- defaultPaymentMethod,
19266
- handleSetDefault,
19267
- setDefaultPaymentMethodLoading,
19268
- queryClient,
19269
- accountId,
19270
- token,
19271
- ]);
19447
+ };
19448
+ return {
19449
+ handleApproveHold,
19450
+ handlePayment,
19451
+ handleCheckoutNoPayment: checkoutNoPayment,
19452
+ isPaying: isCheckingOutNoPayment ||
19453
+ isPayingDemoPay ||
19454
+ isPayingStripe ||
19455
+ isApprovingHoldDemoPay ||
19456
+ isApprovingHoldStripe,
19457
+ paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : PaymentType.PAY,
19458
+ formattedAmountDue: formattedAmountDue(),
19459
+ };
19272
19460
  };
19273
19461
 
19274
- const usePaymentMethodSelectorPlugin = ({ defaultPaymentMethod, defaultPaymentMethodPlugin, paymentMethodAllowedPlugins, }) => {
19275
- const [selectorPaymentMethodPlugin, setSelectorPaymentMethodPlugin] = react.useState();
19276
- react.useEffect(() => {
19277
- if (selectorPaymentMethodPlugin) {
19278
- return;
19462
+ function useSave({ onSaveSuccess, onSaveError, accountId, }) {
19463
+ // Hooks
19464
+ const [isSaving, setIsSaving] = react.useState(false);
19465
+ const elements = reactStripeJs.useElements();
19466
+ const stripe = reactStripeJs.useStripe();
19467
+ const { apiHost } = react.useContext(BunnyContext);
19468
+ const token = useToken();
19469
+ const selectedPlugin = useSelectedPlugin();
19470
+ const createStripePaymentMethodId = async () => {
19471
+ var _a, _b;
19472
+ if (!stripe)
19473
+ throw new Error('Form is not ready');
19474
+ if (!elements)
19475
+ throw new Error("Elements couldn't be retrieved");
19476
+ // Trigger form validation and wallet collection
19477
+ const { error: submitError } = await elements.submit();
19478
+ if (submitError)
19479
+ throw new Error(submitError.message);
19480
+ const response = await createSetupIntent(selectedPlugin, apiHost, token, accountId);
19481
+ if (response.status !== 'success')
19482
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
19483
+ const clientSecret = (_a = response === null || response === void 0 ? void 0 : response.payload) === null || _a === void 0 ? void 0 : _a.client_secret;
19484
+ if (!clientSecret)
19485
+ throw new Error('Error retrieving client secret');
19486
+ // Confirm the SetupIntent using the details collected by the Payment Element
19487
+ const intentResponse = await stripe.confirmSetup({
19488
+ elements,
19489
+ clientSecret,
19490
+ redirect: 'if_required',
19491
+ confirmParams: {
19492
+ return_url: window.location.href,
19493
+ },
19494
+ });
19495
+ // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
19496
+ if (intentResponse.error)
19497
+ throw new Error(intentResponse.error.message);
19498
+ const paymentMethodId = (_b = intentResponse.setupIntent.payment_method) === null || _b === void 0 ? void 0 : _b.toString();
19499
+ if (!paymentMethodId)
19500
+ throw new Error("Payment method couldn't be retrieved");
19501
+ return paymentMethodId;
19502
+ };
19503
+ const save = async () => {
19504
+ try {
19505
+ setIsSaving(true);
19506
+ const paymentMethodId = await createStripePaymentMethodId();
19507
+ const paymentMethodResponse = await createPaymentMethod({
19508
+ paymentMethodId,
19509
+ plugin: selectedPlugin,
19510
+ token,
19511
+ apiHost,
19512
+ accountId,
19513
+ });
19514
+ const savedPaymentMethodId = paymentMethodResponse.payload[0].id;
19515
+ onSaveSuccess === null || onSaveSuccess === void 0 ? void 0 : onSaveSuccess({
19516
+ pluginPaymentResponse: {
19517
+ savePaymentMethod: true,
19518
+ plugin: selectedPlugin,
19519
+ token: paymentMethodResponse.token,
19520
+ },
19521
+ savedPaymentMethodResponse: {
19522
+ paymentMethodId: savedPaymentMethodId,
19523
+ },
19524
+ });
19525
+ return savedPaymentMethodId;
19279
19526
  }
19280
- if (defaultPaymentMethod) {
19281
- setSelectorPaymentMethodPlugin(defaultPaymentMethodPlugin);
19527
+ catch (error) {
19528
+ onSaveError === null || onSaveError === void 0 ? void 0 : onSaveError(error);
19282
19529
  }
19283
- else {
19284
- setSelectorPaymentMethodPlugin(paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]);
19530
+ finally {
19531
+ setIsSaving(false);
19285
19532
  }
19286
- }, [
19287
- defaultPaymentMethod,
19288
- defaultPaymentMethodPlugin,
19289
- paymentMethodAllowedPlugins,
19290
- ]);
19291
- return {
19292
- selectorPaymentMethodPlugin,
19293
- setSelectorPaymentMethodPlugin,
19533
+ return undefined;
19294
19534
  };
19295
- };
19535
+ return { save, createStripePaymentMethodId, isSaving };
19536
+ }
19296
19537
 
19297
- const SavePaymentMethodFooter = ({ isSaving, onSave, noPadding, }) => {
19298
- const isMobile = common.useIsMobile();
19299
- const { onClickCancel } = react.useContext(PaymentContext);
19300
- return (jsxRuntime.jsxs("div", { className: `bunny-flex bunny-justify-end bunny-gap-2 ${noPadding ? "" : "pt-6"}`, children: [onClickCancel && (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", size: isMobile ? "large" : "middle", onClick: () => onClickCancel(), children: "Cancel" })), jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isSaving, onClick: onSave, size: isMobile ? "large" : "middle", type: "primary", children: isSaving ? "Saving" : "Save" })] }));
19301
- };
19538
+ const useShowPaymentDetailsState = (isOpen = false) => react.useState(isOpen);
19539
+ const [ShowPaymentDetailsProvider, useShowPaymentDetails] = createStateContext(useShowPaymentDetailsState);
19302
19540
 
19303
- const DIGIT_REGEX = /\d/;
19304
- const isDigit = (char) => DIGIT_REGEX.test(char);
19305
- const isDeletion = (char) => [8, 46].includes(char); // Backspace or Delete
19306
- const isNavigation = (char) => [9, 37, 38, 39, 40].includes(char); // Tab, Arrows
19307
- const isModifier = (char) => [16, 17, 18].includes(char); // Shift, Ctrl, Alt
19308
- const isValidKey = (code) => isDeletion(code) || isNavigation(code) || isModifier(code);
19309
- const isValidExpiry = (expiry) => {
19310
- const month = parseInt(expiry.substring(0, 2), 10);
19311
- const year = parseInt(expiry.substring(2, 4), 10) + 2000;
19312
- if (isNaN(month) || isNaN(year))
19313
- return false;
19314
- if (month < 1 || month > 12)
19315
- return false;
19316
- return true;
19317
- };
19318
- const isCardExpired = (expiry) => {
19319
- const month = parseInt(expiry.substring(0, 2), 10);
19320
- const year = parseInt(expiry.substring(2, 4), 10) + 2000;
19321
- const expiryDate = new Date(year, month, 1);
19322
- return expiryDate < new Date();
19323
- };
19324
- const formatCardExpiry = (cardExpiry) => {
19325
- if (cardExpiry.length <= 2)
19326
- return cardExpiry;
19327
- return cardExpiry.substring(0, 2) + '/' + cardExpiry.substring(2);
19328
- };
19329
- // removes spaces from a credit card number
19330
- const unformatCardNumber = (cardNumber) => {
19331
- const cardNumberArray = cardNumber.split('');
19332
- const unformattedCardNumberArray = cardNumberArray.filter(character => character !== ' ');
19333
- return unformattedCardNumberArray.join('');
19334
- };
19335
- const storePayment = async (options, plugin, apiHost, accountId) => {
19336
- const { testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token } = options;
19337
- const response = await common.invokePlugin({
19338
- method: 'store_payment_method',
19339
- plugin,
19340
- payload: {
19341
- test_credit_card_number: testCreditCardNumber,
19342
- test_credit_card_cvc: testCreditCardCvc,
19343
- test_credit_card_expiration_date: testCreditCardExpirationDate,
19344
- account_id: accountId,
19541
+ const handleAllErrorFormats$1 = common.useAllErrorFormats();
19542
+ const showErrorNotification$5 = common.useErrorNotification();
19543
+ // Contexts
19544
+ const [AmountDueProvider, useAmountDue] = createValueContext();
19545
+ const [PaymentTypeProvider, usePaymentType] = createValueContext();
19546
+ const [IsPayingProvider, useIsPaying] = createValueContext();
19547
+ const [HandlePaymentFormSubmitProvider, useHandlePaymentFormSubmit] = createValueContext();
19548
+ const [IsSavingProvider, useIsSaving] = createValueContext();
19549
+ // Used for Signup component. Signup uses an apiClient token which api can't infer an account from, so accountId must be used
19550
+ const [AccountIdProvider, useAccountId] = createValueContext();
19551
+ function PaymentProvider({ children, accountId, quote, invoice, onPaymentSuccess, onPaymentHoldSuccess, paymentHoldOptions, onSavePaymentMethod, }) {
19552
+ var _a, _b, _c;
19553
+ // Context
19554
+ const [showPaymentMethodForm, setShowPaymentMethodForm] = useShowPaymentDetails();
19555
+ const selectedPlugin = useSelectedPlugin();
19556
+ // Hooks
19557
+ const queryClient = reactQuery.useQueryClient();
19558
+ const token = useToken();
19559
+ const { handlePayment, handleApproveHold, handleCheckoutNoPayment, isPaying, paymentType, formattedAmountDue, } = useHandlePayment({
19560
+ quote,
19561
+ invoice,
19562
+ onPaymentSuccess: (response) => {
19563
+ // TODO: type the response to PaymentSuccessResponse
19564
+ // Hide payment method selector and form
19565
+ setShowPaymentMethodForm(false);
19566
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
19345
19567
  },
19346
- token,
19347
- apiHost,
19568
+ onPaymentHoldSuccess,
19569
+ plugin: selectedPlugin, // TODO: type the response to PluginData
19570
+ paymentHoldOptions,
19571
+ accountId,
19348
19572
  });
19349
- if ((response === null || response === void 0 ? void 0 : response.status) !== 'success')
19350
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
19351
- return response;
19573
+ const { defaultPaymentMethod } = usePaymentMethod({ accountId });
19574
+ const { save: saveDemoPay, isSaving: isSavingDemoPay } = useSave$1({
19575
+ onSaveSuccess: (response) => {
19576
+ onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(response);
19577
+ queryClient.invalidateQueries({
19578
+ queryKey: QueryKeyFactory.accountPaymentMethodsKey({
19579
+ accountId,
19580
+ token,
19581
+ }),
19582
+ });
19583
+ setShowPaymentMethodForm(false);
19584
+ },
19585
+ onSaveError: handleAllErrorFormats$1,
19586
+ accountId,
19587
+ });
19588
+ const { save: saveStripe, isSaving: isSavingStripe } = useSave({
19589
+ onSaveSuccess: async (response) => {
19590
+ onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(response);
19591
+ queryClient.invalidateQueries({
19592
+ queryKey: QueryKeyFactory.accountPaymentMethodsKey({
19593
+ accountId,
19594
+ token,
19595
+ }),
19596
+ });
19597
+ setShowPaymentMethodForm(false);
19598
+ },
19599
+ onSaveError: handleAllErrorFormats$1,
19600
+ accountId,
19601
+ });
19602
+ const pluginName = (_c = (_b = (_a = selectedPlugin === null || selectedPlugin === void 0 ? void 0 : selectedPlugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name;
19603
+ const handleSave = async (demoPayCardDetails) => {
19604
+ var _a, _b;
19605
+ if (pluginName === 'StripePayment') {
19606
+ return await saveStripe();
19607
+ }
19608
+ else if (pluginName === 'DemoPayPayment') {
19609
+ return await saveDemoPay(demoPayCardDetails);
19610
+ }
19611
+ else {
19612
+ showErrorNotification$5(`Can not find form for plugin ${(_b = (_a = selectedPlugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name}`);
19613
+ return undefined;
19614
+ }
19615
+ };
19616
+ const handleApproveHoldFlow = async (savedPaymentMethodId) => {
19617
+ var _a, _b;
19618
+ if (pluginName === 'StripePayment') {
19619
+ await handleApproveHold(savedPaymentMethodId);
19620
+ }
19621
+ else if (pluginName === 'DemoPayPayment') {
19622
+ await handleApproveHold(savedPaymentMethodId);
19623
+ }
19624
+ else {
19625
+ showErrorNotification$5(`Can not find form for plugin ${(_b = (_a = selectedPlugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name}`);
19626
+ }
19627
+ };
19628
+ const handlePaymentFormSubmit = async (demoPayCardDetails) => {
19629
+ if (paymentType === PaymentType.CHECKOUT_NO_PAYMENT) {
19630
+ handleCheckoutNoPayment();
19631
+ return;
19632
+ }
19633
+ if (paymentType === PaymentType.APPROVE_HOLD) {
19634
+ // If payment method form is shown, save payment method first, then approve hold
19635
+ const savedPaymentMethodId = showPaymentMethodForm
19636
+ ? await handleSave(demoPayCardDetails)
19637
+ : undefined;
19638
+ await handleApproveHoldFlow(savedPaymentMethodId);
19639
+ return;
19640
+ }
19641
+ if (formattedAmountDue === undefined) {
19642
+ // If amount due is undefined, we need to save a payment method only
19643
+ await handleSave(demoPayCardDetails);
19644
+ return;
19645
+ }
19646
+ if (paymentType === PaymentType.PAY) {
19647
+ if (showPaymentMethodForm) {
19648
+ // If paying and showing payment method form, save payment method first, then pay (1 click for user convenience)
19649
+ const savedPaymentMethodId = await handleSave(demoPayCardDetails);
19650
+ if (savedPaymentMethodId) {
19651
+ await handlePayment(savedPaymentMethodId);
19652
+ }
19653
+ }
19654
+ else {
19655
+ if (!(defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id)) {
19656
+ showErrorNotification$5('Default payment method ID is undefined');
19657
+ return;
19658
+ }
19659
+ await handlePayment(defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id);
19660
+ }
19661
+ return;
19662
+ }
19663
+ };
19664
+ const providers = [
19665
+ [AmountDueProvider, { value: formattedAmountDue }],
19666
+ [PaymentTypeProvider, { value: paymentType }],
19667
+ [IsPayingProvider, { value: isPaying }],
19668
+ [HandlePaymentFormSubmitProvider, { value: handlePaymentFormSubmit }],
19669
+ [IsSavingProvider, { value: isSavingDemoPay || isSavingStripe }],
19670
+ [AccountIdProvider, { value: accountId }],
19671
+ ];
19672
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: providers.reduceRight((acc, [Provider, props]) => react.createElement(Provider, props, acc), children) }));
19673
+ }
19674
+ function StripeWrapper({ children, currencyId, accountId, }) {
19675
+ const plugin = useSelectedPlugin();
19676
+ const { stripe, options } = useStripePlugin(plugin, currencyId, accountId);
19677
+ return (jsxRuntime.jsx(reactStripeJs.Elements, { options: options, stripe: stripe, children: children }));
19678
+ }
19679
+
19680
+ const CheckoutFooter = () => {
19681
+ const isMobile = useIsMobile();
19682
+ const paymentType = usePaymentType();
19683
+ const isPaying = useIsPaying();
19684
+ const formattedAmountDue = useAmountDue();
19685
+ const onPaymentFormSubmit = useHandlePaymentFormSubmit();
19686
+ const buttonText = paymentType === PaymentType.APPROVE_HOLD ? 'Approve hold for' : 'Pay';
19687
+ const isPayingButtonText = paymentType === PaymentType.APPROVE_HOLD ? 'Approving hold for' : 'Paying';
19688
+ return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isPaying, onClick: () => onPaymentFormSubmit(), size: isMobile ? 'large' : 'middle', type: "primary", children: `${isPaying ? isPayingButtonText : buttonText} ${formattedAmountDue}` }));
19352
19689
  };
19353
19690
 
19691
+ function PaymentMethodFooter({ onSubmit, noPadding, }) {
19692
+ const isPaying = useIsPaying();
19693
+ const isSaving = useIsSaving();
19694
+ const buttonText = useSubmitButtonText();
19695
+ const isMobile = common.useIsMobile();
19696
+ const [, setShowPaymentMethodForm] = useShowPaymentDetails();
19697
+ return (jsxRuntime.jsxs("div", { className: `bunny-flex bunny-justify-end bunny-gap-2 ${noPadding ? '' : 'pt-6'}`, children: [jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", size: isMobile ? 'large' : 'middle', onClick: () => setShowPaymentMethodForm(false), children: "Cancel" }), jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isSaving || isPaying, loading: isSaving || isPaying, onClick: onSubmit, size: isMobile ? 'large' : 'middle', type: "primary", children: buttonText })] }));
19698
+ }
19699
+ function useSubmitButtonText() {
19700
+ const amountDue = useAmountDue();
19701
+ const paymentType = usePaymentType();
19702
+ const payableAvailable = amountDue !== undefined;
19703
+ const paymentTypeText = paymentType === PaymentType.APPROVE_HOLD ? 'approve hold for' : 'pay';
19704
+ const buttonTextPrefix = payableAvailable ? paymentTypeText : 'save';
19705
+ return lodashExports.capitalize(buttonTextPrefix) + ' ' + (amountDue !== null && amountDue !== void 0 ? amountDue : '');
19706
+ }
19707
+
19354
19708
  const DemoPayCardCvc = ({ autoFocus, onChange, placeholder, value, }) => {
19355
19709
  const onKeyPress = (event) => {
19356
19710
  if (!isDigit(event.key) && !isValidKey(event.keyCode))
@@ -19389,73 +19743,27 @@ const DemoPayExpiry = ({ autoFocus, onChange, placeholder, value, }) => {
19389
19743
  return (jsxRuntime.jsx("div", { className: "bunny-grow", children: jsxRuntime.jsx(antd.Input, { name: "expiry", autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: formatCardExpiry(value), maxLength: 5, placeholder: placeholder || "MM/YY" }) }));
19390
19744
  };
19391
19745
 
19392
- function useSave$1({ onSaveSuccess, onSaveError, token, apiHost, accountId, }) {
19393
- const [isSaving, setIsSaving] = react.useState(false);
19394
- const save = async ({ cardDetails, plugin, savePaymentMethod, }) => {
19395
- try {
19396
- setIsSaving(true);
19397
- const response = await storePayment({
19398
- testCreditCardNumber: unformatCardNumber(cardDetails.number),
19399
- testCreditCardCvc: cardDetails.cvc.toString(),
19400
- testCreditCardExpirationDate: cardDetails.expiry,
19401
- token,
19402
- }, plugin, apiHost, accountId);
19403
- const paymentMethodId = response.payload[0].id;
19404
- if (response.status !== 'success')
19405
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
19406
- onSaveSuccess === null || onSaveSuccess === void 0 ? void 0 : onSaveSuccess({
19407
- pluginPaymentResponse: {
19408
- plugin,
19409
- token: response.token,
19410
- savePaymentMethod,
19411
- },
19412
- savedPaymentMethodResponse: {
19413
- paymentMethodId,
19414
- },
19415
- });
19416
- }
19417
- catch (error) {
19418
- onSaveError === null || onSaveError === void 0 ? void 0 : onSaveError(error);
19419
- }
19420
- finally {
19421
- setIsSaving(false);
19422
- }
19423
- };
19424
- return { save, isSaving };
19425
- }
19426
-
19427
19746
  const { Text: Text$y } = antd.Typography;
19747
+ const handleAllErrorFormats = common.useAllErrorFormats();
19428
19748
  const TEST_CARD = '4242424242424242';
19429
- const DemoPayForm = ({ onFail, onSavePaymentMethod, plugin, }) => {
19749
+ const DemoPayForm = () => {
19430
19750
  // Context
19431
- const { token, apiHost, darkMode } = react.useContext(BunnyContext);
19432
- const { accountId } = react.useContext(PaymentContext);
19433
- // Hooks
19434
- const { save, isSaving } = useSave$1({
19435
- onSaveSuccess: onSavePaymentMethod,
19436
- onSaveError: onFail,
19437
- token,
19438
- apiHost,
19439
- accountId,
19440
- });
19751
+ const { darkMode } = react.useContext(BunnyContext);
19752
+ const onPaymentFormSubmit = useHandlePaymentFormSubmit();
19441
19753
  const [cardDetails, setCardDetails] = react.useState({
19442
19754
  number: '4242424242424242',
19443
19755
  expiry: '',
19444
19756
  cvc: '',
19445
19757
  });
19446
- const onSave = async () => {
19758
+ function onSubmit() {
19447
19759
  try {
19448
19760
  validateCardDetails();
19449
- await save({
19450
- cardDetails,
19451
- plugin,
19452
- savePaymentMethod: false,
19453
- });
19761
+ onPaymentFormSubmit(cardDetails);
19454
19762
  }
19455
19763
  catch (error) {
19456
- onFail(error);
19764
+ handleAllErrorFormats(error);
19457
19765
  }
19458
- };
19766
+ }
19459
19767
  function validateCardDetails() {
19460
19768
  if (cardDetails.number !== TEST_CARD)
19461
19769
  throw new Error('Only the card number 4242 4242 4242 4242 will be accepted.');
@@ -19475,7 +19783,7 @@ const DemoPayForm = ({ onFail, onSavePaymentMethod, plugin, }) => {
19475
19783
  const onCardCvcChange = (cvc) => {
19476
19784
  setCardDetails({ ...cardDetails, cvc });
19477
19785
  };
19478
- return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: [jsxRuntime.jsxs(StyledInputs, { className: "bunny-flex bunny-flex-col bunny-gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false, children: [jsxRuntime.jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxRuntime.jsxs("div", { className: "bunny-flex bunny-gap-2", children: [jsxRuntime.jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsxRuntime.jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] })] }), jsxRuntime.jsx(Text$y, { children: "DemoPay is for testing only." }), jsxRuntime.jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] }));
19786
+ return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: [jsxRuntime.jsxs(StyledInputs, { className: "bunny-flex bunny-flex-col bunny-gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false, children: [jsxRuntime.jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxRuntime.jsxs("div", { className: "bunny-flex bunny-gap-2", children: [jsxRuntime.jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsxRuntime.jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] })] }), jsxRuntime.jsx(Text$y, { children: "DemoPay is for testing only." }), jsxRuntime.jsx(PaymentMethodFooter, { onSubmit: onSubmit })] }));
19479
19787
  };
19480
19788
  const StyledInputs = defaultStyled.div `
19481
19789
  .ant-input {
@@ -19486,92 +19794,12 @@ const StyledInputs = defaultStyled.div `
19486
19794
  }
19487
19795
  `;
19488
19796
 
19489
- function useSave({ onSaveSuccess, onSaveError, }) {
19490
- // Hooks
19491
- const [isSaving, setIsSaving] = react.useState(false);
19492
- const elements = reactStripeJs.useElements();
19493
- const stripe = reactStripeJs.useStripe();
19494
- const { apiHost } = react.useContext(BunnyContext);
19495
- const token = useToken();
19496
- const { accountId } = react.useContext(PaymentContext);
19497
- const save = async ({ plugin }) => {
19498
- var _a, _b;
19499
- try {
19500
- if (!stripe)
19501
- throw new Error('Form is not ready');
19502
- if (!elements)
19503
- throw new Error("Elements couldn't be retrieved");
19504
- setIsSaving(true);
19505
- // Trigger form validation and wallet collection
19506
- const { error: submitError } = await elements.submit();
19507
- if (submitError)
19508
- throw new Error(submitError.message);
19509
- const response = await createSetupIntent(plugin, apiHost, token, accountId);
19510
- if (response.status !== 'success')
19511
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
19512
- const clientSecret = (_a = response === null || response === void 0 ? void 0 : response.payload) === null || _a === void 0 ? void 0 : _a.client_secret;
19513
- if (!clientSecret)
19514
- throw new Error('Error retrieving client secret');
19515
- // Confirm the SetupIntent using the details collected by the Payment Element
19516
- const intentResponse = await stripe.confirmSetup({
19517
- elements,
19518
- clientSecret,
19519
- redirect: 'if_required',
19520
- confirmParams: {
19521
- return_url: window.location.href,
19522
- },
19523
- });
19524
- // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
19525
- if (intentResponse.error)
19526
- throw new Error(intentResponse.error.message);
19527
- const paymentMethodId = (_b = intentResponse.setupIntent.payment_method) === null || _b === void 0 ? void 0 : _b.toString();
19528
- if (!paymentMethodId)
19529
- throw new Error("Payment method couldn't be retrieved");
19530
- const paymentMethodResponse = await createPaymentMethod({
19531
- paymentMethodId,
19532
- plugin,
19533
- token,
19534
- apiHost,
19535
- accountId,
19536
- });
19537
- onSaveSuccess === null || onSaveSuccess === void 0 ? void 0 : onSaveSuccess({
19538
- pluginPaymentResponse: {
19539
- savePaymentMethod: true,
19540
- plugin,
19541
- token: paymentMethodResponse.token,
19542
- },
19543
- savedPaymentMethodResponse: {
19544
- paymentMethodId: paymentMethodResponse.payload[0].id,
19545
- },
19546
- });
19547
- }
19548
- catch (error) {
19549
- onSaveError === null || onSaveError === void 0 ? void 0 : onSaveError(error);
19550
- }
19551
- finally {
19552
- setIsSaving(false);
19553
- }
19554
- };
19555
- return { save, isSaving };
19556
- }
19557
-
19558
- const PaymentMethodForm = ({ plugin, onFail, onSavePaymentMethod, }) => {
19797
+ const StripeForm = () => {
19798
+ // Context
19799
+ const onPaymentFormSubmit = useHandlePaymentFormSubmit();
19800
+ // State
19559
19801
  const [isIdealWarningOpen, setIsIdealWarningOpen] = react.useState(false);
19560
19802
  const idealWarningHasShown = react.useRef(false);
19561
- // Hooks
19562
- const { save, isSaving } = useSave({
19563
- onSaveSuccess: onSavePaymentMethod,
19564
- onSaveError: onFail,
19565
- });
19566
- // Handlers
19567
- const onSubmit = async () => {
19568
- try {
19569
- await save({ plugin });
19570
- }
19571
- catch (error) {
19572
- onFail(error);
19573
- }
19574
- };
19575
19803
  const onChange = (event) => {
19576
19804
  if (event.value.type === 'ideal' && !idealWarningHasShown.current) {
19577
19805
  idealWarningHasShown.current = true;
@@ -19580,26 +19808,22 @@ const PaymentMethodForm = ({ plugin, onFail, onSavePaymentMethod, }) => {
19580
19808
  };
19581
19809
  return (jsxRuntime.jsxs("form", { children: [jsxRuntime.jsx(reactStripeJs.PaymentElement, { options: {
19582
19810
  layout: { type: 'accordion' },
19583
- }, onChange: onChange }), jsxRuntime.jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSubmit }), jsxRuntime.jsx(IdealWarningModal, { isOpen: isIdealWarningOpen, onClose: () => setIsIdealWarningOpen(false) })] }));
19811
+ }, onChange: onChange }), jsxRuntime.jsx(PaymentMethodFooter, { onSubmit: onPaymentFormSubmit }), jsxRuntime.jsx(IdealWarningModal, { isOpen: isIdealWarningOpen, onClose: () => setIsIdealWarningOpen(false) })] }));
19584
19812
  };
19585
19813
  function IdealWarningModal({ isOpen, onClose }) {
19586
19814
  return (jsxRuntime.jsx(antd.Modal, { open: isOpen, onCancel: onClose, footer: jsxRuntime.jsx(antd.Button, { type: "primary", onClick: onClose, children: "Ok" }), children: jsxRuntime.jsx("div", { className: "bunny-p-4", children: "iDEAL will charge a 1 cent fee when storing this payment method. You will be refunded later." }) }));
19587
19815
  }
19588
19816
 
19589
- // This is just a wrapper to fetch the stripe object and pass it to the form
19590
- const StripeForm = ({ plugin, onFail, onSavePaymentMethod, }) => {
19591
- return (jsxRuntime.jsx(PaymentMethodForm, { plugin: plugin, onFail: onFail, onSavePaymentMethod: onSavePaymentMethod }));
19592
- };
19593
-
19594
- const PaymentMethodDetails = ({ onFail, plugin, onSavePaymentMethod, }) => {
19817
+ const PaymentMethodDetails = () => {
19595
19818
  var _a, _b;
19596
- switch ((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) {
19819
+ const selectedPlugin = useSelectedPlugin();
19820
+ switch ((_b = (_a = selectedPlugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) {
19597
19821
  case 'StripePayment':
19598
- return (jsxRuntime.jsx(StripeForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
19822
+ return jsxRuntime.jsx(StripeForm, {});
19599
19823
  case 'DemoPayPayment':
19600
- return (jsxRuntime.jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: response => onSavePaymentMethod(response), plugin: plugin }));
19824
+ return jsxRuntime.jsx(DemoPayForm, {});
19601
19825
  default:
19602
- console.warn('Can not find form for plugin', plugin);
19826
+ console.warn('Can not find form for plugin', selectedPlugin);
19603
19827
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
19604
19828
  }
19605
19829
  };
@@ -19609,17 +19833,20 @@ const CardIcon = ({ className }) => {
19609
19833
  };
19610
19834
 
19611
19835
  const { Text: Text$x } = antd.Typography;
19612
- const PaymentMethodSelector = ({ paymentMethodAllowedPlugins, onSelect, value, }) => {
19613
- return (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map((plugin, index) => (jsxRuntime.jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentPlugin: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index))) }));
19836
+ const PaymentMethodSelector = () => {
19837
+ const accountId = useAccountId();
19838
+ const { paymentPlugins } = usePaymentPlugins(accountId);
19839
+ const [selectedPluginId, setSelectedPluginId] = useSelectedPluginId();
19840
+ return (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin, index) => (jsxRuntime.jsx(PaymentOption, { name: plugin.name, onClick: setSelectedPluginId, paymentPluginId: plugin.id, selected: selectedPluginId === plugin.id }, index))) }));
19614
19841
  };
19615
- const PaymentOption = ({ selected, paymentPlugin, onClick, name, }) => {
19842
+ const PaymentOption = ({ selected, paymentPluginId, onClick, name, }) => {
19616
19843
  const { brandColor } = useBrand();
19617
19844
  const { darkMode } = react.useContext(BunnyContext);
19618
19845
  const isAch = name === null || name === void 0 ? void 0 : name.toLowerCase().includes('ach');
19619
19846
  const isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes('card');
19620
19847
  return (jsxRuntime.jsxs(PaymentOptionContainer, { "$brandColor": brandColor, "$selected": selected, className: `bunny-flex bunny-justify-between bunny-items-center bunny-cursor-pointer bunny-py-2 bunny-rounded bunny-border-solid ${darkMode
19621
19848
  ? `var(--row-background-dark) border-gray-500`
19622
- : 'bunny-bg-slate-50 bunny-border-slate-200'} bunny-border`, onClick: () => onClick(paymentPlugin), children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-gap-2 bunny-items-center bunny-pl-4", children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? 'border-gray-400' : '' }), jsxRuntime.jsx(Text$x, { children: name })] }), isAch ? (jsxRuntime.jsx(icons.BankOutlined, { className: "bunny-pr-4" })) : isCard ? (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" })) : (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" }))] }));
19849
+ : 'bunny-bg-slate-50 bunny-border-slate-200'} bunny-border`, onClick: () => onClick(paymentPluginId), children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-gap-2 bunny-items-center bunny-pl-4", children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? 'border-gray-400' : '' }), jsxRuntime.jsx(Text$x, { children: name })] }), isAch ? (jsxRuntime.jsx(icons.BankOutlined, { className: "bunny-pr-4" })) : isCard ? (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" })) : (jsxRuntime.jsx(CardIcon, { className: "bunny-pr-4" }))] }));
19623
19850
  };
19624
19851
  const PaymentOptionContainer = defaultStyled.div `
19625
19852
  transition: border 0.3s ease;
@@ -19634,15 +19861,117 @@ const PaymentOptionContainer = defaultStyled.div `
19634
19861
  }
19635
19862
  `;
19636
19863
 
19637
- function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId, onRemovePaymentMethod, onError) {
19864
+ // Automatically sets the default payment method if there is none currently set
19865
+ const useAutoSetDefaultPaymentMethod = ({ handleSetDefault, setDefaultPaymentMethodLoading, enabled = true, }) => {
19866
+ const accountId = useAccountId();
19867
+ const token = useToken();
19868
+ const queryClient = reactQuery.useQueryClient();
19869
+ const { paymentMethods, defaultPaymentMethod } = usePaymentMethod({
19870
+ accountId,
19871
+ });
19872
+ // Set the default payment method on the cache. Prevents 'handleSetDefault' from being called too many times.
19873
+ function setDefaultPaymentMethodOnCache(targetPaymentMethod) {
19874
+ let cachedPaymentMethods = queryClient.getQueryData(common.QueryKeyFactory.default.accountPaymentMethodsKey({
19875
+ accountId,
19876
+ token,
19877
+ }));
19878
+ if (cachedPaymentMethods) {
19879
+ for (const paymentMethod of cachedPaymentMethods) {
19880
+ paymentMethod.isDefault = paymentMethod.id === targetPaymentMethod.id;
19881
+ }
19882
+ queryClient.setQueryData(common.QueryKeyFactory.default.accountPaymentMethodsKey({
19883
+ accountId,
19884
+ token,
19885
+ }), cachedPaymentMethods);
19886
+ }
19887
+ }
19888
+ react.useEffect(() => {
19889
+ var _a;
19890
+ if (setDefaultPaymentMethodLoading || !enabled)
19891
+ return;
19892
+ if ((paymentMethods === null || paymentMethods === void 0 ? void 0 : paymentMethods.length) && (paymentMethods === null || paymentMethods === void 0 ? void 0 : paymentMethods.length) > 0 && !defaultPaymentMethod) {
19893
+ handleSetDefault((_a = paymentMethods[0]) === null || _a === void 0 ? void 0 : _a.id);
19894
+ setDefaultPaymentMethodOnCache(paymentMethods[0]);
19895
+ }
19896
+ }, [
19897
+ paymentMethods,
19898
+ defaultPaymentMethod,
19899
+ handleSetDefault,
19900
+ setDefaultPaymentMethodLoading,
19901
+ queryClient,
19902
+ accountId,
19903
+ token,
19904
+ ]);
19905
+ };
19906
+
19907
+ const query$4 = t(`
19908
+ query GetCurrentUserData {
19909
+ company {
19910
+ name
19911
+ }
19912
+ currentUser {
19913
+ account {
19914
+ billingCountry
19915
+ currencyId
19916
+ id
19917
+ }
19918
+ authObjectName
19919
+ payload {
19920
+ returnUrl
19921
+ }
19922
+ privacyUrl
19923
+ termsUrl
19924
+ entityId
19925
+ }
19926
+ }
19927
+ `);
19928
+ const getCurrentUserData = async ({ token, apiHost }) => {
19929
+ var _a, _b, _c, _d, _e, _f, _g, _h;
19930
+ const response = await execute(query$4, { apiHost, token }, {});
19931
+ return {
19932
+ authObjectName: (_a = response === null || response === void 0 ? void 0 : response.currentUser) === null || _a === void 0 ? void 0 : _a.authObjectName,
19933
+ account: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.account,
19934
+ companyName: (_c = response === null || response === void 0 ? void 0 : response.company) === null || _c === void 0 ? void 0 : _c.name,
19935
+ returnUrl: (_e = (_d = response === null || response === void 0 ? void 0 : response.currentUser) === null || _d === void 0 ? void 0 : _d.payload) === null || _e === void 0 ? void 0 : _e.returnUrl,
19936
+ privacyUrl: (_f = response === null || response === void 0 ? void 0 : response.currentUser) === null || _f === void 0 ? void 0 : _f.privacyUrl,
19937
+ termsUrl: (_g = response === null || response === void 0 ? void 0 : response.currentUser) === null || _g === void 0 ? void 0 : _g.termsUrl,
19938
+ entityId: (_h = response === null || response === void 0 ? void 0 : response.currentUser) === null || _h === void 0 ? void 0 : _h.entityId,
19939
+ };
19940
+ };
19941
+
19942
+ const useCurrentUserData = (token) => {
19943
+ const { apiHost } = react.useContext(BunnyContext);
19944
+ const { data: currentUserData, isLoading: isCurrentUserDataLoading } = reactQuery.useQuery({
19945
+ queryKey: common.QueryKeyFactory.default.currentUserKey(token),
19946
+ queryFn: () => getCurrentUserData({ token, apiHost }),
19947
+ enabled: Boolean(token),
19948
+ });
19949
+ const currentUser = currentUserData || {};
19950
+ return { currentUser, isCurrentUserDataLoading };
19951
+ };
19952
+
19953
+ function usePayableCurrency({ payableCurrencyId }) {
19954
+ const token = useToken();
19955
+ const { currentUser, isCurrentUserDataLoading } = useCurrentUserData(token);
19956
+ const account = currentUser === null || currentUser === void 0 ? void 0 : currentUser.account;
19957
+ const accountCurrencyId = account === null || account === void 0 ? void 0 : account.currencyId;
19958
+ const currencyId = react.useMemo(() => { var _a; return (_a = (accountCurrencyId || payableCurrencyId)) === null || _a === void 0 ? void 0 : _a.toLowerCase(); }, [accountCurrencyId, payableCurrencyId]);
19959
+ return { currencyId, isCurrencyIdLoading: isCurrentUserDataLoading };
19960
+ }
19961
+
19962
+ function useRemovePaymentMethod(onRemovePaymentMethod, onError) {
19638
19963
  const queryClient = reactQuery.useQueryClient();
19639
19964
  const showErrorNotification = common.useErrorNotification();
19640
19965
  const showSuccessNotification = common.useSuccessNotification();
19966
+ const accountId = useAccountId();
19967
+ const { paymentPlugins } = usePaymentPlugins(accountId);
19968
+ const token = useToken();
19969
+ const { apiHost } = react.useContext(BunnyContext);
19641
19970
  const removePaymentMethod = react.useCallback(async (data) => {
19642
19971
  const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === ((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
19643
19972
  if (data && plugin) {
19644
19973
  await common.invokePlugin({
19645
- plugin,
19974
+ plugin: plugin, // TODO: type the plugin
19646
19975
  method: 'remove_payment_method',
19647
19976
  payload: {
19648
19977
  payment_method_id: data.id,
@@ -19666,34 +19995,48 @@ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId, onRem
19666
19995
  });
19667
19996
  }
19668
19997
  else {
19669
- const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name; });
19998
+ const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin) => { var _a, _b, _c; return (_c = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name; });
19670
19999
  onError === null || onError === void 0 ? void 0 : onError(`Either the payment method was not found or the plugin was not present. Available plugins: ${availablePlugins === null || availablePlugins === void 0 ? void 0 : availablePlugins.join(', ')}`);
19671
20000
  }
19672
20001
  }, [paymentPlugins, token, apiHost, queryClient]);
19673
20002
  return removePaymentMethod;
19674
20003
  }
19675
20004
 
19676
- function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId, onError, onSuccess) {
19677
- const queryClient = reactQuery.useQueryClient();
20005
+ function useSetDefaultPaymentMethod(onError, onSuccess) {
20006
+ // Context
20007
+ const accountId = useAccountId();
20008
+ const token = useToken();
20009
+ const { apiHost } = react.useContext(BunnyContext);
20010
+ const { paymentPlugins } = usePaymentPlugins(accountId);
20011
+ const { paymentMethods } = usePaymentMethod({ accountId });
20012
+ // Hooks
19678
20013
  const showErrorNotification = common.useErrorNotification();
19679
20014
  const showSuccessNotification = common.useSuccessNotification();
20015
+ const queryClient = reactQuery.useQueryClient();
20016
+ // State
19680
20017
  const [loading, setLoading] = react.useState(false);
19681
- const setDefaultPaymentMethod = react.useCallback(async (data) => {
19682
- const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === ((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
19683
- if (data && plugin) {
20018
+ const setDefaultPaymentMethod = react.useCallback(async (paymentMethodId) => {
20019
+ const paymentMethod = paymentMethods === null || paymentMethods === void 0 ? void 0 : paymentMethods.find(paymentMethod => (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id) === paymentMethodId);
20020
+ if (paymentMethod === undefined) {
20021
+ showErrorNotification('Payment method not found', 'Error setting default payment method');
20022
+ return;
20023
+ }
20024
+ const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === ((_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.plugin) === null || _a === void 0 ? void 0 : _a.id); }); // TODO: type the response to PluginData
20025
+ if (plugin) {
19684
20026
  setLoading(true);
19685
20027
  await common.invokePlugin({
19686
- plugin,
20028
+ plugin: plugin,
19687
20029
  method: 'assign_default_payment_method',
19688
20030
  payload: {
19689
- payment_method_id: data.id,
20031
+ payment_method_id: paymentMethod.id,
19690
20032
  account_id: accountId,
19691
20033
  },
19692
20034
  token,
19693
20035
  apiHost,
19694
20036
  })
19695
20037
  .then(() => {
19696
- showSuccessNotification(`Payment method ${data.metadata.identifier} was set as default`, 'Success');
20038
+ var _a;
20039
+ showSuccessNotification(`Payment method ${(_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.metadata) === null || _a === void 0 ? void 0 : _a.identifier} was set as default`, 'Success');
19697
20040
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
19698
20041
  queryClient.invalidateQueries({
19699
20042
  queryKey: common.QueryKeyFactory.default.accountPaymentMethodsKey({
@@ -19711,7 +20054,7 @@ function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId, o
19711
20054
  });
19712
20055
  }
19713
20056
  else {
19714
- const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name; });
20057
+ const availablePlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.map((plugin) => { var _a, _b, _c; return (_c = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name; });
19715
20058
  onError === null || onError === void 0 ? void 0 : onError(`Either the payment method was not found or the plugin was not present. Available plugins: ${availablePlugins === null || availablePlugins === void 0 ? void 0 : availablePlugins.join(', ')}`);
19716
20059
  }
19717
20060
  }, [paymentPlugins, token, apiHost, queryClient]);
@@ -19719,83 +20062,53 @@ function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId, o
19719
20062
  }
19720
20063
 
19721
20064
  const showErrorNotification$4 = common.useErrorNotification();
19722
- const PaymentForm = ({ invoice, onFail, onPaymentSuccess, onPaymentHoldSuccess, quote, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }) => {
19723
- // Local state
19724
- const [showPaymentMethodForm, setShowPaymentMethodForm] = react.useState(false);
19725
- // Simple hooks
19726
- const queryClient = reactQuery.useQueryClient();
19727
- const { apiHost } = react.useContext(BunnyContext);
19728
- const tokenFromContexts = useToken();
19729
- const token = overrideToken || tokenFromContexts;
19730
- const { paymentMethods: storedPaymentMethods, defaultPaymentMethod, isLoading: isPaymentMethodLoading, } = usePaymentMethod({
19731
- accountId,
19732
- token,
19733
- apiHost,
19734
- });
19735
- // Complex hooks
19736
- const { paymentPlugins } = usePaymentPlugins({ apiHost, token, accountId });
19737
- const selectedPaymentMethodPlugin = react.useMemo(() => {
19738
- // TODO: consolate PluginData and PaymentPlugin into one type. Needs to be done on API side.
19739
- return paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find((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()); });
19740
- }, [paymentPlugins, defaultPaymentMethod]);
19741
- // Derived state
19742
- const defaultPaymentMethodPlugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find((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()); });
19743
- const paying = Boolean(quote || invoice);
19744
- const { currencyId, isCurrencyIdLoading } = usePaymentFormCurrencyId({
19745
- quote,
19746
- invoice,
20065
+ function PaymentForm({ invoice, quote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }) {
20066
+ const { currencyId, isCurrencyIdLoading } = usePayableCurrency({
20067
+ payableCurrencyId: (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId),
19747
20068
  });
19748
- const paymentRequired = quote ? getQuoteAmountDue(quote) > 0 : true;
20069
+ // Return early because PaymentForm should not be rendered without a valid currency ID.
20070
+ // For example, sepa / iDeal may not show for Dutch customer if no currencyId
20071
+ if (isCurrencyIdLoading) {
20072
+ return null;
20073
+ }
20074
+ if (!currencyId) {
20075
+ return jsxRuntime.jsx("div", { children: "PaymentForm error: No currency ID found from Quote or Invoice or props." });
20076
+ }
20077
+ // Wrap providers around the children
20078
+ const providers = [
20079
+ [ShowPaymentDetailsProvider, { value: undefined }],
20080
+ [CustomCheckoutFunctionProvider, { value: customCheckoutFunction }],
20081
+ ];
20082
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: providers.reduceRight((acc, [Provider, props]) => react.createElement(Provider, props, acc), jsxRuntime.jsx(OverrideTokenContext.Provider, { value: { overrideToken }, children: jsxRuntime.jsx(SelectedPluginProvider, { accountId: accountId, children: jsxRuntime.jsx(StripeWrapper, { currencyId: currencyId, accountId: accountId, children: jsxRuntime.jsx(PaymentProvider, { quote: quote, invoice: invoice, accountId: accountId, onPaymentHoldSuccess: onPaymentHoldSuccess, onPaymentSuccess: onPaymentSuccess, paymentHoldOptions: paymentHoldOptions !== null && paymentHoldOptions !== void 0 ? paymentHoldOptions : {}, onSavePaymentMethod: onSavePaymentMethod, children: jsxRuntime.jsx(PaymentFormContent, { onRemovePaymentMethod: onRemovePaymentMethod, onSetDefaultPaymentMethod: onSetDefaultPaymentMethod }) }) }) }) })) }));
20083
+ }
20084
+ function PaymentFormContent({ onRemovePaymentMethod, onSetDefaultPaymentMethod, }) {
20085
+ // Context
20086
+ const [showPaymentMethodForm, setShowPaymentMethodForm] = useShowPaymentDetails();
20087
+ const paymentType = usePaymentType();
20088
+ const isPaying = useIsPaying();
20089
+ const amountDue = useAmountDue();
20090
+ const selectedPlugin = useSelectedPlugin();
20091
+ const onPaymentFormSubmit = useHandlePaymentFormSubmit();
20092
+ const accountId = useAccountId();
20093
+ // Hooks
20094
+ const { paymentPlugins } = usePaymentPlugins(accountId);
20095
+ const { paymentMethods: maskedPaymentMethods, isLoading: isPaymentMethodLoading } = usePaymentMethod({ accountId });
20096
+ // Read fragments
20097
+ const paymentMethods = react.useMemo(() => maskedPaymentMethods === null || maskedPaymentMethods === void 0 ? void 0 : maskedPaymentMethods.map(paymentMethod => readFragment(PaymentForm_PaymentMethodsFragment, paymentMethod)), [maskedPaymentMethods]);
19749
20098
  // Custom hooks
19750
- const { setDefaultPaymentMethod: handleSetDefault, loading: setDefaultPaymentMethodLoading } = useSetDefaultPaymentMethod(paymentPlugins || [], apiHost, token, accountId, message => {
20099
+ const { setDefaultPaymentMethod: handleSetDefault, loading: setDefaultPaymentMethodLoading } = useSetDefaultPaymentMethod(message => {
19751
20100
  showErrorNotification$4(message, 'Error setting default payment method');
19752
20101
  }, () => {
19753
20102
  onSetDefaultPaymentMethod === null || onSetDefaultPaymentMethod === void 0 ? void 0 : onSetDefaultPaymentMethod();
19754
20103
  });
19755
20104
  useAutoSetDefaultPaymentMethod({
19756
- accountId,
19757
- token,
19758
20105
  handleSetDefault,
19759
20106
  setDefaultPaymentMethodLoading,
19760
20107
  enabled: !!paymentPlugins,
19761
20108
  });
19762
- const { selectorPaymentMethodPlugin, setSelectorPaymentMethodPlugin } = usePaymentMethodSelectorPlugin({
19763
- defaultPaymentMethod,
19764
- defaultPaymentMethodPlugin,
19765
- paymentMethodAllowedPlugins: paymentPlugins || [],
19766
- });
19767
- // Mutations
19768
- const { mutate: checkoutNoPayment, isPending: isCheckingOutNoPayment } = reactQuery.useMutation({
19769
- mutationFn: async () => {
19770
- if (!quote)
19771
- throw new Error('Quote is required');
19772
- if (paymentRequired)
19773
- throw new Error('Payment is required');
19774
- return await checkout({ quoteId: quote.id, token, apiHost });
19775
- },
19776
- onSuccess: () => {
19777
- handlePaymentSuccess();
19778
- },
19779
- onError: onFail,
19780
- });
19781
- const onClickRemove = useRemovePaymentMethod(paymentPlugins || [], apiHost, token, accountId, onRemovePaymentMethod, message => {
20109
+ const onClickRemove = useRemovePaymentMethod(onRemovePaymentMethod, message => {
19782
20110
  showErrorNotification$4(message, 'Error removing payment method');
19783
20111
  });
19784
- const handlePaymentSuccess = () => {
19785
- // Hide payment method selector and form
19786
- setShowPaymentMethodForm(false);
19787
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess();
19788
- };
19789
- const handleSavePaymentMethod = (response) => {
19790
- queryClient.invalidateQueries({
19791
- queryKey: common.QueryKeyFactory.default.accountPaymentMethodsKey({
19792
- accountId,
19793
- token,
19794
- }),
19795
- });
19796
- onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(response);
19797
- setShowPaymentMethodForm(false);
19798
- };
19799
20112
  function handleClickAddPaymentMethod() {
19800
20113
  if ((paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.length) === 0) {
19801
20114
  showErrorNotification$4('No payment plugins available', 'Error adding payment method');
@@ -19806,45 +20119,21 @@ const PaymentForm = ({ invoice, onFail, onPaymentSuccess, onPaymentHoldSuccess,
19806
20119
  }
19807
20120
  // Automatically show the payment method form if there are no payment methods
19808
20121
  react.useEffect(() => {
19809
- if ((storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) === 0) {
20122
+ if ((paymentMethods === null || paymentMethods === void 0 ? void 0 : paymentMethods.length) === 0) {
19810
20123
  setShowPaymentMethodForm(true);
19811
20124
  }
19812
- }, [storedPaymentMethods]);
19813
- if (isPaymentMethodLoading || isCurrencyIdLoading) {
20125
+ }, [paymentMethods]);
20126
+ if (isPaymentMethodLoading) {
19814
20127
  return jsxRuntime.jsx(antd.Skeleton, { active: true, className: "bunny-p-4" });
19815
20128
  }
19816
- // Return early because it is a bug if PaymentForm is rendered without a currency ID.
19817
- // For example, sepa / iDeal may not show for dutch customer if no currencyId
19818
- if (!currencyId) {
19819
- return jsxRuntime.jsx("div", { children: "PaymentForm error: No currency ID found from Quote or Invoice or props." });
19820
- }
19821
- return (jsxRuntime.jsx(PaymentContext.Provider, { value: {
19822
- onClickCancel: () => setShowPaymentMethodForm(false),
19823
- accountId,
19824
- overrideToken,
19825
- storedPaymentMethods,
19826
- defaultPaymentMethod,
19827
- customCheckoutFunction,
19828
- }, children: jsxRuntime.jsx(StripeWrapper, { plugin: selectorPaymentMethodPlugin, token: token, apiHost: apiHost, currencyId: currencyId, accountId: accountId, children: jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-0 bunny-w-full", children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-px-4", children: [storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.map(paymentMethod => (jsxRuntime.jsx(MiniCreditCard, { onClickRemove: () => onClickRemove(paymentMethod), onClickSetDefault: () => handleSetDefault(paymentMethod), paymentMethodData: paymentMethod, id: `payment-method-${paymentMethod.id}` }, paymentMethod.id))), (storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) === 0 && (jsxRuntime.jsx(MiniCreditCard, { onClickRemove: () => { }, onClickSetDefault: () => { } }))] }), jsxRuntime.jsx(antd.Collapse, { bordered: false, activeKey: showPaymentMethodForm ? '1' : undefined, ghost: true, collapsible: "disabled", destroyOnHidden: true, items: [
19829
- {
19830
- key: '1',
19831
- showArrow: false,
19832
- label: !showPaymentMethodForm ? (jsxRuntime.jsx("div", { className: "bunny-pt-2", children: jsxRuntime.jsx(antd.Button, { onClick: handleClickAddPaymentMethod, type: "default", className: "bunny-w-full", id: "addPaymentMethod", children: "Add payment method" }) })) : null,
19833
- children: (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-mt-2", children: [jsxRuntime.jsx(PaymentMethodSelector, { onSelect: setSelectorPaymentMethodPlugin, paymentMethodAllowedPlugins: paymentPlugins || [], value: selectorPaymentMethodPlugin }), selectorPaymentMethodPlugin && (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col", children: jsxRuntime.jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, plugin: selectorPaymentMethodPlugin }) }))] })),
19834
- },
19835
- ] }), paying && defaultPaymentMethod && (jsxRuntime.jsx("div", { className: "bunny-px-4", children: jsxRuntime.jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethodPlugin, onPaymentHoldSuccess: onPaymentHoldSuccess, paymentHoldOptions: paymentHoldOptions }) }))] })) : (jsxRuntime.jsx(antd.Button, { style: { margin: '0 16px' }, loading: isCheckingOutNoPayment, onClick: () => checkoutNoPayment(), type: "primary", children: isCheckingOutNoPayment ? 'Processing...' : 'Complete Order' })) }) }) }) }));
19836
- };
19837
- function StripeWrapper({ children, plugin, token, apiHost, currencyId, accountId, }) {
19838
- const { stripe, options } = useStripePlugin(plugin, apiHost, currencyId || 'usd', token, accountId);
19839
- return (jsxRuntime.jsx(reactStripeJs.Elements, { options: options, stripe: stripe, children: children }));
19840
- }
19841
- function usePaymentFormCurrencyId({ quote, invoice, }) {
19842
- const token = useToken();
19843
- const { currentUser, isCurrentUserDataLoading } = useCurrentUserData(token);
19844
- const account = currentUser === null || currentUser === void 0 ? void 0 : currentUser.account;
19845
- const accountCurrencyId = account === null || account === void 0 ? void 0 : account.currencyId;
19846
- const currencyId = react.useMemo(() => { var _a; return (_a = (accountCurrencyId || (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId))) === null || _a === void 0 ? void 0 : _a.toLowerCase(); }, [accountCurrencyId, quote === null || quote === void 0 ? void 0 : quote.currencyId, invoice === null || invoice === void 0 ? void 0 : invoice.currencyId]);
19847
- return { currencyId, isCurrencyIdLoading: isCurrentUserDataLoading };
20129
+ return (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-0 bunny-w-full", children: paymentType === PaymentType.PAY || paymentType === PaymentType.APPROVE_HOLD ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-px-4", children: [paymentMethods === null || paymentMethods === void 0 ? void 0 : paymentMethods.map(paymentMethod => (jsxRuntime.jsx(MiniCreditCard, { onClickRemove: () => onClickRemove(paymentMethod), onClickSetDefault: () => handleSetDefault(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id), paymentMethod: paymentMethod, id: `payment-method-${paymentMethod.id}` }, paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id))), (paymentMethods === null || paymentMethods === void 0 ? void 0 : paymentMethods.length) === 0 && jsxRuntime.jsx(MiniCreditCard, {})] }), jsxRuntime.jsx(antd.Collapse, { bordered: false, activeKey: showPaymentMethodForm ? '1' : undefined, ghost: true, collapsible: "disabled", destroyOnHidden: true, items: [
20130
+ {
20131
+ key: '1',
20132
+ showArrow: false,
20133
+ label: !showPaymentMethodForm ? (jsxRuntime.jsx("div", { className: "bunny-pt-2", children: jsxRuntime.jsx(antd.Button, { onClick: handleClickAddPaymentMethod, type: "default", className: "bunny-w-full", id: "addPaymentMethod", children: "Add payment method" }) })) : null,
20134
+ children: (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-mt-2", children: [jsxRuntime.jsx(PaymentMethodSelector, {}), selectedPlugin && (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col", children: jsxRuntime.jsx(PaymentMethodDetails, {}) }))] })),
20135
+ },
20136
+ ] }), amountDue !== undefined && !showPaymentMethodForm && (jsxRuntime.jsx("div", { className: "bunny-px-4", children: jsxRuntime.jsx(CheckoutFooter, {}) }))] })) : (jsxRuntime.jsx(antd.Button, { style: { margin: '0 16px' }, loading: isPaying, onClick: () => onPaymentFormSubmit(), type: "primary", children: isPaying ? 'Processing...' : 'Complete Order' })) }));
19848
20137
  }
19849
20138
 
19850
20139
  function Invoice({ id, invoiceQuoteViewComponent, backButtonName, onBackButtonClick, onInvoiceDownloadError, onPaymentSuccess, shadow = 'shadow-md', className, hideDownloadButton = false, hidePaymentForm = false, onInvoiceLoaded, }) {
@@ -19865,12 +20154,11 @@ function ActualInvoice({ hidePaymentForm }) {
19865
20154
  // Context
19866
20155
  const queryClient = reactQuery.useQueryClient();
19867
20156
  const { id, invoiceQuoteViewComponent, backButtonName, onBackButtonClick, onPaymentSuccess, className, } = react.useContext(InvoiceQuoteContext);
19868
- const { apiHost, onTokenExpired } = react.useContext(BunnyContext);
20157
+ const { apiHost } = react.useContext(BunnyContext);
19869
20158
  const { hideDownloadButton, onInvoiceLoaded } = react.useContext(InvoiceQuoteContext);
19870
20159
  const token = useToken();
19871
20160
  // Hooks
19872
20161
  const showSuccessNotification = common.useSuccessNotification();
19873
- const handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
19874
20162
  // Queries
19875
20163
  const { data: formattedInvoice } = reactQuery.useQuery({
19876
20164
  queryKey: common.QueryKeyFactory.default.createFormattedInvoiceKey({ id, token }),
@@ -19893,9 +20181,6 @@ function ActualInvoice({ hidePaymentForm }) {
19893
20181
  showSuccessNotification('Your invoice has been paid', 'Payment successful');
19894
20182
  onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess();
19895
20183
  };
19896
- const onFail = (error) => {
19897
- handleAllErrorFormats(error.message);
19898
- };
19899
20184
  react.useEffect(() => {
19900
20185
  if (formattedInvoice) {
19901
20186
  onInvoiceLoaded === null || onInvoiceLoaded === void 0 ? void 0 : onInvoiceLoaded(formattedInvoice);
@@ -19903,7 +20188,7 @@ function ActualInvoice({ hidePaymentForm }) {
19903
20188
  }, [formattedInvoice]);
19904
20189
  if (!formattedInvoice)
19905
20190
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
19906
- return (jsxRuntime.jsx("div", { className: "bunny-invoice-container", children: jsxRuntime.jsxs("div", { className: `bunny-flex bunny-gap-6 ${isMobile ? 'bunny-flex-col bunny-w-full' : ''} ${className}`, children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", { 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 && !hidePaymentForm && (jsxRuntime.jsx("div", { className: `bunny-w-full ${hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12'}`, children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) }))] }) }));
20191
+ return (jsxRuntime.jsx("div", { className: "bunny-invoice-container", children: jsxRuntime.jsxs("div", { className: `bunny-flex bunny-gap-6 ${isMobile ? 'bunny-flex-col bunny-w-full' : ''} ${className}`, children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", { 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 && !hidePaymentForm && (jsxRuntime.jsx("div", { className: `bunny-w-full ${hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12'}`, children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, invoice: formattedInvoice }) }))] }) }));
19907
20192
  }
19908
20193
 
19909
20194
  const MUTATION$8 = () => `
@@ -20221,8 +20506,53 @@ const useSigningComplete = ({ data, token }) => {
20221
20506
  }, [data, eventParam, queryClient, token]);
20222
20507
  };
20223
20508
 
20509
+ var dayjs_min$1 = {exports: {}};
20510
+
20511
+ var dayjs_min = dayjs_min$1.exports;
20512
+
20513
+ var hasRequiredDayjs_min;
20514
+
20515
+ function requireDayjs_min () {
20516
+ if (hasRequiredDayjs_min) return dayjs_min$1.exports;
20517
+ hasRequiredDayjs_min = 1;
20518
+ (function (module, exports) {
20519
+ !function(t,e){module.exports=e();}(dayjs_min,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
20520
+ } (dayjs_min$1));
20521
+ return dayjs_min$1.exports;
20522
+ }
20523
+
20524
+ var dayjs_minExports = requireDayjs_min();
20525
+ var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
20526
+
20224
20527
  const useIsExpired = (expiresAt) => dayjs(expiresAt).diff(dayjs(dayjs().format("YYYY-MM-DD"))) < 0;
20225
20528
 
20529
+ const tagStyleMap = {
20530
+ blue: { color: 'var(--bunny-blue-500)', background: 'var(--bunny-blue-200)' },
20531
+ green: {
20532
+ color: 'var(--bunny-green-600)',
20533
+ background: 'var(--bunny-green-200)',
20534
+ },
20535
+ red: { color: 'var(--bunny-red-500)', background: 'var(--bunny-red-200)' },
20536
+ orange: {
20537
+ color: 'var(--bunny-orange-500)',
20538
+ background: 'var(--bunny-orange-200)',
20539
+ },
20540
+ yellow: {
20541
+ color: 'var(--bunny-yellow-500)',
20542
+ background: 'var(--bunny-yellow-200)',
20543
+ },
20544
+ purple: {
20545
+ color: 'var(--bunny-purple-500)',
20546
+ background: 'var(--bunny-purple-200)',
20547
+ },
20548
+ black: { color: 'white', background: 'var(--bunny-black)' },
20549
+ };
20550
+ // This component provides custom styling for antd Tag components without using antd overwrites.
20551
+ // Please use this component instead of the antd Tag component directly to maintain consistent styling.
20552
+ const CustomizedTag = ({ children, color, className, style, }) => {
20553
+ return (jsxRuntime.jsx(antd.Tag, { color: color, style: { ...(color ? tagStyleMap[color] : undefined), ...style }, className: `bunny-m-0 bunny-rounded-full bunny-border-none bunny-whitespace-nowrap ${className}`, children: children }));
20554
+ };
20555
+
20226
20556
  const POLLING_INTERVAL = 2000;
20227
20557
  const PandadocPollingModal = ({ isVisible, setVisible, id }) => {
20228
20558
  const { apiHost, onTokenExpired } = react.useContext(BunnyContext);
@@ -20341,15 +20671,13 @@ const PaymentHoldModal = ({ visible, setVisible, quote, }) => {
20341
20671
  const token = useToken();
20342
20672
  return (jsxRuntime.jsxs(StyledModal$2, { centered: true, onCancel: () => {
20343
20673
  setVisible(false);
20344
- }, footer: null, open: visible, width: 600, children: [jsxRuntime.jsxs("div", { className: "bunny-mt-5 bunny-pb-4 bunny-mx-4", children: [jsxRuntime.jsx(Title$2, { className: "bunny-mt-0", level: 5, children: "Pay to accept" }), jsxRuntime.jsxs(Text$w, { className: "bunny-bt-2 bunny-text-sm/5 bunny-text-gray-500", children: ["To accept this quote, approve a payment hold for", ' ', common.formatCurrency(quote.amount, quote.currency), ". This amount will be charged to your payment method once the quote is signed."] })] }), jsxRuntime.jsx("div", { className: "bunny-mb-3", children: jsxRuntime.jsx(PaymentForm, { quote: {
20674
+ }, footer: null, open: visible, width: 600, children: [jsxRuntime.jsxs("div", { className: "bunny-mt-5 bunny-pb-4 bunny-mx-4", children: [jsxRuntime.jsx(Title$2, { className: "bunny-mt-0", level: 5, children: "Pay now" }), jsxRuntime.jsxs(Text$w, { className: "bunny-bt-2 bunny-text-sm/5 bunny-text-gray-500", children: ["To accept this quote, approve a payment hold for", ' ', common.formatCurrency(quote.amount, quote.currency), ". This amount will be charged to your payment method once the quote is signed."] })] }), jsxRuntime.jsx("div", { className: "bunny-mb-3", children: jsxRuntime.jsx(PaymentForm, { quote: {
20345
20675
  amount: quote.amount,
20346
20676
  currencyId: quote.currency,
20347
20677
  id: quote.quote.id,
20348
20678
  }, paymentHoldOptions: {
20349
20679
  payToAccept: true,
20350
20680
  amountToHold: quote.amount,
20351
- }, onFail: () => {
20352
- setVisible(false);
20353
20681
  }, onPaymentSuccess: () => {
20354
20682
  setVisible(false);
20355
20683
  }, onPaymentHoldSuccess: () => {
@@ -20485,7 +20813,7 @@ function QuoteButtons({ isAccepted, formattedQuote, isMobile, hideDownloadButton
20485
20813
  const signingPlugins = useSigningPlugins({ apiHost, token });
20486
20814
  return (jsxRuntime.jsxs("div", { className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
20487
20815
  color: secondaryColor,
20488
- }, children: [isAccepted && formattedQuote.acceptedAt ? (jsxRuntime.jsx(Text$v, { children: `Quote was accepted by ${formattedQuote.acceptedByName} on ${common.formatDate(formattedQuote.acceptedAt)}` })) : null, (!isMobile || !isAccepted) && (jsxRuntime.jsxs("div", { className: isMobile ? 'flex w-full justify-end gap-2' : 'flex items-center justify-end gap-2', children: [paymentHold ? (jsxRuntime.jsx(PaymentHoldDisplay, { paymentHold: paymentHold, currency: formattedQuote.currency, amount: formattedQuote.amount })) : null, !isMobile && !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, { icon: jsxRuntime.jsx(icons.DownloadOutlined, {}), onClick: () => downloadFile(apiHost + '/api/pdf/quote', token), children: "Download" })) : null, shouldDoPaymentHold && !paymentHoldCompleted ? (jsxRuntime.jsx(antd.Button, { disabled: isExpired, onClick: () => setPaymentHoldModalVisible(true), type: "primary", children: "Pay to accept" })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !isAccepted ? (jsxRuntime.jsx(antd.Button, { disabled: isExpired || isAccepting, onClick: handleClickAccept, type: "primary", children: isExpired
20816
+ }, children: [isAccepted && formattedQuote.acceptedAt ? (jsxRuntime.jsx(Text$v, { children: `Quote was accepted by ${formattedQuote.acceptedByName} on ${common.formatDate(formattedQuote.acceptedAt)}` })) : null, (!isMobile || !isAccepted) && (jsxRuntime.jsxs("div", { className: isMobile ? 'flex w-full justify-end gap-2' : 'flex items-center justify-end gap-2', children: [paymentHold ? (jsxRuntime.jsx(PaymentHoldDisplay, { paymentHold: paymentHold, currency: formattedQuote.currency, amount: formattedQuote.amount })) : null, !isMobile && !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, { icon: jsxRuntime.jsx(icons.DownloadOutlined, {}), onClick: () => downloadFile(apiHost + '/api/pdf/quote', token), children: "Download" })) : null, shouldDoPaymentHold && !paymentHoldCompleted ? (jsxRuntime.jsx(antd.Button, { disabled: isExpired, onClick: () => setPaymentHoldModalVisible(true), type: "primary", children: "Pay now" })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !isAccepted ? (jsxRuntime.jsx(antd.Button, { disabled: isExpired || isAccepting, onClick: handleClickAccept, type: "primary", children: isExpired
20489
20817
  ? 'Quote is expired'
20490
20818
  : (signingPlugins === null || signingPlugins === void 0 ? void 0 : signingPlugins.length)
20491
20819
  ? 'Start signing'
@@ -20961,6 +21289,14 @@ function QuotesWrapper() {
20961
21289
  return (jsxRuntime.jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search }));
20962
21290
  }
20963
21291
 
21292
+ const useHasTaxPlugin = ({ apiHost, token, }) => {
21293
+ const { data: plugins } = usePlugins({
21294
+ apiHost,
21295
+ token,
21296
+ });
21297
+ return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some((plugin) => plugin.type === "taxation"));
21298
+ };
21299
+
20964
21300
  const MUTATION$7 = () => `
20965
21301
  mutation AccountSignup (
20966
21302
  $pluginId: String!,
@@ -21304,14 +21640,6 @@ const getTaxationRequiredAccountFields = async ({ apiHost, token, }) => {
21304
21640
  : null;
21305
21641
  };
21306
21642
 
21307
- const useHasTaxPlugin = ({ apiHost, token, }) => {
21308
- const { data: plugins } = usePlugins({
21309
- apiHost,
21310
- token,
21311
- });
21312
- return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some((plugin) => plugin.type === "taxation"));
21313
- };
21314
-
21315
21643
  const BunnyFooterIcon = ({ color }) => {
21316
21644
  return (jsxRuntime.jsxs("svg", { width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsxs("g", { 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", { id: "clip0_6_851", children: jsxRuntime.jsx("rect", { width: "39", height: "13", fill: "white" }) }) })] }));
21317
21645
  };
@@ -21466,21 +21794,10 @@ const useUpdateCoupons = ({ apiHost, token, quoteChangeId, onCouponAdded, onCoup
21466
21794
  };
21467
21795
  };
21468
21796
 
21469
- var SubscriptionState;
21470
- (function (SubscriptionState) {
21471
- SubscriptionState["ACTIVE"] = "ACTIVE";
21472
- SubscriptionState["TRIAL"] = "TRIAL";
21473
- SubscriptionState["PENDING"] = "PENDING";
21474
- SubscriptionState["EXPIRED"] = "EXPIRED";
21475
- SubscriptionState["CANCELED"] = "CANCELED";
21476
- SubscriptionState["TRIAL_EXPIRED"] = "TRIAL_EXPIRED";
21477
- })(SubscriptionState || (SubscriptionState = {}));
21478
- var SubscriptionState$1 = SubscriptionState;
21479
-
21480
21797
  function shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) {
21481
21798
  var _a, _b;
21482
- const upgradingFromTrial = ((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$1.TRIAL ||
21483
- ((_b = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$1.TRIAL_EXPIRED;
21799
+ const upgradingFromTrial = ((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL') ||
21800
+ ((_b = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED');
21484
21801
  function upgradingFromFree() {
21485
21802
  const totalPrice = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.charges.reduce((acc, charge) => acc + Number((charge === null || charge === void 0 ? void 0 : charge.discountedPrice) || 0), 0);
21486
21803
  return totalPrice === 0;
@@ -21722,7 +22039,7 @@ const QuoteCheckout = ({ account, onSuccess, onFail, quote: maskedQuote, taxatio
21722
22039
  }
21723
22040
  if (taxationRequiredAccountFields)
21724
22041
  return (jsxRuntime.jsx(PaymentFormWrapper, { setMaxHeight: false, children: jsxRuntime.jsx(TaxationForm, { account: account, accountId: quote.accountId }) }));
21725
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsxs("div", { 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 &&
22042
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-w-full", children: [jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, quote: quote }), (couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.length) === 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: upgradingSubscription &&
21726
22043
  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, { type: "link", loading: isRemovingCoupon, onClick: () => {
21727
22044
  couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.forEach(couponCharge => {
21728
22045
  var _a;
@@ -21824,15 +22141,13 @@ const Checkout = ({ onCancel, onSuccess, onFail, invoice, open, quote: maskedQuo
21824
22141
  return (jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-col bunny-fixed bunny-top-0 bunny-left-0 bunny-right-0 bunny-bottom-0 bunny-bg-slate-50
21825
22142
  bunny-overflow-auto bunny-height-full`, style: {
21826
22143
  zIndex: 1001,
21827
- }, children: jsxRuntime.jsxs("div", { className: `bunny-flex bunny-flex-col bunny-grow bunny-pt-4 ${isMobile ? 'bunny-pb-4' : 'bunny-pb-8'} bunny-content-container`, children: [jsxRuntime.jsx("div", { className: "bunny-flex bunny-justify-end bunny-w-full bunny-pr-4", children: jsxRuntime.jsx(icons.CloseOutlined, { className: "bunny-text-base bunny-shadow-padding-xb", onClick: onCancel }) }), jsxRuntime.jsxs("div", { className: `bunny-flex bunny-justify-end bunny-pt-4 bunny-gap-4 ${isMobile ? 'bunny-flex-col' : 'bunny-shadow-padding-xb'}`, children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsxRuntime.jsx(InvoiceQuoteView, { html: invoice ? invoice.html : (_d = (_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html) !== null && _d !== void 0 ? _d : '' })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_e = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _e === void 0 ? void 0 : _e.html)) && (jsxRuntime.jsx(antd.Divider, { className: "bunny-h-full", type: "vertical" })), invoice ? (jsxRuntime.jsx("div", { className: "bunny-w-full bunny-pt-12", children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: invoice }) })) : quote ? (jsxRuntime.jsx(QuoteCheckout, { account: account, onFail: error => {
22144
+ }, children: jsxRuntime.jsxs("div", { className: `bunny-flex bunny-flex-col bunny-grow bunny-pt-4 ${isMobile ? 'bunny-pb-4' : 'bunny-pb-8'} bunny-content-container`, children: [jsxRuntime.jsx("div", { className: "bunny-flex bunny-justify-end bunny-w-full bunny-pr-4", children: jsxRuntime.jsx(icons.CloseOutlined, { className: "bunny-text-base bunny-shadow-padding-xb", onClick: onCancel }) }), jsxRuntime.jsxs("div", { className: `bunny-flex bunny-justify-end bunny-pt-4 bunny-gap-4 ${isMobile ? 'bunny-flex-col' : 'bunny-shadow-padding-xb'}`, children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsxRuntime.jsx(InvoiceQuoteView, { html: invoice ? invoice.html : (_d = (_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html) !== null && _d !== void 0 ? _d : '' })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_e = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _e === void 0 ? void 0 : _e.html)) && (jsxRuntime.jsx(antd.Divider, { className: "bunny-h-full", type: "vertical" })), invoice ? (jsxRuntime.jsx("div", { className: "bunny-w-full bunny-pt-12", children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, invoice: invoice }) })) : quote ? (jsxRuntime.jsx(QuoteCheckout, { account: account, onFail: error => {
21828
22145
  onFail(error);
21829
22146
  }, onSuccess: onSuccess, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token, onRecalculateTaxes: async () => {
21830
22147
  if (recalculateTaxesEnabled) {
21831
22148
  await recalculateTaxes();
21832
22149
  }
21833
- } })) : (jsxRuntime.jsx(PaymentForm, { onFail: error => {
21834
- onFail(error);
21835
- }, onPaymentSuccess: onSuccess }))] }), jsxRuntime.jsx(Footer, { className: "bunny-px-12" })] }) }));
22150
+ } })) : (jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess }))] }), jsxRuntime.jsx(Footer, { className: "bunny-px-12" })] }) }));
21836
22151
  };
21837
22152
 
21838
22153
  const QuoteContext = react.createContext({});
@@ -21922,29 +22237,29 @@ function hasUnpurchasedAddonPriceLists(maskedPriceListAddonPlans, currentSubscri
21922
22237
 
21923
22238
  const canSubscriptionUpgradeFromTrial = (subscription) => {
21924
22239
  var _a;
21925
- return (((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL &&
22240
+ return (((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL') &&
21926
22241
  subscription.plan.selfServiceBuy) ||
21927
22242
  false;
21928
22243
  };
21929
22244
  const canSubscriptionUpgradeFromTrialExpired = (subscription) => {
21930
22245
  var _a;
21931
- return (((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL_EXPIRED &&
22246
+ return (((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED') &&
21932
22247
  subscription.plan.selfServiceBuy) ||
21933
22248
  false;
21934
22249
  };
21935
22250
  const isSubscriptionNotActive = (subscription) => {
21936
22251
  var _a, _b, _c;
21937
- return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
21938
- ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.CANCELED ||
21939
- ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL_EXPIRED;
22252
+ return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'EXPIRED') ||
22253
+ ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'CANCELED') ||
22254
+ ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED');
21940
22255
  };
21941
22256
  const isSubscriptionActiveOrPending = (subscription) => {
21942
22257
  var _a, _b;
21943
- return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE ||
21944
- ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
22258
+ return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'ACTIVE') ||
22259
+ ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'PENDING');
21945
22260
  };
21946
- const isSubscriptionTrial = (subscription) => { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL; };
21947
- const isSubscriptionTrialExpired = (subscription) => { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL_EXPIRED; };
22261
+ const isSubscriptionTrial = (subscription) => { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL'); };
22262
+ const isSubscriptionTrialExpired = (subscription) => { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED'); };
21948
22263
  // Helper function to check if charge is a discount
21949
22264
  const isDiscount$1 = (kind) => kind === common.QuoteChangeKind.DISCOUNT || kind === common.QuoteChangeKind.FREE_PERIOD_DISCOUNT;
21950
22265
  const hasPriceTiers = (charge) => {
@@ -22053,18 +22368,12 @@ const { Text: Text$m } = antd.Typography;
22053
22368
  const CheckoutBarSummarySection = ({ open, selectedPriceList, onClickCheckout, }) => {
22054
22369
  var _a;
22055
22370
  // Context
22056
- const { apiHost } = react.useContext(BunnyContext);
22057
22371
  const { quote: quoteData, isQuotePending, isUpdatingQuote } = react.useContext(QuoteContext);
22058
22372
  const quote = quoteData;
22059
- const { accountId } = react.useContext(PaymentContext);
22060
22373
  const { upgradingSubscription, isInPreviewMode } = react.useContext(SubscriptionsContext);
22061
22374
  // Hooks
22062
22375
  const token = useToken();
22063
- const { paymentPlugins } = usePaymentPlugins({
22064
- apiHost,
22065
- token,
22066
- accountId,
22067
- });
22376
+ const { paymentPlugins } = usePaymentPlugins(undefined);
22068
22377
  const queryClient = reactQuery.useQueryClient();
22069
22378
  const isMobile = common.useIsMobile();
22070
22379
  // Derived state
@@ -22322,8 +22631,8 @@ const CheckoutSummaryDivider = () => {
22322
22631
  };
22323
22632
 
22324
22633
  const { Title: Title$1 } = antd.Typography;
22325
- function PaymentForms({ quote, handlePaymentSuccess, handlePaymentFail, handleSubmit, proceedingToPayment, accountId, overrideToken, customCheckoutFunction, defaultValues, }) {
22326
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, { className: "bunny-px-4 bunny-m-0", level: 2, children: "Payment" }), jsxRuntime.jsx("div", { 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, { className: "bunny-px-4 bunny-m-0", level: 2, children: "Signup" }), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
22634
+ function PaymentForms({ quote, handlePaymentSuccess, handleSubmit, proceedingToPayment, accountId, overrideToken, customCheckoutFunction, defaultValues, }) {
22635
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, { className: "bunny-px-4 bunny-m-0", level: 2, children: "Payment" }), jsxRuntime.jsx("div", { className: "bunny-overflow-y-auto bunny-max-h-[calc(100vh-10rem)]", children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction }) })] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, { className: "bunny-px-4 bunny-m-0", level: 2, children: "Signup" }), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
22327
22636
  }
22328
22637
  function InitialSignupForm({ className, onSubmit, submitting, defaultValues, }) {
22329
22638
  const [form] = antd.Form.useForm();
@@ -22368,7 +22677,7 @@ const { Text: Text$j } = antd.Typography;
22368
22677
  function PriceListDisplay({ priceListData }) {
22369
22678
  if (!priceListData)
22370
22679
  return null;
22371
- return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-space-y-8", children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: [jsxRuntime.jsxs(Text$j, { className: "bunny-text-slate-500 bunny-font-bold bunny-text-lg", children: [priceListData.product.name, " ", priceListData.name] }), jsxRuntime.jsxs(Text$j, { className: "bunny-font-bold bunny-text-xl", children: [common.formatCurrency(priceListData.basePrice, priceListData.currencyId), " / month"] })] }), priceListData.trialAllowed ? (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col", children: [jsxRuntime.jsxs(Text$j, { style: { fontSize: '16px' }, className: "bunny-text-slate-500", children: [priceListData.trialLengthDays, " day trial"] }), jsxRuntime.jsx(Text$j, { className: "bunny-text-slate-500", style: { fontSize: '12px' }, children: "You will not be charged until the last day of the trial." })] })) : null] }));
22680
+ return (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col bunny-space-y-8", children: jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2", children: [jsxRuntime.jsxs(Text$j, { className: "bunny-text-slate-500 bunny-font-bold bunny-text-lg", children: [priceListData.product.name, " ", priceListData.name] }), jsxRuntime.jsxs(Text$j, { className: "bunny-font-bold bunny-text-xl", children: [common.formatCurrency(priceListData.basePrice, priceListData.currencyId), " / month"] })] }) }));
22372
22681
  }
22373
22682
 
22374
22683
  const showErrorNotification$1 = common.useErrorNotification();
@@ -22395,13 +22704,11 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
22395
22704
  const [purchaseSucceeded, setPurchaseSucceeded] = react.useState(false);
22396
22705
  const defaultCouponAppliedRef = react.useRef(undefined);
22397
22706
  const [couponEditorCouponCode, setCouponEditorCouponCode] = react.useState('');
22398
- const { defaultPaymentMethod } = usePaymentMethod({
22399
- accountId,
22400
- token,
22707
+ const hasTaxPlugin = useHasTaxPlugin({
22401
22708
  apiHost,
22402
- enabled: Boolean(accountId),
22709
+ token,
22403
22710
  });
22404
- const { mutate: recalculateTaxes } = reactQuery.useMutation({
22711
+ const { mutate: recalculateTaxesMutation } = reactQuery.useMutation({
22405
22712
  mutationFn: () => {
22406
22713
  if (!(quote === null || quote === void 0 ? void 0 : quote.id)) {
22407
22714
  throw new Error('Quote ID is required');
@@ -22455,6 +22762,8 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
22455
22762
  }),
22456
22763
  });
22457
22764
  setInitialQuote(data.quote);
22765
+ console.log('handleRecalculateTaxes in quoteAccountSignupMutate');
22766
+ handleRecalculateTaxes();
22458
22767
  },
22459
22768
  onError: (error) => {
22460
22769
  const errorMessage = error.response.errors[0].message;
@@ -22492,7 +22801,7 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
22492
22801
  queryKey: ['quote', quote === null || quote === void 0 ? void 0 : quote.id],
22493
22802
  });
22494
22803
  showSuccessNotification('Coupon applied');
22495
- recalculateTaxes();
22804
+ handleRecalculateTaxes();
22496
22805
  setCouponEditorCouponCode('');
22497
22806
  },
22498
22807
  onCouponRemoved: () => {
@@ -22500,7 +22809,7 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
22500
22809
  queryKey: ['quote', quote === null || quote === void 0 ? void 0 : quote.id],
22501
22810
  });
22502
22811
  showSuccessNotification('Coupon removed');
22503
- recalculateTaxes();
22812
+ handleRecalculateTaxes();
22504
22813
  },
22505
22814
  });
22506
22815
  // Handle default coupon application
@@ -22516,7 +22825,7 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
22516
22825
  async function handlePaymentSuccess() {
22517
22826
  setPurchaseSucceeded(true);
22518
22827
  }
22519
- async function accountSignupFunction(plugin) {
22828
+ async function accountSignupFunction(pluginId, paymentMethodId) {
22520
22829
  var _a;
22521
22830
  if (!portalSessionToken) {
22522
22831
  throw new Error('Portal session token is required');
@@ -22524,37 +22833,30 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
22524
22833
  if (!accountId) {
22525
22834
  throw new Error('Account ID is required');
22526
22835
  }
22527
- if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
22528
- throw new Error('Plugin ID is required');
22529
- }
22530
- if (!(defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id)) {
22531
- throw new Error('Payment method ID is required');
22532
- }
22533
22836
  return await accountSignup({
22534
22837
  token: portalSessionToken,
22535
22838
  apiHost,
22536
22839
  quoteId: (_a = quote === null || quote === void 0 ? void 0 : quote.id) !== null && _a !== void 0 ? _a : undefined,
22537
- paymentMethodId: defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id,
22538
- pluginId: plugin === null || plugin === void 0 ? void 0 : plugin.id.toString(),
22840
+ paymentMethodId,
22841
+ pluginId,
22539
22842
  priceListCode: priceListCode,
22540
22843
  accountId,
22541
22844
  });
22542
22845
  }
22543
- function handlePaymentFail(error) {
22544
- var _a;
22545
- showErrorNotification$1((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.message);
22546
- }
22547
- react.useEffect(() => {
22548
- if (initialQuote === null || initialQuote === void 0 ? void 0 : initialQuote.id) {
22549
- recalculateTaxes();
22846
+ function handleRecalculateTaxes() {
22847
+ console.log('handleRecalculateTaxes', hasTaxPlugin);
22848
+ if (!hasTaxPlugin) {
22849
+ console.log('no tax plugin, returning');
22850
+ return;
22550
22851
  }
22551
- }, [initialQuote === null || initialQuote === void 0 ? void 0 : initialQuote.id]);
22852
+ recalculateTaxesMutation();
22853
+ }
22552
22854
  if (purchaseSucceeded) {
22553
22855
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (quote === null || quote === void 0 ? void 0 : quote.currencyId) !== undefined ? (jsxRuntime.jsx("div", { className: "bunny-w-screen bunny-absolute bunny-top-0 bunny-left-0 bunny-flex bunny-items-start bunny-pt-[25vh]", children: jsxRuntime.jsx(PaymentSuccessDisplay, { amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, className: "bunny-w-full", companyName: companyName, returnUrl: returnUrl, currencyId: quote === null || quote === void 0 ? void 0 : quote.currencyId }) })) : (jsxRuntime.jsx("div", { children: "No currency ID found from Quote" })) }));
22554
22856
  }
22555
22857
  return (jsxRuntime.jsxs("div", { className: `bunny-flex ${isMobile ? 'bunny-flex-col' : 'bunny-flex-row'} bunny-h-screen bunny-w-screen bunny-absolute bunny-top-0 bunny-left-0 ${shadow} ${className}`, style: style, children: [jsxRuntime.jsx("div", { className: `bunny-flex bunny-items-center bunny-flex-col ${isMobile ? 'bunny-w-full bunny-h-1/2' : 'bunny-w-1/2 bunny-h-full'} bunny-justify-center`, children: jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-start bunny-justify-between bunny-w-3/5 bunny-h-full bunny-gap-4 bunny-my-24", children: [jsxRuntime.jsx("div", { children: topNavImageUrl.length > 0 && (jsxRuntime.jsx(antd.Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false })) }), data ? (jsxRuntime.jsx(CheckoutSummary, { quote: data, className: "bunny-h-full bunny-w-full", onAddCoupon: addCoupon, onRemoveCoupon: removeCoupon, isRemovingCoupon: isRemovingCoupon, priceListData: priceListData, isAddingCoupon: isAddingCoupon, couponCode: couponEditorCouponCode, setCouponCode: setCouponEditorCouponCode, activeCouponsExist: activeCouponsExist })) : (jsxRuntime.jsx("div", { className: "bunny-h-full", children: isLoadingPriceList ? (jsxRuntime.jsx(antd.Skeleton, { active: true })) : (jsxRuntime.jsx(PriceListDisplay, { priceListData: priceListData })) })), jsxRuntime.jsx(Footer, {})] }) }), jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-col ${isMobile ? 'bunny-w-full bunny-h-1/2 bunny-overflow-auto' : 'bunny-w-1/2 bunny-h-full'} bunny-items-center`, style: {
22556
22858
  boxShadow: '-5px 0 20px 0 rgba(0, 0, 0, 0.05)',
22557
- }, children: isLoadingPriceList ? (jsxRuntime.jsx(antd.Skeleton, { active: true, className: `bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24` })) : (jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24`, children: jsxRuntime.jsx(PaymentForms, { quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: isSigningUp || isLoadingQuote, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction, defaultValues: defaultValues }) })) })] }));
22859
+ }, children: isLoadingPriceList ? (jsxRuntime.jsx(antd.Skeleton, { active: true, className: `bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24` })) : (jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24`, children: jsxRuntime.jsx(PaymentForms, { quote: quote, handlePaymentSuccess: handlePaymentSuccess, handleSubmit: handleSubmit, proceedingToPayment: isSigningUp || isLoadingQuote, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction, defaultValues: defaultValues }) })) })] }));
22558
22860
  }
22559
22861
 
22560
22862
  const { Text: Text$i } = antd.Typography;
@@ -22562,25 +22864,6 @@ const DrawerHeader = ({ description, onClose, title, closeButtonClassName, }) =>
22562
22864
  return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-4", children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-items-center bunny-justify-between bunny-gap-2", children: [jsxRuntime.jsx(Text$i, { className: "bunny-text-xl bunny-font-normal", children: title }), onClose ? (jsxRuntime.jsx("button", { id: "closePayment", onClick: onClose, className: closeButtonClassName, children: jsxRuntime.jsx(icons.CloseOutlined, {}) })) : null] }), description && jsxRuntime.jsx("div", { className: "bunny-text-sm bunny-font-medium", children: description })] }));
22563
22865
  };
22564
22866
 
22565
- /**
22566
- * Creates a context and provider for a state value
22567
- * @param useValue - A function that returns the state value
22568
- * @returns A tuple containing the provider and the context value
22569
- * @example take a look at how this is used in the quoteIdContext in the QuantityDrawer
22570
- */
22571
- const createStateContext = (useValue) => {
22572
- const StateContext = react.createContext(null);
22573
- const StateProvider = ({ initialValue, children, }) => jsxRuntime.jsxs(StateContext.Provider, { value: useValue(initialValue), children: [" ", children, " "] });
22574
- const useContextState = () => {
22575
- const value = react.useContext(StateContext);
22576
- if (value === null) {
22577
- throw new Error('Provider missing');
22578
- }
22579
- return value;
22580
- };
22581
- return [StateProvider, useContextState];
22582
- };
22583
-
22584
22867
  const useQuoteIdState = (id) => react.useState(id);
22585
22868
  const [QuoteIdProvider, useQuoteId] = createStateContext(useQuoteIdState);
22586
22869
 
@@ -23257,6 +23540,14 @@ function addonPlanSwitchTestId(planName) {
23257
23540
 
23258
23541
  const AddonIndentation = ({ isLast, indentation, verticalMargin, }) => (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-relative", style: { width: `${indentation}px` }, children: [jsxRuntime.jsx("div", { className: `bunny-flex-1 bunny-bg-gray-300 bunny-w-0.5 bunny-mx-auto`, style: { marginTop: verticalMargin } }), jsxRuntime.jsx("div", { className: "bunny-bg-gray-300 bunny-h-0.5 bunny-w-1/2 bunny-ml-auto" }), isLast ? (jsxRuntime.jsx("div", { className: "bunny-flex-1" })) : (jsxRuntime.jsx("div", { className: `bunny-flex-1 bunny-bg-gray-300 bunny-w-0.5 bunny-mx-auto`, style: { marginBottom: verticalMargin } }))] }));
23259
23542
 
23543
+ const Card = ({ children, className, style, }) => {
23544
+ const { darkMode } = react.useContext(BunnyContext);
23545
+ return (jsxRuntime.jsx("div", { className: `bunny-flex bunny-flex-col bunny-rounded-md ${className}`, style: {
23546
+ ...style,
23547
+ backgroundColor: darkMode ? 'var(--row-background-dark)' : 'var(--row-background)',
23548
+ }, children: children }));
23549
+ };
23550
+
23260
23551
  var utc$2 = {exports: {}};
23261
23552
 
23262
23553
  var utc$1 = utc$2.exports;
@@ -23407,83 +23698,6 @@ const StyledAreaChart = defaultStyled(recharts.AreaChart) `
23407
23698
  }
23408
23699
  `;
23409
23700
 
23410
- const QueryKeyFactory = {
23411
- accountPaymentMethodsKey: ({ accountId, entityId, token }) => [
23412
- 'accountPaymentMethods',
23413
- ...(entityId ? [entityId] : []),
23414
- ...(accountId ? [accountId] : []),
23415
- ...(token ? [token] : []),
23416
- ],
23417
- billingDetailsKey: ({ entityId, token }) => [
23418
- 'billingDetails',
23419
- ...(entityId ? [entityId] : []),
23420
- ...(token ? [token] : []),
23421
- ],
23422
- brandingKey: (token) => ['branding', ...(token ? [token] : [])],
23423
- calculatedPricesKey: ({ priceListId, quantity, token }) => [
23424
- 'calculatedPrices',
23425
- ...(priceListId ? [priceListId] : []),
23426
- ...(quantity ? [quantity] : []),
23427
- ...(token ? [token] : []),
23428
- ],
23429
- createEventsKey: ({ entityId, pluralType, token }) => [
23430
- pluralType,
23431
- 'events',
23432
- entityId,
23433
- ...(token ? [token] : []),
23434
- ],
23435
- createFormattedInvoiceKey: ({ id, token }) => [
23436
- 'formattedInvoice',
23437
- id,
23438
- ...(token ? [token] : []),
23439
- ],
23440
- createInvoiceKey: ({ id, token }) => ['invoice', id, token],
23441
- createObjectKey: ({ id, objectName, token }) => [
23442
- objectName,
23443
- ...(id ? [id] : []),
23444
- ...(token ? [token] : []),
23445
- ],
23446
- createQuoteKey: ({ id, token }) => ['quote', id, token],
23447
- createQuoteTaxCalculateKey: ({ id, token }) => [
23448
- 'quoteTaxCalculate',
23449
- ...(id ? [id] : []),
23450
- ...(token ? [token] : []),
23451
- ],
23452
- createTableKey: ({ filterString, pluralType, token }) => filterString ? [pluralType, 'list', filterString, token] : [pluralType, 'list', token],
23453
- currentUserKey: (token) => ['currentUser', ...(token ? [token] : [])],
23454
- editingQuoteKey: (token) => ['editingQuote', ...(token ? [token] : [])],
23455
- finixAchKey: (token) => ['finixAchKey', ...(token ? [token] : [])],
23456
- finixKey: (token) => ['finixKey', ...(token ? [token] : [])],
23457
- planChangeOptionsKey: ({ subscriptionId, productId, token }) => [
23458
- 'planChangeOptions',
23459
- ...(subscriptionId ? [subscriptionId] : []),
23460
- ...(productId ? [productId] : []),
23461
- ...(token ? [token] : []),
23462
- ],
23463
- pluginsKey: (token) => ['plugins', ...(token ? [token] : [])],
23464
- portalPreviewDataKey: ({ productId, token }) => [
23465
- 'portalPreviewData',
23466
- ...(productId ? [productId] : []),
23467
- ...(token ? [token] : []),
23468
- ],
23469
- taxationRequiredAccountFieldsKey: ({ entityId, token, }) => [
23470
- 'taxationRequiredAccountFields',
23471
- ...(entityId ? [entityId] : []),
23472
- ...(token ? [token] : []),
23473
- ],
23474
- transactionsKey: ({ filter, token }) => [
23475
- 'transactions',
23476
- ...(filter ? [filter] : []),
23477
- ...(token ? [token] : []),
23478
- ],
23479
- availableAddonPlansKey: ({ priceListId, token, }) => ['availableAddonPlans', priceListId, ...(token ? [token] : [])],
23480
- addonPlansKey: ({ priceListId, token }) => [
23481
- 'addonPlans',
23482
- priceListId,
23483
- ...(token ? [token] : []),
23484
- ],
23485
- };
23486
-
23487
23701
  const TAG_COLORS = {
23488
23702
  ACTIVE: "green",
23489
23703
  TRIAL: "blue",
@@ -23537,12 +23751,12 @@ const { Text: Text$f } = antd.Typography;
23537
23751
  const getSubscriptionStatusText = (subscription) => {
23538
23752
  const { cancellationDate, state, evergreen, endDate, trialEndDate, trialStartDate, startDate, trialExpirationAction, } = subscription;
23539
23753
  const stateUpperCased = state === null || state === void 0 ? void 0 : state.toUpperCase();
23540
- const isActive = stateUpperCased === common.SubscriptionState.ACTIVE;
23541
- const isPending = stateUpperCased === common.SubscriptionState.PENDING;
23542
- const isCanceled = stateUpperCased === common.SubscriptionState.CANCELED;
23543
- const isExpired = stateUpperCased === common.SubscriptionState.EXPIRED;
23544
- const isTrialExpired = stateUpperCased === common.SubscriptionState.TRIAL_EXPIRED;
23545
- const isTrial = stateUpperCased === common.SubscriptionState.TRIAL;
23754
+ const isActive = stateUpperCased === t.scalar('SubscriptionState', 'ACTIVE');
23755
+ const isPending = stateUpperCased === t.scalar('SubscriptionState', 'PENDING');
23756
+ const isCanceled = stateUpperCased === t.scalar('SubscriptionState', 'CANCELED');
23757
+ const isExpired = stateUpperCased === t.scalar('SubscriptionState', 'EXPIRED');
23758
+ const isTrialExpired = stateUpperCased === t.scalar('SubscriptionState', 'TRIAL_EXPIRED');
23759
+ const isTrial = stateUpperCased === t.scalar('SubscriptionState', 'TRIAL');
23546
23760
  if (cancellationDate && (isActive || isPending || isTrial))
23547
23761
  return (jsxRuntime.jsxs(CustomizedTag, { color: "red", children: ["Canceled - ends on ", common.formatDate(cancellationDate)] }));
23548
23762
  if (cancellationDate && isCanceled)
@@ -23597,8 +23811,6 @@ function SubscriptionStatusAndActions({ onChangePlanClick, onCancelSubscriptionC
23597
23811
  });
23598
23812
  const { isLoading: isPaymentMethodLoading } = usePaymentMethod({
23599
23813
  accountId: subscription.accountId,
23600
- token,
23601
- apiHost,
23602
23814
  });
23603
23815
  // Derived state
23604
23816
  const cardActionsVisible = !isMobile;
@@ -24080,9 +24292,9 @@ const useQuoteCreate = ({ upgradingSubscription, selectedPriceList, token, }) =>
24080
24292
  return;
24081
24293
  }
24082
24294
  const buyingAddonsForCurrentSubscription = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id);
24083
- const isActivatingTrialSubscription = ((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL &&
24295
+ const isActivatingTrialSubscription = ((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL') &&
24084
24296
  upgradingSubscription.priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id);
24085
- const isActivatingExpiredTrialSubscription = ((_b = upgradingSubscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL_EXPIRED &&
24297
+ const isActivatingExpiredTrialSubscription = ((_b = upgradingSubscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED') &&
24086
24298
  upgradingSubscription.priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id);
24087
24299
  if (isActivatingTrialSubscription || isActivatingExpiredTrialSubscription) {
24088
24300
  subscriptionActivate({
@@ -24934,11 +25146,11 @@ const PriceListCard = ({ hideButton, isSelected, priceList: maskedPriceList, sub
24934
25146
  upgradingSubscription,
24935
25147
  });
24936
25148
  const subscriptionPlan = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.find(subscription => {
24937
- var _a;
25149
+ var _a, _b;
24938
25150
  return subscription.plan.id === ((_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.id) &&
24939
25151
  subscription.state !== t.scalar('SubscriptionState', 'CANCELED') &&
24940
25152
  subscription.state !== t.scalar('SubscriptionState', 'EXPIRED') &&
24941
- subscription.state !== t.scalar('SubscriptionState', 'TRIAL_EXPIRED');
25153
+ ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED');
24942
25154
  });
24943
25155
  if (!activeCharge) {
24944
25156
  return null;
@@ -25814,7 +26026,7 @@ const AddonPlans = ({ selectedPriceList, subscriptions, selectedBillingPeriod, c
25814
26026
  const addonSubscriptionIds = currentSubscription === null || currentSubscription === void 0 ? void 0 : currentSubscription.addonSubscriptions;
25815
26027
  const addonSubscriptions = addonSubscriptionIds === null || addonSubscriptionIds === void 0 ? void 0 : addonSubscriptionIds.map(addonSubscription => subscriptions.find(subscription => subscription.id === addonSubscription.id));
25816
26028
  // filter out cancelled addons
25817
- const activeAddonSubscriptions = addonSubscriptions === null || addonSubscriptions === void 0 ? void 0 : addonSubscriptions.filter(addonSubscription => (addonSubscription === null || addonSubscription === void 0 ? void 0 : addonSubscription.state) !== common.SubscriptionState.CANCELED);
26029
+ const activeAddonSubscriptions = addonSubscriptions === null || addonSubscriptions === void 0 ? void 0 : addonSubscriptions.filter(addonSubscription => (addonSubscription === null || addonSubscription === void 0 ? void 0 : addonSubscription.state) !== t.scalar('SubscriptionState', 'CANCELED'));
25818
26030
  return activeAddonSubscriptions === null || activeAddonSubscriptions === void 0 ? void 0 : activeAddonSubscriptions.some(addonSubscription => (addonSubscription === null || addonSubscription === void 0 ? void 0 : addonSubscription.priceList.id) === priceList.id);
25819
26031
  }
25820
26032
  return (jsxRuntime.jsxs(Text$2, { className: `bunny-flex bunny-flex-col ${className}`, children: [jsxRuntime.jsx(AddonPlanModal, { onClose: () => setSelectedAddonPriceListId(null), priceList: selectedAddonPriceList }), addonPriceLists.length > 0 && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "bunny-text-slate-500 bunny-text-xs bunny-font-medium bunny-mb-2", children: 'Add-on plans'.toUpperCase() }), jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col", children: addonPriceLists.map(addonPriceList => {
@@ -26548,16 +26760,16 @@ const Subscriptions = ({ handlePortalErrors, companyName, noSubscriptionsCompone
26548
26760
  const allSubscriptionsInactive = (_c = (_b = subscriptionsData === null || subscriptionsData === void 0 ? void 0 : subscriptionsData.subscriptions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.every(maskedSubscription => {
26549
26761
  var _a, _b, _c;
26550
26762
  const subscription = readFragment(Subscriptions_SubscriptionFragment, maskedSubscription);
26551
- return (((_a = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
26552
- ((_b = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL_EXPIRED ||
26553
- ((_c = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.CANCELED);
26763
+ return (((_a = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'EXPIRED') ||
26764
+ ((_b = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED') ||
26765
+ ((_c = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === t.scalar('SubscriptionState', 'CANCELED'));
26554
26766
  });
26555
26767
  const hasInactiveSubscriptions = (_e = (_d = subscriptionsData === null || subscriptionsData === void 0 ? void 0 : subscriptionsData.subscriptions) === null || _d === void 0 ? void 0 : _d.nodes) === null || _e === void 0 ? void 0 : _e.some(maskedSubscription => {
26556
26768
  var _a, _b, _c;
26557
26769
  const subscription = readFragment(Subscriptions_SubscriptionFragment, maskedSubscription);
26558
- return (((_a = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
26559
- ((_b = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL_EXPIRED ||
26560
- ((_c = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.CANCELED);
26770
+ return (((_a = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === t.scalar('SubscriptionState', 'EXPIRED') ||
26771
+ ((_b = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED') ||
26772
+ ((_c = subscription === null || subscription === void 0 ? void 0 : subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === t.scalar('SubscriptionState', 'CANCELED'));
26561
26773
  });
26562
26774
  react.useEffect(() => {
26563
26775
  if (allSubscriptionsInactive && subscriptions && subscriptions.length > 0) {
@@ -26809,12 +27021,8 @@ const ResponsiveDivider = () => {
26809
27021
  };
26810
27022
  const PaymentFormSection = ({ hideBillingDetailsForm, isUpgradeFromTrial, onSavePaymentMethod, }) => {
26811
27023
  const isMobile = common.useIsMobile();
26812
- const { onTokenExpired } = react.useContext(BunnyContext);
26813
- const handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
26814
27024
  const showSuccessNotification = common.useSuccessNotification();
26815
- return (jsxRuntime.jsx("div", { className: `${isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4'} bunny-flex bunny-justify-center`, children: jsxRuntime.jsx(PaymentForm, { onFail: (error) => {
26816
- handleAllErrorFormats(error);
26817
- }, onSavePaymentMethod: (response) => {
27025
+ return (jsxRuntime.jsx("div", { className: `${isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4'} bunny-flex bunny-justify-center`, children: jsxRuntime.jsx(PaymentForm, { onSavePaymentMethod: (response) => {
26818
27026
  showSuccessNotification(isUpgradeFromTrial
26819
27027
  ? 'Payment method saved! Your trial will automatically convert to a paid subscription.'
26820
27028
  : 'Payment method saved successfully!');