@bunnyapp/components 1.0.55 → 1.0.56-beta.0.1

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 (96) hide show
  1. package/dist/cjs/index.js +685 -625
  2. package/dist/cjs/src/components/BunnyProvider.d.ts +2 -2
  3. package/dist/cjs/src/components/Checkout/Checkout.d.ts +2 -3
  4. package/dist/cjs/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  5. package/dist/cjs/src/components/PaymentForm/{PaymentMethod → DemoPay}/CreditCard/CreditCard.d.ts +5 -3
  6. package/dist/cjs/src/components/PaymentForm/PaymentForm.d.ts +2 -3
  7. package/dist/cjs/src/components/PaymentForm/PaymentFormTypes.d.ts +1 -1
  8. package/dist/cjs/src/components/PaymentForm/PaymentMethodDetails.d.ts +4 -4
  9. package/dist/cjs/src/components/PaymentForm/hooks/useAutoSetDefaultPaymentMethod.d.ts +8 -0
  10. package/dist/cjs/src/components/PaymentForm/hooks/useHasActiveSubscription.d.ts +5 -0
  11. package/dist/cjs/src/components/PaymentForm/hooks/usePaymentMethodSelectorPlugin.d.ts +11 -0
  12. package/dist/cjs/src/components/PaymentForm/index.d.ts +0 -1
  13. package/dist/cjs/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
  14. package/dist/cjs/src/components/PaymentForm/useSetDefaultPaymentMethod.d.ts +6 -0
  15. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/NextPriceListButton.d.ts +2 -1
  16. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/checkoutBar/CheckoutBarInput.d.ts +3 -2
  17. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/checkoutBar/CheckoutBarSummarySection.d.ts +1 -2
  18. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/EverythingPlanFeatures.d.ts +2 -1
  19. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/PlanFeatures.d.ts +2 -1
  20. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/PriceListGridDesktop.d.ts +1 -2
  21. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/planPickerUtils.d.ts +3 -2
  22. package/dist/cjs/src/components/Subscriptions/SubscriptionRequests.d.ts +2 -2
  23. package/dist/cjs/src/components/index.d.ts +1 -1
  24. package/dist/cjs/src/contexts/PaymentContext.d.ts +2 -1
  25. package/dist/cjs/src/graphql/QuoteRequests.d.ts +4 -3
  26. package/dist/cjs/src/graphql/mutations/quoteChargeCreate.d.ts +2 -3
  27. package/dist/cjs/src/graphql/mutations/quoteChargeUpdate.d.ts +12 -0
  28. package/dist/cjs/src/graphql/mutations/quoteCompose.d.ts +1 -1
  29. package/dist/cjs/src/graphql/mutations/quoteRecalculateTaxes.d.ts +2 -2
  30. package/dist/cjs/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -1
  31. package/dist/cjs/src/graphql/queries/getTaxationRequiredAccountFields.d.ts +2 -2
  32. package/dist/cjs/src/hooks/quotes/useSendAcceptQuote.d.ts +1 -1
  33. package/dist/cjs/src/hooks/quotes/useSigningComplete.d.ts +1 -1
  34. package/dist/cjs/src/hooks/useHasTaxPlugin.d.ts +1 -1
  35. package/dist/cjs/src/hooks/usePaymentMethod.d.ts +6 -5
  36. package/dist/cjs/src/hooks/usePaymentPlugins.d.ts +1 -1
  37. package/dist/cjs/src/hooks/usePlugins.d.ts +2 -2
  38. package/dist/cjs/src/hooks/useSigningPlugins.d.ts +1 -1
  39. package/dist/cjs/src/hooks/useToken.d.ts +1 -1
  40. package/dist/cjs/src/utils/apiUtils.d.ts +1 -1
  41. package/dist/esm/index.js +689 -628
  42. package/dist/esm/src/components/BunnyProvider.d.ts +2 -2
  43. package/dist/esm/src/components/Checkout/Checkout.d.ts +2 -3
  44. package/dist/esm/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  45. package/dist/esm/src/components/PaymentForm/{PaymentMethod → DemoPay}/CreditCard/CreditCard.d.ts +5 -3
  46. package/dist/esm/src/components/PaymentForm/PaymentForm.d.ts +2 -3
  47. package/dist/esm/src/components/PaymentForm/PaymentFormTypes.d.ts +1 -1
  48. package/dist/esm/src/components/PaymentForm/PaymentMethodDetails.d.ts +4 -4
  49. package/dist/esm/src/components/PaymentForm/hooks/useAutoSetDefaultPaymentMethod.d.ts +8 -0
  50. package/dist/esm/src/components/PaymentForm/hooks/useHasActiveSubscription.d.ts +5 -0
  51. package/dist/esm/src/components/PaymentForm/hooks/usePaymentMethodSelectorPlugin.d.ts +11 -0
  52. package/dist/esm/src/components/PaymentForm/index.d.ts +0 -1
  53. package/dist/esm/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
  54. package/dist/esm/src/components/PaymentForm/useSetDefaultPaymentMethod.d.ts +6 -0
  55. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/NextPriceListButton.d.ts +2 -1
  56. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/checkoutBar/CheckoutBarInput.d.ts +3 -2
  57. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/checkoutBar/CheckoutBarSummarySection.d.ts +1 -2
  58. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/EverythingPlanFeatures.d.ts +2 -1
  59. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/PlanFeatures.d.ts +2 -1
  60. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/PriceListGridDesktop.d.ts +1 -2
  61. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/planPickerUtils.d.ts +3 -2
  62. package/dist/esm/src/components/Subscriptions/SubscriptionRequests.d.ts +2 -2
  63. package/dist/esm/src/components/index.d.ts +1 -1
  64. package/dist/esm/src/contexts/PaymentContext.d.ts +2 -1
  65. package/dist/esm/src/graphql/QuoteRequests.d.ts +4 -3
  66. package/dist/esm/src/graphql/mutations/quoteChargeCreate.d.ts +2 -3
  67. package/dist/esm/src/graphql/mutations/quoteChargeUpdate.d.ts +12 -0
  68. package/dist/esm/src/graphql/mutations/quoteCompose.d.ts +1 -1
  69. package/dist/esm/src/graphql/mutations/quoteRecalculateTaxes.d.ts +2 -2
  70. package/dist/esm/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -1
  71. package/dist/esm/src/graphql/queries/getTaxationRequiredAccountFields.d.ts +2 -2
  72. package/dist/esm/src/hooks/quotes/useSendAcceptQuote.d.ts +1 -1
  73. package/dist/esm/src/hooks/quotes/useSigningComplete.d.ts +1 -1
  74. package/dist/esm/src/hooks/useHasTaxPlugin.d.ts +1 -1
  75. package/dist/esm/src/hooks/usePaymentMethod.d.ts +6 -5
  76. package/dist/esm/src/hooks/usePaymentPlugins.d.ts +1 -1
  77. package/dist/esm/src/hooks/usePlugins.d.ts +2 -2
  78. package/dist/esm/src/hooks/useSigningPlugins.d.ts +1 -1
  79. package/dist/esm/src/hooks/useToken.d.ts +1 -1
  80. package/dist/esm/src/utils/apiUtils.d.ts +1 -1
  81. package/dist/index.d.ts +4 -12
  82. package/package.json +1 -1
  83. package/dist/cjs/src/components/PaymentForm/PaymentMethod/PaymentMethod.d.ts +0 -8
  84. package/dist/cjs/src/components/PaymentForm/PaymentMethod/PaymentMethod.stories.d.ts +0 -11
  85. package/dist/cjs/src/components/PaymentForm/PaymentMethod/index.d.ts +0 -1
  86. package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/consts.d.ts +0 -1
  87. package/dist/cjs/src/graphql/queries/getPortalPreviewQuery.d.ts +0 -2
  88. package/dist/esm/src/components/PaymentForm/PaymentMethod/PaymentMethod.d.ts +0 -8
  89. package/dist/esm/src/components/PaymentForm/PaymentMethod/PaymentMethod.stories.d.ts +0 -11
  90. package/dist/esm/src/components/PaymentForm/PaymentMethod/index.d.ts +0 -1
  91. package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/consts.d.ts +0 -1
  92. package/dist/esm/src/graphql/queries/getPortalPreviewQuery.d.ts +0 -2
  93. /package/dist/cjs/src/components/PaymentForm/{PaymentMethod → DemoPay}/CreditCard/LargCardIcon.d.ts +0 -0
  94. /package/dist/cjs/src/components/PaymentForm/{PaymentMethod → DemoPay}/CreditCard/PlusIcon.d.ts +0 -0
  95. /package/dist/esm/src/components/PaymentForm/{PaymentMethod → DemoPay}/CreditCard/LargCardIcon.d.ts +0 -0
  96. /package/dist/esm/src/components/PaymentForm/{PaymentMethod → DemoPay}/CreditCard/PlusIcon.d.ts +0 -0
package/dist/esm/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { createContext, useEffect, useState, useContext, useMemo, useCallback, useRef } from 'react';
3
3
  import { Markup } from 'interweave';
4
- import { ConfigProvider, Button, Tag, Typography, Divider, Popconfirm, Input, Checkbox, Collapse, Skeleton, Modal, Form, Drawer, Card as Card$1, Image, Select, Tooltip, Radio, Space, Dropdown } from 'antd';
5
- import { DownloadOutlined, CreditCardOutlined, BankOutlined, SearchOutlined, CloseOutlined, CheckCircleFilled, ArrowLeftOutlined } from '@ant-design/icons';
4
+ import { ConfigProvider, Button, Tag, Typography, Dropdown, Input, Checkbox, Collapse, Skeleton, Modal, Form, Drawer, Card as Card$1, Image, Divider, Select, Tooltip, Radio, Space, Popconfirm } from 'antd';
5
+ import { DownloadOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, SearchOutlined, CheckCircleFilled, CloseOutlined, ArrowLeftOutlined } from '@ant-design/icons';
6
6
  import styled from 'styled-components';
7
- import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, useAllErrorFormats, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useErrorNotification, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, sortSubscriptionCharges, Lists, SLATE_500, PRIMARY_COLOR, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, useInfoNotification, MODAL_MAX_HEIGHT, DataInterval, TAG_COLORS, SubscriptionChargeKind } from '@bunnyapp/common';
7
+ import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, useAllErrorFormats, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useErrorNotification, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, sortSubscriptionCharges, SLATE_500, PRIMARY_COLOR, Lists, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, useInfoNotification, MODAL_MAX_HEIGHT, DataInterval, TAG_COLORS, SubscriptionChargeKind } from '@bunnyapp/common';
8
8
  import { QueryClient, QueryClientProvider, useQuery, useQueryClient, keepPreviousData, useMutation } from '@tanstack/react-query';
9
9
  import theme from 'antd/lib/theme/index.js';
10
10
  import { RecoilRoot } from 'recoil';
@@ -44,7 +44,7 @@ function styleInject(css, ref) {
44
44
  }
45
45
  }
46
46
 
47
- var css_248z = ".ant-divider-horizontal {\n margin: 0;\n}\n.ant-divider-horizontal {\n margin: 0;\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-link:disabled {\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\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-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: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 --bunny-blue-500: #3b82f6;\n --bunny-blue-200: #bfdbfe;\n --bunny-green-600: #059669;\n --bunny-green-200: #a7f3d0;\n --bunny-red-500: #ef4444;\n --bunny-red-200: #fecaca;\n --bunny-orange-500: #f97316;\n --bunny-orange-200: #fed7aa;\n --bunny-yellow-500: #f59e0b;\n --bunny-yellow-200: #fde68a;\n --bunny-purple-500: #8b5cf6;\n --bunny-purple-200: #ddd6fe;\n --bunny-black: #000000;\n}\n* {\n padding: 0;\n box-sizing: border-box !important;\n line-height: 1.15;\n}\n.hidden {\n display: none;\n}\n.bunny-show-on-hover {\n opacity: 0;\n}\n.bunny-show-on-hover-container:hover .bunny-show-on-hover {\n opacity: 1;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\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.bunny-icon-path {\n transition: fill 0.3s;\n}\n.bunny-shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.bunny-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 .bunny-shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .bunny-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.sticky {\n position: sticky;\n}\n.-top-0\\.5 {\n top: -0.125rem;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.bottom-4 {\n bottom: 1rem;\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.col-span-full {\n grid-column: 1 / -1;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-0 {\n margin-left: 0px;\n margin-right: 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-2 {\n margin-bottom: 0.5rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.mb-8 {\n margin-bottom: 2rem;\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-12 {\n width: 3rem;\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 {\n flex-shrink: 1;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.flex-grow {\n flex-grow: 1;\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-3 {\n gap: 0.75rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.gap-8 {\n gap: 2rem;\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-lg {\n border-radius: 0.5rem;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.rounded-sm {\n border-radius: 0.125rem;\n}\n.border {\n border-width: 1px;\n}\n.border-2 {\n border-width: 2px;\n}\n.border-b {\n border-bottom-width: 1px;\n}\n.border-t {\n border-top-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-none {\n border-style: none;\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-transparent {\n background-color: transparent;\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-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\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.px-8 {\n padding-left: 2rem;\n padding-right: 2rem;\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-orange-600 {\n --tw-text-opacity: 1;\n color: rgb(234 88 12 / 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-slate-600 {\n --tw-text-opacity: 1;\n color: rgb(71 85 105 / 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.transition-\\[margin\\] {\n transition-property: margin;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.transition-all {\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.duration-200 {\n transition-duration: 200ms;\n}\n.duration-300 {\n transition-duration: 300ms;\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.hover\\:bg-gray-100:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n.bunny-invoice-container {\n padding: 0;\n box-sizing: border-box !important;\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";
47
+ var css_248z = ".ant-divider-horizontal {\n margin: 0;\n}\n.ant-divider-horizontal {\n margin: 0;\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-link:disabled {\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\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-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: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 --bunny-blue-500: #3b82f6;\n --bunny-blue-200: #bfdbfe;\n --bunny-green-600: #059669;\n --bunny-green-200: #a7f3d0;\n --bunny-red-500: #ef4444;\n --bunny-red-200: #fecaca;\n --bunny-orange-500: #f97316;\n --bunny-orange-200: #fed7aa;\n --bunny-yellow-500: #f59e0b;\n --bunny-yellow-200: #fde68a;\n --bunny-purple-500: #8b5cf6;\n --bunny-purple-200: #ddd6fe;\n --bunny-black: #000000;\n}\n* {\n padding: 0;\n box-sizing: border-box !important;\n line-height: 1.15;\n}\n.hidden {\n display: none;\n}\n.bunny-show-on-hover {\n opacity: 0;\n}\n.bunny-show-on-hover-container:hover .bunny-show-on-hover {\n opacity: 1;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\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.bunny-icon-path {\n transition: fill 0.3s;\n}\n.bunny-shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.bunny-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 .bunny-shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .bunny-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.sticky {\n position: sticky;\n}\n.-top-0\\.5 {\n top: -0.125rem;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.bottom-4 {\n bottom: 1rem;\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.col-span-full {\n grid-column: 1 / -1;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-0 {\n margin-left: 0px;\n margin-right: 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-2 {\n margin-bottom: 0.5rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.mb-8 {\n margin-bottom: 2rem;\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-12 {\n width: 3rem;\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 {\n flex-shrink: 1;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.flex-grow {\n flex-grow: 1;\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-3 {\n gap: 0.75rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.gap-8 {\n gap: 2rem;\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-lg {\n border-radius: 0.5rem;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.rounded-sm {\n border-radius: 0.125rem;\n}\n.border {\n border-width: 1px;\n}\n.border-2 {\n border-width: 2px;\n}\n.border-b {\n border-bottom-width: 1px;\n}\n.border-t {\n border-top-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-none {\n border-style: none;\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-transparent {\n background-color: transparent;\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-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\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.px-8 {\n padding-left: 2rem;\n padding-right: 2rem;\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-orange-600 {\n --tw-text-opacity: 1;\n color: rgb(234 88 12 / 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-slate-600 {\n --tw-text-opacity: 1;\n color: rgb(71 85 105 / 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.transition-\\[margin\\] {\n transition-property: margin;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.transition-all {\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.duration-200 {\n transition-duration: 200ms;\n}\n.duration-300 {\n transition-duration: 300ms;\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.hover\\:bg-gray-100:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));\n}\n.hover\\:bg-slate-100:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(241 245 249 / var(--tw-bg-opacity, 1));\n}\n.hover\\:bg-slate-200:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(226 232 240 / var(--tw-bg-opacity, 1));\n}\n.hover\\:bg-gray-200:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(229 231 235 / var(--tw-bg-opacity, 1));\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n.bunny-invoice-container {\n padding: 0;\n box-sizing: border-box !important;\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";
48
48
  styleInject(css_248z);
49
49
 
50
50
  /******************************************************************************
@@ -141,7 +141,7 @@ var BrandContext = createContext({
141
141
  topNavImageUrl: DEFAULT_TOP_NAV_IMAGE_URL,
142
142
  });
143
143
 
144
- var MUTATION$9 = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
144
+ var MUTATION$8 = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
145
145
  var getBranding = function (_a) {
146
146
  var token = _a.token, apiHost = _a.apiHost;
147
147
  return __awaiter(void 0, void 0, void 0, function () {
@@ -149,7 +149,7 @@ var getBranding = function (_a) {
149
149
  return __generator(this, function (_b) {
150
150
  switch (_b.label) {
151
151
  case 0: return [4 /*yield*/, gqlRequest({
152
- query: MUTATION$9,
152
+ query: MUTATION$8,
153
153
  token: token,
154
154
  apiHost: apiHost,
155
155
  })];
@@ -413,35 +413,47 @@ function InvoicePDF(_a) {
413
413
  }, title: "Invoice PDF", width: "100%" }));
414
414
  }
415
415
 
416
- 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}";
416
+ var paymentMethodsQuery = "query paymentMethods ($filter: String, $sort: String) {\n paymentMethods (filter: $filter, 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 isDefault\n }\n }\n}";
417
+ var getPaymentMethods = function (_a) {
418
+ var apiHost = _a.apiHost, token = _a.token;
419
+ return __awaiter(void 0, void 0, void 0, function () {
420
+ var response, paymentMethods;
421
+ var _b;
422
+ return __generator(this, function (_c) {
423
+ switch (_c.label) {
424
+ case 0: return [4 /*yield*/, gqlRequest({
425
+ query: paymentMethodsQuery,
426
+ token: token,
427
+ apiHost: apiHost,
428
+ })];
429
+ case 1:
430
+ response = _c.sent();
431
+ paymentMethods = ((_b = response === null || response === void 0 ? void 0 : response.paymentMethods) === null || _b === void 0 ? void 0 : _b.nodes) || [];
432
+ return [2 /*return*/, paymentMethods];
433
+ }
434
+ });
435
+ });
436
+ };
417
437
  var usePaymentMethod = function (_a) {
418
- var accountId = _a.accountId, graphQLClient = _a.graphQLClient, token = _a.token;
438
+ var accountId = _a.accountId, token = _a.token, apiHost = _a.apiHost;
419
439
  var _b = useQuery({
420
440
  queryKey: QueryKeyFactory.default.accountPaymentMethodKey({
421
- token: token,
422
441
  accountId: accountId,
442
+ token: token,
423
443
  }),
424
- queryFn: function () {
425
- return graphQLClient
426
- .request(paymentMethodsQuery, {
427
- first: 1,
428
- filter: "disabled is false".concat(accountId ? " && accountId=".concat(accountId) : ""),
429
- })
430
- .then(function (data) {
431
- var _a, _b;
432
- // TODO error checking of response
433
- var paymentMethod = ((_b = (_a = data === null || data === void 0 ? void 0 : data.paymentMethods) === null || _a === void 0 ? void 0 : _a.nodes) === null || _b === void 0 ? void 0 : _b[0]) || null;
434
- return paymentMethod;
435
- });
436
- },
444
+ queryFn: function () { return getPaymentMethods({ apiHost: apiHost, token: token }); },
437
445
  }), data = _b.data, isLoading = _b.isLoading;
438
- return { data: data, isLoading: isLoading };
446
+ return {
447
+ paymentMethods: data,
448
+ defaultPaymentMethod: data === null || data === void 0 ? void 0 : data.find(function (paymentMethod) { return paymentMethod.isDefault; }),
449
+ isLoading: isLoading,
450
+ };
439
451
  };
440
452
 
441
453
  var usePlugins = function (_a) {
442
454
  var apiHost = _a.apiHost, token = _a.token;
443
455
  var response = useQuery({
444
- queryKey: QueryKeyFactory.default.pluginsKey(token),
456
+ queryKey: QueryKeyFactory.default.pluginsKey(token || ""),
445
457
  queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
446
458
  var plugins;
447
459
  return __generator(this, function (_a) {
@@ -490,7 +502,7 @@ var getQuoteAmountDue = function (quote) {
490
502
  return quote.amountDue;
491
503
  };
492
504
 
493
- 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";
505
+ var MUTATION$7 = "\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";
494
506
  var checkout = function (_a) {
495
507
  var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
496
508
  return __awaiter(void 0, void 0, void 0, function () {
@@ -507,7 +519,7 @@ var checkout = function (_a) {
507
519
  mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
508
520
  }
509
521
  return [4 /*yield*/, gqlRequest({
510
- query: MUTATION$8,
522
+ query: MUTATION$7,
511
523
  token: token,
512
524
  vars: mutationVars,
513
525
  apiHost: apiHost,
@@ -620,7 +632,7 @@ var ActualCheckoutFooter = function (_a) {
620
632
  var quote = _a.quote, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, noPadding = _a.noPadding, plugin = _a.plugin;
621
633
  var isMobile = useIsMobile();
622
634
  var _b = useState(false), isPaying = _b[0], setIsPaying = _b[1];
623
- var storedPaymentMethod = useContext(PaymentContext).storedPaymentMethod;
635
+ var defaultPaymentMethod = useContext(PaymentContext).defaultPaymentMethod;
624
636
  var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
625
637
  var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId);
626
638
  // Payment hooks
@@ -632,7 +644,7 @@ var ActualCheckoutFooter = function (_a) {
632
644
  },
633
645
  quote: quote,
634
646
  invoice: invoice,
635
- storedPaymentMethod: storedPaymentMethod,
647
+ storedPaymentMethod: defaultPaymentMethod,
636
648
  plugin: plugin,
637
649
  }).pay;
638
650
  var payStripe = usePay({
@@ -643,7 +655,7 @@ var ActualCheckoutFooter = function (_a) {
643
655
  },
644
656
  quote: quote,
645
657
  invoice: invoice,
646
- storedPaymentMethod: storedPaymentMethod,
658
+ storedPaymentMethod: defaultPaymentMethod,
647
659
  plugin: plugin,
648
660
  }).pay;
649
661
  var handlePaymentSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -673,7 +685,7 @@ var ActualCheckoutFooter = function (_a) {
673
685
  }
674
686
  });
675
687
  }); };
676
- return (jsx("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: jsx(Button, __assign({ className: "w-full", disabled: isPaying, onClick: function () {
688
+ return (jsx("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "") }, { children: jsx(Button, __assign({ className: "w-full", disabled: isPaying, onClick: function () {
677
689
  setIsPaying(true);
678
690
  handlePaymentSubmit();
679
691
  }, size: isMobile ? "large" : "middle", type: "primary" }, { children: "".concat(isPaying ? "Paying" : "Pay", " ").concat(amountDue && currencyId ? formatCurrency(amountDue, currencyId) : "") })) })));
@@ -685,6 +697,75 @@ var CheckoutFooter = function (_a) {
685
697
  return (jsx(ActualCheckoutFooter, { plugin: plugin, invoice: invoice, quote: quote, onPaymentSuccess: onPaymentSuccess, noPadding: noPadding }));
686
698
  };
687
699
 
