@bunnyapp/components 1.0.10 → 1.0.12

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 (136) hide show
  1. package/dist/cjs/index.js +1069 -1167
  2. package/dist/cjs/src/components/BillingDetails/BillingDetails.d.ts +10 -0
  3. package/dist/cjs/src/components/BillingDetails/BillingDetails.stories.d.ts +11 -0
  4. package/dist/cjs/src/components/BillingDetails/index.d.ts +1 -0
  5. package/dist/cjs/src/components/BunnyProvider.d.ts +3 -3
  6. package/dist/cjs/src/components/Checkout/InvoiceCheckout.d.ts +1 -21
  7. package/dist/cjs/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  8. package/dist/cjs/src/components/Invoice/Invoice.d.ts +8 -2
  9. package/dist/cjs/src/components/Invoice/Invoice.stories.d.ts +14 -5
  10. package/dist/cjs/src/components/PageHeaderWithActions.d.ts +2 -1
  11. package/dist/cjs/src/components/PaymentForm/CheckoutFooter.d.ts +8 -7
  12. package/dist/cjs/src/components/PaymentForm/DemoPay/DemoPayForm.d.ts +6 -2
  13. package/dist/cjs/src/components/PaymentForm/DemoPay/demoPayUtils.d.ts +1 -3
  14. package/dist/cjs/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +13 -0
  15. package/dist/cjs/src/components/PaymentForm/DemoPay/hooks/useSave.d.ts +21 -0
  16. package/dist/cjs/src/components/PaymentForm/PaymentForm.d.ts +10 -6
  17. package/dist/cjs/src/components/PaymentForm/PaymentFormTypes.d.ts +0 -8
  18. package/dist/cjs/src/components/PaymentForm/PaymentMethod/CreditCard/CreditCard.d.ts +12 -2
  19. package/dist/cjs/src/components/PaymentForm/PaymentMethod/PaymentMethod.d.ts +6 -4
  20. package/dist/cjs/src/components/PaymentForm/PaymentMethod/PaymentMethod.stories.d.ts +11 -0
  21. package/dist/cjs/src/components/PaymentForm/PaymentMethodDetails.d.ts +8 -0
  22. package/dist/cjs/src/components/PaymentForm/PaymentMethodSelector.d.ts +2 -3
  23. package/dist/cjs/src/components/PaymentForm/SavePaymentMethodFooter.d.ts +6 -0
  24. package/dist/cjs/src/components/PaymentForm/Stripe/PaymentMethodForm.d.ts +6 -2
  25. package/dist/cjs/src/components/PaymentForm/Stripe/StripeForm.d.ts +6 -2
  26. package/dist/cjs/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +12 -0
  27. package/dist/cjs/src/components/PaymentForm/Stripe/hooks/useSave.d.ts +10 -0
  28. package/dist/cjs/src/components/PaymentForm/Stripe/stripeUtils.d.ts +9 -3
  29. package/dist/cjs/src/components/PaymentForm/useRemovePaymentMethod.d.ts +3 -0
  30. package/dist/cjs/src/components/Quote/Quote.d.ts +2 -4
  31. package/dist/cjs/src/components/Quote/Quote.stories.d.ts +122 -6
  32. package/dist/cjs/src/components/Quotes/Quotes.d.ts +8 -4
  33. package/dist/cjs/src/components/Quotes/Quotes.stories.d.ts +22 -0
  34. package/dist/cjs/src/components/Signup/PaymentForms.d.ts +2 -4
  35. package/dist/cjs/src/components/Signup/Signup.d.ts +11 -1
  36. package/dist/cjs/src/components/Signup/Signup.stories.d.ts +6 -4
  37. package/dist/cjs/src/components/StateTag.d.ts +3 -5
  38. package/dist/cjs/src/components/Subscriptions/Subscriptions.d.ts +2 -1
  39. package/dist/cjs/src/components/Subscriptions/Subscriptions.stories.d.ts +10 -0
  40. package/dist/cjs/src/components/Transactions/Transactions.d.ts +7 -5
  41. package/dist/cjs/src/components/Transactions/Transactions.stories.d.ts +15 -6
  42. package/dist/cjs/src/components/Transactions/TransactionsListContext.d.ts +5 -1
  43. package/dist/cjs/src/components/Transactions/transactionsList/TransactionsListDesktop.d.ts +1 -1
  44. package/dist/cjs/src/contexts/PaymentContext.d.ts +2 -2
  45. package/dist/cjs/src/graphql/queries/getAccount.d.ts +1 -1
  46. package/dist/cjs/src/hooks/quotes/useSendAcceptQuote.d.ts +2 -2
  47. package/dist/cjs/src/hooks/usePaymentMethod.d.ts +1 -1
  48. package/dist/cjs/src/mocks/handlers.d.ts +1 -1
  49. package/dist/cjs/src/storybook-utils.d.ts +10 -0
  50. package/dist/cjs/src/types/shadowType.d.ts +1 -0
  51. package/dist/esm/index.js +1073 -1171
  52. package/dist/esm/src/components/BillingDetails/BillingDetails.d.ts +10 -0
  53. package/dist/esm/src/components/BillingDetails/BillingDetails.stories.d.ts +11 -0
  54. package/dist/esm/src/components/BillingDetails/index.d.ts +1 -0
  55. package/dist/esm/src/components/BunnyProvider.d.ts +3 -3
  56. package/dist/esm/src/components/Checkout/InvoiceCheckout.d.ts +1 -21
  57. package/dist/esm/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  58. package/dist/esm/src/components/Invoice/Invoice.d.ts +8 -2
  59. package/dist/esm/src/components/Invoice/Invoice.stories.d.ts +14 -5
  60. package/dist/esm/src/components/PageHeaderWithActions.d.ts +2 -1
  61. package/dist/esm/src/components/PaymentForm/CheckoutFooter.d.ts +8 -7
  62. package/dist/esm/src/components/PaymentForm/DemoPay/DemoPayForm.d.ts +6 -2
  63. package/dist/esm/src/components/PaymentForm/DemoPay/demoPayUtils.d.ts +1 -3
  64. package/dist/esm/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +13 -0
  65. package/dist/esm/src/components/PaymentForm/DemoPay/hooks/useSave.d.ts +21 -0
  66. package/dist/esm/src/components/PaymentForm/PaymentForm.d.ts +10 -6
  67. package/dist/esm/src/components/PaymentForm/PaymentFormTypes.d.ts +0 -8
  68. package/dist/esm/src/components/PaymentForm/PaymentMethod/CreditCard/CreditCard.d.ts +12 -2
  69. package/dist/esm/src/components/PaymentForm/PaymentMethod/PaymentMethod.d.ts +6 -4
  70. package/dist/esm/src/components/PaymentForm/PaymentMethod/PaymentMethod.stories.d.ts +11 -0
  71. package/dist/esm/src/components/PaymentForm/PaymentMethodDetails.d.ts +8 -0
  72. package/dist/esm/src/components/PaymentForm/PaymentMethodSelector.d.ts +2 -3
  73. package/dist/esm/src/components/PaymentForm/SavePaymentMethodFooter.d.ts +6 -0
  74. package/dist/esm/src/components/PaymentForm/Stripe/PaymentMethodForm.d.ts +6 -2
  75. package/dist/esm/src/components/PaymentForm/Stripe/StripeForm.d.ts +6 -2
  76. package/dist/esm/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +12 -0
  77. package/dist/esm/src/components/PaymentForm/Stripe/hooks/useSave.d.ts +10 -0
  78. package/dist/esm/src/components/PaymentForm/Stripe/stripeUtils.d.ts +9 -3
  79. package/dist/esm/src/components/PaymentForm/useRemovePaymentMethod.d.ts +3 -0
  80. package/dist/esm/src/components/Quote/Quote.d.ts +2 -4
  81. package/dist/esm/src/components/Quote/Quote.stories.d.ts +122 -6
  82. package/dist/esm/src/components/Quotes/Quotes.d.ts +8 -4
  83. package/dist/esm/src/components/Quotes/Quotes.stories.d.ts +22 -0
  84. package/dist/esm/src/components/Signup/PaymentForms.d.ts +2 -4
  85. package/dist/esm/src/components/Signup/Signup.d.ts +11 -1
  86. package/dist/esm/src/components/Signup/Signup.stories.d.ts +6 -4
  87. package/dist/esm/src/components/StateTag.d.ts +3 -5
  88. package/dist/esm/src/components/Subscriptions/Subscriptions.d.ts +2 -1
  89. package/dist/esm/src/components/Subscriptions/Subscriptions.stories.d.ts +10 -0
  90. package/dist/esm/src/components/Transactions/Transactions.d.ts +7 -5
  91. package/dist/esm/src/components/Transactions/Transactions.stories.d.ts +15 -6
  92. package/dist/esm/src/components/Transactions/TransactionsListContext.d.ts +5 -1
  93. package/dist/esm/src/components/Transactions/transactionsList/TransactionsListDesktop.d.ts +1 -1
  94. package/dist/esm/src/contexts/PaymentContext.d.ts +2 -2
  95. package/dist/esm/src/graphql/queries/getAccount.d.ts +1 -1
  96. package/dist/esm/src/hooks/quotes/useSendAcceptQuote.d.ts +2 -2
  97. package/dist/esm/src/hooks/usePaymentMethod.d.ts +1 -1
  98. package/dist/esm/src/mocks/handlers.d.ts +1 -1
  99. package/dist/esm/src/storybook-utils.d.ts +10 -0
  100. package/dist/esm/src/types/shadowType.d.ts +1 -0
  101. package/dist/index.d.ts +45 -25
  102. package/package.json +3 -3
  103. package/dist/cjs/src/components/PaymentForm/Finix/FinixCardForm.d.ts +0 -4
  104. package/dist/cjs/src/components/PaymentForm/Finix/index.d.ts +0 -2
  105. package/dist/cjs/src/components/PaymentForm/FinixAch.d.ts +0 -3
  106. package/dist/cjs/src/components/PaymentForm/PaymentMethod/PaymentMethodContext.d.ts +0 -5
  107. package/dist/cjs/src/components/PaymentForm/PaymentMethodForm.d.ts +0 -3
  108. package/dist/cjs/src/components/PaymentForm/PaymentOption.d.ts +0 -8
  109. package/dist/cjs/src/components/PaymentForm/StoredPaymentMethod/StoredPaymentMethodForm.d.ts +0 -3
  110. package/dist/cjs/src/components/PaymentForm/Stripe/CheckoutForm.d.ts +0 -3
  111. package/dist/cjs/src/components/PaymentForm/Stripe/index.d.ts +0 -1
  112. package/dist/cjs/src/components/PaymentForm/paymentUtils.d.ts +0 -7
  113. package/dist/cjs/src/graphql/queries/getCurrentUserData.d.ts +0 -12
  114. package/dist/cjs/src/stories/Button.d.ts +0 -15
  115. package/dist/cjs/src/stories/Button.stories.d.ts +0 -9
  116. package/dist/cjs/src/stories/Header.d.ts +0 -12
  117. package/dist/cjs/src/stories/Header.stories.d.ts +0 -7
  118. package/dist/cjs/src/stories/Page.d.ts +0 -3
  119. package/dist/cjs/src/stories/Page.stories.d.ts +0 -7
  120. package/dist/esm/src/components/PaymentForm/Finix/FinixCardForm.d.ts +0 -4
  121. package/dist/esm/src/components/PaymentForm/Finix/index.d.ts +0 -2
  122. package/dist/esm/src/components/PaymentForm/FinixAch.d.ts +0 -3
  123. package/dist/esm/src/components/PaymentForm/PaymentMethod/PaymentMethodContext.d.ts +0 -5
  124. package/dist/esm/src/components/PaymentForm/PaymentMethodForm.d.ts +0 -3
  125. package/dist/esm/src/components/PaymentForm/PaymentOption.d.ts +0 -8
  126. package/dist/esm/src/components/PaymentForm/StoredPaymentMethod/StoredPaymentMethodForm.d.ts +0 -3
  127. package/dist/esm/src/components/PaymentForm/Stripe/CheckoutForm.d.ts +0 -3
  128. package/dist/esm/src/components/PaymentForm/Stripe/index.d.ts +0 -1
  129. package/dist/esm/src/components/PaymentForm/paymentUtils.d.ts +0 -7
  130. package/dist/esm/src/graphql/queries/getCurrentUserData.d.ts +0 -12
  131. package/dist/esm/src/stories/Button.d.ts +0 -15
  132. package/dist/esm/src/stories/Button.stories.d.ts +0 -9
  133. package/dist/esm/src/stories/Header.d.ts +0 -12
  134. package/dist/esm/src/stories/Header.stories.d.ts +0 -7
  135. package/dist/esm/src/stories/Page.d.ts +0 -3
  136. package/dist/esm/src/stories/Page.stories.d.ts +0 -7
package/dist/cjs/index.js CHANGED
@@ -13,10 +13,10 @@ var theme = require('antd/lib/theme');
13
13
  var recoil = require('recoil');
14
14
  var graphqlRequest = import('graphql-request');
15
15
  var reactHelmetAsync = require('react-helmet-async');
16
- var reactStripeJs = require('@stripe/react-stripe-js');
17
- var pure = require('@stripe/stripe-js/pure');
18
16
  var lodash = require('lodash');
19
17
  var recharts = require('recharts');
18
+ var reactStripeJs = require('@stripe/react-stripe-js');
19
+ var pure = require('@stripe/stripe-js/pure');
20
20
 
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
@@ -70,7 +70,7 @@ function styleInject(css, ref) {
70
70
  }
71
71
  }
72
72
 
73
- var css_248z = ".ant-tag {\n border: none;\n border-radius: 14px;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n white-space: nowrap;\n margin: 0;\n}\n.ant-tag-blue {\n color: #3b82f6 !important;\n background: #bfdbfe !important;\n}\n.ant-tag-green {\n color: #059669 !important;\n background: #a7f3d0 !important;\n}\n.ant-tag-red {\n color: #ef4444 !important;\n background: #fecaca !important;\n}\n.ant-tag-orange {\n color: #f97316 !important;\n background: #fed7aa !important;\n}\n.ant-tag-yellow {\n color: #f59e0b !important;\n background: #fde68a !important;\n}\n.ant-tag-purple {\n color: #8b5cf6 !important;\n background: #ddd6fe !important;\n}\n.ant-tag-black {\n color: white !important;\n background: black !important;\n}\n.ant-popover {\n z-index: 1050;\n}\n.ant-popover-inner-content {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n max-width: 300px;\n}\n.ant-popover-message-title {\n padding: 0;\n text-align: center;\n font-size: 1rem;\n}\n.ant-popover-buttons {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.ant-btn-primary:disabled {\n background: #eef0f2 !important;\n color: rgba(0, 0, 0, 0.25) !important;\n border: none;\n}\n.ant-btn {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n box-shadow: none;\n text-shadow: none;\n outline: none !important;\n line-height: 1;\n font-size: 0.875rem;\n font-weight: normal;\n}\n.ant-btn > span {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.ant-btn-lg {\n height: 44px !important;\n}\n.ant-btn-default:disabled {\n border-color: rgba(113, 125, 148, 0.2) !important;\n}\n.ant-btn-link {\n border: none !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.ant-btn-link > span {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.ant-btn-link:disabled {\n background-color: transparent !important;\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\n}\n.ant-input-affix-wrapper .ant-input-prefix {\n transition: color 0.3s;\n}\n.ant-select-selector {\n box-shadow: none !important;\n background-color: transparent !important;\n border: none !important;\n}\n.ant-form-item-label {\n text-transform: none !important;\n font-size: 0.75rem;\n padding-bottom: 2px !important;\n}\n.ant-form-item-label > label {\n width: 100%;\n color: #4b5563 !important;\n}\n.ant-form-item-explain-error {\n font-size: 11px;\n min-height: 11px;\n line-height: 11px;\n padding-top: 2px;\n}\n.ant-form-item {\n margin-bottom: 0;\n}\n.ant-notification {\n width: min-content;\n}\n.ant-notification-topRight {\n right: 0 !important;\n left: 0 !important;\n margin-left: auto !important;\n margin-right: auto !important;\n}\n.ant-notification-notice-wrapper {\n width: 350px !important;\n overflow: hidden !important;\n}\n.ant-notification-notice {\n padding: 16px !important;\n width: 350px !important;\n display: flex !important;\n box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.08), 0px 1px 18px rgba(0, 0, 0, 0.08), 0px 3px 5px rgba(0, 0, 0, 0.16) !important;\n}\n.ant-notification-notice-description {\n padding: 0 14px 0 0 !important;\n color: #232323 !important;\n font-size: 14px !important;\n word-break: break-all !important;\n overflow-wrap: break-word !important;\n}\n.ant-notification-notice-success {\n background-color: #edfffa !important;\n}\n.ant-notification-notice-error {\n background-color: #fff8f4 !important;\n}\n.ant-notification-notice-error .ant-notification-notice-message {\n color: #ff6e1c !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-error .ant-notification-notice-icon {\n color: #ff6e1c;\n}\n.ant-notification-notice-success .ant-notification-notice-message {\n color: #00b76a !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-success .ant-notification-notice-icon {\n color: #00b76a !important;\n}\n.ant-notification-notice-message {\n margin-bottom: 0 !important;\n}\n.ant-notification-notice-close {\n top: 16px !important;\n right: 16px !important;\n}\n.ant-divider {\n margin: 0;\n}\n.ant-menu-submenu-popup > .ant-menu .ant-menu-item {\n display: flex !important;\n align-items: center !important;\n}\n.ant-menu-submenu::after {\n display: none !important;\n}\n.ant-drawer-title {\n font-weight: 400 !important;\n}\n.ant-drawer-header-title {\n flex-direction: row-reverse !important;\n align-items: start !important ;\n}\n.ant-drawer-close {\n margin-inline-end: 0 !important;\n}\n@media (min-width: 768px) {\n .ant-input,\n .ant-picker,\n .ant-select,\n .ant-input-affix-wrapper {\n font-size: 1rem !important;\n }\n .ant-drawer-header {\n padding-right: 1.5rem !important;\n padding-left: 1.5rem !important;\n }\n}\n:root {\n --row-background: #ffffff;\n --row-background-alternate: rgba(100, 116, 139, 0.04);\n --row-background-dark: #121212;\n --row-background-alternate-dark: #1e1e1e;\n}\n.plan-step-line {\n height: 1px;\n min-width: 128px;\n background: #717d94;\n}\n.plan-step-number {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n border: 1px solid #717d94;\n background: white;\n width: 24px;\n height: 24px;\n color: #717d94;\n}\n.plan-step-number.active {\n border: none;\n color: white;\n background: #ff6e1c;\n}\n.hidden {\n display: none;\n}\n.cardElement {\n padding: 8px 11px;\n border: 1px solid #e5e7eb;\n background-color: white;\n font-family: Inter !important;\n}\n.tooltip {\n visibility: hidden;\n position: absolute !important;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\n}\n.show-on-hover {\n opacity: 0;\n}\n.show-on-hover-container:hover .show-on-hover {\n opacity: 1;\n}\n.pdf-only {\n display: none !important;\n}\n.notes p {\n margin: 0;\n padding: 0;\n padding-bottom: 0.25rem;\n}\n#form-element #finix-form-container .field-holder label {\n color: #717d94 !important;\n font-size: 12px !important;\n}\n#form-element #finix-form-container > *:first-child,\n#form-element #finix-form-container > *:last-child {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container > *:not(:first-child):not(:last-child) {\n margin-top: 12px !important;\n}\n#form-element #finix-form-container .field-array > * {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container .field-holder .field,\n#form-element #finix-form-container iframe {\n height: 34px !important;\n}\n#form-element #finix-form-container .field {\n margin-top: 0 !important;\n padding-top: 2px !important;\n}\n#form-element #finix-form-container .field-holder .validation {\n font-size: 11px !important;\n color: #ff4d4f !important;\n}\n.icon-path {\n transition: fill 0.3s;\n}\n.shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.shadow-padding-xb {\n padding-right: 1rem;\n padding-left: 1rem;\n padding-bottom: 0.5rem;\n}\n.content-container {\n width: 100%;\n margin: 0 auto;\n}\n@media (min-width: 1220px) {\n .content-container {\n width: 1220px !important;\n margin: 0 auto;\n }\n}\n@media (min-width: 768px) {\n .shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .shadow-padding-xb {\n padding-right: 2rem;\n padding-left: 2rem;\n padding-bottom: 0.5rem;\n }\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\n }\n}\n.rotate-45,\n.transform {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n}\n.shadow,\n.shadow-md {\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 768px) {\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n .container {\n max-width: 1536px;\n }\n}\n.visible {\n visibility: visible;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.left-0 {\n left: 0px;\n}\n.right-0 {\n right: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-50 {\n z-index: 50;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.col-span-3 {\n grid-column: span 3 / span 3;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-8 {\n margin-left: 2rem;\n margin-right: 2rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.my-4 {\n margin-top: 1rem;\n margin-bottom: 1rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-1 {\n margin-top: 0.25rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.block {\n display: block;\n}\n.flex {\n display: flex;\n}\n.table {\n display: table;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-full {\n height: 100%;\n}\n.h-screen {\n height: 100vh;\n}\n.w-1\\/2 {\n width: 50%;\n}\n.w-1\\/3 {\n width: 33.333333%;\n}\n.w-2\\/3 {\n width: 66.666667%;\n}\n.w-4 {\n width: 1rem;\n}\n.w-full {\n width: 100%;\n}\n.w-screen {\n width: 100vw;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.grow {\n flex-grow: 1;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.rotate-45 {\n --tw-rotate: 45deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n}\n.flex-row {\n flex-direction: row;\n}\n.flex-col {\n flex-direction: column;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-center {\n align-items: center;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.space-y-2 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));\n}\n.space-y-8 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(2rem * var(--tw-space-y-reverse));\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.overflow-visible {\n overflow: visible;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.border {\n border-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-gray-400 {\n --tw-border-opacity: 1;\n border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));\n}\n.border-gray-500 {\n --tw-border-opacity: 1;\n border-color: rgb(107 114 128 / var(--tw-border-opacity, 1));\n}\n.border-slate-200 {\n --tw-border-opacity: 1;\n border-color: rgb(226 232 240 / var(--tw-border-opacity, 1));\n}\n.border-slate-300 {\n --tw-border-opacity: 1;\n border-color: rgb(203 213 225 / var(--tw-border-opacity, 1));\n}\n.bg-black {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));\n}\n.bg-emerald-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(167 243 208 / var(--tw-bg-opacity, 1));\n}\n.bg-green-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(187 247 208 / var(--tw-bg-opacity, 1));\n}\n.bg-orange-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 215 170 / var(--tw-bg-opacity, 1));\n}\n.bg-red-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));\n}\n.bg-slate-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(248 250 252 / var(--tw-bg-opacity, 1));\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));\n}\n.bg-yellow-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));\n}\n.p-0 {\n padding: 0px;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-4 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n.px-6 {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n}\n.py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n}\n.py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n.py-4 {\n padding-top: 1rem;\n padding-bottom: 1rem;\n}\n.py-6 {\n padding-top: 1.5rem;\n padding-bottom: 1.5rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n.pl-0 {\n padding-left: 0px;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.pt-5 {\n padding-top: 1.25rem;\n}\n.pt-6 {\n padding-top: 1.5rem;\n}\n.pt-8 {\n padding-top: 2rem;\n}\n.text-left {\n text-align: left;\n}\n.text-center {\n text-align: center;\n}\n.text-right {\n text-align: right;\n}\n.align-middle {\n vertical-align: middle;\n}\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n.text-base {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n.text-lg {\n font-size: 1.125rem;\n line-height: 1.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xl {\n font-size: 1.25rem;\n line-height: 1.75rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.font-bold {\n font-weight: 700;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-normal {\n font-weight: 400;\n}\n.capitalize {\n text-transform: capitalize;\n}\n.text-emerald-600 {\n --tw-text-opacity: 1;\n color: rgb(5 150 105 / var(--tw-text-opacity, 1));\n}\n.text-emerald-700 {\n --tw-text-opacity: 1;\n color: rgb(4 120 87 / var(--tw-text-opacity, 1));\n}\n.text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(75 85 99 / var(--tw-text-opacity, 1));\n}\n.text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity, 1));\n}\n.text-green-600 {\n --tw-text-opacity: 1;\n color: rgb(22 163 74 / var(--tw-text-opacity, 1));\n}\n.text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity, 1));\n}\n.text-red-500 {\n --tw-text-opacity: 1;\n color: rgb(239 68 68 / var(--tw-text-opacity, 1));\n}\n.text-slate-400 {\n --tw-text-opacity: 1;\n color: rgb(148 163 184 / var(--tw-text-opacity, 1));\n}\n.text-slate-500 {\n --tw-text-opacity: 1;\n color: rgb(100 116 139 / var(--tw-text-opacity, 1));\n}\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.text-yellow-500 {\n --tw-text-opacity: 1;\n color: rgb(234 179 8 / var(--tw-text-opacity, 1));\n}\n.underline {\n text-decoration-line: underline;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-md {\n --tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.font-light {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-medium {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-bold {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n line-height: 1.15;\n}\nbody {\n color: #232323;\n background-color: #f8fafc;\n}\nth {\n font-weight: normal;\n}\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\", monospace;\n}\n@media only screen and (max-width: 768px) {\n select,\n textarea,\n input[type=\"text\"],\n input[type=\"password\"],\n input[type=\"datetime\"],\n input[type=\"datetime-local\"],\n input[type=\"date\"],\n input[type=\"month\"],\n input[type=\"time\"],\n input[type=\"week\"],\n input[type=\"number\"],\n input[type=\"email\"],\n input[type=\"url\"],\n input[type=\"search\"],\n input[type=\"tel\"],\n input[type=\"color\"] {\n font-size: 16px !important;\n }\n}\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n";
73
+ var css_248z = ".ant-collapse-header {\n cursor: default !important;\n padding: 0 !important;\n}\n.ant-tag {\n border: none;\n border-radius: 14px;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n white-space: nowrap;\n margin: 0;\n}\n.ant-tag-blue {\n color: #3b82f6 !important;\n background: #bfdbfe !important;\n}\n.ant-tag-green {\n color: #059669 !important;\n background: #a7f3d0 !important;\n}\n.ant-tag-red {\n color: #ef4444 !important;\n background: #fecaca !important;\n}\n.ant-tag-orange {\n color: #f97316 !important;\n background: #fed7aa !important;\n}\n.ant-tag-yellow {\n color: #f59e0b !important;\n background: #fde68a !important;\n}\n.ant-tag-purple {\n color: #8b5cf6 !important;\n background: #ddd6fe !important;\n}\n.ant-tag-black {\n color: white !important;\n background: black !important;\n}\n.ant-popover {\n z-index: 1050;\n}\n.ant-popover-inner-content {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n max-width: 300px;\n}\n.ant-popover-message-title {\n padding: 0;\n text-align: center;\n font-size: 1rem;\n}\n.ant-popover-buttons {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.ant-btn-primary:disabled {\n background: #eef0f2 !important;\n color: rgba(0, 0, 0, 0.25) !important;\n border: none;\n}\n.ant-btn {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n box-shadow: none;\n text-shadow: none;\n outline: none !important;\n line-height: 1;\n font-size: 0.875rem;\n font-weight: normal;\n}\n.ant-btn > span {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.ant-btn-lg {\n height: 44px !important;\n}\n.ant-btn-default:disabled {\n border-color: rgba(113, 125, 148, 0.2) !important;\n}\n.ant-btn-link {\n border: none !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.ant-btn-link > span {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.ant-btn-link:disabled {\n background-color: transparent !important;\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\n}\n.ant-input-affix-wrapper .ant-input-prefix {\n transition: color 0.3s;\n}\n.ant-form-item-label {\n text-transform: none !important;\n font-size: 0.75rem;\n padding-bottom: 2px !important;\n}\n.ant-form-item-label > label {\n width: 100%;\n color: #4b5563 !important;\n}\n.ant-form-item-explain-error {\n font-size: 11px;\n min-height: 11px;\n line-height: 11px;\n padding-top: 2px;\n}\n.ant-form-item {\n margin-bottom: 0;\n}\n.ant-notification {\n width: min-content;\n}\n.ant-notification-topRight {\n right: 0 !important;\n left: 0 !important;\n margin-left: auto !important;\n margin-right: auto !important;\n}\n.ant-notification-notice-wrapper {\n width: 350px !important;\n overflow: hidden !important;\n}\n.ant-notification-notice {\n padding: 16px !important;\n width: 350px !important;\n display: flex !important;\n box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.08), 0px 1px 18px rgba(0, 0, 0, 0.08), 0px 3px 5px rgba(0, 0, 0, 0.16) !important;\n}\n.ant-notification-notice-description {\n padding: 0 14px 0 0 !important;\n color: #232323 !important;\n font-size: 14px !important;\n word-break: break-all !important;\n overflow-wrap: break-word !important;\n}\n.ant-notification-notice-success {\n background-color: #edfffa !important;\n}\n.ant-notification-notice-error {\n background-color: #fff8f4 !important;\n}\n.ant-notification-notice-error .ant-notification-notice-message {\n color: #ff6e1c !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-error .ant-notification-notice-icon {\n color: #ff6e1c;\n}\n.ant-notification-notice-success .ant-notification-notice-message {\n color: #00b76a !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-success .ant-notification-notice-icon {\n color: #00b76a !important;\n}\n.ant-notification-notice-message {\n margin-bottom: 0 !important;\n}\n.ant-notification-notice-close {\n top: 16px !important;\n right: 16px !important;\n}\n.ant-divider {\n margin: 0;\n}\n.ant-menu-submenu-popup > .ant-menu .ant-menu-item {\n display: flex !important;\n align-items: center !important;\n}\n.ant-menu-submenu::after {\n display: none !important;\n}\n.ant-drawer-title {\n font-weight: 400 !important;\n}\n.ant-drawer-header-title {\n flex-direction: row-reverse !important;\n align-items: start !important ;\n}\n.ant-drawer-close {\n margin-inline-end: 0 !important;\n}\n@media (min-width: 768px) {\n .ant-input,\n .ant-picker,\n .ant-select,\n .ant-input-affix-wrapper {\n font-size: 1rem !important;\n }\n .ant-drawer-header {\n padding-right: 1.5rem !important;\n padding-left: 1.5rem !important;\n }\n}\n:root {\n --row-background: #ffffff;\n --row-background-alternate: rgba(100, 116, 139, 0.04);\n --row-background-dark: #121212;\n --row-background-alternate-dark: #1e1e1e;\n}\n.plan-step-line {\n height: 1px;\n min-width: 128px;\n background: #717d94;\n}\n.plan-step-number {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n border: 1px solid #717d94;\n background: white;\n width: 24px;\n height: 24px;\n color: #717d94;\n}\n.plan-step-number.active {\n border: none;\n color: white;\n background: #ff6e1c;\n}\n.hidden {\n display: none;\n}\n.cardElement {\n padding: 8px 11px;\n border: 1px solid #e5e7eb;\n background-color: white;\n font-family: Inter !important;\n}\n.tooltip {\n visibility: hidden;\n position: absolute !important;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\n}\n.show-on-hover {\n opacity: 0;\n}\n.show-on-hover-container:hover .show-on-hover {\n opacity: 1;\n}\n.pdf-only {\n display: none !important;\n}\n.notes p {\n margin: 0;\n padding: 0;\n padding-bottom: 0.25rem;\n}\n#form-element #finix-form-container .field-holder label {\n color: #717d94 !important;\n font-size: 12px !important;\n}\n#form-element #finix-form-container > *:first-child,\n#form-element #finix-form-container > *:last-child {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container > *:not(:first-child):not(:last-child) {\n margin-top: 12px !important;\n}\n#form-element #finix-form-container .field-array > * {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container .field-holder .field,\n#form-element #finix-form-container iframe {\n height: 34px !important;\n}\n#form-element #finix-form-container .field {\n margin-top: 0 !important;\n padding-top: 2px !important;\n}\n#form-element #finix-form-container .field-holder .validation {\n font-size: 11px !important;\n color: #ff4d4f !important;\n}\n.icon-path {\n transition: fill 0.3s;\n}\n.shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.shadow-padding-xb {\n padding-right: 1rem;\n padding-left: 1rem;\n padding-bottom: 0.5rem;\n}\n.content-container {\n width: 100%;\n margin: 0 auto;\n}\n@media (min-width: 1220px) {\n .content-container {\n width: 1220px !important;\n margin: 0 auto;\n }\n}\n@media (min-width: 768px) {\n .shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .shadow-padding-xb {\n padding-right: 2rem;\n padding-left: 2rem;\n padding-bottom: 0.5rem;\n }\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\n }\n}\n.rotate-45,\n.transform {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n}\n.shadow,\n.shadow-lg,\n.shadow-md,\n.shadow-none,\n.shadow-sm,\n.shadow-xl {\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 768px) {\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n .container {\n max-width: 1536px;\n }\n}\n.visible {\n visibility: visible;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.left-0 {\n left: 0px;\n}\n.right-0 {\n right: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-50 {\n z-index: 50;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.col-span-3 {\n grid-column: span 3 / span 3;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.my-2 {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n}\n.my-4 {\n margin-top: 1rem;\n margin-bottom: 1rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-1 {\n margin-top: 0.25rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.block {\n display: block;\n}\n.flex {\n display: flex;\n}\n.table {\n display: table;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-full {\n height: 100%;\n}\n.w-1\\/2 {\n width: 50%;\n}\n.w-1\\/3 {\n width: 33.333333%;\n}\n.w-2\\/3 {\n width: 66.666667%;\n}\n.w-4 {\n width: 1rem;\n}\n.w-full {\n width: 100%;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.flex-1 {\n flex: 1 1 0%;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.grow {\n flex-grow: 1;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.rotate-45 {\n --tw-rotate: 45deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n}\n.flex-row {\n flex-direction: row;\n}\n.flex-col {\n flex-direction: column;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-center {\n align-items: center;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.gap-0 {\n gap: 0px;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.space-y-2 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));\n}\n.space-y-4 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(1rem * var(--tw-space-y-reverse));\n}\n.space-y-8 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(2rem * var(--tw-space-y-reverse));\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.overflow-visible {\n overflow: visible;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.border {\n border-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-gray-400 {\n --tw-border-opacity: 1;\n border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));\n}\n.border-gray-500 {\n --tw-border-opacity: 1;\n border-color: rgb(107 114 128 / var(--tw-border-opacity, 1));\n}\n.border-slate-200 {\n --tw-border-opacity: 1;\n border-color: rgb(226 232 240 / var(--tw-border-opacity, 1));\n}\n.border-slate-300 {\n --tw-border-opacity: 1;\n border-color: rgb(203 213 225 / var(--tw-border-opacity, 1));\n}\n.border-slate-700 {\n --tw-border-opacity: 1;\n border-color: rgb(51 65 85 / var(--tw-border-opacity, 1));\n}\n.bg-black {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));\n}\n.bg-emerald-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(167 243 208 / var(--tw-bg-opacity, 1));\n}\n.bg-green-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(187 247 208 / var(--tw-bg-opacity, 1));\n}\n.bg-orange-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 215 170 / var(--tw-bg-opacity, 1));\n}\n.bg-red-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));\n}\n.bg-red-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));\n}\n.bg-slate-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(248 250 252 / var(--tw-bg-opacity, 1));\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));\n}\n.bg-yellow-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));\n}\n.p-0 {\n padding: 0px;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-8 {\n padding: 2rem;\n}\n.px-0 {\n padding-left: 0px;\n padding-right: 0px;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-4 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n.px-6 {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n}\n.py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n}\n.py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n.py-4 {\n padding-top: 1rem;\n padding-bottom: 1rem;\n}\n.py-6 {\n padding-top: 1.5rem;\n padding-bottom: 1.5rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n.pl-0 {\n padding-left: 0px;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-12 {\n padding-top: 3rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.pt-5 {\n padding-top: 1.25rem;\n}\n.pt-6 {\n padding-top: 1.5rem;\n}\n.pt-8 {\n padding-top: 2rem;\n}\n.text-left {\n text-align: left;\n}\n.text-center {\n text-align: center;\n}\n.text-right {\n text-align: right;\n}\n.align-middle {\n vertical-align: middle;\n}\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n.text-base {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n.text-lg {\n font-size: 1.125rem;\n line-height: 1.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xl {\n font-size: 1.25rem;\n line-height: 1.75rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.font-bold {\n font-weight: 700;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-normal {\n font-weight: 400;\n}\n.capitalize {\n text-transform: capitalize;\n}\n.text-emerald-600 {\n --tw-text-opacity: 1;\n color: rgb(5 150 105 / var(--tw-text-opacity, 1));\n}\n.text-emerald-700 {\n --tw-text-opacity: 1;\n color: rgb(4 120 87 / var(--tw-text-opacity, 1));\n}\n.text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(75 85 99 / var(--tw-text-opacity, 1));\n}\n.text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity, 1));\n}\n.text-green-600 {\n --tw-text-opacity: 1;\n color: rgb(22 163 74 / var(--tw-text-opacity, 1));\n}\n.text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity, 1));\n}\n.text-red-500 {\n --tw-text-opacity: 1;\n color: rgb(239 68 68 / var(--tw-text-opacity, 1));\n}\n.text-slate-400 {\n --tw-text-opacity: 1;\n color: rgb(148 163 184 / var(--tw-text-opacity, 1));\n}\n.text-slate-500 {\n --tw-text-opacity: 1;\n color: rgb(100 116 139 / var(--tw-text-opacity, 1));\n}\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.text-yellow-500 {\n --tw-text-opacity: 1;\n color: rgb(234 179 8 / var(--tw-text-opacity, 1));\n}\n.underline {\n text-decoration-line: underline;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-md {\n --tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-none {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-sm {\n --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-xl {\n --tw-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.font-light {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-medium {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-bold {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n line-height: 1.15;\n}\nbody {\n color: #232323;\n background-color: #f8fafc;\n}\nth {\n font-weight: normal;\n}\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\", monospace;\n}\n@media only screen and (max-width: 768px) {\n select,\n textarea,\n input[type=\"text\"],\n input[type=\"password\"],\n input[type=\"datetime\"],\n input[type=\"datetime-local\"],\n input[type=\"date\"],\n input[type=\"month\"],\n input[type=\"time\"],\n input[type=\"week\"],\n input[type=\"number\"],\n input[type=\"email\"],\n input[type=\"url\"],\n input[type=\"search\"],\n input[type=\"tel\"],\n input[type=\"color\"] {\n font-size: 16px !important;\n }\n}\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n";
74
74
  styleInject(css_248z);
