@dropins/storefront-cart 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/api/graphql/CartFragment.d.ts +1 -0
  2. package/api.js +3 -4
  3. package/chunks/MiniCart.js +0 -1
  4. package/chunks/getEstimatedTotals.js +1 -2
  5. package/chunks/getStoreConfig.js +12 -229
  6. package/chunks/resetCart.js +230 -0
  7. package/chunks/updateProductsFromCart.js +1 -2
  8. package/containers/Cart.js +1 -2
  9. package/containers/MiniCart.js +1 -2
  10. package/data/models/cart-model.d.ts +1 -0
  11. package/data/transforms/__fixtures__/estimatedTotalsData.d.ts +8 -6
  12. package/hooks/useEstimatedShipping.d.ts +3 -0
  13. package/hooks/useEstimatedTotals.d.ts +1 -0
  14. package/i18n/en_US.json.d.ts +1 -0
  15. package/lib/persisted-data.d.ts +8 -2
  16. package/package.json +1 -1
  17. package/render.js +1 -2
  18. package/api/addProductsToCart/addProductsToCart.d.ts.map +0 -1
  19. package/api/addProductsToCart/graphql/AddProductsToCartMutation.d.ts.map +0 -1
  20. package/api/addProductsToCart/index.d.ts.map +0 -1
  21. package/api/createEmptyCart/createEmptyCart.d.ts.map +0 -1
  22. package/api/createEmptyCart/graphql/CreateCartMutation.d.ts.map +0 -1
  23. package/api/createEmptyCart/index.d.ts.map +0 -1
  24. package/api/fetch-graphql/fetch-graphql.d.ts.map +0 -1
  25. package/api/fetch-graphql/index.d.ts.map +0 -1
  26. package/api/getCartData/getCartData.d.ts.map +0 -1
  27. package/api/getCartData/graphql/CartQuery.d.ts.map +0 -1
  28. package/api/getCartData/index.d.ts.map +0 -1
  29. package/api/getEstimateShipping/getEstimateShipping.d.ts.map +0 -1
  30. package/api/getEstimateShipping/graphql/countriesAndRegionsQueries.d.ts.map +0 -1
  31. package/api/getEstimateShipping/graphql/estimateShippingMethodsMutation.d.ts.map +0 -1
  32. package/api/getEstimateShipping/index.d.ts.map +0 -1
  33. package/api/getEstimatedTotals/getEstimatedTotals.d.ts.map +0 -1
  34. package/api/getEstimatedTotals/graphql/GetEstimatedTotalsMutation.d.ts.map +0 -1
  35. package/api/getEstimatedTotals/index.d.ts.map +0 -1
  36. package/api/getStoreConfig/getStoreConfig.d.ts.map +0 -1
  37. package/api/getStoreConfig/graphql/StoreConfigQuery.d.ts.map +0 -1
  38. package/api/getStoreConfig/index.d.ts.map +0 -1
  39. package/api/graphql/CartFragment.d.ts.map +0 -1
  40. package/api/index.d.ts.map +0 -1
  41. package/api/initialize/index.d.ts.map +0 -1
  42. package/api/initialize/initialize.d.ts.map +0 -1
  43. package/api/initializeCart/graphql/MergeCartsMutation.d.ts.map +0 -1
  44. package/api/initializeCart/index.d.ts.map +0 -1
  45. package/api/initializeCart/initializeCart.d.ts.map +0 -1
  46. package/api/resetCart/index.d.ts.map +0 -1
  47. package/api/resetCart/resetCart.d.ts.map +0 -1
  48. package/api/updateProductsFromCart/graphql/UpdateProductsMutation.d.ts.map +0 -1
  49. package/api/updateProductsFromCart/index.d.ts.map +0 -1
  50. package/api/updateProductsFromCart/updateProductsFromCart.d.ts.map +0 -1
  51. package/api.js.map +0 -1
  52. package/chunks/MiniCart.js.map +0 -1
  53. package/chunks/getEstimatedTotals.js.map +0 -1
  54. package/chunks/getStoreConfig.js.map +0 -1
  55. package/chunks/updateProductsFromCart.js.map +0 -1
  56. package/components/Cart/Cart.d.ts.map +0 -1
  57. package/components/Cart/index.d.ts.map +0 -1
  58. package/components/EmptyCart/EmptyCart.d.ts.map +0 -1
  59. package/components/EmptyCart/index.d.ts.map +0 -1
  60. package/components/MiniCart/MiniCart.d.ts.map +0 -1
  61. package/components/MiniCart/index.d.ts.map +0 -1
  62. package/components/index.d.ts.map +0 -1
  63. package/containers/Cart/Cart.d.ts.map +0 -1
  64. package/containers/Cart/index.d.ts.map +0 -1
  65. package/containers/Cart.js.map +0 -1
  66. package/containers/MiniCart/MiniCart.d.ts.map +0 -1
  67. package/containers/MiniCart/index.d.ts.map +0 -1
  68. package/containers/MiniCart.js.map +0 -1
  69. package/containers/index.d.ts.map +0 -1
  70. package/data/models/acdl-models.d.ts.map +0 -1
  71. package/data/models/cart-model.d.ts.map +0 -1
  72. package/data/models/index.d.ts.map +0 -1
  73. package/data/models/store-models.d.ts.map +0 -1
  74. package/data/transforms/__fixtures__/cartModel.d.ts.map +0 -1
  75. package/data/transforms/__fixtures__/estimatedTotalsData.d.ts.map +0 -1
  76. package/data/transforms/__fixtures__/productTypesData.d.ts.map +0 -1
  77. package/data/transforms/acdl-context.d.ts.map +0 -1
  78. package/data/transforms/index.d.ts.map +0 -1
  79. package/data/transforms/transform-cart.d.ts.map +0 -1
  80. package/data/transforms/transform-store-config.d.ts.map +0 -1
  81. package/hooks/index.d.ts.map +0 -1
  82. package/hooks/useEstimatedShipping.d.ts.map +0 -1
  83. package/hooks/useEstimatedTotals.d.ts.map +0 -1
  84. package/lib/acdl.d.ts.map +0 -1
  85. package/lib/cookies.d.ts.map +0 -1
  86. package/lib/fetch-error.d.ts.map +0 -1
  87. package/lib/persisted-data.d.ts.map +0 -1
  88. package/lib/state.d.ts.map +0 -1
  89. package/render/Provider.d.ts.map +0 -1
  90. package/render/index.d.ts.map +0 -1
  91. package/render/render.d.ts.map +0 -1
  92. package/render.js.map +0 -1
@@ -1,3 +1,4 @@
1
1
  export declare const CART_FRAGMENT: string;
2
2
  export declare const CART_ITEMS_PAGINATION_ARGUMENTS = "\n $pageSize: Int! = 100,\n $currentPage: Int! = 1,\n $itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}\n";
3
+ export declare const CUSTOMER_ACCOUNT_FRAGMENT = "\ncustomer {\n addresses {\n default_shipping\n country_id\n postcode\n region {\n region\n region_code\n region_id\n }\n }\n}";
3
4
  //# sourceMappingURL=CartFragment.d.ts.map