700
+ // Automatically sets the default payment method if there is none currently set
701
+ var useAutoSetDefaultPaymentMethod = function (_a) {
702
+ var accountId = _a.accountId, token = _a.token, handleSetDefault = _a.handleSetDefault, setDefaultPaymentMethodLoading = _a.setDefaultPaymentMethodLoading;
703
+ var queryClient = useQueryClient();
704
+ var apiHost = useContext(BunnyContext).apiHost;
705
+ var _b = usePaymentMethod({
706
+ accountId: accountId,
707
+ token: token,
708
+ apiHost: apiHost,
709
+ }), storedPaymentMethods = _b.paymentMethods, defaultPaymentMethod = _b.defaultPaymentMethod;
710
+ // Set the default payment method on the cache. Prevents 'handleSetDefault' from being called too many times.
711
+ function setDefaultPaymentMethodOnCache(targetPaymentMethod) {
712
+ var cachedPaymentMethods = queryClient.getQueryData(QueryKeyFactory.default.accountPaymentMethodKey({
713
+ accountId: accountId,
714
+ token: token,
715
+ }));
716
+ if (cachedPaymentMethods) {
717
+ for (var _i = 0, _a = cachedPaymentMethods; _i < _a.length; _i++) {
718
+ var paymentMethod = _a[_i];
719
+ paymentMethod.isDefault = paymentMethod.id === targetPaymentMethod.id;
720
+ }
721
+ queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey({
722
+ accountId: accountId,
723
+ token: token,
724
+ }), cachedPaymentMethods);
725
+ }
726
+ }
727
+ useEffect(function () {
728
+ if (setDefaultPaymentMethodLoading)
729
+ return;
730
+ if ((storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) > 0 && !defaultPaymentMethod) {
731
+ handleSetDefault(storedPaymentMethods[0]);
732
+ setDefaultPaymentMethodOnCache(storedPaymentMethods[0]);
733
+ }
734
+ }, [
735
+ storedPaymentMethods,
736
+ defaultPaymentMethod,
737
+ handleSetDefault,
738
+ setDefaultPaymentMethodLoading,
739
+ queryClient,
740
+ accountId,
741
+ token,
742
+ ]);
743
+ };
744
+
745
+ var usePaymentMethodSelectorPlugin = function (_a) {
746
+ var defaultPaymentMethod = _a.defaultPaymentMethod, defaultPaymentMethodPlugin = _a.defaultPaymentMethodPlugin, paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins;
747
+ var _b = useState(), selectorPaymentMethodPlugin = _b[0], setSelectorPaymentMethodPlugin = _b[1];
748
+ useEffect(function () {
749
+ if (selectorPaymentMethodPlugin) {
750
+ return;
751
+ }
752
+ if (defaultPaymentMethod) {
753
+ setSelectorPaymentMethodPlugin(defaultPaymentMethodPlugin);
754
+ }
755
+ else {
756
+ setSelectorPaymentMethodPlugin(paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]);
757
+ }
758
+ }, [
759
+ defaultPaymentMethod,
760
+ defaultPaymentMethodPlugin,
761
+ paymentMethodAllowedPlugins,
762
+ ]);
763
+ return {
764
+ selectorPaymentMethodPlugin: selectorPaymentMethodPlugin,
765
+ setSelectorPaymentMethodPlugin: setSelectorPaymentMethodPlugin,
766
+ };
767
+ };
768
+
688
769
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
689
770
 
690
771
  function getDefaultExportFromCjs (x) {
@@ -755,7 +836,7 @@ var ChinaUnionPay = function (_a) {
755
836
  return (jsxs("svg", __assign({ className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsx("path", { d: "M18.2466 6.855H27.4811C28.7703 6.855 29.5728 7.90603 29.272 9.20036L24.972 27.6585C24.6682 28.949 23.3782 30 22.0886 30H12.8537C11.5641 30 10.7624 28.949 11.0632 27.6585L15.3654 9.20036C15.6653 7.90603 16.9545 6.855 18.2466 6.855Z", fill: "#ED171F" }), jsx("path", { d: "M26.7132 6.855H37.3336C38.6223 6.855 38.0411 7.90603 37.7381 9.20036L33.4385 27.6585C33.1382 28.949 33.2324 30 31.9402 30H21.3206C20.0298 30 19.2303 28.949 19.5336 27.6585L23.8315 9.20036C24.1353 7.90603 25.424 6.855 26.7132 6.855Z", fill: "#082F67" }), jsx("path", { d: "M36.9136 6.855H46.1468C47.4368 6.855 48.2384 7.90603 47.9364 9.20036L43.6372 27.6585C43.3351 28.949 42.0455 30 40.7516 30H31.521C30.2288 30 29.4285 28.949 29.7314 27.6585L34.0293 9.20036C34.3318 7.90603 35.621 6.855 36.9136 6.855Z", fill: "#006A65" }), jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M38.4247 20.4849L37.2994 24.2089H37.6019L37.3681 24.979H37.0656L36.9951 25.218H35.9242L35.9968 24.979H33.82L34.0387 24.2664H34.2587L35.4005 20.4849L35.6286 19.7209H36.7212L36.6071 20.1072C36.6071 20.1072 36.8979 19.8972 37.1741 19.8254C37.4502 19.7528 39.0337 19.7265 39.0337 19.7265L38.799 20.4849H38.4247ZM36.4995 20.4849L36.2103 21.4365C36.2103 21.4365 36.5336 21.2909 36.7112 21.2421C36.8901 21.1958 37.1589 21.1777 37.1589 21.1777L37.3681 20.4849H36.4995ZM36.0669 21.9098L35.7678 22.8994C35.7678 22.8994 36.0984 22.73 36.276 22.6773C36.4549 22.6358 36.7255 22.6021 36.7255 22.6021L36.9377 21.9098H36.0669ZM35.3702 24.2197H36.241L36.4925 23.383H35.6217L35.3702 24.2197Z", fill: "white" }), jsx("path", { d: "M38.9076 19.7265H40.0736L40.0866 20.1613C40.0797 20.2343 40.1427 20.2689 40.2776 20.2689H40.5144L40.2979 20.9863H39.6687C39.1224 21.0265 38.9163 20.7918 38.9284 20.5286L38.9076 19.7265Z", fill: "white" }), jsx("path", { d: "M39.0602 23.1305H37.9487L38.1397 22.4909H39.4099L39.5918 21.9079H38.3368L38.5525 21.1875H42.0439L41.8252 21.9079H40.6545L40.4713 22.4909H41.6446L41.4514 23.1305H40.1808L39.9561 23.3998H40.4713L40.5962 24.2049C40.6096 24.284 40.6121 24.3363 40.6372 24.3708C40.6631 24.4006 40.8174 24.4145 40.9069 24.4145H41.0633L40.8256 25.198H40.4293C40.368 25.198 40.2772 25.1928 40.1532 25.1863C40.033 25.1759 39.9479 25.1064 39.8684 25.0683C39.7958 25.032 39.6869 24.9439 39.6618 24.7939L39.5374 23.9905L38.9608 24.7831C38.7772 25.032 38.5291 25.2226 38.1108 25.2226H37.3009L37.5131 24.5238H37.8221C37.9116 24.5238 37.9906 24.4888 38.0485 24.4586C38.1082 24.4335 38.1605 24.4037 38.2201 24.3155L39.0602 23.1305Z", fill: "white" }), jsx("path", { d: "M26.8864 21.3815H29.8294L29.612 22.0842H28.4348L28.252 22.6818H29.456L29.2365 23.4075H28.0333L27.7416 24.3811C27.7057 24.4892 28.026 24.5043 28.1418 24.5043L28.7451 24.4209L28.5035 25.223H27.1457C27.0389 25.223 26.9555 25.2079 26.8371 25.1811C26.7226 25.1525 26.672 25.1015 26.6214 25.0237C26.5722 24.9438 26.497 24.879 26.548 24.7096L26.9374 23.42H26.2692L26.4909 22.6818H27.1629L27.3414 22.0842H26.672L26.8864 21.3815Z", fill: "white" }), jsx("path", { d: "M28.8682 20.1195H30.0752L29.8544 20.8541H28.2052L28.0259 21.0084C27.9498 21.0832 27.923 21.0516 27.8232 21.1057C27.7303 21.1532 27.5337 21.2461 27.28 21.2461H26.7506L26.9658 20.5395H27.1244C27.2588 20.5395 27.35 20.5283 27.3962 20.4985C27.449 20.4656 27.5073 20.3909 27.5751 20.269L27.8777 19.718H29.0786L28.8682 20.1195Z", fill: "white" }), jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M30.5938 19.7264H31.6223L31.4728 20.2437C31.4728 20.2437 31.7969 19.9848 32.0247 19.8923C32.2511 19.8072 32.7641 19.7311 32.7641 19.7311L34.428 19.7225L33.861 21.6106C33.7659 21.9347 33.6548 22.1439 33.5852 22.239C33.5217 22.3366 33.4482 22.4183 33.3026 22.4974C33.1626 22.5722 33.0351 22.6154 32.9175 22.6275C32.8073 22.6357 32.6388 22.64 32.4046 22.6422H30.8025L30.3501 24.1366C30.3073 24.284 30.2865 24.354 30.3146 24.3937C30.3384 24.43 30.3928 24.4702 30.468 24.4702L31.1746 24.4037L30.9339 25.2226H30.1413C29.8898 25.2226 29.7066 25.2174 29.5778 25.2075C29.4559 25.198 29.3284 25.2075 29.2441 25.1414C29.1694 25.0766 29.0574 24.9918 29.06 24.9041C29.0683 24.8229 29.1011 24.688 29.1534 24.5039L30.5938 19.7264ZM32.7775 21.6344H31.0912L30.9884 21.9749H32.4473C32.6198 21.9533 32.6552 21.9779 32.669 21.9697L32.7775 21.6344ZM31.185 21.3271C31.185 21.3271 31.5139 21.0263 32.0778 20.9286C32.2062 20.9036 33.0083 20.9118 33.0083 20.9118L33.1297 20.5081H31.4305L31.185 21.3271Z", fill: "white" }), jsx("path", { d: "M33.5921 22.7747L33.4979 23.2285C33.4559 23.3693 33.4209 23.4778 33.3138 23.5686C33.2027 23.6632 33.0696 23.763 32.7606 23.763L32.191 23.7859L32.1862 24.2998C32.1785 24.4459 32.2178 24.4303 32.2411 24.4541C32.2675 24.4787 32.2904 24.4904 32.3168 24.4986L32.4961 24.4904L33.0415 24.4584L32.8168 25.2078H32.191C31.7524 25.2078 31.4274 25.1983 31.3202 25.1127C31.2156 25.0466 31.2018 24.9619 31.2048 24.8188L31.2441 22.8201H32.242L32.2295 23.2285H32.4702C32.5523 23.2285 32.6063 23.2198 32.6417 23.1986C32.6707 23.1749 32.6936 23.1437 32.7096 23.0932L32.8068 22.7747H33.5921Z", fill: "white" }), jsx("path", { d: "M19.3395 12.7519C19.3032 12.9127 18.6632 15.8704 18.6606 15.8722C18.5219 16.4698 18.4238 16.8985 18.0824 17.1721C17.8887 17.3311 17.6623 17.4094 17.4008 17.4094C16.9808 17.4094 16.734 17.2006 16.6921 16.8035L16.6843 16.6678C16.6843 16.6678 16.8122 15.8652 16.814 15.8622C16.814 15.8622 17.486 13.1664 17.6065 12.8116C17.6117 12.7917 17.6143 12.7817 17.6169 12.7714C16.3075 12.783 16.0745 12.7714 16.0594 12.7519C16.052 12.7783 16.017 12.946 16.017 12.946L15.3299 15.9815L15.2703 16.2408L15.1579 17.0826C15.1579 17.3311 15.2072 17.536 15.3044 17.7084C15.6177 18.2564 16.511 18.3377 17.0149 18.3377C17.6662 18.3377 18.2751 18.1985 18.6874 17.9478C19.4026 17.5243 19.591 16.8614 19.7583 16.2754L19.8352 15.975C19.8352 15.975 20.5288 13.1759 20.6473 12.8116C20.6507 12.7917 20.6529 12.7817 20.6576 12.7714C19.709 12.7817 19.4298 12.7714 19.3395 12.7519Z", fill: "white" }), jsx("path", { d: "M23.1723 18.3077C22.7073 18.3012 22.5444 18.3012 22.0011 18.3289L21.98 18.2887C22.0279 18.0821 22.0794 17.8785 22.1252 17.6689L22.1917 17.3867C22.2924 16.9464 22.3909 16.4347 22.4026 16.2804C22.4121 16.1862 22.4432 15.952 22.1757 15.952C22.0625 15.952 21.9449 16.0073 21.8265 16.0613C21.7608 16.2955 21.6282 16.9515 21.5672 17.2519C21.432 17.8829 21.4233 17.9542 21.3633 18.2666L21.3244 18.3077C20.8451 18.3012 20.6796 18.3012 20.1286 18.3289L20.1026 18.283C20.1951 17.9079 20.2867 17.5298 20.3749 17.1555C20.6057 16.1395 20.6601 15.7501 20.7245 15.2337L20.7677 15.203C21.3049 15.1278 21.435 15.1131 22.0163 14.9934L22.0655 15.0483L21.9778 15.372C22.0759 15.3141 22.1688 15.2549 22.2704 15.203C22.5444 15.0682 22.8495 15.0284 23.0176 15.0284C23.2713 15.0284 23.5496 15.0997 23.6663 15.394C23.7769 15.6564 23.7039 15.9805 23.5586 16.6175L23.4835 16.9412C23.3344 17.6504 23.3102 17.78 23.2267 18.2666L23.1723 18.3077Z", fill: "white" }), jsx("path", { d: "M25.0585 18.3077C24.7793 18.3064 24.5995 18.3012 24.4232 18.3064C24.2486 18.3077 24.0779 18.3168 23.8182 18.3289L23.8026 18.3064L23.7853 18.283C23.8562 18.0142 23.8964 17.92 23.9309 17.8245C23.9664 17.7299 24.001 17.6339 24.0623 17.3612C24.1436 17.006 24.1937 16.7571 24.2296 16.5397C24.2667 16.3284 24.2879 16.1495 24.3143 15.9416L24.3359 15.9252L24.3592 15.9053C24.6371 15.866 24.8147 15.84 24.9945 15.8124C25.1769 15.786 25.3605 15.7501 25.6488 15.6957L25.66 15.7207L25.6678 15.7462C25.6142 15.9662 25.5598 16.1862 25.5075 16.41C25.4561 16.6326 25.4016 16.8513 25.3532 17.073C25.2478 17.541 25.2067 17.7148 25.1816 17.8396C25.1587 17.9589 25.1509 18.0237 25.1095 18.2666L25.0844 18.2887L25.0585 18.3077Z", fill: "white" }), jsx("path", { d: "M29.2305 16.7091C29.3935 15.9948 29.2686 15.6607 29.1091 15.4563C28.8658 15.1477 28.4397 15.0479 27.9958 15.0479C27.7301 15.0479 27.0952 15.0751 26.5987 15.5332C26.2443 15.8621 26.0779 16.3107 25.9781 16.7389C25.8782 17.175 25.7628 17.9641 26.4867 18.2567C26.7114 18.3509 27.0313 18.3777 27.2396 18.3777C27.7698 18.3777 28.3135 18.2312 28.7206 17.7982C29.0382 17.446 29.1813 16.923 29.2305 16.7091ZM28.0166 16.6573C27.9911 16.777 27.8865 17.2256 27.7426 17.4161C27.6432 17.5562 27.5252 17.6404 27.3947 17.6404C27.358 17.6404 27.1285 17.6404 27.1242 17.2999C27.1216 17.1322 27.1566 16.9576 27.1985 16.7718C27.3208 16.2307 27.4651 15.7769 27.8329 15.7769C28.1225 15.7769 28.1415 16.1145 28.0166 16.6573Z", fill: "white" }), jsx("path", { d: "M40.5855 18.3561C40.0254 18.3509 39.8642 18.3509 39.3465 18.373L39.3115 18.331C39.4532 17.7982 39.595 17.267 39.7199 16.7286C39.8819 16.0298 39.9191 15.7329 39.9736 15.324L40.0155 15.2895C40.5713 15.2095 40.726 15.1875 41.3059 15.0803L41.3241 15.1278C41.2178 15.566 41.1115 16.0047 41.0103 16.4446C40.7964 17.3664 40.7186 17.8349 40.6365 18.3163L40.5855 18.3561Z", fill: "white" }), jsx("path", { d: "M40.8523 16.7721C41.0152 16.0612 40.3601 16.7094 40.2551 16.4748C40.0943 16.1092 40.195 15.3671 39.5493 15.1195C39.3017 15.0231 38.7183 15.148 38.2204 15.6031C37.8682 15.9307 37.7005 16.3736 37.6016 16.8015C37.5013 17.2315 37.3864 18.0189 38.1063 18.3015C38.3337 18.3979 38.5424 18.4256 38.7498 18.4173C39.4741 18.378 40.0265 17.2855 40.434 16.852C40.749 16.5098 40.8043 16.9808 40.8523 16.7721ZM39.7442 16.7189C39.717 16.833 39.612 17.2868 39.4681 17.4744C39.373 17.6088 39.1466 17.6939 39.0169 17.6939C38.9802 17.6939 38.7524 17.6939 38.7442 17.3564C38.7425 17.1904 38.7775 17.0158 38.8207 16.8283C38.943 16.2989 39.0874 15.8468 39.4551 15.8468C39.7451 15.8468 39.8687 16.1761 39.7442 16.7189Z", fill: "white" }), jsx("path", { d: "M32.4031 18.3077C31.9372 18.3012 31.7795 18.3012 31.2319 18.3289L31.2125 18.2887C31.2587 18.0821 31.3114 17.8785 31.3598 17.6689L31.4251 17.3867C31.5262 16.9464 31.6243 16.4347 31.6355 16.2804C31.6446 16.1862 31.6757 15.952 31.4104 15.952C31.2954 15.952 31.1792 16.0073 31.0599 16.0613C30.9951 16.2955 30.862 16.9515 30.798 17.2519C30.6653 17.8829 30.6563 17.9542 30.5962 18.2666L30.5564 18.3077C30.0776 18.3012 29.9134 18.3012 29.3637 18.3289L29.3386 18.283C29.4302 17.9079 29.5201 17.5298 29.6083 17.1555C29.8386 16.1395 29.8935 15.7501 29.9575 15.2337L30.0007 15.203C30.5378 15.1278 30.6684 15.1131 31.2496 14.9934L31.2954 15.0483L31.2112 15.372C31.3067 15.3141 31.4039 15.2549 31.5029 15.203C31.7751 15.0682 32.0828 15.0284 32.2475 15.0284C32.502 15.0284 32.7808 15.0997 32.9005 15.394C33.0098 15.6564 32.9359 15.9805 32.7894 16.6175L32.7164 16.9412C32.5643 17.6504 32.5409 17.78 32.4605 18.2666L32.4031 18.3077Z", fill: "white" }), jsx("path", { d: "M36.9307 14.4822C36.8486 14.8504 36.6096 15.1629 36.3006 15.3137C36.0452 15.4421 35.7344 15.4516 35.4129 15.4516H35.2059L35.2215 15.369C35.2215 15.369 35.6048 13.7048 35.6031 13.71L35.6143 13.6248L35.6212 13.5591L35.7742 13.5751C35.7742 13.5751 36.5616 13.6434 36.5815 13.6456C36.8931 13.764 37.0201 14.0769 36.9307 14.4822ZM36.4276 12.7467C36.4255 12.7467 36.0417 12.7518 36.0417 12.7518C35.0378 12.7631 34.6354 12.7583 34.4703 12.7385C34.4531 12.8119 34.428 12.9424 34.428 12.9424L34.0693 14.6115C34.0693 14.6115 33.2097 18.1565 33.1687 18.3229C34.0447 18.3134 34.4042 18.3134 34.5542 18.3285C34.5883 18.1621 34.7932 17.172 34.7932 17.172C34.7932 17.172 34.9682 16.4447 34.9786 16.4179C34.9786 16.4179 35.0326 16.3436 35.0883 16.3137H35.1683C35.9233 16.3137 36.7781 16.3137 37.4462 15.8206C37.9004 15.4831 38.2138 14.9848 38.3516 14.3802C38.3888 14.2316 38.4147 14.0535 38.4147 13.8772C38.4147 13.6456 38.368 13.4161 38.2323 13.2363C37.8918 12.7583 37.2142 12.7518 36.4276 12.7467Z", fill: "white" }), jsx("path", { d: "M45.1748 15.0751L45.1303 15.0254C44.5581 15.1399 44.4535 15.1598 43.9263 15.2293L43.8865 15.2674C43.8848 15.2739 43.8831 15.2842 43.8818 15.2924L43.8792 15.2842C43.4868 16.1913 43.4993 15.9951 43.1791 16.7073C43.1769 16.6736 43.1765 16.6525 43.1756 16.6187L43.0961 15.0751L43.0455 15.0254C42.4466 15.1399 42.4306 15.1598 41.8761 15.2293L41.8316 15.2674C41.8277 15.2877 41.8264 15.3076 41.8234 15.3292L41.8277 15.3374C41.8968 15.6931 41.8809 15.6131 41.9496 16.171C41.982 16.445 42.0243 16.7225 42.0567 16.9926C42.1121 17.4463 42.1423 17.6706 42.208 18.3612C41.835 18.981 41.7447 19.2148 41.3882 19.7584L41.4072 19.8077C41.9496 19.7874 42.0745 19.7874 42.4755 19.7874L42.5641 19.6884C42.8671 19.0354 45.1748 15.0751 45.1748 15.0751Z", fill: "white" }), jsx("path", { d: "M25.5693 15.4586C25.8753 15.2447 25.9146 14.9491 25.6553 14.7957C25.3926 14.6414 24.9353 14.6898 24.6259 14.9042C24.3143 15.1151 24.2802 15.4115 24.5399 15.5662C24.8001 15.7171 25.2595 15.673 25.5693 15.4586Z", fill: "white" }), jsx("path", { d: "M42.5238 19.7429L42.0727 20.5152C41.93 20.7788 41.6651 20.9771 41.2442 20.9784L40.5255 20.9668L40.7347 20.2706H40.8738C40.9477 20.2706 41.0018 20.2658 41.0432 20.2455C41.0787 20.2343 41.105 20.2062 41.1344 20.1647L41.3993 19.7429H42.5238Z", fill: "white" })] })));
756
837
  };
757
838
 
758
- var CreditCard$1 = function (_a) {
839
+ var CreditCard = function (_a) {
759
840
  var className = _a.className;
760
841
  return (jsxs("svg", __assign({ className: className, width: "60", height: "38", viewBox: "0 0 60 38", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("rect", { x: "0.5", y: "0.5", width: "59", height: "37", rx: "7.5", fill: "white", stroke: "#D3D3D3" }), jsx("path", { d: "M1 10L59 10", stroke: "#D3D3D3", "stroke-width": "7" }), jsx("path", { d: "M5 20H34", stroke: "#D3D3D3", "stroke-width": "2", "stroke-linecap": "round" }), jsx("path", { d: "M5 27H25", stroke: "#D3D3D3", "stroke-width": "2", "stroke-linecap": "round" }), jsx("rect", { x: "46", y: "21", width: "10", height: "7", rx: "2", fill: "#D9D9D9" })] })));
761
842
  };