75
75
 
76
76
  /******************************************************************************
@@ -1494,11 +1494,11 @@ var BankOutlined = function BankOutlined(props, ref) {
1494
1494
  };
1495
1495
 
1496
1496
  /**![bank](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNjYWNhY2EiIHZpZXdCb3g9IjY0IDY0IDg5NiA4OTYiIGZvY3VzYWJsZT0iZmFsc2UiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTg5NCA0NjJjMzAuOSAwIDQzLjgtMzkuNyAxOC43LTU4TDUzMC44IDEyNi4yYTMxLjgxIDMxLjgxIDAgMDAtMzcuNiAwTDExMS4zIDQwNGMtMjUuMSAxOC4yLTEyLjIgNTggMTguOCA1OEgxOTJ2Mzc0aC03MmMtNC40IDAtOCAzLjYtOCA4djUyYzAgNC40IDMuNiA4IDggOGg3ODRjNC40IDAgOC0zLjYgOC04di01MmMwLTQuNC0zLjYtOC04LThoLTcyVjQ2Mmg2MnpNNTEyIDE5Ni43bDI3MS4xIDE5Ny4ySDI0MC45TDUxMiAxOTYuN3pNMjY0IDQ2MmgxMTd2Mzc0SDI2NFY0NjJ6bTE4OSAwaDExN3YzNzRINDUzVjQ2MnptMzA3IDM3NEg2NDJWNDYyaDExOHYzNzR6IiAvPjwvc3ZnPg==) */
1497
- var RefIcon$4 = /*#__PURE__*/React__namespace.forwardRef(BankOutlined);
1497
+ var RefIcon$5 = /*#__PURE__*/React__namespace.forwardRef(BankOutlined);
1498
1498
  if (process.env.NODE_ENV !== 'production') {
1499
- RefIcon$4.displayName = 'BankOutlined';
1499
+ RefIcon$5.displayName = 'BankOutlined';
1500
1500
  }
1501
- var BankOutlined$1 = RefIcon$4;
1501
+ var BankOutlined$1 = RefIcon$5;
1502
1502
 
1503
1503
  // This icon file is generated automatically.
1504
1504
  var CheckCircleFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" } }] }, "name": "check-circle", "theme": "filled" };
@@ -1512,11 +1512,11 @@ var CheckCircleFilled = function CheckCircleFilled(props, ref) {
1512
1512
  };
1513
1513
 
1514
1514
  /**![check-circle](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNjYWNhY2EiIHZpZXdCb3g9IjY0IDY0IDg5NiA4OTYiIGZvY3VzYWJsZT0iZmFsc2UiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTUxMiA2NEMyNjQuNiA2NCA2NCAyNjQuNiA2NCA1MTJzMjAwLjYgNDQ4IDQ0OCA0NDggNDQ4LTIwMC42IDQ0OC00NDhTNzU5LjQgNjQgNTEyIDY0em0xOTMuNSAzMDEuN2wtMjEwLjYgMjkyYTMxLjggMzEuOCAwIDAxLTUxLjcgMEwzMTguNSA0ODQuOWMtMy44LTUuMyAwLTEyLjcgNi41LTEyLjdoNDYuOWMxMC4yIDAgMTkuOSA0LjkgMjUuOSAxMy4zbDcxLjIgOTguOCAxNTcuMi0yMThjNi04LjMgMTUuNi0xMy4zIDI1LjktMTMuM0g2OTljNi41IDAgMTAuMyA3LjQgNi41IDEyLjd6IiAvPjwvc3ZnPg==) */
1515
- var RefIcon$3 = /*#__PURE__*/React__namespace.forwardRef(CheckCircleFilled);
1515
+ var RefIcon$4 = /*#__PURE__*/React__namespace.forwardRef(CheckCircleFilled);
1516
1516
  if (process.env.NODE_ENV !== 'production') {
1517
- RefIcon$3.displayName = 'CheckCircleFilled';
1517
+ RefIcon$4.displayName = 'CheckCircleFilled';
1518
1518
  }
1519
- var CheckCircleFilled$1 = RefIcon$3;
1519
+ var CheckCircleFilled$1 = RefIcon$4;
1520
1520
 
1521
1521
  // This icon file is generated automatically.
1522
1522
  var CloseOutlined$2 = { "icon": { "tag": "svg", "attrs": { "fill-rule": "evenodd", "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M799.86 166.31c.02 0 .04.02.08.06l57.69 57.7c.04.03.05.05.06.08a.12.12 0 010 .06c0 .03-.02.05-.06.09L569.93 512l287.7 287.7c.04.04.05.06.06.09a.12.12 0 010 .07c0 .02-.02.04-.06.08l-57.7 57.69c-.03.04-.05.05-.07.06a.12.12 0 01-.07 0c-.03 0-.05-.02-.09-.06L512 569.93l-287.7 287.7c-.04.04-.06.05-.09.06a.12.12 0 01-.07 0c-.02 0-.04-.02-.08-.06l-57.69-57.7c-.04-.03-.05-.05-.06-.07a.12.12 0 010-.07c0-.03.02-.05.06-.09L454.07 512l-287.7-287.7c-.04-.04-.05-.06-.06-.09a.12.12 0 010-.07c0-.02.02-.04.06-.08l57.7-57.69c.03-.04.05-.05.07-.06a.12.12 0 01.07 0c.03 0 .05.02.09.06L512 454.07l287.7-287.7c.04-.04.06-.05.09-.06a.12.12 0 01.07 0z" } }] }, "name": "close", "theme": "outlined" };
@@ -1530,11 +1530,29 @@ var CloseOutlined = function CloseOutlined(props, ref) {
1530
1530
  };
1531
1531
 
1532
1532
  /**![close](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNjYWNhY2EiIGZpbGwtcnVsZT0iZXZlbm9kZCIgdmlld0JveD0iNjQgNjQgODk2IDg5NiIgZm9jdXNhYmxlPSJmYWxzZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNzk5Ljg2IDE2Ni4zMWMuMDIgMCAuMDQuMDIuMDguMDZsNTcuNjkgNTcuN2MuMDQuMDMuMDUuMDUuMDYuMDhhLjEyLjEyIDAgMDEwIC4wNmMwIC4wMy0uMDIuMDUtLjA2LjA5TDU2OS45MyA1MTJsMjg3LjcgMjg3LjdjLjA0LjA0LjA1LjA2LjA2LjA5YS4xMi4xMiAwIDAxMCAuMDdjMCAuMDItLjAyLjA0LS4wNi4wOGwtNTcuNyA1Ny42OWMtLjAzLjA0LS4wNS4wNS0uMDcuMDZhLjEyLjEyIDAgMDEtLjA3IDBjLS4wMyAwLS4wNS0uMDItLjA5LS4wNkw1MTIgNTY5LjkzbC0yODcuNyAyODcuN2MtLjA0LjA0LS4wNi4wNS0uMDkuMDZhLjEyLjEyIDAgMDEtLjA3IDBjLS4wMiAwLS4wNC0uMDItLjA4LS4wNmwtNTcuNjktNTcuN2MtLjA0LS4wMy0uMDUtLjA1LS4wNi0uMDdhLjEyLjEyIDAgMDEwLS4wN2MwLS4wMy4wMi0uMDUuMDYtLjA5TDQ1NC4wNyA1MTJsLTI4Ny43LTI4Ny43Yy0uMDQtLjA0LS4wNS0uMDYtLjA2LS4wOWEuMTIuMTIgMCAwMTAtLjA3YzAtLjAyLjAyLS4wNC4wNi0uMDhsNTcuNy01Ny42OWMuMDMtLjA0LjA1LS4wNS4wNy0uMDZhLjEyLjEyIDAgMDEuMDcgMGMuMDMgMCAuMDUuMDIuMDkuMDZMNTEyIDQ1NC4wN2wyODcuNy0yODcuN2MuMDQtLjA0LjA2LS4wNS4wOS0uMDZhLjEyLjEyIDAgMDEuMDcgMHoiIC8+PC9zdmc+) */
1533
- var RefIcon$2 = /*#__PURE__*/React__namespace.forwardRef(CloseOutlined);
1533
+ var RefIcon$3 = /*#__PURE__*/React__namespace.forwardRef(CloseOutlined);
1534
+ if (process.env.NODE_ENV !== 'production') {
1535
+ RefIcon$3.displayName = 'CloseOutlined';
1536
+ }
1537
+ var CloseOutlined$1 = RefIcon$3;
1538
+
1539
+ // This icon file is generated automatically.
1540
+ var CreditCardOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-792 72h752v120H136V232zm752 560H136V440h752v352zm-237-64h165c4.4 0 8-3.6 8-8v-72c0-4.4-3.6-8-8-8H651c-4.4 0-8 3.6-8 8v72c0 4.4 3.6 8 8 8z" } }] }, "name": "credit-card", "theme": "outlined" };
1541
+ var CreditCardOutlinedSvg = CreditCardOutlined$2;
1542
+
1543
+ var CreditCardOutlined = function CreditCardOutlined(props, ref) {
1544
+ return /*#__PURE__*/React__namespace.createElement(AntdIcon, _extends({}, props, {
1545
+ ref: ref,
1546
+ icon: CreditCardOutlinedSvg
1547
+ }));
1548
+ };
1549
+
1550
+ /**![credit-card](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNjYWNhY2EiIHZpZXdCb3g9IjY0IDY0IDg5NiA4OTYiIGZvY3VzYWJsZT0iZmFsc2UiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTkyOCAxNjBIOTZjLTE3LjcgMC0zMiAxNC4zLTMyIDMydjY0MGMwIDE3LjcgMTQuMyAzMiAzMiAzMmg4MzJjMTcuNyAwIDMyLTE0LjMgMzItMzJWMTkyYzAtMTcuNy0xNC4zLTMyLTMyLTMyem0tNzkyIDcyaDc1MnYxMjBIMTM2VjIzMnptNzUyIDU2MEgxMzZWNDQwaDc1MnYzNTJ6bS0yMzctNjRoMTY1YzQuNCAwIDgtMy42IDgtOHYtNzJjMC00LjQtMy42LTgtOC04SDY1MWMtNC40IDAtOCAzLjYtOCA4djcyYzAgNC40IDMuNiA4IDggOHoiIC8+PC9zdmc+) */
1551
+ var RefIcon$2 = /*#__PURE__*/React__namespace.forwardRef(CreditCardOutlined);
1534
1552
  if (process.env.NODE_ENV !== 'production') {
1535
- RefIcon$2.displayName = 'CloseOutlined';
1553
+ RefIcon$2.displayName = 'CreditCardOutlined';
1536
1554
  }
1537
- var CloseOutlined$1 = RefIcon$2;
1555
+ var CreditCardOutlined$1 = RefIcon$2;
1538
1556
 
1539
1557
  // This icon file is generated automatically.
1540
1558
  var DownloadOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z" } }] }, "name": "download", "theme": "outlined" };
@@ -1579,7 +1597,7 @@ var BrandContext = React.createContext({
1579
1597
  topNavImageUrl: common.DEFAULT_TOP_NAV_IMAGE_URL,
1580
1598
  });
1581
1599
 
1582
- var MUTATION$9 = "{\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }";
1600
+ var MUTATION$9 = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
1583
1601
  var getBranding = function (_a) {
1584
1602
  var token = _a.token, apiHost = _a.apiHost;
1585
1603
  return __awaiter(void 0, void 0, void 0, function () {
@@ -1611,7 +1629,7 @@ var BunnyContext = React.createContext({});
1611
1629
  var extraQueryClient = new reactQuery.QueryClient();
1612
1630
  // Every component shares similar props and functionality, which this wrapper handles.
1613
1631
  function BunnyProvider(_a) {
1614
- var accountId = _a.accountId, children = _a.children, _b = _a.darkMode, darkMode = _b === void 0 ? false : _b, onErrorNavigate = _a.onErrorNavigate, queryClient = _a.queryClient, apiHost = _a.apiHost, token = _a.token, window = _a.window;
1632
+ var accountId = _a.accountId, children = _a.children, _b = _a.darkMode, darkMode = _b === void 0 ? false : _b, queryClient = _a.queryClient, apiHost = _a.apiHost, token = _a.token, window = _a.window, onTokenExpired = _a.onTokenExpired;
1615
1633
  var graphQLClient = createGraphQLClient(token, apiHost || "");
1616
1634
  var isMobile = common.useIsMobile();
1617
1635
  var _c = React.useState(undefined), branding = _c[0], setBranding = _c[1];
@@ -1648,10 +1666,10 @@ function BunnyProvider(_a) {
1648
1666
  accountId: accountId,
1649
1667
  darkMode: darkMode,
1650
1668
  graphQLClient: graphQLClient,
1651
- onErrorNavigate: onErrorNavigate,
1652
1669
  apiHost: apiHost,
1653
1670
  token: token,
1654
1671
  window: window,
1672
+ onTokenExpired: onTokenExpired,
1655
1673
  } }, { children: [jsxRuntime.jsx("div", __assign({ style: { position: "fixed", left: -2000000000 } }, { children: "test" })), jsxRuntime.jsx(reactQuery.QueryClientProvider, __assign({ client: queryClient || extraQueryClient }, { children: jsxRuntime.jsx(recoil.RecoilRoot, { children: jsxRuntime.jsx(BrandContext.Provider, __assign({ value: entityBranding }, { children: jsxRuntime.jsx(antd.ConfigProvider, __assign({ theme: {
1656
1674
  algorithm: darkMode
1657
1675
  ? theme__default["default"].darkAlgorithm
@@ -1768,27 +1786,39 @@ var InvoiceQuoteView = function (_a) {
1768
1786
  var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError;
1769
1787
  var downloadFile = useDownloadFile(formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.id, onDownloadError);
1770
1788
  var secondaryColor = React.useContext(BrandContext).secondaryColor;
1771
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost; _b.window;
1789
+ var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost;
1790
+ var _c = React.useContext(InvoiceQuoteContext), shadow = _c.shadow, hideDownloadButton = _c.hideDownloadButton;
1772
1791
  var isMobile = common.useIsMobile();
1773
- return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full grow ".concat(isMobile ? "overflow-hidden" : "") }, { children: [formattedInvoice ? (jsxRuntime.jsxs("div", __assign({ className: "flex justify-between items-center pb-4 ".concat(isMobile ? "shadow-padding-x" : ""), id: "acceptance" }, { children: [jsxRuntime.jsx("div", { children: onBackButtonClick ? (jsxRuntime.jsx(antd.Button, __assign({ className: "text-xs pl-0", onClick: onBackButtonClick, style: {
1792
+ var buttonsVisible = formattedInvoice && (!hideDownloadButton || onBackButtonClick);
1793
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full grow ".concat(isMobile ? "overflow-hidden" : "") }, { children: [buttonsVisible ? (jsxRuntime.jsxs("div", __assign({ className: "flex justify-between items-center pb-4 ".concat(isMobile ? "shadow-padding-x" : ""), id: "acceptance" }, { children: [jsxRuntime.jsx("div", { children: onBackButtonClick ? (jsxRuntime.jsx(antd.Button, __assign({ className: "text-xs pl-0", onClick: onBackButtonClick, style: {
1774
1794
  color: secondaryColor,
1775
- }, type: "link" }, { children: backButtonName || "Back" }))) : null }), jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(DownloadOutlined$1, {}), onClick: function () {
1795
+ }, type: "link" }, { children: backButtonName || "Back" }))) : null }), !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(DownloadOutlined$1, {}), onClick: function () {
1776
1796
  return downloadFile(apiHost + "/api/pdf/invoice/" + formattedInvoice.id, token);
1777
- } }, { children: "Download" }))] }))) : null, isMobile ? (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "flex flex-col gap-4 grow w-full shadow-padding-xb overflow-auto" }, { children: [jsxRuntime.jsx(interweave.Markup, { content: html }), children] }))) : (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "flex flex-col gap-4 p-2 w-full bg-white shadow-md rounded-md", style: {
1797
+ } }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "flex flex-col gap-4 grow w-full shadow-padding-xb overflow-auto" }, { children: [jsxRuntime.jsx(interweave.Markup, { content: html }), children] }))) : (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "flex flex-col gap-4 p-2 w-full bg-white ".concat(shadow ? shadow : "shadow-md", " rounded-md"), style: {
1778
1798
  minWidth: "750px",
1779
1799
  } }, { children: [jsxRuntime.jsx(interweave.Markup, { content: html }), children] })))] })));
1780
1800
  };
1781
1801
  var templateObject_1$8;
1782
1802
 
1803
+ var quoteMetaDescription = function (vendorName) {
1804
+ return "View this quote on the ".concat(vendorName, " customer portal. Powered by Bunny");
1805
+ };
1806
+ var quoteMetaTitle = function (_a) {
1807
+ var documentName = _a.documentName, vendorName = _a.vendorName;
1808
+ return vendorName + " " + documentName;
1809
+ };
1810
+
1811
+ var PaymentContext = React.createContext({});
1812
+
1783
1813
  var paymentMethodsQuery = "query paymentMethods ($filter: String, $first: Int, $sort: String) {\n paymentMethods (filter: $filter, first: $first, sort: $sort) {\n nodes {\n id\n disabled\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n }\n }\n }\n}";