package/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import{C,a as T,s as n,f as m,h as u,t as l,c as I}from"./chunks/getStoreConfig.js";import{j as P,g as D,m as b,i as F,k as y,r as $,l as v,b as w,d as x,e as Q}from"./chunks/getStoreConfig.js";import{events as d}from"@dropins/tools/event-bus.js";import{p as f,a as g}from"./chunks/updateProductsFromCart.js";import{u as H}from"./chunks/updateProductsFromCart.js";import{a as Y,g as j,c as q,b as B}from"./chunks/getEstimatedTotals.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const E=`
1
+ import{C,a as T,s as n,f as m,h as u,t as l}from"./chunks/resetCart.js";import{g as b,r as D,e as F,b as y,c as $,d as v}from"./chunks/resetCart.js";import{events as d}from"@dropins/tools/event-bus.js";import{p as I,a as f}from"./chunks/updateProductsFromCart.js";import{u as x}from"./chunks/updateProductsFromCart.js";import{c as g}from"./chunks/getStoreConfig.js";import{g as H,b as k,i as z,a as Y}from"./chunks/getStoreConfig.js";import{a as q,g as B,c as J,b as K}from"./chunks/getEstimatedTotals.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const E=`
2
2
  mutation ADD_PRODUCTS_TO_CART_MUTATION(
3
3
  $cartId: String!,
4
4
  $cartItems: [CartItemInput!]!,
@@ -18,9 +18,8 @@ import{C,a as T,s as n,f as m,h as u,t as l,c as I}from"./chunks/getStoreConfig.
18
18
  }
19
19
  }
20
20
  ${T}
21
- `,G=async e=>{let r=!1;const s=n.cartId||await h().then(a=>(r=!0,a));return m(E,{variables:{cartId:s,cartItems:e.map(({sku:a,parentSku:i,quantity:t,optionsUIDs:o,enteredOptions:c})=>({sku:a,parent_sku:i,quantity:t,selected_options:o,entered_options:c}))}}).then(({errors:a,data:i})=>{if(a)return u(a);const t=l(i.addProductsToCart.cart);if(d.emit("cart/updated",t),d.emit("cart/data",t),t){const o=t.items.filter(c=>e.some(({sku:p})=>p===c.sku));r?f(t,o,n.locale||"en-US"):g(t,o,n.locale||"en-US")}return t})},_=`
21
+ `,M=async r=>{let e=!1;const s=n.cartId||await h().then(a=>(e=!0,a));return m(E,{variables:{cartId:s,cartItems:r.map(({sku:a,parentSku:i,quantity:t,optionsUIDs:o,enteredOptions:c})=>({sku:a,parent_sku:i,quantity:t,selected_options:o,entered_options:c}))}}).then(({errors:a,data:i})=>{if(a)return u(a);const t=l(i.addProductsToCart.cart);if(d.emit("cart/updated",t),d.emit("cart/data",t),t){const o=t.items.filter(c=>r.some(({sku:p})=>p===c.sku));e?I(t,o,n.locale||"en-US"):f(t,o,n.locale||"en-US")}return t})},_=`
22
22
  mutation CREATE_EMPTY_CART_MUTATION {
23
23
  createEmptyCart
24
24
  }