@@ -785,26 +866,10 @@ var Visa = function (_a) {
785
866
  return (jsxs("svg", __assign({ className: className, width: "70", height: "48", viewBox: "0 0 70 48", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("rect", { x: "0.5", y: "0.5", width: "69", height: "47", rx: "5.5", fill: "white", stroke: "#D9D9D9" }), jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M21.2505 32.5165H17.0099L13.8299 20.3847C13.679 19.8267 13.3585 19.3333 12.8871 19.1008C11.7106 18.5165 10.4142 18.0514 9 17.8169V17.3498H15.8313C16.7742 17.3498 17.4813 18.0514 17.5991 18.8663L19.2491 27.6173L23.4877 17.3498H27.6104L21.2505 32.5165ZM29.9675 32.5165H25.9626L29.2604 17.3498H33.2653L29.9675 32.5165ZM38.4467 21.5514C38.5646 20.7346 39.2717 20.2675 40.0967 20.2675C41.3931 20.1502 42.8052 20.3848 43.9838 20.9671L44.6909 17.7016C43.5123 17.2345 42.216 17 41.0395 17C37.1524 17 34.3239 19.1008 34.3239 22.0165C34.3239 24.2346 36.3274 25.3992 37.7417 26.1008C39.2717 26.8004 39.861 27.2675 39.7431 27.9671C39.7431 29.0165 38.5646 29.4836 37.3881 29.4836C35.9739 29.4836 34.5596 29.1338 33.2653 28.5494L32.5582 31.8169C33.9724 32.3992 35.5025 32.6338 36.9167 32.6338C41.2752 32.749 43.9838 30.6502 43.9838 27.5C43.9838 23.5329 38.4467 23.3004 38.4467 21.5514ZM58 32.5165L54.82 17.3498H51.4044C50.6972 17.3498 49.9901 17.8169 49.7544 18.5165L43.8659 32.5165H47.9887L48.8116 30.3004H53.8772L54.3486 32.5165H58ZM51.9936 21.4342L53.1701 27.1502H49.8723L51.9936 21.4342Z", fill: "#172B85" })] })));
786
867
  };
787
868
 
788
- var LargeCardIcon = function () {
789
- return (jsx("svg", __assign({ width: "72", height: "56", viewBox: "0 0 72 56", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: 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" }) })));
790
- };
791
-
792
- var PlusIcon = function (_a) {
793
- var color = _a.color;
794
- return (jsxs("svg", __assign({ width: "14", height: "15", viewBox: "0 0 14 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("path", { d: "M2.9165 7.5H11.0832", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M7 3.41663V11.5833", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
795
- };
796
-
797
- var Text$o = Typography.Text;
798
- var CreditCard = function (_a) {
799
- var _b;
800
- 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;
801
- var isMobile = useIsMobile();
802
- var Wrapper = cardEnabled ? Card : "div";
803
- return (jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$o, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier })] })), jsx(CustomizedTag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Divider, {}), jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
804
- };
869
+ var Text$p = Typography.Text;
805
870
  var MiniCreditCard = function (_a) {
806
871
  var _b, _c;
807
- var _d = _a.hideRemoveButton, hideRemoveButton = _d === void 0 ? false : _d, onClickRemove = _a.onClickRemove, paymentMethodData = _a.paymentMethodData;
872
+ var _d = _a.hideDropdownMenu, hideDropdownMenu = _d === void 0 ? false : _d, onClickRemove = _a.onClickRemove, paymentMethodData = _a.paymentMethodData, onClickSetDefault = _a.onClickSetDefault, id = _a.id;
808
873
  var darkMode = useContext(BunnyContext).darkMode;
809
874
  var borderColor = useMemo(function () {
810
875
  return darkMode ? "border-slate-700" : "border-slate-200";
@@ -815,14 +880,37 @@ var MiniCreditCard = function (_a) {
815
880
  function capitalize(str) {
816
881
  return str.charAt(0).toUpperCase() + str.slice(1);
817
882
  }
818
- return (jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxs(Fragment, { children: [jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxs("div", __assign({ className: "flex items-center gap-2 space-between w-full" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$o, { children: capitalize((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) }), jsxs("div", { children: [jsx(Text$o, __assign({ className: "relative -top-0.5" }, { children: "****" })), jsx(Text$o, { children: (_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.identifier })] })] })) })), !hideRemoveButton && (jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsx(CreditCardOutlined, {}), jsx(Text$o, __assign({ className: "text-slate-400", style: { fontSize: "12px" } }, { children: "No payment method selected" })), jsx(Button, { disabled: true, type: "link" })] }))) })));
883
+ var isDefault = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.isDefault;
884
+ return (jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border"), id: id }, { children: paymentMethodData ? (jsxs(Fragment, { children: [jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxs("div", __assign({ className: "flex items-center gap-2 space-between w-full" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$p, { children: capitalize((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) }), jsxs("div", { children: [jsx(Text$p, __assign({ className: "relative -top-0.5" }, { children: "****" })), jsx(Text$p, { children: (_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.identifier })] }), jsx("div", { children: isDefault ? (jsx(Tag, __assign({ bordered: false, color: "blue" }, { children: "Default" }))) : null })] })) })), !hideDropdownMenu && (jsx(DropdownMenu, { setDefault: onClickSetDefault, remove: onClickRemove, isDefault: isDefault !== null && isDefault !== void 0 ? isDefault : false, id: "credit-card-dropdown-".concat(paymentMethodData.id) }))] })) : (jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsx(CreditCardOutlined, {}), jsx(Text$p, __assign({ className: "text-slate-400", style: { fontSize: "12px" } }, { children: "No payment methods" })), jsx(Button, { disabled: true, type: "link" })] }))) })));
885
+ };
886
+ var DropdownMenu = function (_a) {
887
+ var setDefault = _a.setDefault, remove = _a.remove, isDefault = _a.isDefault, id = _a.id;
888
+ // Define the menu items
889
+ var items = [
890
+ {
891
+ key: "1",
892
+ label: "Remove",
893
+ onClick: function () {
894
+ remove();
895
+ },
896
+ },
897
+ {
898
+ key: "2",
899
+ label: "Set as default",
900
+ onClick: function () {
901
+ setDefault();
902
+ },
903
+ disabled: isDefault,
904
+ },
905
+ ];
906
+ return (jsx(Dropdown, __assign({ menu: { items: items }, trigger: ["click"] }, { children: jsx("a", __assign({ onClick: function (e) { return e.preventDefault(); }, id: id, className: "cursor-pointer hover:bg-gray-100 rounded-md p-1" }, { children: jsx(EllipsisOutlined, { style: { fontSize: "20px" } }) })) })));
819
907
  };
820
908
  var CardImage = function (_a) {
821
909
  var _b;
822
910
  var paymentMethodData = _a.paymentMethodData;
823
911
  var issuer = (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer;
824
912
  var className = "w-12 h-8";
825
- switch (issuer) {
913
+ switch (issuer.toLowerCase()) {
826
914
  case "visa":
827
915
  return jsx(Visa, { className: className });
828
916
  case "mastercard":
@@ -842,30 +930,9 @@ var CardImage = function (_a) {
842
930
  case "china_unionpay":
843
931
  return jsx(ChinaUnionPay, { className: className });
844
932
  default:
845
- return jsx(CreditCard$1, { className: className });
933
+ return jsx(CreditCard, { className: className });
846
934
  }
847
935
  };
848
- var CardAttribute = function (_a) {
849
- var title = _a.title, value = _a.value;
850
- return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsx(Text$o, { children: value })] })));
851
- };
852
- var CardActions = function (_a) {
853
- var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
854
- var isMobile = useIsMobile();
855
- return (jsxs("div", __assign({ className: "flex items-center gap-6 ".concat(isMobile ? "justify-center mt-4" : "") }, { children: [jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove payment method" })) })), jsx(Divider, { style: { height: "24px" }, type: "vertical" }), jsx(Button, __assign({ onClick: onClickUpdate, type: "primary" }, { children: "Update" }))] })));
856
- };
857
- var EmptyCard = function (_a) {
858
- var onClick = _a.onClick, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, _c = _a.cardEnabled, cardEnabled = _c === void 0 ? true : _c;
859
- var brandColor = useContext(BrandContext).brandColor;
860
- return (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: [jsx(LargeCardIcon, {}), jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsx(Button, __assign({ type: "link", id: "openAddPaymentMethodDrawer" }, { children: jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
861
- };
862
- var isExpired = function (paymentMethodData) {
863
- var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
864
- return expDate.isBefore(dayjs());
865
- };
866
- var expirationDate = function (storedPaymentMethod) {
867
- return dayjs(storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.expirationDate).format("MM/YY");
868
- };
869
936
 
870
937
  var SavePaymentMethodFooter = function (_a) {
871
938
  var isSaving = _a.isSaving, onSave = _a.onSave, noPadding = _a.noPadding;
@@ -1028,7 +1095,7 @@ function useSave$1(_a) {
1028
1095
  return { save: save, isSaving: isSaving };
1029
1096
  }
1030
1097
 
1031
- var Text$n = Typography.Text;
1098
+ var Text$o = Typography.Text;
1032
1099
  var TEST_CARD = "4242424242424242";
1033
1100
  var DemoPayForm = function (_a) {
1034
1101
  var onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod, plugin = _a.plugin;
@@ -1089,7 +1156,7 @@ var DemoPayForm = function (_a) {
1089
1156
  var onCardCvcChange = function (cvc) {
1090
1157
  setCardDetails(__assign(__assign({}, cardDetails), { cvc: cvc }));
1091
1158
  };
1092
- return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsx(Text$n, { children: "DemoPay is for testing only." }), jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] })));
1159
+ return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsx(Text$o, { children: "DemoPay is for testing only." }), jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] })));
1093
1160
  };
1094
1161
  var StyledInputs = defaultStyled.div(templateObject_1$a || (templateObject_1$a = __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) {
1095
1162
  var darkMode = _a.darkMode;
@@ -1308,20 +1375,17 @@ var StripeForm = function (_a) {
1308
1375
 
1309
1376
  var PaymentMethodDetails = function (_a) {
1310
1377
  var _b, _c, _d, _e, _f, _g, _h, _j;
1311
- var onFail = _a.onFail, paymentMethod = _a.paymentMethod, onSavePaymentMethod = _a.onSavePaymentMethod, customPaymentForms = _a.customPaymentForms;
1312
- if (!paymentMethod)
1313
- return null;
1314
- paymentMethod = paymentMethod;
1315
- switch ((_c = (_b = paymentMethod.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name) {
1378
+ var onFail = _a.onFail, plugin = _a.plugin, onSavePaymentMethod = _a.onSavePaymentMethod, customPaymentForms = _a.customPaymentForms;
1379
+ switch ((_c = (_b = plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name) {
1316
1380
  case "StripePayment":
1317
- return (jsx(StripeForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: paymentMethod }));
1381
+ return (jsx(StripeForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
1318
1382
  case "DemoPayPayment":
1319
- return (jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: paymentMethod }));
1383
+ return (jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
1320
1384
  default:
1321
1385
  if (customPaymentForms &&
1322
- ((_e = (_d = paymentMethod.components) === null || _d === void 0 ? void 0 : _d.frontend) === null || _e === void 0 ? void 0 : _e[0].name) &&
1323
- customPaymentForms[(_g = (_f = paymentMethod.components) === null || _f === void 0 ? void 0 : _f.frontend) === null || _g === void 0 ? void 0 : _g[0].name]) {
1324
- return (jsx(Fragment, { children: customPaymentForms[(_j = (_h = paymentMethod.components) === null || _h === void 0 ? void 0 : _h.frontend) === null || _j === void 0 ? void 0 : _j[0].name] }));
1386
+ ((_e = (_d = plugin.components) === null || _d === void 0 ? void 0 : _d.frontend) === null || _e === void 0 ? void 0 : _e[0].name) &&
1387
+ customPaymentForms[(_g = (_f = plugin.components) === null || _f === void 0 ? void 0 : _f.frontend) === null || _g === void 0 ? void 0 : _g[0].name]) {
1388
+ return jsx(Fragment, { children: customPaymentForms[(_j = (_h = plugin.components) === null || _h === void 0 ? void 0 : _h.frontend) === null || _j === void 0 ? void 0 : _j[0].name] });
1325
1389
  }
1326
1390
  return jsx("p", { children: "Can not find form for plugin" });
1327
1391
  }
@@ -1331,7 +1395,7 @@ var CardIcon = function () {
1331
1395
  return (jsxs("svg", __assign({ width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [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: SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M1.5 7.5H16.5", stroke: SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
1332
1396
  };
1333
1397
 
1334
- var Text$m = Typography.Text;
1398
+ var Text$n = Typography.Text;
1335
1399
  var PaymentMethodSelector = function (_a) {
1336
1400
  var paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins, onSelect = _a.onSelect, value = _a.value;
1337
1401
  return (jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentPlugin: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
@@ -1344,7 +1408,7 @@ var PaymentOption = function (_a) {
1344
1408
  var isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("card");
1345
1409
  return (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
1346
1410
  ? "var(--row-background-dark) border-gray-500"
1347
- : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$m, { children: name })] })), isAch ? (jsx(BankOutlined, { className: "text-slate-400" })) : isCard ? (jsx(CardIcon, {})) : (jsx(CardIcon, {}))] })));
1411
+ : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$n, { children: name })] })), isAch ? (jsx(BankOutlined, { className: "text-slate-400" })) : isCard ? (jsx(CardIcon, {})) : (jsx(CardIcon, {}))] })));
1348
1412
  };
1349
1413
  var PaymentOptionContainer = defaultStyled.div(templateObject_1$9 || (templateObject_1$9 = __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) {
1350
1414
  var $brandColor = _a.$brandColor, $selected = _a.$selected;
@@ -1356,7 +1420,7 @@ var PaymentOptionContainer = defaultStyled.div(templateObject_1$9 || (templateOb
1356
1420
  });
1357
1421
  var templateObject_1$9;
1358
1422
 
1359
- function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1423
+ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId, onRemovePaymentMethod) {
1360
1424
  var _this = this;
1361
1425
  var queryClient = useQueryClient();
1362
1426
  var showErrorNotification = useErrorNotification();
@@ -1380,10 +1444,14 @@ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1380
1444
  })
1381
1445
  .then(function () {
1382
1446
  showSuccessNotification("Payment method was removed", "Success");
1383
- queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey({
1384
- token: token,
1385
- accountId: accountId,
1386
- }), null);
1447
+ // TODO: rename accountPaymentMethodKey to accountPaymentMethodsKey (pluralized)
1448
+ queryClient.invalidateQueries({
1449
+ queryKey: QueryKeyFactory.default.accountPaymentMethodKey({
1450
+ token: token,
1451
+ accountId: accountId,
1452
+ }),
1453
+ });
1454
+ onRemovePaymentMethod === null || onRemovePaymentMethod === void 0 ? void 0 : onRemovePaymentMethod();
1387
1455
  })
1388
1456
  .catch(function (error) {
1389
1457
  showErrorNotification(error.message, "Error removing payment method");
@@ -1398,62 +1466,104 @@ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1398
1466
  return removePaymentMethod;
1399
1467
  }
1400
1468
 
1469
+ function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId) {
1470
+ var _this = this;
1471
+ var queryClient = useQueryClient();
1472
+ var showErrorNotification = useErrorNotification();
1473
+ var showSuccessNotification = useSuccessNotification();
1474
+ var _a = useState(false), loading = _a[0], setLoading = _a[1];
1475
+ var setDefaultPaymentMethod = useCallback(function (data) { return __awaiter(_this, void 0, void 0, function () {
1476
+ var plugin;
1477
+ return __generator(this, function (_a) {
1478
+ switch (_a.label) {
1479
+ case 0:
1480
+ 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); });
1481
+ if (!(data && plugin)) return [3 /*break*/, 2];
1482
+ setLoading(true);
1483
+ return [4 /*yield*/, invokePlugin({
1484
+ plugin: plugin,
1485
+ method: "assign_default_payment_method",
1486
+ payload: {
1487
+ payment_method_id: data.id,
1488
+ account_id: accountId,
1489
+ },
1490
+ token: token,
1491
+ apiHost: apiHost,
1492
+ })
1493
+ .then(function () {
1494
+ showSuccessNotification("Payment method ".concat(data.metadata.identifier, " was set as default"), "Success");
1495
+ // TODO: rename accountPaymentMethodKey to accountPaymentMethodsKey (pluralized)
1496
+ queryClient.invalidateQueries({
1497
+ queryKey: QueryKeyFactory.default.accountPaymentMethodKey({
1498
+ token: token,
1499
+ accountId: accountId,
1500
+ }),
1501
+ });
1502
+ })
1503
+ .catch(function (error) {
1504
+ setLoading(false);
1505
+ showErrorNotification(error.message, "Error removing payment method");
1506
+ })
1507
+ .finally(function () {
1508
+ setLoading(false);
1509
+ })];
1510
+ case 1:
1511
+ _a.sent();
1512
+ _a.label = 2;
1513
+ case 2: return [2 /*return*/];
1514
+ }
1515
+ });
1516
+ }); }, [paymentPlugins, token, apiHost, queryClient]);
1517
+ return { setDefaultPaymentMethod: setDefaultPaymentMethod, loading: loading };
1518
+ }
1519
+
1401
1520
  var Panel = Collapse.Panel;
1402
1521
  var PaymentForm = function (_a) {
1403
1522
  var _b;
1404
- var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, overrideToken = _a.overrideToken, graphQLClient = _a.graphQLClient, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, customPaymentForms = _a.customPaymentForms, _c = _a.useAllPaymentPlugins, useAllPaymentPlugins = _c === void 0 ? false : _c;
1523
+ var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, customPaymentForms = _a.customPaymentForms, _c = _a.useAllPaymentPlugins, useAllPaymentPlugins = _c === void 0 ? false : _c;
1405
1524
  // Local state
1406
- var _d = useState(), selectedPaymentMethod = _d[0], setSelectedPaymentMethod = _d[1];
1407
- var _e = useState(false), showPaymentMethodForm = _e[0], setShowPaymentMethodForm = _e[1];
1408
- var paying = !!(quote || invoice);
1409
- var currencyId = (_b = ((quote === null || quote === void 0 ? void 0 : quote.currencyId) ||
1410
- (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId) ||
1411
- currencyIdFromProps)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
1412
- // Hooks
1525
+ var _d = useState(false), showPaymentMethodForm = _d[0], setShowPaymentMethodForm = _d[1];
1526
+ // Simple hooks
1527
+ var queryClient = useQueryClient();
1413
1528
  var apiHost = useContext(BunnyContext).apiHost;
1414
1529
  var tokenFromContexts = useToken();
1415
1530
  var token = overrideToken || tokenFromContexts;
1416
- var _f = usePaymentMethod({
1531
+ var _e = usePaymentMethod({
1417
1532
  accountId: accountId,
1418
- graphQLClient: graphQLClient,
1419
1533
  token: token,
1420
- }), storedPaymentMethod = _f.data, isPaymentMethodLoading = _f.isLoading;
1421
- var isPaymentMethodFetched = storedPaymentMethod !== undefined;
1422
- var _g = usePaymentPlugins({ apiHost: apiHost, token: token }), allPaymentMethodAllowedPlugins = _g.paymentMethodAllowedPlugins, allPaymentPlugins = _g.paymentPlugins, arePluginsFetched = _g.isFetched;
1534
+ apiHost: apiHost,
1535
+ }), storedPaymentMethods = _e.paymentMethods, defaultPaymentMethod = _e.defaultPaymentMethod, isPaymentMethodLoading = _e.isLoading;
1536
+ // Complex hooks
1537
+ var _f = usePaymentPlugins({ apiHost: apiHost, token: token }), allPaymentMethodAllowedPlugins = _f.paymentMethodAllowedPlugins, allPaymentPlugins = _f.paymentPlugins;
1423
1538
  var paymentMethodAllowedPlugins = useMemo(function () {
1424
1539
  if (useAllPaymentPlugins) {
1425
1540
  return allPaymentPlugins;
1426
1541
  }
1427
1542
  return allPaymentMethodAllowedPlugins;
1428
1543
  }, [allPaymentMethodAllowedPlugins, allPaymentPlugins, useAllPaymentPlugins]);
1429
- var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], apiHost, token, accountId);
1430
- var queryClient = useQueryClient();
1431
- // Set default plugin
1432
- useEffect(function () {
1433
- if (!arePluginsFetched ||
1434
- !isPaymentMethodFetched ||
1435
- selectedPaymentMethod) {
1436
- return;
1437
- }
1438
- var pluginPaymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
1439
- if (pluginPaymentMethod) {
1440
- setSelectedPaymentMethod(pluginPaymentMethod);
1441
- }
1442
- else if (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]) {
1443
- setSelectedPaymentMethod(paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]);
1444
- }
1445
- }, [
1446
- arePluginsFetched,
1447
- isPaymentMethodFetched,
1448
- paymentMethodAllowedPlugins,
1449
- selectedPaymentMethod,
1450
- setSelectedPaymentMethod,
1451
- storedPaymentMethod,
1452
- ]);
1453
- var showPaymentMethodSelector = useMemo(function () {
1454
- var pluginCount = (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.length) || 0;
1455
- return pluginCount > 1;
1456
- }, [paymentMethodAllowedPlugins]);
1544
+ var selectedPaymentMethodPlugin = useMemo(function () {
1545
+ return paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
1546
+ }, [paymentMethodAllowedPlugins, defaultPaymentMethod]);
1547
+ // Derived state
1548
+ var defaultPaymentMethodPlugin = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
1549
+ var paying = !!(quote || invoice);
1550
+ var currencyId = (_b = ((quote === null || quote === void 0 ? void 0 : quote.currencyId) ||
1551
+ (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId) ||
1552
+ currencyIdFromProps)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
1553
+ // Custom hooks
1554
+ var _g = useSetDefaultPaymentMethod(paymentMethodAllowedPlugins || [], apiHost, token, accountId), handleSetDefault = _g.setDefaultPaymentMethod, setDefaultPaymentMethodLoading = _g.loading;
1555
+ useAutoSetDefaultPaymentMethod({
1556
+ accountId: accountId,
1557
+ token: token,
1558
+ handleSetDefault: handleSetDefault,
1559
+ setDefaultPaymentMethodLoading: setDefaultPaymentMethodLoading,
1560
+ });
1561
+ var _h = usePaymentMethodSelectorPlugin({
1562
+ defaultPaymentMethod: defaultPaymentMethod,
1563
+ defaultPaymentMethodPlugin: defaultPaymentMethodPlugin,
1564
+ paymentMethodAllowedPlugins: paymentMethodAllowedPlugins,
1565
+ }), selectorPaymentMethodPlugin = _h.selectorPaymentMethodPlugin, setSelectorPaymentMethodPlugin = _h.setSelectorPaymentMethodPlugin;
1566
+ var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], apiHost, token, accountId, onRemovePaymentMethod);
1457
1567
  var handlePaymentSuccess = function () {
1458
1568
  // Hide payment method selector and form
1459
1569
  setShowPaymentMethodForm(false);
@@ -1476,13 +1586,12 @@ var PaymentForm = function (_a) {
1476
1586
  onClickCancel: function () { return setShowPaymentMethodForm(false); },
1477
1587
  accountId: accountId,
1478
1588
  overrideToken: overrideToken,
1479
- storedPaymentMethod: storedPaymentMethod,
1589
+ storedPaymentMethods: storedPaymentMethods,
1590
+ defaultPaymentMethod: defaultPaymentMethod,
1480
1591
  customCheckoutFunction: customCheckoutFunction,
1481
- } }, { children: jsx(StripeWrapper, __assign({ plugin: selectedPaymentMethod, token: token, apiHost: apiHost, currencyId: currencyId, accountId: accountId }, { children: jsx("div", __assign({ className: "flex flex-col gap-0 w-full" }, { children: jsxs(Fragment, { children: [jsx("div", __assign({ className: "px-4" }, { children: jsx(MiniCreditCard, { onClickRemove: function () { return onClickRemove(storedPaymentMethod); }, paymentMethodData: storedPaymentMethod }) })), paying && storedPaymentMethod ? (jsx("div", __assign({ className: "px-4" }, { children: jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethod }) }))) : (
1482
- //if not paying and payment method is saved, show Collapse
1483
- jsx(Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsx(Panel, __assign({ header: jsx(Fragment, { children: !showPaymentMethodForm ? (jsx("div", __assign({ className: "pt-2" }, { children: jsxs(Button, __assign({ onClick: function () {
1592
+ } }, { children: jsx(StripeWrapper, __assign({ plugin: selectorPaymentMethodPlugin, token: token, apiHost: apiHost, currencyId: currencyId, accountId: accountId }, { children: jsx("div", __assign({ className: "flex flex-col gap-0 w-full" }, { children: jsxs(Fragment, { children: [jsxs("div", __assign({ className: "flex flex-col gap-2 px-4" }, { children: [storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.map(function (paymentMethod) { return (jsx(MiniCreditCard, { onClickRemove: function () { return onClickRemove(paymentMethod); }, onClickSetDefault: function () { return handleSetDefault(paymentMethod); }, paymentMethodData: paymentMethod, id: "payment-method-".concat(paymentMethod.id) }, paymentMethod.id)); }), (storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) === 0 && (jsx(MiniCreditCard, { onClickRemove: function () { }, onClickSetDefault: function () { } }))] })), jsx(Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsx(Panel, __assign({ header: jsx(Fragment, { children: !showPaymentMethodForm ? (jsx("div", __assign({ className: "pt-2" }, { children: jsx(Button, __assign({ onClick: function () {
1484
1593
  setShowPaymentMethodForm(true);
1485
- }, type: "default", className: "w-full", id: "addPaymentMethod" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsx("div", { children: selectedPaymentMethod ? (jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod, customPaymentForms: customPaymentForms }) }))] }))) : (jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })) })));
1594
+ }, type: "default", className: "w-full", id: "addPaymentMethod" }, { children: "Add payment method" })) }))) : null }), showArrow: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [jsx(PaymentMethodSelector, { onSelect: setSelectorPaymentMethodPlugin, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectorPaymentMethodPlugin }), selectorPaymentMethodPlugin && (jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, plugin: selectorPaymentMethodPlugin, customPaymentForms: customPaymentForms }) })))] })) }), "1") })), paying ? (jsx(Fragment, { children: defaultPaymentMethod ? (jsx("div", __assign({ className: "px-4" }, { children: jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethodPlugin }) }))) : null })) : null] }) })) })) })));
1486
1595
  };
1487
1596
  function StripeWrapper(_a) {
1488
1597
  var children = _a.children, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, currencyId = _a.currencyId, accountId = _a.accountId;
@@ -1509,7 +1618,7 @@ function ActualInvoice() {
1509
1618
  // Context
1510
1619
  var queryClient = useQueryClient();
1511
1620
  var _a = useContext(InvoiceQuoteContext), id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess, className = _a.className;
1512
- var _b = useContext(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired, graphQLClient = _b.graphQLClient;
1621
+ var _b = useContext(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired; _b.graphQLClient;
1513
1622
  var _c = useContext(InvoiceQuoteContext), hideDownloadButton = _c.hideDownloadButton, onInvoiceLoaded = _c.onInvoiceLoaded;
1514
1623
  var token = useToken();
1515
1624
  // Hooks
@@ -1547,10 +1656,10 @@ function ActualInvoice() {
1547
1656
  }, [formattedInvoice]);
1548
1657
  if (!formattedInvoice)
1549
1658
  return jsx(Fragment, {});
1550
- return (jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost, token: token }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? "" : "pt-12") }, { children: jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice, graphQLClient: graphQLClient }) })))] })) })));
1659
+ return (jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost, token: token }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? "" : "pt-12") }, { children: jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
1551
1660
  }
1552
1661
 