1784
- var usePaymentMethod = function (graphQLClient) {
1814
+ var usePaymentMethod = function (graphQLClient, accountId) {
1785
1815
  var result = reactQuery.useQuery({
1786
1816
  queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
1787
1817
  queryFn: function () {
1788
1818
  return graphQLClient
1789
1819
  .request(paymentMethodsQuery, {
1790
1820
  first: 1,
1791
- filter: "disabled is false",
1821
+ filter: "disabled is false".concat(accountId ? " and accountId is ".concat(accountId) : ""),
1792
1822
  })
1793
1823
  .then(function (data) {
1794
1824
  var _a, _b;
@@ -1801,40 +1831,151 @@ var usePaymentMethod = function (graphQLClient) {
1801
1831
  return result;
1802
1832
  };
1803
1833
 
1804
- var CardIcon = function () {
1805
- return (jsxRuntime.jsxs("svg", __assign({ width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsx("path", { d: "M15 3.75H3C2.17157 3.75 1.5 4.42157 1.5 5.25V12.75C1.5 13.5784 2.17157 14.25 3 14.25H15C15.8284 14.25 16.5 13.5784 16.5 12.75V5.25C16.5 4.42157 15.8284 3.75 15 3.75Z", stroke: common.SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M1.5 7.5H16.5", stroke: common.SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
1834
+ var usePlugins = function (_a) {
1835
+ var entityId = _a.entityId, apiHost = _a.apiHost, token = _a.token;
1836
+ var response = reactQuery.useQuery({
1837
+ queryKey: common.QueryKeyFactory.default.pluginsKey,
1838
+ queryFn: function () {
1839
+ var plugins = common.getPlugins({
1840
+ entityId: entityId,
1841
+ token: token,
1842
+ apiHost: apiHost,
1843
+ });
1844
+ return plugins;
1845
+ },
1846
+ enabled: Boolean(entityId),
1847
+ });
1848
+ return response;
1806
1849
  };
1807
1850
 
1808
- var Text$d = antd.Typography.Text;
1809
- var PaymentOption = function (_a) {
1810
- var selected = _a.selected, paymentOption = _a.paymentOption, onClick = _a.onClick, name = _a.name;
1811
- var brandColor = React.useContext(BrandContext).brandColor;
1812
- var darkMode = React.useContext(BunnyContext).darkMode;
1813
- var isAch = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("ach");
1814
- var isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("card");
1815
- return (jsxRuntime.jsxs(PaymentOptionContainer, __assign({ "$brandColor": brandColor, "$selected": selected, className: "flex justify-between items-center w-full cursor-pointer py-2 px-4 rounded border-solid ".concat(darkMode
1816
- ? "var(--row-background-dark) border-gray-500"
1817
- : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentOption); } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsxRuntime.jsx(Text$d, { children: name })] })), isAch ? (jsxRuntime.jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsxRuntime.jsx(CardIcon, {})) : (jsxRuntime.jsx(CardIcon, {}))] })));
1851
+ var filterPaymentPlugins = function (plugins) {
1852
+ return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
1853
+ var _a, _b, _c, _d;
1854
+ return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "payment" &&
1855
+ ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === "valid" &&
1856
+ ((_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d.length);
1857
+ });
1858
+ };
1859
+ var usePaymentPlugins = function (_a) {
1860
+ var entityId = _a.entityId, apiHost = _a.apiHost, token = _a.token;
1861
+ var _b = usePlugins({
1862
+ entityId: entityId,
1863
+ apiHost: apiHost,
1864
+ token: token,
1865
+ }), plugins = _b.data, isFetched = _b.isFetched;
1866
+ var paymentPlugins = filterPaymentPlugins(Array.isArray(plugins) ? plugins : []);
1867
+ var paymentMethodAllowedPlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.filter(function (plugin) {
1868
+ var _a, _b;
1869
+ return (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b.some(function (component) { var _a; return (_a = component === null || component === void 0 ? void 0 : component.scenarios) === null || _a === void 0 ? void 0 : _a.includes("admin-payment_method"); });
1870
+ });
1871
+ return {
1872
+ paymentPlugins: paymentPlugins,
1873
+ paymentMethodAllowedPlugins: paymentMethodAllowedPlugins,
1874
+ isFetched: isFetched,
1875
+ };
1818
1876
  };
1819
- var PaymentOptionContainer = styled__default["default"].div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"], ["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"])), function (_a) {
1820
- var $brandColor = _a.$brandColor, $selected = _a.$selected;
1821
- return $selected &&
1822
- "\n border-color: ".concat($brandColor, ";\n ");
1823
- }, function (_a) {
1824
- var $brandColor = _a.$brandColor;
1825
- return $brandColor;
1826
- });
1827
- var templateObject_1$7;
1828
1877
 
1829
- var PaymentMethodSelector = function (_a) {
1830
- var _b, _c;
1831
- var paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins, onSelect = _a.onSelect, showStoredPaymentMethodOption = _a.showStoredPaymentMethodOption, value = _a.value;
1832
- var graphQLClient = React.useContext(BunnyContext).graphQLClient;
1833
- var storedPaymentMethod = usePaymentMethod(graphQLClient).data;
1834
- return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [showStoredPaymentMethodOption && storedPaymentMethod && (jsxRuntime.jsx(PaymentOption, { name: (_b = storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.metadata) === null || _b === void 0 ? void 0 : _b.description, onClick: onSelect, selected: (value === null || value === void 0 ? void 0 : value.id) === storedPaymentMethod.id &&
1835
- ((_c = value === null || value === void 0 ? void 0 : value.metadata) === null || _c === void 0 ? void 0 : _c.identifier) ===
1836
- storedPaymentMethod.metadata.identifier, paymentOption: storedPaymentMethod })), paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsxRuntime.jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentOption: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); })] })));
1878
+ // Simulated payment creation and confirmation
1879
+ var confirmPayment = function (_a) {
1880
+ var amount = _a.amount, currency = _a.currency;
1881
+ return { token: "DemoPayTestToken", amount: amount, currency: currency };
1882
+ };
1883
+ var DIGIT_REGEX = /\d/;
1884
+ var isDigit = function (char) { return DIGIT_REGEX.test(char); };
1885
+ var isDeletion = function (char) { return [8, 46].includes(char); }; // Backspace or Delete
1886
+ var isNavigation = function (char) { return [9, 37, 38, 39, 40].includes(char); }; // Tab, Arrows
1887
+ var isModifier = function (char) { return [16, 17, 18].includes(char); }; // Shift, Ctrl, Alt
1888
+ var isValidKey = function (code) {
1889
+ return isDeletion(code) || isNavigation(code) || isModifier(code);
1890
+ };
1891
+ var isValidExpiry = function (expiry) {
1892
+ var month = parseInt(expiry.substring(0, 2), 10);
1893
+ var year = parseInt(expiry.substring(2, 4), 10) + 2000;
1894
+ if (isNaN(month) || isNaN(year))
1895
+ return false;
1896
+ if (month < 1 || month > 12)
1897
+ return false;
1898
+ return true;
1899
+ };
1900
+ var isCardExpired = function (expiry) {
1901
+ var month = parseInt(expiry.substring(0, 2), 10);
1902
+ var year = parseInt(expiry.substring(2, 4), 10) + 2000;
1903
+ var expiryDate = new Date(year, month, 1);
1904
+ return expiryDate < new Date();
1905
+ };
1906
+ var formatCardExpiry = function (cardExpiry) {
1907
+ if (cardExpiry.length <= 2)
1908
+ return cardExpiry;
1909
+ return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
1910
+ };
1911
+ // removes spaces from a credit card number
1912
+ var unformatCardNumber = function (cardNumber) {
1913
+ var cardNumberArray = cardNumber.split("");
1914
+ var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
1915
+ return unformattedCardNumberArray.join("");
1837
1916
  };
1917
+ var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
1918
+ var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
1919
+ return __generator(this, function (_a) {
1920
+ switch (_a.label) {
1921
+ case 0:
1922
+ testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
1923
+ return [4 /*yield*/, common.invokePlugin({
1924
+ method: "store_payment_method",
1925
+ plugin: plugin,
1926
+ payload: {
1927
+ test_credit_card_number: testCreditCardNumber,
1928
+ test_credit_card_cvc: testCreditCardCvc,
1929
+ test_credit_card_expiration_date: testCreditCardExpirationDate,
1930
+ account_id: accountId,
1931
+ },
1932
+ token: token,
1933
+ apiHost: apiHost,
1934
+ })];
1935
+ case 1:
1936
+ response = _a.sent();
1937
+ if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
1938
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
1939
+ return [2 /*return*/, response];
1940
+ }
1941
+ });
1942
+ }); };
1943
+
1944
+ function usePay$1(_a) {
1945
+ var _this = this;
1946
+ var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice;
1947
+ var pay = function (_a) {
1948
+ var plugin = _a.plugin, savePaymentMethod = _a.savePaymentMethod;
1949
+ return __awaiter(_this, void 0, void 0, function () {
1950
+ var amountDue, currencyId, response;
1951
+ return __generator(this, function (_b) {
1952
+ amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
1953
+ currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
1954
+ if (!amountDue || !currencyId) {
1955
+ throw new Error("No amount or currencyId");
1956
+ }
1957
+ try {
1958
+ response = confirmPayment({
1959
+ amount: amountDue,
1960
+ currency: currencyId,
1961
+ });
1962
+ onPaymentSuccess({
1963
+ pluginPaymentResponse: {
1964
+ plugin: plugin,
1965
+ token: response.token,
1966
+ savePaymentMethod: savePaymentMethod,
1967
+ },
1968
+ });
1969
+ }
1970
+ catch (error) {
1971
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error);
1972
+ }
1973
+ return [2 /*return*/];
1974
+ });
1975
+ });
1976
+ };
1977
+ return { pay: pay };
1978
+ }
1838
1979
 
1839
1980
  var createPaymentMethod = function (_a) {
1840
1981
  var paymentMethodId = _a.paymentMethodId, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
@@ -1873,7 +2014,7 @@ var createSetupIntent = function (plugin, token, apiHost, accountId) {
1873
2014
  });
1874
2015
  };
1875
2016
  var createPaymentIntent = function (_a) {
1876
- var payable = _a.payable, savePaymentMethod = _a.savePaymentMethod, memo = _a.memo, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
2017
+ var payable = _a.payable, savePaymentMethod = _a.savePaymentMethod, memo = _a.memo, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost;
1877
2018
  return __awaiter(void 0, void 0, void 0, function () {
1878
2019
  var payload, response;
1879
2020
  return __generator(this, function (_b) {
@@ -1883,7 +2024,6 @@ var createPaymentIntent = function (_a) {
1883
2024
  payable_id: payable.payableId,
1884
2025
  save_payment_method: savePaymentMethod,
1885
2026
  memo: memo,
1886
- account_id: accountId,
1887
2027
  };
1888
2028
  return [4 /*yield*/, common.invokePlugin({
1889
2029
  plugin: plugin,
@@ -1901,21 +2041,37 @@ var createPaymentIntent = function (_a) {
1901
2041
  });
1902
2042
  });
1903
2043
  };
1904
- var fetchStripeKey = function (plugin, token, apiHost, accountId) {
1905
- return common.invokePlugin({
1906
- plugin: plugin,
1907
- method: "retrieve_config",
1908
- token: token,
1909
- apiHost: apiHost,
1910
- payload: {
1911
- account_id: accountId,
1912
- },
2044
+ var fetchStripeKey = function (plugin, token, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2045
+ var response;
2046
+ return __generator(this, function (_a) {
2047
+ switch (_a.label) {
2048
+ case 0: return [4 /*yield*/, common.invokePlugin({
2049
+ plugin: plugin,
2050
+ method: "retrieve_config",
2051
+ token: token,
2052
+ apiHost: apiHost,
2053
+ payload: {
2054
+ account_id: accountId,
2055
+ },
2056
+ })];
2057
+ case 1:
2058
+ response = _a.sent();
2059
+ return [2 /*return*/, response];
2060
+ }
1913
2061
  });
1914
- };
2062
+ }); };
1915
2063
  pure.loadStripe.setLoadParameters({ advancedFraudSignals: false });
1916
2064
  var useStripePlugin = function (plugin, token, apiHost, accountId) {
1917
2065
  var _a = React.useState(null), stripe = _a[0], setStripe = _a[1];
1918
2066
  var showErrorNotification = common.useErrorNotification();
2067
+ var options = {
2068
+ mode: "setup",
2069
+ // TODO: Fetch currency from the entity/account
2070
+ currency: "usd",
2071
+ setupFutureUsage: "off_session",
2072
+ };
2073
+ if (!plugin)
2074
+ return { stripe: null, options: options };
1919
2075
  React.useEffect(function () {
1920
2076
  fetchStripeKey(plugin, token, apiHost || "", accountId)
1921
2077
  .then(function (_a) {
@@ -1928,293 +2084,253 @@ var useStripePlugin = function (plugin, token, apiHost, accountId) {
1928
2084
  });
1929
2085
  // eslint-disable-next-line
1930
2086
  }, [plugin, token]);
1931
- return stripe;
1932
- };
1933
-
1934
- var PaymentContext = React.createContext({});
1935
-
1936
- var CheckoutFooter = function (_a) {
1937
- var amountDue = _a.amountDue, currencyId = _a.currencyId, isSaving = _a.isSaving, onPaymentSubmit = _a.onPaymentSubmit, onlySavePaymentMethod = _a.onlySavePaymentMethod, noPadding = _a.noPadding;
1938
- React.useContext(BunnyContext).window;
1939
- var isMobile = common.useIsMobile();
1940
- var displayPayButtonNameAnyways = React.useContext(PaymentContext).displayPayButtonNameAnyways;
1941
- var buttonName = function () {
1942
- return onlySavePaymentMethod && !displayPayButtonNameAnyways
1943
- ? isSaving
1944
- ? "Saving"
1945
- : "Save"
1946
- : isSaving
1947
- ? "Paying"
1948
- : "Pay";
1949
- };
1950
- return (jsxRuntime.jsx("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "w-full", disabled: isSaving, onClick: onPaymentSubmit, size: isMobile ? "large" : "middle", type: "primary" }, { children: "".concat(buttonName()).concat(amountDue && currencyId
1951
- ? " ".concat(common.formatCurrency(amountDue, currencyId))
1952
- : "") })) })));
2087
+ return { stripe: stripe, options: options };
1953
2088
  };
1954
2089
 
1955
- var CheckoutForm = function (_a) {
1956
- var payable = _a.payable, plugin = _a.plugin, isSaving = _a.isSaving, setIsSaving = _a.setIsSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess;
2090
+ function usePay(_a) {
2091
+ var _this = this;
2092
+ var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice;
1957
2093
  // Hooks
1958
2094
  var elements = reactStripeJs.useElements();
1959
2095
  var stripe = reactStripeJs.useStripe();
1960
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, accountId = _b.accountId;
1961
- if (!payable)
1962
- throw new Error("A Payable is required to start checkout");
1963
- // Handlers
1964
- var onPaymentSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
1965
- var submitError, paymentIntent, clientSecret, response, paymentIntentId, error_1;
2096
+ var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2097
+ var pay = function (_a) {
2098
+ var plugin = _a.plugin;
2099
+ return __awaiter(_this, void 0, void 0, function () {
2100
+ var payable, submitError, paymentIntent, clientSecret, response, paymentIntentId, error_1;
2101
+ var _b;
2102
+ return __generator(this, function (_c) {
2103
+ switch (_c.label) {
2104
+ case 0:
2105
+ payable = (quote || invoice);
2106
+ _c.label = 1;
2107
+ case 1:
2108
+ _c.trys.push([1, 5, , 6]);
2109
+ if (!stripe)
2110
+ throw new Error("Form is not ready");
2111
+ if (!elements)
2112
+ throw new Error("Elements couldn't be retrieved");
2113
+ return [4 /*yield*/, elements.submit()];
2114
+ case 2:
2115
+ submitError = (_c.sent()).error;
2116
+ if (submitError)
2117
+ throw new Error(submitError.message);
2118
+ return [4 /*yield*/, createPaymentIntent({
2119
+ payable: payable,
2120
+ savePaymentMethod: true,
2121
+ plugin: plugin,
2122
+ token: token,
2123
+ apiHost: apiHost || "",
2124
+ })];
2125
+ case 3:
2126
+ paymentIntent = _c.sent();
2127
+ clientSecret = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.client_secret;
2128
+ return [4 /*yield*/, stripe.confirmPayment({
2129
+ elements: elements,
2130
+ clientSecret: clientSecret,
2131
+ redirect: "if_required",
2132
+ confirmParams: {
2133
+ return_url: window.location.href,
2134
+ },
2135
+ })];
2136
+ case 4:
2137
+ response = _c.sent();
2138
+ // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
2139
+ if (response.error)
2140
+ throw new Error(response.error.message);
2141
+ paymentIntentId = (_b = response.paymentIntent) === null || _b === void 0 ? void 0 : _b.id;
2142
+ if (!paymentIntentId)
2143
+ throw new Error("Payment intent couldn't be retrieved");
2144
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess({
2145
+ pluginPaymentResponse: {
2146
+ plugin: plugin,
2147
+ token: paymentIntentId,
2148
+ savePaymentMethod: true,
2149
+ },
2150
+ });
2151
+ return [3 /*break*/, 6];
2152
+ case 5:
2153
+ error_1 = _c.sent();
2154
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error_1);
2155
+ return [3 /*break*/, 6];
2156
+ case 6: return [2 /*return*/];
2157
+ }
2158
+ });
2159
+ });
2160
+ };
2161
+ return { pay: pay };
2162
+ }
2163
+
2164
+ var showErrorNotification$1 = common.useErrorNotification();
2165
+ var ActualCheckoutFooter = function (_a) {
2166
+ var quote = _a.quote, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, noPadding = _a.noPadding, plugin = _a.plugin;
2167
+ var isMobile = common.useIsMobile();
2168
+ var _b = React.useState(false), isPaying = _b[0], setIsPaying = _b[1];
2169
+ var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
2170
+ var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
2171
+ // Payment hooks
2172
+ var payDemoPay = usePay$1({
2173
+ onPaymentSuccess: function (response) {
2174
+ onPaymentSuccess(response);
2175
+ },
2176
+ onPaymentError: function (error) {
2177
+ setIsPaying(false);
2178
+ showErrorNotification$1(error);
2179
+ },
2180
+ quote: quote,
2181
+ invoice: invoice,
2182
+ }).pay;
2183
+ var payStripe = usePay({
2184
+ onPaymentSuccess: function (response) {
2185
+ onPaymentSuccess(response);
2186
+ },
2187
+ onPaymentError: function (error) {
2188
+ setIsPaying(false);
2189
+ showErrorNotification$1(error);
2190
+ },
2191
+ quote: quote,
2192
+ invoice: invoice,
2193
+ }).pay;
2194
+ var handlePaymentSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
1966
2195
  var _a;
1967
- return __generator(this, function (_b) {
1968
- switch (_b.label) {
2196
+ var _b, _c;
2197
+ return __generator(this, function (_d) {
2198
+ switch (_d.label) {
1969
2199
  case 0:
1970
- _b.trys.push([0, 4, , 5]);
1971
- if (!stripe)
1972
- throw new Error("Form is not ready");
1973
- if (!elements)
1974
- throw new Error("Elements couldn't be retrieved");
1975
- setIsSaving(true);
1976
- return [4 /*yield*/, elements.submit()];
1977
- case 1:
1978
- submitError = (_b.sent()).error;
1979
- if (submitError)
1980
- throw new Error(submitError.message);
1981
- return [4 /*yield*/, createPaymentIntent({
1982
- payable: payable,
1983
- savePaymentMethod: true,
1984
- plugin: plugin,
1985
- token: token,
1986
- apiHost: apiHost || "",
1987
- accountId: accountId,
1988
- })];
1989
- case 2:
1990
- paymentIntent = _b.sent();
1991
- clientSecret = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.client_secret;
1992
- return [4 /*yield*/, stripe.confirmPayment({
1993
- elements: elements,
1994
- clientSecret: clientSecret,
1995
- redirect: "if_required",
1996
- confirmParams: {
1997
- return_url: window.location.href,
1998
- },
1999
- })];
2000
- case 3:
2001
- response = _b.sent();
2002
- // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
2003
- if (response.error)
2004
- throw new Error(response.error.message);
2005
- paymentIntentId = (_a = response.paymentIntent) === null || _a === void 0 ? void 0 : _a.id;
2006
- if (!paymentIntentId)
2007
- throw new Error("Payment intent couldn't be retrieved");
2008
- onPaymentSuccess({
2009
- pluginPaymentResponse: {
2010
- plugin: plugin,
2011
- token: paymentIntentId,
2012
- savePaymentMethod: true,
2013
- },
2014
- });
2200
+ if (!plugin)
2201
+ return [2 /*return*/];
2202
+ _a = (_c = (_b = plugin === null || plugin === void 0 ? void 0 : plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name;
2203
+ switch (_a) {
2204
+ case "StripePayment": return [3 /*break*/, 1];
2205
+ case "DemoPayPayment": return [3 /*break*/, 3];
2206
+ }
2015
2207
  return [3 /*break*/, 5];
2208
+ case 1: return [4 /*yield*/, payStripe({
2209
+ plugin: plugin,
2210
+ })];
2211
+ case 2:
2212
+ _d.sent();
2213
+ return [3 /*break*/, 6];
2214
+ case 3: return [4 /*yield*/, payDemoPay({
2215
+ plugin: plugin,
2216
+ savePaymentMethod: false,
2217
+ })];
2016
2218
  case 4:
2017
- error_1 = _b.sent();
2018
- onFail(error_1);
2019
- return [3 /*break*/, 5];
2020
- case 5: return [2 /*return*/];
2219
+ _d.sent();
2220
+ return [3 /*break*/, 6];
2221
+ case 5: return [3 /*break*/, 6];
2222
+ case 6: return [2 /*return*/];
2021
2223
  }
2022
2224
  });
2023
2225
  }); };
2024
- var options = {
2025
- // defaultValues: {
2026
- // billingDetails: {
2027
- // email: currentUser.email,
2028
- // name: currentUser.name,
2029
- // phone: currentUser.phone,
2030
- // },
2031
- // },
2032
- layout: { type: "accordion" },
2033
- };
2034
- return (jsxRuntime.jsxs("form", { children: [jsxRuntime.jsx(reactStripeJs.PaymentElement, { options: options }), jsxRuntime.jsx(CheckoutFooter, { amountDue: payable.amountDue, currencyId: payable.currencyId.toLowerCase(), isSaving: isSaving, onPaymentSubmit: onPaymentSubmit, onlySavePaymentMethod: false })] }));
2226
+ return (jsxRuntime.jsx("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "w-full", disabled: isPaying, onClick: function () {
2227
+ setIsPaying(true);
2228
+ handlePaymentSubmit();
2229
+ }, size: isMobile ? "large" : "middle", type: "primary" }, { children: "".concat(isPaying ? "Paying" : "Pay", " ").concat(amountDue && currencyId ? common.formatCurrency(amountDue, currencyId) : "") })) })));
2035
2230
  };
2036
-
2037
- var PaymentMethodForm$1 = function (_a) {
2038
- var isSaving = _a.isSaving, setIsSaving = _a.setIsSaving, plugin = _a.plugin, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess;
2039
- // Hooks
2040
- var elements = reactStripeJs.useElements();
2041
- var stripe = reactStripeJs.useStripe();
2042
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2231
+ var CheckoutFooter = function (_a) {
2232
+ var _b, _c;
2233
+ var quote = _a.quote, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, noPadding = _a.noPadding, plugin = _a.plugin;
2234
+ if (!plugin)
2235
+ return null;
2236
+ var _d = React.useContext(BunnyContext), token = _d.token, apiHost = _d.apiHost;
2043
2237
  var accountId = React.useContext(PaymentContext).accountId;
2044
- // Handlers
2045
- var onSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
2046
- var submitError, response, clientSecret, intentResponse, paymentMethodId, paymentMethodResponse, error_1;
2047
- var _a, _b;
2048
- return __generator(this, function (_c) {
2049
- switch (_c.label) {
2050
- case 0:
2051
- _c.trys.push([0, 5, , 6]);
2052
- if (!stripe)
2053
- throw new Error("Form is not ready");
2054
- if (!elements)
2055
- throw new Error("Elements couldn't be retrieved");
2056
- setIsSaving(true);
2057
- return [4 /*yield*/, elements.submit()];
2058
- case 1:
2059
- submitError = (_c.sent()).error;
2060
- if (submitError)
2061
- throw new Error(submitError.message);
2062
- return [4 /*yield*/, createSetupIntent(plugin, token, apiHost, accountId)];
2063
- case 2:
2064
- response = _c.sent();
2065
- if (response.status !== "success")
2066
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
2067
- clientSecret = (_a = response === null || response === void 0 ? void 0 : response.payload) === null || _a === void 0 ? void 0 : _a.client_secret;
2068
- if (!clientSecret)
2069
- throw new Error("Error retrieving client secret");
2070
- return [4 /*yield*/, stripe.confirmSetup({
2071
- elements: elements,
2072
- clientSecret: clientSecret,
2073
- redirect: "if_required",
2074
- confirmParams: {
2075
- return_url: window.location.href,
2076
- },
2077
- })];
2078
- case 3:
2079
- intentResponse = _c.sent();
2080
- // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
2081
- if (intentResponse.error)
2082
- throw new Error(intentResponse.error.message);
2083
- paymentMethodId = (_b = intentResponse.setupIntent.payment_method) === null || _b === void 0 ? void 0 : _b.toString();
2084
- if (!paymentMethodId)
2085
- throw new Error("Payment method couldn't be retrieved");
2086
- return [4 /*yield*/, createPaymentMethod({
2087
- paymentMethodId: paymentMethodId,
2088
- plugin: plugin,
2089
- token: token,
2090
- apiHost: apiHost,
2091
- accountId: accountId,
2092
- })];
2093
- case 4:
2094
- paymentMethodResponse = _c.sent();
2095
- onPaymentSuccess({
2096
- pluginPaymentResponse: {
2097
- savePaymentMethod: true,
2098
- plugin: plugin,
2099
- token: paymentMethodResponse.token,
2100
- },
2101
- savedPaymentMethodResponse: {
2102
- paymentMethodId: paymentMethodResponse.payload[0].id,
2103
- },
2104
- });
2105
- return [3 /*break*/, 6];
2106
- case 5:
2107
- error_1 = _c.sent();
2108
- onFail(error_1);
2109
- return [3 /*break*/, 6];
2110
- case 6: return [2 /*return*/];
2111
- }
2112
- });
2113
- }); };
2114
- return (jsxRuntime.jsxs("form", { children: [jsxRuntime.jsx(reactStripeJs.PaymentElement, { options: { layout: { type: "accordion" } } }), jsxRuntime.jsx(CheckoutFooter, { isSaving: isSaving, onPaymentSubmit: onSubmit, onlySavePaymentMethod: true })] }));
2238
+ // If plugin is not stripe, pass undefined to prevent errors
2239
+ var stripePlugin = ((_c = (_b = plugin === null || plugin === void 0 ? void 0 : plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name) === "StripePayment"
2240
+ ? plugin
2241
+ : undefined;
2242
+ var _e = useStripePlugin(stripePlugin, token, apiHost, accountId), stripe = _e.stripe, options = _e.options;
2243
+ return (jsxRuntime.jsx(reactStripeJs.Elements, __assign({ options: options, stripe: stripe }, { children: jsxRuntime.jsx(ActualCheckoutFooter, { plugin: plugin, invoice: invoice, quote: quote, onPaymentSuccess: onPaymentSuccess, noPadding: noPadding }) })));
2115
2244
  };
2116
2245
 
2117
- // This is just a wrapper to fetch the stripe object and pass it to the form
2118
- var StripeForm = function (_a) {
2119
- var entityId = _a.entityId, payable = _a.payable, plugin = _a.plugin, isSaving = _a.isSaving, setIsSaving = _a.setIsSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess;
2120
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2121
- var accountId = React.useContext(PaymentContext).accountId;
2122
- var stripe = useStripePlugin(plugin, token, apiHost, accountId);
2123
- var onlySavePaymentMethod = !payable;
2124
- if (!stripe)
2125
- return null;
2126
- // Ideally this choice should be made way up in the chain,
2127
- // were we enter into either PaymentMethod Management or Payable Checkout
2128
- // Probably around Pages/PaymentMethodForm.tsx and Checkout.tsx
2129
- if (onlySavePaymentMethod) {
2130
- var options = {
2131
- mode: "setup",
2132
- // TODO: Fetch currency from the entity/account
2133
- currency: "usd",
2134
- setupFutureUsage: "off_session",
2135
- };
2136
- return (jsxRuntime.jsx(reactStripeJs.Elements, __assign({ options: options, stripe: stripe }, { children: jsxRuntime.jsx(PaymentMethodForm$1, { entityId: entityId, isSaving: isSaving, setIsSaving: setIsSaving, plugin: plugin, onFail: onFail, onPaymentSuccess: onPaymentSuccess }) })));
2137
- }
2138
- else {
2139
- var options = {
2140
- mode: "payment",
2141
- amount: payable === null || payable === void 0 ? void 0 : payable.smallUnitAmountDue,
2142
- currency: payable === null || payable === void 0 ? void 0 : payable.currencyId.toLowerCase(),
2143
- setupFutureUsage: "off_session",
2144
- };
2145
- return (jsxRuntime.jsx(reactStripeJs.Elements, __assign({ options: options, stripe: stripe }, { children: jsxRuntime.jsx(CheckoutForm, { entityId: entityId, payable: payable, plugin: plugin, isSaving: isSaving, setIsSaving: setIsSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess }) })));
2146
- }
2246
+ var dayjs_min = {exports: {}};
2247
+
2248
+ (function (module, exports) {
2249
+ !function(t,e){module.exports=e();}(commonjsGlobal,(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}));
2250
+ }(dayjs_min));
2251
+
2252
+ var dayjs = dayjs_min.exports;
2253
+
2254
+ var Card = function (_a) {
2255
+ var children = _a.children, className = _a.className, style = _a.style;
2256
+ var darkMode = React.useContext(BunnyContext).darkMode;
2257
+ return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col rounded-md shadow-md ".concat(className), style: __assign(__assign({}, style), { backgroundColor: darkMode
2258
+ ? "var(--row-background-dark)"
2259
+ : "var(--row-background)" }) }, { children: children })));
2147
2260
  };
2148
2261
 