25
- `,h=async()=>{const{disableGuestCart:e}=I.getConfig();if(e)throw new Error("Guest cart is disabled");return await m(_).then(({data:r})=>{const s=r.createEmptyCart;return n.cartId=s,s})};export{G as addProductsToCart,I as config,h as createEmptyCart,m as fetchGraphQl,P as getCartData,D as getConfig,Y as getCountries,j as getEstimateShipping,q as getEstimatedTotals,B as getRegions,b as getStoreConfig,F as initialize,y as initializeCart,$ as removeFetchGraphQlHeader,v as resetCart,w as setEndpoint,x as setFetchGraphQlHeader,Q as setFetchGraphQlHeaders,H as updateProductsFromCart};
26
- //# sourceMappingURL=api.js.map
25
+ `,h=async()=>{const{disableGuestCart:r}=g.getConfig();if(r)throw new Error("Guest cart is disabled");return await m(_).then(({data:e})=>{const s=e.createEmptyCart;return n.cartId=s,s})};export{M as addProductsToCart,g as config,h as createEmptyCart,m as fetchGraphQl,H as getCartData,b as getConfig,q as getCountries,B as getEstimateShipping,J as getEstimatedTotals,K as getRegions,k as getStoreConfig,z as initialize,Y as initializeCart,D as removeFetchGraphQlHeader,F as resetCart,y as setEndpoint,$ as setFetchGraphQlHeader,v as setFetchGraphQlHeaders,x as updateProductsFromCart};
@@ -1,2 +1 @@
1
1
  import{classes as o}from"@dropins/tools/lib.js";import{IllustratedMessage as i,Icon as s,Button as m}from"@dropins/tools/components.js";import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import*as t from"@dropins/tools/preact-compat.js";import{useText as l}from"@dropins/tools/i18n.js";const p=e=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("g",{clipPath:"url(#clip0_102_196)"},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_102_196"},t.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),E=({className:e,children:d,ctaLinkURL:a,...n})=>{const c=l({emptyCart:"Cart.EmptyCart.heading",cta:"Cart.EmptyCart.cta"});return r("div",{...n,className:o(["cart-empty-cart",e]),children:r(i,{className:o(["cart-empty-cart__wrapper",e]),"data-testid":"cart-empty-cart",heading:c.emptyCart,icon:r(s,{className:"cart-empty-cart__icon",source:p}),action:a?r(m,{"data-testid":"cart-empty-cart-button",size:"medium",variant:"primary",type:"submit",href:a,children:c.cta},"routeHome"):void 0})})};export{E};
2
- //# sourceMappingURL=MiniCart.js.map
@@ -1,4 +1,4 @@
1
- import{s as l,f as d,h as u,C as m,a as T,t as E}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";const I=`
1
+ import{s as l,f as d,h as u,C as m,a as T,t as E}from"./resetCart.js";import"@dropins/tools/event-bus.js";const I=`
2
2
  mutation ESTIMATE_SHIPPING_METHODS_MUTATION(
3
3
  $cartId: String!
4
4
  $address: EstimateAddressInput!
@@ -67,4 +67,3 @@ query REGIONS_QUERY($id: String) {
67
67
  }
68
68
  ${T}
69
69
  `,$=async r=>{var c,a;const t=l.cartId;if(!t)throw new Error("No cart ID found");if(!r)throw new Error("No address parameter found");const{countryCode:o,postcode:n,region:e}=r,i=(c=r.shipping_method)==null?void 0:c.carrier_code,s=(a=r.shipping_method)==null?void 0:a.method_code;return d(S,{variables:{cartId:t,address:{country_code:o||"US",postcode:n||"00000",region:{region:(e==null?void 0:e.region)||"region",region_code:(e==null?void 0:e.code)||"regionCode",region_id:(e==null?void 0:e.id)||0}},shipping_method:{carrier_code:i||"",method_code:s||""}}}).then(({errors:_,data:h})=>{if(_)return u(_);const p=h.estimateTotals;return p?E(p.cart):null})};export{M as a,U as b,$ as c,N as g};
70
- //# sourceMappingURL=getEstimatedTotals.js.map
@@ -1,224 +1,7 @@
1
- import{events as l}from"@dropins/tools/event-bus.js";import{FetchGraphQL as N}from"@dropins/tools/fetch-graphql.js";import{Initializer as z}from"@dropins/tools/lib.js";function U(e){const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const r=t[n].trim();if(r.indexOf(`${e}=`)===0)return r.substring(e.length+1)}return null}const M={cartId:null,authenticated:!1},c=new Proxy(M,{set(e,t,n){var r;if(e[t]=n,t==="cartId"){if(n===c.cartId)return!0;if(n===null)return document.cookie="DROPIN__CART__CART-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const a=(r=c.config)==null?void 0:r.cartExpiresInDays;a||console.warn('Missing "expiresInDays" config. Cookie expiration will default to 30 days.');const u=new Date;u.setDate(u.getDate()+(a??30)),document.cookie=`DROPIN__CART__CART-ID=${n}; expires=${u.toUTCString()}; path=/`}return!0},get(e,t){return t==="cartId"?U("DROPIN__CART__CART-ID"):e[t]}});function k(e){e?sessionStorage.setItem("DROPIN__CART__CART__DATA",JSON.stringify(e)):sessionStorage.removeItem("DROPIN__CART__CART__DATA")}function ue(){const e=sessionStorage.getItem("DROPIN__CART__CART__DATA");return e?JSON.parse(e):null}const G=new z({init:async e=>{const t={disableGuestCart:!1,...e};G.config.setConfig(t),o()},listeners:()=>[l.on("authenticated",async e=>{e!==c.authenticated&&(c.authenticated=e,o().catch(console.error))}),l.on("locale",async e=>{e!==c.locale&&(c.locale=e,o().catch(console.error))}),l.on("cart/reset",()=>{P().catch(console.error)}),l.on("cart/data",e=>{k(e)})]}),F=G.config,{setEndpoint:ie,setFetchGraphQlHeader:le,removeFetchGraphQlHeader:se,setFetchGraphQlHeaders:oe,fetchGraphQl:_,getConfig:_e}=new N().getMethods();function g(e){var t,n,r,a,u,i,s;return e?{id:e.id,totalQuantity:X(e),errors:q(e==null?void 0:e.itemsV2),items:A(e==null?void 0:e.itemsV2),miniCartMaxItems:A(e==null?void 0:e.itemsV2).slice(0,((t=c.config)==null?void 0:t.miniCartMaxItemsDisplay)??10),total:{includingTax:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},excludingTax:{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency}},subtotal:{excludingTax:{value:(n=e.prices.subtotal_excluding_tax)==null?void 0:n.value,currency:(r=e.prices.subtotal_excluding_tax)==null?void 0:r.currency},includingTax:{value:(a=e.prices.subtotal_including_tax)==null?void 0:a.value,currency:(u=e.prices.subtotal_including_tax)==null?void 0:u.currency},includingDiscountOnly:{value:(i=e.prices.subtotal_with_discount_excluding_tax)==null?void 0:i.value,currency:(s=e.prices.subtotal_with_discount_excluding_tax)==null?void 0:s.currency}},appliedTaxes:D(e.prices.applied_taxes),totalTax:Q(e.prices.applied_taxes),appliedDiscounts:D(e.prices.discounts),isVirtual:e.is_virtual,addresses:{shipping:e.shipping_addresses&&Y(e.shipping_addresses)}}:null}function Q(e){return e!=null&&e.length?e.reduce((t,n)=>({value:t.value+n.amount.value,currency:n.amount.currency}),{value:0,currency:""}):null}function A(e){var n;if(!((n=e==null?void 0:e.items)!=null&&n.length))return[];const t=c.config;return e.items.map(r=>{var a,u,i,s,f,C,h,b,x,I,v,T,S,R,E;return{itemType:r.__typename,uid:r.uid,url:{urlKey:r.product.url_key,categories:r.product.categories.map($=>$.url_key)},quantity:r.quantity,sku:r.product.sku,name:r.product.name,image:{src:t!=null&&t.useConfigurableParentThumbnail?r.product.thumbnail.url:((u=(a=r.configured_variant)==null?void 0:a.thumbnail)==null?void 0:u.url)||r.product.thumbnail.url,alt:t!=null&&t.useConfigurableParentThumbnail?r.product.thumbnail.label:((s=(i=r.configured_variant)==null?void 0:i.thumbnail)==null?void 0:s.label)||r.product.thumbnail.label},price:{value:r.prices.price.value,currency:r.prices.price.currency},taxedPrice:{value:r.prices.price_including_tax.value,currency:r.prices.price_including_tax.currency},rowTotal:{value:r.prices.row_total.value,currency:r.prices.row_total.currency},rowTotalIncludingTax:{value:r.prices.row_total_including_tax.value,currency:r.prices.row_total_including_tax.currency},links:j(r.links),total:r.__typename==="SimpleCartItem"&&r.customizable_options.length!==0||r.__typename==="BundleCartItem"?{value:r.prices.row_total.value,currency:r.prices.row_total.currency}:{value:(f=r.prices.original_row_total)==null?void 0:f.value,currency:(C=r.prices.original_row_total)==null?void 0:C.currency},discount:{value:r.prices.total_item_discount.value,currency:r.prices.total_item_discount.currency},regularPrice:r.__typename==="ConfigurableCartItem"?{value:(b=(h=r.configured_variant)==null?void 0:h.price_range)==null?void 0:b.maximum_price.regular_price.value,currency:(I=(x=r.configured_variant)==null?void 0:x.price_range)==null?void 0:I.maximum_price.regular_price.currency}:r.__typename==="GiftCardCartItem"||r.__typename==="SimpleCartItem"&&r.customizable_options.length!==0||r.__typename==="BundleCartItem"?{value:r.prices.price.value,currency:r.prices.price.currency}:{value:(v=r.product.price_range)==null?void 0:v.maximum_price.regular_price.value,currency:(T=r.product.price_range)==null?void 0:T.maximum_price.regular_price.currency},discounted:r.__typename==="BundleCartItem"||r.__typename==="SimpleCartItem"&&r.customizable_options.length!==0?!1:r.__typename==="ConfigurableCartItem"?((R=(S=r.configured_variant)==null?void 0:S.price_range)==null?void 0:R.maximum_price.discount.amount_off)>0:((E=r.product.price_range)==null?void 0:E.maximum_price.discount.amount_off)>0,bundleOptions:r.__typename==="BundleCartItem"?L(r.bundle_options):null,selectedOptions:B(r.configurable_options),customizableOptions:V(r.customizable_options),sender:r.__typename==="GiftCardCartItem"?r.sender_name:null,senderEmail:r.__typename==="GiftCardCartItem"?r.sender_email:null,recipient:r.__typename==="GiftCardCartItem"?r.recipient_name:null,recipientEmail:r.__typename==="GiftCardCartItem"?r.recipient_email:null,message:r.__typename==="GiftCardCartItem"?r.message:null,discountedTotal:{value:r.prices.row_total.value,currency:r.prices.row_total.currency}}})}function q(e){var n;const t=(n=e==null?void 0:e.items)==null?void 0:n.reduce((r,a)=>{var u;return(u=a.errors)==null||u.forEach(i=>{r.push({uid:a.uid,text:i.message})}),r},[]);return t!=null&&t.length?t:null}function D(e){return e!=null&&e.length?e.map(t=>({amount:{value:t.amount.value,currency:t.amount.currency},label:t.label})):[]}function L(e){const t=e==null?void 0:e.map(r=>({uid:r.uid,label:r.label,value:r.values.map(a=>a.label).join(", ")})),n={};return t==null||t.forEach(r=>{n[r.label]=r.value}),Object.keys(n).length>0?n:null}function B(e){const t=e==null?void 0:e.map(r=>({uid:r.configurable_product_option_uid,label:r.option_label,value:r.value_label})),n={};return t==null||t.forEach(r=>{n[r.label]=r.value}),Object.keys(n).length>0?n:null}function V(e){const t=e==null?void 0:e.map(r=>({uid:r.customizable_option_uid,label:r.label,type:r.type,values:r.values.map(a=>({uid:a.customizable_option_value_uid,label:a.label,value:a.value}))})),n={};return t==null||t.forEach(r=>{switch(r.type){case"field":case"area":case"date_time":n[r.label]=r.values[0].value;break;case"radio":case"drop_down":n[r.label]=r.values[0].label;break;case"multiple":case"checkbox":n[r.label]=r.values.reduce((a,u)=>a?`${a}, ${u.label}`:u.label,"");break}}),n}function X(e){var t,n;return((t=c.config)==null?void 0:t.cartSummaryDisplayTotal)===0?e.itemsV2.items.length:((n=c.config)==null?void 0:n.cartSummaryDisplayTotal)===1?e.total_quantity:e.itemsV2.items.length}function j(e){return(e==null?void 0:e.length)>0?{count:e.length,result:e.map(t=>t.title).join(", ")}:null}function Y(e){return e!=null&&e.length?e.map(t=>{var n,r;return{countryCode:(n=t.country)==null?void 0:n.code,zipCode:t.postcode,regionCode:(r=t.region)==null?void 0:r.code}}):null}function H(e){if(!e)return null;const t=n=>{switch(n){case 1:return"EXCLUDING_TAX";case 2:return"INCLUDING_TAX";case 3:return"INCLUDING_EXCLUDING_TAX";default:return"EXCLUDING_TAX"}};return{displayMiniCart:e.minicart_display,miniCartMaxItemsDisplay:e.minicart_max_items,cartExpiresInDays:e.cart_expires_in_days,cartSummaryDisplayTotal:e.cart_summary_display_quantity,defaultCountry:e.default_country,categoryFixedProductTaxDisplaySetting:e.category_fixed_product_tax_display_setting,productFixedProductTaxDisplaySetting:e.product_fixed_product_tax_display_setting,salesFixedProductTaxDisplaySetting:e.sales_fixed_product_tax_display_setting,shoppingCartDisplaySetting:{zeroTax:e.shopping_cart_display_zero_tax,subtotal:t(e.shopping_cart_display_subtotal),price:t(e.shopping_cart_display_price),shipping:t(e.shopping_cart_display_shipping),fullSummary:e.shopping_cart_display_full_summary,grandTotal:e.shopping_cart_display_grand_total,taxGiftWrapping:e.shopping_cart_display_tax_gift_wrapping},useConfigurableParentThumbnail:e.configurable_thumbnail_source==="parent"}}const d=e=>{const t=e.findIndex(({extensions:a})=>(a==null?void 0:a.category)==="graphql-authorization")>-1,n=e.findIndex(({extensions:a})=>(a==null?void 0:a.category)==="graphql-no-such-entity")>-1,r=e.map(a=>a.message).join(" ");if(t||n)return P(),console.error(r),null;throw Error(r)},p=`
2
- customizable_options {
3
- type
4
- customizable_option_uid
5
- label
6
- is_required
7
- values {
8
- label
9
- value
10
- price{
11
- type
12
- units
13
- value
14
- }
15
- }
16
- }
17
- `,w=`
18
- price_range {
19
- minimum_price {
20
- regular_price {
21
- value
22
- currency
23
- }
24
- final_price {
25
- value
26
- currency
27
- }
28
- discount {
29
- percent_off
30
- amount_off
31
- }
32
- }
33
- maximum_price {
34
- regular_price {
35
- value
36
- currency
37
- }
38
- final_price {
39
- value
40
- currency
41
- }
42
- discount {
43
- percent_off
44
- amount_off
45
- }
46
- }
47
- }
48
- `,y=`
49
- fragment CartFragment on Cart {
50
- id
51
- total_quantity
52
- is_virtual
53
- prices {
54
- subtotal_with_discount_excluding_tax {
55
- currency
56
- value
57
- }
58
- subtotal_including_tax {
59
- currency
60
- value
61
- }
62
- subtotal_excluding_tax {
63
- currency
64
- value
65
- }
66
- grand_total {
67
- currency
68
- value
69
- }
70
- grand_total_excluding_tax {
71
- currency
72
- value
73
- }
74
- applied_taxes {
75
- label,
76
- amount {
77
- value
78
- currency
79
- }
80
- }
81
- discounts {
82
- amount {
83
- value
84
- currency
85
- }
86
- label
87
- }
88
- }
89
- itemsV2 (
90
- pageSize:$pageSize,
91
- currentPage:$currentPage,
92
- sort: $itemsSortInput
93
- ) {
94
- items {
95
- __typename
96
- uid
97
- quantity
98
-
99
- errors {
100
- code
101
- message
102
- }
103
-
104
- prices {
105
- price {
106
- value
107
- currency
108
- }
109
- total_item_discount {
110
- value
111
- currency
112
- }
113
- row_total {
114
- value
115
- currency
116
- }
117
- row_total_including_tax {
118
- value
119
- currency
120
- }
121
- price_including_tax {
122
- value
123
- currency
124
- }
125
- fixed_product_taxes {
126
- amount {
127
- value
128
- currency
129
- }
130
- label
131
- }
132
- original_row_total{
133
- value
134
- currency
135
- }
136
- }
137
-
138
- product {
139
- name
140
- sku
141
- thumbnail {
142
- url
143
- label
144
- }
145
- url_key
146
- url_suffix
147
- categories {
148
- url_path
149
- url_key
150
- }
151
- ${w}
152
- }
153
- ...on SimpleCartItem {
154
- ${p}
155
- }
156
- ... on ConfigurableCartItem {
157
- configurable_options {
158
- configurable_product_option_uid
159
- option_label
160
- value_label
161
- }
162
- configured_variant {
163
- uid
164
- sku
165
- thumbnail {
166
- label
167
- url
168
- }
169
- ${w}
170
- }
171
- ${p}
172
- }
173
- ... on DownloadableCartItem {
174
- links {
175
- sort_order
176
- title
177
- }
178
- ${p}
179
- }
180
- ... on BundleCartItem {
181
- bundle_options {
182
- uid
183
- label
184
- values {
185
- uid
186
- label
187
- }
188
- }
189
- }
190
- ... on GiftCardCartItem {
191
- message
192
- recipient_email
193
- recipient_name
194
- sender_email
195
- sender_name
196
- amount{
197
- currency
198
- value
199
- }
200
- is_available
201
- }
202
- }
203
- }
204
- shipping_addresses {
205
- country {
206
- code
207
- }
208
- region {
209
- code
210
- }
211
- postcode
212
- }
213
- }
214
- `,m=`
215
- $pageSize: Int! = 100,
216
- $currentPage: Int! = 1,
217
- $itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}
218
- `,J=`
1
+ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m,C as u,a as l,j as f,f as s,h as o,t as p}from"./resetCart.js";import{Initializer as C}from"@dropins/tools/lib.js";const d=new C({init:async t=>{const r={disableGuestCart:!1,...t};d.config.setConfig(r),c().catch(console.error)},listeners:()=>[i.on("authenticated",t=>{a.authenticated&&!t?i.emit("cart/reset",void 0):t&&!a.authenticated&&(a.authenticated=t,c().catch(console.error))},{eager:!0}),i.on("locale",async t=>{t!==a.locale&&(a.locale=t,c().catch(console.error))}),i.on("cart/reset",()=>{y().catch(console.error),i.emit("cart/data",null)}),i.on("cart/data",t=>{m(t)})]}),h=d.config;function T(t){if(!t)return null;const r=e=>{switch(e){case 1:return"EXCLUDING_TAX";case 2:return"INCLUDING_TAX";case 3:return"INCLUDING_EXCLUDING_TAX";default:return"EXCLUDING_TAX"}};return{displayMiniCart:t.minicart_display,miniCartMaxItemsDisplay:t.minicart_max_items,cartExpiresInDays:t.cart_expires_in_days,cartSummaryDisplayTotal:t.cart_summary_display_quantity,defaultCountry:t.default_country,categoryFixedProductTaxDisplaySetting:t.category_fixed_product_tax_display_setting,productFixedProductTaxDisplaySetting:t.product_fixed_product_tax_display_setting,salesFixedProductTaxDisplaySetting:t.sales_fixed_product_tax_display_setting,shoppingCartDisplaySetting:{zeroTax:t.shopping_cart_display_zero_tax,subtotal:r(t.shopping_cart_display_subtotal),price:r(t.shopping_cart_display_price),shipping:r(t.shopping_cart_display_shipping),fullSummary:t.shopping_cart_display_full_summary,grandTotal:t.shopping_cart_display_grand_total,taxGiftWrapping:t.shopping_cart_display_tax_gift_wrapping},useConfigurableParentThumbnail:t.configurable_thumbnail_source==="parent"}}const x=`
219
2
  query GUEST_CART_QUERY(
220
3
  $cartId: String!,
221
- ${m}
4
+ ${u}
222
5
  ) {
223
6
 
224
7
  cart(cart_id: $cartId){
@@ -226,23 +9,24 @@ fragment CartFragment on Cart {
226
9
  }
227
10
  }
228
11
 
229
- ${y}
230
- `,K=`
12
+ ${l}
13
+ `,I=`
231
14
  query CUSTOMER_CART_QUERY(
232
- ${m}
15
+ ${u}
233
16
  ) {
17
+ ${f}
234
18
 
235
19
  cart: customerCart {
236
20
  ...CartFragment
237
21
  }
238
22
  }
239
23
 
240
- ${y}
241
- `,O=async()=>{const e=c.authenticated,t=c.cartId;if(e)return _(K,{method:"POST"}).then(({errors:n,data:r})=>n?d(n):g(r.cart));if(!t)throw new Error("No cart ID found");return _(J,{method:"POST",cache:"no-cache",variables:{cartId:t}}).then(({errors:n,data:r})=>n?d(n):g(r.cart))},W=`
24
+ ${l}
25
+ `,_=async()=>{const t=a.authenticated,r=a.cartId;if(t)return s(I,{method:"POST"}).then(({errors:e,data:n})=>{if(e)return o(e);const g={...n.cart,...n.customer};return p(g)});if(!r)throw new Error("No cart ID found");return s(x,{method:"POST",cache:"no-cache",variables:{cartId:r}}).then(({errors:e,data:n})=>e?o(e):p(n.cart))},E=`
242
26
  mutation MERGE_CARTS_MUTATION(
243
27
  $guestCartId: String!,
244
28
  $customerCartId: String!,
245
- ${m}
29
+ ${u}
246
30
  ) {
247
31
  mergeCarts(
248
32
  source_cart_id: $guestCartId,
@@ -252,8 +36,8 @@ fragment CartFragment on Cart {
252
36
  }
253
37
  }
254
38
 
255
- ${y}
256
- `,o=async()=>{c.config=await te();const e=c.authenticated?await Z():await ee();return l.emit("cart/initialized",e),l.emit("cart/data",e),e};async function Z(){const e=c.cartId,t=await O();return t?(c.cartId=t.id,!e||t.id===e?t:await _(W,{variables:{guestCartId:e,customerCartId:t.id}}).then(({data:n})=>g(n.mergeCarts)).catch(()=>(console.error("Could not merge carts"),t))):null}async function ee(){if(F.getConfig().disableGuestCart===!0||!c.cartId)return null;try{return await O()}catch(e){return console.error(e),null}}const P=()=>(c.cartId=null,c.authenticated=!1,o()),re=`
39
+ ${l}
40
+ `,c=async()=>{a.config=await A();const t=a.authenticated?await S():await R();return i.emit("cart/initialized",t),i.emit("cart/data",t),t};async function S(){const t=a.cartId,r=await _();return r?(a.cartId=r.id,!t||r.id===t?r:await s(E,{variables:{guestCartId:t,customerCartId:r.id}}).then(()=>_()).then(e=>{const n={oldCartItems:r.items,newCart:e};return i.emit("cart/merged",n),e}).catch(()=>(console.error("Could not merge carts"),r))):null}async function R(){if(h.getConfig().disableGuestCart===!0||!a.cartId)return null;try{return await _()}catch(t){return console.error(t),null}}const G=`
257
41
  query STORE_CONFIG_QUERY {
258
42
  storeConfig {
259
43
  minicart_display
@@ -274,5 +58,4 @@ query STORE_CONFIG_QUERY {
274
58
  configurable_thumbnail_source
275
59
  }
276
60
  }
277
- `,te=async()=>_(re,{method:"GET",cache:"force-cache"}).then(({errors:e,data:t})=>e?d(e):H(t.storeConfig));export{m as C,y as a,ie as b,F as c,le as d,oe as e,_ as f,_e as g,d as h,G as i,O as j,o as k,P as l,te as m,ue as n,se as r,c as s,g as t};
278
- //# sourceMappingURL=getStoreConfig.js.map
61
+ `,A=async()=>s(G,{method:"GET",cache:"force-cache"}).then(({errors:t,data:r})=>t?o(t):T(r.storeConfig));export{c as a,A as b,h as c,_ as g,d as i};
@@ -0,0 +1,230 @@
1
+ import{FetchGraphQL as A}from"@dropins/tools/fetch-graphql.js";import"@dropins/tools/event-bus.js";function D(r){const n=document.cookie.split(";");for(let t=0;t<n.length;t++){const e=n[t].trim();if(e.indexOf(`${r}=`)===0)return e.substring(r.length+1)}return null}function q(r){r?sessionStorage.setItem("DROPIN__CART__CART__DATA",JSON.stringify(r)):sessionStorage.removeItem("DROPIN__CART__CART__DATA")}function R(){const r=sessionStorage.getItem("DROPIN__CART__CART__DATA");return r?JSON.parse(r):null}function Q(r){r?sessionStorage.setItem("DROPIN__CART__SHIPPING__DATA",JSON.stringify(r)):sessionStorage.removeItem("DROPIN__CART__SHIPPING__DATA")}const S=(()=>{const r=R();return{cartId:null,authenticated:r?!r.isGuestCart:!1}})(),a=new Proxy(S,{set(r,n,t){var e;if(r[n]=t,n==="cartId"){if(t===a.cartId)return!0;if(t===null)return document.cookie="DROPIN__CART__CART-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const u=(e=a.config)==null?void 0:e.cartExpiresInDays;u||console.warn('Missing "expiresInDays" config. Cookie expiration will default to 30 days.');const l=new Date;l.setDate(l.getDate()+(u??30)),document.cookie=`DROPIN__CART__CART-ID=${t}; expires=${l.toUTCString()}; path=/`}return!0},get(r,n){return n==="cartId"?D("DROPIN__CART__CART-ID"):r[n]}}),{setEndpoint:B,setFetchGraphQlHeader:V,removeFetchGraphQlHeader:j,setFetchGraphQlHeaders:U,fetchGraphQl:H,getConfig:J}=new A().getMethods();function L(r){var n,t,e,u,l,c,i;return r?{id:r.id,totalQuantity:N(r),errors:w(r==null?void 0:r.itemsV2),items:h(r==null?void 0:r.itemsV2),miniCartMaxItems:h(r==null?void 0:r.itemsV2).slice(0,((n=a.config)==null?void 0:n.miniCartMaxItemsDisplay)??10),total:{includingTax:{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency},excludingTax:{value:r.prices.grand_total_excluding_tax.value,currency:r.prices.grand_total_excluding_tax.currency}},subtotal:{excludingTax:{value:(t=r.prices.subtotal_excluding_tax)==null?void 0:t.value,currency:(e=r.prices.subtotal_excluding_tax)==null?void 0:e.currency},includingTax:{value:(u=r.prices.subtotal_including_tax)==null?void 0:u.value,currency:(l=r.prices.subtotal_including_tax)==null?void 0:l.currency},includingDiscountOnly:{value:(c=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:c.value,currency:(i=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:i.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:O(r.prices.applied_taxes),appliedDiscounts:I(r.prices.discounts),isVirtual:r.is_virtual,addresses:{shipping:r.shipping_addresses&&z(r)},isGuestCart:!a.authenticated}:null}function O(r){return r!=null&&r.length?r.reduce((n,t)=>({value:n.value+t.amount.value,currency:t.amount.currency}),{value:0,currency:""}):null}function h(r){var t;if(!((t=r==null?void 0:r.items)!=null&&t.length))return[];const n=a.config;return r.items.map(e=>{var u,l,c,i,s,_,p,g,d,m,y,f,b,v,C;return{itemType:e.__typename,uid:e.uid,url:{urlKey:e.product.url_key,categories:e.product.categories.map(T=>T.url_key)},quantity:e.quantity,sku:e.product.sku,name:e.product.name,image:{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((l=(u=e.configured_variant)==null?void 0:u.thumbnail)==null?void 0:l.url)||e.product.thumbnail.url,alt:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.label:((i=(c=e.configured_variant)==null?void 0:c.thumbnail)==null?void 0:i.label)||e.product.thumbnail.label},price:{value:e.prices.price.value,currency:e.prices.price.currency},taxedPrice:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency},links:k(e.links),total:e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.row_total.value,currency:e.prices.row_total.currency}:{value:(s=e.prices.original_row_total)==null?void 0:s.value,currency:(_=e.prices.original_row_total)==null?void 0:_.currency},discount:{value:e.prices.total_item_discount.value,currency:e.prices.total_item_discount.currency},regularPrice:e.__typename==="ConfigurableCartItem"?{value:(g=(p=e.configured_variant)==null?void 0:p.price_range)==null?void 0:g.maximum_price.regular_price.value,currency:(m=(d=e.configured_variant)==null?void 0:d.price_range)==null?void 0:m.maximum_price.regular_price.currency}:e.__typename==="GiftCardCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.price.value,currency:e.prices.price.currency}:{value:(y=e.product.price_range)==null?void 0:y.maximum_price.regular_price.value,currency:(f=e.product.price_range)==null?void 0:f.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((v=(b=e.configured_variant)==null?void 0:b.price_range)==null?void 0:v.maximum_price.discount.amount_off)>0:((C=e.product.price_range)==null?void 0:C.maximum_price.discount.amount_off)>0,bundleOptions:e.__typename==="BundleCartItem"?P(e.bundle_options):null,selectedOptions:E(e.configurable_options),customizableOptions:G(e.customizable_options),sender:e.__typename==="GiftCardCartItem"?e.sender_name:null,senderEmail:e.__typename==="GiftCardCartItem"?e.sender_email:null,recipient:e.__typename==="GiftCardCartItem"?e.recipient_name:null,recipientEmail:e.__typename==="GiftCardCartItem"?e.recipient_email:null,message:e.__typename==="GiftCardCartItem"?e.message:null,discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency}}})}function w(r){var t;const n=(t=r==null?void 0:r.items)==null?void 0:t.reduce((e,u)=>{var l;return(l=u.errors)==null||l.forEach(c=>{e.push({uid:u.uid,text:c.message})}),e},[]);return n!=null&&n.length?n:null}function I(r){return r!=null&&r.length?r.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})):[]}function P(r){const n=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(u=>u.label).join(", ")})),t={};return n==null||n.forEach(e=>{t[e.label]=e.value}),Object.keys(t).length>0?t:null}function E(r){const n=r==null?void 0:r.map(e=>({uid:e.configurable_product_option_uid,label:e.option_label,value:e.value_label})),t={};return n==null||n.forEach(e=>{t[e.label]=e.value}),Object.keys(t).length>0?t:null}function G(r){const n=r==null?void 0:r.map(e=>({uid:e.customizable_option_uid,label:e.label,type:e.type,values:e.values.map(u=>({uid:u.customizable_option_value_uid,label:u.label,value:u.value}))})),t={};return n==null||n.forEach(e=>{switch(e.type){case"field":case"area":case"date_time":t[e.label]=e.values[0].value;break;case"radio":case"drop_down":t[e.label]=e.values[0].label;break;case"multiple":case"checkbox":t[e.label]=e.values.reduce((u,l)=>u?`${u}, ${l.label}`:l.label,"");break}}),t}function N(r){var n,t;return((n=a.config)==null?void 0:n.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((t=a.config)==null?void 0:t.cartSummaryDisplayTotal)===1?r.total_quantity:r.itemsV2.items.length}function k(r){return(r==null?void 0:r.length)>0?{count:r.length,result:r.map(n=>n.title).join(", ")}:null}function z(r){var n,t,e,u;return(n=r.shipping_addresses)!=null&&n.length?(t=r.shipping_addresses)==null?void 0:t.map(l=>({countryCode:l.country.code,zipCode:l.postcode,regionCode:l.region.code})):(e=r.addresses)!=null&&e.length?(u=r.addresses)==null?void 0:u.filter(l=>l.default_shipping).map(l=>{var c;return l.default_shipping&&{countryCode:l.country_id,zipCode:l.postcode,regionCode:(c=l.region)==null?void 0:c.region_code}}):null}const K=r=>{const n=r.findIndex(({extensions:u})=>(u==null?void 0:u.category)==="graphql-authorization")>-1,t=r.findIndex(({extensions:u})=>(u==null?void 0:u.category)==="graphql-no-such-entity")>-1,e=r.map(u=>u.message).join(" ");if(n||t)return $(),console.error(e),null;throw Error(e)},o=`
2
+ customizable_options {
3
+ type
4
+ customizable_option_uid
5
+ label
6
+ is_required
7
+ values {
8
+ label
9
+ value
10
+ price{
11
+ type
12
+ units
13
+ value
14
+ }
15
+ }
16
+ }
17
+ `,x=`
18
+ price_range {
19
+ minimum_price {
20
+ regular_price {
21
+ value
22
+ currency
23
+ }
24
+ final_price {
25
+ value
26
+ currency
27
+ }
28
+ discount {
29
+ percent_off
30
+ amount_off
31
+ }
32
+ }
33
+ maximum_price {
34
+ regular_price {
35
+ value
36
+ currency
37
+ }
38
+ final_price {
39
+ value
40
+ currency
41
+ }
42
+ discount {
43
+ percent_off
44
+ amount_off
45
+ }
46
+ }
47
+ }
48
+ `,Z=`
49
+ fragment CartFragment on Cart {
50
+ id
51
+ total_quantity
52
+ is_virtual
53
+ prices {
54
+ subtotal_with_discount_excluding_tax {
55
+ currency
56
+ value
57
+ }
58
+ subtotal_including_tax {
59
+ currency
60
+ value
61
+ }
62
+ subtotal_excluding_tax {
63
+ currency
64
+ value
65
+ }
66
+ grand_total {
67
+ currency
68
+ value
69
+ }
70
+ grand_total_excluding_tax {
71
+ currency
72
+ value
73
+ }
74
+ applied_taxes {
75
+ label,
76
+ amount {
77
+ value
78
+ currency
79
+ }
80
+ }
81
+ discounts {
82
+ amount {
83
+ value
84
+ currency
85
+ }
86
+ label
87
+ }
88
+ }
89
+ itemsV2 (
90
+ pageSize:$pageSize,
91
+ currentPage:$currentPage,
92
+ sort: $itemsSortInput
93
+ ) {
94
+ items {
95
+ __typename
96
+ uid
97
+ quantity
98
+
99
+ errors {
100
+ code
101
+ message
102
+ }
103
+
104
+ prices {
105
+ price {
106
+ value
107
+ currency
108
+ }
109
+ total_item_discount {
110
+ value
111
+ currency
112
+ }
113
+ row_total {
114
+ value
115
+ currency
116
+ }
117
+ row_total_including_tax {
118
+ value
119
+ currency
120
+ }
121
+ price_including_tax {
122
+ value
123
+ currency
124
+ }
125
+ fixed_product_taxes {
126
+ amount {
127
+ value
128
+ currency
129
+ }
130
+ label
131
+ }
132
+ original_row_total{
133
+ value
134
+ currency
135
+ }
136
+ }
137
+
138
+ product {
139
+ name
140
+ sku
141
+ thumbnail {
142
+ url
143
+ label
144
+ }
145
+ url_key
146
+ url_suffix
147
+ categories {
148
+ url_path
149
+ url_key
150
+ }
151
+ ${x}
152
+ }
153
+ ...on SimpleCartItem {
154
+ ${o}
155
+ }
156
+ ... on ConfigurableCartItem {
157
+ configurable_options {
158
+ configurable_product_option_uid
159
+ option_label
160
+ value_label
161
+ }
162
+ configured_variant {
163
+ uid
164
+ sku
165
+ thumbnail {
166
+ label
167
+ url
168
+ }
169
+ ${x}
170
+ }
171
+ ${o}
172
+ }
173
+ ... on DownloadableCartItem {
174
+ links {
175
+ sort_order
176
+ title
177
+ }
178
+ ${o}
179
+ }
180
+ ... on BundleCartItem {
181
+ bundle_options {
182
+ uid
183
+ label
184
+ values {
185
+ uid
186
+ label
187
+ }
188
+ }
189
+ }
190
+ ... on GiftCardCartItem {
191
+ message
192
+ recipient_email
193
+ recipient_name
194
+ sender_email
195
+ sender_name
196
+ amount{
197
+ currency
198
+ value
199
+ }
200
+ is_available
201
+ }
202
+ }
203
+ }
204
+ shipping_addresses {
205
+ country {
206
+ code
207
+ }
208
+ region {
209
+ code
210
+ }
211
+ postcode
212
+ }
213
+ }
214
+ `,W=`
215
+ $pageSize: Int! = 100,
216
+ $currentPage: Int! = 1,
217
+ $itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}
218
+ `,X=`
219
+ customer {
220
+ addresses {
221
+ default_shipping
222
+ country_id
223
+ postcode
224
+ region {
225
+ region
226
+ region_code
227
+ region_id
228
+ }
229
+ }
230
+ }`,$=()=>(a.cartId=null,a.authenticated=!1,Promise.resolve(null));export{W as C,Z as a,B as b,V as c,U as d,$ as e,H as f,J as g,K as h,q as i,X as j,R as k,Q as l,j as r,a as s,L as t};
@@ -1,4 +1,4 @@
1
- import{C as P,a as A,s as f,f as I,h as v,t as D}from"./getStoreConfig.js";import{events as g}from"@dropins/tools/event-bus.js";function T(r){const{cart:e,locale:t="en-US"}=r;return{id:e.id,items:m(e.items,t),prices:{subtotalExcludingTax:e.subtotal.excludingTax,subtotalIncludingTax:e.subtotal.includingTax},totalQuantity:e.totalQuantity,possibleOnepageCheckout:void 0,giftMessageSelected:void 0,giftWrappingSelected:void 0,source:void 0}}function m(r,e){return r.map(t=>{var a;return{canApplyMsrp:!1,formattedPrice:h(e,t.price.currency,t.price.value),id:t.uid,prices:{price:t.price},product:{productId:t.uid,name:t.name,sku:t.sku,topLevelSku:void 0,specialToDate:void 0,specialFromDate:void 0,newToDate:void 0,newFromDate:void 0,createdAt:void 0,updatedAt:void 0,manufacturer:void 0,countryOfManufacture:void 0,categories:t.url.categories,productType:void 0,pricing:{regularPrice:t.regularPrice.value,minimalPrice:void 0,maximalPrice:void 0,specialPrice:(a=t.discount)==null?void 0:a.value,tierPricing:void 0,currencyCode:t.regularPrice.currency},canonicalUrl:t.url.urlKey,mainImageUrl:t.image.src,image:{src:t.image.src,alt:t.image.alt}},configurableOptions:void 0,quantity:t.quantity}})}function h(r,e,t){const a=r.replace("_","-");return new Intl.NumberFormat(a,{style:"currency",currency:e}).format(t)}const c={SHOPPING_CART_CONTEXT:"shoppingCartContext",PRODUCT_CONTEXT:"productContext",CHANGED_PRODUCTS_CONTEXT:"changedProductsContext"},s={OPEN_CART:"open-cart",ADD_TO_CART:"add-to-cart",REMOVE_FROM_CART:"remove-from-cart",SHOPPING_CART_VIEW:"shopping-cart-view"};function _(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function i(r,e){const t=_();t.push({[r]:null}),t.push({[r]:e})}function l(r,e){_().push(a=>{const n=a.getState?a.getState():{};a.push({event:r,eventInfo:{...n,...e}})})}function b(r,e,t){const a=T({cart:r,locale:t});i(c.SHOPPING_CART_CONTEXT,{...a}),l(s.OPEN_CART),m(e,t).forEach(d=>{i(c.PRODUCT_CONTEXT,d.product),p(a,[d],s.ADD_TO_CART)})}function x(r,e){const t=T({cart:r,locale:e});i(c.SHOPPING_CART_CONTEXT,{...t}),l(s.SHOPPING_CART_VIEW)}function p(r,e,t){const a={items:e};i(c.SHOPPING_CART_CONTEXT,{...r}),i(c.CHANGED_PRODUCTS_CONTEXT,{...a}),l(t)}function N(r,e,t){const a=T({cart:r,locale:t}),n=a.items,d=_(),E=d.getState?d.getState():{},{shoppingCartContext:{items:R=[]}={}}=E;e.forEach(O=>{const u=R.find(C=>C.id===O.uid),o=n.find(C=>C.id===O.uid);!o&&!u||(!u&&o?(i(c.PRODUCT_CONTEXT,o.product),p(a,[o],s.ADD_TO_CART)):u&&!o?(i(c.PRODUCT_CONTEXT,u.product),p(a,[u],s.REMOVE_FROM_CART)):o.quantity>u.quantity?(i(c.PRODUCT_CONTEXT,o.product),p(a,[o],s.ADD_TO_CART)):(i(c.PRODUCT_CONTEXT,o.product),p(a,[o],s.REMOVE_FROM_CART)))})}const y=`
1
+ import{C as P,a as A,s as f,f as I,h as v,t as D}from"./resetCart.js";import{events as g}from"@dropins/tools/event-bus.js";function T(r){const{cart:e,locale:t="en-US"}=r;return{id:e.id,items:m(e.items,t),prices:{subtotalExcludingTax:e.subtotal.excludingTax,subtotalIncludingTax:e.subtotal.includingTax},totalQuantity:e.totalQuantity,possibleOnepageCheckout:void 0,giftMessageSelected:void 0,giftWrappingSelected:void 0,source:void 0}}function m(r,e){return r.map(t=>{var a;return{canApplyMsrp:!1,formattedPrice:h(e,t.price.currency,t.price.value),id:t.uid,prices:{price:t.price},product:{productId:t.uid,name:t.name,sku:t.sku,topLevelSku:void 0,specialToDate:void 0,specialFromDate:void 0,newToDate:void 0,newFromDate:void 0,createdAt:void 0,updatedAt:void 0,manufacturer:void 0,countryOfManufacture:void 0,categories:t.url.categories,productType:void 0,pricing:{regularPrice:t.regularPrice.value,minimalPrice:void 0,maximalPrice:void 0,specialPrice:(a=t.discount)==null?void 0:a.value,tierPricing:void 0,currencyCode:t.regularPrice.currency},canonicalUrl:t.url.urlKey,mainImageUrl:t.image.src,image:{src:t.image.src,alt:t.image.alt}},configurableOptions:void 0,quantity:t.quantity}})}function h(r,e,t){const a=r.replace("_","-");return new Intl.NumberFormat(a,{style:"currency",currency:e}).format(t)}const c={SHOPPING_CART_CONTEXT:"shoppingCartContext",PRODUCT_CONTEXT:"productContext",CHANGED_PRODUCTS_CONTEXT:"changedProductsContext"},s={OPEN_CART:"open-cart",ADD_TO_CART:"add-to-cart",REMOVE_FROM_CART:"remove-from-cart",SHOPPING_CART_VIEW:"shopping-cart-view"};function _(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function i(r,e){const t=_();t.push({[r]:null}),t.push({[r]:e})}function l(r,e){_().push(a=>{const n=a.getState?a.getState():{};a.push({event:r,eventInfo:{...n,...e}})})}function b(r,e,t){const a=T({cart:r,locale:t});i(c.SHOPPING_CART_CONTEXT,{...a}),l(s.OPEN_CART),m(e,t).forEach(d=>{i(c.PRODUCT_CONTEXT,d.product),p(a,[d],s.ADD_TO_CART)})}function x(r,e){const t=T({cart:r,locale:e});i(c.SHOPPING_CART_CONTEXT,{...t}),l(s.SHOPPING_CART_VIEW)}function p(r,e,t){const a={items:e};i(c.SHOPPING_CART_CONTEXT,{...r}),i(c.CHANGED_PRODUCTS_CONTEXT,{...a}),l(t)}function N(r,e,t){const a=T({cart:r,locale:t}),n=a.items,d=_(),E=d.getState?d.getState():{},{shoppingCartContext:{items:R=[]}={}}=E;e.forEach(O=>{const u=R.find(C=>C.id===O.uid),o=n.find(C=>C.id===O.uid);!o&&!u||(!u&&o?(i(c.PRODUCT_CONTEXT,o.product),p(a,[o],s.ADD_TO_CART)):u&&!o?(i(c.PRODUCT_CONTEXT,u.product),p(a,[u],s.REMOVE_FROM_CART)):o.quantity>u.quantity?(i(c.PRODUCT_CONTEXT,o.product),p(a,[o],s.ADD_TO_CART)):(i(c.PRODUCT_CONTEXT,o.product),p(a,[o],s.REMOVE_FROM_CART)))})}const y=`
2
2
  mutation UPDATE_PRODUCTS_FROM_CART_MUTATION(
3
3
  $cartId: String!,
4
4
  $cartItems: [CartItemUpdateInput!]!,
@@ -18,4 +18,3 @@ import{C as P,a as A,s as f,f as I,h as v,t as D}from"./getStoreConfig.js";impor
18
18
  }
19
19
  ${A}
20
20
  `,M=async r=>{const e=f.cartId;if(!e)throw Error("Cart ID is not set");return I(y,{variables:{cartId:e,cartItems:r.map(({uid:t,quantity:a})=>({cart_item_uid:t,quantity:a}))}}).then(({errors:t,data:a})=>{if(t)return v(t);const n=D(a.updateCartItems.cart);return g.emit("cart/updated",n),g.emit("cart/data",n),n&&N(n,r,f.locale||"en-US"),n})};export{N as a,x as b,b as p,M as u};
21
- //# sourceMappingURL=updateProductsFromCart.js.map