1553
- 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 }"; };
1662
+ var MUTATION$6 = 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 }"; };
1554
1663
  var getFormattedQuote = function (_a) {
1555
1664
  var id = _a.id, token = _a.token, apiHost = _a.apiHost;
1556
1665
  return __awaiter(void 0, void 0, void 0, function () {
@@ -1558,7 +1667,7 @@ var getFormattedQuote = function (_a) {
1558
1667
  return __generator(this, function (_b) {
1559
1668
  switch (_b.label) {
1560
1669
  case 0: return [4 /*yield*/, gqlRequest({
1561
- query: MUTATION$7(),
1670
+ query: MUTATION$6(),
1562
1671
  token: token,
1563
1672
  apiHost: apiHost,
1564
1673
  vars: { id: id },
@@ -1808,7 +1917,7 @@ var AcceptQuoteModal = function (_a) {
1808
1917
  }, open: acceptBoxVisible, title: "Accept quote", width: 400 }, { children: jsxs(Form, __assign({ className: "flex flex-col gap-2", form: form, layout: "vertical" }, { children: [jsx(Form.Item, __assign({ label: "Your name", name: "name", rules: createRules(true, "Your name") }, { children: jsx(Input, { autoFocus: true, ref: firstInputRef }) })), jsx(Form.Item, __assign({ label: "Your job title", name: "title", rules: createRules(true, "Your job title") }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Purchase order number", name: "poNumber", rules: createRules(poNumberRequired, "Purchase order number") }, { children: jsx(Input, {}) })), taxNumberRequired && (jsx(Form.Item, __assign({ name: "taxNumber", label: taxNumberLabel, rules: createRules(taxNumberRequired, taxNumberLabel) }, { children: jsx(Input, {}) })))] })) })));
1809
1918
  };
1810
1919
 
1811
- var Text$l = Typography.Text;
1920
+ var Text$m = Typography.Text;
1812
1921
  defaultStyled.div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
1813
1922
  function Quote(_a) {
1814
1923
  var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, onInvoiceDownloadError = _a.onInvoiceDownloadError, onPaymentSuccess = _a.onPaymentSuccess, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, className = _a.className, _c = _a.hideDownloadButton, hideDownloadButton = _c === void 0 ? false : _c, onQuoteLoaded = _a.onQuoteLoaded;
@@ -1877,7 +1986,7 @@ function ActualQuote() {
1877
1986
  var isAccepted = formattedQuote.state === "ACCEPTED";
1878
1987
  return (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "flex flex-col gap-4 ".concat(isMobile ? "w-full overflow-hidden" : "bunny-shadow-padding-xb", " ").concat(className) }, { children: [jsxs("div", __assign({ className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
1879
1988
  color: entityBranding.secondaryColor,
1880
- } }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$l, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxs("div", __assign({ className: isMobile
1989
+ } }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$m, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxs("div", __assign({ className: isMobile
1881
1990
  ? "flex w-full justify-end gap-2"
1882
1991
  : "flex items-center justify-end gap-2" }, { children: [!isMobile && !hideDownloadButton ? (jsx(Button, __assign({ icon: jsx(DownloadOutlined, {}), onClick: function () {
1883
1992
  return downloadFile(apiHost + "/api/pdf/quote", token);
@@ -19183,10 +19292,10 @@ var getColor = function (state) {
19183
19292
  }
19184
19293
  };
19185
19294
 
19186
- var Text$k = Typography.Text;
19295
+ var Text$l = Typography.Text;
19187
19296
  var TransactionDate = function (_a) {
19188
19297
  var date = _a.date;
19189
- return jsx(Text$k, __assign({ className: "text-sm" }, { children: formatDate(date) }));
19298
+ return jsx(Text$l, __assign({ className: "text-sm" }, { children: formatDate(date) }));
19190
19299
  };
19191
19300
 
19192
19301
  var ArrowDownToLine = function (_a) {
@@ -19223,12 +19332,13 @@ var TransactionGridCell = defaultStyled.div.withConfig({
19223
19332
  }, SLATE_600);
19224
19333
  var templateObject_1$6;
19225
19334
 
19226
- var Text$j = Typography.Text;
19335
+ var Text$k = Typography.Text;
19227
19336
  var TransactionsEmptyState = function () {
19228
19337
  var noTransactionsMessage = useContext(TransactionsListContext).noTransactionsMessage;
19229
- return (jsx(Text$j, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
19338
+ return (jsx(Text$k, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
19230
19339
  };
19231
19340
 
19341
+ var Text$j = Typography.Text;
19232
19342
  var isInvoice = function (transaction) {
19233
19343
  return transaction.kind === "INVOICE";
19234
19344
  };
@@ -19240,7 +19350,7 @@ var TransactionRowTitle = function (_a) {
19240
19350
  if (!isInvoice(transaction) && !isQuote(transaction)) {
19241
19351
  return jsx(Fragment, {});
19242
19352
  }
19243
- return (jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
19353
+ return (jsx(Text$j, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
19244
19354
  };
19245
19355
 
19246
19356
  function transactionDateToDisplay(transaction, transactionDateType) {
@@ -19551,103 +19661,7 @@ function QuotesWrapper() {
19551
19661
  return (jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search }));
19552
19662
  }
19553
19663
 
19554
- // TODO: move this to common
19555
- var billingDetailsQuery = function () {
19556
- return "\nquery BillingDetails {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n currency {\n id\n }\n }\n}";
19557
- };
19558
- var getBillingDetails = function (_a) {
19559
- var token = _a.token, apiHost = _a.apiHost;
19560
- return __awaiter(void 0, void 0, void 0, function () {
19561
- var response;
19562
- var _b;
19563
- return __generator(this, function (_c) {
19564
- switch (_c.label) {
19565
- case 0: return [4 /*yield*/, gqlRequest({
19566
- query: billingDetailsQuery(),
19567
- token: token,
19568
- apiHost: apiHost,
19569
- })];
19570
- case 1:
19571
- response = _c.sent();
19572
- if (response === null || response === void 0 ? void 0 : response.errors) {
19573
- throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
19574
- }
19575
- return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
19576
- }
19577
- });
19578
- });
19579
- };
19580
-
19581
- var Text$f = Typography.Text;
19582
- var DrawerHeader = function (_a) {
19583
- var description = _a.description, onClose = _a.onClose, title = _a.title, closeButtonClassName = _a.closeButtonClassName;
19584
- return (jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsx(Text$f, __assign({ className: "text-xl", style: { fontWeight: 400 } }, { children: title })), onClose ? (jsx("button", __assign({ id: "closePayment", onClick: onClose, className: closeButtonClassName }, { children: jsx(CloseOutlined, {}) }))) : null] })), description && jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
19585
- };
19586
-
19587
- var PaymentMethod = function (_a) {
19588
- var _b;
19589
- var className = _a.className, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, _d = _a.cardEnabled, cardEnabled = _d === void 0 ? true : _d,
19590
- /** Whether to use a modal instead of a drawer for the payment method form */
19591
- _e = _a.useModal,
19592
- /** Whether to use a modal instead of a drawer for the payment method form */
19593
- useModal = _e === void 0 ? true : _e;
19594
- var _f = useContext(BunnyContext), apiHost = _f.apiHost, graphQLClient = _f.graphQLClient, onTokenExpired = _f.onTokenExpired;
19595
- var token = useToken();
19596
- // Hooks
19597
- var queryClient = useQueryClient();
19598
- var paymentPlugins = usePaymentPlugins({ apiHost: apiHost, token: token }).paymentPlugins;
19599
- var showSuccessNotification = useSuccessNotification();
19600
- var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
19601
- var data = usePaymentMethod({ graphQLClient: graphQLClient, token: token }).data;
19602
- var onClickRemove = useRemovePaymentMethod(paymentPlugins || [], apiHost, token);
19603
- // Queries
19604
- var billingDetails = useQuery({
19605
- queryKey: QueryKeyFactory.default.billingDetailsKey({ token: token }),
19606
- queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
19607
- }).data;
19608
- // Local state
19609
- var _g = useState(false), showModal = _g[0], setShowModal = _g[1];
19610
- var onSuccess = function () {
19611
- queryClient.invalidateQueries({
19612
- queryKey: QueryKeyFactory.default.accountPaymentMethodKey({ token: token }),
19613
- });
19614
- setShowModal(false);
19615
- showSuccessNotification("Your payment method has been saved");
19616
- };
19617
- if (data === undefined)
19618
- return jsx(Fragment, {});
19619
- return (jsxs("div", __assign({ className: "".concat(className) }, { children: [data ? (jsx(CreditCard, { onClickRemove: function () { return __awaiter(void 0, void 0, void 0, function () {
19620
- return __generator(this, function (_a) {
19621
- switch (_a.label) {
19622
- case 0: return [4 /*yield*/, onClickRemove(data)];
19623
- case 1:
19624
- _a.sent();
19625
- return [2 /*return*/];
19626
- }
19627
- });
19628
- }); }, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data, shadow: shadow, cardEnabled: cardEnabled })) : (jsx(EmptyCard, { onClick: function () { return setShowModal(true); }, shadow: shadow, cardEnabled: cardEnabled })), jsx(PaymentMethodDisplay, __assign({ useModal: useModal, setShowModal: setShowModal, showModal: showModal }, { children: jsx(PaymentForm, { onFail: function (error) {
19629
- handleAllErrorFormats(error);
19630
- }, onPaymentSuccess: function () {
19631
- onSuccess();
19632
- }, graphQLClient: graphQLClient, currencyId: (_b = billingDetails === null || billingDetails === void 0 ? void 0 : billingDetails.currency) === null || _b === void 0 ? void 0 : _b.id }) }))] })));
19633
- };
19634
- var PaymentMethodDisplay = function (_a) {
19635
- var children = _a.children, useModal = _a.useModal, setShowModal = _a.setShowModal, showModal = _a.showModal;
19636
- if (useModal) {
19637
- return (jsx(Modal, __assign({ closeIcon: null, open: showModal, onClose: function () { return setShowModal(false); }, onCancel: function () { return setShowModal(false); }, styles: {
19638
- body: {
19639
- padding: "1rem 0 0 0",
19640
- },
19641
- }, title: jsx("div", __assign({ className: "px-4" }, { children: jsx(DrawerHeader, { closeButtonClassName: "bg-transparent border-none cursor-pointer hover:bg-gray-100 p-2 rounded-sm transition-all duration-200", onClose: function () { return setShowModal(false); }, title: "New payment method" }) })), footer: null }, { children: children })));
19642
- }
19643
- return (jsx(Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
19644
- body: {
19645
- padding: "1rem 0.5rem 0",
19646
- },
19647
- }, title: jsx(DrawerHeader, { onClose: function () { return setShowModal(false); }, title: "New payment method", closeButtonClassName: "ant-drawer-close" }) }, { children: children })));
19648
- };
19649
-
19650
- var MUTATION$6 = function () { return "\nmutation AccountSignup (\n $pluginId: String!,\n $paymentMethodId: String,\n $priceListCode: String!,\n $accountId: ID!,\n $quoteId: ID!,\n $entityId: ID!\n) {\n accountSignup(\n pluginId: $pluginId,\n paymentMethodId: $paymentMethodId,\n priceListCode: $priceListCode,\n accountId: $accountId,\n quoteId: $quoteId,\n entityId: $entityId\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}"; };
19664
+ var MUTATION$5 = function () { return "\nmutation AccountSignup (\n $pluginId: String!,\n $paymentMethodId: String,\n $priceListCode: String!,\n $accountId: ID!,\n $quoteId: ID!,\n $entityId: ID!\n) {\n accountSignup(\n pluginId: $pluginId,\n paymentMethodId: $paymentMethodId,\n priceListCode: $priceListCode,\n accountId: $accountId,\n quoteId: $quoteId,\n entityId: $entityId\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}"; };
19651
19665
  var accountSignup = function (_a) {
19652
19666
  var token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode, entityId = _a.entityId;
19653
19667
  return __awaiter(void 0, void 0, void 0, function () {
@@ -19666,7 +19680,7 @@ var accountSignup = function (_a) {
19666
19680
  entityId: entityId,
19667
19681
  };
19668
19682
  return [4 /*yield*/, gqlRequest({
19669
- query: MUTATION$6(),
19683
+ query: MUTATION$5(),
19670
19684
  token: token,
19671
19685
  vars: vars,
19672
19686
  apiHost: apiHost,
@@ -19682,7 +19696,7 @@ var accountSignup = function (_a) {
19682
19696
  });
19683
19697
  };
19684
19698
 
19685
- var MUTATION$5 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $priceListCode: String!,\n $entityId: ID!\n) {\n quoteAccountSignup(\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact,\n entityId: $entityId\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 portalSessionToken\n errors\n }\n}"; };
19699
+ var MUTATION$4 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $priceListCode: String!,\n $entityId: ID!\n) {\n quoteAccountSignup(\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact,\n entityId: $entityId\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 portalSessionToken\n errors\n }\n}"; };
19686
19700
  var quoteAccountSignup = function (_a) {
19687
19701
  var token = _a.token, apiHost = _a.apiHost, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact, entityId = _a.entityId;
19688
19702
  return __awaiter(void 0, void 0, void 0, function () {
@@ -19698,7 +19712,7 @@ var quoteAccountSignup = function (_a) {
19698
19712
  entityId: entityId,
19699
19713
  };
19700
19714
  return [4 /*yield*/, gqlRequest({
19701
- query: MUTATION$5(),
19715
+ query: MUTATION$4(),
19702
19716
  token: token,
19703
19717
  vars: vars,
19704
19718
  apiHost: apiHost,
@@ -19714,7 +19728,7 @@ var quoteAccountSignup = function (_a) {
19714
19728
  });
19715
19729
  };
19716
19730
 
19717
- var MUTATION$4 = 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}"; };
19731
+ var MUTATION$3 = 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}"; };
19718
19732
  var getPriceList = function (_a) {
19719
19733
  var token = _a.token, code = _a.code, apiHost = _a.apiHost;
19720
19734
  return __awaiter(void 0, void 0, void 0, function () {
@@ -19722,7 +19736,7 @@ var getPriceList = function (_a) {
19722
19736
  return __generator(this, function (_b) {
19723
19737
  switch (_b.label) {
19724
19738
  case 0: return [4 /*yield*/, gqlRequest({
19725
- query: MUTATION$4(),
19739
+ query: MUTATION$3(),
19726
19740
  token: token,
19727
19741
  vars: { code: code },
19728
19742
  apiHost: apiHost,
@@ -19737,8 +19751,8 @@ var getPriceList = function (_a) {
19737
19751
 
19738
19752
  function PaymentForms(_a) {
19739
19753
  var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction;
19740
- var apiHost = useContext(BunnyContext).apiHost;
19741
- return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: overrideToken ? (jsx(PaymentForm, { onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, graphQLClient: createGraphQLClient(apiHost, overrideToken), customCheckoutFunction: customCheckoutFunction })) : null })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
19754
+ useContext(BunnyContext).apiHost;
19755
+ return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: overrideToken ? (jsx(PaymentForm, { onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction })) : null })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
19742
19756
  }
19743
19757
  function InitialSignupForm(_a) {
19744
19758
  var onSubmit = _a.onSubmit, submitting = _a.submitting;
@@ -19756,40 +19770,39 @@ function InitialSignupForm(_a) {
19756
19770
  ] }, { children: jsx(Input, { placeholder: "Company name" }) }))] })), jsx(Form.Item, { children: jsx(Button, __assign({ type: "primary", onClick: handleSubmit, loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
19757
19771
  }
19758
19772
 
19759
- var Title = Typography.Title, Text$e = Typography.Text;
19773
+ var Title = Typography.Title, Text$f = Typography.Text;
19760
19774
  function PaymentSuccessDisplay(_a) {
19761
19775
  var amountPaid = _a.amountPaid, className = _a.className, companyName = _a.companyName, returnUrl = _a.returnUrl, style = _a.style, currencyId = _a.currencyId;
19762
- return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsx(CheckCircleFilled, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", formatCurrency(amountPaid, currencyId), " successful"] })), returnUrl && (jsxs(Text$e, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
19776
+ return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsx(CheckCircleFilled, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", formatCurrency(amountPaid, currencyId), " successful"] })), returnUrl && (jsxs(Text$f, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
19763
19777
  }
19764
19778
 
19765
- var Text$d = Typography.Text;
19779
+ var Text$e = Typography.Text;
19766
19780
  function PriceListDisplay(_a) {
19767
19781
  var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
19768
19782
  if (!priceListData)
19769
19783
  return null;
19770
- return (jsx(Fragment, { children: jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsx(Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsx(Text$d, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$d, __assign({ className: "font-bold text-xl" }, { children: [formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), priceListData.trialAllowed ? (jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$d, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsx(Text$d, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))) : null] })) })) }));
19784
+ return (jsx(Fragment, { children: jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsx(Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsx(Text$e, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$e, __assign({ className: "font-bold text-xl" }, { children: [formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), priceListData.trialAllowed ? (jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$e, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsx(Text$e, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))) : null] })) })) }));
19771
19785
  }
19772
19786
 
19773
19787
  var showErrorNotification = useErrorNotification();
19774
19788
  function Signup(_a) {
19775
19789
  var companyName = _a.companyName, 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, entityId = _a.entityId;
19776
19790
  // Hooks
19777
- var _d = useContext(BunnyContext), apiHost = _d.apiHost, graphQLClient = _d.graphQLClient;
19791
+ var apiHost = useContext(BunnyContext).apiHost;
19778
19792
  var tokenFromContexts = useToken();
19779
19793
  var isMobile = useIsMobile();
19780
19794
  var topNavImageUrl = useContext(BrandContext).topNavImageUrl;
19781
- var _e = useState(undefined), quote = _e[0], setQuote = _e[1];
19782
- var _f = useState(undefined), accountId = _f[0], setAccountId = _f[1];
19783
- var _g = useState(undefined), portalSessionToken = _g[0], setPortalSessionToken = _g[1];
19795
+ var _d = useState(undefined), quote = _d[0], setQuote = _d[1];
19796
+ var _e = useState(undefined), accountId = _e[0], setAccountId = _e[1];
19797
+ var _f = useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
19784
19798
  var token = portalSessionToken || tokenFromContexts;
19785
- var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
19786
- var _j = useState(false), purchaseSucceeded = _j[0], setPurchaseSucceeded = _j[1];
19787
- var _k = useState(undefined), paymentMethodGraphQLClient = _k[0], setPaymentMethodGraphQLClient = _k[1];
19788
- var paymentMethod = usePaymentMethod({
19799
+ var _g = useState(false), proceedingToPayment = _g[0], setProceedingToPayment = _g[1];
19800
+ var _h = useState(false), purchaseSucceeded = _h[0], setPurchaseSucceeded = _h[1];
19801
+ var defaultPaymentMethod = usePaymentMethod({
19789
19802
  accountId: accountId,
19790
- graphQLClient: paymentMethodGraphQLClient || graphQLClient,
19791
19803
  token: token,
19792
- }).data;
19804
+ apiHost: apiHost,
19805
+ }).defaultPaymentMethod;
19793
19806
  var queryClient = useQueryClient();
19794
19807
  // Queries
19795
19808
  var priceListData = useQuery({
@@ -19820,11 +19833,11 @@ function Signup(_a) {
19820
19833
  data = _a.sent();
19821
19834
  setAccountId(data.account.id);
19822
19835
  setPortalSessionToken(data.portalSessionToken);
19823
- setPaymentMethodGraphQLClient(createGraphQLClient(apiHost, data.portalSessionToken));
19824
19836
  // We must invalidate the accountPaymentMethodKey query in order to clear payment methods from the provided api token,
19825
19837
  // to instead use paymentMethods from portalSessionToken.
19826
19838
  queryClient.invalidateQueries({
19827
19839
  queryKey: QueryKeyFactory.default.accountPaymentMethodKey({
19840
+ accountId: accountId,
19828
19841
  token: token,
19829
19842
  }),
19830
19843
  });
@@ -19863,14 +19876,14 @@ function Signup(_a) {
19863
19876
  if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
19864
19877
  throw new Error("Plugin ID is required");
19865
19878
  }
19866
- if (!(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id)) {
19879
+ if (!(defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id)) {
19867
19880
  throw new Error("Payment method ID is required");
19868
19881
  }
19869
19882
  return [4 /*yield*/, accountSignup({
19870
19883
  token: portalSessionToken,
19871
19884
  apiHost: apiHost,
19872
19885
  quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
19873
- paymentMethodId: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id,
19886
+ paymentMethodId: defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.id,
19874
19887
  pluginId: plugin === null || plugin === void 0 ? void 0 : plugin.id.toString(),
19875
19888
  priceListCode: priceListCode,
19876
19889
  accountId: accountId,
@@ -19894,18 +19907,20 @@ function Signup(_a) {
19894
19907
  }
19895
19908
 
19896
19909
  var createRequestHeaders = function (token) {
19897
- var bearerToken = "Bearer ".concat(token);
19910
+ var bearerToken = token ? "Bearer ".concat(token) : null;
19898
19911
  var headers = {
19899
19912
  "Content-type": "application/json; charset=utf-8",
19900
19913
  };
19901
- headers["Authorization"] = bearerToken;
19914
+ if (bearerToken) {
19915
+ headers["Authorization"] = bearerToken;
19916
+ }
19902
19917
  return headers;
19903
19918
  };
19904
19919
  var getGraphQLBaseURL = function (apiHost) {
19905
19920
  return "".concat(apiHost, "/graphql");
19906
19921
  };
19907
19922
  var useGraphQLRequest = function () {
19908
- return function (query, token, apiHost, variables) { return __awaiter(void 0, void 0, void 0, function () {
19923
+ return function (query, apiHost, token, variables) { return __awaiter(void 0, void 0, void 0, function () {
19909
19924
  var error_1;
19910
19925
  return __generator(this, function (_a) {
19911
19926
  switch (_a.label) {
@@ -19922,13 +19937,27 @@ var useGraphQLRequest = function () {
19922
19937
  }); };
19923
19938
  };
19924
19939
 
19940
+ var useQuoteSubscriptionUpgrade = function () {
19941
+ var graphQLRequest = useGraphQLRequest();
19942
+ return function (subscriptionId, priceListId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19943
+ var data;
19944
+ return __generator(this, function (_a) {
19945
+ switch (_a.label) {
19946
+ case 0: return [4 /*yield*/, graphQLRequest("\n mutation QuoteSubscriptionUpgrade($subscriptionId: ID!, $priceListId: ID!) {\n quoteSubscriptionUpgrade(\n subscriptionId: $subscriptionId\n priceListId: $priceListId\n ) {\n quote {\n id\n }\n }\n }\n ", apiHost, token, { subscriptionId: subscriptionId, priceListId: priceListId })];
19947
+ case 1:
19948
+ data = _a.sent();
19949
+ return [2 /*return*/, data];
19950
+ }
19951
+ });
19952
+ }); };
19953
+ };
19925
19954
  var useCreateSubscriptionQuote = function () {
19926
19955
  var graphQLRequest = useGraphQLRequest();
19927
- return function (subscriptionIds, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
19956
+ return function (subscriptionIds, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19928
19957
  var data;
19929
19958
  return __generator(this, function (_a) {
19930
19959
  switch (_a.label) {
19931
- case 0: return [4 /*yield*/, graphQLRequest("\n mutation quoteSubscriptionUpdate(\n $subscriptionIds: [ID!]!,\n ) {\n quoteSubscriptionUpdate(\n subscriptionIds: $subscriptionIds,\n ) {\n quote {\n id\n quoteChanges {\n id\n priceList {\n id\n }\n subscription {\n charges {\n startDate\n endDate\n id\n priceListCharge {\n id\n }\n }\n }\n }\n }\n }\n }\n ", token, apiHost, {
19960
+ case 0: return [4 /*yield*/, graphQLRequest("\n mutation quoteSubscriptionUpdate(\n $subscriptionIds: [ID!]!,\n ) {\n quoteSubscriptionUpdate(\n subscriptionIds: $subscriptionIds,\n ) {\n quote {\n id\n quoteChanges {\n id\n priceList {\n id\n }\n subscription {\n charges {\n startDate\n endDate\n id\n priceListCharge {\n id\n }\n }\n }\n }\n }\n }\n }\n ", apiHost, token, {
19932
19961
  subscriptionIds: subscriptionIds,
19933
19962
  })];
19934
19963
  case 1:
@@ -19940,11 +19969,11 @@ var useCreateSubscriptionQuote = function () {
19940
19969
  };
19941
19970
  var useQuoteChangeUpdate = function () {
19942
19971
  var graphQLRequest = useGraphQLRequest();
19943
- return function (charges, quoteChangeId, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
19972
+ return function (charges, quoteChangeId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19944
19973
  var response;
19945
19974
  return __generator(this, function (_a) {
19946
19975
  switch (_a.label) {
19947
- case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteChangeUpdate($charges:[QuoteChargeAttributes!], $id:ID!) {\n quoteChangeUpdate(id:$id, charges:$charges) {\n quoteChange { id quoteId }\n errors\n }\n }", token, apiHost, { charges: charges, id: quoteChangeId })];
19976
+ case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteChangeUpdate($charges:[QuoteChargeAttributes!], $id:ID!) {\n quoteChangeUpdate(id:$id, charges:$charges) {\n quoteChange { id quoteId }\n errors\n }\n }", apiHost, token, { charges: charges, id: quoteChangeId })];
19948
19977
  case 1:
19949
19978
  response = _a.sent();
19950
19979
  return [2 /*return*/, response];
@@ -19954,11 +19983,11 @@ var useQuoteChangeUpdate = function () {
19954
19983
  };
19955
19984
  var useQuoteDelete = function () {
19956
19985
  var graphQLRequest = useGraphQLRequest();
19957
- return function (quoteId, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
19986
+ return function (quoteId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19958
19987
  var response;
19959
19988
  return __generator(this, function (_a) {
19960
19989
  switch (_a.label) {
19961
- case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteDelete($id: ID!) {\n quoteDelete(id: $id) {\n errors\n }\n }", token, apiHost, { id: quoteId })];
19990
+ case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteDelete($id: ID!) {\n quoteDelete(id: $id) {\n errors\n }\n }", apiHost, token, { id: quoteId })];
19962
19991
  case 1:
19963
19992
  response = _a.sent();
19964
19993
  return [2 /*return*/, response];
@@ -19967,7 +19996,7 @@ var useQuoteDelete = function () {
19967
19996
  }); };
19968
19997
  };
19969
19998
 
19970
- var QUOTE_QUERY = function (id) { return "\n query quote {\n quote(id: ".concat(id, ") {\n accountId\n amount\n amountDue\n smallUnitAmountDue\n currencyId\n formattedQuote {\n html\n }\n id\n payableId\n periodAmount\n subtotal\n taxAmount\n amountsByPeriod {\n amount\n startDate\n }\n quoteChanges {\n currencyId\n id\n charges {\n amountsByPeriod {\n amount\n startDate\n }\n amount\n billingPeriod\n currencyId\n feature {\n unitName\n }\n id\n name\n priceListCharge {\n id\n }\n quantity\n }\n priceList {\n id\n plan {\n name\n }\n product {\n name\n }\n }\n\n }\n }\n }"); };
19999
+ var QUOTE_QUERY = function (id) { return "\n query quote {\n quote(id: ".concat(id, ") {\n accountId\n amount\n amountDue\n smallUnitAmountDue\n currencyId\n formattedQuote {\n html\n }\n id\n payableId\n periodAmount\n subtotal\n taxAmount\n amountsByPeriod {\n amount\n startDate\n }\n quoteChanges {\n currencyId\n id\n charges {\n amountsByPeriod {\n amount\n startDate\n }\n amount\n billingPeriod\n currencyId\n feature {\n unitName\n }\n id\n name\n priceListCharge {\n id\n }\n priceList {\n id\n }\n quantity\n }\n priceList {\n id\n plan {\n name\n }\n product {\n name\n }\n }\n\n }\n }\n }"); };
19971
20000
  var getQuote = function (_a) {
19972
20001
  var id = _a.id, token = _a.token, apiHost = _a.apiHost;
19973
20002
  return __awaiter(void 0, void 0, void 0, function () {
@@ -20016,35 +20045,10 @@ var pageWrapperClassName = function (isMobile) {
20016
20045
  };
20017
20046
 
20018
20047
  var QUOTE_FIELDS = "quote {\n formattedQuote {\n html\n }\n acceptedByName\n acceptedByTitle\n accountId\n amount\n amountDue\n applicationDate\n applied\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 invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n ownerId\n periodAmount\n poNumber\n requiresApproval\n startDate\n state\n subtotal\n taxAmount\n updatedAt\n uuid\n amountsByPeriod {\n amount\n id\n name\n }\n endDateOptions {\n endDate\n label\n }\n invoiceUntilOptions {\n endDate\n label\n }\n quoteChanges {\n id\n priceListId\n charges {\n amount\n amountsByPeriod { amount startDate }\n billingPeriod\n billingPeriodAmounts { id amount prorationRate }\n chargeType\n couponId\n createdAt\n currencyId\n discount\n endDate\n feature { id name code isUnit unitName }\n id\n invoiceLineText\n name\n price\n priceDecimals\n priceTiers { starts price }\n pricingModel\n prorationRate\n quantity\n quantityMax\n quantityMin\n startDate\n tieredAveragePrice\n updatedAt\n }\n }\n}";
20019
- var MUTATION$3 = "\nmutation quoteCompose($quoteId: ID, $priceListId: ID, $subscriptionId: ID, $quantity: Int, $accountId: ID) {\n quoteCompose(quoteId: $quoteId, priceListId: $priceListId, subscriptionId: $subscriptionId, quantity: $quantity, accountId: $accountId) {\n ".concat(QUOTE_FIELDS, "\n }\n}\n");
20020
- var quoteCompose = function (_a) {
20021
- var quoteId = _a.quoteId, priceListId = _a.priceListId, subscriptionId = _a.subscriptionId, quantity = _a.quantity, accountId = _a.accountId, token = _a.token, apiHost = _a.apiHost;
20022
- return __awaiter(void 0, void 0, void 0, function () {
20023
- var vars, response, _b, errors, quote;
20024
- return __generator(this, function (_c) {
20025
- switch (_c.label) {
20026
- case 0:
20027
- vars = { quoteId: quoteId, priceListId: priceListId, subscriptionId: subscriptionId, quantity: quantity, accountId: accountId };
20028
- return [4 /*yield*/, gqlRequest({
20029
- query: MUTATION$3,
20030
- token: token,
20031
- vars: vars,
20032
- apiHost: apiHost,
20033
- })];
20034
- case 1:
20035
- response = _c.sent();
20036
- _b = response === null || response === void 0 ? void 0 : response.quoteCompose, errors = _b.errors, quote = _b.quote;
20037
- if (errors)
20038
- throw errors;
20039
- return [2 /*return*/, quote];
20040
- }
20041
- });
20042
- });
20043
- };
20044
20048
 
20045
20049
  var QUOTE_RECALCULATE_TAXES = "\n mutation QuoteRecalculateTaxes($id: ID!) {\n quoteRecalculateTaxes(id: $id) {\n ".concat(QUOTE_FIELDS, "\n errors\n }\n }\n");
20046
20050
  var quoteRecalculateTaxes = function (_a) {
20047
- var quoteId = _a.quoteId, token = _a.token, apiHost = _a.apiHost;
20051
+ var quoteId = _a.quoteId, apiHost = _a.apiHost, token = _a.token;
20048
20052
  return __awaiter(void 0, void 0, void 0, function () {
20049
20053
  var vars, response, errors;
20050
20054
  var _b, _c;
@@ -20071,7 +20075,7 @@ var quoteRecalculateTaxes = function (_a) {
20071
20075
 
20072
20076
  var MUTATION$2 = "{\n currentUser {\n taxationRequiredAccountFields\n }\n}";
20073
20077
  var getTaxationRequiredAccountFields = function (_a) {
20074
- var token = _a.token, apiHost = _a.apiHost;
20078
+ var apiHost = _a.apiHost, token = _a.token;
20075
20079
  return __awaiter(void 0, void 0, void 0, function () {
20076
20080
  var response;
20077
20081
  var _b, _c;
@@ -20102,9 +20106,38 @@ var useHasTaxPlugin = function (_a) {
20102
20106
  return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some(function (plugin) { return plugin.type === "taxation"; }));
20103
20107
  };
20104
20108
 
20105
- var MUTATION$1 = "\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";
20106
- var accountUpdate = function (_a) {
20107
- var accountId = _a.accountId, attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
20109
+ var useCurrentUserData = function () {
20110
+ var queryClient = useQueryClient();
20111
+ var token = useToken();
20112
+ var currentUser = queryClient.getQueryData(QueryKeyFactory.default.currentUserKey(token));
20113
+ if (!currentUser)
20114
+ return {};
20115
+ return currentUser;
20116
+ };
20117
+
20118
+ var BunnyFooterIcon = function (_a) {
20119
+ var color = _a.color;
20120
+ return (jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [jsx("path", { className: "bunny-icon-path", d: "M14.5898 7.19708C14.5898 9.35053 13.0926 10.325 11.2495 10.325C9.39955 10.325 7.90234 9.35001 7.90234 7.18967V3.26221H10.1125V7.00052C10.1125 7.87719 10.5855 8.27725 11.2495 8.27725C11.9061 8.27725 12.3865 7.87719 12.3865 7.00052V3.26221H14.5898V7.19708Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M31.8943 12.9625H29.4793L31.8523 8.62816L28.9355 3.26221H31.4708L33.0457 6.35524L34.5924 3.26221H37.0075L31.8943 12.9625Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M15.1602 5.96827C15.1602 3.8148 16.6574 2.84033 18.5005 2.84033C20.3504 2.84033 21.8476 3.81533 21.8476 5.97568V10.1473H19.6374V6.16483C19.6374 5.28815 19.1645 4.8881 18.5005 4.8881C17.8439 4.8881 17.3634 5.28815 17.3634 6.16483V10.1473H15.1602V5.96827Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M22.4316 5.96827C22.4316 3.8148 23.9289 2.84033 25.7719 2.84033C27.6219 2.84033 29.1191 3.81533 29.1191 5.97568V10.1473H26.9089V6.16483C26.9089 5.28815 26.4359 4.8881 25.7719 4.8881C25.1154 4.8881 24.6349 5.28815 24.6349 6.16483V10.1473H22.4316V5.96827Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M7.40511 6.68957C7.40511 8.7236 6.02815 10.3227 4.17816 10.3227C3.23907 10.3227 2.61071 9.94378 2.19358 9.40371V10.1404H0.0605469V0.0405273H2.26381V3.91939C2.68041 3.42158 3.28802 3.07069 4.17763 3.07069C6.02759 3.07069 7.40511 4.66981 7.40511 6.68957ZM2.17229 6.69642C2.17229 7.60802 2.77937 8.2744 3.64823 8.2744C4.53783 8.2744 5.13107 7.59372 5.13107 6.69642C5.13107 5.79912 4.53783 5.11844 3.64823 5.11844C2.77937 5.11844 2.17229 5.78482 2.17229 6.69642Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M38.966 8.94801C38.966 9.76181 38.2668 10.4631 37.4618 10.4631C36.6499 10.4631 35.9434 9.76181 35.9434 8.94801C35.9434 8.14846 36.6494 7.46094 37.4618 7.46094C38.2668 7.46094 38.966 8.14846 38.966 8.94801Z", fill: color })] })), jsx("defs", { children: jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
20121
+ };
20122
+
20123
+ var Footer = function (_a) {
20124
+ var className = _a.className;
20125
+ var _b = useCurrentUserData(), privacyUrl = _b.privacyUrl, termsUrl = _b.termsUrl;
20126
+ var isMobile = useIsMobile();
20127
+ return (jsxs("div", __assign({ className: "flex items-center justify-between shrink-0 ".concat(isMobile ? "flex-col gap-2 grow" : "", " ").concat(className) }, { children: [(termsUrl || privacyUrl) && (jsxs("div", __assign({ className: "flex items-center gap-3" }, { children: [termsUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: termsUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Terms" }))), privacyUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: privacyUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Privacy" })))] }))), jsx(BunnyMarketingLink, {})] })));
20128
+ };
20129
+ var BunnyMarketingLink = function () {
20130
+ var _a = useState(false), isHovered = _a[0], setIsHovered = _a[1];
20131
+ var isMobile = useIsMobile();
20132
+ return (jsx("div", __assign({ className: "flex items-end justify-end ".concat(isMobile ? "" : "grow") }, { children: jsx(StyledBunnyLink, __assign({ className: "flex items-end justify-end text-slate-400", href: "https://bunny.com/", rel: "noopener noreferrer", target: "_blank" }, { children: jsxs("div", __assign({ className: "flex items-center", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }, { children: ["Powered by\u00A0", jsx("div", __assign({ style: { paddingTop: "5px" } }, { children: jsx(BunnyFooterIcon, { color: isHovered ? PRIMARY_COLOR : SLATE_400 }) }))] })) })) })));
20133
+ };
20134
+ var StyedLink = styled.a(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n font-family: Inter;\n text-decoration: none;\n font-size: 14px;\n"], ["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n font-family: Inter;\n text-decoration: none;\n font-size: 14px;\n"])), SLATE_400, SLATE_500);
20135
+ var StyledBunnyLink = styled(StyedLink)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), PRIMARY_COLOR);
20136
+ var templateObject_1$5, templateObject_2$1;
20137
+
20138
+ var MUTATION$1 = "\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";
20139
+ var accountUpdate = function (_a) {
20140
+ var accountId = _a.accountId, attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
20108
20141
  return __awaiter(void 0, void 0, void 0, function () {
20109
20142
  var vars, response, errors;
20110
20143
  var _b;
@@ -20176,7 +20209,7 @@ var FormBillingState = function (_a) {
20176
20209
 
20177
20210
  var QuoteCheckout = function (_a) {
20178
20211
  var account = _a.account, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, taxationRequiredAccountFields = _a.taxationRequiredAccountFields;
20179
- var _b = useContext(BunnyContext), apiHost = _b.apiHost, graphQLClient = _b.graphQLClient;
20212
+ var _b = useContext(BunnyContext), apiHost = _b.apiHost; _b.graphQLClient;
20180
20213
  var token = useToken();
20181
20214
  var isMobile = useIsMobile();
20182
20215
  var _c = useState(false), isSaving = _c[0], setIsSaving = _c[1];
@@ -20210,7 +20243,7 @@ var QuoteCheckout = function (_a) {
20210
20243
  }
20211
20244
  if (taxationRequiredAccountFields)
20212
20245
  return (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsx(TaxationForm, { account: account, quote: quote }) })));
20213
- return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { onFail: onFail, onPaymentSuccess: onSuccess, quote: quote, graphQLClient: graphQLClient })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "bunny-shadow-padding-x" : "") }, { children: [jsx(Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
20246
+ return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { onFail: onFail, onPaymentSuccess: onSuccess, quote: quote })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "bunny-shadow-padding-x" : "") }, { children: [jsx(Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
20214
20247
  };
20215
20248
  var PaymentFormWrapper = function (_a) {
20216
20249
  var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
@@ -20224,40 +20257,11 @@ var PaymentFormWrapper = function (_a) {
20224
20257
  })) }, { children: children })));
20225
20258
  };
20226
20259
 
20227
- var useCurrentUserData = function () {
20228
- var queryClient = useQueryClient();
20229
- var token = useToken();
20230
- var currentUser = queryClient.getQueryData(QueryKeyFactory.default.currentUserKey(token));
20231
- if (!currentUser)
20232
- return {};
20233
- return currentUser;
20234
- };
20235
-
20236
- var BunnyFooterIcon = function (_a) {
20237
- var color = _a.color;
20238
- return (jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [jsx("path", { className: "bunny-icon-path", d: "M14.5898 7.19708C14.5898 9.35053 13.0926 10.325 11.2495 10.325C9.39955 10.325 7.90234 9.35001 7.90234 7.18967V3.26221H10.1125V7.00052C10.1125 7.87719 10.5855 8.27725 11.2495 8.27725C11.9061 8.27725 12.3865 7.87719 12.3865 7.00052V3.26221H14.5898V7.19708Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M31.8943 12.9625H29.4793L31.8523 8.62816L28.9355 3.26221H31.4708L33.0457 6.35524L34.5924 3.26221H37.0075L31.8943 12.9625Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M15.1602 5.96827C15.1602 3.8148 16.6574 2.84033 18.5005 2.84033C20.3504 2.84033 21.8476 3.81533 21.8476 5.97568V10.1473H19.6374V6.16483C19.6374 5.28815 19.1645 4.8881 18.5005 4.8881C17.8439 4.8881 17.3634 5.28815 17.3634 6.16483V10.1473H15.1602V5.96827Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M22.4316 5.96827C22.4316 3.8148 23.9289 2.84033 25.7719 2.84033C27.6219 2.84033 29.1191 3.81533 29.1191 5.97568V10.1473H26.9089V6.16483C26.9089 5.28815 26.4359 4.8881 25.7719 4.8881C25.1154 4.8881 24.6349 5.28815 24.6349 6.16483V10.1473H22.4316V5.96827Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M7.40511 6.68957C7.40511 8.7236 6.02815 10.3227 4.17816 10.3227C3.23907 10.3227 2.61071 9.94378 2.19358 9.40371V10.1404H0.0605469V0.0405273H2.26381V3.91939C2.68041 3.42158 3.28802 3.07069 4.17763 3.07069C6.02759 3.07069 7.40511 4.66981 7.40511 6.68957ZM2.17229 6.69642C2.17229 7.60802 2.77937 8.2744 3.64823 8.2744C4.53783 8.2744 5.13107 7.59372 5.13107 6.69642C5.13107 5.79912 4.53783 5.11844 3.64823 5.11844C2.77937 5.11844 2.17229 5.78482 2.17229 6.69642Z", fill: color }), jsx("path", { className: "bunny-icon-path", d: "M38.966 8.94801C38.966 9.76181 38.2668 10.4631 37.4618 10.4631C36.6499 10.4631 35.9434 9.76181 35.9434 8.94801C35.9434 8.14846 36.6494 7.46094 37.4618 7.46094C38.2668 7.46094 38.966 8.14846 38.966 8.94801Z", fill: color })] })), jsx("defs", { children: jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
20239
- };
20240
-
20241
- var Footer = function (_a) {
20242
- var className = _a.className;
20243
- var _b = useCurrentUserData(), privacyUrl = _b.privacyUrl, termsUrl = _b.termsUrl;
20244
- var isMobile = useIsMobile();
20245
- return (jsxs("div", __assign({ className: "flex items-center justify-between shrink-0 ".concat(isMobile ? "flex-col gap-2 grow" : "", " ").concat(className) }, { children: [(termsUrl || privacyUrl) && (jsxs("div", __assign({ className: "flex items-center gap-3" }, { children: [termsUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: termsUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Terms" }))), privacyUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: privacyUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Privacy" })))] }))), jsx(BunnyMarketingLink, {})] })));
20246
- };
20247
- var BunnyMarketingLink = function () {
20248
- var _a = useState(false), isHovered = _a[0], setIsHovered = _a[1];
20249
- var isMobile = useIsMobile();
20250
- return (jsx("div", __assign({ className: "flex items-end justify-end ".concat(isMobile ? "" : "grow") }, { children: jsx(StyledBunnyLink, __assign({ className: "flex items-end justify-end text-slate-400", href: "https://bunny.com/", rel: "noopener noreferrer", target: "_blank" }, { children: jsxs("div", __assign({ className: "flex items-center", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }, { children: ["Powered by\u00A0", jsx("div", __assign({ style: { paddingTop: "5px" } }, { children: jsx(BunnyFooterIcon, { color: isHovered ? PRIMARY_COLOR : SLATE_400 }) }))] })) })) })));
20251
- };
20252
- var StyedLink = styled.a(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n font-family: Inter;\n text-decoration: none;\n font-size: 14px;\n"], ["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n font-family: Inter;\n text-decoration: none;\n font-size: 14px;\n"])), SLATE_400, SLATE_500);
20253
- var StyledBunnyLink = styled(StyedLink)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), PRIMARY_COLOR);
20254
- var templateObject_1$5, templateObject_2$1;
20255
-
20256
20260
  var queryKeyFactory = QueryKeyFactory.default;
20257
20261
  var Checkout = function (_a) {
20258
20262
  var _b, _c;
20259
- var 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;
20260
- var _e = useContext(BunnyContext), apiHost = _e.apiHost, graphQLClient = _e.graphQLClient;
20263
+ var onCancel = _a.onCancel, onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, open = _a.open, quote = _a.quote, selectedPriceList = _a.selectedPriceList, token = _a.token;
20264
+ var apiHost = useContext(BunnyContext).apiHost;
20261
20265
  var isMobile = useIsMobile();
20262
20266
  var hasTaxPlugin = useHasTaxPlugin({
20263
20267
  apiHost: apiHost,
@@ -20265,20 +20269,20 @@ var Checkout = function (_a) {
20265
20269
  });
20266
20270
  var queryClient = useQueryClient();
20267
20271
  // Queries
20268
- var _f = useQuery({
20272
+ var _d = useQuery({
20269
20273
  queryKey: ["getTaxationRequiredAccountFields", token],
20270
- queryFn: function () { return getTaxationRequiredAccountFields({ token: token, apiHost: apiHost }); },
20274
+ queryFn: function () { return getTaxationRequiredAccountFields({ apiHost: apiHost, token: token }); },
20271
20275
  enabled: Boolean(quote),
20272
20276
  staleTime: 0,
20273
- }), taxationRequiredAccountFields = _f.data, isLoadingTaxationRequiredAccountFields = _f.isLoading;
20274
- var _g = useQuery({
20277
+ }), taxationRequiredAccountFields = _d.data, isLoadingTaxationRequiredAccountFields = _d.isLoading;
20278
+ var _e = useQuery({
20275
20279
  queryKey: ["account", quote === null || quote === void 0 ? void 0 : quote.accountId],
20276
20280
  queryFn: function () {
20277
- return (quote === null || quote === void 0 ? void 0 : quote.accountId) && getAccount({ id: quote.accountId, token: token, apiHost: apiHost });
20281
+ return (quote === null || quote === void 0 ? void 0 : quote.accountId) && getAccount({ id: quote.accountId, apiHost: apiHost, token: token });
20278
20282
  },
20279
20283
  enabled: Boolean(quote === null || quote === void 0 ? void 0 : quote.accountId) &&
20280
20284
  ((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
20281
- }), account = _g.data, isLoadingAccount = _g.isLoading;
20285
+ }), account = _e.data, isLoadingAccount = _e.isLoading;
20282
20286
  useQuery({
20283
20287
  queryKey: queryKeyFactory.createQuoteTaxCalculateKey({
20284
20288
  id: quote === null || quote === void 0 ? void 0 : quote.id,
@@ -20292,8 +20296,8 @@ var Checkout = function (_a) {
20292
20296
  if (!quote) return [3 /*break*/, 2];
20293
20297
  return [4 /*yield*/, quoteRecalculateTaxes({
20294
20298
  quoteId: quote.id,
20295
- token: token,
20296
20299
  apiHost: apiHost,
20300
+ token: token,
20297
20301
  })];
20298
20302
  case 1:
20299
20303
  updatedQuote = _a.sent();
@@ -20304,7 +20308,7 @@ var Checkout = function (_a) {
20304
20308
  token: token,
20305
20309
  });
20306
20310
  calculatedPricesKey = queryKeyFactory.calculatedPricesKey({
20307
- quantity: quantity,
20311
+ // quantity,
20308
20312
  priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
20309
20313
  token: token,
20310
20314
  });
@@ -20328,11 +20332,11 @@ var Checkout = function (_a) {
20328
20332
  return null;
20329
20333
  return (jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
20330
20334
  zIndex: 1001,
20331
- } }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined, { className: "text-base bunny-shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "bunny-shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (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)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: invoice, graphQLClient: graphQLClient }) }))) : quote ? (jsx(QuoteCheckout, { account: account, onFail: function (error) {
20335
+ } }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined, { className: "text-base bunny-shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "bunny-shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (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)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: invoice }) }))) : quote ? (jsx(QuoteCheckout, { account: account, onFail: function (error) {
20332
20336
  onFail(error);
20333
20337
  }, onSuccess: onSuccess, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsx(PaymentForm, { onFail: function (error) {
20334
20338
  onFail(error);
20335
- }, onPaymentSuccess: onSuccess, graphQLClient: graphQLClient }))] })), jsx(Footer, {})] })) })));
20339
+ }, onPaymentSuccess: onSuccess }))] })), jsx(Footer, {})] })) })));
20336
20340
  };
20337
20341
 
20338
20342
  var PageTitle = function (_a) {
@@ -20351,70 +20355,44 @@ var PageTitle = function (_a) {
20351
20355
 
20352
20356
  var SubscriptionsContext = createContext({});
20353
20357
 
20354
- var calculateNewQuantity = function (priceList, currentQuantity) {
20355
- if (currentQuantity === void 0) { currentQuantity = 1; }
20356
- var priceListRecurringCharge = priceList === null || priceList === void 0 ? void 0 : priceList.charges.find(function (priceListCharge) {
20357
- return priceListCharge.chargeType === "RECURRING" ||
20358
- priceListCharge.chargeType === "USAGE";
20358
+ var QUOTE_CHARGE_UPDATE = "\n mutation QuoteChargeUpdate (\n $discount: Float,\n $endDate: ISO8601Date,\n $name: String,\n $price: Float,\n $quantity: Int,\n $quoteChargeId: ID!\n $startDate: ISO8601Date\n $subtotal: Float,\n ) {\n quoteChargeUpdate(\n discount: $discount\n endDate: $endDate\n name: $name\n price: $price\n quantity: $quantity\n quoteChargeId: $quoteChargeId\n startDate: $startDate\n subtotal: $subtotal\n ) {\n quoteCharge {\n id\n }\n }\n }\n";
20359
+ var quoteChargeUpdate = function (_a) {
20360
+ var discount = _a.discount,
20361
+ // endDate,
20362
+ name = _a.name, price = _a.price, quantity = _a.quantity, quoteChargeId = _a.quoteChargeId, startDate = _a.startDate, subtotal = _a.subtotal, apiHost = _a.apiHost, token = _a.token;
20363
+ return gqlRequest({
20364
+ query: QUOTE_CHARGE_UPDATE,
20365
+ vars: {
20366
+ subtotal: subtotal,
20367
+ discount: discount,
20368
+ // endDate,
20369
+ name: name,
20370
+ price: price,
20371
+ quantity: quantity,
20372
+ quoteChargeId: quoteChargeId,
20373
+ startDate: startDate,
20374
+ },
20375
+ apiHost: apiHost,
20376
+ token: token,
20359
20377
  });
20360
- var quantityMax = (priceListRecurringCharge === null || priceListRecurringCharge === void 0 ? void 0 : priceListRecurringCharge.quantityMax) || Number.POSITIVE_INFINITY;
20361
- var quantityMin = (priceListRecurringCharge === null || priceListRecurringCharge === void 0 ? void 0 : priceListRecurringCharge.quantityMin) || Number.NEGATIVE_INFINITY;
20362
- var selfServiceQuantity = priceListRecurringCharge === null || priceListRecurringCharge === void 0 ? void 0 : priceListRecurringCharge.selfServiceQuantity;
20363
- // If self service quantity is disabled, return the min quantity
20364
- if (!selfServiceQuantity && quantityMin) {
20365
- return quantityMin;
20366
- }
20367
- // If the current quantity is greater than the max quantity, return the max quantity
20368
- else if (currentQuantity > quantityMax) {
20369
- return quantityMax;
20370
- }
20371
- // If the current quantity is less than the min quantity, return the min quantity
20372
- else if (currentQuantity < quantityMin) {
20373
- return quantityMin;
20374
- }
20375
- // If the current quantity is between the min and max quantity, return the current quantity
20376
- else if (currentQuantity <= quantityMax && currentQuantity >= quantityMin) {
20377
- return currentQuantity;
20378
- }
20379
- // If all else fails, return 1
20380
- else {
20381
- return 1;
20382
- }
20383
20378
  };
20384
20379
 
20385
20380
  var CheckoutBarInput = function (_a) {
20386
- var charge = _a.charge, quantity = _a.quantity, selectedPriceList = _a.selectedPriceList, setQuantity = _a.setQuantity;
20381
+ var disabled = _a.disabled, charge = _a.charge, quantity = _a.quantity, selectedPriceList = _a.selectedPriceList, onQuantityChanged = _a.onQuantityChanged;
20382
+ // State
20387
20383
  var _b = useState(false), isTooltipOpen = _b[0], setIsTooltipOpen = _b[1];
20388
- // Context
20389
- var _c = useContext(SubscriptionsContext), setQuotePreviewData = _c.setQuotePreviewData, quotePreviewData = _c.quotePreviewData;
20384
+ var _c = useState(0), quantityLocal = _c[0], setQuantityLocal = _c[1];
20390
20385
  // Hooks
20391
20386
  var isMobile = useIsMobile();
20392
- // Handlers
20393
- var onChangeQuantity = function (quantity) {
20394
- if (quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList) {
20395
- setQuotePreviewData({
20396
- priceList: quotePreviewData.priceList,
20397
- quantity: calculateNewQuantity(quotePreviewData.priceList, quantity),
20398
- });
20399
- }
20400
- else {
20401
- console.error("No price list found in quote preview data");
20402
- }
20403
- };
20404
- var onBlurUsers = function (e) {
20405
- var amount = Number(e.target.value);
20406
- if (!amount) {
20407
- onChangeQuantity(1);
20408
- }
20409
- };
20410
- // Quantity debounce
20411
- // eslint-disable-next-line
20412
20387
  var quoteChangeDebounce = useCallback(lodashExports.debounce(function (newQuantity) { return __awaiter(void 0, void 0, void 0, function () {
20413
20388
  return __generator(this, function (_a) {
20414
- onChangeQuantity(newQuantity);
20389
+ onQuantityChanged(newQuantity);
20415
20390
  return [2 /*return*/];
20416
20391
  });
20417
20392
  }); }, 1000), []);
20393
+ useEffect(function () {
20394
+ setQuantityLocal(quantity);
20395
+ }, [quantity]);
20418
20396
  useEffect(function () {
20419
20397
  setTimeout(function () {
20420
20398
  setIsTooltipOpen(true);
@@ -20430,11 +20408,11 @@ var CheckoutBarInput = function (_a) {
20430
20408
  paddingTop: "0.75rem",
20431
20409
  paddingBottom: "0.75rem",
20432
20410
  },
20433
- } }, { children: jsx(Input, { className: isMobile ? "text-right" : "", disabled: !selectedPriceList || !charge.selfServiceQuantity, onBlur: onBlurUsers, onChange: function (e) {
20411
+ } }, { children: jsx(Input, { className: isMobile ? "text-right" : "", disabled: disabled || !selectedPriceList || !charge.selfServiceQuantity, onChange: function (e) {
20434
20412
  var quantity = Number(e.target.value);
20435
- setQuantity(quantity);
20413
+ setQuantityLocal(quantity);
20436
20414
  quoteChangeDebounce(quantity);
20437
- }, min: charge === null || charge === void 0 ? void 0 : charge.quantityMin, max: charge === null || charge === void 0 ? void 0 : charge.quantityMax, style: { minWidth: "120px" }, type: "number", value: quantity, required: true }) }))] })));
20415
+ }, min: charge === null || charge === void 0 ? void 0 : charge.quantityMin, max: charge === null || charge === void 0 ? void 0 : charge.quantityMax, style: { minWidth: "120px" }, type: "number", value: quantityLocal, required: true }) }))] })));
20438
20416
  };
20439
20417
  var QuantityLabel = function (_a) {
20440
20418
  var _b;
@@ -20554,7 +20532,7 @@ var CheckoutPrice = function (_a) {
20554
20532
 
20555
20533
  var CheckoutBarSummarySection = function (_a) {
20556
20534
  var _b;
20557
- var open = _a.open, quantityLocal = _a.quantityLocal, quote = _a.quote, selectedPriceList = _a.selectedPriceList, onClickCheckout = _a.onClickCheckout, upgradingSubscription = _a.upgradingSubscription, quotePreviewData = _a.quotePreviewData;
20535
+ var open = _a.open, quote = _a.quote, selectedPriceList = _a.selectedPriceList, onClickCheckout = _a.onClickCheckout, upgradingSubscription = _a.upgradingSubscription, quotePreviewData = _a.quotePreviewData;
20558
20536
  // Context
20559
20537
  var apiHost = useContext(BunnyContext).apiHost;
20560
20538
  // Hooks
@@ -20574,7 +20552,7 @@ var CheckoutBarSummarySection = function (_a) {
20574
20552
  });
20575
20553
  var checkoutButtonDisabled = Boolean(!(quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) ||
20576
20554
  !selectedPriceList ||
20577
- quantityLocal !== quotePreviewData.quantity ||
20555
+ // quantityLocal !== quotePreviewData.quantity ||
20578
20556
  isFetching ||
20579
20557
  selectedPriceList.id === (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) ||
20580
20558
  open);
@@ -20595,82 +20573,90 @@ var PlanPickerCheckoutBarWrapper = function (_a) {
20595
20573
  return (jsx(PlanPickerCheckoutBar, { handlePortalErrors: handlePortalErrors, selectedPriceList: selectedPriceList, onCheckoutSuccess: onCheckoutSuccess }));
20596
20574
  };
20597
20575
  var PlanPickerCheckoutBar = function (_a) {
20598
- var _b;
20599
20576
  var selectedPriceList = _a.selectedPriceList, handlePortalErrors = _a.handlePortalErrors, onCheckoutSuccess = _a.onCheckoutSuccess;
20600
20577
  // Context
20601
20578
  var token = useToken();
20602
- var _c = useContext(SubscriptionsContext), quotePreviewData = _c.quotePreviewData, upgradingSubscription = _c.upgradingSubscription, shadow = _c.shadow;
20603
- var _d = useContext(BunnyContext), apiHost = _d.apiHost, graphQLClient = _d.graphQLClient;
20579
+ var _b = useContext(SubscriptionsContext), quotePreviewData = _b.quotePreviewData, upgradingSubscription = _b.upgradingSubscription, shadow = _b.shadow;
20580
+ var apiHost = useContext(BunnyContext).apiHost;
20604
20581
  // Local state
20605
- var _e = useState(0), quantityLocal = _e[0], setQuantity = _e[1];
20606
- var _f = useState(0), prevQuantity = _f[0], setPrevQuantity = _f[1];
20607
- var _g = useState(false), payModalVisible = _g[0], setPayModalVisible = _g[1];
20582
+ var _c = useState(false), payModalVisible = _c[0], setPayModalVisible = _c[1];
20583
+ var quoteIdRef = useRef();
20608
20584
  // Hooks
20609
20585
  var showSuccessNotification = useSuccessNotification();
20610
20586
  var queryClient = useQueryClient();
20611
20587
  var isMobile = useIsMobile();
20612
- var storedPaymentMethod = usePaymentMethod({
20613
- graphQLClient: graphQLClient,
20588
+ var defaultPaymentMethod = usePaymentMethod({
20614
20589
  token: token,
20615
- }).data;
20616
- // Quote ID ref
20617
- var quoteIdRef = useRef();
20590
+ apiHost: apiHost,
20591
+ }).defaultPaymentMethod;
20592
+ var createSubscriptionQuote = useQuoteSubscriptionUpgrade();
20593
+ // Mutations
20594
+ var createQuote = useMutation({
20595
+ mutationFn: function (_a) {
20596
+ var subscriptionId = _a.subscriptionId, priceListId = _a.priceListId;
20597
+ return createSubscriptionQuote(subscriptionId, priceListId, apiHost, token);
20598
+ },
20599
+ onSuccess: function (subscriptionUpdateData) {
20600
+ var _a;
20601
+ var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpgrade) === null || _a === void 0 ? void 0 : _a.quote;
20602
+ quoteIdRef.current = quote.id;
20603
+ },
20604
+ });
20605
+ var updateCharge = useMutation({
20606
+ mutationFn: quoteChargeUpdate,
20607
+ onSuccess: function () {
20608
+ queryClient.invalidateQueries({
20609
+ queryKey: QueryKeyFactory.default.createQuoteKey({
20610
+ id: quoteIdRef.current || "",
20611
+ token: token,
20612
+ }),
20613
+ });
20614
+ },
20615
+ }).mutate;
20618
20616
  // Queries
20619
- var _h = useQuery({
20620
- queryKey: QueryKeyFactory.default.calculatedPricesKey({
20621
- quantity: (quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) || 0,
20622
- priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
20617
+ var quote = useQuery({
20618
+ queryKey: QueryKeyFactory.default.createQuoteKey({
20619
+ id: quoteIdRef.current || "",
20623
20620
  token: token,
20624
20621
  }),
20625
20622
  queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
20626
20623
  var quote;
20627
- var _a;
20628
- return __generator(this, function (_b) {
20629
- switch (_b.label) {
20630
- case 0: return [4 /*yield*/, quoteCompose({
20631
- priceListId: (_a = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList) === null || _a === void 0 ? void 0 : _a.id,
20632
- quantity: quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity,
20633
- quoteId: quoteIdRef.current,
20634
- subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
20624
+ return __generator(this, function (_a) {
20625
+ switch (_a.label) {
20626
+ case 0: return [4 /*yield*/, getQuote({
20627
+ id: quoteIdRef.current || "",
20635
20628
  token: token,
20636
20629
  apiHost: apiHost,
20637
20630
  })];
20638
20631
  case 1:
20639
- quote = _b.sent();
20640
- quoteIdRef.current = quote === null || quote === void 0 ? void 0 : quote.id;
20632
+ quote = _a.sent();
20641
20633
  return [2 /*return*/, quote];
20642
20634
  }
20643
20635
  });
20644
20636
  }); },
20645
- // 'enabled' is commented out for HACKY FIX
20646
- // enabled: Boolean(
20647
- // quotePreviewData?.priceList?.id &&
20648
- // selectedPriceList &&
20649
- // selectedPriceList.id !== upgradingSubscription?.priceList.id
20650
- // ),
20651
- enabled: false,
20652
- placeholderData: keepPreviousData,
20653
- }), quote = _h.data, refetch = _h.refetch;
20654
- // TODO: eventually solve this hacky fix
20655
- // THIS IS NOT OKAY (we couldn't find any other solution on short notice)
20656
- // HACKY FIX START
20657
- // Essentially this useEffect is doing the work useQuery is supposed to do, but isn't doing properly.
20637
+ }).data;
20658
20638
  useEffect(function () {
20659
- var _a;
20660
- if (((_a = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList) === null || _a === void 0 ? void 0 : _a.id) &&
20661
- selectedPriceList &&
20662
- selectedPriceList.id !== (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id)) {
20663
- refetch();
20639
+ if (!(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id)) {
20640
+ console.error("upgradingSubscription is undefined");
20641
+ return;
20664
20642
  }
20665
- }, [
20666
- (_b = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList) === null || _b === void 0 ? void 0 : _b.id,
20667
- quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity,
20668
- refetch,
20669
- selectedPriceList,
20670
- selectedPriceList.id,
20671
- upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id,
20672
- ]);
20673
- // HACKY FIX END
20643
+ createQuote.mutate({
20644
+ subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
20645
+ priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
20646
+ });
20647
+ }, [selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id, upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id]);
20648
+ // Reset query key on unmount
20649
+ useEffect(function () {
20650
+ return function () {
20651
+ queryClient.invalidateQueries({
20652
+ queryKey: QueryKeyFactory.default.calculatedPricesKey({
20653
+ priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
20654
+ quantity: (quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) || 0,
20655
+ token: token,
20656
+ }),
20657
+ });
20658
+ };
20659
+ }, [queryClient, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id, quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity, token]);
20674
20660
  var handleCheckoutSuccess = function () {
20675
20661
  queryClient.invalidateQueries({
20676
20662
  queryKey: QueryKeyFactory.default.createTableKey({
@@ -20688,39 +20674,45 @@ var PlanPickerCheckoutBar = function (_a) {
20688
20674
  var onCheckoutFail = function (error) {
20689
20675
  handlePortalErrors(error);
20690
20676
  };
20691
- // Set quantity from quote preview data
20692
- useEffect(function () {
20693
- if ((quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) &&
20694
- prevQuantity !== quotePreviewData.quantity) {
20695
- setQuantity(quotePreviewData.quantity);
20696
- setPrevQuantity(quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity);
20677
+ function onChangeQuantity(chargeId, quantity) {
20678
+ var quoteChange = quote === null || quote === void 0 ? void 0 : quote.quoteChanges.find(function (qc) { return qc.priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id); });
20679
+ var quoteCharge = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) {
20680
+ var _a;
20681
+ return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceListCharge) === null || _a === void 0 ? void 0 : _a.id) === chargeId;
20682
+ });
20683
+ if (!token) {
20684
+ console.error("token is undefined");
20685
+ return;
20697
20686
  }
20698
- }, [
20699
- prevQuantity,
20700
- quantityLocal,
20701
- quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity,
20702
- setPrevQuantity,
20703
- setQuantity,
20704
- ]);
20705
- // Reset query key on unmount
20706
- useEffect(function () {
20707
- return function () {
20708
- queryClient.invalidateQueries({
20709
- queryKey: QueryKeyFactory.default.calculatedPricesKey({
20710
- priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
20711
- quantity: (quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) || 0,
20712
- token: token,
20713
- }),
20714
- });
20715
- };
20716
- }, [queryClient, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id, quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity, token]);
20687
+ if (!quoteCharge) {
20688
+ console.error("quoteCharge not found");
20689
+ return;
20690
+ }
20691
+ updateCharge({
20692
+ quoteChargeId: quoteCharge.id,
20693
+ quantity: quantity,
20694
+ apiHost: apiHost,
20695
+ token: token,
20696
+ });
20697
+ }
20717
20698
  return (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-4" : "flex-row", " my-2 p-4 justify-between bg-white rounded-md ").concat(shadow ? "shadow-".concat(shadow) : "") }, { children: [jsx("div", __assign({ className: "".concat(isMobile ? "flex flex-col" : "flex", " gap-4") }, { children: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.charges.map(function (charge, index) {
20718
- return (jsx(CheckoutBarInput, { charge: charge, quantity: quantityLocal || 0, selectedPriceList: selectedPriceList, setQuantity: setQuantity }, index));
20719
- }) })), jsx(CheckoutBarSummarySection, { onClickCheckout: function () { return setPayModalVisible(true); }, open: payModalVisible, quantityLocal: quantityLocal, quote: quote, selectedPriceList: selectedPriceList, upgradingSubscription: upgradingSubscription, quotePreviewData: quotePreviewData }), jsx(Checkout, { isMobile: isMobile, onCancel: function () { return setPayModalVisible(false); }, onFail: onCheckoutFail, onSuccess: handleCheckoutSuccess, open: payModalVisible, quantity: quantityLocal, quote: quote, selectedPriceList: selectedPriceList, storedPaymentMethod: storedPaymentMethod, token: token })] })));
20699
+ var _a;
20700
+ var quoteChange = quote === null || quote === void 0 ? void 0 : quote.quoteChanges.find(function (qc) { return qc.priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id); });
20701
+ var chargeQuantity = (_a = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) { var _a; return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceList) === null || _a === void 0 ? void 0 : _a.id) === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id); })) === null || _a === void 0 ? void 0 : _a.quantity;
20702
+ if (charge.chargeType === ChargeType.USAGE)
20703
+ return null;
20704
+ if (!quote)
20705
+ return null;
20706
+ if (!chargeQuantity)
20707
+ return null;
20708
+ return (jsx(CheckoutBarInput, { disabled: !chargeQuantity, charge: charge, quantity: chargeQuantity !== null && chargeQuantity !== void 0 ? chargeQuantity : 0, selectedPriceList: selectedPriceList, onQuantityChanged: function (quantity) {
20709
+ onChangeQuantity(charge.id, quantity);
20710
+ } }, index));
20711
+ }) })), jsx(CheckoutBarSummarySection, { onClickCheckout: function () { return setPayModalVisible(true); }, open: payModalVisible, quote: quote, selectedPriceList: selectedPriceList, upgradingSubscription: upgradingSubscription, quotePreviewData: quotePreviewData }), jsx(Checkout, { isMobile: isMobile, onCancel: function () { return setPayModalVisible(false); }, onFail: onCheckoutFail, onSuccess: handleCheckoutSuccess, open: payModalVisible, quote: quote, selectedPriceList: selectedPriceList, storedPaymentMethod: defaultPaymentMethod, token: token })] })));
20720
20712
  };
20721
20713
 
20722
20714
  // WARNING: There is a preview button on APP that will need to be changed if this query is changed
20723
- var PRICE_LIST_CHANGE_OPTIONS_QUERY = "\n query priceListChangeOptions($subscriptionId: ID, $productId: ID) {\n priceListChangeOptions(subscriptionId: $subscriptionId, productId: $productId) {\n products {\n everythingInPlus\n id\n name\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n priceLists {\n basePrice\n id\n currencyId\n periodMonths\n plan {\n code\n contactUsLabel\n contactUsUrl\n description\n id\n name\n position\n pricingDescription\n pricingStyle\n planFeatures {\n featureId\n value\n feature {\n name\n }\n }\n }\n product {\n id\n }\n charges {\n basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
20715
+ var PRICE_LIST_CHANGE_OPTIONS_QUERY = "\n query priceListChangeOptions($subscriptionId: ID, $productId: ID) {\n priceListChangeOptions(subscriptionId: $subscriptionId, productId: $productId) {\n products {\n everythingInPlus\n id\n name\n plansToDisplay\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n priceLists {\n basePrice\n id\n currencyId\n periodMonths\n plan {\n code\n contactUsLabel\n contactUsUrl\n description\n id\n name\n position\n pricingDescription\n pricingStyle\n planFeatures {\n featureId\n value\n feature {\n name\n }\n }\n }\n product {\n id\n }\n charges {\n basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
20724
20716
  var getPriceListChangeOptions = function (_a) {
20725
20717
  var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription;
20726
20718
  return __awaiter(void 0, void 0, void 0, function () {
@@ -20754,6 +20746,37 @@ var ErrorView = function (_a) {
20754
20746
  return (jsxs("div", __assign({ className: "flex flex-col w-full", style: { marginTop: "80px" } }, { children: [jsx("div", __assign({ style: { fontSize: "32px" } }, { children: message })), children] })));
20755
20747
  };
20756
20748
 
20749
+ var calculateNewQuantity = function (priceList, currentQuantity) {
20750
+ if (currentQuantity === void 0) { currentQuantity = 1; }
20751
+ var priceListRecurringCharge = priceList === null || priceList === void 0 ? void 0 : priceList.charges.find(function (priceListCharge) {
20752
+ return priceListCharge.chargeType === "RECURRING" ||
20753
+ priceListCharge.chargeType === "USAGE";
20754
+ });
20755
+ var quantityMax = (priceListRecurringCharge === null || priceListRecurringCharge === void 0 ? void 0 : priceListRecurringCharge.quantityMax) || Number.POSITIVE_INFINITY;
20756
+ var quantityMin = (priceListRecurringCharge === null || priceListRecurringCharge === void 0 ? void 0 : priceListRecurringCharge.quantityMin) || Number.NEGATIVE_INFINITY;
20757
+ var selfServiceQuantity = priceListRecurringCharge === null || priceListRecurringCharge === void 0 ? void 0 : priceListRecurringCharge.selfServiceQuantity;
20758
+ // If self service quantity is disabled, return the min quantity
20759
+ if (!selfServiceQuantity && quantityMin) {
20760
+ return quantityMin;
20761
+ }
20762
+ // If the current quantity is greater than the max quantity, return the max quantity
20763
+ else if (currentQuantity > quantityMax) {
20764
+ return quantityMax;
20765
+ }
20766
+ // If the current quantity is less than the min quantity, return the min quantity
20767
+ else if (currentQuantity < quantityMin) {
20768
+ return quantityMin;
20769
+ }
20770
+ // If the current quantity is between the min and max quantity, return the current quantity
20771
+ else if (currentQuantity <= quantityMax && currentQuantity >= quantityMin) {
20772
+ return currentQuantity;
20773
+ }
20774
+ // If all else fails, return 1
20775
+ else {
20776
+ return 1;
20777
+ }
20778
+ };
20779
+
20757
20780
  var BillingPeriodSelector = function (_a) {
20758
20781
  var availableBillingPeriods = _a.availableBillingPeriods, onChangeBillingPeriod = _a.onChangeBillingPeriod, products = _a.products, selectedBillingPeriod = _a.selectedBillingPeriod, selectedProduct = _a.selectedProduct, onChangeProduct = _a.onChangeProduct;
20759
20782
  var _b = useContext(BrandContext), secondaryColor = _b.secondaryColor, brandColor = _b.brandColor;
@@ -20802,22 +20825,22 @@ var PriceListCardPrice = function (_a) {
20802
20825
  : "Free" })));
20803
20826
  };
20804
20827
 
20805
- var Text$c = Typography.Text;
20828
+ var Text$d = Typography.Text;
20806
20829
  var PriceListCardDescription = function (_a) {
20807
20830
  var description = _a.description;
20808
20831
  if (!description)
20809
20832
  return null;
20810
- return jsx(Text$c, __assign({ className: "text-center" }, { children: description }));
20833
+ return jsx(Text$d, __assign({ className: "text-center" }, { children: description }));
20811
20834
  };
20812
20835
 
20813
- var Text$b = Typography.Text;
20836
+ var Text$c = Typography.Text;
20814
20837
  var PriceListCardPriceDescription = function (_a) {
20815
20838
  var feature = _a.feature, priceList = _a.priceList;
20816
20839
  var isMobile = useIsMobile();
20817
20840
  var doesPlanHaveFlatFeeCharges = priceList.charges.some(function (charge) { return charge.pricingModel === PricingModel.FLAT && charge.basePrice > 0; });
20818
20841
  if (priceList.periodMonths <= 0 || priceList.plan.pricingStyle !== PricingStyle.PRICED)
20819
20842
  return null;
20820
- return (jsx(Text$b, __assign({ className: "text-center text-gray-900", style: {
20843
+ return (jsx(Text$c, __assign({ className: "text-center text-gray-900", style: {
20821
20844
  fontSize: isMobile ? "13px" : "12px",
20822
20845
  } }, { children: priceList.plan.pricingDescription
20823
20846
  ? priceList.plan.pricingDescription
@@ -20890,7 +20913,6 @@ var PriceListCardDesktop = function (_a) {
20890
20913
  }
20891
20914
  }, style: {
20892
20915
  height: "100%",
20893
- maxWidth: "440px",
20894
20916
  } }, { children: [jsxs("div", __assign({ className: "flex flex-col items-center gap-3" }, { children: [jsxs("div", __assign({ className: "flex flex-col items-center gap-2" }, { children: [jsx(PriceListCardTitle, { isPriceListCurrentSubscription: isPriceListCurrentSubscription, priceList: priceList, trialRemainingDays: trialRemainingDays }), jsx(PriceListCardDescription, { description: description })] })), jsxs("div", __assign({ className: "flex flex-col items-center gap-2" }, { children: [jsx(PriceListCardPrice, { priceList: priceList }), jsx(PriceListCardPriceDescription, { feature: feature, priceList: priceList })] }))] })), jsx(PriceListCardButton, { disableOnClick: disableOnClick, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, priceList: priceList, subscriptionPlan: subscriptionPlan })] })) }));
20895
20917
  };
20896
20918
 
@@ -20924,18 +20946,18 @@ var PriceListCard = function (_a) {
20924
20946
  return isMobile ? (jsx(PriceListCardMobile, { description: description, disableOnClick: disableOnClick, feature: feature, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, onClick: onClick, priceList: priceList, trialRemainingDays: trialRemainingDays, subscriptionPlan: subscriptionPlan })) : (jsx(PriceListCardDesktop, { description: description, disableOnClick: disableOnClick, feature: feature, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, onClick: onClick, priceList: priceList, trialRemainingDays: trialRemainingDays, subscriptionPlan: subscriptionPlan }));
20925
20947
  };
20926
20948
 
20927
- var Text$a = Typography.Text;
20949
+ var Text$b = Typography.Text;
20928
20950
  var PriceListCardFeature = function (_a) {
20929
20951
  var index = _a.index, planFeature = _a.planFeature;
20930
20952
  var brandColor = useContext(BrandContext).brandColor;
20931
20953
  if (planFeature.feature.kind === "GROUP")
20932
- return jsx(Text$a, __assign({ className: "font-medium base-text" }, { children: planFeature.name }));
20933
- return (jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CheckIcon, { backgroundColor: brandColor, size: "15px" }), jsx(Text$a, __assign({ className: "text-gray-600" }, { children: planFeature.feature.name }))] }), index));
20954
+ return jsx(Text$b, __assign({ className: "font-medium base-text" }, { children: planFeature.name }));
20955
+ return (jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CheckIcon, { backgroundColor: brandColor, size: "15px" }), jsx(Text$b, __assign({ className: "text-gray-600" }, { children: planFeature.feature.name }))] }), index));
20934
20956
  };
