@zonos/elements 1.0.16 → 1.0.17-alpha.0

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 (85) hide show
  1. package/dist/cjs/{cart-e27fd17c.js → cart-108bc407.js} +8 -1
  2. package/dist/cjs/cart-108bc407.js.map +1 -0
  3. package/dist/cjs/zonos-address_2.cjs.entry.js +1 -1
  4. package/dist/cjs/zonos-banner_2.cjs.entry.js +1 -1
  5. package/dist/cjs/zonos-cart-items_10.cjs.entry.js +5 -3
  6. package/dist/cjs/zonos-cart-items_10.cjs.entry.js.map +1 -1
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +6 -2
  8. package/dist/cjs/zonos-checkout.cjs.entry.js.map +1 -1
  9. package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
  10. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.js +3 -1
  11. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.js.map +1 -1
  12. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +1 -1
  13. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js.map +1 -1
  14. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +5 -1
  15. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js.map +1 -1
  16. package/dist/collection/components/store/checkout/cart.js +6 -0
  17. package/dist/collection/components/store/checkout/cart.js.map +1 -1
  18. package/dist/collection/components/store/checkout/stripe.js +2 -0
  19. package/dist/collection/components/store/checkout/stripe.js.map +1 -1
  20. package/dist/collection/environment.js +9 -1
  21. package/dist/collection/environment.js.map +1 -1
  22. package/dist/collection/scripts/stripe.js +3 -3
  23. package/dist/collection/scripts/stripe.js.map +1 -1
  24. package/dist/collection/types/generated/graphql.customer.types.js +5 -0
  25. package/dist/collection/types/generated/graphql.customer.types.js.map +1 -1
  26. package/dist/components/stripe.js +8 -1
  27. package/dist/components/stripe.js.map +1 -1
  28. package/dist/components/zonos-cart-items2.js +3 -1
  29. package/dist/components/zonos-cart-items2.js.map +1 -1
  30. package/dist/components/zonos-checkout-finish2.js +1 -1
  31. package/dist/components/zonos-checkout-finish2.js.map +1 -1
  32. package/dist/components/zonos-checkout.js +5 -1
  33. package/dist/components/zonos-checkout.js.map +1 -1
  34. package/dist/esm/{cart-36c33342.js → cart-2f83e048.js} +8 -1
  35. package/dist/esm/cart-2f83e048.js.map +1 -0
  36. package/dist/esm/zonos-address_2.entry.js +1 -1
  37. package/dist/esm/zonos-banner_2.entry.js +1 -1
  38. package/dist/esm/zonos-cart-items_10.entry.js +5 -3
  39. package/dist/esm/zonos-cart-items_10.entry.js.map +1 -1
  40. package/dist/esm/zonos-checkout.entry.js +6 -2
  41. package/dist/esm/zonos-checkout.entry.js.map +1 -1
  42. package/dist/esm/zonos-controller.entry.js +1 -1
  43. package/dist/esm-es5/cart-2f83e048.js +2 -0
  44. package/dist/esm-es5/cart-2f83e048.js.map +1 -0
  45. package/dist/esm-es5/zonos-address_2.entry.js +1 -1
  46. package/dist/esm-es5/zonos-banner_2.entry.js +1 -1
  47. package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
  48. package/dist/esm-es5/zonos-cart-items_10.entry.js.map +1 -1
  49. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  50. package/dist/esm-es5/zonos-checkout.entry.js.map +1 -1
  51. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  52. package/dist/scripts/loadStripe.js +118 -0
  53. package/dist/scripts/loadZonos.js +300 -0
  54. package/dist/scripts/stripe.js +126 -0
  55. package/dist/scripts/zonos.js +300 -0
  56. package/dist/types/components/store/checkout/cart.d.ts +14 -0
  57. package/dist/types/components/store/checkout/stripe.d.ts +1 -1
  58. package/dist/types/types/generated/graphql.customer.types.d.ts +48 -0
  59. package/dist/types/types/generated/graphql.customer.types.ts +50 -0
  60. package/dist/zonos-elements/{cart-36c33342.js → cart-2f83e048.js} +8 -1
  61. package/dist/zonos-elements/cart-2f83e048.js.map +1 -0
  62. package/dist/zonos-elements/cart-9780fa28.system.js +2 -0
  63. package/dist/zonos-elements/cart-9780fa28.system.js.map +1 -0
  64. package/dist/zonos-elements/zonos-address_2.entry.js +1 -1
  65. package/dist/zonos-elements/zonos-address_2.system.entry.js +1 -1
  66. package/dist/zonos-elements/zonos-banner_2.entry.js +1 -1
  67. package/dist/zonos-elements/zonos-banner_2.system.entry.js +1 -1
  68. package/dist/zonos-elements/zonos-cart-items_10.entry.js +5 -3
  69. package/dist/zonos-elements/zonos-cart-items_10.entry.js.map +1 -1
  70. package/dist/zonos-elements/zonos-cart-items_10.system.entry.js +1 -1
  71. package/dist/zonos-elements/zonos-cart-items_10.system.entry.js.map +1 -1
  72. package/dist/zonos-elements/zonos-checkout.entry.js +6 -2
  73. package/dist/zonos-elements/zonos-checkout.entry.js.map +1 -1
  74. package/dist/zonos-elements/zonos-checkout.system.entry.js +1 -1
  75. package/dist/zonos-elements/zonos-checkout.system.entry.js.map +1 -1
  76. package/dist/zonos-elements/zonos-controller.entry.js +1 -1
  77. package/dist/zonos-elements/zonos-controller.system.entry.js +1 -1
  78. package/package.json +2 -2
  79. package/dist/cjs/cart-e27fd17c.js.map +0 -1
  80. package/dist/esm/cart-36c33342.js.map +0 -1
  81. package/dist/esm-es5/cart-36c33342.js +0 -2
  82. package/dist/esm-es5/cart-36c33342.js.map +0 -1
  83. package/dist/zonos-elements/cart-36c33342.js.map +0 -1
  84. package/dist/zonos-elements/cart-ecd9011b.system.js +0 -2
  85. package/dist/zonos-elements/cart-ecd9011b.system.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"file":"cart-2f83e048.js","mappings":";;;;;AAIO,MAAM,uBAAuB,GAAG;;EAErC,MAAM,cAAc,GAAG,WAAW,CAAC,mBAAmB,CAAC;EAEvD,MAAM,iBAAiB,GAAG,WAAW,CAAC,sBAAsB,CAAC;EAC7D,IAAI,CAAC,iBAAiB,I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EAE9B,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC;EACrC,MAAM,yBAAyB,CAAC;IAC9B,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,KAAK;GACnB,CAAC,CAAC;EACH,WAAW,CAAC,iBAAiB,GAAG,KAAK,CAAC;AACxC,EAAE;AAEF,MAAM,oCAAoC,GAAG;EAC3C,SAAS,CAAC,sBAAsB,GAAG,IAAI,CAAC;EACxC,SAAS,CAAC,gCAAgC,GAAG,KAAK,CAAC;EACnD,SAAS,CAAC,2BAA2B,GAAG,KAAK,CAAC;EAC9C,SAAS,CAAC,kCAAkC,GAAG,EAAE,CAAC;EAClD,SAAS,CAAC,iCAAiC,GAAG,EAAE,CAAC;EACjD,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC;MAEI,iBAAiB,GAAG;EACxB,IAAI,SAAS,CAAC,IAAI,KAAK,eAAe,EAAE;IACtC,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC;GAC7B;OAAM,IAAI,SAAS,CAAC,IAAI,KAAK,UAAU,EAAE;IACxC,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC;GAC5B;OAAM,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,EAAE;IACvC,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC;GAC3B;AACH,EAAE;MAEI,qBAAqB,GAAG;EAC5B,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,EAAE;IAChC,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC;GAC7B;OAAM,IAAI,SAAS,CAAC,IAAI,KAAK,UAAU,EAAE;IACxC,SAAS,CAAC,IAAI,GAAG,eAAe,CAAC;;IAEjC,oCAAoC,EAAE,CAAC;GACxC;AACH;;;;","names":["onChange","reset"],"sources":["src/components/utils/api/prepCalculateLandedCost.ts","src/components/utils/api/calculateLandedCost.ts","src/styles/stripe/addressRuleStyle.ts","src/styles/stripe/defaultVariable.ts","src/components/store/checkout/stripe.ts","src/components/utils/formatDate.ts","src/components/utils/getDaysDifference.ts","src/components/store/checkout/cart.ts"],"sourcesContent":["import { cartStore } from 'src/components/store/checkout/cart';\nimport { stripeStore } from 'src/components/store/checkout/stripe';\nimport type { CalculateLandedCostRequest } from 'src/types/checkout/api/CalculateLandedCostRequest';\n\nexport const prepCalculateLandedCost = (): CalculateLandedCostRequest => {\n // maybe we don't need email now for prefetch the landed cost\n const stripeLinkData = stripeStore.stripeLinkEventData;\n\n const stripeAddressData = stripeStore.stripeAddressEventData;\n if (!stripeAddressData || !stripeAddressData.complete) {\n throw new Error('Missing stripe address data');\n }\n\n return {\n checkoutSessionId: cartStore.checkoutSessionId || '',\n contact: {\n email: stripeLinkData?.value.email || '',\n // firstName and lastName should be valid now since stripe only mark\n // the address as complete when both fields are filled.\n firstName: stripeAddressData.value.firstName || '',\n lastName: stripeAddressData.value.lastName || '',\n phone: stripeAddressData.value.phone || '',\n },\n items: cartStore.items.map(item => ({\n amount: item.amount,\n countryOfOrigin: item.countryOfOrigin,\n currencyCode: item.currencyCode,\n imageUrl: item.imageUrl,\n name: item.name,\n productId: item.productId,\n quantity: item.quantity,\n })),\n shippingAddress: {\n addressLine1: stripeAddressData.value.address.line1,\n addressLine2: stripeAddressData.value.address.line2 || '',\n city: stripeAddressData.value.address.city,\n country: stripeAddressData.value.address.country,\n postalCode: stripeAddressData.value.address.postal_code,\n state: stripeAddressData.value.address.state,\n },\n };\n};\n","import { prepCalculateLandedCost } from 'src/components/utils/api/prepCalculateLandedCost';\nimport { handleFetch } from 'src/components/utils/handleFetch';\nimport type { CalculateLandedCostRequest } from 'src/types/checkout/api/CalculateLandedCostRequest';\nimport type { CalculateLandedCostMutation } from 'src/types/generated/graphql.customer.types';\n\nexport const calculateLandedCost = async (\n abortController?: AbortController,\n) => {\n // request to get landed cost info\n const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/calculate-landed-cost`;\n const { errors, json } = await handleFetch<\n CalculateLandedCostMutation,\n CalculateLandedCostRequest\n >(url, {\n body: prepCalculateLandedCost(),\n method: 'POST',\n signal: abortController?.signal,\n });\n if (errors.length || !json) {\n throw new Error('Failed to calculate landed cost');\n }\n\n return json;\n};\n","import type { ElementsUiTheme, StripeRuleType } from 'src/types';\n\nexport const addressRuleStyle = ({\n theme,\n}: {\n theme: ElementsUiTheme;\n}): StripeRuleType => {\n switch (theme) {\n default:\n return {\n '.Input': {\n // need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.\n padding: '0',\n paddingBottom: '8px',\n paddingLeft: '16px',\n paddingRight: '8px',\n // any value here will be add up to the default paddingTop (20px).\n paddingTop: '6px',\n },\n };\n }\n};\n","import type { Appearance } from '@stripe/stripe-js';\n\nimport { getBorderRadius } from 'src/components/utils/getBorderRadius';\nimport type {\n ElementsUiStyle,\n ElementsUiTheme,\n} from 'src/types/generated/graphql.customer.types';\n\nexport const defaultVariable = ({\n borderStyle,\n theme,\n}: {\n borderStyle?: ElementsUiStyle;\n theme: ElementsUiTheme;\n}): Appearance['variables'] => {\n switch (theme) {\n case 'DARK':\n return {\n borderRadius: getBorderRadius(borderStyle),\n colorBackground: '#101117',\n colorBackgroundText: '#C5C6CA',\n colorText: '#C5C6CA',\n colorTextPlaceholder: '#C5C6CA',\n };\n default:\n return {\n borderRadius: getBorderRadius(borderStyle),\n };\n }\n};\n","import { createStore } from '@stencil/store';\nimport type {\n PaymentIntent,\n Stripe,\n StripeAddressElement,\n StripeAddressElementChangeEvent,\n StripeElements,\n StripeElementsOptionsClientSecret,\n StripeLinkAuthenticationElement,\n StripeLinkAuthenticationElementChangeEvent,\n StripePaymentElement,\n StripePaymentElementChangeEvent,\n} from '@stripe/stripe-js';\n\nimport {\n cartStore,\n cartStoreApplySubtotals,\n} from 'src/components/store/checkout/cart';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport { zonosStore } from 'src/components/store/zonosStore';\nimport { calculateLandedCost } from 'src/components/utils/api/calculateLandedCost';\nimport { handleFetch } from 'src/components/utils/handleFetch';\nimport { isDarkColor } from 'src/components/utils/isDarkColor';\nimport { log } from 'src/components/utils/logging/log';\nimport { logError } from 'src/components/utils/logging/logError';\nimport { addressRuleStyle } from 'src/styles/stripe/addressRuleStyle';\nimport { defaultVariable } from 'src/styles/stripe/defaultVariable';\nimport type {\n CheckoutSessionCreateMutation,\n CheckoutSessionUpdateMutation,\n CountryCode,\n ElementsUiStyle,\n ElementsUiTheme,\n} from 'src/types/generated/graphql.customer.types';\n\nexport type ContactOption = {\n address: {\n city: string;\n country: string;\n line1: string;\n line2?: string;\n postal_code: string;\n state: string;\n };\n name: string;\n phone?: string;\n};\n\ntype StripeStore = {\n // client secret is used to render link and payment elements\n clientSecret: string | null;\n fetchingLandedCostAbordController: AbortController | null;\n // toggle to indicate if we are pre-fetching/fetching landed cost\n isFetchingLandedCost: boolean;\n // toggle to indicate if we are fetching checkout session\n isFetchingSession: boolean;\n stripe: Stripe | null;\n stripeAddressElement: StripeAddressElement | null;\n stripeAddressEventData: StripeAddressElementChangeEvent | null;\n stripeAddressUsedWhenFetchingLC: StripeAddressElementChangeEvent | null;\n stripeElements: StripeElements | null;\n stripeLinkElement: StripeLinkAuthenticationElement | null;\n stripeLinkEventData: StripeLinkAuthenticationElementChangeEvent | null;\n stripeLinkUsedWhenFetchingLC: StripeLinkAuthenticationElementChangeEvent | null;\n stripePaymentElement: StripePaymentElement | null;\n stripePaymentEventData: StripePaymentElementChangeEvent | null;\n};\n\nconst {\n onChange,\n reset,\n state: stripeStore,\n} = createStore<StripeStore>(() => ({\n clientSecret: sessionStorage.getItem('zonos--client-secret') || null,\n fetchingLandedCostAbordController: null,\n isFetchingLandedCost: false,\n isFetchingSession: false,\n stripe: null,\n stripeAddressElement: null,\n stripeAddressEventData: null,\n stripeAddressUsedWhenFetchingLC: null,\n stripeElements: null,\n stripeLinkElement: null,\n stripeLinkEventData: null,\n stripeLinkUsedWhenFetchingLC: null,\n stripePaymentElement: null,\n stripePaymentEventData: null,\n}));\n\nconst getStripeOptions = ({\n clientSecret,\n overrideBorderRaidus,\n overridePrimaryColor,\n overrideTheme,\n}: {\n clientSecret?: string;\n overrideBorderRaidus?: ElementsUiStyle;\n overridePrimaryColor?: string;\n overrideTheme?: ElementsUiTheme;\n}): StripeElementsOptionsClientSecret => {\n const primaryColor =\n overridePrimaryColor || zonosStore.appearance.colorPrimary;\n const themeBasedColor =\n primaryColor && isDarkColor(primaryColor) ? 'night' : 'flat';\n // if overrideTheme is provided, use it. Otherwise, use theme based on primary color\n const theme = overrideTheme === 'DARK' ? 'night' : 'flat';\n return {\n appearance: {\n labels: 'floating',\n rules: {\n ...addressRuleStyle({ theme: 'LIGHT' }),\n },\n // get contrast theme color base on primary color\n theme: overrideTheme ? theme : themeBasedColor,\n variables: {\n ...defaultVariable({\n borderStyle: overrideBorderRaidus,\n theme: 'LIGHT',\n }),\n },\n },\n clientSecret,\n locale: localizationStore.selectedLocale,\n };\n};\n\nconst initStripeElements = async (props?: {\n overrideBorderRaidus?: ElementsUiStyle;\n overridePrimaryColor?: string;\n overrideTheme?: ElementsUiTheme;\n}) => {\n const clientSecret = stripeStore.clientSecret;\n\n if (!stripeStore.stripe) {\n log('Skip. Stripe is not initialized');\n return;\n }\n if (clientSecret) {\n const stripeOptions = getStripeOptions({\n clientSecret,\n overrideBorderRaidus: props?.overrideBorderRaidus,\n overridePrimaryColor: props?.overridePrimaryColor,\n overrideTheme: props?.overrideTheme,\n });\n\n if (!stripeStore.stripeElements) {\n // init stripe elements if it doesn't exist\n stripeStore.stripeElements = stripeStore.stripe?.elements(stripeOptions);\n } else {\n // update elements with new option if it already exists\n stripeStore.stripeElements.update(stripeOptions);\n }\n log('Stripe elements initialized');\n }\n};\n\nconst stripeStoreReset = () => {\n // clean clientSecret so that we can start the new one.\n sessionStorage.removeItem('zonos--client-secret');\n\n // cleanup stripe elements\n reset();\n // set stripe back to window.Zonos.stripe\n stripeStore.stripe = window.Zonos.stripe;\n};\n\n/**\n * Check if the address and email info used when fetching landed cost with the current email and address info are different\n * Purpose is to resend the request if the info used when fetching landed cost is different from the current info\n */\nconst isPrefetchInfoOutdated = () => {\n const hasAbortController = stripeStore.fetchingLandedCostAbordController;\n if (!hasAbortController) {\n // if there is no abort controller, this is a new request\n return false;\n }\n\n const isLinkDataDirty =\n JSON.stringify(stripeStore.stripeLinkUsedWhenFetchingLC?.value) !==\n JSON.stringify(stripeStore.stripeLinkEventData?.value);\n const isAddressDataDirty =\n JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC?.value) !==\n JSON.stringify(stripeStore.stripeAddressEventData?.value);\n\n return isLinkDataDirty || isAddressDataDirty;\n};\n\nconst stripeStorePrefetchLandedCost = async () => {\n const stripeAddressReady = !!stripeStore.stripeAddressEventData?.complete;\n const stripeLinkReady = !!stripeStore.stripeLinkEventData?.complete;\n const shouldRefetch = isPrefetchInfoOutdated();\n\n if (shouldRefetch) {\n // if the info used when fetching landed cost is different from the current info, abort the previous request\n stripeStore.fetchingLandedCostAbordController?.abort();\n stripeStore.fetchingLandedCostAbordController = null;\n }\n\n // only fetch if we are not fetching or we need to refetch\n if (\n stripeAddressReady &&\n stripeLinkReady &&\n (shouldRefetch || !stripeStore.isFetchingLandedCost)\n ) {\n stripeStore.isFetchingLandedCost = true;\n if (stripeStore.stripeAddressEventData) {\n stripeStore.stripeAddressUsedWhenFetchingLC = {\n ...stripeStore.stripeAddressEventData,\n };\n }\n if (stripeStore.stripeLinkEventData) {\n stripeStore.stripeLinkUsedWhenFetchingLC = {\n ...stripeStore.stripeLinkEventData,\n };\n }\n try {\n const abortController = new AbortController();\n stripeStore.fetchingLandedCostAbordController = abortController;\n const { checkoutSessionWorkflow, shipmentRatingCalculateWorkflow } =\n await calculateLandedCost(abortController);\n\n // reset abort controller after we are done\n stripeStore.fetchingLandedCostAbordController = null;\n\n // update cart store with landed cost info\n cartStore.landedCostData =\n checkoutSessionWorkflow?.filter(Boolean) || null;\n\n cartStore.shippingData =\n shipmentRatingCalculateWorkflow?.filter(Boolean) || null;\n // apply new subtotal and total, this is mainly to show items in the presentment currency\n const firstLandedCostData = cartStore.landedCostData?.find(Boolean);\n const subtotals = !!firstLandedCostData\n ? firstLandedCostData.subtotals\n : null;\n if (subtotals) {\n // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet\n cartStoreApplySubtotals({\n exchangeRate: subtotals.exchangeRate,\n items: subtotals.items,\n landedCostTotal: 0,\n presentmentCurrencyCode: subtotals.presentmentCurrencyCode,\n shipping: 0,\n total: subtotals.items,\n });\n }\n } catch (err) {\n logError(err);\n }\n stripeStore.isFetchingLandedCost = false;\n }\n};\n\nconst getStripeMessageBasedOnStatus = (status?: PaymentIntent['status']) => {\n let messages: string[] = [];\n let isError = true;\n // Inspect the PaymentIntent `status` to indicate the status of the payment\n // to your customer.\n //\n // Some payment methods will [immediately succeed or fail][0] upon\n // confirmation, while others will first enter a `processing` state.\n //\n // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification\n switch (status) {\n case 'succeeded': {\n messages = [\n translate(\n 'Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us.',\n ),\n '',\n '',\n translate(\n \"We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.\",\n ),\n ];\n isError = false;\n break;\n }\n case 'requires_capture':\n case 'processing': {\n messages = [\n translate(\n \"Payment processing. We'll update you when payment is received.\",\n ),\n ];\n isError = false;\n break;\n }\n\n case 'requires_payment_method': {\n messages = [\n translate('Payment failed. Please try another payment method.'),\n ];\n break;\n }\n\n default: {\n messages = [translate('Something went wrong.')];\n break;\n }\n }\n return {\n isError,\n messages,\n };\n};\n\nconst stripeStoreRetrievePayment = async ({\n clientSecret: _clientSecret,\n storybookForceStatus,\n}: {\n clientSecret: string | null;\n storybookForceStatus?: PaymentIntent['status'];\n}) => {\n if (storybookForceStatus) {\n // return status right away if we are in storybook mode\n const { isError, messages } =\n getStripeMessageBasedOnStatus(storybookForceStatus);\n\n return { error: isError, messages };\n }\n const clientSecret = _clientSecret || stripeStore.clientSecret;\n if (!stripeStore.stripe || !clientSecret) {\n logError('Failed to retrieve payment intent. Stripe is not initialized');\n return { error: true, message: [translate('Something went wrong.')] };\n }\n const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(\n clientSecret,\n );\n\n const status = paymentIntent?.status;\n\n const { isError, messages } = getStripeMessageBasedOnStatus(status);\n\n return { error: isError, messages };\n};\n\nconst stripeStoreConfirmPayment = async () => {\n const stripePaymentReady = !!stripeStore.stripePaymentEventData?.complete;\n const stripeElements = stripeStore.stripeElements;\n const stripe = stripeStore.stripe;\n const stripeClientSecret = stripeStore.clientSecret;\n if (stripe && stripeElements && stripePaymentReady && stripeClientSecret) {\n const { error } = await stripe.confirmPayment({\n confirmParams: {\n receipt_email: stripeStore.stripeLinkEventData?.value?.email,\n return_url: window.location.href,\n },\n elements: stripeElements,\n redirect: 'if_required',\n });\n\n if (error) {\n if (error.type === 'card_error' || error.type === 'validation_error') {\n throw new Error(error.message);\n }\n if (error.type === 'invalid_request_error') {\n if (error.code === 'payment_intent_unexpected_state') {\n // PaymentIntent was canceled or expired, or status is `require_capture`.\n // don't throw error here because we will reset the checkout session last step\n return;\n }\n }\n throw new Error('An unexpected error occurred.');\n }\n }\n};\n\ntype CheckoutSessionCreateRequest = {\n currency: string;\n itemsAmount: number;\n presentmentCountryCode: CountryCode | null;\n};\n\n/**\n * Init checkout session\n * @returns {boolean} whether or not the checkout session is successfully created\n */\nconst stripeStoreInitCheckoutSession = async () => {\n const total = cartStore.items.reduce(\n (amount, item) => amount + item.amount * item.quantity,\n 0,\n );\n\n if (!total || !localizationStore.targetCurrency) {\n logError('Fail to create checkout session - invalid total or currency');\n return false;\n }\n\n stripeStore.isFetchingSession = true;\n\n const { errors, json } = await handleFetch<\n CheckoutSessionCreateMutation,\n CheckoutSessionCreateRequest\n >(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/create-checkout-session`, {\n body: {\n currency: cartStore.items.find(Boolean)?.currencyCode || '',\n itemsAmount: total,\n presentmentCountryCode: localizationStore.selectedCountryCode || null,\n },\n method: 'POST',\n });\n\n stripeStore.isFetchingSession = false;\n\n if (errors.length || !json) {\n logError(\n 'Error occurs when creating checkout session',\n JSON.stringify(errors, null, 2),\n );\n\n return false;\n }\n const result = json.checkoutSessionCreate;\n\n stripeStore.clientSecret = result.clientSecret;\n // update cart store with updated informations\n cartStore.checkoutSessionId = result.id;\n cartStoreApplySubtotals({\n ...result.subtotals,\n landedCostTotal: 0,\n shipping: 0,\n total: result.subtotals.items,\n });\n log(\n 'Exchange rate updated for cart items (checkout session create)',\n 'info',\n cartStore.exchangeRate,\n );\n\n log('done-init-checkout-session');\n return true;\n};\n\ntype CheckoutSessionUpdateRequest = {\n currency?: string;\n id: string;\n itemsAmount?: number;\n landedCostId?: string;\n presentmentCountryCode: CountryCode | null;\n};\n/**\n * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change\n */\nconst stripeStoreUpdateCheckoutSession = async ({\n currency,\n id,\n itemsAmount,\n landedCostId,\n presentmentCountryCode,\n}: CheckoutSessionUpdateRequest) => {\n // No need to set loading state here because this function will be called under the hood to update\n // landed cost id for the section.\n const { errors, json } = await handleFetch<\n CheckoutSessionUpdateMutation,\n CheckoutSessionUpdateRequest\n >(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/update-checkout-session`, {\n body: {\n currency,\n id,\n itemsAmount,\n landedCostId,\n presentmentCountryCode,\n },\n method: 'POST',\n });\n\n if (errors.length || !json) {\n logError(\n 'Error occurs when updating checkout session',\n JSON.stringify(errors, null, 2),\n );\n return { errors, json };\n }\n\n return { errors: [], json };\n};\n\nonChange('clientSecret', clientSecret => {\n // update stripe elements when client secret changes\n if (clientSecret && stripeStore.stripe) {\n sessionStorage.setItem('zonos--client-secret', clientSecret);\n }\n\n if (!clientSecret) {\n sessionStorage.removeItem('zonos--client-secret');\n }\n});\n\nexport {\n initStripeElements,\n stripeStore,\n stripeStoreConfirmPayment,\n stripeStoreInitCheckoutSession,\n stripeStorePrefetchLandedCost,\n stripeStoreReset,\n stripeStoreRetrievePayment,\n stripeStoreUpdateCheckoutSession,\n};\n","type Params = {\n date: Date;\n /**\n * Format options for Intl.DateTimeFormat\n * @default {day:'numeric',weekday:'long',year:'numeric'} Thursday 3, 2023\n */\n formatOptions?: Intl.DateTimeFormatOptions;\n};\n\nexport const formatDate = ({\n date,\n formatOptions = { day: 'numeric', weekday: 'long', year: 'numeric' },\n}: Params): string => {\n // format date to Thursday 3, 2023\n return new Intl.DateTimeFormat('en-US', formatOptions).format(date);\n};\n","export const getDaysDifference = (targetDate: Date) => {\n const currentDate = new Date();\n const timeDifference = targetDate.getTime() - currentDate.getTime();\n const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); // Convert milliseconds to days\n return daysDifference;\n};\n","import { createStore } from '@stencil/store';\n\nimport {\n stripeStore,\n stripeStoreUpdateCheckoutSession,\n} from 'src/components/store/checkout/stripe';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport { formatDate } from 'src/components/utils/formatDate';\nimport { getDaysDifference } from 'src/components/utils/getDaysDifference';\nimport { log } from 'src/components/utils/logging/log';\nimport { logError } from 'src/components/utils/logging/logError';\nimport type {\n CheckoutPresentmentFragment,\n CurrencyCode,\n ShipmentRatingFragment,\n} from 'src/types/generated/graphql.customer.types';\n\nexport type CartItem = {\n amount: number;\n countryOfOrigin?: string;\n currencyCode: string;\n description?: string;\n hsCode?: string;\n imageUrl?: string;\n name: string;\n productId?: string;\n quantity: number;\n};\n\ntype CartStore = {\n checkoutSessionId: string | null;\n currency: CurrencyCode;\n dutiesTaxFees: number;\n error: {\n messages: string[];\n title: string;\n } | null;\n exchangeRate: {\n id: string;\n rate: number;\n sourceCurrencyCode: CurrencyCode;\n targetCurrencyCode: CurrencyCode;\n type: string;\n } | null;\n isSelectedShippingAboveDeminimis: boolean;\n isSelectedShippingGuarantee: boolean;\n items: CartItem[];\n landedCostData: CheckoutPresentmentFragment[] | null;\n selectedLandedCost: CheckoutPresentmentFragment | null;\n selectedShippingOption: ShipmentRatingFragment | null;\n selectedShippingOptionExpectedDate: string;\n selectedShippingOptionTransitTime: string;\n shipping: number;\n shippingData: ShipmentRatingFragment[] | null;\n step: 'customer-info' | 'shipping' | 'payment' | 'finish' | 'error';\n subtotal: number;\n total: number;\n};\n\nconst {\n onChange,\n reset,\n state: cartStore,\n} = createStore<CartStore>(() => ({\n checkoutSessionId:\n sessionStorage.getItem('zonos--checkout-session-id') || null,\n currency: 'USD',\n dutiesTaxFees: 0,\n error: null,\n exchangeRate: null,\n isSelectedShippingAboveDeminimis: false,\n isSelectedShippingGuarantee: false,\n items: [],\n landedCostData: null,\n selectedLandedCost: null,\n selectedShippingOption: null,\n selectedShippingOptionExpectedDate: '',\n selectedShippingOptionTransitTime: '',\n shipping: 0,\n shippingData: null,\n step: 'customer-info',\n subtotal: 0,\n total: 0,\n}));\n\n/**\n * Format shipping transit info to be displayed on UI\n * @returns\n * - expectedDate: Thursday, Aug 12\n * - maxTransit: 5\n * - minTransit: 3\n */\nconst cartStoreGetShippingTransitInfo = (item: ShipmentRatingFragment) => {\n const minTransit = item.minTransitAt\n ? getDaysDifference(new Date(item.minTransitAt))\n : '';\n const maxTransit = item.maxTransitAt\n ? getDaysDifference(new Date(item.maxTransitAt))\n : '';\n const expectedDate = item.minTransitAt\n ? formatDate({\n date: new Date(item.minTransitAt),\n })\n : '';\n return {\n expectedDate,\n maxTransit,\n minTransit,\n };\n};\n\nconst cartStoreReset = () => {\n sessionStorage.removeItem('zonos--checkout-session-id');\n\n // reset cart store\n reset();\n};\n\nconst cartStoreUpdateToErrorState = ({\n messages,\n title,\n}: {\n messages: string[];\n title: string;\n}) => {\n cartStore.step = 'error';\n cartStore.error = {\n messages,\n title,\n };\n};\n\ntype CartSubtotals = {\n exchangeRate: {\n id: string;\n rate: number;\n sourceCurrencyCode: CurrencyCode;\n targetCurrencyCode: CurrencyCode;\n type: string;\n };\n items: number;\n landedCostTotal: number;\n presentmentCurrencyCode: CurrencyCode;\n shipping: number;\n total: number;\n};\n\nconst cartStoreApplySubtotals = (subtotals: CartSubtotals) => {\n // update exchange rate so we can use it to display cart items\n cartStore.exchangeRate = subtotals.exchangeRate;\n cartStore.dutiesTaxFees = subtotals.landedCostTotal;\n cartStore.subtotal = subtotals.items;\n cartStore.total = subtotals.total;\n cartStore.currency = subtotals.presentmentCurrencyCode;\n};\n\ntype CartStoreRecalculateTotalParams = Omit<\n Parameters<typeof stripeStoreUpdateCheckoutSession>[0],\n 'id' | 'presentmentCountryCode'\n>;\n\nconst cartStoreReCalculateTotal = async ({\n currency,\n itemsAmount,\n landedCostId,\n}: CartStoreRecalculateTotalParams) => {\n if (landedCostId && cartStore.selectedLandedCost) {\n // update cart total right away if we have landed cost id to avoid order total flickering\n const subtotals = cartStore.selectedLandedCost.subtotals;\n cartStoreApplySubtotals(subtotals);\n log(\n 'Exchange rate updated for cart items (landed cost subtotal)',\n 'info',\n cartStore.exchangeRate,\n );\n }\n // update checkout session\n if (!cartStore.checkoutSessionId) {\n logError('Could update cart total without checkout session id');\n return false;\n }\n const { json } = await stripeStoreUpdateCheckoutSession({\n currency,\n id: cartStore.checkoutSessionId,\n itemsAmount,\n landedCostId,\n presentmentCountryCode: localizationStore.selectedCountryCode,\n });\n if (!json) {\n // do nothing if we can't get checkout session\n logError('Error occurs when updating checkout session');\n cartStoreUpdateToErrorState({\n messages: [\n translate(\n \"There's been an error updating your checkout session. Please reload and try again or contact support if the error persists\",\n ),\n ],\n title: translate('Error updating Checkout'),\n });\n return false;\n }\n if (!landedCostId) {\n // This is when first open the checkout modal and we just want to get info from the old cart session.\n // use subtotals from checkout session to update cart total\n cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);\n log(\n 'Exchange rate updated for cart items (checkout session update)',\n 'info',\n cartStore.exchangeRate,\n );\n }\n return true;\n};\n\nconst cartStoreUpdateSelectedShippingOption = async (\n selectedShippingOption: ShipmentRatingFragment,\n) => {\n cartStore.selectedShippingOption = selectedShippingOption;\n\n // update shipping transit info\n const { expectedDate, maxTransit, minTransit } =\n cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);\n cartStore.selectedShippingOptionExpectedDate = expectedDate;\n cartStore.selectedShippingOptionTransitTime =\n minTransit && maxTransit\n ? `${minTransit}-${maxTransit}`\n : `${minTransit || maxTransit}`;\n\n const selectedLandedCost = cartStore.landedCostData?.find(\n checkoutSessionPresentment =>\n checkoutSessionPresentment.landedCost?.shipmentRating?.id ===\n cartStore.selectedShippingOption?.id,\n );\n // save selected landed cost for later use\n cartStore.selectedLandedCost = selectedLandedCost || null;\n\n if (!selectedLandedCost) {\n // do nothing if we can't find landed cost for selected shipping option\n return false;\n }\n\n // update shipping value and dutiesTaxFees on selectedShippingOption change\n cartStore.shipping = selectedLandedCost.subtotals.shipping;\n\n // update deminimis status\n const isGuarantee =\n selectedLandedCost?.landedCost?.landedCostGuaranteeCode === 'ZONOS';\n // one item in deminimis with type of duty and tax has threshold value is \"ABOVE\"\n const isAboveDeminimis = !!selectedLandedCost?.landedCost?.deMinimis?.find(\n item => ['DUTY', 'TAX'].includes(item.type) && item.threshold === 'ABOVE',\n );\n cartStore.isSelectedShippingAboveDeminimis = isAboveDeminimis;\n cartStore.isSelectedShippingGuarantee = isGuarantee;\n // update session with selected landed cost\n const updateCalulateStatus = await cartStoreReCalculateTotal({\n landedCostId: selectedLandedCost.landedCost?.id,\n });\n return updateCalulateStatus;\n};\n\nonChange('checkoutSessionId', () => {\n if (!cartStore.checkoutSessionId) {\n sessionStorage.removeItem('zonos--checkout-session-id');\n return;\n }\n sessionStorage.setItem(\n 'zonos--checkout-session-id',\n cartStore.checkoutSessionId,\n );\n});\n\nconst cartStoreUpdateItems = async (items: CartItem[]) => {\n cartStore.items = items;\n const currency = items.find(Boolean)?.currencyCode as CurrencyCode;\n const total = items.reduce((amt, item) => {\n return amt + item.amount * item.quantity;\n }, 0);\n if (!currency || !total) {\n // do nothing if we can't get currency or total\n return;\n }\n cartStore.currency = currency;\n // set loading state here because this is first load checkout session when we already have checkout session id stored\n stripeStore.isFetchingSession = true;\n await cartStoreReCalculateTotal({\n currency: currency,\n itemsAmount: total,\n });\n stripeStore.isFetchingSession = false;\n};\n\nconst cartStoreResetSelectedShippingOption = () => {\n cartStore.selectedShippingOption = null;\n cartStore.isSelectedShippingAboveDeminimis = false;\n cartStore.isSelectedShippingGuarantee = false;\n cartStore.selectedShippingOptionExpectedDate = '';\n cartStore.selectedShippingOptionTransitTime = '';\n cartStore.shipping = 0;\n};\n\nconst cartStoreNextStep = () => {\n if (cartStore.step === 'customer-info') {\n cartStore.step = 'shipping';\n } else if (cartStore.step === 'shipping') {\n cartStore.step = 'payment';\n } else if (cartStore.step === 'payment') {\n cartStore.step = 'finish';\n }\n};\n\nconst cartStorePreviousStep = () => {\n if (cartStore.step === 'payment') {\n cartStore.step = 'shipping';\n } else if (cartStore.step === 'shipping') {\n cartStore.step = 'customer-info';\n // reset selected shipping option\n cartStoreResetSelectedShippingOption();\n }\n};\n\nexport {\n cartStore,\n cartStoreApplySubtotals,\n cartStoreGetShippingTransitInfo,\n cartStoreNextStep,\n cartStorePreviousStep,\n cartStoreReCalculateTotal,\n cartStoreReset,\n cartStoreUpdateItems,\n cartStoreUpdateSelectedShippingOption,\n cartStoreUpdateToErrorState,\n};\n"],"version":3}