2149
- var getQuoteAmountDue = function (quote) {
2150
- return quote.amountDue;
2262
+ var LargeCardIcon = function () {
2263
+ return (jsxRuntime.jsx("svg", __assign({ width: "72", height: "56", viewBox: "0 0 72 56", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: jsxRuntime.jsx("path", { d: "M8 0H64C68.375 0 72 3.625 72 8V12H0V8C0 3.625 3.5 0 8 0ZM72 24V48C72 52.5 68.375 56 64 56H8C3.5 56 0 52.5 0 48V24H72ZM14 40C12.875 40 12 41 12 42C12 43.125 12.875 44 14 44H22C23 44 24 43.125 24 42C24 41 23 40 22 40H14ZM28 42C28 43.125 28.875 44 30 44H46C47 44 48 43.125 48 42C48 41 47 40 46 40H30C28.875 40 28 41 28 42Z", fill: "#E2E8F0" }) })));
2151
2264
  };
2152
2265
 
2153
- // Simulated payment creation and confirmation
2154
- var confirmPayment = function (_a) {
2155
- var amount = _a.amount, currency = _a.currency, cardDetails = _a.cardDetails;
2156
- return { token: "DemoPayTestToken", amount: amount, currency: currency, cardDetails: cardDetails };
2266
+ var PlusIcon = function (_a) {
2267
+ var color = _a.color;
2268
+ return (jsxRuntime.jsxs("svg", __assign({ width: "14", height: "15", viewBox: "0 0 14 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsx("path", { d: "M2.9165 7.5H11.0832", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M7 3.41663V11.5833", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
2157
2269
  };
2158
- var DIGIT_REGEX = /\d/;
2159
- var isDigit = function (char) { return DIGIT_REGEX.test(char); };
2160
- var isDeletion = function (char) { return [8, 46].includes(char); }; // Backspace or Delete
2161
- var isNavigation = function (char) { return [9, 37, 38, 39, 40].includes(char); }; // Tab, Arrows
2162
- var isModifier = function (char) { return [16, 17, 18].includes(char); }; // Shift, Ctrl, Alt
2163
- var isValidKey = function (code) {
2164
- return isDeletion(code) || isNavigation(code) || isModifier(code);
2270
+
2271
+ var Text$f = antd.Typography.Text;
2272
+ var CreditCard = function (_a) {
2273
+ var _b;
2274
+ var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, _d = _a.cardEnabled, cardEnabled = _d === void 0 ? true : _d;
2275
+ var isMobile = common.useIsMobile();
2276
+ var Wrapper = cardEnabled ? Card : "div";
2277
+ return (jsxRuntime.jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsxRuntime.jsx(CardImage, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.description })] })), jsxRuntime.jsx(antd.Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsxRuntime.jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(antd.Divider, {}), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsxRuntime.jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsxRuntime.jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
2165
2278
  };
2166
- var isValidExpiry = function (expiry) {
2167
- var month = parseInt(expiry.substring(0, 2), 10);
2168
- var year = parseInt(expiry.substring(2, 4), 10) + 2000;
2169
- if (isNaN(month) || isNaN(year))
2170
- return false;
2171
- if (month < 1 || month > 12)
2172
- return false;
2173
- return true;
2279
+ var MiniCreditCard = function (_a) {
2280
+ var _b;
2281
+ var _c = _a.hideRemoveButton, hideRemoveButton = _c === void 0 ? false : _c, onClickRemove = _a.onClickRemove, paymentMethodData = _a.paymentMethodData;
2282
+ var darkMode = React.useContext(BunnyContext).darkMode;
2283
+ var borderColor = React.useMemo(function () {
2284
+ return darkMode ? "border-slate-700" : "border-slate-200";
2285
+ }, [darkMode]);
2286
+ var backgroundColor = React.useMemo(function () {
2287
+ return darkMode ? "var(--row-background-alternate)" : "bg-slate-50";
2288
+ }, [darkMode]);
2289
+ return (jsxRuntime.jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-row gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsxRuntime.jsx(CardImage, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.description })] })), jsxRuntime.jsx(antd.Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), jsxRuntime.jsx("div", __assign({ className: "flex flex-row gap-1 items-center" }, { children: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$f, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "EXP" })), jsxRuntime.jsx(Text$f, { children: expirationDate(paymentMethodData) })] })) }))] })), !hideRemoveButton && (jsxRuntime.jsx(antd.Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxRuntime.jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsxRuntime.jsx(CreditCardOutlined$1, {}), jsxRuntime.jsx(Text$f, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "No payment method selected" })), jsxRuntime.jsx(antd.Button, { disabled: true, type: "link" })] }))) })));
2290
+ };
2291
+ var CardImage = function (_a) {
2292
+ var _b, _c;
2293
+ var paymentMethodData = _a.paymentMethodData;
2294
+ var apiHost = React.useContext(BunnyContext).apiHost;
2295
+ var darkMode = React.useContext(BunnyContext).darkMode;
2296
+ var getCardImage = function (issuer) {
2297
+ if (issuer === "visa")
2298
+ return "Visa_Brandmark_Blue_RGB_2021.png";
2299
+ else if (issuer === "mastercard")
2300
+ return "mc_symbol_opt_73_3x.png";
2301
+ };
2302
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: getCardImage((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) && (jsxRuntime.jsx("img", { alt: "Card", width: "24px", src: "".concat(apiHost, "/portal/").concat(getCardImage((_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.issuer)), style: {
2303
+ color: darkMode ? "white" : "",
2304
+ } })) }));
2174
2305
  };
2175
- var isCardExpired = function (expiry) {
2176
- var month = parseInt(expiry.substring(0, 2), 10);
2177
- var year = parseInt(expiry.substring(2, 4), 10) + 2000;
2178
- var expiryDate = new Date(year, month, 1);
2179
- return expiryDate < new Date();
2306
+ var CardAttribute = function (_a) {
2307
+ var title = _a.title, value = _a.value;
2308
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsxRuntime.jsx(Text$f, { children: value })] })));
2180
2309
  };
2181
- var formatCardExpiry = function (cardExpiry) {
2182
- if (cardExpiry.length <= 2)
2183
- return cardExpiry;
2184
- return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
2310
+ var CardActions = function (_a) {
2311
+ var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
2312
+ var isMobile = common.useIsMobile();
2313
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-6 ".concat(isMobile ? "justify-center mt-4" : "") }, { children: [jsxRuntime.jsx(antd.Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove payment method" })) })), jsxRuntime.jsx(antd.Divider, { style: { height: "24px" }, type: "vertical" }), jsxRuntime.jsx(antd.Button, __assign({ onClick: onClickUpdate, type: "primary" }, { children: "Update" }))] })));
2185
2314
  };
2186
- // removes spaces from a credit card number
2187
- var unformatCardNumber = function (cardNumber) {
2188
- var cardNumberArray = cardNumber.split("");
2189
- var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
2190
- return unformattedCardNumberArray.join("");
2315
+ var EmptyCard = function (_a) {
2316
+ var onClick = _a.onClick, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, _c = _a.cardEnabled, cardEnabled = _c === void 0 ? true : _c;
2317
+ var brandColor = React.useContext(BrandContext).brandColor;
2318
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center w-full pt-8 px-4 pb-6 cursor-pointer ".concat(cardEnabled ? "bg-white ".concat(shadow, " rounded-md") : ""), onClick: onClick }, { children: [jsxRuntime.jsx(LargeCardIcon, {}), jsxRuntime.jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsxRuntime.jsx(antd.Button, __assign({ type: "link" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsxRuntime.jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
2319
+ };
2320
+ var isExpired = function (paymentMethodData) {
2321
+ var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
2322
+ return expDate.isBefore(dayjs());
2323
+ };
2324
+ var expirationDate = function (storedPaymentMethod) {
2325
+ return dayjs(storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.expirationDate).format("MM/YY");
2326
+ };
2327
+
2328
+ var SavePaymentMethodFooter = function (_a) {
2329
+ var isSaving = _a.isSaving, onSave = _a.onSave, noPadding = _a.noPadding;
2330
+ var isMobile = common.useIsMobile();
2331
+ var onClickCancel = React.useContext(PaymentContext).onClickCancel;
2332
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: [onClickCancel && (jsxRuntime.jsx(antd.Button, __assign({ className: "w-full", size: isMobile ? "large" : "middle", onClick: function () { return onClickCancel(); } }, { children: "Cancel" }))), jsxRuntime.jsx(antd.Button, __assign({ className: "w-full", disabled: isSaving, onClick: onSave, size: isMobile ? "large" : "middle", type: "primary" }, { children: isSaving ? "Saving" : "Save" }))] })));
2191
2333
  };
2192
- var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2193
- var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
2194
- return __generator(this, function (_a) {
2195
- switch (_a.label) {
2196
- case 0:
2197
- testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
2198
- return [4 /*yield*/, common.invokePlugin({
2199
- method: "store_payment_method",
2200
- plugin: plugin,
2201
- payload: {
2202
- test_credit_card_number: testCreditCardNumber,
2203
- test_credit_card_cvc: testCreditCardCvc,
2204
- test_credit_card_expiration_date: testCreditCardExpirationDate,
2205
- account_id: accountId,
2206
- },
2207
- token: token,
2208
- apiHost: apiHost,
2209
- })];
2210
- case 1:
2211
- response = _a.sent();
2212
- if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
2213
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
2214
- return [2 /*return*/, response];
2215
- }
2216
- });
2217
- }); };
2218
2334
 
2219
2335
  var DemoPayCardCvc = function (_a) {
2220
2336
  var autoFocus = _a.autoFocus, onChange = _a.onChange, placeholder = _a.placeholder, value = _a.value;
@@ -2259,83 +2375,95 @@ var DemoPayExpiry = function (_a) {
2259
2375
  return (jsxRuntime.jsx("div", __assign({ className: "grow" }, { children: jsxRuntime.jsx(antd.Input, { autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: formatCardExpiry(value), maxLength: 5, placeholder: placeholder || "MM/YY" }) })));
2260
2376
  };
2261
2377
 
2262
- var Text$c = antd.Typography.Text;
2378
+ function useSave$1(_a) {
2379
+ var _this = this;
2380
+ var onSaveSuccess = _a.onSaveSuccess, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
2381
+ var _b = React.useState(false), isSaving = _b[0], setIsSaving = _b[1];
2382
+ var save = function (_a) {
2383
+ var cardDetails = _a.cardDetails, plugin = _a.plugin, savePaymentMethod = _a.savePaymentMethod;
2384
+ return __awaiter(_this, void 0, void 0, function () {
2385
+ var response, paymentMethodId, error_1;
2386
+ return __generator(this, function (_b) {
2387
+ switch (_b.label) {
2388
+ case 0:
2389
+ _b.trys.push([0, 2, 3, 4]);
2390
+ setIsSaving(true);
2391
+ return [4 /*yield*/, storePayment({
2392
+ testCreditCardNumber: unformatCardNumber(cardDetails.number),
2393
+ testCreditCardCvc: cardDetails.cvc.toString(),
2394
+ testCreditCardExpirationDate: cardDetails.expiry,
2395
+ token: token,
2396
+ }, plugin, apiHost, accountId)];
2397
+ case 1:
2398
+ response = _b.sent();
2399
+ paymentMethodId = response.payload[0].id;
2400
+ if (response.status !== "success")
2401
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
2402
+ onSaveSuccess({
2403
+ pluginPaymentResponse: {
2404
+ plugin: plugin,
2405
+ token: response.token,
2406
+ savePaymentMethod: savePaymentMethod,
2407
+ },
2408
+ savedPaymentMethodResponse: {
2409
+ paymentMethodId: paymentMethodId,
2410
+ },
2411
+ });
2412
+ return [3 /*break*/, 4];
2413
+ case 2:
2414
+ error_1 = _b.sent();
2415
+ console.error("Payment failed", error_1);
2416
+ return [3 /*break*/, 4];
2417
+ case 3:
2418
+ setIsSaving(false);
2419
+ return [7 /*endfinally*/];
2420
+ case 4: return [2 /*return*/];
2421
+ }
2422
+ });
2423
+ });
2424
+ };
2425
+ return { save: save, isSaving: isSaving };
2426
+ }
2427
+
2428
+ var Text$e = antd.Typography.Text;
2263
2429
  var TEST_CARD = "4242424242424242";
2264
2430
  var DemoPayForm = function (_a) {
2265
- var isSaving = _a.isSaving, invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, plugin = _a.plugin, quote = _a.quote, setIsSaving = _a.setIsSaving;
2431
+ var onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod, plugin = _a.plugin;
2266
2432
  // Context
2267
2433
  var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, darkMode = _b.darkMode;
2268
2434
  var accountId = React.useContext(PaymentContext).accountId;
2269
- // Local state
2270
- var _c = React.useState(false), savePaymentMethod = _c[0], setSavePaymentMethod = _c[1];
2435
+ // Hooks
2436
+ var _c = useSave$1({
2437
+ onSaveSuccess: onSavePaymentMethod,
2438
+ token: token,
2439
+ apiHost: apiHost,
2440
+ accountId: accountId,
2441
+ }), save = _c.save, isSaving = _c.isSaving;
2271
2442
  var _d = React.useState({
2272
2443
  number: "4242424242424242",
2273
2444
  expiry: "",
2274
2445
  cvc: "",
2275
2446
  }), cardDetails = _d[0], setCardDetails = _d[1];
2276
- var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
2277
- var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
2278
- var onlySavePaymentMethod = !quote && !invoice;
2279
- var onPaymentSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
2280
- var response, paymentMethodId, response, error_1;
2447
+ var onSave = function () { return __awaiter(void 0, void 0, void 0, function () {
2448
+ var error_1;
2281
2449
  return __generator(this, function (_a) {
2282
2450
  switch (_a.label) {
2283
2451
  case 0:
2284
- _a.trys.push([0, 6, , 7]);
2285
- if (!onlySavePaymentMethod) return [3 /*break*/, 2];
2452
+ _a.trys.push([0, 2, , 3]);
2286
2453
  validateCardDetails();
2287
- setIsSaving(true);
2288
- return [4 /*yield*/, storePayment({
2289
- testCreditCardNumber: unformatCardNumber(cardDetails.number),
2290
- testCreditCardCvc: cardDetails.cvc.toString(),
2291
- testCreditCardExpirationDate: cardDetails.expiry,
2292
- token: token,
2293
- }, plugin, apiHost, accountId)];
2294
- case 1:
2295
- response = _a.sent();
2296
- paymentMethodId = response.payload[0].id;
2297
- if (response.status !== "success")
2298
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
2299
- onPaymentSuccess({
2300
- pluginPaymentResponse: {
2301
- plugin: plugin,
2302
- token: response.token,
2303
- savePaymentMethod: savePaymentMethod,
2304
- },
2305
- savedPaymentMethodResponse: {
2306
- paymentMethodId: paymentMethodId,
2307
- },
2308
- });
2309
- return [3 /*break*/, 5];
2310
- case 2:
2311
- if (!(amountDue !== undefined && currencyId)) return [3 /*break*/, 4];
2312
- validateCardDetails();
2313
- setIsSaving(true);
2314
- return [4 /*yield*/, confirmPayment({
2315
- amount: amountDue,
2316
- currency: currencyId,
2454
+ return [4 /*yield*/, save({
2317
2455
  cardDetails: cardDetails,
2318
- })];
2319
- case 3:
2320
- response = _a.sent();
2321
- onPaymentSuccess({
2322
- pluginPaymentResponse: {
2323
2456
  plugin: plugin,
2324
- token: response.token,
2325
- savePaymentMethod: savePaymentMethod,
2326
- },
2327
- });
2328
- setIsSaving(false);
2329
- return [3 /*break*/, 5];
2330
- case 4:
2331
- onFail(new Error("No amount or currencyId"));
2332
- _a.label = 5;
2333
- case 5: return [3 /*break*/, 7];
2334
- case 6:
2457
+ savePaymentMethod: false,
2458
+ })];
2459
+ case 1:
2460
+ _a.sent();
2461
+ return [3 /*break*/, 3];
2462
+ case 2:
2335
2463
  error_1 = _a.sent();
2336
2464
  onFail(error_1);
2337
- return [3 /*break*/, 7];
2338
- case 7: return [2 /*return*/];
2465
+ return [3 /*break*/, 3];
2466
+ case 3: return [2 /*return*/];
2339
2467
  }
2340
2468
  });
2341
2469
  }); };
@@ -2358,454 +2486,231 @@ var DemoPayForm = function (_a) {
2358
2486
  var onCardCvcChange = function (cvc) {
2359
2487
  setCardDetails(__assign(__assign({}, cardDetails), { cvc: cvc }));
2360
2488
  };
2361
- return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsxRuntime.jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxRuntime.jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsxRuntime.jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsxRuntime.jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsxRuntime.jsx(Text$c, __assign({ className: "text-xs" }, { children: "DemoPay is for testing only." })), !onlySavePaymentMethod && (jsxRuntime.jsx(antd.Checkbox, __assign({ className: "mt-2", onChange: function (e) { return setSavePaymentMethod(e.target.checked); } }, { children: "Save as primary payment method" }))), jsxRuntime.jsx(CheckoutFooter, { amountDue: amountDue, currencyId: currencyId, isSaving: isSaving, onPaymentSubmit: onPaymentSubmit, onlySavePaymentMethod: onlySavePaymentMethod })] })));
2489
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsxRuntime.jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxRuntime.jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsxRuntime.jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsxRuntime.jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsxRuntime.jsx(Text$e, __assign({ className: "text-xs" }, { children: "DemoPay is for testing only." })), jsxRuntime.jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] })));
2362
2490
  };
2363
- var StyledInputs = styled__default["default"].div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"], ["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"])), function (_a) {
2491
+ var StyledInputs = styled__default["default"].div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"], ["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"])), function (_a) {
2364
2492
  var darkMode = _a.darkMode;
2365
2493
  return darkMode ? "var(--row-background-dark)" : "white";
2366
2494
  }, function (_a) {
2367
2495
  var darkMode = _a.darkMode;
2368
2496
  return darkMode ? common.GRAY_500 : common.GRAY_200;
2369
2497
  });
2370
- var templateObject_1$6;
2498
+ var templateObject_1$7;
2371
2499
 
2372
- var finixStyles = function (isMobile) { return ({
2373
- default: {
2374
- color: common.CHARCOAL_GRAY,
2375
- border: "1px solid ".concat(common.INPUT_BORDER_COLOR),
2376
- padding: "4px 11px",
2377
- backgroundColor: "white",
2378
- fontSize: isMobile ? "16px" : "14px",
2379
- borderRadius: "4px",
2380
- },
2381
- success: {
2382
- color: common.CHARCOAL_GRAY, // specific styling if the field is valid
2383
- },
2384
- error: {
2385
- color: "#ff4d4f", // specific styling if the field has errors
2386
- },
2387
- }); };
2500
+ function useSave(_a) {
2501
+ var _this = this;
2502
+ var onSaveSuccess = _a.onSaveSuccess;
2503
+ // Hooks
2504
+ var _b = React.useState(false), isSaving = _b[0], setIsSaving = _b[1];
2505
+ var elements = reactStripeJs.useElements();
2506
+ var stripe = reactStripeJs.useStripe();
2507
+ var _c = React.useContext(BunnyContext), token = _c.token, apiHost = _c.apiHost;
2508
+ var accountId = React.useContext(PaymentContext).accountId;
2509
+ var save = function (_a) {
2510
+ var plugin = _a.plugin;
2511
+ return __awaiter(_this, void 0, void 0, function () {
2512
+ var submitError, response, clientSecret, intentResponse, paymentMethodId, paymentMethodResponse, error_1;
2513
+ var _b, _c;
2514
+ return __generator(this, function (_d) {
2515
+ switch (_d.label) {
2516
+ case 0:
2517
+ _d.trys.push([0, 5, 6, 7]);
2518
+ if (!stripe)
2519
+ throw new Error("Form is not ready");
2520
+ if (!elements)
2521
+ throw new Error("Elements couldn't be retrieved");
2522
+ setIsSaving(true);
2523
+ return [4 /*yield*/, elements.submit()];
2524
+ case 1:
2525
+ submitError = (_d.sent()).error;
2526
+ if (submitError)
2527
+ throw new Error(submitError.message);
2528
+ return [4 /*yield*/, createSetupIntent(plugin, token, apiHost, accountId)];
2529
+ case 2:
2530
+ response = _d.sent();
2531
+ if (response.status !== "success")
2532
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
2533
+ clientSecret = (_b = response === null || response === void 0 ? void 0 : response.payload) === null || _b === void 0 ? void 0 : _b.client_secret;
2534
+ if (!clientSecret)
2535
+ throw new Error("Error retrieving client secret");
2536
+ return [4 /*yield*/, stripe.confirmSetup({
2537
+ elements: elements,
2538
+ clientSecret: clientSecret,
2539
+ redirect: "if_required",
2540
+ confirmParams: {
2541
+ return_url: window.location.href,
2542
+ },
2543
+ })];
2544
+ case 3:
2545
+ intentResponse = _d.sent();
2546
+ // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
2547
+ if (intentResponse.error)
2548
+ throw new Error(intentResponse.error.message);
2549
+ paymentMethodId = (_c = intentResponse.setupIntent.payment_method) === null || _c === void 0 ? void 0 : _c.toString();
2550
+ if (!paymentMethodId)
2551
+ throw new Error("Payment method couldn't be retrieved");
2552
+ return [4 /*yield*/, createPaymentMethod({
2553
+ paymentMethodId: paymentMethodId,
2554
+ plugin: plugin,
2555
+ token: token,
2556
+ apiHost: apiHost,
2557
+ accountId: accountId,
2558
+ })];
2559
+ case 4:
2560
+ paymentMethodResponse = _d.sent();
2561
+ onSaveSuccess({
2562
+ pluginPaymentResponse: {
2563
+ savePaymentMethod: true,
2564
+ plugin: plugin,
2565
+ token: paymentMethodResponse.token,
2566
+ },
2567
+ savedPaymentMethodResponse: {
2568
+ paymentMethodId: paymentMethodResponse.payload[0].id,
2569
+ },
2570
+ });
2571
+ return [3 /*break*/, 7];
2572
+ case 5:
2573
+ error_1 = _d.sent();
2574
+ console.error(error_1);
2575
+ return [3 /*break*/, 7];
2576
+ case 6:
2577
+ setIsSaving(false);
2578
+ return [7 /*endfinally*/];
2579
+ case 7: return [2 /*return*/];
2580
+ }
2581
+ });
2582
+ });
2583
+ };
2584
+ return { save: save, isSaving: isSaving };
2585
+ }
2388
2586
 
2389
- var retrieveConfig = function (_a) {
2390
- var plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
2391
- return __awaiter(void 0, void 0, void 0, function () {
2392
- var response;
2393
- return __generator(this, function (_b) {
2394
- switch (_b.label) {
2395
- case 0: return [4 /*yield*/, common.invokePlugin({
2396
- plugin: plugin,
2397
- method: "retrieve_config",
2398
- token: token,
2399
- apiHost: apiHost,
2400
- payload: {
2401
- account_id: accountId,
2402
- },
2403
- })];
2587
+ var PaymentMethodForm = function (_a) {
2588
+ var plugin = _a.plugin, onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod;
2589
+ // Hooks
2590
+ var _b = useSave({
2591
+ onSaveSuccess: onSavePaymentMethod,
2592
+ }), save = _b.save, isSaving = _b.isSaving;
2593
+ // Handlers
2594
+ var onSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
2595
+ var error_1;
2596
+ return __generator(this, function (_a) {
2597
+ switch (_a.label) {
2598
+ case 0:
2599
+ _a.trys.push([0, 2, , 3]);
2600
+ return [4 /*yield*/, save({ plugin: plugin })];
2404
2601
  case 1:
2405
- response = _b.sent();
2406
- if (response.status !== "success")
2407
- throw new Error(response.message || "Unknown error");
2408
- return [2 /*return*/, response.payload];
2602
+ _a.sent();
2603
+ return [3 /*break*/, 3];
2604
+ case 2:
2605
+ error_1 = _a.sent();
2606
+ onFail(error_1);
2607
+ return [3 /*break*/, 3];
2608
+ case 3: return [2 /*return*/];
2409
2609
  }
2410
2610
  });
2411
- });
2611
+ }); };
2612
+ return (jsxRuntime.jsxs("form", { children: [jsxRuntime.jsx(reactStripeJs.PaymentElement, { options: { layout: { type: "accordion" } } }), jsxRuntime.jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSubmit })] }));
2412
2613
  };
2413
2614
 