20935
20957
 
20936
20958
  var getAvailablePlansAndPriceLists = function (_a) {
20937
- var availablePriceLists = _a.availablePriceLists, priceListChangeOptions = _a.priceListChangeOptions, priceListStart = _a.priceListStart;
20938
- var displayPriceLists = availablePriceLists.slice(priceListStart, priceListStart + 3);
20959
+ var availablePriceLists = _a.availablePriceLists, priceListChangeOptions = _a.priceListChangeOptions, priceListStart = _a.priceListStart, plansToDisplay = _a.plansToDisplay;
20960
+ var displayPriceLists = availablePriceLists.slice(priceListStart, priceListStart + plansToDisplay);
20939
20961
  var availablePlansArray = displayPriceLists === null || displayPriceLists === void 0 ? void 0 : displayPriceLists.map(function (displayPriceList) {
20940
20962
  var _a;
20941
20963
  var foundPriceList = (_a = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _a === void 0 ? void 0 : _a.find(function (priceList) { return priceList.plan.id === displayPriceList.plan.id; });
@@ -20965,6 +20987,67 @@ var PriceListGridMobile = function (_a) {
20965
20987
  : "Features" })), jsx("div", __assign({ className: "flex flex-col gap-4 overflow-auto shadow-padding-x" }, { children: (_e = (_d = selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.plan) === null || _d === void 0 ? void 0 : _d.planFeatures) === null || _e === void 0 ? void 0 : _e.map(function (planFeature, index) { return (jsx(PriceListCardFeature, { planFeature: planFeature, index: index }, index)); }) }))] }));