@@ -0,0 +1,2 @@
1
+ var __awaiter=this&&this.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r["throw"](e))}catch(e){o(e)}}function c(e){e.done?n(e.value):i(e.value).then(s,a)}c((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(e){return function(t){return c([e,t])}}function c(a){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./zonosStore-77bcd7c0.system.js","./localization-3c43290f.system.js","./isDarkColor-dc2b7c8f.system.js","./getBorderRadius-4fbe49de.system.js"],(function(e){"use strict";var t,n,r,i,o,s,a,c,l;return{setters:[function(e){t=e.c;n=e.z},function(e){r=e.h;i=e.l;o=e.a;s=e.b;a=e.t},function(e){c=e.i},function(e){l=e.g}],execute:function(){var u=this;var d=function(){var e=y.stripeLinkEventData;var t=y.stripeAddressEventData;if(!t||!t.complete){throw new Error("Missing stripe address data")}return{checkoutSessionId:j.checkoutSessionId||"",contact:{email:(e===null||e===void 0?void 0:e.value.email)||"",firstName:t.value.firstName||"",lastName:t.value.lastName||"",phone:t.value.phone||""},items:j.items.map((function(e){return{amount:e.amount,countryOfOrigin:e.countryOfOrigin,currencyCode:e.currencyCode,imageUrl:e.imageUrl,name:e.name,productId:e.productId,quantity:e.quantity}})),shippingAddress:{addressLine1:t.value.address.line1,addressLine2:t.value.address.line2||"",city:t.value.address.city,country:t.value.address.country,postalCode:t.value.address.postal_code,state:t.value.address.state}}};var p=function(e){return __awaiter(u,void 0,void 0,(function(){var t,n,i,o;return __generator(this,(function(s){switch(s.label){case 0:t="".concat("https://route.js.zonos.com","/api/calculate-landed-cost");return[4,r(t,{body:d(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 1:n=s.sent(),i=n.errors,o=n.json;if(i.length||!o){throw new Error("Failed to calculate landed cost")}return[2,o]}}))}))};var v=function(e){var t=e.theme;switch(t){default:return{".Input":{padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"}}}};var f=function(e){var t=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:l(t),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:l(t)}}};var h=t((function(){return{clientSecret:sessionStorage.getItem("zonos--client-secret")||null,fetchingLandedCostAbordController:null,isFetchingLandedCost:false,isFetchingSession:false,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenFetchingLC:null,stripeElements:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null}})),m=h.onChange,g=h.reset,y=h.state;e("s",y);var C=function(e){var t=e.clientSecret,r=e.overrideBorderRaidus,i=e.overridePrimaryColor,s=e.overrideTheme;var a=i||n.appearance.colorPrimary;var l=a&&c(a)?"night":"flat";var u=s==="DARK"?"night":"flat";return{appearance:{labels:"floating",rules:Object.assign({},v({theme:"LIGHT"})),theme:s?u:l,variables:Object.assign({},f({borderStyle:r,theme:"LIGHT"}))},clientSecret:t,locale:o.selectedLocale}};var S=e("i",(function(e){return __awaiter(u,void 0,void 0,(function(){var t,n,r;return __generator(this,(function(o){n=y.clientSecret;if(!y.stripe){i("Skip. Stripe is not initialized");return[2]}if(n){r=C({clientSecret:n,overrideBorderRaidus:e===null||e===void 0?void 0:e.overrideBorderRaidus,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme});if(!y.stripeElements){y.stripeElements=(t=y.stripe)===null||t===void 0?void 0:t.elements(r)}else{y.stripeElements.update(r)}i("Stripe elements initialized")}return[2]}))}))}));var b=e("j",(function(){sessionStorage.removeItem("zonos--client-secret");g();y.stripe=window.Zonos.stripe}));var w=function(){var e,t,n,r;var i=y.fetchingLandedCostAbordController;if(!i){return false}var o=JSON.stringify((e=y.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=y.stripeLinkEventData)===null||t===void 0?void 0:t.value);var s=JSON.stringify((n=y.stripeAddressUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((r=y.stripeAddressEventData)===null||r===void 0?void 0:r.value);return o||s};var _=e("f",(function(){return __awaiter(u,void 0,void 0,(function(){var e,t,n,r,i,o,a,c,l,u,d,v,f,h;return __generator(this,(function(m){switch(m.label){case 0:i=!!((e=y.stripeAddressEventData)===null||e===void 0?void 0:e.complete);o=!!((t=y.stripeLinkEventData)===null||t===void 0?void 0:t.complete);a=w();if(a){(n=y.fetchingLandedCostAbordController)===null||n===void 0?void 0:n.abort();y.fetchingLandedCostAbordController=null}if(!(i&&o&&(a||!y.isFetchingLandedCost)))return[3,5];y.isFetchingLandedCost=true;if(y.stripeAddressEventData){y.stripeAddressUsedWhenFetchingLC=Object.assign({},y.stripeAddressEventData)}if(y.stripeLinkEventData){y.stripeLinkUsedWhenFetchingLC=Object.assign({},y.stripeLinkEventData)}m.label=1;case 1:m.trys.push([1,3,,4]);c=new AbortController;y.fetchingLandedCostAbordController=c;return[4,p(c)];case 2:l=m.sent(),u=l.checkoutSessionWorkflow,d=l.shipmentRatingCalculateWorkflow;y.fetchingLandedCostAbordController=null;j.landedCostData=(u===null||u===void 0?void 0:u.filter(Boolean))||null;j.shippingData=(d===null||d===void 0?void 0:d.filter(Boolean))||null;v=(r=j.landedCostData)===null||r===void 0?void 0:r.find(Boolean);f=!!v?v.subtotals:null;if(f){B({exchangeRate:f.exchangeRate,items:f.items,landedCostTotal:0,presentmentCurrencyCode:f.presentmentCurrencyCode,shipping:0,total:f.items})}return[3,4];case 3:h=m.sent();s(h);return[3,4];case 4:y.isFetchingLandedCost=false;m.label=5;case 5:return[2]}}))}))}));var k=function(e){var t=[];var n=true;switch(e){case"succeeded":{t=[a("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"","",a("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];n=false;break}case"requires_capture":case"processing":{t=[a("Payment processing. We'll update you when payment is received.")];n=false;break}case"requires_payment_method":{t=[a("Payment failed. Please try another payment method.")];break}default:{t=[a("Something went wrong.")];break}}return{isError:n,messages:t}};var A=e("l",(function(e){var t=e.clientSecret,n=e.storybookForceStatus;return __awaiter(u,void 0,void 0,(function(){var e,r,i,o,c,l,u,d,p;return __generator(this,(function(v){switch(v.label){case 0:if(n){e=k(n),r=e.isError,i=e.messages;return[2,{error:r,messages:i}]}o=t||y.clientSecret;if(!y.stripe||!o){s("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[a("Something went wrong.")]}]}return[4,y.stripe.retrievePaymentIntent(o)];case 1:c=v.sent().paymentIntent;l=c===null||c===void 0?void 0:c.status;u=k(l),d=u.isError,p=u.messages;return[2,{error:d,messages:p}]}}))}))}));var E=e("h",(function(){return __awaiter(u,void 0,void 0,(function(){var e,t,n,r,i,o,s,a;return __generator(this,(function(c){switch(c.label){case 0:r=!!((e=y.stripePaymentEventData)===null||e===void 0?void 0:e.complete);i=y.stripeElements;o=y.stripe;s=y.clientSecret;if(!(o&&i&&r&&s))return[3,2];return[4,o.confirmPayment({confirmParams:{receipt_email:(n=(t=y.stripeLinkEventData)===null||t===void 0?void 0:t.value)===null||n===void 0?void 0:n.email,return_url:window.location.href},elements:i,redirect:"if_required"})];case 1:a=c.sent().error;if(a){if(a.type==="card_error"||a.type==="validation_error"){throw new Error(a.message)}if(a.type==="invalid_request_error"){if(a.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}c.label=2;case 2:return[2]}}))}))}));var T=e("d",(function(){return __awaiter(u,void 0,void 0,(function(){var e,t,n,a,c,l;return __generator(this,(function(u){switch(u.label){case 0:t=j.items.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!t||!o.targetCurrency){s("Fail to create checkout session - invalid total or currency");return[2,false]}y.isFetchingSession=true;return[4,r("".concat("https://route.js.zonos.com","/api/create-checkout-session"),{body:{currency:((e=j.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",itemsAmount:t,presentmentCountryCode:o.selectedCountryCode||null},method:"POST"})];case 1:n=u.sent(),a=n.errors,c=n.json;y.isFetchingSession=false;if(a.length||!c){s("Error occurs when creating checkout session",JSON.stringify(a,null,2));return[2,false]}l=c.checkoutSessionCreate;y.clientSecret=l.clientSecret;j.checkoutSessionId=l.id;B(Object.assign(Object.assign({},l.subtotals),{landedCostTotal:0,shipping:0,total:l.subtotals.items}));i("Exchange rate updated for cart items (checkout session create)","info",j.exchangeRate);i("done-init-checkout-session");return[2,true]}}))}))}));var D=function(e){var t=e.currency,n=e.id,i=e.itemsAmount,o=e.landedCostId,a=e.presentmentCountryCode;return __awaiter(u,void 0,void 0,(function(){var e,c,l;return __generator(this,(function(u){switch(u.label){case 0:return[4,r("".concat("https://route.js.zonos.com","/api/update-checkout-session"),{body:{currency:t,id:n,itemsAmount:i,landedCostId:o,presentmentCountryCode:a},method:"POST"})];case 1:e=u.sent(),c=e.errors,l=e.json;if(c.length||!l){s("Error occurs when updating checkout session",JSON.stringify(c,null,2));return[2,{errors:c,json:l}]}return[2,{errors:[],json:l}]}}))}))};m("clientSecret",(function(e){if(e&&y.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var x=function(e){var t=e.date,n=e.formatOptions,r=n===void 0?{day:"numeric",weekday:"long",year:"numeric"}:n;return new Intl.DateTimeFormat("en-US",r).format(t)};var L=function(e){var t=new Date;var n=e.getTime()-t.getTime();var r=Math.floor(n/(1e3*60*60*24));return r};var O=t((function(){return{checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id")||null,currency:"USD",dutiesTaxFees:0,error:null,exchangeRate:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,items:[],landedCostData:null,selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,step:"customer-info",subtotal:0,total:0}})),I=O.onChange,F=O.reset,j=O.state;e("c",j);var P=e("n",(function(e){var t=e.minTransitAt?L(new Date(e.minTransitAt)):"";var n=e.maxTransitAt?L(new Date(e.maxTransitAt)):"";var r=e.minTransitAt?x({date:new Date(e.minTransitAt)}):"";return{expectedDate:r,maxTransit:n,minTransit:t}}));var R=e("b",(function(){sessionStorage.removeItem("zonos--checkout-session-id");F()}));var z=e("e",(function(e){var t=e.messages,n=e.title;j.step="error";j.error={messages:t,title:n}}));var B=function(e){j.exchangeRate=e.exchangeRate;j.dutiesTaxFees=e.landedCostTotal;j.subtotal=e.items;j.total=e.total;j.currency=e.presentmentCurrencyCode};var U=function(e){var t=e.currency,n=e.itemsAmount,r=e.landedCostId;return __awaiter(u,void 0,void 0,(function(){var e,c;return __generator(this,(function(l){switch(l.label){case 0:if(r&&j.selectedLandedCost){e=j.selectedLandedCost.subtotals;B(e);i("Exchange rate updated for cart items (landed cost subtotal)","info",j.exchangeRate)}if(!j.checkoutSessionId){s("Could update cart total without checkout session id");return[2,false]}return[4,D({currency:t,id:j.checkoutSessionId,itemsAmount:n,landedCostId:r,presentmentCountryCode:o.selectedCountryCode})];case 1:c=l.sent().json;if(!c){s("Error occurs when updating checkout session");z({messages:[a("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error updating Checkout")});return[2,false]}if(!r){B(c.checkoutSessionUpdate.subtotals);i("Exchange rate updated for cart items (checkout session update)","info",j.exchangeRate)}return[2,true]}}))}))};var N=e("m",(function(e){return __awaiter(u,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,l,u,d,p,v;return __generator(this,(function(f){switch(f.label){case 0:j.selectedShippingOption=e;s=P(j.selectedShippingOption),a=s.expectedDate,c=s.maxTransit,l=s.minTransit;j.selectedShippingOptionExpectedDate=a;j.selectedShippingOptionTransitTime=l&&c?"".concat(l,"-").concat(c):"".concat(l||c);u=(t=j.landedCostData)===null||t===void 0?void 0:t.find((function(e){var t,n,r;return((n=(t=e.landedCost)===null||t===void 0?void 0:t.shipmentRating)===null||n===void 0?void 0:n.id)===((r=j.selectedShippingOption)===null||r===void 0?void 0:r.id)}));j.selectedLandedCost=u||null;if(!u){return[2,false]}j.shipping=u.subtotals.shipping;d=((n=u===null||u===void 0?void 0:u.landedCost)===null||n===void 0?void 0:n.landedCostGuaranteeCode)==="ZONOS";p=!!((i=(r=u===null||u===void 0?void 0:u.landedCost)===null||r===void 0?void 0:r.deMinimis)===null||i===void 0?void 0:i.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));j.isSelectedShippingAboveDeminimis=p;j.isSelectedShippingGuarantee=d;return[4,U({landedCostId:(o=u.landedCost)===null||o===void 0?void 0:o.id})];case 1:v=f.sent();return[2,v]}}))}))}));I("checkoutSessionId",(function(){if(!j.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",j.checkoutSessionId)}));var W=e("a",(function(e){return __awaiter(u,void 0,void 0,(function(){var t,n,r;return __generator(this,(function(i){switch(i.label){case 0:j.items=e;n=(t=e.find(Boolean))===null||t===void 0?void 0:t.currencyCode;r=e.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!n||!r){return[2]}j.currency=n;y.isFetchingSession=true;return[4,U({currency:n,itemsAmount:r})];case 1:i.sent();y.isFetchingSession=false;return[2]}}))}))}));var q=function(){j.selectedShippingOption=null;j.isSelectedShippingAboveDeminimis=false;j.isSelectedShippingGuarantee=false;j.selectedShippingOptionExpectedDate="";j.selectedShippingOptionTransitTime="";j.shipping=0};var G=e("g",(function(){if(j.step==="customer-info"){j.step="shipping"}else if(j.step==="shipping"){j.step="payment"}else if(j.step==="payment"){j.step="finish"}}));var J=e("k",(function(){if(j.step==="payment"){j.step="shipping"}else if(j.step==="shipping"){j.step="customer-info";q()}}))}}}));
2
+ //# sourceMappingURL=cart-9780fa28.system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["prepCalculateLandedCost","stripeLinkData","stripeStore","stripeLinkEventData","stripeAddressData","stripeAddressEventData","complete","Error","checkoutSessionId","cartStore","contact","email","value","firstName","lastName","phone","items","map","item","amount","countryOfOrigin","currencyCode","imageUrl","name","productId","quantity","shippingAddress","addressLine1","address","line1","addressLine2","line2","city","country","postalCode","postal_code","state","calculateLandedCost","abortController","__awaiter","_this","url","concat","handleFetch","body","method","signal","_f","_g","sent","errors","json","length","addressRuleStyle","theme","padding","paddingBottom","paddingLeft","paddingRight","paddingTop","defaultVariable","borderStyle","borderRadius","getBorderRadius","colorBackground","colorBackgroundText","colorText","colorTextPlaceholder","createStore","clientSecret","sessionStorage","getItem","fetchingLandedCostAbordController","isFetchingLandedCost","isFetchingSession","stripe","stripeAddressElement","stripeAddressUsedWhenFetchingLC","stripeElements","stripeLinkElement","stripeLinkUsedWhenFetchingLC","stripePaymentElement","stripePaymentEventData","onChange","reset","exports","getStripeOptions","overrideBorderRaidus","overridePrimaryColor","overrideTheme","primaryColor","zonosStore","appearance","colorPrimary","themeBasedColor","isDarkColor","labels","rules","Object","assign","variables","locale","localizationStore","selectedLocale","initStripeElements","props","log","stripeOptions","_a","elements","update","stripeStoreReset","removeItem","window","Zonos","isPrefetchInfoOutdated","hasAbortController","isLinkDataDirty","JSON","stringify","_b","isAddressDataDirty","_c","_d","stripeStorePrefetchLandedCost","stripeAddressReady","stripeLinkReady","shouldRefetch","abort","AbortController","checkoutSessionWorkflow","shipmentRatingCalculateWorkflow","landedCostData","filter","Boolean","shippingData","firstLandedCostData","find","subtotals","cartStoreApplySubtotals","exchangeRate","landedCostTotal","presentmentCurrencyCode","shipping","total","logError","err_1","getStripeMessageBasedOnStatus","status","messages","isError","translate","stripeStoreRetrievePayment","_clientSecret","storybookForceStatus","isError_1","messages_1","error","message","retrievePaymentIntent","paymentIntent","_j","_h","stripeStoreConfirmPayment","stripePaymentReady","stripeClientSecret","confirmPayment","confirmParams","receipt_email","return_url","location","href","redirect","type","code","stripeStoreInitCheckoutSession","reduce","targetCurrency","currency","itemsAmount","presentmentCountryCode","selectedCountryCode","result","checkoutSessionCreate","id","stripeStoreUpdateCheckoutSession","landedCostId","setItem","formatDate","date","formatOptions","day","weekday","year","Intl","DateTimeFormat","format","getDaysDifference","targetDate","currentDate","Date","timeDifference","getTime","daysDifference","Math","floor","dutiesTaxFees","isSelectedShippingAboveDeminimis","isSelectedShippingGuarantee","selectedLandedCost","selectedShippingOption","selectedShippingOptionExpectedDate","selectedShippingOptionTransitTime","step","subtotal","cartStoreGetShippingTransitInfo","minTransit","minTransitAt","maxTransit","maxTransitAt","expectedDate","cartStoreReset","cartStoreUpdateToErrorState","title","cartStoreReCalculateTotal","checkoutSessionUpdate","cartStoreUpdateSelectedShippingOption","checkoutSessionPresentment","landedCost","shipmentRating","isGuarantee","landedCostGuaranteeCode","isAboveDeminimis","deMinimis","includes","threshold","_e","updateCalulateStatus","cartStoreUpdateItems","amt","cartStoreResetSelectedShippingOption","cartStoreNextStep","cartStorePreviousStep"],"sources":["src/components/utils/api/prepCalculateLandedCost.ts","src/components/utils/api/calculateLandedCost.ts","src/styles/stripe/addressRuleStyle.ts","src/styles/stripe/defaultVariable.ts","src/components/store/checkout/stripe.ts","src/components/utils/formatDate.ts","src/components/utils/getDaysDifference.ts","src/components/store/checkout/cart.ts"],"sourcesContent":["import { cartStore } from 'src/components/store/checkout/cart';\nimport { stripeStore } from 'src/components/store/checkout/stripe';\nimport type { CalculateLandedCostRequest } from 'src/types/checkout/api/CalculateLandedCostRequest';\n\nexport const prepCalculateLandedCost = (): CalculateLandedCostRequest => {\n // maybe we don't need email now for prefetch the landed cost\n const stripeLinkData = stripeStore.stripeLinkEventData;\n\n const stripeAddressData = stripeStore.stripeAddressEventData;\n if (!stripeAddressData || !stripeAddressData.complete) {\n throw new Error('Missing stripe address data');\n }\n\n return {\n checkoutSessionId: cartStore.checkoutSessionId || '',\n contact: {\n email: stripeLinkData?.value.email || '',\n // firstName and lastName should be valid now since stripe only mark\n // the address as complete when both fields are filled.\n firstName: stripeAddressData.value.firstName || '',\n lastName: stripeAddressData.value.lastName || '',\n phone: stripeAddressData.value.phone || '',\n },\n items: cartStore.items.map(item => ({\n amount: item.amount,\n countryOfOrigin: item.countryOfOrigin,\n currencyCode: item.currencyCode,\n imageUrl: item.imageUrl,\n name: item.name,\n productId: item.productId,\n quantity: item.quantity,\n })),\n shippingAddress: {\n addressLine1: stripeAddressData.value.address.line1,\n addressLine2: stripeAddressData.value.address.line2 || '',\n city: stripeAddressData.value.address.city,\n country: stripeAddressData.value.address.country,\n postalCode: stripeAddressData.value.address.postal_code,\n state: stripeAddressData.value.address.state,\n },\n };\n};\n","import { prepCalculateLandedCost } from 'src/components/utils/api/prepCalculateLandedCost';\nimport { handleFetch } from 'src/components/utils/handleFetch';\nimport type { CalculateLandedCostRequest } from 'src/types/checkout/api/CalculateLandedCostRequest';\nimport type { CalculateLandedCostMutation } from 'src/types/generated/graphql.customer.types';\n\nexport const calculateLandedCost = async (\n abortController?: AbortController,\n) => {\n // request to get landed cost info\n const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/calculate-landed-cost`;\n const { errors, json } = await handleFetch<\n CalculateLandedCostMutation,\n CalculateLandedCostRequest\n >(url, {\n body: prepCalculateLandedCost(),\n method: 'POST',\n signal: abortController?.signal,\n });\n if (errors.length || !json) {\n throw new Error('Failed to calculate landed cost');\n }\n\n return json;\n};\n","import type { ElementsUiTheme, StripeRuleType } from 'src/types';\n\nexport const addressRuleStyle = ({\n theme,\n}: {\n theme: ElementsUiTheme;\n}): StripeRuleType => {\n switch (theme) {\n default:\n return {\n '.Input': {\n // need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.\n padding: '0',\n paddingBottom: '8px',\n paddingLeft: '16px',\n paddingRight: '8px',\n // any value here will be add up to the default paddingTop (20px).\n paddingTop: '6px',\n },\n };\n }\n};\n","import type { Appearance } from '@stripe/stripe-js';\n\nimport { getBorderRadius } from 'src/components/utils/getBorderRadius';\nimport type {\n ElementsUiStyle,\n ElementsUiTheme,\n} from 'src/types/generated/graphql.customer.types';\n\nexport const defaultVariable = ({\n borderStyle,\n theme,\n}: {\n borderStyle?: ElementsUiStyle;\n theme: ElementsUiTheme;\n}): Appearance['variables'] => {\n switch (theme) {\n case 'DARK':\n return {\n borderRadius: getBorderRadius(borderStyle),\n colorBackground: '#101117',\n colorBackgroundText: '#C5C6CA',\n colorText: '#C5C6CA',\n colorTextPlaceholder: '#C5C6CA',\n };\n default:\n return {\n borderRadius: getBorderRadius(borderStyle),\n };\n }\n};\n","import { createStore } from '@stencil/store';\nimport type {\n PaymentIntent,\n Stripe,\n StripeAddressElement,\n StripeAddressElementChangeEvent,\n StripeElements,\n StripeElementsOptionsClientSecret,\n StripeLinkAuthenticationElement,\n StripeLinkAuthenticationElementChangeEvent,\n StripePaymentElement,\n StripePaymentElementChangeEvent,\n} from '@stripe/stripe-js';\n\nimport {\n cartStore,\n cartStoreApplySubtotals,\n} from 'src/components/store/checkout/cart';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport { zonosStore } from 'src/components/store/zonosStore';\nimport { calculateLandedCost } from 'src/components/utils/api/calculateLandedCost';\nimport { handleFetch } from 'src/components/utils/handleFetch';\nimport { isDarkColor } from 'src/components/utils/isDarkColor';\nimport { log } from 'src/components/utils/logging/log';\nimport { logError } from 'src/components/utils/logging/logError';\nimport { addressRuleStyle } from 'src/styles/stripe/addressRuleStyle';\nimport { defaultVariable } from 'src/styles/stripe/defaultVariable';\nimport type {\n CheckoutSessionCreateMutation,\n CheckoutSessionUpdateMutation,\n CountryCode,\n ElementsUiStyle,\n ElementsUiTheme,\n} from 'src/types/generated/graphql.customer.types';\n\nexport type ContactOption = {\n address: {\n city: string;\n country: string;\n line1: string;\n line2?: string;\n postal_code: string;\n state: string;\n };\n name: string;\n phone?: string;\n};\n\ntype StripeStore = {\n // client secret is used to render link and payment elements\n clientSecret: string | null;\n fetchingLandedCostAbordController: AbortController | null;\n // toggle to indicate if we are pre-fetching/fetching landed cost\n isFetchingLandedCost: boolean;\n // toggle to indicate if we are fetching checkout session\n isFetchingSession: boolean;\n stripe: Stripe | null;\n stripeAddressElement: StripeAddressElement | null;\n stripeAddressEventData: StripeAddressElementChangeEvent | null;\n stripeAddressUsedWhenFetchingLC: StripeAddressElementChangeEvent | null;\n stripeElements: StripeElements | null;\n stripeLinkElement: StripeLinkAuthenticationElement | null;\n stripeLinkEventData: StripeLinkAuthenticationElementChangeEvent | null;\n stripeLinkUsedWhenFetchingLC: StripeLinkAuthenticationElementChangeEvent | null;\n stripePaymentElement: StripePaymentElement | null;\n stripePaymentEventData: StripePaymentElementChangeEvent | null;\n};\n\nconst {\n onChange,\n reset,\n state: stripeStore,\n} = createStore<StripeStore>(() => ({\n clientSecret: sessionStorage.getItem('zonos--client-secret') || null,\n fetchingLandedCostAbordController: null,\n isFetchingLandedCost: false,\n isFetchingSession: false,\n stripe: null,\n stripeAddressElement: null,\n stripeAddressEventData: null,\n stripeAddressUsedWhenFetchingLC: null,\n stripeElements: null,\n stripeLinkElement: null,\n stripeLinkEventData: null,\n stripeLinkUsedWhenFetchingLC: null,\n stripePaymentElement: null,\n stripePaymentEventData: null,\n}));\n\nconst getStripeOptions = ({\n clientSecret,\n overrideBorderRaidus,\n overridePrimaryColor,\n overrideTheme,\n}: {\n clientSecret?: string;\n overrideBorderRaidus?: ElementsUiStyle;\n overridePrimaryColor?: string;\n overrideTheme?: ElementsUiTheme;\n}): StripeElementsOptionsClientSecret => {\n const primaryColor =\n overridePrimaryColor || zonosStore.appearance.colorPrimary;\n const themeBasedColor =\n primaryColor && isDarkColor(primaryColor) ? 'night' : 'flat';\n // if overrideTheme is provided, use it. Otherwise, use theme based on primary color\n const theme = overrideTheme === 'DARK' ? 'night' : 'flat';\n return {\n appearance: {\n labels: 'floating',\n rules: {\n ...addressRuleStyle({ theme: 'LIGHT' }),\n },\n // get contrast theme color base on primary color\n theme: overrideTheme ? theme : themeBasedColor,\n variables: {\n ...defaultVariable({\n borderStyle: overrideBorderRaidus,\n theme: 'LIGHT',\n }),\n },\n },\n clientSecret,\n locale: localizationStore.selectedLocale,\n };\n};\n\nconst initStripeElements = async (props?: {\n overrideBorderRaidus?: ElementsUiStyle;\n overridePrimaryColor?: string;\n overrideTheme?: ElementsUiTheme;\n}) => {\n const clientSecret = stripeStore.clientSecret;\n\n if (!stripeStore.stripe) {\n log('Skip. Stripe is not initialized');\n return;\n }\n if (clientSecret) {\n const stripeOptions = getStripeOptions({\n clientSecret,\n overrideBorderRaidus: props?.overrideBorderRaidus,\n overridePrimaryColor: props?.overridePrimaryColor,\n overrideTheme: props?.overrideTheme,\n });\n\n if (!stripeStore.stripeElements) {\n // init stripe elements if it doesn't exist\n stripeStore.stripeElements = stripeStore.stripe?.elements(stripeOptions);\n } else {\n // update elements with new option if it already exists\n stripeStore.stripeElements.update(stripeOptions);\n }\n log('Stripe elements initialized');\n }\n};\n\nconst stripeStoreReset = () => {\n // clean clientSecret so that we can start the new one.\n sessionStorage.removeItem('zonos--client-secret');\n\n // cleanup stripe elements\n reset();\n // set stripe back to window.Zonos.stripe\n stripeStore.stripe = window.Zonos.stripe;\n};\n\n/**\n * Check if the address and email info used when fetching landed cost with the current email and address info are different\n * Purpose is to resend the request if the info used when fetching landed cost is different from the current info\n */\nconst isPrefetchInfoOutdated = () => {\n const hasAbortController = stripeStore.fetchingLandedCostAbordController;\n if (!hasAbortController) {\n // if there is no abort controller, this is a new request\n return false;\n }\n\n const isLinkDataDirty =\n JSON.stringify(stripeStore.stripeLinkUsedWhenFetchingLC?.value) !==\n JSON.stringify(stripeStore.stripeLinkEventData?.value);\n const isAddressDataDirty =\n JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC?.value) !==\n JSON.stringify(stripeStore.stripeAddressEventData?.value);\n\n return isLinkDataDirty || isAddressDataDirty;\n};\n\nconst stripeStorePrefetchLandedCost = async () => {\n const stripeAddressReady = !!stripeStore.stripeAddressEventData?.complete;\n const stripeLinkReady = !!stripeStore.stripeLinkEventData?.complete;\n const shouldRefetch = isPrefetchInfoOutdated();\n\n if (shouldRefetch) {\n // if the info used when fetching landed cost is different from the current info, abort the previous request\n stripeStore.fetchingLandedCostAbordController?.abort();\n stripeStore.fetchingLandedCostAbordController = null;\n }\n\n // only fetch if we are not fetching or we need to refetch\n if (\n stripeAddressReady &&\n stripeLinkReady &&\n (shouldRefetch || !stripeStore.isFetchingLandedCost)\n ) {\n stripeStore.isFetchingLandedCost = true;\n if (stripeStore.stripeAddressEventData) {\n stripeStore.stripeAddressUsedWhenFetchingLC = {\n ...stripeStore.stripeAddressEventData,\n };\n }\n if (stripeStore.stripeLinkEventData) {\n stripeStore.stripeLinkUsedWhenFetchingLC = {\n ...stripeStore.stripeLinkEventData,\n };\n }\n try {\n const abortController = new AbortController();\n stripeStore.fetchingLandedCostAbordController = abortController;\n const { checkoutSessionWorkflow, shipmentRatingCalculateWorkflow } =\n await calculateLandedCost(abortController);\n\n // reset abort controller after we are done\n stripeStore.fetchingLandedCostAbordController = null;\n\n // update cart store with landed cost info\n cartStore.landedCostData =\n checkoutSessionWorkflow?.filter(Boolean) || null;\n\n cartStore.shippingData =\n shipmentRatingCalculateWorkflow?.filter(Boolean) || null;\n // apply new subtotal and total, this is mainly to show items in the presentment currency\n const firstLandedCostData = cartStore.landedCostData?.find(Boolean);\n const subtotals = !!firstLandedCostData\n ? firstLandedCostData.subtotals\n : null;\n if (subtotals) {\n // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet\n cartStoreApplySubtotals({\n exchangeRate: subtotals.exchangeRate,\n items: subtotals.items,\n landedCostTotal: 0,\n presentmentCurrencyCode: subtotals.presentmentCurrencyCode,\n shipping: 0,\n total: subtotals.items,\n });\n }\n } catch (err) {\n logError(err);\n }\n stripeStore.isFetchingLandedCost = false;\n }\n};\n\nconst getStripeMessageBasedOnStatus = (status?: PaymentIntent['status']) => {\n let messages: string[] = [];\n let isError = true;\n // Inspect the PaymentIntent `status` to indicate the status of the payment\n // to your customer.\n //\n // Some payment methods will [immediately succeed or fail][0] upon\n // confirmation, while others will first enter a `processing` state.\n //\n // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification\n switch (status) {\n case 'succeeded': {\n messages = [\n translate(\n 'Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us.',\n ),\n '',\n '',\n translate(\n \"We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.\",\n ),\n ];\n isError = false;\n break;\n }\n case 'requires_capture':\n case 'processing': {\n messages = [\n translate(\n \"Payment processing. We'll update you when payment is received.\",\n ),\n ];\n isError = false;\n break;\n }\n\n case 'requires_payment_method': {\n messages = [\n translate('Payment failed. Please try another payment method.'),\n ];\n break;\n }\n\n default: {\n messages = [translate('Something went wrong.')];\n break;\n }\n }\n return {\n isError,\n messages,\n };\n};\n\nconst stripeStoreRetrievePayment = async ({\n clientSecret: _clientSecret,\n storybookForceStatus,\n}: {\n clientSecret: string | null;\n storybookForceStatus?: PaymentIntent['status'];\n}) => {\n if (storybookForceStatus) {\n // return status right away if we are in storybook mode\n const { isError, messages } =\n getStripeMessageBasedOnStatus(storybookForceStatus);\n\n return { error: isError, messages };\n }\n const clientSecret = _clientSecret || stripeStore.clientSecret;\n if (!stripeStore.stripe || !clientSecret) {\n logError('Failed to retrieve payment intent. Stripe is not initialized');\n return { error: true, message: [translate('Something went wrong.')] };\n }\n const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(\n clientSecret,\n );\n\n const status = paymentIntent?.status;\n\n const { isError, messages } = getStripeMessageBasedOnStatus(status);\n\n return { error: isError, messages };\n};\n\nconst stripeStoreConfirmPayment = async () => {\n const stripePaymentReady = !!stripeStore.stripePaymentEventData?.complete;\n const stripeElements = stripeStore.stripeElements;\n const stripe = stripeStore.stripe;\n const stripeClientSecret = stripeStore.clientSecret;\n if (stripe && stripeElements && stripePaymentReady && stripeClientSecret) {\n const { error } = await stripe.confirmPayment({\n confirmParams: {\n receipt_email: stripeStore.stripeLinkEventData?.value?.email,\n return_url: window.location.href,\n },\n elements: stripeElements,\n redirect: 'if_required',\n });\n\n if (error) {\n if (error.type === 'card_error' || error.type === 'validation_error') {\n throw new Error(error.message);\n }\n if (error.type === 'invalid_request_error') {\n if (error.code === 'payment_intent_unexpected_state') {\n // PaymentIntent was canceled or expired, or status is `require_capture`.\n // don't throw error here because we will reset the checkout session last step\n return;\n }\n }\n throw new Error('An unexpected error occurred.');\n }\n }\n};\n\ntype CheckoutSessionCreateRequest = {\n currency: string;\n itemsAmount: number;\n presentmentCountryCode: CountryCode | null;\n};\n\n/**\n * Init checkout session\n * @returns {boolean} whether or not the checkout session is successfully created\n */\nconst stripeStoreInitCheckoutSession = async () => {\n const total = cartStore.items.reduce(\n (amount, item) => amount + item.amount * item.quantity,\n 0,\n );\n\n if (!total || !localizationStore.targetCurrency) {\n logError('Fail to create checkout session - invalid total or currency');\n return false;\n }\n\n stripeStore.isFetchingSession = true;\n\n const { errors, json } = await handleFetch<\n CheckoutSessionCreateMutation,\n CheckoutSessionCreateRequest\n >(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/create-checkout-session`, {\n body: {\n currency: cartStore.items.find(Boolean)?.currencyCode || '',\n itemsAmount: total,\n presentmentCountryCode: localizationStore.selectedCountryCode || null,\n },\n method: 'POST',\n });\n\n stripeStore.isFetchingSession = false;\n\n if (errors.length || !json) {\n logError(\n 'Error occurs when creating checkout session',\n JSON.stringify(errors, null, 2),\n );\n\n return false;\n }\n const result = json.checkoutSessionCreate;\n\n stripeStore.clientSecret = result.clientSecret;\n // update cart store with updated informations\n cartStore.checkoutSessionId = result.id;\n cartStoreApplySubtotals({\n ...result.subtotals,\n landedCostTotal: 0,\n shipping: 0,\n total: result.subtotals.items,\n });\n log(\n 'Exchange rate updated for cart items (checkout session create)',\n 'info',\n cartStore.exchangeRate,\n );\n\n log('done-init-checkout-session');\n return true;\n};\n\ntype CheckoutSessionUpdateRequest = {\n currency?: string;\n id: string;\n itemsAmount?: number;\n landedCostId?: string;\n presentmentCountryCode: CountryCode | null;\n};\n/**\n * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change\n */\nconst stripeStoreUpdateCheckoutSession = async ({\n currency,\n id,\n itemsAmount,\n landedCostId,\n presentmentCountryCode,\n}: CheckoutSessionUpdateRequest) => {\n // No need to set loading state here because this function will be called under the hood to update\n // landed cost id for the section.\n const { errors, json } = await handleFetch<\n CheckoutSessionUpdateMutation,\n CheckoutSessionUpdateRequest\n >(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/update-checkout-session`, {\n body: {\n currency,\n id,\n itemsAmount,\n landedCostId,\n presentmentCountryCode,\n },\n method: 'POST',\n });\n\n if (errors.length || !json) {\n logError(\n 'Error occurs when updating checkout session',\n JSON.stringify(errors, null, 2),\n );\n return { errors, json };\n }\n\n return { errors: [], json };\n};\n\nonChange('clientSecret', clientSecret => {\n // update stripe elements when client secret changes\n if (clientSecret && stripeStore.stripe) {\n sessionStorage.setItem('zonos--client-secret', clientSecret);\n }\n\n if (!clientSecret) {\n sessionStorage.removeItem('zonos--client-secret');\n }\n});\n\nexport {\n initStripeElements,\n stripeStore,\n stripeStoreConfirmPayment,\n stripeStoreInitCheckoutSession,\n stripeStorePrefetchLandedCost,\n stripeStoreReset,\n stripeStoreRetrievePayment,\n stripeStoreUpdateCheckoutSession,\n};\n","type Params = {\n date: Date;\n /**\n * Format options for Intl.DateTimeFormat\n * @default {day:'numeric',weekday:'long',year:'numeric'} Thursday 3, 2023\n */\n formatOptions?: Intl.DateTimeFormatOptions;\n};\n\nexport const formatDate = ({\n date,\n formatOptions = { day: 'numeric', weekday: 'long', year: 'numeric' },\n}: Params): string => {\n // format date to Thursday 3, 2023\n return new Intl.DateTimeFormat('en-US', formatOptions).format(date);\n};\n","export const getDaysDifference = (targetDate: Date) => {\n const currentDate = new Date();\n const timeDifference = targetDate.getTime() - currentDate.getTime();\n const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); // Convert milliseconds to days\n return daysDifference;\n};\n","import { createStore } from '@stencil/store';\n\nimport {\n stripeStore,\n stripeStoreUpdateCheckoutSession,\n} from 'src/components/store/checkout/stripe';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport { formatDate } from 'src/components/utils/formatDate';\nimport { getDaysDifference } from 'src/components/utils/getDaysDifference';\nimport { log } from 'src/components/utils/logging/log';\nimport { logError } from 'src/components/utils/logging/logError';\nimport type {\n CheckoutPresentmentFragment,\n CurrencyCode,\n ShipmentRatingFragment,\n} from 'src/types/generated/graphql.customer.types';\n\nexport type CartItem = {\n amount: number;\n countryOfOrigin?: string;\n currencyCode: string;\n description?: string;\n hsCode?: string;\n imageUrl?: string;\n name: string;\n productId?: string;\n quantity: number;\n};\n\ntype CartStore = {\n checkoutSessionId: string | null;\n currency: CurrencyCode;\n dutiesTaxFees: number;\n error: {\n messages: string[];\n title: string;\n } | null;\n exchangeRate: {\n id: string;\n rate: number;\n sourceCurrencyCode: CurrencyCode;\n targetCurrencyCode: CurrencyCode;\n type: string;\n } | null;\n isSelectedShippingAboveDeminimis: boolean;\n isSelectedShippingGuarantee: boolean;\n items: CartItem[];\n landedCostData: CheckoutPresentmentFragment[] | null;\n selectedLandedCost: CheckoutPresentmentFragment | null;\n selectedShippingOption: ShipmentRatingFragment | null;\n selectedShippingOptionExpectedDate: string;\n selectedShippingOptionTransitTime: string;\n shipping: number;\n shippingData: ShipmentRatingFragment[] | null;\n step: 'customer-info' | 'shipping' | 'payment' | 'finish' | 'error';\n subtotal: number;\n total: number;\n};\n\nconst {\n onChange,\n reset,\n state: cartStore,\n} = createStore<CartStore>(() => ({\n checkoutSessionId:\n sessionStorage.getItem('zonos--checkout-session-id') || null,\n currency: 'USD',\n dutiesTaxFees: 0,\n error: null,\n exchangeRate: null,\n isSelectedShippingAboveDeminimis: false,\n isSelectedShippingGuarantee: false,\n items: [],\n landedCostData: null,\n selectedLandedCost: null,\n selectedShippingOption: null,\n selectedShippingOptionExpectedDate: '',\n selectedShippingOptionTransitTime: '',\n shipping: 0,\n shippingData: null,\n step: 'customer-info',\n subtotal: 0,\n total: 0,\n}));\n\n/**\n * Format shipping transit info to be displayed on UI\n * @returns\n * - expectedDate: Thursday, Aug 12\n * - maxTransit: 5\n * - minTransit: 3\n */\nconst cartStoreGetShippingTransitInfo = (item: ShipmentRatingFragment) => {\n const minTransit = item.minTransitAt\n ? getDaysDifference(new Date(item.minTransitAt))\n : '';\n const maxTransit = item.maxTransitAt\n ? getDaysDifference(new Date(item.maxTransitAt))\n : '';\n const expectedDate = item.minTransitAt\n ? formatDate({\n date: new Date(item.minTransitAt),\n })\n : '';\n return {\n expectedDate,\n maxTransit,\n minTransit,\n };\n};\n\nconst cartStoreReset = () => {\n sessionStorage.removeItem('zonos--checkout-session-id');\n\n // reset cart store\n reset();\n};\n\nconst cartStoreUpdateToErrorState = ({\n messages,\n title,\n}: {\n messages: string[];\n title: string;\n}) => {\n cartStore.step = 'error';\n cartStore.error = {\n messages,\n title,\n };\n};\n\ntype CartSubtotals = {\n exchangeRate: {\n id: string;\n rate: number;\n sourceCurrencyCode: CurrencyCode;\n targetCurrencyCode: CurrencyCode;\n type: string;\n };\n items: number;\n landedCostTotal: number;\n presentmentCurrencyCode: CurrencyCode;\n shipping: number;\n total: number;\n};\n\nconst cartStoreApplySubtotals = (subtotals: CartSubtotals) => {\n // update exchange rate so we can use it to display cart items\n cartStore.exchangeRate = subtotals.exchangeRate;\n cartStore.dutiesTaxFees = subtotals.landedCostTotal;\n cartStore.subtotal = subtotals.items;\n cartStore.total = subtotals.total;\n cartStore.currency = subtotals.presentmentCurrencyCode;\n};\n\ntype CartStoreRecalculateTotalParams = Omit<\n Parameters<typeof stripeStoreUpdateCheckoutSession>[0],\n 'id' | 'presentmentCountryCode'\n>;\n\nconst cartStoreReCalculateTotal = async ({\n currency,\n itemsAmount,\n landedCostId,\n}: CartStoreRecalculateTotalParams) => {\n if (landedCostId && cartStore.selectedLandedCost) {\n // update cart total right away if we have landed cost id to avoid order total flickering\n const subtotals = cartStore.selectedLandedCost.subtotals;\n cartStoreApplySubtotals(subtotals);\n log(\n 'Exchange rate updated for cart items (landed cost subtotal)',\n 'info',\n cartStore.exchangeRate,\n );\n }\n // update checkout session\n if (!cartStore.checkoutSessionId) {\n logError('Could update cart total without checkout session id');\n return false;\n }\n const { json } = await stripeStoreUpdateCheckoutSession({\n currency,\n id: cartStore.checkoutSessionId,\n itemsAmount,\n landedCostId,\n presentmentCountryCode: localizationStore.selectedCountryCode,\n });\n if (!json) {\n // do nothing if we can't get checkout session\n logError('Error occurs when updating checkout session');\n cartStoreUpdateToErrorState({\n messages: [\n translate(\n \"There's been an error updating your checkout session. Please reload and try again or contact support if the error persists\",\n ),\n ],\n title: translate('Error updating Checkout'),\n });\n return false;\n }\n if (!landedCostId) {\n // This is when first open the checkout modal and we just want to get info from the old cart session.\n // use subtotals from checkout session to update cart total\n cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);\n log(\n 'Exchange rate updated for cart items (checkout session update)',\n 'info',\n cartStore.exchangeRate,\n );\n }\n return true;\n};\n\nconst cartStoreUpdateSelectedShippingOption = async (\n selectedShippingOption: ShipmentRatingFragment,\n) => {\n cartStore.selectedShippingOption = selectedShippingOption;\n\n // update shipping transit info\n const { expectedDate, maxTransit, minTransit } =\n cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);\n cartStore.selectedShippingOptionExpectedDate = expectedDate;\n cartStore.selectedShippingOptionTransitTime =\n minTransit && maxTransit\n ? `${minTransit}-${maxTransit}`\n : `${minTransit || maxTransit}`;\n\n const selectedLandedCost = cartStore.landedCostData?.find(\n checkoutSessionPresentment =>\n checkoutSessionPresentment.landedCost?.shipmentRating?.id ===\n cartStore.selectedShippingOption?.id,\n );\n // save selected landed cost for later use\n cartStore.selectedLandedCost = selectedLandedCost || null;\n\n if (!selectedLandedCost) {\n // do nothing if we can't find landed cost for selected shipping option\n return false;\n }\n\n // update shipping value and dutiesTaxFees on selectedShippingOption change\n cartStore.shipping = selectedLandedCost.subtotals.shipping;\n\n // update deminimis status\n const isGuarantee =\n selectedLandedCost?.landedCost?.landedCostGuaranteeCode === 'ZONOS';\n // one item in deminimis with type of duty and tax has threshold value is \"ABOVE\"\n const isAboveDeminimis = !!selectedLandedCost?.landedCost?.deMinimis?.find(\n item => ['DUTY', 'TAX'].includes(item.type) && item.threshold === 'ABOVE',\n );\n cartStore.isSelectedShippingAboveDeminimis = isAboveDeminimis;\n cartStore.isSelectedShippingGuarantee = isGuarantee;\n // update session with selected landed cost\n const updateCalulateStatus = await cartStoreReCalculateTotal({\n landedCostId: selectedLandedCost.landedCost?.id,\n });\n return updateCalulateStatus;\n};\n\nonChange('checkoutSessionId', () => {\n if (!cartStore.checkoutSessionId) {\n sessionStorage.removeItem('zonos--checkout-session-id');\n return;\n }\n sessionStorage.setItem(\n 'zonos--checkout-session-id',\n cartStore.checkoutSessionId,\n );\n});\n\nconst cartStoreUpdateItems = async (items: CartItem[]) => {\n cartStore.items = items;\n const currency = items.find(Boolean)?.currencyCode as CurrencyCode;\n const total = items.reduce((amt, item) => {\n return amt + item.amount * item.quantity;\n }, 0);\n if (!currency || !total) {\n // do nothing if we can't get currency or total\n return;\n }\n cartStore.currency = currency;\n // set loading state here because this is first load checkout session when we already have checkout session id stored\n stripeStore.isFetchingSession = true;\n await cartStoreReCalculateTotal({\n currency: currency,\n itemsAmount: total,\n });\n stripeStore.isFetchingSession = false;\n};\n\nconst cartStoreResetSelectedShippingOption = () => {\n cartStore.selectedShippingOption = null;\n cartStore.isSelectedShippingAboveDeminimis = false;\n cartStore.isSelectedShippingGuarantee = false;\n cartStore.selectedShippingOptionExpectedDate = '';\n cartStore.selectedShippingOptionTransitTime = '';\n cartStore.shipping = 0;\n};\n\nconst cartStoreNextStep = () => {\n if (cartStore.step === 'customer-info') {\n cartStore.step = 'shipping';\n } else if (cartStore.step === 'shipping') {\n cartStore.step = 'payment';\n } else if (cartStore.step === 'payment') {\n cartStore.step = 'finish';\n }\n};\n\nconst cartStorePreviousStep = () => {\n if (cartStore.step === 'payment') {\n cartStore.step = 'shipping';\n } else if (cartStore.step === 'shipping') {\n cartStore.step = 'customer-info';\n // reset selected shipping option\n cartStoreResetSelectedShippingOption();\n }\n};\n\nexport {\n cartStore,\n cartStoreApplySubtotals,\n cartStoreGetShippingTransitInfo,\n cartStoreNextStep,\n cartStorePreviousStep,\n cartStoreReCalculateTotal,\n cartStoreReset,\n cartStoreUpdateItems,\n cartStoreUpdateSelectedShippingOption,\n cartStoreUpdateToErrorState,\n};\n"],"mappings":"yzDAIO,IAAMA,EAA0B,WAErC,IAAMC,EAAiBC,EAAYC,oBAEnC,IAAMC,EAAoBF,EAAYG,uBACtC,IAAKD,IAAsBA,EAAkBE,SAAU,CACrD,MAAM,IAAIC,MAAM,8B,CAGlB,MAAO,CACLC,kBAAmBC,EAAUD,mBAAqB,GAClDE,QAAS,CACPC,OAAOV,IAAc,MAAdA,SAAc,SAAdA,EAAgBW,MAAMD,QAAS,GAGtCE,UAAWT,EAAkBQ,MAAMC,WAAa,GAChDC,SAAUV,EAAkBQ,MAAME,UAAY,GAC9CC,MAAOX,EAAkBQ,MAAMG,O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U4M,KAAO,U,MACZ,GAAI5M,EAAU4M,OAAS,WAAY,CACxC5M,EAAU4M,KAAO,S,MACZ,GAAI5M,EAAU4M,OAAS,UAAW,CACvC5M,EAAU4M,KAAO,Q,CAErB,I,IAEM6B,EAAqB7J,EAAA,KAAG,WAC5B,GAAI5E,EAAU4M,OAAS,UAAW,CAChC5M,EAAU4M,KAAO,U,MACZ,GAAI5M,EAAU4M,OAAS,WAAY,CACxC5M,EAAU4M,KAAO,gBAEjB2B,G,CAEJ,G"}
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-d1aa9293.js';
2
- import { s as stripeStore, f as stripeStorePrefetchLandedCost } from './cart-36c33342.js';
2
+ import { s as stripeStore, f as stripeStorePrefetchLandedCost } from './cart-2f83e048.js';
3
3
  import { b as logError, a as localizationStore } from './localization-4a424f49.js';
4
4
  import './zonosStore-13a7b534.js';
5
5
  import './isDarkColor-b21326ae.js';
@@ -1,2 +1,2 @@
1
- var __awaiter=this&&this.__awaiter||function(t,n,e,s){function o(t){return t instanceof e?t:new e((function(n){n(t)}))}return new(e||(e=Promise))((function(e,i){function a(t){try{c(s.next(t))}catch(t){i(t)}}function r(t){try{c(s["throw"](t))}catch(t){i(t)}}function c(t){t.done?e(t.value):o(t.value).then(a,r)}c((s=s.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,o,i,a;return a={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function r(t){return function(n){return c([t,n])}}function c(r){if(s)throw new TypeError("Generator is already executing.");while(a&&(a=0,r[0]&&(e=0)),e)try{if(s=1,o&&(i=r[0]&2?o["return"]:r[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;if(o=0,i)r=[r[0]&2,i.value];switch(r[0]){case 0:case 1:i=r;break;case 4:e.label++;return{value:r[1],done:false};case 5:e.label++;o=r[1];r=[0];continue;case 7:r=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(r[0]===6||r[0]===2)){e=0;continue}if(r[0]===3&&(!i||r[1]>i[0]&&r[1]<i[3])){e.label=r[1];break}if(r[0]===6&&e.label<i[1]){e.label=i[1];i=r;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(r);break}if(i[2])e.ops.pop();e.trys.pop();continue}r=n.call(t,e)}catch(t){r=[6,t];o=0}finally{s=i=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};System.register(["./index-87193773.system.js","./cart-ecd9011b.system.js","./localization-3c43290f.system.js","./zonosStore-77bcd7c0.system.js","./isDarkColor-dc2b7c8f.system.js","./getBorderRadius-4fbe49de.system.js"],(function(t){"use strict";var n,e,s,o,i,a,r,c;return{setters:[function(t){n=t.r;e=t.h;s=t.H;o=t.d},function(t){i=t.s;a=t.f},function(t){r=t.b;c=t.a},function(){},function(){},function(){}],execute:function(){var l=".sc-zonos-address-h{font-family:Inter;display:block}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:var(--amino-space-16)}";var d=t("zonos_address",function(){function t(t){n(this,t);this.type=undefined;this.titleText=undefined;this.defaultAddress=null;this.stripe=window.Zonos.stripe}t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,e,s,o;return __generator(this,(function(l){this.stripe=window.Zonos.stripe;if(!this.stripe||!i.stripeElements){r("Stripe is not initialized. Couldn't load stripe element.");return[2]}e=(t=this.defaultAddress)===null||t===void 0?void 0:t.phone;if(!e){(n=this.defaultAddress)===null||n===void 0?true:delete n.phone}s=c.shippingZoneCountries;o=i.stripeAddressElement||i.stripeElements.create("address",{allowedCountries:s?Object.values(s).map((function(t){return t.code})):[],contacts:this.defaultAddress?[this.defaultAddress]:undefined,display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});o.mount(this.el.querySelector(".zonos--address-component"));o.on("change",(function(t){var n=t.value;i.stripeAddressEventData=Object.assign(Object.assign({},t),{elementMode:"shipping",elementType:"address",empty:false,value:Object.assign(Object.assign({},n),{firstName:n.firstName||n.name.split(" ")[0],lastName:n.lastName||n.name.split(" ").pop()})});void a()}));i.stripeAddressElement=o;return[2]}))}))};t.prototype.componentDidLoad=function(){void this.watchInitStripe()};t.prototype.render=function(){return e(s,{class:"zonos--address zonos--elements"},e("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),e("div",{class:"zonos--address-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}());d.style=l;var u=".sc-zonos-link-authentication-h{font-family:Inter;display:block}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:var(--amino-space-16)}";var h=t("zonos_link_authentication",function(){function t(t){n(this,t);this.titleText=undefined;this.stripe=i.stripe}t.prototype.watchInitStripe=function(){if(!this.stripe||!i.stripeElements){return}var t=i.stripeLinkElement||i.stripeElements.create("linkAuthentication");var n=this.el.querySelector(".zonos--link-authentication-component");if(!n){console.error("Cannot find container element for linkAuthenticationElement");return}t.mount(n);t.on("change",(function(t){i.stripeLinkEventData=t;void a()}));i.stripeLinkElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return e(s,{class:"zonos--link-authentication zonos--elements"},e("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),e("div",{class:"zonos--link-authentication-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}());h.style=u}}}));
1
+ var __awaiter=this&&this.__awaiter||function(t,n,e,s){function o(t){return t instanceof e?t:new e((function(n){n(t)}))}return new(e||(e=Promise))((function(e,i){function a(t){try{c(s.next(t))}catch(t){i(t)}}function r(t){try{c(s["throw"](t))}catch(t){i(t)}}function c(t){t.done?e(t.value):o(t.value).then(a,r)}c((s=s.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,o,i,a;return a={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function r(t){return function(n){return c([t,n])}}function c(r){if(s)throw new TypeError("Generator is already executing.");while(a&&(a=0,r[0]&&(e=0)),e)try{if(s=1,o&&(i=r[0]&2?o["return"]:r[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;if(o=0,i)r=[r[0]&2,i.value];switch(r[0]){case 0:case 1:i=r;break;case 4:e.label++;return{value:r[1],done:false};case 5:e.label++;o=r[1];r=[0];continue;case 7:r=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(r[0]===6||r[0]===2)){e=0;continue}if(r[0]===3&&(!i||r[1]>i[0]&&r[1]<i[3])){e.label=r[1];break}if(r[0]===6&&e.label<i[1]){e.label=i[1];i=r;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(r);break}if(i[2])e.ops.pop();e.trys.pop();continue}r=n.call(t,e)}catch(t){r=[6,t];o=0}finally{s=i=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};System.register(["./index-87193773.system.js","./cart-9780fa28.system.js","./localization-3c43290f.system.js","./zonosStore-77bcd7c0.system.js","./isDarkColor-dc2b7c8f.system.js","./getBorderRadius-4fbe49de.system.js"],(function(t){"use strict";var n,e,s,o,i,a,r,c;return{setters:[function(t){n=t.r;e=t.h;s=t.H;o=t.d},function(t){i=t.s;a=t.f},function(t){r=t.b;c=t.a},function(){},function(){},function(){}],execute:function(){var l=".sc-zonos-address-h{font-family:Inter;display:block}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:var(--amino-space-16)}";var d=t("zonos_address",function(){function t(t){n(this,t);this.type=undefined;this.titleText=undefined;this.defaultAddress=null;this.stripe=window.Zonos.stripe}t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,e,s,o;return __generator(this,(function(l){this.stripe=window.Zonos.stripe;if(!this.stripe||!i.stripeElements){r("Stripe is not initialized. Couldn't load stripe element.");return[2]}e=(t=this.defaultAddress)===null||t===void 0?void 0:t.phone;if(!e){(n=this.defaultAddress)===null||n===void 0?true:delete n.phone}s=c.shippingZoneCountries;o=i.stripeAddressElement||i.stripeElements.create("address",{allowedCountries:s?Object.values(s).map((function(t){return t.code})):[],contacts:this.defaultAddress?[this.defaultAddress]:undefined,display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});o.mount(this.el.querySelector(".zonos--address-component"));o.on("change",(function(t){var n=t.value;i.stripeAddressEventData=Object.assign(Object.assign({},t),{elementMode:"shipping",elementType:"address",empty:false,value:Object.assign(Object.assign({},n),{firstName:n.firstName||n.name.split(" ")[0],lastName:n.lastName||n.name.split(" ").pop()})});void a()}));i.stripeAddressElement=o;return[2]}))}))};t.prototype.componentDidLoad=function(){void this.watchInitStripe()};t.prototype.render=function(){return e(s,{class:"zonos--address zonos--elements"},e("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),e("div",{class:"zonos--address-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}());d.style=l;var u=".sc-zonos-link-authentication-h{font-family:Inter;display:block}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:var(--amino-space-16)}";var h=t("zonos_link_authentication",function(){function t(t){n(this,t);this.titleText=undefined;this.stripe=i.stripe}t.prototype.watchInitStripe=function(){if(!this.stripe||!i.stripeElements){return}var t=i.stripeLinkElement||i.stripeElements.create("linkAuthentication");var n=this.el.querySelector(".zonos--link-authentication-component");if(!n){console.error("Cannot find container element for linkAuthenticationElement");return}t.mount(n);t.on("change",(function(t){i.stripeLinkEventData=t;void a()}));i.stripeLinkElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return e(s,{class:"zonos--link-authentication zonos--elements"},e("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),e("div",{class:"zonos--link-authentication-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}());h.style=u}}}));
2
2
  //# sourceMappingURL=zonos-address_2.system.entry.js.map
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-d1aa9293.js';
2
2
  import { c as classes } from './classes-0d95c529.js';
3
- import { s as stripeStore } from './cart-36c33342.js';
3
+ import { s as stripeStore } from './cart-2f83e048.js';
4
4
  import './zonosStore-13a7b534.js';
5
5
  import './localization-4a424f49.js';
6
6
  import './isDarkColor-b21326ae.js';
@@ -1,2 +1,2 @@
1
- System.register(["./index-87193773.system.js","./classes-ce25a814.system.js","./cart-ecd9011b.system.js","./zonosStore-77bcd7c0.system.js","./localization-3c43290f.system.js","./isDarkColor-dc2b7c8f.system.js","./getBorderRadius-4fbe49de.system.js"],(function(t){"use strict";var e,n,o,s,a,r;return{setters:[function(t){e=t.r;n=t.h;o=t.H;s=t.d},function(t){a=t.c},function(t){r=t.s},function(){},function(){},function(){},function(){}],execute:function(){var i=':host{font-family:Inter;display:block}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{border-radius:var(--amino-radius-10);padding:var(--amino-space-16);background:var(--amino-gray-100)}:host .zonos--container{display:grid;-ms-flex-align:center;align-items:center;grid-template-areas:"icon header" ". content";grid-template-columns:32px auto 0}:host .zonos--icon-wrapper{grid-area:icon;display:-ms-flexbox;display:flex;justify-self:start}:host .zonos--header-wrapper{grid-area:header}:host .zonos--content-wrapper{grid-area:content;margin-top:8px}:host(.info){background-color:var(--amino-blue-100)}:host(.success){background-color:var(--amino-green-100)}:host(.error){background-color:var(--amino-red-100)}:host(.warning){background-color:var(--amino-orange-100)}';var c=t("zonos_banner",function(){function t(t){var n=this;e(this,t);this.handleSlotChange=function(){n.hasContent=true};this.bannerTitle=undefined;this.intent=undefined;this.class="";this.hasContent=false}t.prototype.render=function(){var t=this;var e=function(e){var o=e.color;var s="var(--amino-".concat(o,"-800)");var r="var(--amino-".concat(o,"-300)");var i=[t.bannerTitle,n("slot",{onSlotchange:t.handleSlotChange})].filter(Boolean),c=i[0],l=i[1];var h=o==="gray"?"gray-1200":"".concat(o,"-800");return n("div",{class:a(["zonos--container"])},n("div",{class:"zonos--icon-wrapper"},n("svg",{color:s,fill:"none",height:"20",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},n("path",{"clip-rule":"evenodd",d:"M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Z","data-is-secondary-color":"true",fill:r,"fill-rule":"evenodd"}),n("path",{"clip-rule":"evenodd",d:"M12 6.99a1 1 0 0 1 1 1V8a1 1 0 1 1-2 0v-.01a1 1 0 0 1 1-1ZM12 11a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1Z",fill:"currentColor","fill-rule":"evenodd"}))),n("div",{class:"zonos--header-wrapper"},n("zonos-text",{color:h,type:"label",weight:600},c)),l&&n("div",{class:"zonos--content-wrapper"},n("zonos-text",{color:h},l)))};var s=a(["zonos--elements zonos--banner",this.class,this.intent]);switch(this.intent){case"error":return n(o,{class:s},e({color:"red"}));case"info":return n(o,{class:s},e({color:"blue"}));case"success":return n(o,{class:s},e({color:"green"}));case"warning":return n(o,{class:s},e({color:"orange"}));default:return n(o,{class:s},e({color:"gray"}))}};return t}());c.style=i;var l=".sc-zonos-payment-h{font-family:Inter;display:block}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:var(--amino-space-16)}";var h=t("zonos_payment",function(){function t(t){e(this,t);this.titleText=undefined;this.stripe=r.stripe;this.stripeElements=r.stripeElements}t.prototype.watchInitStripe=function(){if(!this.stripeElements){return}var t=r.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"});var e=this.el.querySelector(".zonos--payment-component");if(!e){console.error("Cannot find container element for paymentElement");return}t.mount(e);t.on("change",(function(t){r.stripePaymentEventData=t}));r.stripePaymentElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return n(o,{class:"zonos--payment zonos--elements"},this.titleText&&n("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),n("div",{class:"zonos--payment-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}());h.style=l}}}));
1
+ System.register(["./index-87193773.system.js","./classes-ce25a814.system.js","./cart-9780fa28.system.js","./zonosStore-77bcd7c0.system.js","./localization-3c43290f.system.js","./isDarkColor-dc2b7c8f.system.js","./getBorderRadius-4fbe49de.system.js"],(function(t){"use strict";var e,n,o,s,a,r;return{setters:[function(t){e=t.r;n=t.h;o=t.H;s=t.d},function(t){a=t.c},function(t){r=t.s},function(){},function(){},function(){},function(){}],execute:function(){var i=':host{font-family:Inter;display:block}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{border-radius:var(--amino-radius-10);padding:var(--amino-space-16);background:var(--amino-gray-100)}:host .zonos--container{display:grid;-ms-flex-align:center;align-items:center;grid-template-areas:"icon header" ". content";grid-template-columns:32px auto 0}:host .zonos--icon-wrapper{grid-area:icon;display:-ms-flexbox;display:flex;justify-self:start}:host .zonos--header-wrapper{grid-area:header}:host .zonos--content-wrapper{grid-area:content;margin-top:8px}:host(.info){background-color:var(--amino-blue-100)}:host(.success){background-color:var(--amino-green-100)}:host(.error){background-color:var(--amino-red-100)}:host(.warning){background-color:var(--amino-orange-100)}';var c=t("zonos_banner",function(){function t(t){var n=this;e(this,t);this.handleSlotChange=function(){n.hasContent=true};this.bannerTitle=undefined;this.intent=undefined;this.class="";this.hasContent=false}t.prototype.render=function(){var t=this;var e=function(e){var o=e.color;var s="var(--amino-".concat(o,"-800)");var r="var(--amino-".concat(o,"-300)");var i=[t.bannerTitle,n("slot",{onSlotchange:t.handleSlotChange})].filter(Boolean),c=i[0],l=i[1];var h=o==="gray"?"gray-1200":"".concat(o,"-800");return n("div",{class:a(["zonos--container"])},n("div",{class:"zonos--icon-wrapper"},n("svg",{color:s,fill:"none",height:"20",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},n("path",{"clip-rule":"evenodd",d:"M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Z","data-is-secondary-color":"true",fill:r,"fill-rule":"evenodd"}),n("path",{"clip-rule":"evenodd",d:"M12 6.99a1 1 0 0 1 1 1V8a1 1 0 1 1-2 0v-.01a1 1 0 0 1 1-1ZM12 11a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1Z",fill:"currentColor","fill-rule":"evenodd"}))),n("div",{class:"zonos--header-wrapper"},n("zonos-text",{color:h,type:"label",weight:600},c)),l&&n("div",{class:"zonos--content-wrapper"},n("zonos-text",{color:h},l)))};var s=a(["zonos--elements zonos--banner",this.class,this.intent]);switch(this.intent){case"error":return n(o,{class:s},e({color:"red"}));case"info":return n(o,{class:s},e({color:"blue"}));case"success":return n(o,{class:s},e({color:"green"}));case"warning":return n(o,{class:s},e({color:"orange"}));default:return n(o,{class:s},e({color:"gray"}))}};return t}());c.style=i;var l=".sc-zonos-payment-h{font-family:Inter;display:block}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:var(--amino-space-16)}";var h=t("zonos_payment",function(){function t(t){e(this,t);this.titleText=undefined;this.stripe=r.stripe;this.stripeElements=r.stripeElements}t.prototype.watchInitStripe=function(){if(!this.stripeElements){return}var t=r.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"});var e=this.el.querySelector(".zonos--payment-component");if(!e){console.error("Cannot find container element for paymentElement");return}t.mount(e);t.on("change",(function(t){r.stripePaymentEventData=t}));r.stripePaymentElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return n(o,{class:"zonos--payment zonos--elements"},this.titleText&&n("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),n("div",{class:"zonos--payment-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}());h.style=l}}}));
2
2
  //# sourceMappingURL=zonos-banner_2.system.entry.js.map
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, a as getAssetPath, h, H as Host, F as Fragment, c as createEvent, d as getElement } from './index-d1aa9293.js';
2
- import { c as cartStore, s as stripeStore, l as stripeStoreRetrievePayment, j as stripeStoreReset, m as cartStoreUpdateSelectedShippingOption, n as cartStoreGetShippingTransitInfo } from './cart-36c33342.js';
2
+ import { c as cartStore, s as stripeStore, l as stripeStoreRetrievePayment, j as stripeStoreReset, m as cartStoreUpdateSelectedShippingOption, n as cartStoreGetShippingTransitInfo } from './cart-2f83e048.js';
3
3
  import { t as translate } from './localization-4a424f49.js';
4
4
  import { g as getBorderRadius } from './getBorderRadius-82fbaf25.js';
5
5
  import { s as submitGtag, i as isCheckoutMobile } from './submitGtag-fbdb454b.js';
@@ -25,7 +25,9 @@ const ZonosCartItems = class {
25
25
  this.errorImages = [];
26
26
  }
27
27
  render() {
28
+ var _a;
28
29
  const emptyItemImg = getAssetPath('./assets/empty-item.jpeg');
30
+ const rate = ((_a = cartStore.exchangeRate) === null || _a === void 0 ? void 0 : _a.rate) || 1;
29
31
  return (h(Host, { class: "zonos--cart-items zonos--elements" }, h("table", { class: "zonos--cart-table" }, h("tbody", null, cartStore.items.map(item => {
30
32
  const itemImg = item.imageUrl;
31
33
  return (h("tr", { class: "zonos--cart-item" }, h("td", { class: "zonos--column zonos--cart-item-image" }, itemImg && !this.errorImages.includes(itemImg) ? (h("img", { alt: item.name, onError: () => {
@@ -33,7 +35,7 @@ const ZonosCartItems = class {
33
35
  }, src: item.imageUrl, style: {
34
36
  'min-width': '40px',
35
37
  }, width: 40 })) : (h("img", { alt: item.name, src: emptyItemImg, width: 40 }))), h("td", { class: "zonos--column zonos--cart-item-name" }, h("zonos-text", { type: "label" }, item.name)), h("td", { class: "zonos--column zonos--cart-item-price" }, h("zonos-text", { type: "semiBoldLabel" }, formatCurrency({
36
- amount: item.amount * item.quantity,
38
+ amount: item.amount * item.quantity * rate,
37
39
  currency: cartStore.currency,
38
40
  })))));
39
41
  })))));
@@ -101,7 +103,7 @@ const ZonosCheckoutFinish = class {
101
103
  this.checkPaymentStatus = async () => {
102
104
  this.isLoading = true;
103
105
  const clientSecret = new URLSearchParams(window.location.search).get('payment_intent_client_secret') || stripeStore.clientSecret;
104
- if (clientSecret) {
106
+ if (clientSecret || this.storybookForceStatus) {
105
107
  const { error, messages } = await stripeStoreRetrievePayment({
106
108
  clientSecret,
107
109
  storybookForceStatus: this.storybookForceStatus,