@dropins/storefront-checkout 2.1.0 → 2.2.0-alpha2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/api/getCompanyCredit/getCompanyCredit.d.ts +4 -0
  2. package/api/getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts +18 -0
  3. package/api/getCompanyCredit/graphql/index.d.ts +18 -0
  4. package/api/getCompanyCredit/index.d.ts +18 -0
  5. package/api/graphql/NegotiableQuoteAddressFragment.graphql.d.ts +1 -1
  6. package/api/graphql/PaymentMethodFragment.graphql.d.ts +1 -1
  7. package/api/index.d.ts +1 -0
  8. package/api/initialize/initialize.d.ts +6 -2
  9. package/api.js +2 -2
  10. package/api.js.map +1 -1
  11. package/chunks/PaymentOnAccount2.js +4 -0
  12. package/chunks/PaymentOnAccount2.js.map +1 -0
  13. package/chunks/PurchaseOrder.js +4 -0
  14. package/chunks/PurchaseOrder.js.map +1 -0
  15. package/chunks/classifiers.js +4 -0
  16. package/chunks/classifiers.js.map +1 -0
  17. package/chunks/events.js +1 -1
  18. package/chunks/events.js.map +1 -1
  19. package/chunks/events2.js +1 -1
  20. package/chunks/events2.js.map +1 -1
  21. package/chunks/fetch-graphql.js +1 -1
  22. package/chunks/getCompanyCredit.js +15 -0
  23. package/chunks/getCompanyCredit.js.map +1 -0
  24. package/chunks/guards.js +1 -1
  25. package/chunks/render.js +10 -0
  26. package/chunks/render.js.map +1 -0
  27. package/chunks/setBillingAddress.js +1 -1
  28. package/chunks/setGuestEmailOnCart.js +1 -1
  29. package/chunks/setGuestEmailOnCart.js.map +1 -1
  30. package/chunks/setShippingAddress.js +1 -1
  31. package/chunks/setShippingMethods.js +2 -2
  32. package/chunks/synchronizeCheckout.js +6 -6
  33. package/chunks/synchronizeCheckout.js.map +1 -1
  34. package/components/PaymentOnAccount/PaymentOnAccount.d.ts +17 -0
  35. package/components/PaymentOnAccount/PaymentOnAccountSkeleton.d.ts +4 -0
  36. package/components/PaymentOnAccount/index.d.ts +20 -0
  37. package/components/PurchaseOrder/PurchaseOrder.d.ts +10 -0
  38. package/components/PurchaseOrder/index.d.ts +19 -0
  39. package/components/index.d.ts +3 -1
  40. package/containers/AddressValidation.js +1 -1
  41. package/containers/AddressValidation.js.map +1 -1
  42. package/containers/BillToShippingAddress.js +1 -1
  43. package/containers/BillToShippingAddress.js.map +1 -1
  44. package/containers/EstimateShipping.js +1 -1
  45. package/containers/EstimateShipping.js.map +1 -1
  46. package/containers/LoginForm.js +1 -1
  47. package/containers/LoginForm.js.map +1 -1
  48. package/containers/MergedCartBanner.js +1 -1
  49. package/containers/MergedCartBanner.js.map +1 -1
  50. package/containers/OutOfStock.js +1 -1
  51. package/containers/OutOfStock.js.map +1 -1
  52. package/containers/PaymentMethods/PaymentMethods.d.ts +8 -6
  53. package/containers/PaymentMethods/handlers.d.ts +11 -0
  54. package/containers/PaymentMethods.js +1 -1
  55. package/containers/PaymentMethods.js.map +1 -1
  56. package/containers/PaymentOnAccount/PaymentOnAccount.d.ts +10 -0
  57. package/containers/PaymentOnAccount/index.d.ts +11 -0
  58. package/containers/PaymentOnAccount.d.ts +3 -0
  59. package/containers/PaymentOnAccount.js +4 -0
  60. package/containers/PaymentOnAccount.js.map +1 -0
  61. package/containers/PlaceOrder.js +1 -1
  62. package/containers/PlaceOrder.js.map +1 -1
  63. package/containers/PurchaseOrder/PurchaseOrder.d.ts +10 -0
  64. package/containers/PurchaseOrder/index.d.ts +19 -0
  65. package/containers/PurchaseOrder.d.ts +3 -0
  66. package/containers/PurchaseOrder.js +4 -0
  67. package/containers/PurchaseOrder.js.map +1 -0
  68. package/containers/ServerError/ServerError.d.ts +2 -1
  69. package/containers/ServerError.js +1 -1
  70. package/containers/ServerError.js.map +1 -1
  71. package/containers/ShippingMethods.js +1 -1
  72. package/containers/ShippingMethods.js.map +1 -1
  73. package/containers/TermsAndConditions.js +1 -1
  74. package/containers/TermsAndConditions.js.map +1 -1
  75. package/containers/index.d.ts +2 -0
  76. package/data/models/address.d.ts +1 -0
  77. package/data/models/company-credit.d.ts +7 -0
  78. package/data/models/index.d.ts +1 -0
  79. package/data/models/payment-method.d.ts +2 -0
  80. package/data/transforms/index.d.ts +1 -0
  81. package/data/transforms/transform-company-credit.d.ts +7 -0
  82. package/data/transforms/transform-quote-address.d.ts +1 -0
  83. package/fragments.js +15 -12
  84. package/fragments.js.map +1 -1
  85. package/i18n/en_US.json.d.ts +20 -0
  86. package/lib/errors/classifiers.d.ts +3 -1
  87. package/lib/utils.js +1 -1
  88. package/lib/utils.js.map +1 -1
  89. package/package.json +1 -1
  90. package/render.js +5 -5
  91. package/render.js.map +1 -1
  92. package/tests/fixtures/fragments/cart.d.ts +1 -0
  93. package/tests/fixtures/helpers/session-storage.d.ts +68 -0
  94. package/tests/fixtures/index.d.ts +1 -0
  95. package/tests/fixtures/queries/get-company-credit.d.ts +14 -0
  96. package/tests/fixtures/queries/index.d.ts +1 -0
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{CHECKOUT_DATA_FRAGMENT as r,NEGOTIABLE_QUOTE_FRAGMENT as h}from"../fragments.js";import{e as d,t as u}from"./guards.js";import{t as M,e as g}from"./synchronizeCheckout.js";import{s as e,M as m,d as c,Q as I}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const S=`
3
+ import{CHECKOUT_DATA_FRAGMENT as r,NEGOTIABLE_QUOTE_FRAGMENT as h}from"../fragments.js";import{e as d,t as u}from"./guards.js";import{t as g,e as M}from"./synchronizeCheckout.js";import{s as e,j as m,d as c,Q as I}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const S=`
4
4
  mutation setShippingMethodsOnCart(
5
5
  $cartId: String!
6
6
  $shippingMethods: [ShippingMethodInput]!
@@ -30,5 +30,5 @@ import{CHECKOUT_DATA_FRAGMENT as r,NEGOTIABLE_QUOTE_FRAGMENT as h}from"../fragme
30
30
  }
31
31
 
32
32
  ${h}
33
- `,o=(t,s,i,n,p)=>async a=>await c({type:"mutation",query:i,queueName:I.Updates,options:{variables:{[s]:t,shippingMethods:u(a)}},path:p,transformer:n}),C=t=>{if(!Array.isArray(t)||t.length===0)throw new m},Q=async t=>(d(),C(t),await(!!e.cartId?o(e.cartId,"cartId",S,M,"setShippingMethodsOnCart.cart"):o(e.quoteId,"quoteId",A,g,"setNegotiableQuoteShippingMethods.quote"))(t));export{Q as s};
33
+ `,o=(t,s,i,n,p)=>async a=>await c({type:"mutation",query:i,queueName:I.Updates,options:{variables:{[s]:t,shippingMethods:u(a)}},path:p,transformer:n}),C=t=>{if(!Array.isArray(t)||t.length===0)throw new m},Q=async t=>(d(),C(t),await(!!e.cartId?o(e.cartId,"cartId",S,g,"setShippingMethodsOnCart.cart"):o(e.quoteId,"quoteId",A,M,"setNegotiableQuoteShippingMethods.quote"))(t));export{Q as s};
34
34
  //# sourceMappingURL=setShippingMethods.js.map