20966
20988
  };
20967
20989
 
20990
+ var NextPriceListButton = function (_a) {
20991
+ var availablePriceLists = _a.availablePriceLists, priceListStart = _a.priceListStart, setPriceListStart = _a.setPriceListStart, numberOfPlansToDisplay = _a.numberOfPlansToDisplay;
20992
+ return (jsxs("div", __assign({ className: "absolute flex gap-1", style: { top: "12px", right: "8px", zIndex: 10 } }, { children: [priceListStart > 0 && (jsx("div", __assign({ className: "flex items-center justify-center rounded-full shadow p-1 cursor-pointer", onClick: function () {
20993
+ setPriceListStart(function (prev) {
20994
+ var newValue = prev - 1;
20995
+ if (newValue < 0) {
20996
+ return prev;
20997
+ }
20998
+ return newValue;
20999
+ });
21000
+ }, style: { width: "22px", height: "22px" } }, { children: jsx(FontAwesomeIcon, { icon: faChevronLeft }) }))), priceListStart < availablePriceLists.length - numberOfPlansToDisplay && (jsx("div", __assign({ className: "flex items-center justify-center rounded-full shadow p-1 cursor-pointer", onClick: function () {
21001
+ return setPriceListStart(function (prev) {
21002
+ var newValue = prev + 1;
21003
+ if (newValue >= availablePriceLists.length) {
21004
+ return prev;
21005
+ }
21006
+ return newValue;
21007
+ });
21008
+ }, style: { width: "22px", height: "22px" } }, { children: jsx(FontAwesomeIcon, { icon: faChevronRight }) })))] })));
21009
+ };
21010
+
21011
+ var filterUniqueFeatures = function (_a) {
21012
+ // Remove any features that in previous plans if everythingInPlus is true
21013
+ var availablePriceLists = _a.availablePriceLists;
21014
+ var uniqueFeatures = new Set();
21015
+ var updatedPriceLists = availablePriceLists.map(function (priceList) {
21016
+ var _a;
21017
+ var updatedPlanFeatures = (_a = priceList.plan.planFeatures) === null || _a === void 0 ? void 0 : _a.filter(function (feature) {
21018
+ if (uniqueFeatures.has(feature.featureId)) {
21019
+ return false;
21020
+ }
21021
+ else {
21022
+ uniqueFeatures.add(feature.featureId);
21023
+ return true;
21024
+ }
21025
+ });
21026
+ return __assign(__assign({}, priceList), { plan: __assign(__assign({}, priceList.plan), { planFeatures: updatedPlanFeatures }) });
21027
+ });
21028
+ return updatedPriceLists;
21029
+ };
21030
+ var EverythingPlanFeatures = function (_a) {
21031
+ var availablePriceLists = _a.availablePriceLists, selectedProduct = _a.selectedProduct, plansToDisplay = _a.plansToDisplay;
21032
+ var brandColor = useContext(BrandContext).brandColor;
21033
+ var uniquePlanFeatures = filterUniqueFeatures({ availablePriceLists: availablePriceLists });
21034
+ return (jsx(Fragment, { children: __spreadArray([], Array(plansToDisplay), true).map(function (_, planIndex) {
21035
+ var priceList = uniquePlanFeatures[planIndex];
21036
+ var prevPriceList = availablePriceLists[planIndex - 1];
21037
+ if (!priceList)
21038
+ return (jsx("div", { style: prevPriceList ? { borderLeft: "1px solid ".concat(SLATE_200) } : {} }, planIndex));
21039
+ if (!priceList.plan.planFeatures)
21040
+ return jsx("div", {}, planIndex);
21041
+ return (jsx("div", __assign({ className: "flex flex-col gap-4 p-4", style: { borderLeft: "1px solid ".concat(SLATE_200) } }, { children: priceList.plan.planFeatures.map(function (planFeature, planFeatureIndex) {
21042
+ var everythingInPlus = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus;
21043
+ return (jsxs("div", __assign({ className: "contents" }, { children: [prevPriceList &&
21044
+ everythingInPlus &&
21045
+ planIndex > 0 &&
21046
+ planFeatureIndex === 0 && (jsx("div", __assign({ className: "font-medium", style: { fontSize: "13px" } }, { children: everythingInPlusString({ priceList: prevPriceList }) }))), jsxs("div", __assign({ className: "flex gap-1 text-gray-600", style: { fontSize: "13px" } }, { children: [jsx(CheckIcon, { backgroundColor: brandColor, size: "15px" }), planFeature.feature.name] }))] }), planFeatureIndex));
21047
+ }) }), planIndex));
21048
+ }) }));
21049
+ };
21050
+
20968
21051
  var shouldColorRow = function (_a) {
20969
21052
  var isFeatureGroup = _a.isFeatureGroup, rowIndex = _a.rowIndex;
20970
21053
  return !isFeatureGroup && rowIndex % 2 === 1;
@@ -20979,12 +21062,10 @@ var FeatureGridCell = function (_a) {
20979
21062
  : {})) }, { children: children })));