2414
- var snakeToSpaces = common.StringUtils.snakeToSpaces;
2415
- var finixOptions$1 = function (isMobile) { return ({
2416
- showAddress: true,
2417
- hideFields: [
2418
- "address_line1",
2419
- "address_line2",
2420
- "address_city",
2421
- "address_region",
2422
- "address_state",
2423
- "address_country",
2424
- ],
2425
- labels: {
2426
- number: "Card number",
2427
- expiration_date: "Expiration date",
2428
- security_code: "CVC",
2429
- address_postal_code: "Postal code",
2430
- },
2431
- styles: finixStyles(isMobile),
2432
- }); };
2433
- var FINIX_FORM_ID$1 = "form-element";
2434
- var FINIX_ERROR_CODE_MAPPINGS = {
2435
- INVALID_FIELD: "Invalid field",
2436
- };
2437
- var FINIX_FIELD_NAME_MAPPINGS = {
2438
- security_code: "CVC",
2439
- number: "Card number",
2440
- UNKNOWN: "Expiration date",
2441
- NOT_SUPPORTED: "Address verification",
2442
- NO_ADDRESS: "Address",
2443
- };
2444
- // Finix doesn't seem to return meaningful errors on their error object
2445
- // they must be extracted from response.data._embedded.errors
2446
- var formatFinixError = function (response) {
2447
- var errors = response.data._embedded.errors;
2448
- var formattedErrors = errors.map(function (error, index) {
2449
- var code = error.code, field = error.field;
2450
- var message = FINIX_ERROR_CODE_MAPPINGS[code] || error.message;
2451
- var formattedField = FINIX_FIELD_NAME_MAPPINGS[field || ""] ||
2452
- lodash.capitalize(snakeToSpaces(field || ""));
2453
- return "".concat(index + 1, ". ").concat(formattedField, ": ").concat(message);
2454
- });
2455
- return formattedErrors.join("\n\n");
2456
- };
2457
- var FinixCardPaymentForm = function (_a) {
2458
- var finixConfig = _a.formData, invoice = _a.invoice, isSaving = _a.isSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, plugin = _a.plugin, quote = _a.quote, setIsSaving = _a.setIsSaving;
2459
- // Context
2615
+ // This is just a wrapper to fetch the stripe object and pass it to the form
2616
+ var StripeForm = function (_a) {
2617
+ var plugin = _a.plugin, onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod;
2460
2618
  var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2461
2619
  var accountId = React.useContext(PaymentContext).accountId;
2462
- var isMobile = common.useIsMobile();
2463
- // Local state
2464
- var _c = React.useState(false), savePaymentMethod = _c[0], setSavePaymentMethod = _c[1];
2465
- var _d = React.useState(null), finixForm = _d[0], setFinixForm = _d[1];
2466
- var _e = React.useState(null), finixAuth = _e[0], setFinixAuth = _e[1];
2467
- var onlySavePaymentMethod = !quote && !invoice;
2468
- var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
2469
- var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
2470
- // Handlers
2471
- var onPaymentSubmit = function () {
2472
- setIsSaving(true);
2473
- try {
2474
- var fraud_session_id_1 = finixAuth.getSessionKey();
2475
- // This is a callback, lets be careful with the scope of the errors and vars
2476
- var finixFormCallback = function (error, response) { return __awaiter(void 0, void 0, void 0, function () {
2477
- var tokenData, finixToken, message, response_1, e_1;
2478
- return __generator(this, function (_a) {
2479
- switch (_a.label) {
2480
- case 0:
2481
- _a.trys.push([0, 3, , 4]);
2482
- tokenData = response.data || {};
2483
- finixToken = tokenData.id;
2484
- if (error) {
2485
- message = formatFinixError(response);
2486
- throw new Error(message);
2487
- }
2488
- if (!finixToken)
2489
- throw new Error("payment token couldn't be retrieved");
2490
- if (!onlySavePaymentMethod) return [3 /*break*/, 2];
2491
- if (!accountId)
2492
- throw new Error("Account ID is required");
2493
- return [4 /*yield*/, common.invokePlugin({
2494
- plugin: plugin,
2495
- method: "store_payment_method",
2496
- payload: {
2497
- finix_token: finixToken,
2498
- fraud_session_id: fraud_session_id_1,
2499
- account_id: accountId,
2500
- },
2501
- token: token,
2502
- apiHost: apiHost,
2503
- })];
2504
- case 1:
2505
- response_1 = _a.sent();
2506
- if (response_1.status === "failed")
2507
- throw new Error(response_1.message);
2508
- return [2 /*return*/, onPaymentSuccess({})];
2509
- case 2:
2510
- onPaymentSuccess({
2511
- pluginPaymentResponse: {
2512
- token: finixToken,
2513
- savePaymentMethod: savePaymentMethod,
2514
- plugin: plugin,
2515
- metadata: {
2516
- fraud_session_id: fraud_session_id_1,
2517
- },
2518
- },
2519
- });
2520
- return [3 /*break*/, 4];
2521
- case 3:
2522
- e_1 = _a.sent();
2523
- // Catch any errors during AFTER submission, during Callback
2524
- onFail(e_1);
2525
- return [3 /*break*/, 4];
2526
- case 4: return [2 /*return*/];
2527
- }
2528
- });
2529
- }); };
2530
- finixForm.submit(finixConfig.environment, finixConfig.application_id, finixFormCallback);
2531
- }
2532
- catch (e) {
2533
- // Catch any errors during configuration and submission
2534
- onFail(e);
2535
- }
2536
- };
2537
- React.useEffect(function () {
2538
- if (!finixForm) {
2539
- var form = window.Finix.CardTokenForm(FINIX_FORM_ID$1, finixOptions$1(isMobile));
2540
- setFinixForm(form);
2541
- }
2542
- }, [finixForm, isMobile]);
2543
- React.useEffect(function () {
2544
- if (!finixAuth) {
2545
- // It is recommended to retrieve the session key ONCE per checkout/payment
2546
- var FinixAuth = window.Finix.Auth(finixConfig.environment, finixConfig.merchant_id);
2547
- setFinixAuth(FinixAuth);
2548
- }
2549
- }, [finixAuth, finixConfig.environment, finixConfig.merchant_id]);
2550
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: FINIX_FORM_ID$1 }), !onlySavePaymentMethod && (jsxRuntime.jsx(antd.Checkbox, __assign({ className: "mt-2", onChange: function (e) { return setSavePaymentMethod(e.target.checked); } }, { children: "Save as primary payment method" }))), jsxRuntime.jsx(CheckoutFooter, { amountDue: amountDue, currencyId: currencyId, isSaving: isSaving, onPaymentSubmit: onPaymentSubmit, onlySavePaymentMethod: onlySavePaymentMethod })] }));
2551
- };
2552
- // This is just a wrapper to fetch the finix config, config its form and pass it to the paymentForm
2553
- var FinixForm = function (_a) {
2554
- var invoice = _a.invoice, isSaving = _a.isSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, plugin = _a.plugin, quote = _a.quote, setIsSaving = _a.setIsSaving, entityId = _a.entityId;
2555
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, accountId = _b.accountId;
2556
- var finixConfig = reactQuery.useQuery({
2557
- queryKey: common.QueryKeyFactory.default.finixKey,
2558
- queryFn: function () {
2559
- return retrieveConfig({
2560
- plugin: plugin,
2561
- token: token,
2562
- apiHost: apiHost,
2563
- accountId: accountId,
2564
- });
2565
- },
2566
- staleTime: 0,
2567
- }).data;
2568
- if (!finixConfig || !finixConfig.application_id)
2569
- return null;
2570
- return (jsxRuntime.jsx(FinixCardPaymentForm, { entityId: entityId, formData: finixConfig, invoice: invoice, isSaving: isSaving, setIsSaving: setIsSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, plugin: plugin, quote: quote }));
2571
- };
2572
-
2573
- var StoredPaymentMethodForm = function (_a) {
2574
- var isSaving = _a.isSaving, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, paymentMethod = _a.paymentMethod, quote = _a.quote, setIsSaving = _a.setIsSaving;
2575
- var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
2576
- var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
2577
- var onPaymentSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
2578
- return __generator(this, function (_a) {
2579
- setIsSaving(true);
2580
- onPaymentSuccess({
2581
- savedPaymentMethodResponse: { paymentMethodId: paymentMethod.id },
2582
- });
2583
- return [2 /*return*/];
2584
- });
2585
- }); };
2586
- return (jsxRuntime.jsx(CheckoutFooter, { amountDue: amountDue, currencyId: currencyId, isSaving: isSaving, onPaymentSubmit: onPaymentSubmit, noPadding: true }));
2587
- };
2588
-
2589
- var finixOptions = function (isMobile) { return ({
2590
- showAddress: true,
2591
- hideFields: [
2592
- "address_line1",
2593
- "address_line2",
2594
- "address_city",
2595
- "address_region",
2596
- "address_state",
2597
- "address_country",
2598
- ],
2599
- labels: {
2600
- account_number: "Account number",
2601
- bank_code: "Routing number",
2602
- account_type: "Account type",
2603
- address_postal_code: "Postal code",
2604
- },
2605
- styles: finixStyles(isMobile),
2606
- }); };
2607
- var FINIX_FORM_ID = "form-element";
2608
- var FinixAchPayment = function (_a) {
2609
- var invoice = _a.invoice, isSaving = _a.isSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, plugin = _a.plugin, quote = _a.quote, setIsSaving = _a.setIsSaving, entityId = _a.entityId;
2610
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, accountId = _b.accountId;
2611
- var finixConfig = reactQuery.useQuery({
2612
- queryKey: common.QueryKeyFactory.default.finixAchKey,
2613
- queryFn: function () {
2614
- return retrieveConfig({
2615
- plugin: plugin,
2616
- token: token,
2617
- apiHost: apiHost,
2618
- accountId: accountId,
2619
- });
2620
- },
2621
- staleTime: 0,
2622
- }).data;
2623
- if (!finixConfig || !finixConfig.application_id)
2620
+ var _c = useStripePlugin(plugin, token, apiHost, accountId), stripe = _c.stripe, options = _c.options;
2621
+ if (!stripe)
2624
2622
  return null;
2625
- return (jsxRuntime.jsx(FinixAchPaymentForm, { entityId: entityId, isSaving: isSaving, formData: finixConfig, invoice: invoice, onFail: onFail, onPaymentSuccess: onPaymentSuccess, plugin: plugin, quote: quote, setIsSaving: setIsSaving }));
2626
- };
2627
- var FinixAchPaymentForm = function (_a) {
2628
- var finixConfig = _a.formData, invoice = _a.invoice, isSaving = _a.isSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, plugin = _a.plugin, quote = _a.quote, setIsSaving = _a.setIsSaving;
2629
- // Context
2630
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, accountId = _b.accountId, window = _b.window;
2631
- var isMobile = common.useIsMobile();
2632
- // Local state
2633
- var _c = React.useState(), finixForm = _c[0], setFinixForm = _c[1];
2634
- var _d = React.useState(false), savePaymentMethod = _d[0], setSavePaymentMethod = _d[1];
2635
- // Derived state
2636
- var onlySavePaymentMethod = !quote && !invoice;
2637
- var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
2638
- var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
2639
- var onPaymentSubmit = function () {
2640
- setIsSaving(true);
2641
- try {
2642
- var finixAchCallback_1 = function (error, response, fraud_session_id) { return __awaiter(void 0, void 0, void 0, function () {
2643
- var tokenData, finixToken, message, response_1, e_1;
2644
- return __generator(this, function (_a) {
2645
- switch (_a.label) {
2646
- case 0:
2647
- _a.trys.push([0, 3, , 4]);
2648
- tokenData = response.data || {};
2649
- finixToken = tokenData.id;
2650
- if (error) {
2651
- message = formatFinixError(response);
2652
- throw new Error(message);
2653
- }
2654
- if (!finixToken) {
2655
- throw new Error("payment token couldn't be retrieved");
2656
- }
2657
- if (!onlySavePaymentMethod) return [3 /*break*/, 2];
2658
- return [4 /*yield*/, common.invokePlugin({
2659
- plugin: plugin,
2660
- method: "store_payment_method",
2661
- payload: {
2662
- finix_token: finixToken,
2663
- fraud_session_id: fraud_session_id,
2664
- account_id: accountId,
2665
- },
2666
- token: token,
2667
- apiHost: apiHost,
2668
- })];
2669
- case 1:
2670
- response_1 = _a.sent();
2671
- if (response_1.status === "failed") {
2672
- throw new Error(response_1.message);
2673
- }
2674
- return [2 /*return*/, onPaymentSuccess({})];
2675
- case 2:
2676
- onPaymentSuccess({
2677
- pluginPaymentResponse: {
2678
- token: finixToken,
2679
- savePaymentMethod: savePaymentMethod,
2680
- plugin: plugin,
2681
- metadata: {
2682
- fraud_session_id: fraud_session_id,
2683
- },
2684
- },
2685
- });
2686
- return [3 /*break*/, 4];
2687
- case 3:
2688
- e_1 = _a.sent();
2689
- // Catch any errors during AFTER submission, during Callback
2690
- onFail(e_1);
2691
- return [3 /*break*/, 4];
2692
- case 4: return [2 /*return*/];
2693
- }
2694
- });
2695
- }); };
2696
- window.Finix.Auth(finixConfig.environment, finixConfig.merchant_id, function (fraud_session_id) {
2697
- finixForm === null || finixForm === void 0 ? void 0 : finixForm.submit(finixConfig.environment, finixConfig.application_id, function (error, response) {
2698
- return finixAchCallback_1(error, response, fraud_session_id);
2699
- });
2700
- });
2701
- }
2702
- catch (e) {
2703
- // Catch any errors during configuration and submission
2704
- onFail(e);
2705
- }
2706
- };
2707
- React.useEffect(function () {
2708
- if (!finixForm) {
2709
- var newFinixForm = window.Finix.BankTokenForm(FINIX_FORM_ID, finixOptions(isMobile));
2710
- setFinixForm(newFinixForm);
2711
- }
2712
- }, [finixForm, isMobile]);
2713
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: FINIX_FORM_ID }), !onlySavePaymentMethod && (jsxRuntime.jsx(antd.Checkbox, __assign({ className: "mt-2", onChange: function (e) { return setSavePaymentMethod(e.target.checked); } }, { children: "Save as primary payment method" }))), jsxRuntime.jsx(CheckoutFooter, { amountDue: amountDue, currencyId: currencyId, onPaymentSubmit: onPaymentSubmit, isSaving: isSaving, onlySavePaymentMethod: onlySavePaymentMethod })] }));
2623
+ return (jsxRuntime.jsx(reactStripeJs.Elements, __assign({ options: options, stripe: stripe }, { children: jsxRuntime.jsx(PaymentMethodForm, { plugin: plugin, onFail: onFail, onSavePaymentMethod: onSavePaymentMethod }) })));
2714
2624
  };
2715
2625
 
2716
- var PaymentMethodForm = function (_a) {
2626
+ var PaymentMethodDetails = function (_a) {
2717
2627
  var _b, _c;
2718
- var entityId = _a.entityId, invoice = _a.invoice, isPlugin = _a.isPlugin, isSaving = _a.isSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, paymentMethod = _a.paymentMethod, quote = _a.quote, setIsSaving = _a.setIsSaving;
2628
+ var onFail = _a.onFail, paymentMethod = _a.paymentMethod, onSavePaymentMethod = _a.onSavePaymentMethod;
2719
2629
  if (!paymentMethod)
2720
2630
  return null;
2721
- if (isPlugin) {
2722
- paymentMethod = paymentMethod;
2723
- var payable = (quote || invoice);
2724
- switch ((_c = (_b = paymentMethod.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name) {
2725
- case "StripePayment":
2726
- return (jsxRuntime.jsx(StripeForm, { entityId: entityId, payable: payable, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, plugin: paymentMethod, setIsSaving: setIsSaving }));
2727
- case "FinixPayment":
2728
- return (jsxRuntime.jsx(FinixForm, { entityId: entityId, invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, plugin: paymentMethod, quote: quote, setIsSaving: setIsSaving }));
2729
- case "FinixAchPayment":
2730
- return (jsxRuntime.jsx(FinixAchPayment, { entityId: entityId, invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, plugin: paymentMethod, quote: quote, setIsSaving: setIsSaving }));
2731
- case "DemoPayPayment":
2732
- return (jsxRuntime.jsx(DemoPayForm, { entityId: entityId, invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, plugin: paymentMethod, quote: quote, setIsSaving: setIsSaving }));
2733
- default:
2734
- return jsxRuntime.jsx("p", { children: "Can not find form for plugin" });
2735
- }
2631
+ paymentMethod = paymentMethod;
2632
+ switch ((_c = (_b = paymentMethod.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name) {
2633
+ case "StripePayment":
2634
+ return (jsxRuntime.jsx(StripeForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: paymentMethod }));
2635
+ case "DemoPayPayment":
2636
+ return (jsxRuntime.jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: paymentMethod }));
2637
+ default:
2638
+ return jsxRuntime.jsx("p", { children: "Can not find form for plugin" });
2736
2639
  }
2737
- else if (quote || invoice)
2738
- return (jsxRuntime.jsx(StoredPaymentMethodForm, { entityId: entityId, invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, paymentMethod: paymentMethod, quote: quote, setIsSaving: setIsSaving }));
2739
- return null;
2740
2640
  };
2741
2641
 
2742
- var usePlugins = function (_a) {
2743
- var entityId = _a.entityId, apiHost = _a.apiHost, token = _a.token;
2744
- return reactQuery.useQuery({
2745
- queryKey: common.QueryKeyFactory.default.pluginsKey,
2746
- queryFn: function () {
2747
- var plugins = common.getPlugins({
2748
- entityId: entityId,
2749
- token: token,
2750
- apiHost: apiHost,
2751
- });
2752
- return plugins;
2753
- },
2754
- enabled: Boolean(entityId),
2755
- });
2642
+ var CardIcon = function () {
2643
+ return (jsxRuntime.jsxs("svg", __assign({ width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsx("path", { d: "M15 3.75H3C2.17157 3.75 1.5 4.42157 1.5 5.25V12.75C1.5 13.5784 2.17157 14.25 3 14.25H15C15.8284 14.25 16.5 13.5784 16.5 12.75V5.25C16.5 4.42157 15.8284 3.75 15 3.75Z", stroke: common.SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M1.5 7.5H16.5", stroke: common.SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
2756
2644
  };
2757
2645
 
2758
- var filterPaymentPlugins = function (plugins) {
2759
- return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
2760
- var _a, _b, _c, _d;
2761
- return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "payment" &&
2762
- ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === "valid" &&
2763
- ((_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d.length);
2764
- });
2646
+ var Text$d = antd.Typography.Text;
2647
+ var PaymentMethodSelector = function (_a) {
2648
+ var paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins, onSelect = _a.onSelect, value = _a.value;
2649
+ return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsxRuntime.jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentOption: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
2765
2650
  };
2766
- var usePaymentPlugins = function (_a) {
2767
- var entityId = _a.entityId, apiHost = _a.apiHost, token = _a.token;
2768
- var _b = usePlugins({
2769
- entityId: entityId,
2770
- apiHost: apiHost,
2771
- token: token,
2772
- }), plugins = _b.data, isFetched = _b.isFetched;
2773
- var paymentPlugins = filterPaymentPlugins(Array.isArray(plugins) ? plugins : []);
2774
- var paymentMethodAllowedPlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.filter(function (plugin) {
2775
- var _a, _b;
2776
- return (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b.some(function (component) { var _a; return (_a = component === null || component === void 0 ? void 0 : component.scenarios) === null || _a === void 0 ? void 0 : _a.includes("admin-payment_method"); });
2777
- });
2778
- return {
2779
- paymentPlugins: paymentPlugins,
2780
- paymentMethodAllowedPlugins: paymentMethodAllowedPlugins,
2781
- isFetched: isFetched,
2782
- };
2651
+ var PaymentOption = function (_a) {
2652
+ var selected = _a.selected, paymentOption = _a.paymentOption, onClick = _a.onClick, name = _a.name;
2653
+ var brandColor = React.useContext(BrandContext).brandColor;
2654
+ var darkMode = React.useContext(BunnyContext).darkMode;
2655
+ var isAch = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("ach");
2656
+ var isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("card");
2657
+ return (jsxRuntime.jsxs(PaymentOptionContainer, __assign({ "$brandColor": brandColor, "$selected": selected, className: "flex justify-between items-center w-full cursor-pointer py-2 px-4 rounded border-solid ".concat(darkMode
2658
+ ? "var(--row-background-dark) border-gray-500"
2659
+ : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentOption); } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsxRuntime.jsx(Text$d, { children: name })] })), isAch ? (jsxRuntime.jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsxRuntime.jsx(CardIcon, {})) : (jsxRuntime.jsx(CardIcon, {}))] })));
2783
2660
  };
2661
+ var PaymentOptionContainer = styled__default["default"].div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"], ["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"])), function (_a) {
2662
+ var $brandColor = _a.$brandColor, $selected = _a.$selected;
2663
+ return $selected &&
2664
+ "\n border-color: ".concat($brandColor, ";\n ");
2665
+ }, function (_a) {
2666
+ var $brandColor = _a.$brandColor;
2667
+ return $brandColor;
2668
+ });
2669
+ var templateObject_1$6;
2784
2670
 
2785
- var PaymentFormWrapper = function (_a) {
2786
- var children = _a.children, setMaxHeight = _a.setMaxHeight;
2787
- var isMobile = common.useIsMobile();
2788
- return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-6 shrink-0 ".concat(isMobile ? "w-full shadow-padding-xb" : ""), style: __assign({}, (isMobile
2789
- ? setMaxHeight
2790
- ? { maxHeight: "60vh" }
2791
- : {}
2792
- : {
2793
- width: "350px",
2794
- })) }, { children: children })));
2795
- };
2796
- var ActualPaymentForm = function (_a) {
2797
- var entityId = _a.entityId, invoice = _a.invoice, isSaving = _a.isSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, setIsSaving = _a.setIsSaving;
2671
+ function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
2672
+ var queryClient = reactQuery.useQueryClient();
2673
+ var showErrorNotification = common.useErrorNotification();
2674
+ var showSuccessNotification = common.useSuccessNotification();
2675
+ var removePaymentMethod = React.useCallback(function (data) {
2676
+ var plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (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); });
2677
+ if (data && plugin) {
2678
+ common.invokePlugin({
2679
+ plugin: plugin,
2680
+ method: "remove_payment_method",
2681
+ payload: {
2682
+ payment_method_id: data.id,
2683
+ account_id: accountId,
2684
+ },
2685
+ token: token,
2686
+ apiHost: apiHost,
2687
+ })
2688
+ .then(function () {
2689
+ showSuccessNotification("Payment method was removed", "Success");
2690
+ queryClient.setQueryData(common.QueryKeyFactory.default.accountPaymentMethodKey, null);
2691
+ })
2692
+ .catch(function (error) {
2693
+ showErrorNotification(error.message, "Error removing payment method");
2694
+ });
2695
+ }
2696
+ }, [paymentPlugins, token, apiHost, queryClient]);
2697
+ return removePaymentMethod;
2698
+ }
2699
+
2700
+ var Panel = antd.Collapse.Panel;
2701
+ var PaymentForm = function (_a) {
2702
+ var entityId = _a.entityId, invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod;
2798
2703
  // Local state
2799
2704
  var _b = React.useState(), selectedPaymentMethod = _b[0], setSelectedPaymentMethod = _b[1];
2800
- var _c = React.useContext(BunnyContext), token = _c.token, apiHost = _c.apiHost, graphQLClient = _c.graphQLClient;
2801
- var storedPaymentMethod = usePaymentMethod(graphQLClient).data;
2802
- // Queries
2705
+ var _c = React.useState(false), showPaymentMethodForm = _c[0], setShowPaymentMethodForm = _c[1];
2706
+ var paying = !!(quote || invoice);
2707
+ // Hooks
2708
+ var _d = React.useContext(BunnyContext), token = _d.token, apiHost = _d.apiHost, graphQLClient = _d.graphQLClient;
2709
+ var storedPaymentMethod = usePaymentMethod(graphQLClient, accountId).data;
2803
2710
  var isPaymentMethodFetched = storedPaymentMethod !== undefined;
2804
- var _d = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: token }), paymentMethodAllowedPlugins = _d.paymentMethodAllowedPlugins, arePluginsFetched = _d.isFetched;
2805
- // Derived state
2806
- // If there is a quote or invoice, we are just saving a payment method and not processing a payment
2807
- var showStoredPaymentMethodOption = Boolean(quote || invoice);
2808
- var isPlugin = !(selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.metadata);
2711
+ var _e = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: token }), paymentMethodAllowedPlugins = _e.paymentMethodAllowedPlugins, arePluginsFetched = _e.isFetched;
2712
+ var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], token, apiHost, accountId);
2713
+ var queryClient = reactQuery.useQueryClient();
2809
2714
  // Set default plugin
2810
2715
  React.useEffect(function () {
2811
2716
  if (!arePluginsFetched ||
@@ -2813,34 +2718,53 @@ var ActualPaymentForm = function (_a) {
2813
2718
  selectedPaymentMethod) {
2814
2719
  return;
2815
2720
  }
2816
- if (storedPaymentMethod && showStoredPaymentMethodOption)
2817
- setSelectedPaymentMethod(storedPaymentMethod);
2818
- else if (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.length)
2819
- setSelectedPaymentMethod(paymentMethodAllowedPlugins[0]);
2721
+ var pluginPaymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a; return plugin.name === ((_a = storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.metadata) === null || _a === void 0 ? void 0 : _a.issuer); });
2722
+ if (pluginPaymentMethod) {
2723
+ setSelectedPaymentMethod(pluginPaymentMethod);
2724
+ }
2725
+ else if (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]) {
2726
+ setSelectedPaymentMethod(paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]);
2727
+ }
2820
2728
  }, [
2821
2729
  arePluginsFetched,
2822
2730
  isPaymentMethodFetched,
2823
2731
  paymentMethodAllowedPlugins,
2824
2732
  selectedPaymentMethod,
2825
2733
  setSelectedPaymentMethod,
2826
- showStoredPaymentMethodOption,
2827
2734
  storedPaymentMethod,
2828
2735
  ]);
2829
2736
  var showPaymentMethodSelector = React.useMemo(function () {
2830
2737
  var pluginCount = (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.length) || 0;
2831
- return showStoredPaymentMethodOption && storedPaymentMethod
2832
- ? pluginCount + 1 > 1
2833
- : pluginCount > 1;
2834
- }, [
2835
- paymentMethodAllowedPlugins,
2836
- showStoredPaymentMethodOption,
2837
- storedPaymentMethod,
2838
- ]);
2839
- return (jsxRuntime.jsxs(PaymentFormWrapper, __assign({ setMaxHeight: isPlugin }, { children: [showPaymentMethodSelector && (jsxRuntime.jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, showStoredPaymentMethodOption: showStoredPaymentMethodOption, value: selectedPaymentMethod })), selectedPaymentMethod && (jsxRuntime.jsx("div", __assign({ className: "flex flex-col" }, { children: jsxRuntime.jsx(PaymentMethodForm, { entityId: entityId, invoice: invoice, isPlugin: isPlugin, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, paymentMethod: selectedPaymentMethod, quote: quote, setIsSaving: setIsSaving }) })))] })));
2840
- };
2841
- var PaymentForm = function (_a) {
2842
- var entityId = _a.entityId, invoice = _a.invoice, isSaving = _a.isSaving, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, setIsSaving = _a.setIsSaving;
2843
- return (jsxRuntime.jsx(ActualPaymentForm, { entityId: entityId, invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, quote: quote, setIsSaving: setIsSaving }));
2738
+ return pluginCount > 1;
2739
+ }, [paymentMethodAllowedPlugins]);
2740
+ var handlePaymentSuccess = function (_a) {
2741
+ var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
2742
+ // Hide payment method selector and form
2743
+ setShowPaymentMethodForm(false);
2744
+ // Set new selected payment method
2745
+ var paymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a; return plugin.id === ((_a = pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.plugin) === null || _a === void 0 ? void 0 : _a.id); });
2746
+ setSelectedPaymentMethod(paymentMethod);
2747
+ // Handle success keeps going up component tree
2748
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess({
2749
+ pluginPaymentResponse: pluginPaymentResponse,
2750
+ savedPaymentMethodResponse: savedPaymentMethodResponse,
2751
+ });
2752
+ };
2753
+ var handleSavePaymentMethod = function () {
2754
+ queryClient.invalidateQueries({
2755
+ queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
2756
+ });
2757
+ onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
2758
+ setShowPaymentMethodForm(false);
2759
+ };
2760
+ return (jsxRuntime.jsx(PaymentContext.Provider, __assign({ value: {
2761
+ onClickCancel: function () { return setShowPaymentMethodForm(false); },
2762
+ accountId: accountId,
2763
+ } }, { children: jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-0 w-full" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", __assign({ className: "".concat(!showPaymentMethodForm ? "px-0" : "px-4") }, { children: jsxRuntime.jsx(MiniCreditCard, { hideRemoveButton: paying, onClickRemove: function () { return onClickRemove(storedPaymentMethod); }, paymentMethodData: storedPaymentMethod }) })), paying && storedPaymentMethod ? (jsxRuntime.jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethod })) : (
2764
+ //if not paying and payment method is saved, show Collapse
2765
+ jsxRuntime.jsx(antd.Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsxRuntime.jsx(Panel, __assign({ header: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !showPaymentMethodForm ? (jsxRuntime.jsx("div", __assign({ className: "pt-4" }, { children: jsxRuntime.jsxs(antd.Button, __assign({ onClick: function () {
2766
+ setShowPaymentMethodForm(true);
2767
+ }, type: "default", className: "w-full" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsxRuntime.jsx("div", { children: selectedPaymentMethod ? (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsxRuntime.jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsxRuntime.jsx("div", __assign({ className: "flex flex-col" }, { children: jsxRuntime.jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsxRuntime.jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })));
2844
2768
  };
2845
2769
 
2846
2770
  var MUTATION$8 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
@@ -2878,9 +2802,8 @@ var checkout = function (_a) {
2878
2802
  });
2879
2803
  };
2880
2804
 
2881
- var InvoiceCheckoutContext = React.createContext({});
2882
2805
  var InvoiceCheckout = function (_a) {
2883
- var isSaving = _a.isSaving, onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, setIsSaving = _a.setIsSaving, preCheckout = _a.preCheckout, setIsPreCheckoutLoading = _a.setIsPreCheckoutLoading, isPreCheckoutLoading = _a.isPreCheckoutLoading, payImmediatelyGivenInvoice = _a.payImmediatelyGivenInvoice, checkoutButtonName = _a.checkoutButtonName, entityId = _a.entityId;
2806
+ var onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, entityId = _a.entityId;
2884
2807
  var _b = React.useContext(BunnyContext), apiHost = _b.apiHost, token = _b.token;
2885
2808
  var checkoutMutation = reactQuery.useMutation({
2886
2809
  mutationFn: function (_a) {
@@ -2944,14 +2867,7 @@ var InvoiceCheckout = function (_a) {
2944
2867
  });
2945
2868
  });
2946
2869
  };
2947
- return (jsxRuntime.jsx(InvoiceCheckoutContext.Provider, __assign({ value: {
2948
- preCheckout: preCheckout,
2949
- payImmediatelyGivenInvoice: payImmediatelyGivenInvoice,
2950
- checkoutButtonName: checkoutButtonName,
2951
- invoice: invoice,
2952
- setIsPreCheckoutLoading: setIsPreCheckoutLoading,
2953
- isPreCheckoutLoading: isPreCheckoutLoading,
2954
- } }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, isSaving: isSaving, onPaymentSuccess: handleCheckout, onFail: onFail, invoice: invoice, setIsSaving: setIsSaving }) })));
2870
+ return (jsxRuntime.jsx("div", __assign({ className: "w-full pt-12" }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: handleCheckout, onFail: onFail, invoice: invoice }) })));
2955
2871
  };
2956
2872
 
2957
2873
  var fetchPDF = function (window, apiEndpoint, invoiceUuid) { return __awaiter(void 0, void 0, void 0, function () {
@@ -2997,31 +2913,39 @@ function InvoicePDF(_a) {
2997
2913
  }, title: "Invoice PDF", width: "100%" }));
2998
2914
  }
2999
2915
 
3000
- var quoteMetaDescription = function (vendorName) {
3001
- return "View this quote on the ".concat(vendorName, " customer portal. Powered by Bunny");
3002
- };
3003
- var quoteMetaTitle = function (_a) {
3004
- var documentName = _a.documentName, vendorName = _a.vendorName;
3005
- return vendorName + " " + documentName;
3006
- };
3007
-
3008
- function ActualInvoice(_a) {
3009
- var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId;
3010
- React.useContext(BunnyContext).window;
3011
- var isMobile = common.useIsMobile();
3012
- var _b = React.useState(false), isSaving = _b[0], setIsSaving = _b[1];
2916
+ var InvoiceQuoteContext = React.createContext({});
2917
+ function Invoice(_a) {
2918
+ var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onInvoiceDownloadError = _a.onInvoiceDownloadError, onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, className = _a.className, _c = _a.hideDownloadButton, hideDownloadButton = _c === void 0 ? false : _c;
2919
+ return (jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(InvoiceQuoteContext.Provider, __assign({ value: {
2920
+ id: id,
2921
+ invoiceQuoteViewComponent: invoiceQuoteViewComponent,
2922
+ backButtonName: backButtonName,
2923
+ onBackButtonClick: onBackButtonClick,
2924
+ onInvoiceDownloadError: onInvoiceDownloadError,
2925
+ onPaymentSuccess: onPaymentSuccess,
2926
+ entityId: entityId,
2927
+ shadow: shadow,
2928
+ className: className,
2929
+ hideDownloadButton: hideDownloadButton,
2930
+ } }, { children: jsxRuntime.jsx(ActualInvoice, {}) })) }));
2931
+ }
2932
+ function ActualInvoice() {
2933
+ // Context
3013
2934
  var queryClient = reactQuery.useQueryClient();
3014
- var _c = React.useContext(BunnyContext), apiHost = _c.apiHost, token = _c.token, onErrorNavigate = _c.onErrorNavigate;
2935
+ var _a = React.useContext(InvoiceQuoteContext), id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId, className = _a.className;
2936
+ var _b = React.useContext(BunnyContext), apiHost = _b.apiHost, token = _b.token, onTokenExpired = _b.onTokenExpired;
2937
+ // Local state
2938
+ var isMobile = common.useIsMobile();
2939
+ // Hooks
3015
2940
  var showSuccessNotification = common.useSuccessNotification();
3016
- var handleAllErrorFormats = common.useAllErrorFormats(onErrorNavigate ||
3017
- (function (url) {
3018
- console.log("navigate to", url, " not implemented");
3019
- }));
2941
+ var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
3020
2942
  // Queries
3021
- var _d = reactQuery.useQuery({
2943
+ var _c = reactQuery.useQuery({
3022
2944
  queryKey: common.QueryKeyFactory.default.createFormattedInvoiceKey(token, id),
3023
2945
  queryFn: function () { return common.getFormattedInvoice({ id: id, token: token, apiHost: apiHost }); },
3024
- }), formattedInvoice = _d.data, error = _d.error;
2946
+ }), formattedInvoice = _c.data, error = _c.error;
2947
+ // Derived state
2948
+ var isInvoicePayable = common.PAYABLE_INVOICE_STATES.includes((formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.state) || "");
3025
2949
  if (error) {
3026
2950
  return jsxRuntime.jsxs("div", { children: ["Error loading invoice: ", error.message] });
3027
2951
  }
@@ -3045,19 +2969,12 @@ function ActualInvoice(_a) {
3045
2969
  var onFail = function (error) {
3046
2970
  handleAllErrorFormats(error.message);
3047
2971
  };
3048
- // Derived state
3049
- var isInvoicePayable = common.PAYABLE_INVOICE_STATES.includes((formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.state) || "");
3050
2972
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(reactHelmetAsync.Helmet, { children: [jsxRuntime.jsxs("title", { children: [formattedInvoice.vendorName, " ", common.DOCUMENT_NAME.INVOICE] }), jsxRuntime.jsx("meta", { name: "description", content: quoteMetaDescription(formattedInvoice.vendorName) }), jsxRuntime.jsx("meta", { property: "og:type", content: "website" }), jsxRuntime.jsx("meta", { property: "og:title", content: quoteMetaTitle({
3051
2973
  vendorName: formattedInvoice.vendorName,
3052
2974
  documentName: common.DOCUMENT_NAME.INVOICE,
3053
- }) }), jsxRuntime.jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxRuntime.jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb") }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsxRuntime.jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), !isMobile && isInvoicePayable && (jsxRuntime.jsx(antd.Divider, { className: "h-full", type: "vertical" })), isInvoicePayable && (jsxRuntime.jsx(InvoiceCheckout, { invoice: formattedInvoice, isSaving: isSaving, onFail: function (error) {
2975
+ }) }), jsxRuntime.jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxRuntime.jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsxRuntime.jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), !isMobile && isInvoicePayable && (jsxRuntime.jsx(antd.Divider, { className: "h-full", type: "vertical" })), isInvoicePayable && (jsxRuntime.jsx(InvoiceCheckout, { invoice: formattedInvoice, onFail: function (error) {
3054
2976
  onFail(error);
3055
- setIsSaving(false);
3056
- }, onSuccess: onSuccess, setIsSaving: setIsSaving, entityId: entityId }))] }))] }));
3057
- }
3058
- function Invoice(_a) {
3059
- var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick; _a.onInvoiceDownloadError; var onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId;
3060
- return (jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(ActualInvoice, { id: id, invoiceQuoteViewComponent: invoiceQuoteViewComponent, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick, onPaymentSuccess: onPaymentSuccess, entityId: entityId }) }));
2977
+ }, onSuccess: onSuccess, entityId: entityId }))] }))] }));
3061
2978
  }