@@ -1,13 +1,13 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{s as i,m as M,d as g,U as T,t as N,i as Q}from"./fetch-graphql.js";import{merge as z,Initializer as S,deepmerge as G}from"@dropins/tools/lib.js";import{events as c}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as y,NEGOTIABLE_QUOTE_FRAGMENT as k}from"../fragments.js";import{b as L,c as D,d as O,a as P,e as U,f as x,g as B}from"./transform-shipping-methods.js";const R=async(e=!1)=>{i.authenticated=e},b=e=>{if(e)return{code:e.code,title:e.title}},C=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:s,title:r}=t;return{code:s,title:r}})},$=e=>{var s,r,o;if(!e)return;const t={availablePaymentMethods:C(e.available_payment_methods),billingAddress:D(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:b(e.selected_payment_method),shippingAddresses:L(e.shipping_addresses),isGuest:!i.authenticated};return z(t,(o=(r=(s=Z.getConfig().models)==null?void 0:s.CartModel)==null?void 0:r.transformer)==null?void 0:o.call(r,e))},_=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:B(e.country),customAttributes:x(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:U(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},F=e=>{if(e)return _(e)},H=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:s,selected_shipping_method:r,...o}=t;return{..._(o),availableShippingMethods:P(s),selectedShippingMethod:O(r)}}),K=e=>e?{availablePaymentMethods:C(e.available_payment_methods),billingAddress:F(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:b(e.selected_payment_method),shippingAddresses:H(e.shipping_addresses),status:e.status,uid:e.uid}:null,V=`
3
+ import{s as r,n as Q,d as y,U as N,t as D,e as S}from"./fetch-graphql.js";import{merge as k,Initializer as z,deepmerge as G}from"@dropins/tools/lib.js";import{events as d}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as _,NEGOTIABLE_QUOTE_FRAGMENT as O}from"../fragments.js";import{b as R,c as U,d as P,a as L,e as x,f as B,g as $}from"./transform-shipping-methods.js";import{E as g}from"./classifiers.js";const F=async(e=!1)=>{r.authenticated=e},C=e=>{if(!e)return;const{code:t,title:i,...s}=e;return{code:t,title:i,additionalData:s}},b=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:i,title:s,...c}=t;return{code:i,title:s,additionalData:c}})},H=e=>{var i,s,c;if(!e)return;const t={availablePaymentMethods:b(e.available_payment_methods),billingAddress:U(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:C(e.selected_payment_method),shippingAddresses:R(e.shipping_addresses),isGuest:!r.authenticated};return k(t,(c=(s=(i=te.getConfig().models)==null?void 0:i.CartModel)==null?void 0:s.transformer)==null?void 0:c.call(s,e))},q=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:$(e.country),customAttributes:B(e.custom_attributes),customerAddressUid:e.customer_address_uid||void 0,fax:e.fax||void 0,firstName:e.firstname,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:x(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},K=e=>{if(e)return q(e)},V=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:i,selected_shipping_method:s,...c}=t;return{...q(c),availableShippingMethods:L(i),selectedShippingMethod:P(s)}}),W=e=>e?{availablePaymentMethods:b(e.available_payment_methods),billingAddress:K(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:C(e.selected_payment_method),shippingAddresses:V(e.shipping_addresses),status:e.status,uid:e.uid}:null,Y=`
4
4
  query getCart($cartId: String!) {
5
5
  cart(cart_id: $cartId) {
6
6
  ...CHECKOUT_DATA_FRAGMENT
7
7
  }
8
8
  }
9
9
 
10
- ${y}
10
+ ${_}
11
11
  `,j=`
12
12
  query getCustomerCart {
13
13
  cart: customerCart {
@@ -15,14 +15,14 @@ import{s as i,m as M,d as g,U as T,t as N,i as Q}from"./fetch-graphql.js";import
15
15
  }
16
16
  }
17
17
 
18
- ${y}
19
- `,A=async()=>{const e=i.cartId,t=i.authenticated===!1,s=t?V:j,r=t?{cartId:e}:{};if(t&&!e)throw new M;return await g({type:"query",query:s,options:{method:"POST",cache:"no-cache",variables:r},path:"cart",transformer:$})},J=`
18
+ ${_}
19
+ `,A=async()=>{const e=r.cartId,t=r.authenticated===!1,i=t?Y:j,s=t?{cartId:e}:{};if(t&&!e)throw new Q;return await y({type:"query",query:i,options:{method:"POST",cache:"no-cache",variables:s},path:"cart",transformer:H})},J=`
20
20
  query getNegotiableQuote($quoteId: ID!) {
21
21
  negotiableQuote(uid: $quoteId) {
22
22
  ...NEGOTIABLE_QUOTE_FRAGMENT
23
23
  }
24
24
  }
25
25
 
26
- ${k}
27
- `,I=async(e={})=>{const t=e.uid??i.quoteId;if(i.authenticated===!1)throw new T;if(!t)throw new N;return await g({type:"query",query:J,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:K})},d={eager:!0},W=e=>{var h,f;const t=((f=(h=e==null?void 0:e.features)==null?void 0:h.b2b)==null?void 0:f.quotes)??!1;return[["authenticated",(n=!1)=>{var u,l,p;if(R(n),!t||n)return;const a=(p=(l=(u=e==null?void 0:e.features)==null?void 0:u.b2b)==null?void 0:l.routeLogin)==null?void 0:p.call(l);a&&window.location.assign(a)},d],...t?[["quote-management/quote-data/initialized",n=>{m(n.quote)},d]]:[["cart/initialized",m,d],["cart/reset",w],["cart/updated",E]]].map(([n,a,u])=>c.on(n,a,u))},X=new URL(window.location.href),Y=X.searchParams.get("quoteId");i.quoteId=Y;const q=new S({init:async(e={})=>{q.config.setConfig(G({defaults:{isBillToShipping:!0,selectedShippingMethod:t=>t.length>0?t[0]:null},features:{b2b:{quotes:!1}}},e))},listeners:W}),Z=q.config,v=e=>"id"in e,ee=async e=>{try{return v(e)?(i.cartId=e.id,i.quoteId=null,await A()??null):(i.cartId=null,i.quoteId=e.uid,await I()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},m=async e=>{if(i.initialized){await E(e);return}i.config||(i.config=await Q());const t=e?await ee(e):null;i.initialized=!0,c.emit("checkout/initialized",t)},w=()=>{i.initialized&&(i.cartId=null,i.quoteId=null,c.emit("checkout/updated",null))},te=async e=>{try{return v(e)?(i.cartId=e.id,i.quoteId=null,await A()??null):(i.cartId=null,i.quoteId=e.uid,await I()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},E=async e=>{if(!i.initialized)return m(e);if(e===null){w();return}const t=await te(e);c.emit("checkout/updated",t)};export{R as a,I as b,Z as c,m as d,K as e,A as g,q as i,w as r,E as s,$ as t};
26
+ ${O}
27
+ `,I=async(e={})=>{const t=e.uid??r.quoteId;if(r.authenticated===!1)throw new N;if(!t)throw new D;return await y({type:"query",query:J,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:W})},m={eager:!0},X=e=>{var f,p;const t=((p=(f=e==null?void 0:e.features)==null?void 0:f.b2b)==null?void 0:p.quotes)??!1;return[["authenticated",(u=!1)=>{var o,a,l;if(F(u),!t||u)return;const n=(l=(a=(o=e==null?void 0:e.features)==null?void 0:o.b2b)==null?void 0:a.routeLogin)==null?void 0:l.call(a);n&&window.location.assign(n)},m],...t?[["quote-management/quote-data/initialized",u=>{var n,o,a,l;if(!u.quote.canCheckout){const M=((l=(a=(o=(n=e==null?void 0:e.langDefinitions)==null?void 0:n.default)==null?void 0:o.Checkout)==null?void 0:a.Quote)==null?void 0:l.permissionDenied)||"You do not have permission to checkout with this quote.";d.emit("checkout/error",{message:M,code:g.QUOTE_PERMISSION_DENIED});return}h(u.quote)},m],["quote-management/quote-data/error",()=>{var n,o,a,l;const u=((l=(a=(o=(n=e==null?void 0:e.langDefinitions)==null?void 0:n.default)==null?void 0:o.Checkout)==null?void 0:a.Quote)==null?void 0:l.dataError)||"We were unable to retrieve the quote data. Please try again later.";d.emit("checkout/error",{message:u,code:g.QUOTE_DATA_ERROR})}]]:[["cart/initialized",h,m],["cart/reset",w],["cart/updated",T]]].map(([u,n,o])=>d.on(u,n,o))},Z=new URL(window.location.href),ee=Z.searchParams.get("quoteId");r.quoteId=ee;const v=new z({init:async(e={})=>{v.config.setConfig(G({defaults:{isBillToShipping:!0,selectedShippingMethod:t=>t.length>0?t[0]:null},features:{b2b:{quotes:!1}}},e))},listeners:X}),te=v.config,E=e=>"id"in e,re=async e=>{try{return E(e)?(r.cartId=e.id,r.quoteId=null,await A()??null):(r.cartId=null,r.quoteId=e.uid,await I()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},h=async e=>{if(r.initialized){await T(e);return}r.config||(r.config=await S());const t=e?await re(e):null;r.initialized=!0,d.emit("checkout/initialized",t)},w=()=>{r.initialized&&(r.cartId=null,r.quoteId=null,d.emit("checkout/updated",null))},se=async e=>{try{return E(e)?(r.cartId=e.id,r.quoteId=null,await A()??null):(r.cartId=null,r.quoteId=e.uid,await I()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},T=async e=>{if(!r.initialized)return h(e);if(e===null){w();return}const t=await se(e);d.emit("checkout/updated",t)};export{F as a,I as b,te as c,h as d,W as e,A as g,v as i,w as r,T as s,H as t};
28
28
  //# sourceMappingURL=synchronizeCheckout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"synchronizeCheckout.js","sources":["/@dropins/storefront-checkout/src/api/authenticateCustomer/authenticateCustomer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-payment-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart.ts","/@dropins/storefront-checkout/src/data/transforms/transform-quote-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-negotiable-quote.ts","/@dropins/storefront-checkout/src/api/getCart/graphql/getCart.graphql.ts","/@dropins/storefront-checkout/src/api/getCart/getCart.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/getNegotiableQuote.ts","/@dropins/storefront-checkout/src/api/initialize/listeners.ts","/@dropins/storefront-checkout/src/api/initialize/initialize.ts","/@dropins/storefront-checkout/src/types/guards.ts","/@dropins/storefront-checkout/src/api/initializeCheckout/initializeCheckout.ts","/@dropins/storefront-checkout/src/api/resetCheckout/resetCheckout.ts","/@dropins/storefront-checkout/src/api/synchronizeCheckout/synchronizeCheckout.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/checkout/lib/state';\n\nexport const authenticateCustomer = async (authenticated = false) => {\n state.authenticated = authenticated;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype SelectedPaymentMethod = NonNullable<\n GetCartQuery['cart']\n>['selected_payment_method'];\n\ntype AvailablePaymentMethods = NonNullable<\n GetCartQuery['cart']\n>['available_payment_methods'];\n\ntype AvailablePaymentMethod = NonNullable<AvailablePaymentMethods>[number];\n\ntype NonNullabePaymentMethod = NonNullable<AvailablePaymentMethod>;\n\nconst transformSelectedPaymentMethod = (\n data: SelectedPaymentMethod\n): PaymentMethod | undefined => {\n if (!data) return;\n return { code: data.code, title: data.title };\n};\n\nconst transformAvailablePaymentMethods = (\n data: AvailablePaymentMethods\n): PaymentMethod[] | undefined => {\n if (!data) return;\n\n return data\n .filter((method) => !!method)\n .map((method) => {\n const { code, title } = method as NonNullabePaymentMethod;\n return { code, title };\n });\n};\n\nexport { transformAvailablePaymentMethods, transformSelectedPaymentMethod };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport { Cart as CartModel } from '@/checkout/data/models';\nimport {\n transformAvailablePaymentMethods,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms/transform-payment-methods';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nimport {\n transformCartBillingAddress,\n transformCartShippingAddress,\n} from '@/checkout/data/transforms/transform-cart-address';\nimport { state } from '@/checkout/lib/state';\n\ntype Cart = GetCartQuery['cart'];\n\nconst transformCart = (data: Cart): CartModel | undefined => {\n if (!data) return;\n\n const model = {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformCartBillingAddress(data.billing_address),\n email: data.email ?? undefined,\n id: data.id,\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformCartShippingAddress(data.shipping_addresses),\n isGuest: !state.authenticated,\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CartModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Cart, transformCart };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n Address as AddressModel,\n ShippingAddress as ShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\ntype QuoteShippingAddresses = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['shipping_addresses'];\ntype QuoteShippingAddress = QuoteShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<QuoteShippingAddress>;\n\ntype QuoteBillingAddress = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<QuoteBillingAddress>;\n\nconst transformAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): AddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n fax: data.fax || undefined,\n firstName: data.firstname,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformQuoteBillingAddress = (\n data: QuoteBillingAddress\n): AddressModel | undefined => {\n if (!data) return;\n return transformAddress(data);\n};\n\nconst transformQuoteShippingAddress = (\n data: QuoteShippingAddresses\n): ShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n };\n });\n};\n\nexport {\n QuoteBillingAddress,\n QuoteShippingAddress,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NegotiableQuote as NegotiableQuoteModel } from '@/checkout/data/models/';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\nimport {\n transformAvailablePaymentMethods,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms';\n\ntype NegotiableQuote = GetNegotiableQuoteQuery['negotiableQuote'];\n\nexport const transformNegotiableQuote = (\n data: NegotiableQuote | undefined\n): NegotiableQuoteModel | null => {\n if (!data) return null;\n\n return {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformQuoteBillingAddress(data.billing_address),\n email: data.email ?? '',\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n name: data.name,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformQuoteShippingAddress(data.shipping_addresses),\n status: data.status,\n uid: data.uid,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const getCartQuery = /* GraphQL */ `\n query getCart($cartId: String!) {\n cart(cart_id: $cartId) {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n\nexport const getCustomerCartQuery = /* GraphQL */ `\n query getCustomerCart {\n cart: customerCart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCartQuery,\n getCustomerCartQuery,\n} from '@/checkout/api/getCart/graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib';\nimport { MissingCart } from '@/checkout/lib/errors';\n\nexport const getCart = async () => {\n const cartId = state.cartId;\n const isGuest = state.authenticated === false;\n const query = isGuest ? getCartQuery : getCustomerCartQuery;\n const variables = isGuest ? { cartId } : {};\n\n if (isGuest && !cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n type: 'query',\n query,\n options: { method: 'POST', cache: 'no-cache', variables },\n path: 'cart',\n transformer: transformCart,\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const getNegotiableQuoteQuery = /* GraphQL */ `\n query getNegotiableQuote($quoteId: ID!) {\n negotiableQuote(uid: $quoteId) {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getNegotiableQuoteQuery } from '@/checkout/api/getNegotiableQuote/graphql';\nimport { transformNegotiableQuote as transformer } from '@/checkout/data/transforms';\nimport { state } from '@/checkout/lib';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport {\n MissingNegotiableQuoteId,\n Unauthenticated,\n} from '@/checkout/lib/errors';\n\ntype GetNegotiableQuoteInput = {\n uid?: string;\n};\n\nexport const getNegotiableQuote = async (\n input: GetNegotiableQuoteInput = {}\n) => {\n const quoteId = input.uid ?? state.quoteId;\n const isGuest = state.authenticated === false;\n\n if (isGuest) throw new Unauthenticated();\n if (!quoteId) throw new MissingNegotiableQuoteId();\n\n const variables = { quoteId };\n\n return await dispatchApiCall({\n type: 'query',\n query: getNegotiableQuoteQuery,\n options: { method: 'GET', cache: 'no-cache', variables },\n path: 'negotiableQuote',\n transformer,\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n authenticateCustomer,\n ConfigProps,\n initializeCheckout,\n resetCheckout,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { events, Events } from '@adobe-commerce/event-bus';\n\ntype Listener = [keyof Events, (...args: any[]) => void, { eager: boolean }?];\n\nconst asEager = { eager: true };\n\nexport const addCheckoutEventListeners = (config: ConfigProps | undefined) => {\n const useB2bQuotes = config?.features?.b2b?.quotes ?? false;\n\n const handleAuthenticated = (isAuthenticated = false) => {\n authenticateCustomer(isAuthenticated);\n\n if (!useB2bQuotes) return;\n if (isAuthenticated) return;\n\n const destination = config?.features?.b2b?.routeLogin?.();\n if (destination) {\n window.location.assign(destination);\n }\n };\n\n const cartListeners: Listener[] = [\n ['cart/initialized', initializeCheckout, asEager],\n ['cart/reset', resetCheckout],\n ['cart/updated', synchronizeCheckout],\n ];\n\n const quoteListeners: Listener[] = [\n [\n 'quote-management/quote-data/initialized',\n (data) => {\n initializeCheckout(data.quote);\n },\n asEager,\n ],\n ];\n\n const listeners: Listener[] = [\n ['authenticated', handleAuthenticated, asEager],\n ...(useB2bQuotes ? quoteListeners : cartListeners),\n ];\n\n return listeners.map(([eventName, handler, options]) => {\n return events.on(eventName, handler, options);\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { addCheckoutEventListeners } from '@/checkout/api/initialize/listeners';\nimport {\n Cart as CartModel,\n Customer as CustomerModel,\n ShippingMethod,\n} from '@/checkout/data/models';\nimport { state } from '@/checkout/lib';\nimport { Filter, Selector } from '@/checkout/types/utils';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { deepmerge, Initializer, Model } from '@adobe-commerce/elsie/lib';\n\nconst url = new URL(window.location.href);\nconst quoteId = url.searchParams.get('quoteId');\nstate.quoteId = quoteId;\n\nexport type ConfigProps = {\n defaults?: {\n isBillToShipping?: boolean;\n selectedShippingMethod?: Selector<ShippingMethod>;\n };\n shipping?: {\n filterOptions?: Filter<ShippingMethod>;\n };\n features?: {\n b2b?: {\n quotes?: boolean;\n routeLogin?: () => string | void;\n };\n };\n langDefinitions?: Lang;\n models?: {\n CartModel?: Model<CartModel>;\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (_config = {}) => {\n initialize.config.setConfig(\n deepmerge(\n {\n defaults: {\n isBillToShipping: true,\n selectedShippingMethod: (options) => {\n return options.length > 0 ? options[0] : null;\n },\n },\n features: {\n b2b: { quotes: false },\n },\n },\n _config\n )\n );\n },\n listeners: addCheckoutEventListeners,\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n CartModel,\n InitializeInput,\n NegotiableQuoteModel,\n SynchronizeInput,\n} from '@/checkout/types';\n\nexport const isCartInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is CartModel => {\n return 'id' in input;\n};\n\nexport const isNegotiableQuoteInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is NegotiableQuoteModel => {\n return 'uid' in input;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCart,\n getNegotiableQuote,\n getStoreConfig,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib';\nimport { InitializeInput, isCartInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getInitialData = async (input: NonNullable<InitializeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout initialization failed:', error);\n return null;\n }\n};\n\nexport const initializeCheckout = async (input: InitializeInput) => {\n if (state.initialized) {\n await synchronizeCheckout(input);\n return;\n }\n\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const initialData = input ? await getInitialData(input) : null;\n\n state.initialized = true;\n events.emit('checkout/initialized', initialData);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/checkout/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const resetCheckout = () => {\n if (!state.initialized) return;\n state.cartId = null;\n state.quoteId = null;\n events.emit('checkout/updated', null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCart,\n getNegotiableQuote,\n initializeCheckout,\n resetCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { isCartInput, SynchronizeInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getSynchronizedData = async (input: NonNullable<SynchronizeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout synchronization failed:', error);\n return null;\n }\n};\n\nexport const synchronizeCheckout = async (data: SynchronizeInput) => {\n if (!state.initialized) return initializeCheckout(data);\n\n if (data === null) {\n resetCheckout();\n return;\n }\n\n const update = await getSynchronizedData(data);\n\n events.emit('checkout/updated', update);\n};\n"],"names":["authenticateCustomer","authenticated","state","transformSelectedPaymentMethod","data","transformAvailablePaymentMethods","method","code","title","transformCart","model","transformCartBillingAddress","transformCartShippingAddress","merge","_c","_b","_a","config","transformAddress","street","transformAddressCountry","transformCustomAttributes","transformAddressRegion","transformQuoteBillingAddress","transformQuoteShippingAddress","address","available_shipping_methods","selected_shipping_method","baseData","transformShippingMethods","transformSelectedShippingMethod","transformNegotiableQuote","getCartQuery","CHECKOUT_DATA_FRAGMENT","getCustomerCartQuery","getCart","cartId","isGuest","query","variables","MissingCart","dispatchApiCall","getNegotiableQuoteQuery","NEGOTIABLE_QUOTE_FRAGMENT","getNegotiableQuote","input","quoteId","Unauthenticated","MissingNegotiableQuoteId","transformer","asEager","addCheckoutEventListeners","useB2bQuotes","isAuthenticated","destination","initializeCheckout","resetCheckout","synchronizeCheckout","eventName","handler","options","events","url","initialize","Initializer","_config","deepmerge","isCartInput","getInitialData","error","getStoreConfig","initialData","getSynchronizedData","update"],"mappings":"mYAmBa,MAAAA,EAAuB,MAAOC,EAAgB,KAAU,CACnEC,EAAM,cAAgBD,CACxB,ECWME,EACJC,GAC8B,CAC9B,GAAKA,EACL,MAAO,CAAE,KAAMA,EAAK,KAAM,MAAOA,EAAK,KAAM,CAC9C,EAEMC,EACJD,GACgC,CAChC,GAAKA,EAEE,OAAAA,EACJ,OAAQE,GAAW,CAAC,CAACA,CAAM,EAC3B,IAAKA,GAAW,CACT,KAAA,CAAE,KAAAC,EAAM,MAAAC,CAAA,EAAUF,EACjB,MAAA,CAAE,KAAAC,EAAM,MAAAC,CAAM,CAAA,CACtB,CACL,EChBMC,EAAiBL,GAAsC,WAC3D,GAAI,CAACA,EAAM,OAEX,MAAMM,EAAQ,CACZ,wBAAyBL,EACvBD,EAAK,yBACP,EACA,eAAgBO,EAA4BP,EAAK,eAAe,EAChE,MAAOA,EAAK,OAAS,OACrB,GAAIA,EAAK,GACT,QAASA,EAAK,iBAAmB,EACjC,UAAWA,EAAK,WAChB,sBAAuBD,EACrBC,EAAK,uBACP,EACA,kBAAmBQ,EAA6BR,EAAK,kBAAkB,EACvE,QAAS,CAACF,EAAM,aAClB,EAGO,OAAAW,EACLH,GACAI,GAAAC,GAAAC,EAAAC,EAAO,UAAU,EAAE,SAAnB,YAAAD,EAA2B,YAA3B,YAAAD,EAAsC,cAAtC,YAAAD,EAAA,KAAAC,EAAoDX,EACtD,CACF,EChBMc,EACJd,GACiB,CACjB,MAAMe,EAASf,EAAK,OAAO,O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AevB,CAAK,EAAI,KAE1D3C,EAAM,YAAc,GACb2D,EAAA,KAAK,uBAAwBU,CAAW,CACjD,ECrCaf,EAAgB,IAAM,CAC5BtD,EAAM,cACXA,EAAM,OAAS,KACfA,EAAM,QAAU,KACT2D,EAAA,KAAK,mBAAoB,IAAI,EACtC,ECEMW,GAAsB,MAAO3B,GAAyC,CACtE,GAAA,CACE,OAAAsB,EAAYtB,CAAK,GACnB3C,EAAM,OAAS2C,EAAM,GACrB3C,EAAM,QAAU,KACR,MAAMiC,KAAc,OAE9BjC,EAAM,OAAS,KACfA,EAAM,QAAU2C,EAAM,IACd,MAAMD,KAAyB,YAChCyB,EAAO,CACN,eAAA,MAAM,mCAAoCA,CAAK,EAChD,IAAA,CAEX,EAEaZ,EAAsB,MAAOrD,GAA2B,CACnE,GAAI,CAACF,EAAM,YAAa,OAAOqD,EAAmBnD,CAAI,EAEtD,GAAIA,IAAS,KAAM,CACHoD,EAAA,EACd,MAAA,CAGI,MAAAiB,EAAS,MAAMD,GAAoBpE,CAAI,EAEtCyD,EAAA,KAAK,mBAAoBY,CAAM,CACxC"}
1
+ {"version":3,"file":"synchronizeCheckout.js","sources":["/@dropins/storefront-checkout/src/api/authenticateCustomer/authenticateCustomer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-payment-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart.ts","/@dropins/storefront-checkout/src/data/transforms/transform-quote-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-negotiable-quote.ts","/@dropins/storefront-checkout/src/api/getCart/graphql/getCart.graphql.ts","/@dropins/storefront-checkout/src/api/getCart/getCart.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/getNegotiableQuote.ts","/@dropins/storefront-checkout/src/api/initialize/listeners.ts","/@dropins/storefront-checkout/src/api/initialize/initialize.ts","/@dropins/storefront-checkout/src/types/guards.ts","/@dropins/storefront-checkout/src/api/initializeCheckout/initializeCheckout.ts","/@dropins/storefront-checkout/src/api/resetCheckout/resetCheckout.ts","/@dropins/storefront-checkout/src/api/synchronizeCheckout/synchronizeCheckout.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/checkout/lib/state';\n\nexport const authenticateCustomer = async (authenticated = false) => {\n state.authenticated = authenticated;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype SelectedPaymentMethod = NonNullable<\n GetCartQuery['cart']\n>['selected_payment_method'];\n\ntype AvailablePaymentMethods = NonNullable<\n GetCartQuery['cart']\n>['available_payment_methods'];\n\ntype AvailablePaymentMethod = NonNullable<AvailablePaymentMethods>[number];\n\ntype NonNullabePaymentMethod = NonNullable<AvailablePaymentMethod>;\n\nconst transformSelectedPaymentMethod = (\n data: SelectedPaymentMethod\n): PaymentMethod | undefined => {\n if (!data) return;\n const { code, title, ...additionalData } = data;\n return { code, title, additionalData };\n};\n\nconst transformAvailablePaymentMethods = (\n data: AvailablePaymentMethods\n): PaymentMethod[] | undefined => {\n if (!data) return;\n\n return data\n .filter((method) => !!method)\n .map((method) => {\n const { code, title, ...additionalData } =\n method as NonNullabePaymentMethod;\n return { code, title, additionalData };\n });\n};\n\nexport { transformAvailablePaymentMethods, transformSelectedPaymentMethod };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport { Cart as CartModel } from '@/checkout/data/models';\nimport {\n transformAvailablePaymentMethods,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms/transform-payment-methods';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nimport {\n transformCartBillingAddress,\n transformCartShippingAddress,\n} from '@/checkout/data/transforms/transform-cart-address';\nimport { state } from '@/checkout/lib/state';\n\ntype Cart = GetCartQuery['cart'];\n\nconst transformCart = (data: Cart): CartModel | undefined => {\n if (!data) return;\n\n const model = {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformCartBillingAddress(data.billing_address),\n email: data.email ?? undefined,\n id: data.id,\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformCartShippingAddress(data.shipping_addresses),\n isGuest: !state.authenticated,\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CartModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Cart, transformCart };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n Address as AddressModel,\n ShippingAddress as ShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\ntype QuoteShippingAddresses = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['shipping_addresses'];\ntype QuoteShippingAddress = QuoteShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<QuoteShippingAddress>;\n\ntype QuoteBillingAddress = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<QuoteBillingAddress>;\n\nconst transformAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): AddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n customerAddressUid: data.customer_address_uid || undefined,\n fax: data.fax || undefined,\n firstName: data.firstname,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformQuoteBillingAddress = (\n data: QuoteBillingAddress\n): AddressModel | undefined => {\n if (!data) return;\n return transformAddress(data);\n};\n\nconst transformQuoteShippingAddress = (\n data: QuoteShippingAddresses\n): ShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n };\n });\n};\n\nexport {\n QuoteBillingAddress,\n QuoteShippingAddress,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NegotiableQuote as NegotiableQuoteModel } from '@/checkout/data/models/';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\nimport {\n transformAvailablePaymentMethods,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms';\n\ntype NegotiableQuote = GetNegotiableQuoteQuery['negotiableQuote'];\n\nexport const transformNegotiableQuote = (\n data: NegotiableQuote | undefined\n): NegotiableQuoteModel | null => {\n if (!data) return null;\n\n return {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformQuoteBillingAddress(data.billing_address),\n email: data.email ?? '',\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n name: data.name,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformQuoteShippingAddress(data.shipping_addresses),\n status: data.status,\n uid: data.uid,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const getCartQuery = /* GraphQL */ `\n query getCart($cartId: String!) {\n cart(cart_id: $cartId) {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n\nexport const getCustomerCartQuery = /* GraphQL */ `\n query getCustomerCart {\n cart: customerCart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCartQuery,\n getCustomerCartQuery,\n} from '@/checkout/api/getCart/graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib';\nimport { MissingCart } from '@/checkout/lib/errors';\n\nexport const getCart = async () => {\n const cartId = state.cartId;\n const isGuest = state.authenticated === false;\n const query = isGuest ? getCartQuery : getCustomerCartQuery;\n const variables = isGuest ? { cartId } : {};\n\n if (isGuest && !cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n type: 'query',\n query,\n options: { method: 'POST', cache: 'no-cache', variables },\n path: 'cart',\n transformer: transformCart,\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const getNegotiableQuoteQuery = /* GraphQL */ `\n query getNegotiableQuote($quoteId: ID!) {\n negotiableQuote(uid: $quoteId) {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getNegotiableQuoteQuery } from '@/checkout/api/getNegotiableQuote/graphql';\nimport { transformNegotiableQuote as transformer } from '@/checkout/data/transforms';\nimport { state } from '@/checkout/lib';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport {\n MissingNegotiableQuoteId,\n Unauthenticated,\n} from '@/checkout/lib/errors';\n\ntype GetNegotiableQuoteInput = {\n uid?: string;\n};\n\nexport const getNegotiableQuote = async (\n input: GetNegotiableQuoteInput = {}\n) => {\n const quoteId = input.uid ?? state.quoteId;\n const isGuest = state.authenticated === false;\n\n if (isGuest) throw new Unauthenticated();\n if (!quoteId) throw new MissingNegotiableQuoteId();\n\n const variables = { quoteId };\n\n return await dispatchApiCall({\n type: 'query',\n query: getNegotiableQuoteQuery,\n options: { method: 'GET', cache: 'no-cache', variables },\n path: 'negotiableQuote',\n transformer,\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n authenticateCustomer,\n ConfigProps,\n initializeCheckout,\n resetCheckout,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { ErrorCodes } from '@/checkout/lib/errors';\nimport { events, Events } from '@adobe-commerce/event-bus';\n\ntype Listener = [keyof Events, (...args: any[]) => void, { eager: boolean }?];\n\nconst asEager = { eager: true };\n\nexport const addCheckoutEventListeners = (config: ConfigProps | undefined) => {\n const useB2bQuotes = config?.features?.b2b?.quotes ?? false;\n\n const handleAuthenticated = (isAuthenticated = false) => {\n authenticateCustomer(isAuthenticated);\n\n if (!useB2bQuotes) return;\n if (isAuthenticated) return;\n\n const destination = config?.features?.b2b?.routeLogin?.();\n if (destination) {\n window.location.assign(destination);\n }\n };\n\n const cartListeners: Listener[] = [\n ['cart/initialized', initializeCheckout, asEager],\n ['cart/reset', resetCheckout],\n ['cart/updated', synchronizeCheckout],\n ];\n\n const quoteListeners: Listener[] = [\n [\n 'quote-management/quote-data/initialized',\n (data) => {\n if (!data.quote.canCheckout) {\n const message =\n config?.langDefinitions?.default?.Checkout?.Quote\n ?.permissionDenied ||\n 'You do not have permission to checkout with this quote.';\n events.emit('checkout/error', {\n message,\n code: ErrorCodes.QUOTE_PERMISSION_DENIED,\n });\n return;\n }\n\n initializeCheckout(data.quote);\n },\n asEager,\n ],\n [\n 'quote-management/quote-data/error',\n () => {\n const message =\n config?.langDefinitions?.default?.Checkout?.Quote?.dataError ||\n 'We were unable to retrieve the quote data. Please try again later.';\n events.emit('checkout/error', {\n message,\n code: ErrorCodes.QUOTE_DATA_ERROR,\n });\n },\n ],\n ];\n\n const listeners: Listener[] = [\n ['authenticated', handleAuthenticated, asEager],\n ...(useB2bQuotes ? quoteListeners : cartListeners),\n ];\n\n return listeners.map(([eventName, handler, options]) => {\n return events.on(eventName, handler, options);\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { addCheckoutEventListeners } from '@/checkout/api/initialize/listeners';\nimport {\n Cart as CartModel,\n Customer as CustomerModel,\n ShippingMethod,\n} from '@/checkout/data/models';\nimport { state } from '@/checkout/lib';\nimport { Filter, Selector } from '@/checkout/types/utils';\nimport { definition } from '@adobe-commerce/elsie/i18n';\nimport { deepmerge, Initializer, Model } from '@adobe-commerce/elsie/lib';\n\nconst url = new URL(window.location.href);\nconst quoteId = url.searchParams.get('quoteId');\nstate.quoteId = quoteId;\n\nexport type ConfigProps = {\n defaults?: {\n isBillToShipping?: boolean;\n selectedShippingMethod?: Selector<ShippingMethod>;\n };\n shipping?: {\n filterOptions?: Filter<ShippingMethod>;\n };\n features?: {\n b2b?: {\n quotes?: boolean;\n routeLogin?: () => string | void;\n };\n };\n langDefinitions?: typeof definition & { default: { Checkout: any } };\n models?: {\n CartModel?: Model<CartModel>;\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (_config = {}) => {\n initialize.config.setConfig(\n deepmerge(\n {\n defaults: {\n isBillToShipping: true,\n selectedShippingMethod: (options) => {\n return options.length > 0 ? options[0] : null;\n },\n },\n features: {\n b2b: { quotes: false },\n },\n },\n _config\n )\n );\n },\n listeners: addCheckoutEventListeners,\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n CartModel,\n InitializeInput,\n NegotiableQuoteModel,\n SynchronizeInput,\n} from '@/checkout/types';\n\nexport const isCartInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is CartModel => {\n return 'id' in input;\n};\n\nexport const isNegotiableQuoteInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is NegotiableQuoteModel => {\n return 'uid' in input;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCart,\n getNegotiableQuote,\n getStoreConfig,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib';\nimport { InitializeInput, isCartInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getInitialData = async (input: NonNullable<InitializeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout initialization failed:', error);\n return null;\n }\n};\n\nexport const initializeCheckout = async (input: InitializeInput) => {\n if (state.initialized) {\n await synchronizeCheckout(input);\n return;\n }\n\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const initialData = input ? await getInitialData(input) : null;\n\n state.initialized = true;\n events.emit('checkout/initialized', initialData);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/checkout/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const resetCheckout = () => {\n if (!state.initialized) return;\n state.cartId = null;\n state.quoteId = null;\n events.emit('checkout/updated', null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCart,\n getNegotiableQuote,\n initializeCheckout,\n resetCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { isCartInput, SynchronizeInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getSynchronizedData = async (input: NonNullable<SynchronizeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout synchronization failed:', error);\n return null;\n }\n};\n\nexport const synchronizeCheckout = async (data: SynchronizeInput) => {\n if (!state.initialized) return initializeCheckout(data);\n\n if (data === null) {\n resetCheckout();\n return;\n }\n\n const update = await getSynchronizedData(data);\n\n events.emit('checkout/updated', update);\n};\n"],"names":["authenticateCustomer","authenticated","state","transformSelectedPaymentMethod","data","code","title","additionalData","transformAvailablePaymentMethods","method","transformCart","model","transformCartBillingAddress","transformCartShippingAddress","merge","_c","_b","_a","config","transformAddress","street","transformAddressCountry","transformCustomAttributes","transformAddressRegion","transformQuoteBillingAddress","transformQuoteShippingAddress","address","available_shipping_methods","selected_shipping_method","baseData","transformShippingMethods","transformSelectedShippingMethod","transformNegotiableQuote","getCartQuery","CHECKOUT_DATA_FRAGMENT","getCustomerCartQuery","getCart","cartId","isGuest","query","variables","MissingCart","dispatchApiCall","getNegotiableQuoteQuery","NEGOTIABLE_QUOTE_FRAGMENT","getNegotiableQuote","input","quoteId","Unauthenticated","MissingNegotiableQuoteId","transformer","asEager","addCheckoutEventListeners","useB2bQuotes","isAuthenticated","destination","message","_d","events","ErrorCodes","initializeCheckout","resetCheckout","synchronizeCheckout","eventName","handler","options","url","initialize","Initializer","_config","deepmerge","isCartInput","getInitialData","error","getStoreConfig","initialData","getSynchronizedData","update"],"mappings":"waAmBa,MAAAA,EAAuB,MAAOC,EAAgB,KAAU,CACnEC,EAAM,cAAgBD,CACxB,ECWME,EACJC,GAC8B,CAC9B,GAAI,CAACA,EAAM,OACX,KAAM,CAAE,KAAAC,EAAM,MAAAC,EAAO,GAAGC,CAAmB,EAAAH,EACpC,MAAA,CAAE,KAAAC,EAAM,MAAAC,EAAO,eAAAC,CAAe,CACvC,EAEMC,EAC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YAAa,CACrB,MAAM4D,EAAoBhB,CAAK,EAC/B,MAAA,CAGG5C,EAAM,SACHA,EAAA,OAAS,MAAMwE,EAAe,GAGtC,MAAMC,EAAc7B,EAAQ,MAAM0B,GAAe1B,CAAK,EAAI,KAE1D5C,EAAM,YAAc,GACbwD,EAAA,KAAK,uBAAwBiB,CAAW,CACjD,ECrCad,EAAgB,IAAM,CAC5B3D,EAAM,cACXA,EAAM,OAAS,KACfA,EAAM,QAAU,KACTwD,EAAA,KAAK,mBAAoB,IAAI,EACtC,ECEMkB,GAAsB,MAAO9B,GAAyC,CACtE,GAAA,CACE,OAAAyB,EAAYzB,CAAK,GACnB5C,EAAM,OAAS4C,EAAM,GACrB5C,EAAM,QAAU,KACR,MAAMkC,KAAc,OAE9BlC,EAAM,OAAS,KACfA,EAAM,QAAU4C,EAAM,IACd,MAAMD,KAAyB,YAChC4B,EAAO,CACN,eAAA,MAAM,mCAAoCA,CAAK,EAChD,IAAA,CAEX,EAEaX,EAAsB,MAAO1D,GAA2B,CACnE,GAAI,CAACF,EAAM,YAAa,OAAO0D,EAAmBxD,CAAI,EAEtD,GAAIA,IAAS,KAAM,CACHyD,EAAA,EACd,MAAA,CAGI,MAAAgB,EAAS,MAAMD,GAAoBxE,CAAI,EAEtCsD,EAAA,KAAK,mBAAoBmB,CAAM,CACxC"}
@@ -0,0 +1,17 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { HTMLAttributes } from 'preact/compat';
3
+ import { Money } from '../../data/models';
4
+
5
+ export type CompanyCredit = {
6
+ availableCredit: Money;
7
+ exceedLimit?: boolean;
8
+ };
9
+ export interface PaymentOnAccountProps extends HTMLAttributes<HTMLFormElement> {
10
+ referenceNumber?: string;
11
+ onReferenceNumberChange?: (event: Event) => void;
12
+ onReferenceNumberBlur?: (event: Event) => void;
13
+ companyCredit?: CompanyCredit | null;
14
+ cartAmount?: Money | null;
15
+ }
16
+ export declare const PaymentOnAccount: FunctionComponent<PaymentOnAccountProps & import('../ConditionalWrapper/ConditionalWrapper').ConditionalProps>;
17
+ //# sourceMappingURL=PaymentOnAccount.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { FunctionComponent } from 'preact';
2
+
3
+ export declare const PaymentOnAccountSkeleton: FunctionComponent;
4
+ //# sourceMappingURL=PaymentOnAccountSkeleton.d.ts.map
@@ -0,0 +1,20 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './PaymentOnAccount';
18
+ export * from './PaymentOnAccountSkeleton';
19
+ export { PaymentOnAccount as default } from './PaymentOnAccount';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { HTMLAttributes } from 'preact/compat';
3
+
4
+ export interface PurchaseOrderProps extends HTMLAttributes<HTMLFormElement> {
5
+ referenceNumber?: string;
6
+ onReferenceNumberChange?: (event: Event) => void;
7
+ onReferenceNumberBlur?: (event: Event) => void;
8
+ }
9
+ export declare const PurchaseOrder: FunctionComponent<PurchaseOrderProps>;
10
+ //# sourceMappingURL=PurchaseOrder.d.ts.map
@@ -0,0 +1,19 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './PurchaseOrder';
18
+ export { PurchaseOrder as default } from './PurchaseOrder';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -16,13 +16,15 @@
16
16
  *******************************************************************/
17
17
  export * from './AddressValidation';
18
18
  export * from './BillToShippingAddress';
19
- export * from './ConditionalWrapper/index';
19
+ export * from './ConditionalWrapper';
20
20
  export * from './EstimateShipping';
21
21
  export * from './LoginForm';
22
22
  export * from './Markup';
23
23
  export * from './OutOfStock';
24
24
  export * from './PaymentMethods';
25
+ export * from './PaymentOnAccount';
25
26
  export * from './PlaceOrder';
27
+ export * from './PurchaseOrder';
26
28
  export * from './ServerError';
27
29
  export * from './ShippingMethods';
28
30
  export * from './TermsAndConditions';
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as h,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{useState as p,useMemo as N,useCallback as k,useEffect as _}from"@dropins/tools/preact-hooks.js";import"../chunks/TermsAndConditions.js";import{classes as A}from"@dropins/tools/lib.js";import{Header as $,ToggleButton as b}from"@dropins/tools/components.js";import{useText as V}from"@dropins/tools/i18n.js";/* empty css *//* empty css */import"../chunks/fetch-graphql.js";import{t as x}from"../chunks/transform-shipping-methods.js";import{events as y}from"@dropins/tools/event-bus.js";import{g as B}from"../chunks/events.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";function T(t){var f;if(!t)return[];const a=`${t.firstName} ${t.lastName}`.trim(),m=((f=t.street)==null?void 0:f[0])??"",r=t.city??"",s=t.region||"",n=t.postcode??"",c=t.countryCode??"";let e="";r&&s?e=`${r}, ${s}`:r?e=r:s&&(e=s);let d=e;n&&(d=e?`${e} ${n}`:n);let u=d;return c&&(u=d?`${d}, ${c}`:c),[a,m,u]}const C=({title:t,address:a,selected:m,busy:r,onChange:s})=>{const[n,c,e]=T(a);return o("div",{className:"checkout-address-validation__option",children:o(b,{busy:r,className:"checkout-address-validation__radio",label:h("div",{children:[o("div",{className:"checkout-address-validation__option-title",children:o("strong",{children:t})}),n&&o("div",{children:n}),c&&o("div",{children:c}),e&&o("div",{children:e})]}),name:"address-validation-choice",selected:m,value:t,onChange:s})})},j=({busy:t=!1,className:a,currentAddress:m,onSelectionChange:r,selection:s,suggestedAddress:n})=>{const c=!!n,e=V({title:"Checkout.AddressValidation.title",subtitle:"Checkout.AddressValidation.subtitle",suggestedAddress:"Checkout.AddressValidation.suggestedAddress",originalAddress:"Checkout.AddressValidation.originalAddress"});return h("div",{className:A(["checkout-address-validation",a]),children:[o($,{className:"checkout-address-validation__title",divider:!1,title:e.title}),o("div",{className:"checkout-address-validation__subtitle",children:e.subtitle}),h("div",{className:A(["checkout-address-validation__options",t&&"checkout-address-validation__options--busy"]),children:[c&&o(C,{address:n,busy:t,selected:s==="suggested",title:e.suggestedAddress,onChange:()=>r("suggested")}),o(C,{address:m,busy:t,selected:s==="original",title:e.originalAddress,onChange:()=>r("original")})]})]})},Q=({suggestedAddress:t,handleSelectedAddress:a})=>{const[m,r]=p(null),[s,n]=p(void 0),[c,e]=p(!1),d=N(()=>!t||!s?null:{...s,regionId:void 0,...t},[s,t]),u=k(i=>{var v;const l=(v=i==null?void 0:i.shippingAddresses)==null?void 0:v[0],g=x(l);n(g)},[]);_(()=>{const i=y.on("checkout/initialized",l=>{u(l)},{eager:!0});return()=>{i==null||i.off()}},[u]),_(()=>{const i=B();i&&u(i);const l=y.on("checkout/updated",g=>{u(g)},{eager:!1});return()=>{l==null||l.off()}},[u]);const f=k(async i=>{r(i);const l=i==="suggested"?d:s;e(!0);try{await(a==null?void 0:a({selection:i,address:l}))}finally{e(!1)}},[d,s,a]);return o(j,{busy:c,currentAddress:s,selection:m,suggestedAddress:d,onSelectionChange:f})};export{Q as AddressValidation,Q as default};
3
+ import{jsxs as h,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{useState as p,useMemo as N,useCallback as k,useEffect as _}from"@dropins/tools/preact-hooks.js";import"../chunks/TermsAndConditions.js";import{classes as A}from"@dropins/tools/lib.js";import{Header as $,ToggleButton as b}from"@dropins/tools/components.js";import{useText as V}from"@dropins/tools/i18n.js";/* empty css */import"../chunks/fetch-graphql.js";import{t as x}from"../chunks/transform-shipping-methods.js";import{events as y}from"@dropins/tools/event-bus.js";import{a as B}from"../chunks/events2.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css */import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";function T(t){var f;if(!t)return[];const a=`${t.firstName} ${t.lastName}`.trim(),m=((f=t.street)==null?void 0:f[0])??"",r=t.city??"",s=t.region||"",n=t.postcode??"",c=t.countryCode??"";let e="";r&&s?e=`${r}, ${s}`:r?e=r:s&&(e=s);let d=e;n&&(d=e?`${e} ${n}`:n);let u=d;return c&&(u=d?`${d}, ${c}`:c),[a,m,u]}const C=({title:t,address:a,selected:m,busy:r,onChange:s})=>{const[n,c,e]=T(a);return o("div",{className:"checkout-address-validation__option",children:o(b,{busy:r,className:"checkout-address-validation__radio",label:h("div",{children:[o("div",{className:"checkout-address-validation__option-title",children:o("strong",{children:t})}),n&&o("div",{children:n}),c&&o("div",{children:c}),e&&o("div",{children:e})]}),name:"address-validation-choice",selected:m,value:t,onChange:s})})},j=({busy:t=!1,className:a,currentAddress:m,onSelectionChange:r,selection:s,suggestedAddress:n})=>{const c=!!n,e=V({title:"Checkout.AddressValidation.title",subtitle:"Checkout.AddressValidation.subtitle",suggestedAddress:"Checkout.AddressValidation.suggestedAddress",originalAddress:"Checkout.AddressValidation.originalAddress"});return h("div",{className:A(["checkout-address-validation",a]),children:[o($,{className:"checkout-address-validation__title",divider:!1,title:e.title}),o("div",{className:"checkout-address-validation__subtitle",children:e.subtitle}),h("div",{className:A(["checkout-address-validation__options",t&&"checkout-address-validation__options--busy"]),children:[c&&o(C,{address:n,busy:t,selected:s==="suggested",title:e.suggestedAddress,onChange:()=>r("suggested")}),o(C,{address:m,busy:t,selected:s==="original",title:e.originalAddress,onChange:()=>r("original")})]})]})},Q=({suggestedAddress:t,handleSelectedAddress:a})=>{const[m,r]=p(null),[s,n]=p(void 0),[c,e]=p(!1),d=N(()=>!t||!s?null:{...s,regionId:void 0,...t},[s,t]),u=k(i=>{var v;const l=(v=i==null?void 0:i.shippingAddresses)==null?void 0:v[0],g=x(l);n(g)},[]);_(()=>{const i=y.on("checkout/initialized",l=>{u(l)},{eager:!0});return()=>{i==null||i.off()}},[u]),_(()=>{const i=B();i&&u(i);const l=y.on("checkout/updated",g=>{u(g)},{eager:!1});return()=>{l==null||l.off()}},[u]);const f=k(async i=>{r(i);const l=i==="suggested"?d:s;e(!0);try{await(a==null?void 0:a({selection:i,address:l}))}finally{e(!1)}},[d,s,a]);return o(j,{busy:c,currentAddress:s,selection:m,suggestedAddress:d,onSelectionChange:f})};export{Q as AddressValidation,Q as default};
4
4
  //# sourceMappingURL=AddressValidation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddressValidation.js","sources":["/@dropins/storefront-checkout/src/components/AddressValidation/AddressValidation.tsx","/@dropins/storefront-checkout/src/containers/AddressValidation/AddressValidation.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport '@/checkout/components/AddressValidation/AddressValidation.css';\nimport { AddressInput } from '@/checkout/data/models';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { Header, ToggleButton } from '@adobe-commerce/elsie/components';\n\nexport interface AddressValidationProps extends HTMLAttributes<HTMLDivElement> {\n busy?: boolean;\n currentAddress: AddressInput | null | undefined;\n selection: 'suggested' | 'original' | null;\n suggestedAddress: AddressInput | null;\n onSelectionChange: (selection: 'suggested' | 'original') => void;\n}\n\nexport function formatAddressLine(\n address: AddressInput | null | undefined\n): string[] {\n if (!address) return [];\n const name = `${address.firstName} ${address.lastName}`.trim();\n const street = address.street?.[0] ?? '';\n const city = address.city ?? '';\n const region = address.region || '';\n const post = address.postcode ?? '';\n const country = address.countryCode ?? '';\n\n let cityRegion = '';\n if (city && region) {\n cityRegion = `${city}, ${region}`;\n } else if (city) {\n cityRegion = city;\n } else if (region) {\n cityRegion = region;\n }\n\n let cityRegionPost = cityRegion;\n if (post) {\n cityRegionPost = cityRegion ? `${cityRegion} ${post}` : post;\n }\n\n let line3 = cityRegionPost;\n if (country) {\n line3 = cityRegionPost ? `${cityRegionPost}, ${country}` : country;\n }\n\n return [name, street, line3];\n}\n\nconst AddressBlock: FunctionComponent<{\n title: string;\n address: AddressInput | null | undefined;\n selected: boolean;\n busy?: boolean;\n onChange: () => void;\n}> = ({ title, address, selected, busy, onChange }) => {\n const [line1, line2, line3] = formatAddressLine(address);\n const label = (\n <div>\n <div className=\"checkout-address-validation__option-title\">\n <strong>{title}</strong>\n </div>\n {line1 && <div>{line1}</div>}\n {line2 && <div>{line2}</div>}\n {line3 && <div>{line3}</div>}\n </div>\n );\n return (\n <div className=\"checkout-address-validation__option\">\n <ToggleButton\n busy={busy}\n className=\"checkout-address-validation__radio\"\n label={label}\n name=\"address-validation-choice\"\n selected={selected}\n value={title}\n onChange={onChange}\n />\n </div>\n );\n};\n\nexport const AddressValidation: FunctionComponent<AddressValidationProps> = ({\n busy = false,\n className,\n currentAddress,\n onSelectionChange,\n selection,\n suggestedAddress,\n}) => {\n const hasSuggestion = !!suggestedAddress;\n const translations = useText({\n title: 'Checkout.AddressValidation.title',\n subtitle: 'Checkout.AddressValidation.subtitle',\n suggestedAddress: 'Checkout.AddressValidation.suggestedAddress',\n originalAddress: 'Checkout.AddressValidation.originalAddress',\n });\n\n return (\n <div className={classes(['checkout-address-validation', className])}>\n <Header\n className=\"checkout-address-validation__title\"\n divider={false}\n title={translations.title}\n />\n <div className=\"checkout-address-validation__subtitle\">\n {translations.subtitle}\n </div>\n\n <div\n className={classes([\n 'checkout-address-validation__options',\n busy && 'checkout-address-validation__options--busy',\n ])}\n >\n {hasSuggestion && (\n <AddressBlock\n address={suggestedAddress}\n busy={busy}\n selected={selection === 'suggested'}\n title={translations.suggestedAddress}\n onChange={() => onSelectionChange('suggested')}\n />\n )}\n\n <AddressBlock\n address={currentAddress}\n busy={busy}\n selected={selection === 'original'}\n title={translations.originalAddress}\n onChange={() => onSelectionChange('original')}\n />\n </div>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\nimport { AddressValidation as AddressValidationComponent } from '@/checkout/components';\nimport { Cart, AddressInput, NegotiableQuote } from '@/checkout/data/models';\nimport { getLatestCheckoutUpdate } from '@/checkout/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { transformAddressToCartAddressInput } from '@/checkout/data/transforms/transform-cart-address';\n\nexport interface AddressValidationProps {\n suggestedAddress: Partial<AddressInput> | null;\n handleSelectedAddress?: (payload: {\n selection: 'suggested' | 'original';\n address: AddressInput | null | undefined;\n }) => void;\n}\n\nexport const AddressValidation: Container<AddressValidationProps> = ({\n suggestedAddress,\n handleSelectedAddress,\n}) => {\n const [selection, setSelection] = useState<'suggested' | 'original' | null>(\n null\n );\n const [currentAddress, setCurrentAddress] = useState<\n AddressInput | null | undefined\n >(undefined);\n const [busy, setBusy] = useState(false);\n\n const mergedSuggestedAddress = useMemo<AddressInput | null>(() => {\n if (!suggestedAddress || !currentAddress) return null;\n return { ...currentAddress, regionId: undefined, ...suggestedAddress };\n }, [currentAddress, suggestedAddress]);\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const addr = (data as Cart | null)?.shippingAddresses?.[0];\n const input = transformAddressToCartAddressInput(addr);\n setCurrentAddress(input);\n },\n []\n );\n\n useEffect(() => {\n const onCheckoutInitialized = events.on(\n 'checkout/initialized',\n (data: Cart | NegotiableQuote | null) => {\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInitialized?.off();\n };\n }, [handleCheckoutData]);\n\n useEffect(() => {\n const pastUpdate = getLatestCheckoutUpdate();\n if (pastUpdate) {\n handleCheckoutData(pastUpdate);\n }\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n (data: Cart | NegotiableQuote | null) => {\n handleCheckoutData(data);\n },\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [handleCheckoutData]);\n\n const onSelectionChange = useCallback(\n async (sel: 'suggested' | 'original') => {\n setSelection(sel);\n const chosen =\n sel === 'suggested' ? mergedSuggestedAddress : currentAddress;\n setBusy(true);\n try {\n await handleSelectedAddress?.({ selection: sel, address: chosen });\n } finally {\n setBusy(false);\n }\n },\n [mergedSuggestedAddress, currentAddress, handleSelectedAddress]\n );\n\n return (\n <AddressValidationComponent\n busy={busy}\n currentAddress={currentAddress}\n selection={selection}\n suggestedAddress={mergedSuggestedAddress}\n onSelectionChange={onSelectionChange}\n />\n );\n};\n"],"names":["formatAddressLine","address","name","street","_a","city","region","post","country","cityRegion","cityRegionPost","line3","AddressBlock","title","selected","busy","onChange","line1","line2","jsx","ToggleButton","AddressValidation","className","currentAddress","onSelectionChange","selection","suggestedAddress","hasSuggestion","translations","useText","jsxs","classes","Header","handleSelectedAddress","setSelection","useState","setCurrentAddress","setBusy","mergedSuggestedAddress","useMemo","handleCheckoutData","useCallback","data","addr","input","transformAddressToCartAddressInput","useEffect","onCheckoutInitialized","events","pastUpdate","getLatestCheckoutUpdate","onCheckoutUpdated","sel","chosen","AddressValidationComponent"],"mappings":"+zBAiCO,SAASA,EACdC,EACU,OACN,GAAA,CAACA,EAAS,MAAO,CAAC,EAChB,MAAAC,EAAO,GAAGD,EAAQ,SAAS,IAAIA,EAAQ,QAAQ,GAAG,KAAK,EACvDE,IAASC,EAAAH,EAAQ,SAAR,YAAAG,EAAiB,KAAM,GAChCC,EAAOJ,EAAQ,MAAQ,GACvBK,EAASL,EAAQ,QAAU,GAC3BM,EAAON,EAAQ,UAAY,GAC3BO,EAAUP,EAAQ,aAAe,GAEvC,IAAIQ,EAAa,GACbJ,GAAQC,EACGG,EAAA,GAAGJ,CAAI,KAAKC,CAAM,GACtBD,EACII,EAAAJ,EACJC,IACIG,EAAAH,GAGf,IAAII,EAAiBD,EACjBF,IACFG,EAAiBD,EAAa,GAAGA,CAAU,IAAIF,CAAI,GAAKA,GAG1D,IAAII,EAAQD,EACZ,OAAIF,IACFG,EAAQD,EAAiB,GAAGA,CAAc,KAAKF,CAAO,GAAKA,GAGtD,CAACN,EAAMC,EAAQQ,CAAK,CAC7B,CAEA,MAAMC,EAMD,CAAC,CAAE,MAAAC,EAAO,QAAAZ,EAAS,SAAAa,EAAU,KAAAC,EAAM,SAAAC,KAAe,CACrD,KAAM,CAACC,EAAOC,EAAOP,CAAK,EAAIX,EAAkBC,CAAO,EAYrD,OAAAkB,EAAC,MAAI,CAAA,UAAU,sCACb,SAAAA,EAACC,EAAA,CACC,KAAAL,EACA,UAAU,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AAA,CACC,KAAAvC,EACA,eAAAQ,EACA,UAAAE,EACA,iBAAkBa,EAClB,kBAAAd,CAAA,CACF,CAEJ"}
1
+ {"version":3,"file":"AddressValidation.js","sources":["/@dropins/storefront-checkout/src/components/AddressValidation/AddressValidation.tsx","/@dropins/storefront-checkout/src/containers/AddressValidation/AddressValidation.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport '@/checkout/components/AddressValidation/AddressValidation.css';\nimport { AddressInput } from '@/checkout/data/models';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { Header, ToggleButton } from '@adobe-commerce/elsie/components';\n\nexport interface AddressValidationProps extends HTMLAttributes<HTMLDivElement> {\n busy?: boolean;\n currentAddress: AddressInput | null | undefined;\n selection: 'suggested' | 'original' | null;\n suggestedAddress: AddressInput | null;\n onSelectionChange: (selection: 'suggested' | 'original') => void;\n}\n\nexport function formatAddressLine(\n address: AddressInput | null | undefined\n): string[] {\n if (!address) return [];\n const name = `${address.firstName} ${address.lastName}`.trim();\n const street = address.street?.[0] ?? '';\n const city = address.city ?? '';\n const region = address.region || '';\n const post = address.postcode ?? '';\n const country = address.countryCode ?? '';\n\n let cityRegion = '';\n if (city && region) {\n cityRegion = `${city}, ${region}`;\n } else if (city) {\n cityRegion = city;\n } else if (region) {\n cityRegion = region;\n }\n\n let cityRegionPost = cityRegion;\n if (post) {\n cityRegionPost = cityRegion ? `${cityRegion} ${post}` : post;\n }\n\n let line3 = cityRegionPost;\n if (country) {\n line3 = cityRegionPost ? `${cityRegionPost}, ${country}` : country;\n }\n\n return [name, street, line3];\n}\n\nconst AddressBlock: FunctionComponent<{\n title: string;\n address: AddressInput | null | undefined;\n selected: boolean;\n busy?: boolean;\n onChange: () => void;\n}> = ({ title, address, selected, busy, onChange }) => {\n const [line1, line2, line3] = formatAddressLine(address);\n const label = (\n <div>\n <div className=\"checkout-address-validation__option-title\">\n <strong>{title}</strong>\n </div>\n {line1 && <div>{line1}</div>}\n {line2 && <div>{line2}</div>}\n {line3 && <div>{line3}</div>}\n </div>\n );\n return (\n <div className=\"checkout-address-validation__option\">\n <ToggleButton\n busy={busy}\n className=\"checkout-address-validation__radio\"\n label={label}\n name=\"address-validation-choice\"\n selected={selected}\n value={title}\n onChange={onChange}\n />\n </div>\n );\n};\n\nexport const AddressValidation: FunctionComponent<AddressValidationProps> = ({\n busy = false,\n className,\n currentAddress,\n onSelectionChange,\n selection,\n suggestedAddress,\n}) => {\n const hasSuggestion = !!suggestedAddress;\n const translations = useText({\n title: 'Checkout.AddressValidation.title',\n subtitle: 'Checkout.AddressValidation.subtitle',\n suggestedAddress: 'Checkout.AddressValidation.suggestedAddress',\n originalAddress: 'Checkout.AddressValidation.originalAddress',\n });\n\n return (\n <div className={classes(['checkout-address-validation', className])}>\n <Header\n className=\"checkout-address-validation__title\"\n divider={false}\n title={translations.title}\n />\n <div className=\"checkout-address-validation__subtitle\">\n {translations.subtitle}\n </div>\n\n <div\n className={classes([\n 'checkout-address-validation__options',\n busy && 'checkout-address-validation__options--busy',\n ])}\n >\n {hasSuggestion && (\n <AddressBlock\n address={suggestedAddress}\n busy={busy}\n selected={selection === 'suggested'}\n title={translations.suggestedAddress}\n onChange={() => onSelectionChange('suggested')}\n />\n )}\n\n <AddressBlock\n address={currentAddress}\n busy={busy}\n selected={selection === 'original'}\n title={translations.originalAddress}\n onChange={() => onSelectionChange('original')}\n />\n </div>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\nimport { AddressValidation as AddressValidationComponent } from '@/checkout/components';\nimport { Cart, AddressInput, NegotiableQuote } from '@/checkout/data/models';\nimport { getLatestCheckoutUpdate } from '@/checkout/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { transformAddressToCartAddressInput } from '@/checkout/data/transforms/transform-cart-address';\n\nexport interface AddressValidationProps {\n suggestedAddress: Partial<AddressInput> | null;\n handleSelectedAddress?: (payload: {\n selection: 'suggested' | 'original';\n address: AddressInput | null | undefined;\n }) => void;\n}\n\nexport const AddressValidation: Container<AddressValidationProps> = ({\n suggestedAddress,\n handleSelectedAddress,\n}) => {\n const [selection, setSelection] = useState<'suggested' | 'original' | null>(\n null\n );\n const [currentAddress, setCurrentAddress] = useState<\n AddressInput | null | undefined\n >(undefined);\n const [busy, setBusy] = useState(false);\n\n const mergedSuggestedAddress = useMemo<AddressInput | null>(() => {\n if (!suggestedAddress || !currentAddress) return null;\n return { ...currentAddress, regionId: undefined, ...suggestedAddress };\n }, [currentAddress, suggestedAddress]);\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const addr = (data as Cart | null)?.shippingAddresses?.[0];\n const input = transformAddressToCartAddressInput(addr);\n setCurrentAddress(input);\n },\n []\n );\n\n useEffect(() => {\n const onCheckoutInitialized = events.on(\n 'checkout/initialized',\n (data: Cart | NegotiableQuote | null) => {\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInitialized?.off();\n };\n }, [handleCheckoutData]);\n\n useEffect(() => {\n const pastUpdate = getLatestCheckoutUpdate();\n if (pastUpdate) {\n handleCheckoutData(pastUpdate);\n }\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n (data: Cart | NegotiableQuote | null) => {\n handleCheckoutData(data);\n },\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [handleCheckoutData]);\n\n const onSelectionChange = useCallback(\n async (sel: 'suggested' | 'original') => {\n setSelection(sel);\n const chosen =\n sel === 'suggested' ? mergedSuggestedAddress : currentAddress;\n setBusy(true);\n try {\n await handleSelectedAddress?.({ selection: sel, address: chosen });\n } finally {\n setBusy(false);\n }\n },\n [mergedSuggestedAddress, currentAddress, handleSelectedAddress]\n );\n\n return (\n <AddressValidationComponent\n busy={busy}\n currentAddress={currentAddress}\n selection={selection}\n suggestedAddress={mergedSuggestedAddress}\n onSelectionChange={onSelectionChange}\n />\n );\n};\n"],"names":["formatAddressLine","address","name","street","_a","city","region","post","country","cityRegion","cityRegionPost","line3","AddressBlock","title","selected","busy","onChange","line1","line2","jsx","ToggleButton","AddressValidation","className","currentAddress","onSelectionChange","selection","suggestedAddress","hasSuggestion","translations","useText","jsxs","classes","Header","handleSelectedAddress","setSelection","useState","setCurrentAddress","setBusy","mergedSuggestedAddress","useMemo","handleCheckoutData","useCallback","data","addr","input","transformAddressToCartAddressInput","useEffect","onCheckoutInitialized","events","pastUpdate","getLatestCheckoutUpdate","onCheckoutUpdated","sel","chosen","AddressValidationComponent"],"mappings":"k0BAiCO,SAASA,EACdC,EACU,OACN,GAAA,CAACA,EAAS,MAAO,CAAC,EAChB,MAAAC,EAAO,GAAGD,EAAQ,SAAS,IAAIA,EAAQ,QAAQ,GAAG,KAAK,EACvDE,IAASC,EAAAH,EAAQ,SAAR,YAAAG,EAAiB,KAAM,GAChCC,EAAOJ,EAAQ,MAAQ,GACvBK,EAASL,EAAQ,QAAU,GAC3BM,EAAON,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AA,EAAuB,KACzB,CAAA,EACC,CAACP,CAAkB,CAAC,EAEvBM,EAAU,IAAM,CACd,MAAMG,EAAaC,EAAwB,EACvCD,GACFT,EAAmBS,CAAU,EAG/B,MAAME,EAAoBH,EAAO,GAC/B,mBACCN,GAAwC,CACvCF,EAAmBE,CAAI,CACzB,EACA,CAAE,MAAO,EAAM,CACjB,EAEA,MAAO,IAAM,CACXS,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAACX,CAAkB,CAAC,EAEvB,MAAMhB,EAAoBiB,EACxB,MAAOW,GAAkC,CACvClB,EAAakB,CAAG,EACV,MAAAC,EACJD,IAAQ,YAAcd,EAAyBf,EACjDc,EAAQ,EAAI,EACR,GAAA,CACF,MAAMJ,GAAA,YAAAA,EAAwB,CAAE,UAAWmB,EAAK,QAASC,IAAQ,QACjE,CACAhB,EAAQ,EAAK,CAAA,CAEjB,EACA,CAACC,EAAwBf,EAAgBU,CAAqB,CAChE,EAGE,OAAAd,EAACmC,EAAA,CACC,KAAAvC,EACA,eAAAQ,EACA,UAAAE,EACA,iBAAkBa,EAClB,kBAAAd,CAAA,CACF,CAEJ"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as n,jsxs as z}from"@dropins/tools/preact-jsx-runtime.js";import{h as j}from"../chunks/fetch-graphql.js";import"@dropins/tools/lib.js";import{h as w,g as C}from"../chunks/events.js";import{n as L,g as R}from"../chunks/values.js";import{events as _}from"@dropins/tools/event-bus.js";import{c as U}from"../chunks/synchronizeCheckout.js";import{s as W}from"../chunks/setBillingAddress.js";/* empty css */import{Skeleton as y,SkeletonRow as P,Checkbox as $,InLineAlert as q}from"@dropins/tools/components.js";import{W as F}from"../chunks/ConditionalWrapper.js";import{c as G}from"../chunks/classes.js";import{useText as D}from"@dropins/tools/i18n.js";import{useState as k,useRef as H,useCallback as b,useEffect as A}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/transform-shipping-methods.js";import"../chunks/guards.js";const J=()=>n(y,{className:"bill-to-shipping-address__skeleton","data-testid":"bill-to-shipping-skeleton",children:n(P,{size:"small",variant:"row"})}),K=({className:i,checked:u,disabled:e,error:t=null,onChange:c=()=>{},onDismissError:p=()=>{}})=>{const m=D({title:"Checkout.BillToShippingAddress.title"}),f=t!==null,r=l=>{const a=l.target;c==null||c(a.checked)};return z("div",{className:"checkout-bill-to-shipping-address",children:[n($,{checked:u,className:G(["checkout-bill-to-shipping-address__checkbox",i]),"data-testid":"bill-to-shipping-checkbox",disabled:e,label:m.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:r}),f&&n("div",{className:"checkout-bill-to-shipping-address__error","data-testid":"checkout-bill-to-shipping-address-alert",children:n(q,{heading:t,type:"error",variant:"primary",onDismiss:p})})]})},M=F(K,J),ms=({active:i=!0,autoSync:u=!0,onCartSyncError:e,onChange:t})=>{const[c,p]=k(null),[m,f]=k(!1),[r,l]=k(),a=H(!1),V=j.value,{cartSyncError:B}=D({cartSyncError:"Checkout.BillToShippingAddress.cartSyncError"}),E=b(()=>{p(null)},[]),I=b(s=>{p(null),l(s),t==null||t(s),!(!u||!s||!w())&&W({sameAsShipping:!0}).catch(o=>{l(!1),e==null||e({error:o}),e||p(B)})},[u,B,e,t]),d=b(s=>{var T;const o=!s||s.isEmpty,h=!!(s!=null&&s.isVirtual);if(o||h){f(h),l(!1),a.current=!1;return}if(a.current)return;const S=s,x=(T=S.shippingAddresses)==null?void 0:T[0],N=!!S.billingAddress;let g;if(x)g=x.sameAsBilling??!N;else{const{defaults:v}=U.getConfig();g=v.isBillToShipping}l(g),a.current=!0},[]);return A(()=>{!i||r===void 0||L({isBillToShipping:r})},[i,r]),A(()=>{if(!i)return;const s=C();if(s){const h=R("isBillToShipping");h!=null&&l(h),d(s);return}const o=_.on("checkout/initialized",d,{eager:!0});return()=>{o==null||o.off()}},[i,d]),A(()=>{if(!i)return;const s=_.on("checkout/updated",d,{eager:!1});return()=>{s==null||s.off()}},[i,d]),n(M,{checked:r,disabled:V,error:c,initialized:r!==void 0,visible:i&&!m,onChange:I,onDismissError:E})};export{ms as BillToShippingAddress,ms as default};
3
+ import{jsx as n,jsxs as z}from"@dropins/tools/preact-jsx-runtime.js";import{h as j}from"../chunks/fetch-graphql.js";import"@dropins/tools/lib.js";import{h as w,a as C}from"../chunks/events2.js";import{n as L,g as R}from"../chunks/values.js";import{events as _}from"@dropins/tools/event-bus.js";import{c as U}from"../chunks/synchronizeCheckout.js";import{s as W}from"../chunks/setBillingAddress.js";/* empty css */import{Skeleton as y,SkeletonRow as P,Checkbox as $,InLineAlert as q}from"@dropins/tools/components.js";import{W as F}from"../chunks/ConditionalWrapper.js";import{c as G}from"../chunks/classes.js";import{useText as D}from"@dropins/tools/i18n.js";import{useState as k,useRef as H,useCallback as b,useEffect as A}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";import"../chunks/guards.js";const J=()=>n(y,{className:"bill-to-shipping-address__skeleton","data-testid":"bill-to-shipping-skeleton",children:n(P,{size:"small",variant:"row"})}),K=({className:i,checked:u,disabled:e,error:t=null,onChange:c=()=>{},onDismissError:p=()=>{}})=>{const m=D({title:"Checkout.BillToShippingAddress.title"}),f=t!==null,r=l=>{const a=l.target;c==null||c(a.checked)};return z("div",{className:"checkout-bill-to-shipping-address",children:[n($,{checked:u,className:G(["checkout-bill-to-shipping-address__checkbox",i]),"data-testid":"bill-to-shipping-checkbox",disabled:e,label:m.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:r}),f&&n("div",{className:"checkout-bill-to-shipping-address__error","data-testid":"checkout-bill-to-shipping-address-alert",children:n(q,{heading:t,type:"error",variant:"primary",onDismiss:p})})]})},M=F(K,J),fs=({active:i=!0,autoSync:u=!0,onCartSyncError:e,onChange:t})=>{const[c,p]=k(null),[m,f]=k(!1),[r,l]=k(),a=H(!1),V=j.value,{cartSyncError:B}=D({cartSyncError:"Checkout.BillToShippingAddress.cartSyncError"}),E=b(()=>{p(null)},[]),I=b(s=>{p(null),l(s),t==null||t(s),!(!u||!s||!w())&&W({sameAsShipping:!0}).catch(o=>{l(!1),e==null||e({error:o}),e||p(B)})},[u,B,e,t]),d=b(s=>{var T;const o=!s||s.isEmpty,h=!!(s!=null&&s.isVirtual);if(o||h){f(h),l(!1),a.current=!1;return}if(a.current)return;const S=s,x=(T=S.shippingAddresses)==null?void 0:T[0],N=!!S.billingAddress;let g;if(x)g=x.sameAsBilling??!N;else{const{defaults:v}=U.getConfig();g=v.isBillToShipping}l(g),a.current=!0},[]);return A(()=>{!i||r===void 0||L({isBillToShipping:r})},[i,r]),A(()=>{if(!i)return;const s=C();if(s){const h=R("isBillToShipping");h!=null&&l(h),d(s);return}const o=_.on("checkout/initialized",d,{eager:!0});return()=>{o==null||o.off()}},[i,d]),A(()=>{if(!i)return;const s=_.on("checkout/updated",d,{eager:!1});return()=>{s==null||s.off()}},[i,d]),n(M,{checked:r,disabled:V,error:c,initialized:r!==void 0,visible:i&&!m,onChange:I,onDismissError:E})};export{fs as BillToShippingAddress,fs as default};
4
4
  //# sourceMappingURL=BillToShippingAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BillToShippingAddress.js","sources":["/@dropins/storefront-checkout/src/components/BillToShippingAddress/BillToShippingAddressSkeleton.tsx","/@dropins/storefront-checkout/src/components/BillToShippingAddress/BillToShippingAddress.tsx","/@dropins/storefront-checkout/src/containers/BillToShippingAddress/BillToShippingAddress.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const BillToShippingAddressSkeleton: FunctionComponent = () => {\n return (\n <Skeleton\n className=\"bill-to-shipping-address__skeleton\"\n data-testid=\"bill-to-shipping-skeleton\"\n >\n <SkeletonRow size=\"small\" variant=\"row\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport '@/checkout/components/BillToShippingAddress/BillToShippingAddress.css';\nimport { BillToShippingAddressSkeleton } from '@/checkout/components/BillToShippingAddress/BillToShippingAddressSkeleton';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport { Checkbox, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { classes } from '@adobe-commerce/elsie/lib/classes';\nimport { FunctionComponent } from 'preact';\nimport { ChangeEvent, HTMLAttributes } from 'preact/compat';\n\nexport interface BillToShippingAddressProps\n extends Omit<\n HTMLAttributes<HTMLInputElement>,\n 'loading' | 'disabled' | 'onChange'\n > {\n disabled?: boolean;\n error?: string | null;\n onChange?: (checked: boolean) => void;\n onDismissError?: () => void;\n}\n\nconst BillToShippingAddressComponent: FunctionComponent<\n BillToShippingAddressProps\n> = ({\n className,\n checked,\n disabled,\n error = null,\n onChange = () => {},\n onDismissError = () => {},\n}) => {\n const translations = useText({\n title: 'Checkout.BillToShippingAddress.title',\n });\n\n const hasError = error !== null;\n\n const handleChange = (event: Event | ChangeEvent<HTMLInputElement>) => {\n const checkbox = event.target as HTMLInputElement;\n onChange?.(checkbox.checked);\n };\n\n return (\n <div className=\"checkout-bill-to-shipping-address\">\n <Checkbox\n checked={checked}\n className={classes([\n 'checkout-bill-to-shipping-address__checkbox',\n className,\n ])}\n data-testid=\"bill-to-shipping-checkbox\"\n disabled={disabled}\n label={translations.title}\n name=\"checkout-bill-to-shipping-address__checkbox\"\n onChange={handleChange}\n />\n\n {hasError && (\n <div\n className=\"checkout-bill-to-shipping-address__error\"\n data-testid=\"checkout-bill-to-shipping-address-alert\"\n >\n <InLineAlert\n heading={error}\n type=\"error\"\n variant=\"primary\"\n onDismiss={onDismissError}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport const BillToShippingAddress = WithConditionals(\n BillToShippingAddressComponent,\n BillToShippingAddressSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config, setBillingAddress } from '@/checkout/api';\nimport { BillToShippingAddress as BillToShippingAddressComponent } from '@/checkout/components/BillToShippingAddress';\nimport { Cart, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n hasShippingAddress,\n notifyValues,\n} from '@/checkout/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\ninterface CartSyncError {\n error: Error;\n}\n\nexport interface BillToShippingAddressProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onChange?: (checked: boolean) => void;\n}\n\nexport const BillToShippingAddress: Container<BillToShippingAddressProps> = ({\n active = true,\n autoSync = true,\n onCartSyncError,\n onChange,\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n const [isChecked, setIsChecked] = useState<boolean | undefined>();\n\n const hasInitialCartData = useRef(false);\n\n const isDisabled = hasPendingUpdates.value;\n\n const { cartSyncError } = useText({\n cartSyncError: 'Checkout.BillToShippingAddress.cartSyncError',\n });\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const handleChange = useCallback(\n (isBillToShipping: boolean) => {\n setError(null);\n setIsChecked(isBillToShipping);\n\n onChange?.(isBillToShipping);\n\n if (!autoSync || !isBillToShipping || !hasShippingAddress()) {\n return;\n }\n\n setBillingAddress({ sameAsShipping: true }).catch((error: any) => {\n setIsChecked(false);\n onCartSyncError?.({ error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, cartSyncError, onCartSyncError, onChange]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isCartEmpty = !data || data.isEmpty;\n const isCartVirtual = !!data?.isVirtual;\n\n if (isCartEmpty || isCartVirtual) {\n setIsVirtual(isCartVirtual);\n setIsChecked(false);\n hasInitialCartData.current = false;\n return;\n }\n\n // If we've already set the initial state from cart data, don't override it.\n // This preserves any changes the user might have made.\n if (hasInitialCartData.current) {\n return;\n }\n\n const cart = data as Cart;\n const shippingAddress = cart.shippingAddresses?.[0];\n const hasBillingAddress = !!cart.billingAddress;\n\n let initialIsChecked: boolean;\n\n if (!shippingAddress) {\n const { defaults } = config.getConfig();\n initialIsChecked = defaults!.isBillToShipping!;\n } else {\n initialIsChecked = shippingAddress.sameAsBilling ?? !hasBillingAddress;\n }\n\n setIsChecked(initialIsChecked);\n hasInitialCartData.current = true;\n },\n []\n );\n\n useEffect(() => {\n if (!active || isChecked === undefined) return;\n notifyValues({ isBillToShipping: isChecked });\n }, [active, isChecked]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userBillToShipping = getValue('isBillToShipping');\n if (userBillToShipping != null) {\n setIsChecked(userBillToShipping);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n handleCheckoutData,\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n {\n eager: false,\n }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n return (\n <BillToShippingAddressComponent\n checked={isChecked}\n disabled={isDisabled}\n error={error}\n initialized={isChecked !== undefined}\n visible={active && !isVirtual}\n onChange={handleChange}\n onDismissError={handleDismissError}\n />\n );\n};\n"],"names":["BillToShippingAddressSkeleton","jsx","Skeleton","SkeletonRow","BillToShippingAddressComponent","className","checked","disabled","error","onChange","onDismissError","translations","useText","hasError","handleChange","event","checkbox","jsxs","Checkbox","classes","InLineAlert","BillToShippingAddress","WithConditionals","active","autoSync","onCartSyncError","setError","useState","isVirtual","setIsVirtual","isChecked","setIsChecked","hasInitialCartData","useRef","isDisabled","hasPendingUpdates","cartSyncError","handleDismissError","useCallback","isBillToShipping","hasShippingAddress","setBillingAddress","handleCheckoutData","data","isCartEmpty","isCartVirtual","cart","shippingAddress","_a","hasBillingAddress","initialIsChecked","defaults","config","useEffect","notifyValues","pastUpdate","getLatestCheckoutUpdate","userBillToShipping","getValue","onCheckoutInit","events","onCheckoutUpdated"],"mappings":"k8BAoBO,M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kB,EAClDD,GAAsB,MACxB1B,EAAa0B,CAAkB,EAEjCf,EAAmBa,CAAU,EAC7B,MAAA,CAGF,MAAMI,EAAiBC,EAAO,GAC5B,uBACAlB,EACA,CAAE,MAAO,EAAK,CAChB,EAEA,MAAO,IAAM,CACXiB,GAAA,MAAAA,EAAgB,KAClB,CAAA,EACC,CAACpC,EAAQmB,CAAkB,CAAC,EAE/BW,EAAU,IAAM,CACd,GAAI,CAAC9B,EAAQ,OAEb,MAAMsC,EAAoBD,EAAO,GAC/B,mBACAlB,EACA,CACE,MAAO,EAAA,CAEX,EAEA,MAAO,IAAM,CACXmB,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAACtC,EAAQmB,CAAkB,CAAC,EAG7BzC,EAACG,EAAA,CACC,QAAS0B,EACT,SAAUI,EACV,MAAA1B,EACA,YAAasB,IAAc,OAC3B,QAASP,GAAU,CAACK,EACpB,SAAUd,EACV,eAAgBuB,CAAA,CAClB,CAEJ"}
1
+ {"version":3,"file":"BillToShippingAddress.js","sources":["/@dropins/storefront-checkout/src/components/BillToShippingAddress/BillToShippingAddressSkeleton.tsx","/@dropins/storefront-checkout/src/components/BillToShippingAddress/BillToShippingAddress.tsx","/@dropins/storefront-checkout/src/containers/BillToShippingAddress/BillToShippingAddress.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const BillToShippingAddressSkeleton: FunctionComponent = () => {\n return (\n <Skeleton\n className=\"bill-to-shipping-address__skeleton\"\n data-testid=\"bill-to-shipping-skeleton\"\n >\n <SkeletonRow size=\"small\" variant=\"row\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport '@/checkout/components/BillToShippingAddress/BillToShippingAddress.css';\nimport { BillToShippingAddressSkeleton } from '@/checkout/components/BillToShippingAddress/BillToShippingAddressSkeleton';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport { Checkbox, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { classes } from '@adobe-commerce/elsie/lib/classes';\nimport { FunctionComponent } from 'preact';\nimport { ChangeEvent, HTMLAttributes } from 'preact/compat';\n\nexport interface BillToShippingAddressProps\n extends Omit<\n HTMLAttributes<HTMLInputElement>,\n 'loading' | 'disabled' | 'onChange'\n > {\n disabled?: boolean;\n error?: string | null;\n onChange?: (checked: boolean) => void;\n onDismissError?: () => void;\n}\n\nconst BillToShippingAddressComponent: FunctionComponent<\n BillToShippingAddressProps\n> = ({\n className,\n checked,\n disabled,\n error = null,\n onChange = () => {},\n onDismissError = () => {},\n}) => {\n const translations = useText({\n title: 'Checkout.BillToShippingAddress.title',\n });\n\n const hasError = error !== null;\n\n const handleChange = (event: Event | ChangeEvent<HTMLInputElement>) => {\n const checkbox = event.target as HTMLInputElement;\n onChange?.(checkbox.checked);\n };\n\n return (\n <div className=\"checkout-bill-to-shipping-address\">\n <Checkbox\n checked={checked}\n className={classes([\n 'checkout-bill-to-shipping-address__checkbox',\n className,\n ])}\n data-testid=\"bill-to-shipping-checkbox\"\n disabled={disabled}\n label={translations.title}\n name=\"checkout-bill-to-shipping-address__checkbox\"\n onChange={handleChange}\n />\n\n {hasError && (\n <div\n className=\"checkout-bill-to-shipping-address__error\"\n data-testid=\"checkout-bill-to-shipping-address-alert\"\n >\n <InLineAlert\n heading={error}\n type=\"error\"\n variant=\"primary\"\n onDismiss={onDismissError}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport const BillToShippingAddress = WithConditionals(\n BillToShippingAddressComponent,\n BillToShippingAddressSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config, setBillingAddress } from '@/checkout/api';\nimport { BillToShippingAddress as BillToShippingAddressComponent } from '@/checkout/components/BillToShippingAddress';\nimport { Cart, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n hasShippingAddress,\n notifyValues,\n} from '@/checkout/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\ninterface CartSyncError {\n error: Error;\n}\n\nexport interface BillToShippingAddressProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onChange?: (checked: boolean) => void;\n}\n\nexport const BillToShippingAddress: Container<BillToShippingAddressProps> = ({\n active = true,\n autoSync = true,\n onCartSyncError,\n onChange,\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n const [isChecked, setIsChecked] = useState<boolean | undefined>();\n\n const hasInitialCartData = useRef(false);\n\n const isDisabled = hasPendingUpdates.value;\n\n const { cartSyncError } = useText({\n cartSyncError: 'Checkout.BillToShippingAddress.cartSyncError',\n });\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const handleChange = useCallback(\n (isBillToShipping: boolean) => {\n setError(null);\n setIsChecked(isBillToShipping);\n\n onChange?.(isBillToShipping);\n\n if (!autoSync || !isBillToShipping || !hasShippingAddress()) {\n return;\n }\n\n setBillingAddress({ sameAsShipping: true }).catch((error: any) => {\n setIsChecked(false);\n onCartSyncError?.({ error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, cartSyncError, onCartSyncError, onChange]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isCartEmpty = !data || data.isEmpty;\n const isCartVirtual = !!data?.isVirtual;\n\n if (isCartEmpty || isCartVirtual) {\n setIsVirtual(isCartVirtual);\n setIsChecked(false);\n hasInitialCartData.current = false;\n return;\n }\n\n // If we've already set the initial state from cart data, don't override it.\n // This preserves any changes the user might have made.\n if (hasInitialCartData.current) {\n return;\n }\n\n const cart = data as Cart;\n const shippingAddress = cart.shippingAddresses?.[0];\n const hasBillingAddress = !!cart.billingAddress;\n\n let initialIsChecked: boolean;\n\n if (!shippingAddress) {\n const { defaults } = config.getConfig();\n initialIsChecked = defaults!.isBillToShipping!;\n } else {\n initialIsChecked = shippingAddress.sameAsBilling ?? !hasBillingAddress;\n }\n\n setIsChecked(initialIsChecked);\n hasInitialCartData.current = true;\n },\n []\n );\n\n useEffect(() => {\n if (!active || isChecked === undefined) return;\n notifyValues({ isBillToShipping: isChecked });\n }, [active, isChecked]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userBillToShipping = getValue('isBillToShipping');\n if (userBillToShipping != null) {\n setIsChecked(userBillToShipping);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n handleCheckoutData,\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n {\n eager: false,\n }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n return (\n <BillToShippingAddressComponent\n checked={isChecked}\n disabled={isDisabled}\n error={error}\n initialized={isChecked !== undefined}\n visible={active && !isVirtual}\n onChange={handleChange}\n onDismissError={handleDismissError}\n />\n );\n};\n"],"names":["BillToShippingAddressSkeleton","jsx","Skeleton","SkeletonRow","BillToShippingAddressComponent","className","checked","disabled","error","onChange","onDismissError","translations","useText","hasError","handleChange","event","checkbox","jsxs","Checkbox","classes","InLineAlert","BillToShippingAddress","WithConditionals","active","autoSync","onCartSyncError","setError","useState","isVirtual","setIsVirtual","isChecked","setIsChecked","hasInitialCartData","useRef","isDisabled","hasPendingUpdates","cartSyncError","handleDismissError","useCallback","isBillToShipping","hasShippingAddress","setBillingAddress","handleCheckoutData","data","isCartEmpty","isCartVirtual","cart","shippingAddress","_a","hasBillingAddress","initialIsChecked","defaults","config","useEffect","notifyValues","pastUpdate","getLatestCheckoutUpdate","userBillToShipping","getValue","onCheckoutInit","events","onCheckoutUpdated"],"mappings":"o+BAoBO,MAAMA,EAAmD,IAE5DC,EAACC,EAAA,CACC,UAAU,qCACV,cAAY,4BAEZ,SAACD,EAAAE,EAAA,CAAY,KAAK,QAAQ,QAAQ,KAAM,CAAA,CAAA,CAC1C,ECUEC,EAEF,CAAC,CACH,UAAAC,EACA,QAAAC,EACA,SAAAC,EACA,MAAAC,EAAQ,KACR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AACpC,EAAQmB,CAAkB,CAAC,EAE/BW,EAAU,IAAM,CACd,GAAI,CAAC9B,EAAQ,OAEb,MAAMsC,EAAoBD,EAAO,GAC/B,mBACAlB,EACA,CACE,MAAO,EAAA,CAEX,EAEA,MAAO,IAAM,CACXmB,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAACtC,EAAQmB,CAAkB,CAAC,EAG7BzC,EAACG,EAAA,CACC,QAAS0B,EACT,SAAUI,EACV,MAAA1B,EACA,YAAasB,IAAc,OAC3B,QAASP,GAAU,CAACK,EACpB,SAAUd,EACV,eAAgBuB,CAAA,CAClB,CAEJ"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/TermsAndConditions.js";import{VComponent as C,classes as D}from"@dropins/tools/lib.js";import{Skeleton as B,SkeletonRow as U,Price as h}from"@dropins/tools/components.js";/* empty css */import{W as z}from"../chunks/ConditionalWrapper.js";import{useText as _}from"@dropins/tools/i18n.js";/* empty css */import{s as G,T as I}from"../chunks/fetch-graphql.js";import{events as d}from"@dropins/tools/event-bus.js";import{g as P}from"../chunks/events.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as V,useCallback as b,useEffect as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const X=()=>i(B,{"data-testid":"estimate-shipping-skeleton",children:i(U,{size:"xsmall"})}),j=({label:n,price:t,priceExclTax:a,taxExcluded:o=!1,taxIncluded:c=!1})=>{const l=_({withTaxes:"Checkout.EstimateShipping.withTaxes",withoutTaxes:"Checkout.EstimateShipping.withoutTaxes"});return k("div",{className:"checkout-estimate-shipping","data-testid":"estimate-shipping",children:[i(C,{className:"checkout-estimate-shipping__label",node:n}),i(C,{className:"checkout-estimate-shipping__price",node:t}),c&&i("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included",children:l.withTaxes}),o&&k("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included-excluded",children:[a," ",l.withoutTaxes]})]})},v=z(j,X),at=({active:n=!0})=>{var T;const[t,a]=V(),o=(t==null?void 0:t.amount.value)===0,c=(T=G.config)==null?void 0:T.shoppingCartDisplaySetting.shipping,l=c===I.INCLUDING_EXCLUDING_TAX,g=c===I.INCLUDING_TAX,u=_({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined",label:"Checkout.EstimateShipping.label",estimated:"Checkout.EstimateShipping.estimated"}),r=b(e=>{var S;const s=!e||e.isEmpty,p=!!(e!=null&&e.isVirtual);if(s||p){a(null);return}const m=(S=e.shippingAddresses)==null?void 0:S[0];if(!m)return;const E=m==null?void 0:m.selectedShippingMethod;if(!E){a(null);return}const{amount:w,amountExclTax:L,amountInclTax:M}=E;a({estimated:!1,amount:w,amountExclTax:L,amountInclTax:M})},[]),f=b(e=>{let s=null;if(e.shippingMethod){const p=e.shippingMethod;s={estimated:!0,amount:p.amount,amountExclTax:p.amountExclTax,amountInclTax:p.amountInclTax}}a(s)},[]);x(()=>{if(!n)return;const e=d.on("shipping/estimate",f,{eager:!0});return()=>{e==null||e.off()}},[n,f]),x(()=>{if(!n)return;const e=P();if(e){r(e);return}const s=d.on("checkout/initialized",r,{eager:!0});return()=>{s==null||s.off()}},[n,r]),x(()=>{if(!n)return;const e=d.on("checkout/updated",r,{eager:!1});return()=>{e==null||e.off()}},[n,r]);const y=()=>o?i("span",{"data-testid":"free-shipping",children:u.freeShipping}):g&&(t!=null&&t.amountInclTax)?i(h,{amount:t.amountInclTax.value,currency:t.amountInclTax.currency,"data-testid":"shipping"}):i(h,{amount:t==null?void 0:t.amount.value,currency:t==null?void 0:t.amount.currency,"data-testid":"shipping"}),N=()=>t!=null&&t.amountExclTax?i(h,{amount:t.amountExclTax.value,currency:t.amountExclTax.currency,"data-testid":"shipping-excluding-tax"}):i("span",{children:u.taxToBeDetermined});return i(v,{initialized:t!==void 0,label:(()=>{const e=t!=null&&t.estimated?u.estimated:u.label;return i("span",{"data-testid":"estimate-shipping-label",children:e})})(),price:y(),priceExclTax:N(),taxExcluded:l&&!o,taxIncluded:g&&!o,visible:n&&t!==null})};export{at as EstimateShipping,at as default};
3
+ import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/TermsAndConditions.js";import{VComponent as C,classes as D}from"@dropins/tools/lib.js";import{Skeleton as B,SkeletonRow as U,Price as h}from"@dropins/tools/components.js";/* empty css */import{W as z}from"../chunks/ConditionalWrapper.js";import{useText as _}from"@dropins/tools/i18n.js";import{s as G,T as I}from"../chunks/fetch-graphql.js";import{events as d}from"@dropins/tools/event-bus.js";import{a as P}from"../chunks/events2.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css */import{useState as V,useCallback as b,useEffect as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const X=()=>i(B,{"data-testid":"estimate-shipping-skeleton",children:i(U,{size:"xsmall"})}),j=({label:n,price:t,priceExclTax:a,taxExcluded:o=!1,taxIncluded:c=!1})=>{const l=_({withTaxes:"Checkout.EstimateShipping.withTaxes",withoutTaxes:"Checkout.EstimateShipping.withoutTaxes"});return k("div",{className:"checkout-estimate-shipping","data-testid":"estimate-shipping",children:[i(C,{className:"checkout-estimate-shipping__label",node:n}),i(C,{className:"checkout-estimate-shipping__price",node:t}),c&&i("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included",children:l.withTaxes}),o&&k("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included-excluded",children:[a," ",l.withoutTaxes]})]})},v=z(j,X),at=({active:n=!0})=>{var T;const[t,a]=V(),o=(t==null?void 0:t.amount.value)===0,c=(T=G.config)==null?void 0:T.shoppingCartDisplaySetting.shipping,l=c===I.INCLUDING_EXCLUDING_TAX,g=c===I.INCLUDING_TAX,u=_({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined",label:"Checkout.EstimateShipping.label",estimated:"Checkout.EstimateShipping.estimated"}),r=b(e=>{var S;const s=!e||e.isEmpty,p=!!(e!=null&&e.isVirtual);if(s||p){a(null);return}const m=(S=e.shippingAddresses)==null?void 0:S[0];if(!m)return;const E=m==null?void 0:m.selectedShippingMethod;if(!E){a(null);return}const{amount:w,amountExclTax:L,amountInclTax:M}=E;a({estimated:!1,amount:w,amountExclTax:L,amountInclTax:M})},[]),f=b(e=>{let s=null;if(e.shippingMethod){const p=e.shippingMethod;s={estimated:!0,amount:p.amount,amountExclTax:p.amountExclTax,amountInclTax:p.amountInclTax}}a(s)},[]);x(()=>{if(!n)return;const e=d.on("shipping/estimate",f,{eager:!0});return()=>{e==null||e.off()}},[n,f]),x(()=>{if(!n)return;const e=P();if(e){r(e);return}const s=d.on("checkout/initialized",r,{eager:!0});return()=>{s==null||s.off()}},[n,r]),x(()=>{if(!n)return;const e=d.on("checkout/updated",r,{eager:!1});return()=>{e==null||e.off()}},[n,r]);const y=()=>o?i("span",{"data-testid":"free-shipping",children:u.freeShipping}):g&&(t!=null&&t.amountInclTax)?i(h,{amount:t.amountInclTax.value,currency:t.amountInclTax.currency,"data-testid":"shipping"}):i(h,{amount:t==null?void 0:t.amount.value,currency:t==null?void 0:t.amount.currency,"data-testid":"shipping"}),N=()=>t!=null&&t.amountExclTax?i(h,{amount:t.amountExclTax.value,currency:t.amountExclTax.currency,"data-testid":"shipping-excluding-tax"}):i("span",{children:u.taxToBeDetermined});return i(v,{initialized:t!==void 0,label:(()=>{const e=t!=null&&t.estimated?u.estimated:u.label;return i("span",{"data-testid":"estimate-shipping-label",children:e})})(),price:y(),priceExclTax:N(),taxExcluded:l&&!o,taxIncluded:g&&!o,visible:n&&t!==null})};export{at as EstimateShipping,at as default};
4
4
  //# sourceMappingURL=EstimateShipping.js.map