20980
21063
  };
20981
21064
 
20982
- var PLANS_TO_DISPLAY$1 = 3;
20983
-
20984
- var Text$9 = Typography.Text;
21065
+ var Text$a = Typography.Text;
20985
21066
  var PlanFeatures = function (_a) {
20986
21067
  var _b;
20987
- var availablePlansArray = _a.availablePlansArray, selectedProduct = _a.selectedProduct;
21068
+ var availablePlansArray = _a.availablePlansArray, selectedProduct = _a.selectedProduct, plansToDisplay = _a.plansToDisplay;
20988
21069
  var featureGroupCounter = useRef(0);
20989
21070
  var visibleFeatureCounter = useRef(1);
20990
21071
  var brandColor = useContext(BrandContext).brandColor;
@@ -21009,7 +21090,7 @@ var PlanFeatures = function (_a) {
21009
21090
  rowIndex = rowIndex + featureGroupCounter.current;
21010
21091
  // Increment the visible feature counter
21011
21092
  visibleFeatureCounter.current = visibleFeatureCounter.current + 1;
21012
- return (jsxs("div", __assign({ className: "contents" }, { children: [jsx(FeatureGridCell, __assign({ isFeatureGroup: isFeatureGroup, noBorder: true, rowIndex: rowIndex }, { children: jsx(FeatureTitle, { isFeatureGroup: isFeatureGroup, feature: feature }) })), __spreadArray([], Array(PLANS_TO_DISPLAY$1), true).map(function (_, columnIndex) {
21093
+ return (jsxs("div", __assign({ className: "contents" }, { children: [jsx(FeatureGridCell, __assign({ isFeatureGroup: isFeatureGroup, noBorder: true, rowIndex: rowIndex }, { children: jsx(FeatureTitle, { isFeatureGroup: isFeatureGroup, feature: feature }) })), __spreadArray([], Array(plansToDisplay), true).map(function (_, columnIndex) {
21013
21094
  var _a;
21014
21095
  var plan = availablePlansArray[columnIndex];
21015
21096
  var doesHavePrevPlan = availablePlansArray[columnIndex - 1];
@@ -21019,76 +21100,17 @@ var PlanFeatures = function (_a) {
21019
21100
  if (!plan)
21020
21101
  return (jsx(FeatureGridCell, { rowIndex: rowIndex, noBorder: !Boolean(doesHavePrevPlan) }, columnIndex));
21021
21102
  if (isFeatureGroup)
21022
- return jsx(FeatureGridCell, { isFeatureGroup: true, rowIndex: rowIndex }, columnIndex);
21023
- return (jsx(FeatureGridCell, __assign({ rowIndex: rowIndex }, { children: jsx("div", __assign({ className: "flex justify-center text-center" }, { children: planFeature ? ((planFeature === null || planFeature === void 0 ? void 0 : planFeature.value) ? (planFeature.value) : (jsx(CheckIcon, { backgroundColor: brandColor, size: "15px" }))) : (jsx(Text$9, __assign({ className: "text-gray" }, { children: "-" }))) })) }), columnIndex));
21103
+ return (jsx(FeatureGridCell, { isFeatureGroup: true, rowIndex: rowIndex }, columnIndex));
21104
+ return (jsx(FeatureGridCell, __assign({ rowIndex: rowIndex }, { children: jsx("div", __assign({ className: "flex justify-center text-center" }, { children: planFeature ? ((planFeature === null || planFeature === void 0 ? void 0 : planFeature.value) ? (planFeature.value) : (jsx(CheckIcon, { backgroundColor: brandColor, size: "15px" }))) : (jsx(Text$a, __assign({ className: "text-gray" }, { children: "-" }))) })) }), columnIndex));
21024
21105
  })] }), rowIndex));
21025
21106
  }) }));
21026
21107
  };
21027
21108
  var FeatureTitle = function (_a) {
21028
21109
  var _b;
21029
21110
  var isFeatureGroup = _a.isFeatureGroup, feature = _a.feature;
21030
- return (jsx(Text$9, __assign({ className: " ".concat(isFeatureGroup ? "text-slate-500 font-medium pt-4" : ""), style: __assign({}, (isFeatureGroup ? { fontSize: "11px" } : {})) }, { children: isFeatureGroup ? (_b = feature === null || feature === void 0 ? void 0 : feature.name) === null || _b === void 0 ? void 0 : _b.toUpperCase() : feature === null || feature === void 0 ? void 0 : feature.name })));
21031
- };
21032
-
21033
- var NextPriceListButton = function (_a) {
21034
- var availablePriceLists = _a.availablePriceLists, priceListStart = _a.priceListStart, setPriceListStart = _a.setPriceListStart;
21035
- return (jsxs("div", __assign({ className: "absolute flex gap-1", style: { top: "12px", right: "8px", zIndex: 10 } }, { children: [priceListStart > 0 && (jsx("div", __assign({ className: "flex items-center justify-center rounded-full shadow p-1 cursor-pointer", onClick: function () {
21036
- setPriceListStart(function (prev) {
21037
- var newValue = prev - 1;
21038
- if (newValue < 0) {
21039
- return prev;
21040
- }
21041
- return newValue;
21042
- });
21043
- }, style: { width: "22px", height: "22px" } }, { children: jsx(FontAwesomeIcon, { icon: faChevronLeft }) }))), priceListStart < availablePriceLists.length - 3 && (jsx("div", __assign({ className: "flex items-center justify-center rounded-full shadow p-1 cursor-pointer", onClick: function () {
21044
- return setPriceListStart(function (prev) {
21045
- var newValue = prev + 1;
21046
- if (newValue >= availablePriceLists.length) {
21047
- return prev;
21048
- }
21049
- return newValue;
21050
- });
21051
- }, style: { width: "22px", height: "22px" } }, { children: jsx(FontAwesomeIcon, { icon: faChevronRight }) })))] })));
21052
- };
21053
-
21054
- var filterUniqueFeatures = function (_a) {
21055
- // Remove any features that in previous plans if everythingInPlus is true
21056
- var availablePriceLists = _a.availablePriceLists;
21057
- var uniqueFeatures = new Set();
21058
- var updatedPriceLists = availablePriceLists.map(function (priceList) {
21059
- var _a;
21060
- var updatedPlanFeatures = (_a = priceList.plan.planFeatures) === null || _a === void 0 ? void 0 : _a.filter(function (feature) {
21061
- if (uniqueFeatures.has(feature.featureId)) {
21062
- return false;
21063
- }
21064
- else {
21065
- uniqueFeatures.add(feature.featureId);
21066
- return true;
21067
- }
21068
- });
21069
- return __assign(__assign({}, priceList), { plan: __assign(__assign({}, priceList.plan), { planFeatures: updatedPlanFeatures }) });
21070
- });
21071
- return updatedPriceLists;
21072
- };
21073
- var EverythingPlanFeatures = function (_a) {
21074
- var availablePriceLists = _a.availablePriceLists, selectedProduct = _a.selectedProduct;
21075
- var brandColor = useContext(BrandContext).brandColor;
21076
- var uniquePlanFeatures = filterUniqueFeatures({ availablePriceLists: availablePriceLists });
21077
- return (jsx(Fragment, { children: __spreadArray([], Array(PLANS_TO_DISPLAY), true).map(function (_, planIndex) {
21078
- var priceList = uniquePlanFeatures[planIndex];
21079
- var prevPriceList = availablePriceLists[planIndex - 1];
21080
- if (!priceList)
21081
- return (jsx("div", { style: prevPriceList ? { borderLeft: "1px solid ".concat(SLATE_200) } : {} }, planIndex));
21082
- if (!priceList.plan.planFeatures)
21083
- return jsx("div", {}, planIndex);
21084
- return (jsx("div", __assign({ className: "flex flex-col gap-4 p-4", style: { borderLeft: "1px solid ".concat(SLATE_200) } }, { children: priceList.plan.planFeatures.map(function (planFeature, planFeatureIndex) {
21085
- var everythingInPlus = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus;
21086
- return (jsxs("div", __assign({ className: "contents" }, { children: [prevPriceList && everythingInPlus && planIndex > 0 && planFeatureIndex === 0 && (jsx("div", __assign({ className: "font-medium", style: { fontSize: "13px" } }, { children: everythingInPlusString({ priceList: prevPriceList }) }))), jsxs("div", __assign({ className: "flex gap-1 text-gray-600", style: { fontSize: "13px" } }, { children: [jsx(CheckIcon, { backgroundColor: brandColor, size: "15px" }), planFeature.feature.name] }))] }), planFeatureIndex));
21087
- }) }), planIndex));
21088
- }) }));
21111
+ return (jsx(Text$a, __assign({ className: " ".concat(isFeatureGroup ? "text-slate-500 font-medium pt-4" : ""), style: __assign({}, (isFeatureGroup ? { fontSize: "11px" } : {})) }, { children: isFeatureGroup ? (_b = feature === null || feature === void 0 ? void 0 : feature.name) === null || _b === void 0 ? void 0 : _b.toUpperCase() : feature === null || feature === void 0 ? void 0 : feature.name })));
21089
21112
  };
21090
21113
 
21091
- var PLANS_TO_DISPLAY = 3;
21092
21114
  var PriceListGridDesktop = function (_a) {
21093
21115
  var availablePriceLists = _a.availablePriceLists, onChangePriceList = _a.onChangePriceList, priceListChangeOptions = _a.priceListChangeOptions, priceListStart = _a.priceListStart, selectedPriceList = _a.selectedPriceList, selectedProduct = _a.selectedProduct, setPriceListStart = _a.setPriceListStart, subscriptions = _a.subscriptions, trialRemainingDays = _a.trialRemainingDays;
21094
21116
  var _b = useMemo(function () {
@@ -21096,20 +21118,22 @@ var PriceListGridDesktop = function (_a) {
21096
21118
  availablePriceLists: availablePriceLists,
21097
21119
  priceListChangeOptions: priceListChangeOptions,
21098
21120
  priceListStart: priceListStart,
21121
+ plansToDisplay: (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3,
21099
21122
  });
21100
21123
  }, [availablePriceLists, priceListChangeOptions, priceListStart]), availablePlansArray = _b.availablePlansArray, displayPriceLists = _b.displayPriceLists;
21101
21124
  var everythingInPlus = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus;
21102
- return (jsxs("div", __assign({ className: "relative flex flex-col rounded-md shadow overflow-hidden bg-white" }, { children: [jsx(NextPriceListButton, { availablePriceLists: availablePriceLists, priceListStart: priceListStart, setPriceListStart: setPriceListStart }), jsxs("div", __assign({ className: "grid w-full", style: {
21125
+ var plansToDisplay = Math.min((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3, availablePriceLists.length);
21126
+ return (jsxs("div", __assign({ className: "relative flex flex-col rounded-md shadow overflow-hidden bg-white" }, { children: [jsx(NextPriceListButton, { availablePriceLists: availablePriceLists, numberOfPlansToDisplay: plansToDisplay, priceListStart: priceListStart, setPriceListStart: setPriceListStart }), jsxs("div", __assign({ className: "grid w-full", style: {
21103
21127
  gridTemplateColumns: everythingInPlus
21104
- ? "repeat(3, minmax(120px, 1fr))"
21105
- : "minmax(auto, 400px) repeat(3, minmax(120px, 1fr))",
21106
- } }, { children: [!everythingInPlus && jsx(PlanPickerGridCell, { noBorder: true }), __spreadArray([], Array(PLANS_TO_DISPLAY), true).map(function (_, index) {
21128
+ ? "repeat(".concat(plansToDisplay, ", minmax(120px, 1fr))")
21129
+ : "minmax(auto, 400px) repeat(".concat(plansToDisplay, ", minmax(120px, 1fr))"),
21130
+ } }, { children: [!everythingInPlus && jsx(PlanPickerGridCell, { noBorder: true }), __spreadArray([], Array(plansToDisplay), true).map(function (_, index) {
21107
21131
  var priceList = displayPriceLists[index];
21108
21132
  var doesPrevPriceListExist = displayPriceLists[index - 1];
21109
21133
  if (!priceList)
21110
21134
  return (jsx(PlanPickerGridCell, { noBorder: !Boolean(doesPrevPriceListExist) }, index));
21111
21135
  return (jsx(PriceListCard, { isSelected: priceList.plan.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.plan.id), onClick: onChangePriceList, priceList: priceList, subscriptions: subscriptions, trialRemainingDays: trialRemainingDays }, index));
21112
- }), (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus) ? (jsx(EverythingPlanFeatures, { availablePriceLists: availablePriceLists, selectedProduct: selectedProduct })) : (jsx(PlanFeatures, { availablePlansArray: availablePlansArray, selectedProduct: selectedProduct }))] }))] })));
21136
+ }), (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus) ? (jsx(EverythingPlanFeatures, { availablePriceLists: availablePriceLists, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct })) : (jsx(PlanFeatures, { availablePlansArray: availablePlansArray, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct }))] }))] })));
21113
21137
  };
21114
21138
 
21115
21139
  var PriceListGrid = function (_a) {
@@ -21255,7 +21279,6 @@ var PlanPicker = function () {
21255
21279
  var apiHost = useContext(BunnyContext).apiHost;
21256
21280
  var _b = useContext(SubscriptionsContext), isInPreviewMode = _b.isInPreviewMode, productId = _b.productId, quotePreviewData = _b.quotePreviewData, setQuotePreviewData = _b.setQuotePreviewData, upgradingSubscription = _b.upgradingSubscription;
21257
21281
  // Hooks
21258
- var queryClient = useQueryClient();
21259
21282
  var showInfoNotification = useInfoNotification();
21260
21283
  // Queries
21261
21284
  var _c = useQuery({
@@ -21296,55 +21319,48 @@ var PlanPicker = function () {
21296
21319
  setQuotePreviewData({});
21297
21320
  };
21298
21321
  }, [setQuotePreviewData]);
21299
- if (queryClient.isFetching({
21300
- queryKey: QueryKeyFactory.default.planChangeOptionsKey({
21301
- subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
21302
- token: token,
21303
- }),
21304
- }))
21305
- return jsx(Fragment, {});
21306
- else if (((_a = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _a === void 0 ? void 0 : _a.length) === 0)
21322
+ if (((_a = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _a === void 0 ? void 0 : _a.length) === 0)
21307
21323
  return jsx(ErrorView, { message: "There are no plans available" });
21308
21324
  return (jsx(PriceListSelector, { arePlanChangeOptionsLoading: arePlanChangeOptionsLoading, areSubscriptionsLoading: areSubscriptionsLoading, onChangePriceList: onChangePriceList, priceListChangeOptions: priceListChangeOptions, selectedPriceList: quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList, subscriptions: subscriptions }));
21309
21325
  };
21310
21326
 
21311
- var Text$8 = Typography.Text;
21327
+ var Text$9 = Typography.Text;
21312
21328
  var PreviewModeAdvisary = function (_a) {
21313
21329
  var isInPreviewMode = _a.isInPreviewMode;
21314
21330
  if (!isInPreviewMode)
21315
21331
  return null;
21316
- return (jsx("div", __assign({ className: "flex justify-center w-full rounded" }, { children: jsx(Text$8, { children: "You are in preview mode. Products, plans and price lists are shown regardless of visibility settings." }) })));
21332
+ return (jsx("div", __assign({ className: "flex justify-center w-full rounded" }, { children: jsx(Text$9, { children: "You are in preview mode. Products, plans and price lists are shown regardless of visibility settings." }) })));
21317
21333
  };
21318
21334
 
21319
21335
  var PlanManager = function (_a) {
21320
21336
  var onChangePlanCancel = _a.onChangePlanCancel, handlePortalErrors = _a.handlePortalErrors;
21321
21337
  // Context
21322
21338
  var token = useToken();
21323
- var _b = useContext(BunnyContext), apiHost = _b.apiHost, graphQLClient = _b.graphQLClient;
21324
- var _c = useContext(SubscriptionsContext), isInPreviewMode = _c.isInPreviewMode, upgradingSubscription = _c.upgradingSubscription, setUpgradingSubscription = _c.setUpgradingSubscription, subscriptionUpgradeId = _c.subscriptionUpgradeId, setQuotePreviewData = _c.setQuotePreviewData, quotePreviewData = _c.quotePreviewData, className = _c.className;
21339
+ var apiHost = useContext(BunnyContext).apiHost;
21340
+ var _b = useContext(SubscriptionsContext), isInPreviewMode = _b.isInPreviewMode, upgradingSubscription = _b.upgradingSubscription, setUpgradingSubscription = _b.setUpgradingSubscription, subscriptionUpgradeId = _b.subscriptionUpgradeId, setQuotePreviewData = _b.setQuotePreviewData, quotePreviewData = _b.quotePreviewData, className = _b.className;
21325
21341
  // Local state
21326
- var _d = useState(), editingQuoteData = _d[0], setEditingQuoteData = _d[1];
21327
- var _e = useState(false), payModalVisible = _e[0], setPayModalVisible = _e[1];
21328
- var _f = useState(false), isSticky = _f[0], setIsSticky = _f[1];
21342
+ var _c = useState(), editingQuoteData = _c[0], setEditingQuoteData = _c[1];
21343
+ var _d = useState(false), payModalVisible = _d[0], setPayModalVisible = _d[1];
21344
+ var _e = useState(false), isSticky = _e[0], setIsSticky = _e[1];
21329
21345
  var stickyRef = useRef(null);
21330
21346
  // Hooks
21331
21347
  var queryClient = useQueryClient();
21332
21348
  var showSuccessNotification = useSuccessNotification();
21333
21349
  var showInfoNotification = useInfoNotification();
21334
21350
  var isMobile = useIsMobile();
21335
- var storedPaymentMethod = usePaymentMethod({
21336
- graphQLClient: graphQLClient,
21351
+ var defaultPaymentMethod = usePaymentMethod({
21337
21352
  token: token,
21338
- }).data;
21353
+ apiHost: apiHost,
21354
+ }).defaultPaymentMethod;
21339
21355
  // Queries
21340
- var _g = useQuery({
21356
+ var _f = useQuery({
21341
21357
  queryKey: QueryKeyFactory.default.createTableKey({
21342
21358
  pluralType: "subscriptions",
21343
21359
  token: token,
21344
21360
  }),
21345
21361
  queryFn: function () { return getSubscriptions({ isInPreviewMode: isInPreviewMode, token: token, apiHost: apiHost }); },
21346
21362
  enabled: false,
21347
- }), subscriptions = _g.data, subscriptionsAreLoading = _g.isLoading;
21363
+ }), subscriptions = _f.data, subscriptionsAreLoading = _f.isLoading;
21348
21364
  var quote = useQuery({
21349
21365
  queryKey: QueryKeyFactory.default.createObjectKey({
21350
21366
  id: editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.id,
@@ -21418,17 +21434,17 @@ var PlanManager = function (_a) {
21418
21434
  return showInfoNotification("You are in preview mode");
21419
21435
  setQuotePreviewData(undefined);
21420
21436
  onChangePlanCancel();
21421
- }, title: "Change plan" }), jsx(PlanPicker, {}), jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile, storedPaymentMethod: storedPaymentMethod, selectedPriceList: quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList, quantity: quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity }), jsx("div", { ref: stickyRef }), jsx("div", __assign({ className: "sticky bottom-4 transition-[margin] duration-300 ".concat(isSticky ? "mx-4" : "mx-0") }, { children: jsx(PlanPickerCheckoutBarWrapper, { handlePortalErrors: handlePortalErrors, onCheckoutSuccess: function () { return onChangePlanCancel(); } }) }))] })));
21437
+ }, title: "Change plan" }), jsx(PlanPicker, {}), jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile, storedPaymentMethod: defaultPaymentMethod, selectedPriceList: quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList }), jsx("div", { ref: stickyRef }), jsx("div", __assign({ className: "sticky bottom-4 transition-[margin] duration-300 ".concat(isSticky ? "mx-4" : "mx-0") }, { children: jsx(PlanPickerCheckoutBarWrapper, { handlePortalErrors: handlePortalErrors, onCheckoutSuccess: function () { return onChangePlanCancel(); } }) }))] })));
21422
21438
  };