3062
2979
 
3063
2980
  var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n object { documents { id filename size date url } }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
@@ -3075,6 +2992,9 @@ var getFormattedQuote = function (_a) {
3075
2992
  })];
3076
2993
  case 1:
3077
2994
  response = _b.sent();
2995
+ if (response === null || response === void 0 ? void 0 : response.formattedQuote.error) {
2996
+ throw new Error(response === null || response === void 0 ? void 0 : response.formattedQuote.error);
2997
+ }
3078
2998
  return [2 /*return*/, response === null || response === void 0 ? void 0 : response.formattedQuote];
3079
2999
  }
3080
3000
  });
@@ -3095,17 +3015,14 @@ var useSigningPlugins = function (_a) {
3095
3015
  };
3096
3016
 
3097
3017
  var useSendAcceptQuote = function (_a) {
3098
- var entityId = _a.entityId, onErrorNavigate = _a.onErrorNavigate, quoteId = _a.quoteId, apiHost = _a.apiHost, token = _a.token;
3018
+ var entityId = _a.entityId, onTokenExpired = _a.onTokenExpired, quoteId = _a.quoteId, apiHost = _a.apiHost, token = _a.token;
3099
3019
  // Hooks
3100
3020
  var graphQLMutation = common.useGraphQLmutation(function () {
3101
3021
  console.log("navigate in useGraphQLmutation in useSendAcceptQuote is not yet implemented");
3102
3022
  }, apiHost || "", function () {
3103
3023
  console.log("onError in useGraphQLmutation in useSendAcceptQuote is not yet implemented");
3104
3024
  });
3105
- var handleAllErrorFormats = common.useAllErrorFormats(onErrorNavigate ||
3106
- (function (url) {
3107
- console.log("navigate to", url, " not implemented");
3108
- }));
3025
+ var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
3109
3026
  var signingPlugins = useSigningPlugins({ entityId: entityId, apiHost: apiHost, token: token });
3110
3027
  var queryClient = reactQuery.useQueryClient();
3111
3028
  // Local state
@@ -3218,30 +3135,19 @@ var useSigningComplete = function (_a) {
3218
3135
  }, [data, eventParam, queryClient, token]);
3219
3136
  };
3220
3137
 
3221
- var dayjs_min = {exports: {}};
3222
-
3223
- (function (module, exports) {
3224
- !function(t,e){module.exports=e();}(commonjsGlobal,(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}));
3225
- }(dayjs_min));
3226
-
3227
- var dayjs = dayjs_min.exports;
3228
-
3229
3138
  var useIsExpired = function (expiresAt) {
3230
3139
  return dayjs(expiresAt).diff(dayjs(dayjs().format("YYYY-MM-DD"))) < 0;
3231
3140
  };
3232
3141
 
3233
3142
  var PandadocPollingModal = function (_a) {
3234
3143
  var isVisible = _a.isVisible, setVisible = _a.setVisible, id = _a.id;
3235
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, onErrorNavigate = _b.onErrorNavigate;
3144
+ var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired;
3236
3145
  var graphQLMutation = common.useGraphQLmutation(function () {
3237
3146
  console.log("graphQLMutation navigateOnTokenExpired not yet implemented");
3238
3147
  }, apiHost || "", function () {
3239
3148
  console.log("graphQLMutation onError not yet implemented");
3240
3149
  });
3241
- var handleAllErrorFormats = common.useAllErrorFormats(onErrorNavigate ||
3242
- (function (url) {
3243
- console.log("navigate to", url, " not implemented");
3244
- }));
3150
+ var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
3245
3151
  var _c = React.useState(0), numberOfPolls = _c[0], setNumberOfPolls = _c[1];
3246
3152
  var _d = React.useState(""), infoMessage = _d[0], setInfoMessage = _d[1];
3247
3153
  React.useEffect(function () {
@@ -3321,58 +3227,82 @@ var DOCUMENT_NAME;
3321
3227
  DOCUMENT_NAME["QUOTE"] = "quote";
3322
3228
  })(DOCUMENT_NAME || (DOCUMENT_NAME = {}));
3323
3229
 
3230
+ var Text$c = antd.Typography.Text;
3324
3231
  var documentName = DOCUMENT_NAME.QUOTE;
3232
+ styled__default["default"].div(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
3233
+ function Quote(_a) {
3234
+ var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, onInvoiceDownloadError = _a.onInvoiceDownloadError, onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, className = _a.className, _c = _a.hideDownloadButton, hideDownloadButton = _c === void 0 ? false : _c;
3235
+ return (jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(InvoiceQuoteContext.Provider, __assign({ value: {
3236
+ id: id,
3237
+ invoiceQuoteViewComponent: invoiceQuoteViewComponent,
3238
+ onInvoiceDownloadError: onInvoiceDownloadError,
3239
+ onPaymentSuccess: onPaymentSuccess,
3240
+ entityId: entityId,
3241
+ shadow: shadow,
3242
+ className: className,
3243
+ hideDownloadButton: hideDownloadButton,
3244
+ } }, { children: jsxRuntime.jsx(ActualQuote, { entityId: entityId }) })) }));
3245
+ }
3325
3246
  function ActualQuote(_a) {
3247
+ var _this = this;
3326
3248
  var _b, _c;
3327
- var id = _a.id, entityId = _a.entityId;
3328
- var _d = React.useContext(BunnyContext), token = _d.token, apiHost = _d.apiHost, onErrorNavigate = _d.onErrorNavigate;
3249
+ var entityId = _a.entityId;
3250
+ // Context
3251
+ var _d = React.useContext(BunnyContext), token = _d.token, apiHost = _d.apiHost, onTokenExpired = _d.onTokenExpired;
3329
3252
  var entityBranding = React.useContext(BrandContext);
3330
- var isMobile = common.useIsMobile();
3253
+ var _e = React.useContext(InvoiceQuoteContext), className = _e.className, id = _e.id, hideDownloadButton = _e.hideDownloadButton;
3331
3254
  // Queries
3332
- var _e = reactQuery.useQuery({
3255
+ var _f = reactQuery.useQuery({
3333
3256
  queryKey: common.QueryKeyFactory.default.createQuoteKey(token, id),
3334
- queryFn: function () { return getFormattedQuote({ token: token, apiHost: apiHost, id: id }); },
3257
+ queryFn: function () { return __awaiter(_this, void 0, void 0, function () {
3258
+ var error_1;
3259
+ return __generator(this, function (_a) {
3260
+ switch (_a.label) {
3261
+ case 0:
3262
+ _a.trys.push([0, 2, , 3]);
3263
+ return [4 /*yield*/, getFormattedQuote({ token: token, apiHost: apiHost, id: id })];
3264
+ case 1: return [2 /*return*/, _a.sent()];
3265
+ case 2:
3266
+ error_1 = _a.sent();
3267
+ showErrorNotification(error_1.message);
3268
+ return [3 /*break*/, 3];
3269
+ case 3: return [2 /*return*/];
3270
+ }
3271
+ });
3272
+ }); },
3335
3273
  placeholderData: reactQuery.keepPreviousData,
3336
- }), data = _e.data, isLoading = _e.isLoading;
3274
+ }), data = _f.data, isLoading = _f.isLoading;
3337
3275
  var formattedQuote = data;
3338
3276
  // Hooks
3339
3277
  var downloadFile = useDownloadFile(id);
3340
3278
  var isExpired = useIsExpired(formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.expiresAt);
3341
- var _f = useSendAcceptQuote({
3279
+ var _g = useSendAcceptQuote({
3342
3280
  entityId: entityId,
3343
3281
  token: token,
3344
- onErrorNavigate: onErrorNavigate ||
3345
- (function (url) {
3346
- console.log("navigate to", url, " not implemented");
3347
- }),
3282
+ onTokenExpired: onTokenExpired,
3348
3283
  apiHost: apiHost,
3349
3284
  quoteId: id,
3350
- }), acceptBoxVisible = _f.acceptBoxVisible, isAccepting = _f.isAccepting, sendAccept = _f.sendAccept, setAcceptBoxVisible = _f.setAcceptBoxVisible, setIsAccepting = _f.setIsAccepting, startAcceptance = _f.startAcceptance, pandadocPollingModalVisible = _f.pandadocPollingModalVisible, setPandadocPollingModalVisible = _f.setPandadocPollingModalVisible;
3285
+ }), acceptBoxVisible = _g.acceptBoxVisible, isAccepting = _g.isAccepting, sendAccept = _g.sendAccept, setAcceptBoxVisible = _g.setAcceptBoxVisible, setIsAccepting = _g.setIsAccepting, startAcceptance = _g.startAcceptance, pandadocPollingModalVisible = _g.pandadocPollingModalVisible, setPandadocPollingModalVisible = _g.setPandadocPollingModalVisible;
3351
3286
  useSigningComplete({ data: formattedQuote, token: token });
3287
+ var isMobile = common.useIsMobile();
3288
+ var showErrorNotification = common.useErrorNotification();
3352
3289
  if (!formattedQuote || isLoading) {
3353
3290
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
3354
3291
  }
3292
+ // Derived state
3293
+ var isAccepted = formattedQuote.state === "ACCEPTED";
3355
3294
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(reactHelmetAsync.Helmet, { children: [jsxRuntime.jsxs("title", { children: [formattedQuote.vendorName, " ", documentName] }), jsxRuntime.jsx("meta", { name: "description", content: quoteMetaDescription(formattedQuote.vendorName) }), jsxRuntime.jsx("meta", { property: "og:type", content: "website" }), jsxRuntime.jsx("meta", { property: "og:title", content: quoteMetaTitle({
3356
3295
  vendorName: formattedQuote.vendorName,
3357
3296
  documentName: documentName,
3358
- }) }), jsxRuntime.jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedQuote.vendorName) })] }), jsxRuntime.jsxs("div", __assign({ className: "flex shadow-padding-x ".concat(isMobile ? "flex-col gap-1" : "items-center gap-2", " justify-end pb-4"), id: "acceptance", style: {
3359
- color: entityBranding.secondaryColor,
3360
- } }, { children: [formattedQuote.state === "ACCEPTED" ||
3361
- formattedQuote.state === "APPLIED" ? (jsxRuntime.jsxs("div", { children: [formattedQuote.state === "ACCEPTED" &&
3362
- formattedQuote.acceptedAt &&
3363
- "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(common.formatDate(formattedQuote.acceptedAt)), formattedQuote.state === "APPLIED" &&
3364
- formattedQuote.acceptedAt &&
3365
- "Quote is now applied. Accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(common.formatDate(formattedQuote.acceptedAt))] })) : null, jsxRuntime.jsxs("div", __assign({ className: isMobile
3366
- ? "flex w-full justify-between gap-2"
3367
- : "flex items-center justify-end gap-2" }, { children: [!isMobile ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(DownloadOutlined$1, {}), onClick: function () { return downloadFile(apiHost + "/api/pdf/quote", token); } }, { children: "Download" }))) : null, formattedQuote.state !== "ACCEPTED" &&
3368
- formattedQuote.state !== "APPLIED" ? (jsxRuntime.jsx(antd.Button, __assign({ disabled: isExpired || isAccepting, onClick: function () { return startAcceptance(); }, type: "primary" }, { children: isExpired ? "Quote is expired" : "Accept quote" }))) : null] }))] })), jsxRuntime.jsx("div", __assign({ className: "flex ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb") }, { children: jsxRuntime.jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html }, { children: ((_c = (_b = formattedQuote.object) === null || _b === void 0 ? void 0 : _b.documents) === null || _c === void 0 ? void 0 : _c.length) > 0 ? (jsxRuntime.jsx("div", __assign({ className: "flex flex-col items-end" }, { children: formattedQuote.object.documents.map(function (doc, index) {
3369
- return (jsxRuntime.jsx(antd.Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
3370
- }) }))) : null })) })), jsxRuntime.jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept }), jsxRuntime.jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
3371
- }
3372
- styled__default["default"].div(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
3373
- function Quote(_a) {
3374
- var entityId = _a.entityId, id = _a.id;
3375
- return (jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(ActualQuote, { entityId: entityId, id: id }) }));
3297
+ }) }), jsxRuntime.jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedQuote.vendorName) })] }), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-4 ".concat(className) }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
3298
+ color: entityBranding.secondaryColor,
3299
+ } }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsxRuntime.jsx(Text$c, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(common.formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxRuntime.jsxs("div", __assign({ className: isMobile
3300
+ ? "flex w-full justify-end gap-2"
3301
+ : "flex items-center justify-end gap-2" }, { children: [!isMobile && !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(DownloadOutlined$1, {}), onClick: function () {
3302
+ return downloadFile(apiHost + "/api/pdf/quote", token);
3303
+ } }, { children: "Download" }))) : null, !isAccepted ? (jsxRuntime.jsx(antd.Button, __assign({ disabled: isExpired || isAccepting, onClick: function () { return startAcceptance(); }, type: "primary" }, { children: isExpired ? "Quote is expired" : "Accept quote" }))) : null] })))] })), jsxRuntime.jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html }, { children: ((_c = (_b = formattedQuote.object) === null || _b === void 0 ? void 0 : _b.documents) === null || _c === void 0 ? void 0 : _c.length) > 0 ? (jsxRuntime.jsx("div", __assign({ className: "flex flex-col items-end" }, { children: formattedQuote.object.documents.map(function (doc, index) {
3304
+ return (jsxRuntime.jsx(antd.Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
3305
+ }) }))) : null }))] })), jsxRuntime.jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept }), jsxRuntime.jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
3376
3306
  }
3377
3307
  var templateObject_1$4;
3378
3308
 
@@ -3427,21 +3357,14 @@ var getTransactions = function (filter, token, apiHost, kindsToShow) { return __
3427
3357
  });
3428
3358
  }); };
3429
3359
 
3430
- var Text$b = antd.Typography.Text;
3431
- var PageHeaderWithActions = function (_a) {
3432
- var children = _a.children, title = _a.title;
3433
- var isMobile = common.useIsMobile();
3434
- return (jsxRuntime.jsxs("div", __assign({ className: "flex pb-4 shadow-padding-x ".concat(isMobile ? "flex-col gap-2" : "items-center justify-between h-8") }, { children: [jsxRuntime.jsx(PageSubTitle, { title: title }), children] })));
3435
- };
3436
- var PageSubTitle = function (_a) {
3437
- var title = _a.title;
3438
- var secondaryColor = React.useContext(BrandContext).secondaryColor;
3439
- var darkMode = React.useContext(BunnyContext).darkMode;
3440
- return (jsxRuntime.jsx(Text$b, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title })));
3441
- };
3360
+ var TransactionsListContext = React.createContext({});
3442
3361
 
3443
3362
  var StateTag = function (_a) {
3444
3363
  var state = _a.state;
3364
+ var transactionStateRenderer = React.useContext(TransactionsListContext).transactionStateRenderer;
3365
+ if (transactionStateRenderer) {
3366
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: transactionStateRenderer(state) });
3367
+ }
3445
3368
  return jsxRuntime.jsx(antd.Tag, __assign({ color: getColor(state) }, { children: lodash.capitalize(lodash.startCase(state)) }));
3446
3369
  };
3447
3370
  var getColor = function (state) {
@@ -3470,12 +3393,10 @@ var getColor = function (state) {
3470
3393
  }
3471
3394
  };
3472
3395
 
3473
- var TransactionsListContext = React.createContext({});
3474
-
3475
- var Text$a = antd.Typography.Text;
3396
+ var Text$b = antd.Typography.Text;
3476
3397
  var TransactionDate = function (_a) {
3477
3398
  var date = _a.date;
3478
- return jsxRuntime.jsx(Text$a, __assign({ className: "text-sm" }, { children: common.formatDate(date) }));
3399
+ return jsxRuntime.jsx(Text$b, __assign({ className: "text-sm" }, { children: common.formatDate(date) }));
3479
3400
  };
3480
3401
 
3481
3402
  // TODO: delete
@@ -3509,10 +3430,10 @@ var TransactionGridCell = styled__default["default"].div.withConfig({
3509
3430
  })(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n ", "\n\n display: flex;\n align-items: center;\n justify-content: ", ";\n\n text-align: ", ";\n white-space: nowrap;\n font-size: 14px;\n color: ", ";\n\n background-color: inherit;\n\n padding: 1rem;\n min-width: 48px;\n"], ["\n ", "\n\n display: flex;\n align-items: center;\n justify-content: ", ";\n\n text-align: ", ";\n white-space: nowrap;\n font-size: 14px;\n color: ", ";\n\n background-color: inherit;\n\n padding: 1rem;\n min-width: 48px;\n"])), function (props) { return props.gridColumn && "grid-column: ".concat(props.gridColumn, ";"); }, function (props) { return (props.right ? "flex-end" : "flex-start"); }, function (props) { return (props.right ? "right" : "left"); }, common.SLATE_600);
3510
3431
  var templateObject_1$3;
3511
3432
 
3512
- var Text$9 = antd.Typography.Text;
3433
+ var Text$a = antd.Typography.Text;
3513
3434
  var TransactionsEmptyState = function () {
3514
3435
  var noTransactionsMessage = React.useContext(TransactionsListContext).noTransactionsMessage;
3515
- return (jsxRuntime.jsx(Text$9, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
3436
+ return (jsxRuntime.jsx(Text$a, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
3516
3437
  };
3517
3438
 
3518
3439
  var isInvoice = function (transaction) {
@@ -3529,7 +3450,7 @@ var TransactionRowTitle = function (_a) {
3529
3450
  return (jsxRuntime.jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
3530
3451
  };
3531
3452
 
3532
- var Text$8 = antd.Typography.Text;
3453
+ var Text$9 = antd.Typography.Text;
3533
3454
  var TransactionsListDesktop = function (_a) {
3534
3455
  var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
3535
3456
  var columns = React.useContext(TransactionsListContext).columns;
@@ -3549,11 +3470,11 @@ var TransactionsListDesktop = function (_a) {
3549
3470
  backgroundColor: index % 2 === 0
3550
3471
  ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
3551
3472
  : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
3552
- } }, { children: [showDateAndTitle && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TransactionGridCell, __assign({ right: false }, { children: jsxRuntime.jsx(TransactionDate, { date: transaction.createdAt }) })), jsxRuntime.jsxs(TransactionGridCell, __assign({ right: false, className: "flex items-center gap-2" }, { children: [jsxRuntime.jsx(Text$8, { children: lodash.capitalize(transaction.kind.toLowerCase()) }), jsxRuntime.jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })), showState && (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(StateTag, { state: transaction.state }) }))), showAmount && (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(Text$8, { children: common.formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
3473
+ } }, { children: [!showDateAndTitle && !showState && !showAmount && !showDownload && (jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsx(Text$9, { children: "No columns selected" }) })), showDateAndTitle && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TransactionGridCell, __assign({ right: false }, { children: jsxRuntime.jsx(TransactionDate, { date: transaction.createdAt }) })), jsxRuntime.jsxs(TransactionGridCell, __assign({ right: false, className: "flex items-center gap-2" }, { children: [jsxRuntime.jsx(Text$9, { children: lodash.capitalize(transaction.kind.toLowerCase()) }), jsxRuntime.jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })), showState ? (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(StateTag, { state: transaction.state }) }))) : null, showAmount && (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(Text$9, { children: common.formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
3553
3474
  });
3554
3475
  };
3555
3476
 
3556
- var Text$7 = antd.Typography.Text;
3477
+ var Text$8 = antd.Typography.Text;
3557
3478
  var TransactionsListMobile = function (_a) {
3558
3479
  var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
3559
3480
  var columns = React.useContext(TransactionsListContext).columns;
@@ -3572,20 +3493,23 @@ var TransactionsListMobile = function (_a) {
3572
3493
  backgroundColor: index % 2 === 0
3573
3494
  ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
3574
3495
  : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
3575
- } }, { children: [jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$7, { children: lodash.capitalize(transaction.kind.toLowerCase()) }), jsxRuntime.jsx(TransactionRowTitle, { transaction: transaction })] })), showState && jsxRuntime.jsx(StateTag, { state: transaction.state })] })), jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxRuntime.jsx(TransactionDate, { date: transaction.createdAt })), showAmount && showDateAndTitle && jsxRuntime.jsx(Text$7, { children: "\u00B7" }), showAmount && (jsxRuntime.jsx(Text$7, { children: common.formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })))] }), index));
3496
+ } }, { children: [jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$8, { children: lodash.capitalize(transaction.kind.toLowerCase()) }), jsxRuntime.jsx(TransactionRowTitle, { transaction: transaction })] })), showState && jsxRuntime.jsx(StateTag, { state: transaction.state })] })), jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxRuntime.jsx(TransactionDate, { date: transaction.createdAt })), showAmount && showDateAndTitle && jsxRuntime.jsx(Text$8, { children: "\u00B7" }), showAmount && (jsxRuntime.jsx(Text$8, { children: common.formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })))] }), index));
3576
3497
  });
3577
3498
  };
3578
3499
 
3500
+ var Text$7 = antd.Typography.Text;
3501
+ var DISPLAY_WIDTH = 1200;
3579
3502
  function Transactions(_a) {
3580
- var transactionComponent = _a.transactionComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.columns, columns = _d === void 0 ? ["date-and-title", "state", "amount"] : _d, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? "md" : _e, searchBarClassName = _a.searchBarClassName, _f = _a.useModal, useModal = _f === void 0 ? false : _f, onTransactionClick = _a.onTransactionClick, _g = _a.suppressTransactionDisplay, suppressTransactionDisplay = _g === void 0 ? false : _g, _h = _a.kindsToShow, kindsToShow = _h === void 0 ? [
3503
+ var transactionComponent = _a.transactionComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.title, title = _d === void 0 ? "Past transactions" : _d, _e = _a.columns, columns = _e === void 0 ? ["date-and-title", "state", "amount"] : _e, className = _a.className, _f = _a.shadow, shadow = _f === void 0 ? "shadow-md" : _f, searchBarClassName = _a.searchBarClassName, _g = _a.useModal, useModal = _g === void 0 ? false : _g, onTransactionClick = _a.onTransactionClick, _h = _a.suppressTransactionDisplay, suppressTransactionDisplay = _h === void 0 ? false : _h, _j = _a.kindsToShow, kindsToShow = _j === void 0 ? [
3581
3504
  common.TransactionKind.INVOICE,
3582
3505
  common.TransactionKind.PAYMENT,
3583
3506
  common.TransactionKind.REFUND,
3584
3507
  common.TransactionKind.WRITE_OFF,
3585
- ] : _h, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage, entityId = _a.entityId;
3508
+ ] : _j, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage, entityId = _a.entityId;
3586
3509
  var contextValues = {
3587
3510
  showSearchBar: showSearchBar,
3588
3511
  showTitle: showTitle,
3512
+ title: title,
3589
3513
  transactionComponent: transactionComponent,
3590
3514
  columns: columns,
3591
3515
  className: className,
@@ -3600,28 +3524,25 @@ function Transactions(_a) {
3600
3524
  noTransactionsMessage: noTransactionsMessage,
3601
3525
  entityId: entityId,
3602
3526
  };
3603
- return (jsxRuntime.jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsxRuntime.jsx(TransactionsWrapper, {}) })));
3604
- }
3605
- function TransactionsWrapper() {
3606
- var _a = React.useContext(TransactionsListContext), kindsToShow = _a.kindsToShow, filterFromContext = _a.filter;
3607
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost;
3527
+ var _k = React.useContext(BunnyContext), token = _k.token, apiHost = _k.apiHost;
3608
3528
  // Local state
3609
- var _c = React.useState(""), search = _c[0], setSearch = _c[1];
3610
- var filter = filterFromContext ||
3529
+ var _l = React.useState(""), search = _l[0], setSearch = _l[1];
3530
+ var filterValue = filter ||
3611
3531
  (search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
3612
3532
  // Queries
3613
3533
  var data = reactQuery.useQuery({
3614
3534
  queryKey: ["transactions", token, filter],
3615
- queryFn: function () { return getTransactions(filter, token, apiHost, kindsToShow); },
3535
+ queryFn: function () { return getTransactions(filterValue, token, apiHost, kindsToShow); },
3616
3536
  placeholderData: reactQuery.keepPreviousData,
3617
3537
  }).data;
3618
- return (jsxRuntime.jsx(TransactionsDisplay, { transactions: data, onSearchValueChanged: setSearch, search: search }));
3538
+ return (jsxRuntime.jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsxRuntime.jsx(TransactionsDisplay, { transactions: data, onSearchValueChanged: setSearch, search: search }) })));
3619
3539
  }
3620
3540
  function TransactionsDisplay(_a) {
3621
- var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search, title = _a.title;
3622
- var _b = React.useContext(TransactionsListContext), showSearchBar = _b.showSearchBar, showTitle = _b.showTitle, transactionComponent = _b.transactionComponent, useModal = _b.useModal, suppressTransactionDisplay = _b.suppressTransactionDisplay, className = _b.className, shadow = _b.shadow, searchBarClassName = _b.searchBarClassName, style = _b.style, onTransactionClick = _b.onTransactionClick, entityId = _b.entityId;
3541
+ var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search;
3542
+ var _b = React.useContext(TransactionsListContext), showSearchBar = _b.showSearchBar, showTitle = _b.showTitle, title = _b.title, transactionComponent = _b.transactionComponent, useModal = _b.useModal, suppressTransactionDisplay = _b.suppressTransactionDisplay, className = _b.className, shadow = _b.shadow, searchBarClassName = _b.searchBarClassName, style = _b.style, onTransactionClick = _b.onTransactionClick, entityId = _b.entityId, onTransactionDisplayClose = _b.onTransactionDisplayClose;
3623
3543
  var columns = React.useContext(TransactionsListContext).columns;
3624
3544
  var darkMode = React.useContext(BunnyContext).darkMode;
3545
+ var secondaryColor = React.useContext(BrandContext).secondaryColor;
3625
3546
  // Local state
3626
3547
  var _c = React.useState(null), selectedTransaction = _c[0], setSelectedTransaction = _c[1];
3627
3548
  var _d = React.useState(false), drawerOpen = _d[0], setDrawerOpen = _d[1];
@@ -3671,38 +3592,48 @@ function TransactionsDisplay(_a) {
3671
3592
  var kind = selectedTransaction.kind.toLowerCase();
3672
3593
  return kind.charAt(0).toUpperCase() + kind.slice(1);
3673
3594
  };
3674
- return (jsxRuntime.jsxs("div", __assign({ style: style }, { children: [jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: title || (showTitle ? "Past transactions" : undefined) }, { children: showSearchBar && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(antd.Input, { className: searchBarClassName
3675
- ? searchBarClassName
3676
- : "border border-slate-200", onChange: function (e) {
3677
- if (isNaN(Number(e.target.value))) {
3678
- return;
3679
- }
3680
- onSearchValueChanged(e.target.value);
3681
- }, prefix: jsxRuntime.jsx(SearchOutlined$1, {}), placeholder: "Search by id #", style: {
3682
- minWidth: "300px",
3683
- }, value: search }) })) })), jsxRuntime.jsx("div", __assign({ className: "flex w-full shadow-padding-xb ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: jsxRuntime.jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat("shadow-".concat(shadow)), style: {
3684
- gridTemplateColumns: gridTemplateColumns(),
3685
- backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
3686
- } }, { children: isMobile ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: TransactionsListMobile({
3687
- transactions: transactions,
3688
- onTransactionClick: handleTransactionClick,
3689
- }) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: TransactionsListDesktop({
3690
- transactions: transactions,
3691
- onTransactionClick: handleTransactionClick,
3692
- }) })) })) })), useModal ? (jsxRuntime.jsx(antd.Modal, __assign({ title: "Basic Modal", open: drawerOpen, onOk: function () { return setDrawerOpen(false); }, onCancel: function () { return setDrawerOpen(false); }, width: 900, footer: null }, { children: jsxRuntime.jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsxRuntime.jsx(antd.Drawer, __assign({ title: drawerTitle(), onClose: function () { return setDrawerOpen(false); }, open: drawerOpen, width: 900 }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsxRuntime.jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxRuntime.jsxs(antd.Card, __assign({ className: "shadow-md" }, { children: [jsxRuntime.jsx(antd.Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Amount:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: common.formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Description:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Kind:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "State:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
3595
+ function handleDisplayClose() {
3596
+ onTransactionDisplayClose === null || onTransactionDisplayClose === void 0 ? void 0 : onTransactionDisplayClose(selectedTransaction);
3597
+ setDrawerOpen(false);
3598
+ }
3599
+ return (jsxRuntime.jsxs("div", __assign({ style: style }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full shadow-padding-xb gap-2 ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: [showTitle || showSearchBar ? (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-1" : "flex-row items-center", " justify-between") }, { children: [showTitle ? (jsxRuntime.jsx(Text$7, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title }))) : (jsxRuntime.jsx("div", {}) // Empty div so justify-between works
3600
+ ), showSearchBar && (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "") }, { children: jsxRuntime.jsx(antd.Input, { className: searchBarClassName
3601
+ ? searchBarClassName
3602
+ : "border border-slate-200", onChange: function (e) {
3603
+ if (isNaN(Number(e.target.value))) {
3604
+ return;
3605
+ }
3606
+ onSearchValueChanged(e.target.value);
3607
+ }, prefix: jsxRuntime.jsx(SearchOutlined$1, {}), placeholder: "Search by id #", style: {
3608
+ minWidth: "300px",
3609
+ }, value: search }) })))] }))) : null, jsxRuntime.jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat(shadow), style: {
3610
+ gridTemplateColumns: gridTemplateColumns(),
3611
+ backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
3612
+ } }, { children: isMobile ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: TransactionsListMobile({
3613
+ transactions: transactions,
3614
+ onTransactionClick: handleTransactionClick,
3615
+ }) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: TransactionsListDesktop({
3616
+ transactions: transactions,
3617
+ onTransactionClick: handleTransactionClick,
3618
+ }) })) }))] })), useModal ? (jsxRuntime.jsx(antd.Modal, __assign({ title: "Basic Modal", open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null }, { children: jsxRuntime.jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsxRuntime.jsx(antd.Drawer, __assign({ title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsxRuntime.jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxRuntime.jsxs(antd.Card, __assign({ className: "shadow-md" }, { children: [jsxRuntime.jsx(antd.Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Amount:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: common.formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Description:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Kind:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "State:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
3693
3619
  }
3694
3620
 
3695
3621
  function Quotes(_a) {
3696
- var className = _a.className, _b = _a.columns, columns = _b === void 0 ? ["date-and-title", "amount", "download"] : _b, entityId = _a.entityId, filter = _a.filter, _c = _a.noQuotesMessage, noQuotesMessage = _c === void 0 ? "There are no quotes" : _c; _a.onQuoteClick; var quoteComponent = _a.quoteComponent, searchBarClassName = _a.searchBarClassName, _d = _a.shadow, shadow = _d === void 0 ? "md" : _d, _e = _a.showSearchBar, showSearchBar = _e === void 0 ? true : _e, _f = _a.showTitle, showTitle = _f === void 0 ? true : _f, style = _a.style, _g = _a.suppressQuoteDisplay, suppressQuoteDisplay = _g === void 0 ? false : _g, _h = _a.useModal, useModal = _h === void 0 ? false : _h;
3622
+ var className = _a.className, _b = _a.columns, columns = _b === void 0 ? ["date-and-title", "amount", "download"] : _b, entityId = _a.entityId, filter = _a.filter, _c = _a.noQuotesMessage, noQuotesMessage = _c === void 0 ? "There are no quotes" : _c, onQuoteClick = _a.onQuoteClick, quoteComponent = _a.quoteComponent, searchBarClassName = _a.searchBarClassName, _d = _a.shadow, shadow = _d === void 0 ? "shadow-md" : _d, _e = _a.showSearchBar, showSearchBar = _e === void 0 ? true : _e, _f = _a.showTitle, showTitle = _f === void 0 ? true : _f, _g = _a.title, title = _g === void 0 ? "Past quotes" : _g, style = _a.style, _h = _a.suppressQuoteDisplay, suppressQuoteDisplay = _h === void 0 ? false : _h, _j = _a.useModal, useModal = _j === void 0 ? false : _j;
3697
3623
  var apiHost = React.useContext(BunnyContext).apiHost;
3698
- var _j = React.useState(null), component = _j[0], setComponent = _j[1];
3624
+ var _k = React.useState(null), component = _k[0], setComponent = _k[1];
3699
3625
  var contextValues = {
3700
3626
  columns: columns,
3701
3627
  kindsToShow: [],
3702
3628
  onTransactionClick: handleQuoteClick,
3629
+ onTransactionDisplayClose: function () {
3630
+ setComponent(jsxRuntime.jsx(jsxRuntime.Fragment, {}));
3631
+ },
3703
3632
  transactionComponent: component,
3633
+ transactionStateRenderer: quoteStateRenderer,
3704
3634
  showSearchBar: showSearchBar,
3705
3635
  showTitle: showTitle,
3636
+ title: title,
3706
3637
  className: className,
3707
3638
  shadow: shadow,
3708
3639
  searchBarClassName: searchBarClassName,
@@ -3714,7 +3645,29 @@ function Quotes(_a) {
3714
3645
  downloadTransactionLink: function (id) { return "".concat(apiHost, "/api/pdf/quote/").concat(id); },
3715
3646
  entityId: entityId,
3716
3647
  };
3648
+ function quoteStateRenderer(state) {
3649
+ // "DRAFT" | "SHARED" | "VIEWED" | "ACCEPTED" | "IN_APPROVAL" | "APPROVED" | "REJECTED";
3650
+ var getColor = function (state) {
3651
+ switch (state) {
3652
+ case "ACCEPTED":
3653
+ return "green";
3654
+ case "IN_APPROVAL":
3655
+ return "orange";
3656
+ case "APPROVED":
3657
+ return "green";
3658
+ case "REJECTED":
3659
+ return "red";
3660
+ case "DRAFT":
3661
+ case "SHARED":
3662
+ case "VIEWED":
3663
+ default:
3664
+ return "blue";
3665
+ }
3666
+ };
3667
+ return jsxRuntime.jsx(antd.Tag, __assign({ color: getColor(state) }, { children: lodash.capitalize(lodash.startCase(state)) }));
3668
+ }
3717
3669
  function handleQuoteClick(quote) {
3670
+ onQuoteClick === null || onQuoteClick === void 0 ? void 0 : onQuoteClick(quote);
3718
3671
  if (quoteComponent) {
3719
3672
  setComponent(quoteComponent);
3720
3673
  }
@@ -3738,9 +3691,17 @@ function QuotesWrapper() {
3738
3691
  }).data;
3739
3692
  if (data === undefined)
3740
3693
  return null;
3741
- var quotesAsTransactions = data.nodes.map(function (quote) { return ({
3694
+ // filter out quotes in draft state, they are not viewable
3695
+ var quotes = data.nodes
3696
+ .filter(function (quote) {
3697
+ return quote.state !== "DRAFT";
3698
+ })
3699
+ .sort(function (a, b) {
3700
+ return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
3701
+ });
3702
+ var quotesAsTransactions = quotes.map(function (quote) { return ({
3742
3703
  transactionableId: quote.id,
3743
- state: "unapplied",
3704
+ state: quote.state,
3744
3705
  amount: quote.amount || quote.amountDue,
3745
3706
  kind: "QUOTE",
3746
3707
  currencyId: quote.currencyId,
@@ -3749,7 +3710,7 @@ function QuotesWrapper() {
3749
3710
  },
3750
3711
  createdAt: quote.createdAt,
3751
3712
  }); });
3752
- return (jsxRuntime.jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search, title: "Past quotes" }));
3713
+ return (jsxRuntime.jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search }));
3753
3714
  }
3754
3715
 
3755
3716
  var DrawerHeader = function (_a) {
@@ -3757,99 +3718,19 @@ var DrawerHeader = function (_a) {
3757
3718
  return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsxRuntime.jsx("div", __assign({ className: "text-xl" }, { children: title })), jsxRuntime.jsx("button", __assign({ onClick: onClose, className: "ant-drawer-close" }, { children: jsxRuntime.jsx(CloseOutlined$1, {}) }))] })), description && jsxRuntime.jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
3758
3719
  };
3759
3720
 
3760
- var Card = function (_a) {
3761
- var children = _a.children, className = _a.className, style = _a.style;
3762
- var darkMode = React.useContext(BunnyContext).darkMode;
3763
- return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col rounded-md shadow-md ".concat(className), style: __assign(__assign({}, style), { backgroundColor: darkMode
3764
- ? "var(--row-background-dark)"
3765
- : "var(--row-background)" }) }, { children: children })));
3766
- };
3767
-
3768
- var LargeCardIcon = function () {
3769
- return (jsxRuntime.jsx("svg", __assign({ width: "72", height: "56", viewBox: "0 0 72 56", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: jsxRuntime.jsx("path", { d: "M8 0H64C68.375 0 72 3.625 72 8V12H0V8C0 3.625 3.5 0 8 0ZM72 24V48C72 52.5 68.375 56 64 56H8C3.5 56 0 52.5 0 48V24H72ZM14 40C12.875 40 12 41 12 42C12 43.125 12.875 44 14 44H22C23 44 24 43.125 24 42C24 41 23 40 22 40H14ZM28 42C28 43.125 28.875 44 30 44H46C47 44 48 43.125 48 42C48 41 47 40 46 40H30C28.875 40 28 41 28 42Z", fill: "#E2E8F0" }) })));
3770
- };
3771
-
3772
- var PlusIcon = function (_a) {
3773
- var color = _a.color;
3774
- return (jsxRuntime.jsxs("svg", __assign({ width: "14", height: "15", viewBox: "0 0 14 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsx("path", { d: "M2.9165 7.5H11.0832", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M7 3.41663V11.5833", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
3775
- };
3776
-
3777
- var Text$6 = antd.Typography.Text;
3778
- var CreditCard = function (_a) {
3779
- var _b, _c, _d;
3780
- var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData;
3781
- var isExpired = function (paymentMethodData) {
3782
- // paymentMethodData.expirationDate
3783
- var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
3784
- return expDate.isBefore(dayjs());
3785
- };
3786
- var isMobile = common.useIsMobile();
3787
- var apiHost = React.useContext(BunnyContext).apiHost;
3788
- return (jsxRuntime.jsxs(Card, __assign({ className: "shadow-md m-0" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [getCardImage((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) && (jsxRuntime.jsx("img", { alt: "Card", width: "24px", src: "".concat(apiHost, "/portal/").concat(getCardImage((_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.issuer)) })), jsxRuntime.jsx(Text$6, { children: (_d = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _d === void 0 ? void 0 : _d.description })] })), jsxRuntime.jsx(antd.Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsxRuntime.jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(antd.Divider, {}), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsxRuntime.jsx(CardAttribute, { title: "EXPIRATION", value: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).format("MM/YY") }), isMobile && (jsxRuntime.jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
3789
- };
3790
- var CardAttribute = function (_a) {
3791
- var title = _a.title, value = _a.value;
3792
- return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsxRuntime.jsx(Text$6, { children: value })] })));
3793
- };
3794
- var CardActions = function (_a) {
3795
- var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
3796
- var isMobile = common.useIsMobile();
3797
- return (jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-6 ".concat(isMobile ? "justify-center mt-4" : "") }, { children: [jsxRuntime.jsx(antd.Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove payment method" })) })), jsxRuntime.jsx(antd.Divider, { style: { height: "24px" }, type: "vertical" }), jsxRuntime.jsx(antd.Button, __assign({ onClick: onClickUpdate, type: "primary" }, { children: "Update" }))] })));
3798
- };
3799
- var EmptyCard = function (_a) {
3800
- var onClick = _a.onClick;
3801
- var brandColor = React.useContext(BrandContext).brandColor;
3802
- return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center w-full pt-8 px-4 pb-6 cursor-pointer bg-white shadow-md rounded-md", onClick: onClick }, { children: [jsxRuntime.jsx(LargeCardIcon, {}), jsxRuntime.jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsxRuntime.jsx(antd.Button, __assign({ type: "link" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsxRuntime.jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
3803
- };
3804
- var getCardImage = function (issuer) {
3805
- if (issuer === "visa")
3806
- return "Visa_Brandmark_Blue_RGB_2021.png";
3807
- else if (issuer === "mastercard")
3808
- return "mc_symbol_opt_73_3x.png";
3809
- };
3810
-
3811
- var PaymentMethodContext = React.createContext({});
3812
-
3813
- var ActualPaymentMethod = function (_a) {
3814
- var entityId = _a.entityId;
3815
- var _b = React.useContext(BunnyContext), token = _b.token, apiHost = _b.apiHost, graphQLClient = _b.graphQLClient, onErrorNavigate = _b.onErrorNavigate;
3816
- var accountId = React.useContext(PaymentContext).accountId;
3721
+ var PaymentMethod = function (_a) {
3722
+ var entityId = _a.entityId, className = _a.className, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, _c = _a.cardEnabled, cardEnabled = _c === void 0 ? true : _c;
3723
+ var _d = React.useContext(BunnyContext), token = _d.token, apiHost = _d.apiHost, graphQLClient = _d.graphQLClient, onTokenExpired = _d.onTokenExpired;
3817
3724
  // Hooks
3818
3725
  var queryClient = reactQuery.useQueryClient();
3819
3726
  var paymentPlugins = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: token }).paymentPlugins;
3820
- var showErrorNotification = common.useErrorNotification();
3821
3727
  var showSuccessNotification = common.useSuccessNotification();
3822
- var handleAllErrorFormats = common.useAllErrorFormats(onErrorNavigate ||
3823
- (function (url) {
3824
- console.log("navigate to", url, " not implemented");
3825
- }));
3728
+ var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
3826
3729
  var isMobile = common.useIsMobile();
3827
3730
  var data = usePaymentMethod(graphQLClient).data;
3731
+ var onClickRemove = useRemovePaymentMethod(paymentPlugins || [], token, apiHost);
3828
3732
  // Local state
3829
- var _c = React.useState(false), showModal = _c[0], setShowModal = _c[1];
3830
- var _d = React.useState(false), isSaving = _d[0], setIsSaving = _d[1];
3831
- var plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (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); });
3832
- var onClickRemove = function () {
3833
- if (data && plugin) {
3834
- common.invokePlugin({
3835
- plugin: plugin,
3836
- method: "remove_payment_method",
3837
- payload: {
3838
- payment_method_id: data.id,
3839
- account_id: accountId,
3840
- },
3841
- token: token,
3842
- apiHost: apiHost,
3843
- })
3844
- .then(function () {
3845
- showSuccessNotification("Payment method was removed", "Success");
3846
- queryClient.setQueryData(common.QueryKeyFactory.default.accountPaymentMethodKey, null);
3847
- })
3848
- .catch(function (error) {
3849
- showErrorNotification(error.message, "Error removing Payment Method");
3850
- });
3851
- }
3852
- };
3733
+ var _e = React.useState(false), showModal = _e[0], setShowModal = _e[1];
3853
3734
  var onSuccess = function () {
3854
3735
  queryClient.invalidateQueries({
3855
3736
  queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
@@ -3859,25 +3740,18 @@ var ActualPaymentMethod = function (_a) {
3859
3740
  };
3860
3741
  if (data === undefined)
3861
3742
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
3862
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [data ? (jsxRuntime.jsx(CreditCard, { onClickRemove: onClickRemove, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data })) : (jsxRuntime.jsx(EmptyCard, { onClick: function () { return setShowModal(true); } })), jsxRuntime.jsx(antd.Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
3743
+ return (jsxRuntime.jsxs("div", __assign({ className: "".concat(className) }, { children: [data ? (jsxRuntime.jsx(CreditCard, { onClickRemove: function () { return onClickRemove(data); }, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data, shadow: shadow, cardEnabled: cardEnabled })) : (jsxRuntime.jsx(EmptyCard, { onClick: function () { return setShowModal(true); }, shadow: shadow, cardEnabled: cardEnabled })), jsxRuntime.jsx(antd.Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
3863
3744
  body: isMobile
3864
3745
  ? {
3865
3746
  padding: "1rem 0 0",
3866
3747
  }
3867
3748
  : {},
3868
- wrapper: isMobile ? { width: "100vw" } : { width: "min-content" },
3869
- }, title: jsxRuntime.jsx(DrawerHeader, { onClose: function () { return setShowModal(false); }, title: "New payment method" }) }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, isSaving: isSaving, onFail: function (error) {
3749
+ }, title: jsxRuntime.jsx(DrawerHeader, { onClose: function () { return setShowModal(false); }, title: "New payment method" }) }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
3870
3750
  handleAllErrorFormats(error);
3871
- setIsSaving(false);
3872
3751
  }, onPaymentSuccess: function () {
3873
3752
  onSuccess();
3874
- setIsSaving(false);
3875
- }, setIsSaving: setIsSaving }) }))] }));
3753
+ } }) }))] })));
3876
3754
  };
3877
- function PaymentMethod(_a) {
3878
- var entityId = _a.entityId, footer = _a.footer;
3879
- return (jsxRuntime.jsx(PaymentMethodContext.Provider, __assign({ value: { footer: footer } }, { children: jsxRuntime.jsx(ActualPaymentMethod, { entityId: entityId }) })));
3880
- }
3881
3755
 
3882
3756
  var pageWrapperClassName = function (isMobile) {
3883
3757
  return "flex flex-col grow pt-4 ".concat(isMobile ? "pb-4 overflow-hidden" : "pb-8", " ").concat("content-container");
@@ -3912,6 +3786,30 @@ var quoteRecalculateTaxes = function (_a) {
3912
3786
  });
3913
3787
  };
3914
3788
 
3789
+ var MUTATION$6 = "{\n currentUser {\n taxationRequiredAccountFields\n }\n}";
3790
+ var getTaxationRequiredAccountFields = function (_a) {
3791
+ var token = _a.token, apiHost = _a.apiHost;
3792
+ return __awaiter(void 0, void 0, void 0, function () {
3793
+ var response;
3794
+ var _b, _c;
3795
+ return __generator(this, function (_d) {
3796
+ switch (_d.label) {
3797
+ case 0: return [4 /*yield*/, common.gqlRequest({
3798
+ query: MUTATION$6,
3799
+ token: token,
3800
+ apiHost: apiHost,
3801
+ })];
3802
+ case 1:
3803
+ response = _d.sent();
3804
+ return [2 /*return*/, ((_c = (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.taxationRequiredAccountFields) === null || _c === void 0 ? void 0 : _c.length) > 0
3805
+ ? response.currentUser
3806
+ .taxationRequiredAccountFields
3807
+ : null];
3808
+ }
3809
+ });
3810
+ });
3811
+ };
3812
+
3915
3813
  var useHasTaxPlugin = function (_a) {
3916
3814
  var entityId = _a.entityId, apiHost = _a.apiHost, token = _a.token;
3917
3815
  var plugins = usePlugins({
@@ -3922,7 +3820,7 @@ var useHasTaxPlugin = function (_a) {
3922
3820
  return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some(function (plugin) { return plugin.type === "taxation"; }));
3923
3821
  };
3924
3822
 
3925
- var MUTATION$6 = "\nmutation accountUpdate(\n $id: ID!,\n $attributes: AccountAttributes!) {\n accountUpdate(\n id: $id,\n attributes: $attributes\n ) {\n account { id }\n errors\n }\n }\n";
3823
+ var MUTATION$5 = "\nmutation accountUpdate(\n $id: ID!,\n $attributes: AccountAttributes!) {\n accountUpdate(\n id: $id,\n attributes: $attributes\n ) {\n account {\n id\n billingCountry\n billingState\n billingStreet\n billingCity\n billingZip\n name\n }\n errors\n }\n }\n";
3926
3824
  var accountUpdate = function (_a) {
3927
3825
  var accountId = _a.accountId, attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
3928
3826
  return __awaiter(void 0, void 0, void 0, function () {
@@ -3933,7 +3831,7 @@ var accountUpdate = function (_a) {
3933
3831
  case 0:
3934
3832
  vars = { id: accountId, attributes: attributes };
3935
3833
  return [4 /*yield*/, common.gqlRequest({
3936
- query: MUTATION$6,
3834
+ query: MUTATION$5,
3937
3835
  token: token,
3938
3836
  vars: vars,
3939
3837
  apiHost: apiHost,
@@ -3993,11 +3891,16 @@ var FormBillingState = function (_a) {
3993
3891
  return (jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing state", name: "billingState", rules: [{ required: billingStateRequired }] }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "State" }) })));
3994
3892
  };
3995
3893
 
3894
+ var getQuoteAmountDue = function (quote) {
3895
+ return quote.amountDue;
3896
+ };
3897
+
3996
3898
  var QuoteCheckout = function (_a) {
3997
- var account = _a.account, isSaving = _a.isSaving, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, setIsSaving = _a.setIsSaving, taxationRequiredAccountFields = _a.taxationRequiredAccountFields, entityId = _a.entityId;
3899
+ var account = _a.account, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, taxationRequiredAccountFields = _a.taxationRequiredAccountFields, entityId = _a.entityId;
3998
3900
  // Context
3999
3901
  var isMobile = common.useIsMobile();
4000
3902
  var _b = React.useContext(BunnyContext), apiHost = _b.apiHost, token = _b.token;
3903
+ var _c = React.useState(false), isSaving = _c[0], setIsSaving = _c[1];
4001
3904
  var paymentRequired = getQuoteAmountDue(quote) > 0;
4002
3905
  var checkoutMutation = reactQuery.useMutation({
4003
3906
  mutationFn: function (_a) {
@@ -4041,6 +3944,7 @@ var QuoteCheckout = function (_a) {
4041
3944
  return __awaiter(void 0, void 0, void 0, function () {
4042
3945
  var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
4043
3946
  return __generator(this, function (_b) {
3947
+ setIsSaving(true);
4044
3948
  if (pluginPaymentResponse) {
4045
3949
  token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
4046
3950
  checkoutMutation.mutate({
@@ -4063,48 +3967,34 @@ var QuoteCheckout = function (_a) {
4063
3967
  else {
4064
3968
  checkoutMutation.mutate({});
4065
3969
  }
3970
+ setIsSaving(false);
4066
3971
  return [2 /*return*/];
4067
3972
  });
4068
3973
  });
4069
3974
  };
4070
3975
  if (taxationRequiredAccountFields)
4071
3976
  return (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsx(TaxationForm, { account: account, quote: quote }) })));
4072
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsx(PaymentForm, { entityId: entityId, isSaving: isSaving, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote, setIsSaving: setIsSaving })) : (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsxRuntime.jsx(antd.Button, __assign({ disabled: isSaving, onClick: function () {
4073
- setIsSaving(true);
3977
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote })) : (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsxRuntime.jsx(antd.Button, __assign({ onClick: function () {
4074
3978
  handleCheckout({});
4075
3979
  }, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsxRuntime.jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
4076
3980
  };
4077
-
4078
- var MUTATION$5 = "{\n currentUser {\n taxationRequiredAccountFields\n }\n}";
4079
- var getTaxationRequiredAccountFields = function (_a) {
4080
- var token = _a.token, apiHost = _a.apiHost;
4081
- return __awaiter(void 0, void 0, void 0, function () {
4082
- var response;
4083
- var _b, _c;
4084
- return __generator(this, function (_d) {
4085
- switch (_d.label) {
4086
- case 0: return [4 /*yield*/, common.gqlRequest({
4087
- query: MUTATION$5,
4088
- token: token,
4089
- apiHost: apiHost,
4090
- })];
4091
- case 1:
4092
- response = _d.sent();
4093
- return [2 /*return*/, ((_c = (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.taxationRequiredAccountFields) === null || _c === void 0 ? void 0 : _c.length) > 0
4094
- ? response.currentUser
4095
- .taxationRequiredAccountFields
4096
- : null];
4097
- }
4098
- });
4099
- });
3981
+ var PaymentFormWrapper = function (_a) {
3982
+ var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
3983
+ var isMobile = common.useIsMobile();
3984
+ return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-6 shrink-0 ".concat(isMobile ? "w-full shadow-padding-xb" : "", " ").concat(className), style: __assign({}, (isMobile
3985
+ ? setMaxHeight
3986
+ ? { maxHeight: "60vh" }
3987
+ : {}
3988
+ : {
3989
+ width: "350px",
3990
+ })) }, { children: children })));
4100
3991
  };
4101
3992
 
4102
3993
  var queryKeyFactory = common.QueryKeyFactory.default;
4103
3994
  var Checkout = function (_a) {
4104
3995
  var _b, _c;
4105
3996
  var entityId = _a.entityId, onCancel = _a.onCancel, onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, open = _a.open, quote = _a.quote, selectedPriceList = _a.selectedPriceList, token = _a.token, _d = _a.quantity, quantity = _d === void 0 ? 0 : _d;
4106
- var _e = React.useContext(BunnyContext), apiHost = _e.apiHost; _e.window;
4107
- var _f = React.useState(false), isSaving = _f[0], setIsSaving = _f[1];
3997
+ var apiHost = React.useContext(BunnyContext).apiHost;
4108
3998
  var isMobile = common.useIsMobile();
4109
3999
  var hasTaxPlugin = useHasTaxPlugin({
4110
4000
  entityId: entityId,
@@ -4113,20 +4003,20 @@ var Checkout = function (_a) {
4113
4003
  });
4114
4004
  var queryClient = reactQuery.useQueryClient();
4115
4005
  // Queries
4116
- var _g = reactQuery.useQuery({
4006
+ var _e = reactQuery.useQuery({
4117
4007
  queryKey: ["getTaxationRequiredAccountFields", token],
4118
4008
  queryFn: function () { return getTaxationRequiredAccountFields({ token: token, apiHost: apiHost }); },
4119
4009
  enabled: Boolean(quote),
4120
4010
  staleTime: 0,
4121
- }), taxationRequiredAccountFields = _g.data, isLoadingTaxationRequiredAccountFields = _g.isLoading;
4122
- var _h = reactQuery.useQuery({
4011
+ }), taxationRequiredAccountFields = _e.data, isLoadingTaxationRequiredAccountFields = _e.isLoading;
4012
+ var _f = reactQuery.useQuery({
4123
4013
  queryKey: ["account", quote === null || quote === void 0 ? void 0 : quote.accountId],
4124
4014
  queryFn: function () {
4125
4015
  return (quote === null || quote === void 0 ? void 0 : quote.accountId) && common.getAccount({ id: quote.accountId, token: token, apiHost: apiHost });
4126
4016
  },
4127
4017
  enabled: Boolean(quote === null || quote === void 0 ? void 0 : quote.accountId) &&
4128
4018
  ((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
4129
- }), account = _h.data, isLoadingAccount = _h.isLoading;
4019
+ }), account = _f.data, isLoadingAccount = _f.isLoading;
4130
4020
  reactQuery.useQuery({
4131
4021
  queryKey: queryKeyFactory.createQuoteTaxCalculateKey(quote === null || quote === void 0 ? void 0 : quote.id),
4132
4022
  queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -4163,30 +4053,24 @@ var Checkout = function (_a) {
4163
4053
  return null;
4164
4054
  return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
4165
4055
  zIndex: 1001,
4166
- } }, { children: jsxRuntime.jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsxRuntime.jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxRuntime.jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "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 : quote ? quote.formattedQuote.html : "" })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsxRuntime.jsx(antd.Divider, { className: "h-full", type: "vertical" })), invoice ? (jsxRuntime.jsx(InvoiceCheckout, { invoice: invoice, isSaving: isSaving, onFail: function (error) {
4056
+ } }, { children: jsxRuntime.jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsxRuntime.jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxRuntime.jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "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 : quote ? quote.formattedQuote.html : "" })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsxRuntime.jsx(antd.Divider, { className: "h-full", type: "vertical" })), invoice ? (jsxRuntime.jsx(InvoiceCheckout, { invoice: invoice, onFail: function (error) {
4167
4057
  onFail(error);
4168
- setIsSaving(false);
4169
4058
  }, onSuccess: function (_a) {
4170
4059
  var savePaymentMethod = _a.savePaymentMethod;
4171
4060
  onSuccess({ savePaymentMethod: savePaymentMethod });
4172
- setIsSaving(false);
4173
- }, setIsSaving: setIsSaving, entityId: entityId })) : quote ? (jsxRuntime.jsx(QuoteCheckout, { account: account, entityId: entityId, isSaving: isSaving, onFail: function (error) {
4061
+ }, entityId: entityId })) : quote ? (jsxRuntime.jsx(QuoteCheckout, { account: account, entityId: entityId, onFail: function (error) {
4174
4062
  onFail(error);
4175
- setIsSaving(false);
4176
4063
  }, onSuccess: function (_a) {
4177
4064
  var savePaymentMethod = _a.savePaymentMethod;
4178
4065
  onSuccess({ savePaymentMethod: savePaymentMethod });
4179
- setIsSaving(false);
4180
- }, quote: quote, setIsSaving: setIsSaving, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsxRuntime.jsx(PaymentForm, { entityId: entityId, isSaving: isSaving, onFail: function (error) {
4066
+ }, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
4181
4067
  onFail(error);
4182
- setIsSaving(false);
4183
4068
  }, onPaymentSuccess: function (_a) {
4184
4069
  var pluginPaymentResponse = _a.pluginPaymentResponse;
4185
4070
  onSuccess({
4186
4071
  savePaymentMethod: pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.savePaymentMethod,
4187
4072
  });
4188
- setIsSaving(false);
4189
- }, setIsSaving: setIsSaving }))] }))] })) })));
4073
+ } }))] }))] })) })));
4190
4074
  };