21423
21439
 
21424
21440
  var useCancelSubscription = function () {
21425
21441
  var graphQLRequest = useGraphQLRequest();
21426
- return function (subscriptionIds, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
21442
+ return function (subscriptionIds, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
21427
21443
  var data;
21428
21444
  var _a;
21429
21445
  return __generator(this, function (_b) {
21430
21446
  switch (_b.label) {
21431
- case 0: return [4 /*yield*/, graphQLRequest("\n mutation SubscriptionCancel($subscriptionIds: [ID!]!) {\n subscriptionCancel(ids: $subscriptionIds) {\n subscriptions {\n accountId\n state\n }\n }\n }", token, apiHost, { subscriptionIds: subscriptionIds })];
21447
+ case 0: return [4 /*yield*/, graphQLRequest("\n mutation SubscriptionCancel($subscriptionIds: [ID!]!) {\n subscriptionCancel(ids: $subscriptionIds) {\n subscriptions {\n accountId\n state\n }\n }\n }", apiHost, token, { subscriptionIds: subscriptionIds })];
21432
21448
  case 1:
21433
21449
  data = _b.sent();
21434
21450
  return [2 /*return*/, (_a = data === null || data === void 0 ? void 0 : data.subscriptions) === null || _a === void 0 ? void 0 : _a.nodes];
@@ -21628,7 +21644,7 @@ var SubscriptionCardActions = function (_a) {
21628
21644
  canShowSubscriptionActions(subscription) ? (jsxs(Fragment, { children: [canShowCancelButton && (jsx(Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsx(Button, __assign({ className: "p-0", type: "link" }, { children: "Cancel subscription" })) }))), canShowChangePlanButton && (jsx(Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: "primary" }, { children: "Change plan" })))] })) : ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState$2.TRIAL ? (jsx(Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: "primary" }, { children: "Upgrade" }))) : null;
21629
21645
  };
21630
21646
 
21631
- var Text$7 = Typography.Text;
21647
+ var Text$8 = Typography.Text;
21632
21648
  var getSubscriptionStatusText = function (subscription) {
21633
21649
  var cancellationDate = subscription.cancellationDate, state = subscription.state, evergreen = subscription.evergreen, endDate = subscription.endDate;
21634
21650
  if (cancellationDate &&
@@ -21657,7 +21673,7 @@ var SubscriptionCardHeader = function (_a) {
21657
21673
  var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
21658
21674
  return (jsxs("div", __assign({ className: "flex items-center justify-between", style: {
21659
21675
  backgroundColor: darkMode ? "var(--row-background-dark)" : "",
21660
- } }, { children: [jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsx(Text$7, __assign({ style: __assign({ fontSize: "11px", fontWeight: 500, color: brandColor }, subscriptionProductNameStyle) }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), jsxs("div", __assign({ className: "flex grow items-center gap-2" }, { children: [((_e = subscription === null || subscription === void 0 ? void 0 : subscription.plan) === null || _e === void 0 ? void 0 : _e.name) && jsx(Text$7, __assign({ className: "text-lg" }, { children: subscription.plan.name })), jsxs(CustomizedTag, __assign({ color: TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()] }, { children: [lodashExports.capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft, " days left)") : ""] }))] }))] })), jsxs("div", __assign({ className: "flex items-center gap-6" }, { children: [jsx(Text$7, __assign({ className: "grow text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile && priceListChangeOptions && onChangePlanClick && onCancelSubscriptionClick && (jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscription: subscription }))] }))] })));
21676
+ } }, { children: [jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsx(Text$8, __assign({ style: __assign({ fontSize: "11px", fontWeight: 500, color: brandColor }, subscriptionProductNameStyle) }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), jsxs("div", __assign({ className: "flex grow items-center gap-2" }, { children: [((_e = subscription === null || subscription === void 0 ? void 0 : subscription.plan) === null || _e === void 0 ? void 0 : _e.name) && jsx(Text$8, __assign({ className: "text-lg" }, { children: subscription.plan.name })), jsxs(CustomizedTag, __assign({ color: TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()] }, { children: [lodashExports.capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft, " days left)") : ""] }))] }))] })), jsxs("div", __assign({ className: "flex items-center gap-6" }, { children: [jsx(Text$8, __assign({ className: "grow text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile && priceListChangeOptions && onChangePlanClick && onCancelSubscriptionClick && (jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscription: subscription }))] }))] })));
21661
21677
  };
21662
21678
 
21663
21679
  var BillingPeriodConverter;
@@ -21682,7 +21698,7 @@ var SubscriptionChargeTotal = function (_a) {
21682
21698
  : "".concat(formattedPeriodPrice, " ").concat(billingPeriod) })));
21683
21699
  };
21684
21700
 
21685
- var Text$6 = Typography.Text;
21701
+ var Text$7 = Typography.Text;
21686
21702
  var SubscriptionChargeUnitPrice = function (_a) {
21687
21703
  var charge = _a.charge, subscription = _a.subscription;
21688
21704
  var darkMode = useContext(BunnyContext).darkMode;
@@ -21705,23 +21721,23 @@ var SubscriptionChargeUnitPrice = function (_a) {
21705
21721
  }) })) })));
21706
21722
  }, onOpenChange: setShowPriceTiers, open: showPriceTiers, trigger: ["click"] }, { children: jsx("div", __assign({ className: "cursor-pointer underline", onClick: function () { return setShowPriceTiers(!showPriceTiers); } }, { children: showPriceTiers ? "Hide tiers" : "Show tiers" })) })));
21707
21723
  else if (charge.chargeType === ChargeType.USAGE || charge.trial)
21708
- return jsx(Text$6, { children: "-" });
21724
+ return jsx(Text$7, { children: "-" });
21709
21725
  else if (isDiscount)
21710
21726
  return (jsxs(Fragment, { children: ["-", formatCurrency(charge.discountedPrice, subscription.currencyId)] }));
21711
21727
  else
21712
21728
  return (jsx(Fragment, { children: formatCurrency(charge.discountedPrice, subscription.currencyId) }));
21713
21729
  };
21714
21730
 
21715
- var Text$5 = Typography.Text;
21731
+ var Text$6 = Typography.Text;
21716
21732
  var SubscriptionCardColumnHeaders = function (_a) {
21717
21733
  var columns = _a.columns;
21718
- return (jsx(Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsx(Text$5, __assign({ className: "text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: "11px" } }, { children: subscriptionColumn.title }), index)); }) }));
21734
+ return (jsx(Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsx(Text$6, __assign({ className: "text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: "11px" } }, { children: subscriptionColumn.title }), index)); }) }));
21719
21735
  };
21720
21736
 
21721
- var Text$4 = Typography.Text;
21737
+ var Text$5 = Typography.Text;
21722
21738
  var SubscriptionsListCell = function (_a) {
21723
21739
  var children = _a.children, className = _a.className, gridColumn = _a.gridColumn, right = _a.right, style = _a.style;
21724
- return (jsx(Text$4, __assign({ className: "flex items-center text-sm whitespace-nowrap ".concat(className), style: __assign({ gridColumn: gridColumn, textAlign: right ? "right" : "left", justifyContent: right ? "flex-end" : "flex-start" }, style) }, { children: children })));
21740
+ return (jsx(Text$5, __assign({ className: "flex items-center text-sm whitespace-nowrap ".concat(className), style: __assign({ gridColumn: gridColumn, textAlign: right ? "right" : "left", justifyContent: right ? "flex-end" : "flex-start" }, style) }, { children: children })));
21725
21741
  };
21726
21742
 
21727
21743
  var CARD_COLUMNS = [
@@ -21809,10 +21825,10 @@ var SubscriptionCardDesktopRow = function (_a) {
21809
21825
  : (_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString() })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsx(SubscriptionChargeUnitPrice, { charge: charge, subscription: subscription }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
21810
21826
  };
21811
21827
 
21812
- var Text$3 = Typography.Text;
21828
+ var Text$4 = Typography.Text;
21813
21829
  var SubscriptionCardCellMobile = function (_a) {
21814
21830
  var children = _a.children, className = _a.className, style = _a.style;
21815
- return (jsx(Text$3, __assign({ className: className, style: style }, { children: children })));
21831
+ return (jsx(Text$4, __assign({ className: className, style: style }, { children: children })));
21816
21832
  };
21817
21833
 
21818
21834
  var CHARGE_COLUMNS = [
@@ -21885,7 +21901,7 @@ var SubscriptionsListContainer = function (_a) {
21885
21901
  // Queries
21886
21902
  var _c = useQuery({
21887
21903
  queryKey: QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
21888
- queryFn: function () { return getPriceListChangeOptions({ token: token, apiHost: apiHost }); },
21904
+ queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
21889
21905
  enabled: Boolean(onChangePlanClick),
21890
21906
  }), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
21891
21907
  if (subscriptionsAreLoading ||
@@ -21894,13 +21910,21 @@ var SubscriptionsListContainer = function (_a) {
21894
21910
  return (jsx(Fragment, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsx("div", __assign({ className: "flex flex-col gap-".concat(gap, " shrink overflow-auto") }, { children: jsx(SubscriptionsList, { hideExpired: hideExpired, onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions }) }))) : (noSubscriptionsComponent || (jsx("div", __assign({ className: "flex flex-col items-center w-full" }, { children: jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) })))) }));
21895
21911
  };
21896
21912
 
21913
+ var Text$3 = Typography.Text;
21914
+ var DrawerHeader = function (_a) {
21915
+ var description = _a.description, onClose = _a.onClose, title = _a.title, closeButtonClassName = _a.closeButtonClassName;
21916
+ return (jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsx(Text$3, __assign({ className: "text-xl", style: { fontWeight: 400 } }, { children: title })), onClose ? (jsx("button", __assign({ id: "closePayment", onClick: onClose, className: closeButtonClassName }, { children: jsx(CloseOutlined, {}) }))) : null] })), description && jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
21917
+ };
21918
+
21897
21919
  var QUOTE_CHARGE_CREATE = "\nmutation QuoteChargeCreate ($quoteChangeId: ID!, $startDate: ISO8601Date!, $endDate: ISO8601Date, $priceListChargeId: ID, $subscriptionChargeId: ID, $price: Float, $quantity: Int) {\n quoteChargeCreate(\n endDate: $endDate\n price: $price\n priceListChargeId: $priceListChargeId\n quantity: $quantity\n quoteChangeId: $quoteChangeId\n startDate: $startDate\n subscriptionChargeId: $subscriptionChargeId\n ) {\n quoteCharge {\n quoteChange {\n id\n quoteId\n }\n }\n }\n}\n\n";
21898
21920
  var quoteChargeCreate = function (_a) {
21899
- var endDate = _a.endDate, price = _a.price, priceListChargeId = _a.priceListChargeId, quantity = _a.quantity, quoteChangeId = _a.quoteChangeId, startDate = _a.startDate, subscriptionChargeId = _a.subscriptionChargeId, token = _a.token, apiHost = _a.apiHost;
21921
+ var
21922
+ // endDate,
21923
+ price = _a.price, priceListChargeId = _a.priceListChargeId, quantity = _a.quantity, quoteChangeId = _a.quoteChangeId, startDate = _a.startDate, subscriptionChargeId = _a.subscriptionChargeId, token = _a.token, apiHost = _a.apiHost;
21900
21924
  return gqlRequest({
21901
21925
  query: QUOTE_CHARGE_CREATE,
21902
21926
  vars: {
21903
- endDate: endDate,
21927
+ // endDate,
21904
21928
  price: price,
21905
21929
  priceListChargeId: priceListChargeId,
21906
21930
  quantity: quantity,
@@ -21933,14 +21957,17 @@ var QuantityInput = function (_a) {
21933
21957
  (updatingChargeQuantityId && updatingChargeQuantityId !== charge.id) ||
21934
21958
  // If the subscription is not self-service, we disable the quantity input
21935
21959
  !charge.selfServiceQuantity;
21936
- var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? "" : editedSubscription.quantity;
21960
+ var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined
21961
+ ? ""
21962
+ : editedSubscription.quantity;
21937
21963
  // Mutations
21938
21964
  var createCharge = useMutation({
21939
21965
  mutationFn: quoteChargeCreate,
21940
21966
  onSuccess: function (response) {
21941
21967
  var _a, _b, _c, _d, _e, _f, _g, _h;
21942
21968
  if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
21943
- var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
21969
+ var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
21970
+ SubscriptionState$2.TRIAL;
21944
21971
  setEditingQuoteData({
21945
21972
  id: (_e = (_d = (_c = response.quoteChargeCreate) === null || _c === void 0 ? void 0 : _c.quoteCharge) === null || _d === void 0 ? void 0 : _d.quoteChange) === null || _e === void 0 ? void 0 : _e.quoteId,
21946
21973
  isTrial: isTrial,
@@ -21957,17 +21984,19 @@ var QuantityInput = function (_a) {
21957
21984
  }).mutate;
21958
21985
  var createQuote = useMutation({
21959
21986
  mutationFn: function (subscriptionIds) {
21960
- return createSubscriptionQuote(subscriptionIds, token, apiHost);
21987
+ return createSubscriptionQuote(subscriptionIds, apiHost, token);
21961
21988
  },
21962
21989
  onSuccess: function (subscriptionUpdateData) {
21963
21990
  var _a, _b;
21964
21991
  var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
21965
- var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
21992
+ var quoteChange = quote.quoteChanges.find(function (quoteChange) {
21993
+ return quoteChange.priceList.id ===
21994
+ (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id);
21995
+ });
21966
21996
  var subscriptionCharge = (_b = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.subscription) === null || _b === void 0 ? void 0 : _b.charges.find(function (charge) { var _a; return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceListCharge) === null || _a === void 0 ? void 0 : _a.id) === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.chargeId); });
21967
21997
  if (subscriptionCharge && quoteChange && editedSubscription) {
21968
21998
  createCharge({
21969
21999
  apiHost: apiHost,
21970
- endDate: subscriptionCharge.endDate,
21971
22000
  quantity: editedSubscription.quantity,
21972
22001
  quoteChangeId: quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.id,
21973
22002
  startDate: subscriptionCharge.startDate,
@@ -21980,12 +22009,13 @@ var QuantityInput = function (_a) {
21980
22009
  var updateQuote = useMutation({
21981
22010
  mutationFn: function (_a) {
21982
22011
  var charges = _a.charges, quoteChangeId = _a.quoteChangeId;
21983
- return quoteChangeUpdate(charges, quoteChangeId, token, apiHost);
22012
+ return quoteChangeUpdate(charges, quoteChangeId, apiHost, token);
21984
22013
  },
21985
22014
  onSuccess: function (response) {
21986
22015
  var _a, _b, _c, _d, _e, _f;
21987
22016
  if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
21988
- var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
22017
+ var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
22018
+ SubscriptionState$2.TRIAL;
21989
22019
  setEditingQuoteData({
21990
22020
  id: (_d = (_c = response.quoteChangeUpdate) === null || _c === void 0 ? void 0 : _c.quoteChange) === null || _d === void 0 ? void 0 : _d.quoteId,
21991
22021
  isTrial: isTrial,
@@ -22002,7 +22032,8 @@ var QuantityInput = function (_a) {
22002
22032
  });
22003
22033
  // Handlers
22004
22034
  var isQuantityLowerThanOriginal = function (quantity) {
22005
- return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined && editedSubscription.quantity <= quantity;
22035
+ return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined &&
22036
+ editedSubscription.quantity <= quantity;
22006
22037
  };
22007
22038
  var onChangeQuantity = function (chargeIndex, value, priceListChargeId, subscription, subscriptionIndex) {
22008
22039
  var quantity = isNaN(parseInt(value)) ? 0 : parseInt(value);
@@ -22165,7 +22196,10 @@ var QuantityChangeDrawerDesktop = function (_a) {
22165
22196
  var _a;
22166
22197
  var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.TRIAL;
22167
22198
  return (jsx("div", __assign({ className: "contents" }, { children: subscription.charges.map(function (charge, chargeIndex) {
22168
- if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
22199
+ var _a;
22200
+ if ((isTrial && !charge.trial) ||
22201
+ (!isTrial && charge.trial) ||
22202
+ ((_a = charge.chargeType) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === "USAGE")
22169
22203
  return null;
22170
22204
  return (jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index, subscriptions: subscriptions }, chargeIndex));
22171
22205
  }) }), index));
@@ -22240,7 +22274,7 @@ var Subscriptions = function (_a) {
22240
22274
  var handlePortalErrors = _a.handlePortalErrors, companyName = _a.companyName, noSubscriptionsComponent = _a.noSubscriptionsComponent, hideTitle = _a.hideTitle;
22241
22275
  // Context
22242
22276
  var token = useToken();
22243
- var _b = useContext(BunnyContext), apiHost = _b.apiHost, graphQLClient = _b.graphQLClient;
22277
+ var _b = useContext(BunnyContext), apiHost = _b.apiHost; _b.graphQLClient;
22244
22278
  var _c = useContext(SubscriptionsContext), setUpgradingSubscription = _c.setUpgradingSubscription, updatingChargeQuantityId = _c.updatingChargeQuantityId, setUpdatingChargeQuantityId = _c.setUpdatingChargeQuantityId, setSubscriptionUpgradeId = _c.setSubscriptionUpgradeId, className = _c.className, isInPreviewMode = _c.isInPreviewMode;
22245
22279
  // Local state
22246
22280
  var _d = useState(), editingQuoteData = _d[0], setEditingQuoteData = _d[1];
@@ -22254,10 +22288,10 @@ var Subscriptions = function (_a) {
22254
22288
  var showSuccessNotification = useSuccessNotification();
22255
22289
  var quoteDelete = useQuoteDelete();
22256
22290
  var isMobile = useIsMobile();
22257
- var storedPaymentMethod = usePaymentMethod({
22258
- graphQLClient: graphQLClient,
22291
+ var defaultPaymentMethod = usePaymentMethod({
22259
22292
  token: token,
22260
- }).data;
22293
+ apiHost: apiHost,
22294
+ }).defaultPaymentMethod;
22261
22295
  var cancelSubscription = useCancelSubscription();
22262
22296
  // Queries
22263
22297
  var quote = useQuery({
@@ -22283,7 +22317,7 @@ var Subscriptions = function (_a) {
22283
22317
  // Mutations
22284
22318
  var subscriptionCancel = useMutation({
22285
22319
  mutationFn: function (subscription) {
22286
- return cancelSubscription([subscription.id], token, apiHost);
22320
+ return cancelSubscription([subscription.id], apiHost, token);
22287
22321
  },
22288
22322
  onSuccess: function () {
22289
22323
  queryClient.invalidateQueries({
@@ -22334,7 +22368,7 @@ var Subscriptions = function (_a) {
22334
22368
  };
22335
22369
  var onClose = function () {
22336
22370
  if (editingQuoteData) {
22337
- quoteDelete(editingQuoteData.id, token, apiHost);
22371
+ quoteDelete(editingQuoteData.id, apiHost, token);
22338
22372
  setEditingQuoteData(undefined);
22339
22373
  }
22340
22374
  if (updatingChargeQuantityId) {
@@ -22365,7 +22399,7 @@ var Subscriptions = function (_a) {
22365
22399
  setIsChangingPlan(false);
22366
22400
  }, handlePortalErrors: handlePortalErrors }));
22367
22401
  }
22368
- return (jsxs("div", __assign({ className: "".concat(className) }, { children: [!hideTitle ? jsx(PageTitle, { title: "Subscriptions" }) : null, jsx(PageHeaderWithActions, __assign({ title: jsxs(Text$1, __assign({ className: "flex items-center justify-between", style: { minWidth: "137px" } }, { children: [hideExpired ? "Active subscriptions" : "All subscriptions", isMobile && (jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired, visible: expiredSwitchVisible }))] })) }, { children: !isMobile && (jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) })), jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions, subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsx("div", __assign({ className: "pt-4 pb-2" }, { children: jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile, storedPaymentMethod: storedPaymentMethod })] })));
22402
+ return (jsxs("div", __assign({ className: "".concat(className) }, { children: [!hideTitle ? jsx(PageTitle, { title: "Subscriptions" }) : null, jsx(PageHeaderWithActions, __assign({ title: jsxs(Text$1, __assign({ className: "flex items-center justify-between", style: { minWidth: "137px" } }, { children: [hideExpired ? "Active subscriptions" : "All subscriptions", isMobile && (jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired, visible: expiredSwitchVisible }))] })) }, { children: !isMobile && (jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) })), jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions, subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsx("div", __assign({ className: "pt-4 pb-2" }, { children: jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile, storedPaymentMethod: defaultPaymentMethod })] })));
22369
22403
  };
22370
22404
  var PageHeaderWithActions = function (_a) {
22371
22405
  var children = _a.children, title = _a.title;
@@ -22405,6 +22439,33 @@ var billingDetailsUpdate = function (_a) {
22405
22439
  });
22406
22440
  };
22407
22441
 
22442
+ // TODO: move this to common
22443
+ var billingDetailsQuery = function () {
22444
+ return "\nquery BillingDetails {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n currency {\n id\n }\n }\n}";
22445
+ };
22446
+ var getBillingDetails = function (_a) {
22447
+ var token = _a.token, apiHost = _a.apiHost;
22448
+ return __awaiter(void 0, void 0, void 0, function () {
22449
+ var response;
22450
+ var _b;
22451
+ return __generator(this, function (_c) {
22452
+ switch (_c.label) {
22453
+ case 0: return [4 /*yield*/, gqlRequest({
22454
+ query: billingDetailsQuery(),
22455
+ token: token,
22456
+ apiHost: apiHost,
22457
+ })];
22458
+ case 1:
22459
+ response = _c.sent();
22460
+ if (response === null || response === void 0 ? void 0 : response.errors) {
22461
+ throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
22462
+ }
22463
+ return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
22464
+ }
22465
+ });
22466
+ });
22467
+ };
22468
+
22408
22469
  var Text = Typography.Text;
22409
22470
  function BillingDetailsSection(_a) {
22410
22471
  var _this = this;
@@ -22588,14 +22649,14 @@ var ResponsiveDivider = function () {
22588
22649
  var PaymentFormSection = function (_a) {
22589
22650
  var hideBillingDetailsForm = _a.hideBillingDetailsForm;
22590
22651
  var isMobile = useIsMobile();
22591
- var _b = useContext(BunnyContext), onTokenExpired = _b.onTokenExpired, graphQLClient = _b.graphQLClient;
22652
+ var onTokenExpired = useContext(BunnyContext).onTokenExpired;
22592
22653
  var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
22593
22654
  var showSuccessNotification = useSuccessNotification();
22594
22655
  return (jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? "w-full" : "w-1/2 pt-4", " flex justify-center") }, { children: jsx(PaymentForm, { onFail: function (error) {
22595
22656
  handleAllErrorFormats(error);
22596
22657
  }, onSavePaymentMethod: function () {
22597
22658
  showSuccessNotification("Your payment method has been saved");
22598
- }, graphQLClient: graphQLClient }) })));
22659
+ } }) })));
22599
22660
  };
22600
22661
 
22601
- export { BillingDetails, BunnyProvider, Footer, Invoice, PaymentForm, PaymentMethod, Quote, Quotes, Signup, SubscriptionsWrapper as Subscriptions, Transactions };
22662
+ export { BillingDetails, BunnyProvider, Footer, Invoice, PaymentForm, Quote, Quotes, Signup, SubscriptionsWrapper as Subscriptions, Transactions };