4191
4075
 
4192
4076
  var MUTATION$4 = function () { return "\nmutation AccountSignup (\n $entityId: ID!,\n $pluginId: String!,\n $paymentMethodId: String,\n $priceListCode: String!,\n $accountId: ID!,\n $quoteId: ID!\n) {\n accountSignup(\n entityId: $entityId,\n pluginId: $pluginId,\n paymentMethodId: $paymentMethodId,\n priceListCode: $priceListCode,\n accountId: $accountId,\n quoteId: $quoteId\n ) {\n errors\n quote {\n acceptedByName\n acceptedByTitle\n accountId\n amount\n amountDue\n applicationDate\n applied\n backdatedPeriods\n backdatedQuote\n billingDay\n contactId\n createdAt\n credits\n currencyId\n dealId\n discount\n discountValue\n endDate\n evergreen\n expiresAt\n id\n invoiceImmediately\n invoiceImmediatelyAvailable\n invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n number\n ownerId\n payableId\n periodAmount\n poNumber\n requiresApproval\n smallUnitAmountDue\n splitInvoice\n startDate\n state\n subtotal\n taxAmount\n taxCode\n updatedAt\n uuid\n }\n }\n}"; };
@@ -4224,7 +4108,32 @@ var accountSignup = function (_a) {
4224
4108
  });
4225
4109
  };
4226
4110
 
4227
- var MUTATION$3 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $entityId: ID!,\n $priceListCode: String!\n) {\n quoteAccountSignup(\n entityId: $entityId,\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact\n ) {\n account {\n id\n }\n amount\n currencyId\n quote {\n id\n }\n tenant {\n code\n }\n errors\n }\n}"; };
4111
+ var MUTATION$3 = "\n mutation portalSessionCreate ($tenantCode: String!, $expiry: Int!, $returnUrl: String!) {\n portalSessionCreate (tenantCode: $tenantCode, expiry: $expiry, returnUrl: $returnUrl) {\n errors\n token\n }\n }\n";
4112
+ var portalSessionCreate = function (_a) {
4113
+ var tenantCode = _a.tenantCode, expiry = _a.expiry, returnUrl = _a.returnUrl, token = _a.token, apiHost = _a.apiHost;
4114
+ return __awaiter(void 0, void 0, void 0, function () {
4115
+ var response, errors;
4116
+ var _b;
4117
+ return __generator(this, function (_c) {
4118
+ switch (_c.label) {
4119
+ case 0: return [4 /*yield*/, common.gqlRequest({
4120
+ query: MUTATION$3,
4121
+ token: token,
4122
+ vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
4123
+ apiHost: apiHost,
4124
+ })];
4125
+ case 1:
4126
+ response = _c.sent();
4127
+ errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
4128
+ if (errors)
4129
+ throw errors;
4130
+ return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.portalSessionCreate) === null || _b === void 0 ? void 0 : _b.token];
4131
+ }
4132
+ });
4133
+ });
4134
+ };
4135
+
4136
+ var MUTATION$2 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $entityId: ID!,\n $priceListCode: String!\n) {\n quoteAccountSignup(\n entityId: $entityId,\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact\n ) {\n account {\n id\n }\n quote {\n acceptedByName\n acceptedByTitle\n accountId\n amount\n amountDue\n applicationDate\n applied\n backdatedPeriods\n backdatedQuote\n billingDay\n contactId\n createdAt\n credits\n currencyId\n dealId\n discount\n discountValue\n endDate\n evergreen\n expiresAt\n id\n invoiceImmediately\n invoiceImmediatelyAvailable\n invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n number\n ownerId\n payableId\n periodAmount\n poNumber\n requiresApproval\n smallUnitAmountDue\n splitInvoice\n startDate\n state\n subtotal\n taxAmount\n taxCode\n updatedAt\n uuid\n }\n tenant {\n code\n }\n errors\n }\n}"; };
4228
4137
  var quoteAccountSignup = function (_a) {
4229
4138
  var token = _a.token, apiHost = _a.apiHost, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
4230
4139
  return __awaiter(void 0, void 0, void 0, function () {
@@ -4240,7 +4149,7 @@ var quoteAccountSignup = function (_a) {
4240
4149
  billingContact: billingContact,
4241
4150
  };
4242
4151
  return [4 /*yield*/, common.gqlRequest({
4243
- query: MUTATION$3(),
4152
+ query: MUTATION$2(),
4244
4153
  token: token,
4245
4154
  vars: vars,
4246
4155
  apiHost: apiHost,
@@ -4256,7 +4165,7 @@ var quoteAccountSignup = function (_a) {
4256
4165
  });
4257
4166
  };
4258
4167
 
4259
- var MUTATION$2 = function () { return "\nquery PriceList($code: String!) {\n priceList (code: $code) {\n basePrice\n code\n createdAt\n currencyId\n id\n isVisible\n name\n periodMonths\n planId\n priceDescription\n productId\n sku\n trialAllowed\n trialLengthDays\n updatedAt\n }\n}"; };
4168
+ var MUTATION$1 = function () { return "\nquery PriceList($code: String!) {\n priceList (code: $code) {\n basePrice\n code\n createdAt\n currencyId\n id\n isVisible\n name\n periodMonths\n planId\n priceDescription\n productId\n sku\n trialAllowed\n trialLengthDays\n updatedAt\n }\n}"; };
4260
4169
  var getPriceList = function (_a) {
4261
4170
  var token = _a.token, code = _a.code, apiHost = _a.apiHost;
4262
4171
  return __awaiter(void 0, void 0, void 0, function () {
@@ -4264,7 +4173,7 @@ var getPriceList = function (_a) {
4264
4173
  return __generator(this, function (_b) {
4265
4174
  switch (_b.label) {
4266
4175
  case 0: return [4 /*yield*/, common.gqlRequest({
4267
- query: MUTATION$2(),
4176
+ query: MUTATION$1(),
4268
4177
  token: token,
4269
4178
  vars: { code: code },
4270
4179
  apiHost: apiHost,
@@ -4278,8 +4187,8 @@ var getPriceList = function (_a) {
4278
4187
  };
4279
4188
 
4280
4189
  function PaymentForms(_a) {
4281
- var quote = _a.quote, paying = _a.paying, setIsPaying = _a.setIsPaying, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, entityId = _a.entityId;
4282
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: accountId && (jsxRuntime.jsx(PaymentContext.Provider, __assign({ value: { accountId: accountId, displayPayButtonNameAnyways: true } }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, isSaving: paying, setIsSaving: setIsPaying, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSaveSuccess }) }))) })) : (jsxRuntime.jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
4190
+ var quote = _a.quote, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, entityId = _a.entityId, accountId = _a.accountId;
4191
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSaveSuccess, accountId: accountId, quote: quote }) })) : (jsxRuntime.jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
4283
4192
  }
4284
4193
  function InitialSignupForm(_a) {
4285
4194
  var onSubmit = _a.onSubmit, submitting = _a.submitting;
@@ -4294,7 +4203,7 @@ function InitialSignupForm(_a) {
4294
4203
  var _b = e.target, name = _b.name, value = _b.value;
4295
4204
  setFormData(__assign(__assign({}, formData), (_a = {}, _a[name] = value, _a)));
4296
4205
  };
4297
- return (jsxRuntime.jsxs(antd.Form, __assign({ className: "flex w-1/2 flex-col justify-between h-full", onFinish: function () { return onSubmit(formData); } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-col space-y-2" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ rules: [{ required: true, message: "Please input your first name!" }], initialValue: formData.firstName }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "First name", value: formData.firstName, onChange: function (e) {
4206
+ return (jsxRuntime.jsxs(antd.Form, __assign({ className: "flex flex-col justify-between h-full w-full", onFinish: function () { return onSubmit(formData); } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-col space-y-2" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ rules: [{ required: true, message: "Please input your first name!" }], initialValue: formData.firstName }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "First name", value: formData.firstName, onChange: function (e) {
4298
4207
  handleInputChange(e);
4299
4208
  setFormData(__assign(__assign({}, formData), { firstName: e.target.value }));
4300
4209
  } }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ rules: [{ required: true, message: "Please input your last name!" }], initialValue: formData.lastName }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Last name", value: formData.lastName, onChange: function (e) {
@@ -4314,61 +4223,40 @@ function InitialSignupForm(_a) {
4314
4223
  } }) }))] })), jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsx(antd.Button, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
4315
4224
  }
4316
4225
 
4317
- var Title = antd.Typography.Title, Text$5 = antd.Typography.Text;
4226
+ var Title = antd.Typography.Title, Text$6 = antd.Typography.Text;
4318
4227
  function PaymentSuccessDisplay(_a) {
4319
4228
  var amountPaid = _a.amountPaid, className = _a.className, companyName = _a.companyName, returnUrl = _a.returnUrl, style = _a.style;
4320
4229
  var window = React.useContext(BunnyContext).window;
4321
- return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsxRuntime.jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxRuntime.jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", common.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxRuntime.jsxs(Text$5, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
4230
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsxRuntime.jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxRuntime.jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", common.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxRuntime.jsxs(Text$6, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
4322
4231
  }
4323
4232
 
4324
- var Text$4 = antd.Typography.Text;
4233
+ var Text$5 = antd.Typography.Text;
4325
4234
  function PriceListDisplay(_a) {
4326
4235
  var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
4327
4236
  if (!priceListData)
4328
4237
  return null;
4329
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsxRuntime.jsx(antd.Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxRuntime.jsx(Text$4, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxRuntime.jsxs(Text$4, __assign({ className: "font-bold text-xl" }, { children: [common.formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxRuntime.jsxs(Text$4, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsxRuntime.jsx(Text$4, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))] })) })) }));
4238
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsxRuntime.jsx(antd.Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxRuntime.jsx(Text$5, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxRuntime.jsxs(Text$5, __assign({ className: "font-bold text-xl" }, { children: [common.formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxRuntime.jsxs(Text$5, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsxRuntime.jsx(Text$5, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))] })) })) }));
4330
4239
  }
4331
4240
 
4332
- var MUTATION$1 = "\n mutation portalSessionCreate ($tenantCode: String!, $expiry: Int!, $returnUrl: String!) {\n portalSessionCreate (tenantCode: $tenantCode, expiry: $expiry, returnUrl: $returnUrl) {\n errors\n token\n }\n }\n";
4333
- var portalSessionCreate = function (_a) {
4334
- var tenantCode = _a.tenantCode, expiry = _a.expiry, returnUrl = _a.returnUrl, token = _a.token, apiHost = _a.apiHost;
4335
- return __awaiter(void 0, void 0, void 0, function () {
4336
- var response, errors;
4337
- var _b;
4338
- return __generator(this, function (_c) {
4339
- switch (_c.label) {
4340
- case 0: return [4 /*yield*/, common.gqlRequest({
4341
- query: MUTATION$1,
4342
- token: token,
4343
- vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
4344
- apiHost: apiHost,
4345
- })];
4346
- case 1:
4347
- response = _c.sent();
4348
- errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
4349
- if (errors)
4350
- throw errors;
4351
- return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.portalSessionCreate) === null || _b === void 0 ? void 0 : _b.token];
4352
- }
4353
- });
4354
- });
4355
- };
4356
-
4357
4241
  var showErrorNotification = common.useErrorNotification();
4358
4242
  function Signup(_a) {
4359
- var companyName = _a.companyName, entityId = _a.entityId, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl;
4243
+ var companyName = _a.companyName, entityId = _a.entityId, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, _b = _a.isCardEnabled, isCardEnabled = _b === void 0 ? true : _b, className = _a.className, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, style = _a.style;
4360
4244
  // Hooks
4361
- var _b = React.useContext(BunnyContext), apiHost = _b.apiHost, token = _b.token; _b.window;
4245
+ var _d = React.useContext(BunnyContext), apiHost = _d.apiHost, token = _d.token, graphQLClient = _d.graphQLClient;
4362
4246
  var isMobile = common.useIsMobile();
4363
4247
  var topNavImageUrl = React.useContext(BrandContext).topNavImageUrl;
4364
- var _c = React.useState(undefined), quote = _c[0], setQuote = _c[1];
4365
- var _d = React.useState(undefined), accountId = _d[0], setAccountId = _d[1];
4366
- var _e = React.useState(undefined), quoteId = _e[0], setQuoteId = _e[1];
4367
- var _f = React.useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
4368
- var _g = React.useState(undefined), formData = _g[0], setFormData = _g[1];
4369
- var _h = React.useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
4370
- var _j = React.useState(false), paying = _j[0], setIsPaying = _j[1];
4371
- var _k = React.useState(false), purchaseSucceeded = _k[0], setPurchaseSucceeded = _k[1];
4248
+ var _e = React.useState(undefined), quote = _e[0], setQuote = _e[1];
4249
+ var _f = React.useState(undefined), accountId = _f[0], setAccountId = _f[1];
4250
+ var _g = React.useState(undefined), quoteId = _g[0], setQuoteId = _g[1];
4251
+ var _h = React.useState(undefined), portalSessionToken = _h[0], setPortalSessionToken = _h[1];
4252
+ var _j = React.useState(undefined), formData = _j[0], setFormData = _j[1];
4253
+ var _k = React.useState(false), proceedingToPayment = _k[0], setProceedingToPayment = _k[1];
4254
+ var _l = React.useState(false), purchaseSucceeded = _l[0], setPurchaseSucceeded = _l[1];
4255
+ var _m = React.useState(undefined), paymentMethodGraphQLClient = _m[0], setPaymentMethodGraphQLClient = _m[1];
4256
+ var paymentMethod = usePaymentMethod(paymentMethodGraphQLClient || graphQLClient, accountId).data;
4257
+ var queryClient = reactQuery.useQueryClient();
4258
+ // console.log("signup paymentMethod", paymentMethod);
4259
+ console.log("signup accountId", accountId);
4372
4260
  // Queries
4373
4261
  var priceListData = reactQuery.useQuery({
4374
4262
  queryKey: ["priceList", priceListCode],
@@ -4407,6 +4295,12 @@ function Signup(_a) {
4407
4295
  case 2:
4408
4296
  portalSessionToken = _a.sent();
4409
4297
  setPortalSessionToken(portalSessionToken);
4298
+ setPaymentMethodGraphQLClient(createGraphQLClient(portalSessionToken, apiHost || ""));
4299
+ // We must invalidate the accountPaymentMethodKey query in order to clear payment methods from the provided api token,
4300
+ // to instead use paymentMethods from portalSessionToken.
4301
+ queryClient.invalidateQueries({
4302
+ queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
4303
+ });
4410
4304
  setQuoteId(data.quote.id);
4411
4305
  setProceedingToPayment(false);
4412
4306
  setQuote({
@@ -4419,11 +4313,10 @@ function Signup(_a) {
4419
4313
  });
4420
4314
  }
4421
4315
  function handlePaymentSaveSuccess(paymentSuccess) {
4422
- var _a;
4423
4316
  return __awaiter(this, void 0, void 0, function () {
4424
4317
  var response, plugin;
4425
- return __generator(this, function (_b) {
4426
- switch (_b.label) {
4318
+ return __generator(this, function (_a) {
4319
+ switch (_a.label) {
4427
4320
  case 0:
4428
4321
  if (!formData) {
4429
4322
  throw new Error("Form data is required");
@@ -4444,14 +4337,13 @@ function Signup(_a) {
4444
4337
  apiHost: apiHost,
4445
4338
  entityId: entityId,
4446
4339
  quoteId: quoteId,
4447
- paymentMethodId: (_a = paymentSuccess.savedPaymentMethodResponse) === null || _a === void 0 ? void 0 : _a.paymentMethodId.toString(),
4340
+ paymentMethodId: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id,
4448
4341
  pluginId: plugin.id.toString(),
4449
4342
  priceListCode: priceListCode,
4450
4343
  accountId: accountId,
4451
4344
  })];
4452
4345
  case 1:
4453
- _b.sent();
4454
- setIsPaying(false);
4346
+ _a.sent();
4455
4347
  setPurchaseSucceeded(true);
4456
4348
  return [2 /*return*/];
4457
4349
  }
@@ -4460,14 +4352,14 @@ function Signup(_a) {
4460
4352
  }
4461
4353
  function handlePaymentFail(error) {
4462
4354
  showErrorNotification(error.message);
4463
- setIsPaying(false);
4464
- }
4465
- if (isMobile) {
4466
- return (jsxRuntime.jsx(Card, __assign({ className: "p-4 flex flex-col" }, { children: purchaseSucceeded ? (jsxRuntime.jsx(PaymentSuccessDisplay, { amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, className: "w-full", companyName: companyName, returnUrl: returnUrl })) : (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex flex-col items-center" }, { children: jsxRuntime.jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsxRuntime.jsx("div", __assign({ className: "mx-8" }, { children: jsxRuntime.jsx(antd.Divider, { className: "h-full" }) })), jsxRuntime.jsx("div", __assign({ className: "flex items-center justify-center my-12" }, { children: jsxRuntime.jsx(PaymentForms, { entityId: entityId, quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })));
4467
- }
4468
- else {
4469
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(Card, __assign({ className: "p-4 flex flex-col w-screen h-screen" }, { children: purchaseSucceeded ? (jsxRuntime.jsx(PaymentSuccessDisplay, { amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, className: "w-full", companyName: companyName, returnUrl: returnUrl })) : (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex flex-col w-1/2 items-center" }, { children: jsxRuntime.jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsxRuntime.jsx("div", __assign({ className: "my-4" }, { children: jsxRuntime.jsx(antd.Divider, { className: "h-full", type: "vertical" }) })), jsxRuntime.jsx("div", __assign({ className: "flex w-1/2 items-center justify-center my-12" }, { children: jsxRuntime.jsx(PaymentForms, { entityId: entityId, quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })) }));
4470
4355
  }
4356
+ var WrapperComponent = function (_a) {
4357
+ var children = _a.children, className = _a.className, style = _a.style;
4358
+ return isCardEnabled ? (jsxRuntime.jsx(Card, __assign({ className: className, style: style }, { children: children }))) : (jsxRuntime.jsx("div", __assign({ className: className, style: style }, { children: children })));
4359
+ };
4360
+ return (jsxRuntime.jsx(WrapperComponent, __assign({ className: "p-4 flex flex-col ".concat(shadow, " ").concat(className), style: style }, { children: purchaseSucceeded ? (jsxRuntime.jsx(PaymentSuccessDisplay, { amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, className: "w-full", companyName: companyName, returnUrl: returnUrl })) : (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex flex-col ".concat(isMobile ? "items-center" : "w-1/2 items-center") }, { children: jsxRuntime.jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile ? "h-full" : "my-4") }, { children: jsxRuntime.jsx(antd.Divider, { className: "h-full", type: isMobile ? undefined : "vertical" }) })), jsxRuntime.jsx("div", __assign({ className: "flex ".concat(isMobile
4361
+ ? "items-center justify-center my-12"
4362
+ : "w-1/2 items-center justify-center my-12") }, { children: jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2") }, { children: jsxRuntime.jsx(PaymentForms, { entityId: entityId, quote: quote, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId }) })) }))] }))) })));
4471
4363
  }
4472
4364
 
4473
4365
  // WARNING: There is a preview button on APP that will need to be changed if this query is changed
@@ -4601,6 +4493,19 @@ var ErrorView = function (_a) {
4601
4493
  return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full", style: { marginTop: "80px" } }, { children: [jsxRuntime.jsx("div", __assign({ style: { fontSize: "32px" } }, { children: message })), children] })));
4602
4494
  };
4603
4495
 
4496
+ var Text$4 = antd.Typography.Text;
4497
+ var PageHeaderWithActions = function (_a) {
4498
+ var children = _a.children, title = _a.title, className = _a.className;
4499
+ var isMobile = common.useIsMobile();
4500
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex pb-4 shadow-padding-x ".concat(className, " ").concat(isMobile ? "flex-col gap-2" : "items-center justify-between h-8") }, { children: [jsxRuntime.jsx(PageSubTitle, { title: title }), children] })));
4501
+ };
4502
+ var PageSubTitle = function (_a) {
4503
+ var title = _a.title;
4504
+ var secondaryColor = React.useContext(BrandContext).secondaryColor;
4505
+ var darkMode = React.useContext(BunnyContext).darkMode;
4506
+ return (jsxRuntime.jsx(Text$4, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title })));
4507
+ };
4508
+
4604
4509
  var Text$3 = antd.Typography.Text;
4605
4510
  var HideExpiredToggle = function (_a) {
4606
4511
  var hideExpired = _a.hideExpired, setHideExpired = _a.setHideExpired, subscriptions = _a.subscriptions;
@@ -5190,9 +5095,9 @@ var SubscriptionsContext = React.createContext({});
5190
5095
  // !!! This component is intended to be view only, however it still has lots of code for full functionality.
5191
5096
  // !!! This must be refactored.
5192
5097
  var Subscriptions = function (_a) {
5193
- var companyName = _a.companyName, entityId = _a.entityId, gap = _a.gap, shadow = _a.shadow, _b = _a.showTitle, showTitle = _b === void 0 ? true : _b;
5098
+ var companyName = _a.companyName, entityId = _a.entityId, gap = _a.gap, shadow = _a.shadow, _b = _a.showTitle, showTitle = _b === void 0 ? true : _b, className = _a.className;
5194
5099
  // Context
5195
- var _c = React.useContext(BunnyContext), token = _c.token, apiHost = _c.apiHost, onErrorNavigate = _c.onErrorNavigate;
5100
+ var _c = React.useContext(BunnyContext), token = _c.token, apiHost = _c.apiHost, onTokenExpired = _c.onTokenExpired;
5196
5101
  // Recoil state
5197
5102
  // const [updatingChargeQuantityId, setUpdatingChargeQuantityId] =
5198
5103
  // useRecoilState(updatingChargeQuantityIdState);
@@ -5202,10 +5107,7 @@ var Subscriptions = function (_a) {
5202
5107
  var _f = React.useState(true), hideExpired = _f[0], setHideExpired = _f[1];
5203
5108
  var _g = React.useState(false); _g[0]; var setQuantityDrawerOpen = _g[1];
5204
5109
  // Hooks
5205
- var handleAllErrorFormats = common.useAllErrorFormats(onErrorNavigate ||
5206
- (function (url) {
5207
- console.log("navigate to", url, " not implemented");
5208
- }));
5110
+ var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
5209
5111
  var queryClient = reactQuery.useQueryClient();
5210
5112
  var showSuccessNotification = common.useSuccessNotification();
5211
5113
  // const quoteDelete = useQuoteDelete();
@@ -5283,7 +5185,7 @@ var Subscriptions = function (_a) {
5283
5185
  shadow: shadow,
5284
5186
  gap: gap,
5285
5187
  showTitle: showTitle,
5286
- } }, { children: [showTitle && (jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between", style: { minWidth: "137px" } }, { children: [hideExpired ? "Active subscriptions" : "All subscriptions", isMobile && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired, subscriptions: subscriptions }))] })) }, { children: !isMobile && (jsxRuntime.jsx(SubscriptionsNavigation, { hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) }))), jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-".concat(gap === undefined ? 4 : gap, " shadow-padding-xb overflow-auto"), style: {
5188
+ } }, { children: [showTitle && (jsxRuntime.jsx(PageHeaderWithActions, __assign({ className: className, title: jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between", style: { minWidth: "137px" } }, { children: [hideExpired ? "Active subscriptions" : "All subscriptions", isMobile && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired, subscriptions: subscriptions }))] })) }, { children: !isMobile && (jsxRuntime.jsx(SubscriptionsNavigation, { hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) }))), jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-".concat(gap === undefined ? 4 : gap, " shadow-padding-xb overflow-auto ").concat(className), style: {
5287
5189
  flexShrink: 1,
5288
5190
  } }, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(SubscriptionsList, { hideExpired: hideExpired, planChangeOptions: planChangeOptions, setEditingQuoteData: setEditingQuoteData, setPayModalVisible: setPayModalVisible, subscriptions: subscriptions }) })) : (jsxRuntime.jsx("div", __assign({ className: "flex flex-col items-center w-full" }, { children: jsxRuntime.jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) }))) })), isMobile && (jsxRuntime.jsx("div", __assign({ className: "pt-4 pb-2" }, { children: jsxRuntime.jsx(SubscriptionsNavigation, { hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsxRuntime.jsx(Checkout, { entityId: entityId, onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile })] })));
5289
5191
  };