@dropins/storefront-cart 0.3.0 → 0.4.0-alpha128

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 (54) hide show
  1. package/api/getEstimatedTotals/getEstimatedTotals.d.ts +0 -1
  2. package/api/index.d.ts +1 -0
  3. package/api/initializeCart/initializeCart.d.ts +2 -0
  4. package/api/refreshCart/index.d.ts +2 -0
  5. package/api/refreshCart/refreshCart.d.ts +4 -0
  6. package/api.js +5 -5
  7. package/chunks/CartFragment.js +235 -0
  8. package/chunks/CartSummaryList.js +1 -0
  9. package/chunks/MiniCart.js +1 -1
  10. package/chunks/OrderSummary.js +1 -0
  11. package/chunks/getEstimateShipping.js +48 -0
  12. package/chunks/getEstimatedTotals.js +3 -50
  13. package/chunks/getStoreConfig.js +4 -4
  14. package/chunks/resetCart.js +1 -230
  15. package/chunks/state.js +1 -0
  16. package/chunks/updateProductsFromCart.js +3 -3
  17. package/components/Cart/Cart.d.ts +3 -3
  18. package/components/CartSummaryList/CartSummaryList.d.ts +12 -0
  19. package/components/CartSummaryList/index.d.ts +3 -0
  20. package/components/EstimateShipping/EstimateShipping.d.ts +20 -0
  21. package/components/EstimateShipping/index.d.ts +2 -0
  22. package/components/MiniCart/MiniCart.d.ts +0 -2
  23. package/components/OrderSummary/OrderSummary.d.ts +37 -0
  24. package/components/OrderSummary/index.d.ts +3 -0
  25. package/components/index.d.ts +4 -1
  26. package/containers/Cart/Cart.d.ts +6 -7
  27. package/containers/Cart.js +1 -1
  28. package/containers/CartSummaryList/CartSummaryList.d.ts +20 -0
  29. package/containers/CartSummaryList/index.d.ts +3 -0
  30. package/containers/CartSummaryList.d.ts +3 -0
  31. package/containers/CartSummaryList.js +1 -0
  32. package/containers/EstimateShipping/EstimateShipping.d.ts +7 -0
  33. package/containers/EstimateShipping/index.d.ts +3 -0
  34. package/containers/EstimateShipping.d.ts +3 -0
  35. package/containers/EstimateShipping.js +1 -0
  36. package/containers/MiniCart/MiniCart.d.ts +4 -1
  37. package/containers/MiniCart.js +1 -1
  38. package/containers/OrderSummary/OrderSummary.d.ts +16 -0
  39. package/containers/OrderSummary/index.d.ts +3 -0
  40. package/containers/OrderSummary.d.ts +3 -0
  41. package/containers/OrderSummary.js +1 -0
  42. package/containers/index.d.ts +3 -0
  43. package/data/models/cart-model.d.ts +9 -1
  44. package/data/models/index.d.ts +1 -0
  45. package/data/models/shipping-models.d.ts +16 -0
  46. package/data/transforms/__fixtures__/cartModel.d.ts +1 -0
  47. package/data/transforms/__fixtures__/productTypesData.d.ts +223 -5
  48. package/data/transforms/__fixtures__/storeConfig.d.ts +4 -0
  49. package/data/transforms/transform-shipping.d.ts +5 -0
  50. package/hooks/useEstimatedTotals.d.ts +2 -0
  51. package/i18n/en_US.json.d.ts +57 -2
  52. package/lib/state.d.ts +1 -0
  53. package/package.json +1 -1
  54. package/render.js +2 -2
@@ -5,7 +5,6 @@ export interface EstimateAddressShippingInput {
5
5
  postcode?: string;
6
6
  region?: {
7
7
  region?: string;
8
- code?: string;
9
8
  id?: number;
10
9
  };
11
10
  shipping_method?: {
package/api/index.d.ts CHANGED
@@ -9,4 +9,5 @@ export * from './createEmptyCart';
9
9
  export * from './getStoreConfig';
10
10
  export * from './getEstimateShipping';
11
11
  export * from './getEstimatedTotals';
12
+ export * from './refreshCart';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,6 @@
1
1
  import { CartModel } from '../../data/models';
2
2
 
3
3
  export declare const initializeCart: () => Promise<CartModel | null>;
4
+ export declare function getCustomerCartPayload(): Promise<CartModel | null>;
5
+ export declare function getGuestCartPayload(): Promise<CartModel | null>;
4
6
  //# sourceMappingURL=initializeCart.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './refreshCart';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { CartModel } from '../../data/models';
2
+
3
+ export declare const refreshCart: () => Promise<CartModel | null>;
4
+ //# sourceMappingURL=refreshCart.d.ts.map
package/api.js CHANGED
@@ -1,8 +1,8 @@
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=`
1
+ import{s}from"./chunks/state.js";import{C as T,a as l,t as f}from"./chunks/CartFragment.js";import{events as m}from"@dropins/tools/event-bus.js";import{f as p,h as g}from"./chunks/resetCart.js";import{g as v,r as Q,c as H,s as k,a as z,b as Y}from"./chunks/resetCart.js";import{a as I,b as h}from"./chunks/updateProductsFromCart.js";import{u as q}from"./chunks/updateProductsFromCart.js";import{c as _,g as E,a as A}from"./chunks/getStoreConfig.js";import{b as J,e as K,i as L,d as V}from"./chunks/getStoreConfig.js";import{g as X,b as Z,a as tt}from"./chunks/getEstimateShipping.js";import{g as at}from"./chunks/getEstimatedTotals.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const R=`
2
2
  mutation ADD_PRODUCTS_TO_CART_MUTATION(
3
3
  $cartId: String!,
4
4
  $cartItems: [CartItemInput!]!,
5
- ${C}
5
+ ${T}
6
6
  ) {
7
7
  addProductsToCart(
8
8
  cartId: $cartId
@@ -17,9 +17,9 @@ import{C,a as T,s as n,f as m,h as u,t as l}from"./chunks/resetCart.js";import{g
17
17
  }
18
18
  }
19
19
  }
20
- ${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})},_=`
20
+ ${l}
21
+ `,w=async r=>{let o=!1;const n=s.cartId||await O().then(e=>(o=!0,e));return p(R,{variables:{cartId:n,cartItems:r.map(({sku:e,parentSku:a,quantity:i,optionsUIDs:t,enteredOptions:c})=>({sku:e,parent_sku:a,quantity:i,selected_options:t,entered_options:c}))}}).then(({errors:e,data:a})=>{var c;const i=[...((c=a==null?void 0:a.addProductsToCart)==null?void 0:c.user_errors)??[],...e??[]];if(i.length>0)return g(i);const t=f(a.addProductsToCart.cart);if(m.emit("cart/updated",t),m.emit("cart/data",t),t){const d=t.items.filter(C=>r.some(({sku:u})=>u===C.sku));o?I(t,d,s.locale??"en-US"):h(t,d,s.locale??"en-US")}return t})},P=`
22
22
  mutation CREATE_EMPTY_CART_MUTATION {
23
23
  createEmptyCart
24
24
  }
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};
25
+ `,O=async()=>{const{disableGuestCart:r}=_.getConfig();if(r)throw new Error("Guest cart is disabled");return await p(P).then(({data:o})=>{const n=o.createEmptyCart;return s.cartId=n,n})},F=async()=>{const r=s.authenticated?await E():await A();return m.emit("cart/updated",r),m.emit("cart/data",r),r};export{w as addProductsToCart,_ as config,O as createEmptyCart,p as fetchGraphQl,J as getCartData,v as getConfig,X as getCountries,E as getCustomerCartPayload,Z as getEstimateShipping,at as getEstimatedTotals,A as getGuestCartPayload,tt as getRegions,K as getStoreConfig,L as initialize,V as initializeCart,F as refreshCart,Q as removeFetchGraphQlHeader,H as resetCart,k as setEndpoint,z as setFetchGraphQlHeader,Y as setFetchGraphQlHeaders,q as updateProductsFromCart};
@@ -0,0 +1,235 @@
1
+ import{s}from"./state.js";function R(r){var n,u,e,l,c,t,a;return r?{id:r.id,totalQuantity:z(r),errors:S(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=s.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:(u=r.prices.subtotal_excluding_tax)==null?void 0:u.value,currency:(e=r.prices.subtotal_excluding_tax)==null?void 0:e.currency},includingTax:{value:(l=r.prices.subtotal_including_tax)==null?void 0:l.value,currency:(c=r.prices.subtotal_including_tax)==null?void 0:c.currency},includingDiscountOnly:{value:(t=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:t.value,currency:(a=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:a.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:k(r.prices.applied_taxes),appliedDiscounts:I(r.prices.discounts),isVirtual:r.is_virtual,addresses:{shipping:r.shipping_addresses&&N(r)},isGuestCart:!s.authenticated,hasOutOfStockItems:$(r),hasFullyOutOfStockItems:P(r)}:null}function k(r){return r!=null&&r.length?r.reduce((n,u)=>({value:n.value+u.amount.value,currency:u.amount.currency}),{value:0,currency:""}):null}function h(r){var u;if(!((u=r==null?void 0:r.items)!=null&&u.length))return[];const n=s.config;return r.items.map(e=>{var l,c,t,a,_,o,i,g,y,m,f,b,d,v,C,x;return{itemType:e.__typename,uid:e.uid,url:{urlKey:e.product.url_key,categories:e.product.categories.map(O=>O.url_key)},quantity:e.quantity,sku:e.product.sku,name:e.product.name,image:{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(l=e.configured_variant)==null?void 0:l.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.label:((a=(t=e.configured_variant)==null?void 0:t.thumbnail)==null?void 0:a.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:G(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:(_=e.prices.original_row_total)==null?void 0:_.value,currency:(o=e.prices.original_row_total)==null?void 0:o.currency},discount:{value:e.prices.total_item_discount.value,currency:e.prices.total_item_discount.currency},regularPrice:e.__typename==="ConfigurableCartItem"?{value:(g=(i=e.configured_variant)==null?void 0:i.price_range)==null?void 0:g.maximum_price.regular_price.value,currency:(m=(y=e.configured_variant)==null?void 0:y.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:(f=e.product.price_range)==null?void 0:f.maximum_price.regular_price.value,currency:(b=e.product.price_range)==null?void 0:b.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((v=(d=e.configured_variant)==null?void 0:d.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"?w(e.bundle_options):null,selectedOptions:E(e.configurable_options),customizableOptions:A(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},onlyXLeftInStock:e.__typename==="ConfigurableCartItem"?(x=e.configured_variant)==null?void 0:x.only_x_left_in_stock:e.product.only_x_left_in_stock,lowInventory:e.is_available&&e.product.only_x_left_in_stock!==null,insufficientQuantity:(e.__typename==="ConfigurableCartItem"?e.configured_variant:e.product).stock_status==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockLevel:M(e)}})}function S(r){var u;const n=(u=r==null?void 0:r.items)==null?void 0:u.reduce((e,l)=>{var c;return(c=l.errors)==null||c.forEach(t=>{e.push({uid:l.uid,text:t.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 w(r){const n=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(l=>l.label).join(", ")})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u: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})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u:null}function A(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(l=>({uid:l.customizable_option_value_uid,label:l.label,value:l.value}))})),u={};return n==null||n.forEach(e=>{var l;switch(e.type){case"field":case"area":case"date_time":u[e.label]=e.values[0].value;break;case"radio":case"drop_down":u[e.label]=e.values[0].label;break;case"multiple":case"checkbox":u[e.label]=e.values.reduce((o,i)=>o?`${o}, ${i.label}`:i.label,"");break;case"file":const c=new DOMParser,t=e.values[0].value,_=((l=c.parseFromString(t,"text/html").querySelector("a"))==null?void 0:l.textContent)||"";u[e.label]=_;break}}),u}function z(r){var n,u;return((n=s.config)==null?void 0:n.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((u=s.config)==null?void 0:u.cartSummaryDisplayTotal)===1?r.total_quantity:r.itemsV2.items.length}function G(r){return(r==null?void 0:r.length)>0?{count:r.length,result:r.map(n=>n.title).join(", ")}:null}function N(r){var n,u,e,l;return(n=r.shipping_addresses)!=null&&n.length?(u=r.shipping_addresses)==null?void 0:u.map(c=>({countryCode:c.country.code,zipCode:c.postcode,regionCode:c.region.code})):(e=r.addresses)!=null&&e.length?(l=r.addresses)==null?void 0:l.filter(c=>c.default_shipping).map(c=>{var t;return c.default_shipping&&{countryCode:c.country_id,zipCode:c.postcode,regionCode:(t=c.region)==null?void 0:t.region_code}}):null}function $(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"||e.product.stock_status==="IN_STOCK"&&!e.is_available})}function M(r){if(!r.not_available_message)return null;const n=r.not_available_message.match(/-?\d+/);return n?parseInt(n[0]):"noNumber"}function P(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"})}const 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
+ `,T=`
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
+ `,D=`
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
+ is_available
99
+ not_available_message
100
+ errors {
101
+ code
102
+ message
103
+ }
104
+
105
+ prices {
106
+ price {
107
+ value
108
+ currency
109
+ }
110
+ total_item_discount {
111
+ value
112
+ currency
113
+ }
114
+ row_total {
115
+ value
116
+ currency
117
+ }
118
+ row_total_including_tax {
119
+ value
120
+ currency
121
+ }
122
+ price_including_tax {
123
+ value
124
+ currency
125
+ }
126
+ fixed_product_taxes {
127
+ amount {
128
+ value
129
+ currency
130
+ }
131
+ label
132
+ }
133
+ original_row_total{
134
+ value
135
+ currency
136
+ }
137
+ }
138
+
139
+ product {
140
+ name
141
+ sku
142
+ thumbnail {
143
+ url
144
+ label
145
+ }
146
+ url_key
147
+ url_suffix
148
+ categories {
149
+ url_path
150
+ url_key
151
+ }
152
+ only_x_left_in_stock
153
+ stock_status
154
+ ${T}
155
+ }
156
+ ...on SimpleCartItem {
157
+ ${p}
158
+ }
159
+ ... on ConfigurableCartItem {
160
+ configurable_options {
161
+ configurable_product_option_uid
162
+ option_label
163
+ value_label
164
+ }
165
+ configured_variant {
166
+ uid
167
+ sku
168
+ only_x_left_in_stock
169
+ stock_status
170
+ thumbnail {
171
+ label
172
+ url
173
+ }
174
+ ${T}
175
+ }
176
+ ${p}
177
+ }
178
+ ... on DownloadableCartItem {
179
+ links {
180
+ sort_order
181
+ title
182
+ }
183
+ ${p}
184
+ }
185
+ ... on BundleCartItem {
186
+ bundle_options {
187
+ uid
188
+ label
189
+ values {
190
+ uid
191
+ label
192
+ }
193
+ }
194
+ }
195
+ ... on GiftCardCartItem {
196
+ message
197
+ recipient_email
198
+ recipient_name
199
+ sender_email
200
+ sender_name
201
+ amount{
202
+ currency
203
+ value
204
+ }
205
+ is_available
206
+ }
207
+ }
208
+ }
209
+ shipping_addresses {
210
+ country {
211
+ code
212
+ }
213
+ region {
214
+ code
215
+ }
216
+ postcode
217
+ }
218
+ }
219
+ `,V=`
220
+ $pageSize: Int! = 100,
221
+ $currentPage: Int! = 1,
222
+ $itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}
223
+ `,q=`
224
+ customer {
225
+ addresses {
226
+ default_shipping
227
+ country_id
228
+ postcode
229
+ region {
230
+ region
231
+ region_code
232
+ region_id
233
+ }
234
+ }
235
+ }`;export{V as C,D as a,q as b,R as t};
@@ -0,0 +1 @@
1
+ import{jsx as r,jsxs as k,Fragment as P}from"@dropins/tools/preact-jsx-runtime.js";import*as c from"@dropins/tools/preact-compat.js";import{useState as O,useEffect as ut}from"@dropins/tools/preact-compat.js";import{classes as y,VComponent as x,Slot as z}from"@dropins/tools/lib.js";/* empty css */import{IllustratedMessage as dt,Icon as w,Button as gt,Divider as ft,Skeleton as mt,SkeletonRow as pt,InLineAlert as ht,CartList as M,CartItem as yt,Price as L,Image as kt}from"@dropins/tools/components.js";import{useText as B}from"@dropins/tools/i18n.js";import{s as vt,g as Ct}from"./state.js";import{events as Lt}from"@dropins/tools/event-bus.js";const wt=s=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},c.createElement("g",{clipPath:"url(#clip0_102_196)"},c.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"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_102_196"},c.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),$=s=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},c.createElement("g",{clipPath:"url(#clip0_4797_15331)"},c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.25 20.91L1.5 17.55V6.51996L10.25 9.92996V20.91Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19 13.31L15.5 19.37H22.5L19 13.31Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19.0202 17.11H18.9802L18.9502 15.56H19.0502L19.0202 17.11ZM18.9602 18.29V18.06H19.0502V18.29H18.9602Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19 12.16V6.51996L10.25 9.92996V20.91L14.27 19.37L14.4 19.32",stroke:"currentColor",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.51999L10.25 3.04999L19 6.51999L10.25 9.92999L1.5 6.51999Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_4797_15331"},c.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),Et=s=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),It=({className:s,children:E,ctaLinkURL:l,...m})=>{const d=B({emptyCart:"Cart.EmptyCart.heading",cta:"Cart.EmptyCart.cta"});return r("div",{...m,className:y(["cart-empty-cart",s]),children:r(dt,{className:y(["cart-empty-cart__wrapper",s]),"data-testid":"cart-empty-cart",heading:d.emptyCart,icon:r(w,{className:"cart-empty-cart__icon",source:wt}),action:l?r(gt,{"data-testid":"cart-empty-cart-button",size:"medium",variant:"primary",type:"submit",href:l,children:d.cta},"routeHome"):void 0})})},St=({className:s,children:E,heading:l,emptyCart:m,products:d,outOfStockMessage:p,loading:I=!0,...f})=>r("div",{...f,className:y(["cart-cart-summary-list",s]),children:I?r(_t,{}):k(P,{children:[(l||p)&&k("div",{"data-testid":"cart-summary-list-heading-wrapper",className:y(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!d]]),children:[l&&k(P,{children:[r(x,{node:l,className:"cart-cart-summary-list__heading-text"}),r(ft,{variant:"primary",className:y(["cart-cart-summary-list__heading-divider"])})]}),p&&r(x,{node:p,className:"cart-cart-summary-list__out-of-stock-message"})]}),r("div",{className:y(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!d]]),children:d||r(x,{node:m,className:"cart-cart-summary-list__empty-cart"})})]})}),_t=()=>r(mt,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:r(pt,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),Nt=({initialData:s=null,hideHeading:E,routeProduct:l,routeEmptyCartCTA:m,onItemQuantityUpdate:d,onItemRemove:p,maxItems:I,slots:f,attributesToHide:h=[],...T})=>{var G;const[b,W]=O(!s),[a,q]=O(s),[S,F]=O(new Set),o=(G=vt.config)==null?void 0:G.shoppingCartDisplaySetting,i=B({file:"Cart.CartItem.file",files:"Cart.CartItem.files",heading:"Cart.Cart.heading",message:"Cart.CartItem.message",recipient:"Cart.CartItem.recipient",regularPrice:"Cart.CartItem.regularPrice",discountedPrice:"Cart.CartItem.discountedPrice",sender:"Cart.CartItem.sender",lowInventory:"Cart.CartItem.lowInventory",insufficientQuantity:"Cart.CartItem.insufficientQuantity",insufficientQuantityGeneral:"Cart.CartItem.insufficientQuantityGeneral",outOfStockHeading:"Cart.OutOfStockMessage.heading",outOfStockDescription:"Cart.OutOfStockMessage.message",outOfStockAlert:"Cart.OutOfStockMessage.alert",removeAction:"Cart.OutOfStockMessage.action"}),_=(t,e)=>{F(n=>(e?n.add(t):n.delete(t),new Set(n)))},N=(t,e)=>{_(t,!0),p&&e===0?p(t).finally(()=>{_(t,!1)}).catch(n=>{console.warn(n)}):d&&d(t,e).finally(()=>{_(t,!1)}).catch(n=>{console.warn(n)})};ut(()=>{const t=Lt.on("cart/data",e=>{q(e),W(!1)},{eager:!0});return()=>{t==null||t.off()}},[]);const R=(t,e)=>{if(h.includes("image"))return;const n=r(kt,{"data-testid":"cart-list-item-image",loading:e<4?"eager":"lazy",src:t.image.src,alt:t.image.alt,width:"300",height:"300",params:{width:300}});return l?r("a",{href:l(t),children:n}):n},D=t=>{if(!h.includes("name"))return r("span",{"data-testid":"cart-list-item-title",children:l?r("a",{href:l(t),children:t.name}):t.name})},J=t=>{if(!h.includes("configurations"))return{...t.bundleOptions,...t.selectedOptions,...t.customizableOptions,...t.recipient?{[i.recipient]:t.recipient}:null,...t.recipientEmail&&t.recipient?{[i.recipient]:`${t.recipient} (${t.recipientEmail})`}:null,...t.sender?{[i.sender]:t.sender}:null,...t.senderEmail&&t.sender?{[i.sender]:`${t.sender} (${t.senderEmail})`}:{},...t.message?{[i.message]:t.message}:null,...t.links&&t.links.count?t.links.count>1?{[i.files.replace("{count}",t.links.count.toString())]:t.links.result}:{[i.file.replace("{count}",t.links.count.toString())]:t.links.result}:null}},K=t=>{var e,n,g,u;return(o==null?void 0:o.price)==="INCLUDING_TAX"?t.discounted?{amount:t.regularPrice.value,currency:t.regularPrice.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(e=t.taxedPrice)==null?void 0:e.value,currency:(n=t.taxedPrice)==null?void 0:n.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(g=t.regularPrice)==null?void 0:g.value,currency:(u=t.regularPrice)==null?void 0:u.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},Y=t=>(o==null?void 0:o.price)==="INCLUDING_EXCLUDING_TAX"?r(L,{amount:t.rowTotal.value,currency:t.rowTotal.currency,"data-testid":"excluding-tax-total","aria-label":i.regularPrice}):void 0,tt=t=>{var g,u,C,V,X,j,Z,A,H,U;const e={"aria-label":i.regularPrice},n=t.discounted?{}:null;return["INCLUDING_TAX","INCLUDING_EXCLUDING_TAX"].includes(o==null?void 0:o.price)?(e.amount=(g=t.rowTotalIncludingTax)==null?void 0:g.value,e.currency=(u=t.rowTotalIncludingTax)==null?void 0:u.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="including-tax-item-total",n&&(e.amount=(C=t.total)==null?void 0:C.value,e.currency=(V=t.total)==null?void 0:V.currency,n.amount=(X=t.rowTotalIncludingTax)==null?void 0:X.value,n.currency=(j=t.rowTotalIncludingTax)==null?void 0:j.currency,n.sale=!0,n["aria-label"]=i.discountedPrice,n["data-testid"]="discount-total")):(e.amount=(Z=t.total)==null?void 0:Z.value,e.currency=(A=t.total)==null?void 0:A.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",n&&(n.amount=(H=t.discountedTotal)==null?void 0:H.value,n.currency=(U=t.discountedTotal)==null?void 0:U.currency,n.sale=!0,n["aria-label"]=i.regularPrice,n["data-testid"]="discount-total")),{totalProps:e,discountProps:n}},et=t=>{var g,u;if(h.includes("warning"))return;const e=t.insufficientQuantity&&t.stockLevel?t.stockLevel==="noNumber"?i.insufficientQuantityGeneral:i.insufficientQuantity.replace("{inventory}",(g=t.stockLevel)==null?void 0:g.toString()).replace("{count}",t.quantity.toString()):"",n=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(u=t.onlyXLeftInStock)==null?void 0:u.toString());return t.insufficientQuantity||t.lowInventory?k("span",{"data-testid":"item-warning",children:[r(w,{source:Et,size:"16"}),e||n]}):void 0},rt=t=>{if(!(h!=null&&h.includes("alert")))return t.outOfStock?k("span",{"data-testid":"item-alert",children:[r(w,{source:$,size:"16"}),i.outOfStockAlert]}):void 0},nt=t=>r("span",{"data-testid":"cart-list-item-sku",children:t.sku}),Q=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,n)=>{const{totalProps:g,discountProps:u}=tt(e);return r(yt,{updating:S==null?void 0:S.has(e.uid),"data-testid":`cart-list-item-entry-${e.uid}`,image:R(e,n),title:D(e),sku:nt(e),price:r(L,{...K(e)}),quantity:e.quantity,total:k(P,{children:[r(L,{...g}),u&&r(L,{...u})]}),configurations:J(e),totalExcludingTax:Y(e),taxIncluded:(o==null?void 0:o.price)==="INCLUDING_TAX",taxExcluded:(o==null?void 0:o.price)==="INCLUDING_EXCLUDING_TAX",warning:et(e),alert:rt(e),onQuantity:d?C=>{N(e.uid,C)}:void 0,onRemove:p?()=>N(e.uid,0):void 0},e.uid)}):null,at=r(z,{name:"EmptyCart",slot:f==null?void 0:f.EmptyCart,context:{},children:r(It,{"data-testid":"empty-cart",ctaLinkURL:m==null?void 0:m()})}),ct=r(z,{name:"Heading",slot:f==null?void 0:f.Heading,context:{count:(a==null?void 0:a.totalQuantity)??0},children:r("div",{"data-testid":"default-cart-heading",children:i.heading.replace("{count}",((a==null?void 0:a.totalQuantity)??0).toString())})}),it=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{N(e.uid,0)})},ot=Q(t=>t.outOfStock||t.insufficientQuantity||!1),st=a!=null&&a.hasOutOfStockItems?r(ht,{"data-testid":"cart-out-of-stock-message",icon:r(w,{source:$,size:"16"}),itemList:r(M,{"data-testid":"out-of-stock-cart-items",children:ot}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems?[{label:i.removeAction,onClick:it}]:void 0}):void 0,v=Q(t=>!t.outOfStock&&!t.insufficientQuantity),lt=a!=null&&a.totalQuantity?r(M,{"data-testid":"cart-list",children:v==null?void 0:v.slice(0,I??v.length)}):null;return r(St,{...T,heading:E?void 0:ct,loading:b,emptyCart:at,products:lt,outOfStockMessage:st})};Nt.getInitialData=async function(){return Ct()};export{Nt as C};
@@ -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};
1
+ import{jsx as e,jsxs as d,Fragment as G}from"@dropins/tools/preact-jsx-runtime.js";import{useState as S,useEffect as f}from"@dropins/tools/preact-compat.js";import{classes as p,VComponent as _,Slot as I}from"@dropins/tools/lib.js";import{s as b,g as U}from"./state.js";import{events as O}from"@dropins/tools/event-bus.js";/* empty css */import{Price as L,Button as k}from"@dropins/tools/components.js";import{useText as P}from"@dropins/tools/i18n.js";import{p as M,u as T}from"./updateProductsFromCart.js";import{C as D}from"./CartSummaryList.js";import"./OrderSummary.js";const Q=({className:h,products:n,orderSummary:a,empty:r,...i})=>e("div",{...i,className:p(["cart-cart",h]),children:d("div",{className:p(["cart-cart__wrapper"]),children:[e("div",{"data-testid":"cart-content",className:p(["cart-cart__content",["cart-cart__content--empty",r||a==null],["cart-cart__content--full-width",r||a==null]]),children:n&&e(_,{node:n})}),n&&a&&e(_,{node:a,className:p(["cart-cart__order-summary"])})]})}),X=({className:h,products:n,subtotal:a,subtotalExcludingTaxes:r,ctas:i,...l})=>{const o=P({subtotal:"Cart.MiniCart.subtotal",subtotalExcludingTaxes:"Cart.MiniCart.subtotalExcludingTaxes"});return e("div",{...l,className:p(["cart-mini-cart",h]),children:n&&d(G,{children:[e("div",{className:"cart-mini-cart__products","data-testid":"mini-cart-products-wrapper",children:n}),d("div",{className:"cart-mini-cart__footer","data-testid":"mini-cart-subtotals",children:[a&&d("div",{className:"cart-mini-cart__footer__estimated-total","data-testid":"mini-cart-subtotal",children:[o.subtotal,e(_,{node:a})]}),r&&d("div",{className:"cart-mini-cart__footer__estimated-total-excluding-taxes","data-testid":"mini-cart-subtotal-excluding-taxes",children:[o.subtotalExcludingTaxes,e(_,{node:r,className:p(["dropin-price-summary__price","dropin-price-summary__price--muted"])})]}),i&&e(_,{node:i,className:"cart-mini-cart__footer__ctas"})]})]})})},j=({children:h,routeProduct:n,routeEmptyCartCTA:a,slots:r,initialData:i=null,...l})=>{const[o,x]=S(i),t=(s,m)=>T([{uid:s,quantity:m}]);f(()=>{const s=O.on("cart/data",m=>{x(m)},{eager:!0});return()=>{s==null||s.off()}},[]),f(()=>{i&&Object.keys(i).length>0&&M(i,b.locale??"en-US")},[i]);const g=r!=null&&r.OrderSummary?e(I,{name:"OrderSummary",slot:r.OrderSummary}):void 0,c=s=>t(s,0),y=e(I,{name:"ProductList",slot:r==null?void 0:r.ProductList,context:{itemQuantityUpdateHandler:t,itemRemoveHandler:c},children:e(D,{"data-testid":"default-cart-summary-list",routeProduct:n,routeEmptyCartCTA:a,onItemQuantityUpdate:t,onItemRemove:c,initialData:o})});return e(Q,{...l,empty:((o==null?void 0:o.items)&&o.items.length===0)??!0,orderSummary:g,products:y})};j.getInitialData=async function(){return U()};const w=({children:h,initialData:n=null,slots:a,routeProduct:r,routeCart:i,routeCheckout:l,routeEmptyCartCTA:o,...x})=>{var C,N;const[t,g]=S(n),c=(C=b.config)==null?void 0:C.shoppingCartDisplaySetting;f(()=>{const u=O.on("cart/data",v=>{g(v)},{eager:!0});return()=>{u==null||u.off()}},[]);const y=P({cartLink:"Cart.MiniCart.cartLink",checkoutLink:"Cart.MiniCart.checkoutLink"}),s=(u,v)=>T([{uid:u,quantity:v}]),m=u=>s(u,0);f(()=>{n&&Object.keys(n).length>0&&M(n,b.locale||"en-US")},[n]);const E=e(I,{name:"ProductList",slot:a==null?void 0:a.ProductList,context:{itemQuantityUpdateHandler:s,itemRemoveHandler:m},children:e(D,{"data-testid":"default-cart-summary-list",routeProduct:r,routeEmptyCartCTA:o,onItemRemove:m,initialData:t,maxItems:(N=b.config)==null?void 0:N.miniCartMaxItemsDisplay})}),R=()=>(c==null?void 0:c.subtotal)==="INCLUDING_TAX"||(c==null?void 0:c.subtotal)==="INCLUDING_EXCLUDING_TAX"?{amount:t==null?void 0:t.subtotal.includingTax.value,currency:t==null?void 0:t.subtotal.includingTax.currency,"data-testid":"subtotal-including-tax",style:{font:"inherit"}}:{amount:t==null?void 0:t.subtotal.excludingTax.value,currency:t==null?void 0:t.subtotal.excludingTax.currency,"data-testid":"subtotal-excluding-tax",style:{font:"inherit"}};return e(X,{...x,subtotal:(t==null?void 0:t.subtotal)&&e(L,{...R()}),subtotalExcludingTaxes:(t==null?void 0:t.subtotal)&&((c==null?void 0:c.subtotal)==="INCLUDING_EXCLUDING_TAX"?e(L,{amount:t==null?void 0:t.subtotal.excludingTax.value,currency:t==null?void 0:t.subtotal.excludingTax.currency,"data-testid":"subtotal-including-excluding-tax",style:{font:"inherit"}}):void 0),ctas:d("div",{children:[l&&e(k,{"data-testid":"route-checkout-button",variant:"primary",href:t!=null&&t.hasOutOfStockItems?void 0:l(),disabled:t==null?void 0:t.hasOutOfStockItems,"aria-disabled":t==null?void 0:t.hasOutOfStockItems,children:y.checkoutLink}),i&&e(k,{"data-testid":"route-cart-button",variant:"tertiary",href:i(),children:y.cartLink})]}),products:E})};w.getInitialData=async function(){return U()};export{j as C,w as M};
@@ -0,0 +1 @@
1
+ import{jsxs as d,jsx as t,Fragment as rr}from"@dropins/tools/preact-jsx-runtime.js";import*as Z from"@dropins/tools/preact-compat.js";import{useState as q,useEffect as K}from"@dropins/tools/preact-compat.js";import{classes as o,VComponent as h,Slot as er}from"@dropins/tools/lib.js";import{events as Y}from"@dropins/tools/event-bus.js";import{s as tr,g as ar}from"./state.js";import{g as ir}from"./getEstimatedTotals.js";import{Accordion as cr,AccordionSection as nr,ProgressSpinner as ur,Divider as mr,Price as l,Button as sr}from"@dropins/tools/components.js";/* empty css */import{useText as M}from"@dropins/tools/i18n.js";const or=()=>{const[_,O]=q(!1),[T,x]=q();return{handleEstimateTotals:(r,p)=>{O(!0);const{shippingCountry:g,shippingState:e="",shippingStateId:C,shippingZip:y=""}=r,a={countryCode:g,postcode:y,region:{region:e,id:C},shipping_method:{carrier_code:(p==null?void 0:p.carrier_code)||"",method_code:(p==null?void 0:p.method_code)||""}};ir(a).then(c=>{var B,v,m,P,N,w,I,k,E,L,s,W,G,z,F,U,n,i,D,f;c&&x({estimatedTaxTotal:{amount:(B=c.totalTax)==null?void 0:B.value,currency:(v=c.totalTax)==null?void 0:v.currency},estimatedSubTotal:{excludingTax:{amount:(P=(m=c.subtotal)==null?void 0:m.excludingTax)==null?void 0:P.value,currency:(w=(N=c.subtotal)==null?void 0:N.excludingTax)==null?void 0:w.currency},includingTax:{amount:(k=(I=c.subtotal)==null?void 0:I.includingTax)==null?void 0:k.value,currency:(L=(E=c.subtotal)==null?void 0:E.includingTax)==null?void 0:L.currency},includingDiscountOnly:{amount:(W=(s=c.subtotal)==null?void 0:s.includingDiscountOnly)==null?void 0:W.value,currency:(z=(G=c.subtotal)==null?void 0:G.includingDiscountOnly)==null?void 0:z.currency}},estimatedGrandTotalPrice:{includingTax:{amount:(F=c.total)==null?void 0:F.includingTax.value,currency:(U=c.total)==null?void 0:U.includingTax.currency},excludingTax:{amount:(n=c.total)==null?void 0:n.excludingTax.value,currency:(i=c.total)==null?void 0:i.excludingTax.currency}},estimatedAppliedTaxes:{taxes:(D=c.appliedTaxes)==null?void 0:D.map(u=>{var b,S;return{label:u.label,amount:{value:(b=u.amount)==null?void 0:b.value,currency:(S=u.amount)==null?void 0:S.currency}}})},estimatedItems:{items:(f=c.items)==null?void 0:f.map(u=>{var b,S,V,X,j,$,Q,R,H,J;return{uid:u.uid,price:{amount:(b=u.price)==null?void 0:b.value,currency:(S=u.price)==null?void 0:S.currency},taxedPrice:{amount:(V=u.taxedPrice)==null?void 0:V.value,currency:(X=u.taxedPrice)==null?void 0:X.currency},rowTotal:{amount:(j=u.rowTotal)==null?void 0:j.value,currency:($=u.rowTotal)==null?void 0:$.currency},rowTotalIncludingTax:{amount:(Q=u.rowTotalIncludingTax)==null?void 0:Q.value,currency:(R=u.rowTotalIncludingTax)==null?void 0:R.currency},regularPrice:{amount:(H=u.regularPrice)==null?void 0:H.value,currency:(J=u.regularPrice)==null?void 0:J.currency}}})}})}).finally(()=>{O(!1)})},estimatedTotals:T,setEstimatedTotals:x,loading:_}},lr=_=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",..._},Z.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),dr=_=>Z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",..._},Z.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),pr=({className:_,children:O,variant:T="primary",heading:x,loading:A=!0,subTotal:r,shipping:p,discounts:g,taxTotal:e,taxesApplied:C,total:y,primaryAction:a,...c})=>{const[B,v]=q(!1),m=M({checkout:"Cart.PriceSummary.checkout",discountedPrice:"Cart.CartItem.discountedPrice",download:"Cart.CartItem.download",heading:"Cart.Cart.heading",message:"Cart.CartItem.message",regularPrice:"Cart.CartItem.regularPrice",recipient:"Cart.CartItem.recipient",sender:"Cart.CartItem.sender",file:"Cart.CartItem.file",files:"Cart.CartItem.files",orderSummary:"Cart.PriceSummary.orderSummary",taxesBreakdownTitle:"Cart.PriceSummary.taxes.breakdown",taxTotal:"Cart.PriceSummary.taxes.total",taxEstimated:"Cart.PriceSummary.taxes.estimated",taxTotalOnly:"Cart.PriceSummary.taxes.totalOnly",showTaxBreakdown:"Cart.PriceSummary.taxes.showBreakdown",hideTaxBreakdown:"Cart.PriceSummary.taxes.hideBreakdown",taxToBeDetermined:"Cart.PriceSummary.taxToBeDetermined",subtotalLabel:"Cart.PriceSummary.subTotal.label",subtotalWithTaxes:"Cart.PriceSummary.subTotal.withTaxes",subtotalWithoutTaxes:"Cart.PriceSummary.subTotal.withoutTaxes",totalEstimated:"Cart.PriceSummary.total.estimated",totalLabel:"Cart.PriceSummary.total.label",totalWithoutTax:"Cart.PriceSummary.total.withoutTax",shippingLabel:"Cart.PriceSummary.shipping.label",zipPlaceholder:"Cart.PriceSummary.shipping.zipPlaceholder",editZipAction:"Cart.PriceSummary.shipping.editZipAction",shippingWithTaxes:"Cart.PriceSummary.shipping.withTaxes",shippingWithoutTaxes:"Cart.PriceSummary.shipping.withoutTaxes",shippingEstimated:"Cart.PriceSummary.shipping.estimated",shippingEstimatedByState:"Cart.PriceSummary.shipping.alternateField.state",shippingEstimatedByZip:"Cart.PriceSummary.shipping.alternateField.zip",destinationLinkAriaLabel:"Cart.PriceSummary.shipping.destinationLinkAriaLabel",applyButton:"Cart.PriceSummary.estimatedShippingForm.apply.label",countryField:"Cart.PriceSummary.estimatedShippingForm.country.placeholder",freeShipping:"Cart.PriceSummary.freeShipping",stateField:"Cart.PriceSummary.estimatedShippingForm.state.placeholder",zipField:"Cart.PriceSummary.estimatedShippingForm.zip.placeholder"}),P=r&&d("div",{className:o(["cart-order-summary__entry","cart-order-summary__subTotal"]),children:[t("span",{className:"cart-order-summary__label",children:m.subtotalLabel}),t(h,{node:r.price,className:"cart-order-summary__price"}),r.taxIncluded&&t("div",{"data-testid":"sub-total-tax-caption",className:"cart-order-summary__caption",children:t("span",{children:m.subtotalWithTaxes})}),r.taxExcluded?t("div",{"data-testid":"sub-total-tax-caption-excluded",className:"cart-order-summary__caption",children:d("span",{children:[r.priceExcludingTax," ",m.subtotalWithoutTaxes]})}):void 0]}),N=p&&t(h,{node:p,className:"cart-order-summary__shipping"}),w=g&&g.length>0&&t(rr,{children:g.map(s=>d("div",{className:o(["cart-order-summary__entry","cart-order-summary__discount"]),children:[t("span",{className:"cart-order-summary__label",children:s.label}),t(h,{node:s.price,className:"cart-order-summary__price"}),s.caption&&t(h,{node:s.caption,className:"cart-order-summary__caption"})]},s.label))}),I=C&&C.length>0?t(cr,{"data-testid":"tax-breakdown",className:"cart-order-summary__taxes",iconOpen:lr,iconClose:dr,children:d(nr,{title:m.taxesBreakdownTitle,secondaryText:!B&&e?t(h,{node:e.price,className:"cart-order-summary__price"}):void 0,renderContentWhenClosed:!1,onStateChange:v,children:[t("div",{className:"cart-order-summary__appliedTaxes",children:C.map(s=>d("div",{className:o(["cart-order-summary__entry","cart-order-summary__taxEntry"]),children:[t("span",{className:o(["cart-order-summary__label","cart-order-summary__label--muted"]),children:s.label}),t(h,{node:s.price,className:o(["cart-order-summary__price","cart-order-summary__price--muted"])})]},s.label))}),d("div",{className:o(["cart-order-summary__entry","cart-order-summary__taxTotal"]),children:[t("span",{className:"cart-order-summary__label",children:m.taxTotal}),e&&t(h,{node:e.price,className:"cart-order-summary__price"})]})]})}):e&&d("div",{"data-testid":"tax-total-only",className:o(["cart-order-summary__entry","cart-order-summary__taxTotal"]),children:[t("span",{className:"cart-order-summary__label",children:e.estimated?m.taxEstimated:m.taxTotalOnly}),t(h,{node:e.price,className:"cart-order-summary__price"})]}),k=y&&d("div",{"data-testid":"total-content",className:o(["cart-order-summary__entry","cart-order-summary__total",y.estimated&&"cart-order-summary__total--padded"]),children:[t("span",{className:o(["cart-order-summary__label","cart-order-summary__label--bold"]),children:y.estimated?m.totalEstimated:m.totalLabel}),t(h,{node:y.price,className:o(["cart-order-summary__price","cart-order-summary__price--bold"])})]}),E=y&&y.priceWithoutTax&&d("div",{"data-testid":"total-without-tax",className:o(["cart-order-summary__entry","cart-order-summary__totalWithoutTax"]),children:[t("span",{className:o(["cart-order-summary__label","cart-order-summary__label--muted"]),children:m.totalWithoutTax}),t(h,{node:y.priceWithoutTax,className:o(["cart-order-summary__price","cart-order-summary__price--muted"])})]}),L=a&&t("div",{className:o(["cart-order-summary__entry","cart-order-summary__primaryAction"]),children:a});return d("div",{...c,className:o(["cart-order-summary",["cart-order-summary--loading",A],[`cart-order-summary__${T}`,T],_]),children:[A&&t(ur,{className:"cart-order-summary__spinner"}),d("div",{className:"cart-order-summary__heading",children:[x&&t(h,{node:x,className:"cart-order-summary__heading-text"}),t(mr,{variant:"primary",className:"cart-order-summary__divider-primary"})]}),d("div",{className:"cart-order-summary__content",children:[P,N,w,I,k,E,L]})]})},yr=({children:_,initialData:O=null,routeCheckout:T,slots:x,...A})=>{var v,m,P,N,w,I,k,E,L,s,W,G,z,F,U;const[r,p]=q(O),{handleEstimateTotals:g,estimatedTotals:e,setEstimatedTotals:C,loading:y}=or(),a=(v=tr.config)==null?void 0:v.shoppingCartDisplaySetting;K(()=>{const n=Y.on("cart/data",i=>{var u;p(i);const D=(u=i==null?void 0:i.addresses)==null?void 0:u.shipping,f=i==null?void 0:i.isVirtual;(D||f)&&C(null)},{eager:!0});return()=>{n==null||n.off()}},[]),K(()=>{const n=Y.on("shipping/estimate",i=>{var u,b,S,V,X,j;const D={shippingCountry:(u=i==null?void 0:i.address)==null?void 0:u.countryCode,shippingState:(b=i==null?void 0:i.address)==null?void 0:b.region,shippingStateId:(S=i==null?void 0:i.address)==null?void 0:S.regionId,shippingZip:(V=i==null?void 0:i.address)==null?void 0:V.postCode},f={carrier_code:((X=i==null?void 0:i.shippingMethod)==null?void 0:X.carrierCode)||"",method_code:((j=i==null?void 0:i.shippingMethod)==null?void 0:j.methodCode)||""};g(D,f)});return()=>{n==null||n.off()}},[g]);const c=M({checkout:"Cart.PriceSummary.checkout",orderSummary:"Cart.PriceSummary.orderSummary",taxToBeDetermined:"Cart.PriceSummary.taxToBeDetermined"}),B=!(r!=null&&r.isVirtual)&&(x!=null&&x.EstimateShipping)?t(er,{name:"EstimateShipping",slot:x.EstimateShipping},"estimateShippingId"):void 0;return!Object.keys(r??{}).length||(r==null?void 0:r.totalQuantity)===0?null:t(pr,{...A,"data-testid":"cart-order-summary",heading:t("div",{children:c.orderSummary}),shipping:B,loading:y,subTotal:{taxIncluded:(a==null?void 0:a.subtotal)==="INCLUDING_TAX"&&!(a!=null&&a.zeroTax),taxExcluded:(a==null?void 0:a.subtotal)==="INCLUDING_EXCLUDING_TAX",zeroTaxSubtotal:a==null?void 0:a.zeroTax,priceExcludingTax:(m=e==null?void 0:e.estimatedSubTotal)!=null&&m.excludingTax?t(l,{"data-testid":"subtotal",...(P=e==null?void 0:e.estimatedSubTotal)==null?void 0:P.excludingTax}):t(l,{"data-testid":"subtotal",amount:(N=r==null?void 0:r.subtotal.excludingTax)==null?void 0:N.value,currency:(w=r==null?void 0:r.subtotal.excludingTax)==null?void 0:w.currency}),price:!(a!=null&&a.zeroTax)&&(a==null?void 0:a.subtotal)==="INCLUDING_TAX"||!(a!=null&&a.zeroTax)&&(a==null?void 0:a.subtotal)==="INCLUDING_EXCLUDING_TAX"?(I=e==null?void 0:e.estimatedSubTotal)!=null&&I.includingTax?t(l,{"data-testid":"subtotal",...(k=e==null?void 0:e.estimatedSubTotal)==null?void 0:k.includingTax}):t(l,{"data-testid":"subtotal",amount:(E=r==null?void 0:r.subtotal.includingTax)==null?void 0:E.value,currency:(L=r==null?void 0:r.subtotal.includingTax)==null?void 0:L.currency}):t(l,{"data-testid":"subtotal",amount:(s=r==null?void 0:r.subtotal.excludingTax)==null?void 0:s.value,currency:(W=r==null?void 0:r.subtotal.excludingTax)==null?void 0:W.currency})},discounts:r==null?void 0:r.appliedDiscounts.map(n=>({label:n.label,price:t(l,{"data-testid":"summary-discount-total",amount:-n.amount.value,currency:n.amount.currency,sale:!0})})),taxTotal:r!=null&&r.isVirtual?{price:t("span",{"data-testid":"tax-total",children:c.taxToBeDetermined})}:{price:e!=null&&e.estimatedTaxTotal?t(l,{"data-testid":"tax-total",...e==null?void 0:e.estimatedTaxTotal}):r!=null&&r.totalTax?t(l,{"data-testid":"tax-total",amount:(G=r==null?void 0:r.totalTax)==null?void 0:G.value,currency:(z=r==null?void 0:r.totalTax)==null?void 0:z.currency}):t("span",{"data-testid":"tax-total",children:c.taxToBeDetermined}),estimated:!!(e!=null&&e.estimatedTaxTotal)},taxesApplied:r!=null&&r.isVirtual?void 0:a!=null&&a.fullSummary&&(e!=null&&e.estimatedAppliedTaxes)?(U=(F=e==null?void 0:e.estimatedAppliedTaxes)==null?void 0:F.taxes)==null?void 0:U.map(n=>({label:n.label,price:t(l,{"data-testid":"applied-taxes",amount:n.amount.value,currency:n.amount.currency})})):a!=null&&a.fullSummary?r==null?void 0:r.appliedTaxes.map(n=>({label:n.label,price:t(l,{"data-testid":"applied-taxes",amount:n.amount.value,currency:n.amount.currency})})):void 0,total:{price:e!=null&&e.estimatedGrandTotalPrice?t(l,{...e==null?void 0:e.estimatedGrandTotalPrice.includingTax}):t(l,{amount:r==null?void 0:r.total.includingTax.value,currency:r==null?void 0:r.total.includingTax.currency}),estimated:!!(e!=null&&e.estimatedGrandTotalPrice),priceWithoutTax:a!=null&&a.grandTotal?e!=null&&e.estimatedAppliedTaxes?t(l,{...e==null?void 0:e.estimatedGrandTotalPrice.excludingTax}):t(l,{amount:r==null?void 0:r.total.excludingTax.value,currency:r==null?void 0:r.total.excludingTax.currency}):void 0},primaryAction:T&&t(sr,{"data-testid":"checkout-button",variant:"primary",disabled:r==null?void 0:r.hasOutOfStockItems,"aria-disabled":r==null?void 0:r.hasOutOfStockItems,href:r!=null&&r.hasOutOfStockItems?void 0:T({cartId:r.id}),children:c.checkout})})};yr.getInitialData=async function(){return ar()};export{yr as O};
@@ -0,0 +1,48 @@
1
+ import{s as a}from"./state.js";import{events as p}from"@dropins/tools/event-bus.js";import{f as u,h as l}from"./resetCart.js";const m=e=>{var r,n;return{countryCode:e.country_code||"US",postCode:e.postcode||"",region:((r=e.region)==null?void 0:r.region)||"",regionId:(n=e.region)==null?void 0:n.id}},h=e=>e?{carrierCode:e.carrier_code||"",methodCode:e.method_code||"",amount:e.amount,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}:null,g=`
2
+ query COUNTRIES_QUERY {
3
+ countries {
4
+ label: full_name_locale
5
+ id
6
+ }
7
+ storeConfig {
8
+ defaultCountry: default_country
9
+ }
10
+ }
11
+ `,f=`
12
+ query REGIONS_QUERY($id: String) {
13
+ country(id: $id) {
14
+ available_regions {
15
+ code
16
+ name
17
+ }
18
+ }
19
+ }
20
+ `,y=`
21
+ mutation ESTIMATE_SHIPPING_METHODS_MUTATION(
22
+ $cartId: String!
23
+ $address: EstimateAddressInput!
24
+ ) {
25
+ estimateShippingMethods(
26
+ input: {
27
+ cart_id: $cartId
28
+ address: $address
29
+ }
30
+ ) {
31
+ amount {
32
+ currency
33
+ value
34
+ }
35
+ carrier_code
36
+ method_code
37
+ error_message
38
+ price_excl_tax {
39
+ currency
40
+ value
41
+ }
42
+ price_incl_tax {
43
+ currency
44
+ value
45
+ }
46
+ }
47
+ }
48
+ `,C=async e=>{const r=a.cartId;if(!r)throw new Error("No cart ID found");if(!e)throw new Error("No address parameter found");const{countryCode:n,postcode:i,region:t}=e,c={country_code:n||"US",postcode:i||"",region:{region:(t==null?void 0:t.region)||"",region_id:t==null?void 0:t.id}};return u(y,{variables:{cartId:r,address:c}}).then(({errors:o,data:s})=>{if(o)return l(o);const d=s.estimateShippingMethods.find(_=>!_.error_message)||null;return p.emit("shipping/estimate",{address:m(c),shippingMethod:h(d)}),d})},T=async()=>u(g,{}).then(({errors:e,data:r})=>{var t,c;if(e)return l(e);const n=((t=r==null?void 0:r.countries)==null?void 0:t.sort((o,s)=>o.label.localeCompare(s.label)))||[],i=((c=r==null?void 0:r.storeConfig)==null?void 0:c.defaultCountry)||"US";return n.forEach(o=>{o.isDefaultCountry=o.id===i}),n}),M=async e=>u(f,{variables:{id:e}}).then(({errors:r,data:n})=>{var i;return r?l(r):((i=n==null?void 0:n.country)==null?void 0:i.available_regions)||[]});export{M as a,C as b,T as g};
@@ -1,56 +1,9 @@
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
- mutation ESTIMATE_SHIPPING_METHODS_MUTATION(
3
- $cartId: String!
4
- $address: EstimateAddressInput!
5
- ) {
6
- estimateShippingMethods(
7
- input: {
8
- cart_id: $cartId
9
- address: $address
10
- }
11
- ) {
12
- amount {
13
- currency
14
- value
15
- }
16
- carrier_code
17
- method_code
18
- error_message
19
- price_excl_tax {
20
- currency
21
- value
22
- }
23
- price_incl_tax {
24
- currency
25
- value
26
- }
27
- }
28
- }
29
- `,g=`
30
- query COUNTRIES_QUERY {
31
- countries {
32
- label: full_name_locale
33
- id
34
- }
35
- storeConfig {
36
- defaultCountry: default_country
37
- }
38
- }
39
- `,f=`
40
- query REGIONS_QUERY($id: String) {
41
- country(id: $id) {
42
- available_regions {
43
- code
44
- name
45
- }
46
- }
47
- }
48
- `,N=async r=>{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;return d(I,{variables:{cartId:t,address:{country_code:o||"US",postcode:n||"",region:{region:(e==null?void 0:e.region)||"",region_code:(e==null?void 0:e.code)||"",region_id:(e==null?void 0:e.id)||0}}}}).then(({errors:i,data:s})=>{if(i)return u(i);const c=s.estimateShippingMethods;return c.length===0?null:c.find(a=>!a.error_message)})},M=async()=>d(g,{}).then(({errors:r,data:t})=>{var e,i;if(r)return u(r);const o=((e=t==null?void 0:t.countries)==null?void 0:e.sort((s,c)=>s.label.localeCompare(c.label)))||[],n=((i=t==null?void 0:t.storeConfig)==null?void 0:i.defaultCountry)||"US";return o.forEach(s=>{s.isDefaultCountry=s.id===n}),o}),U=async r=>d(f,{variables:{id:r}}).then(({errors:t,data:o})=>{var n;return t?u(t):((n=o==null?void 0:o.country)==null?void 0:n.available_regions)||[]}),S=`
1
+ import{s as m}from"./state.js";import{C as _,a as T,t as E}from"./CartFragment.js";import"@dropins/tools/event-bus.js";import{f as I,h as u}from"./resetCart.js";const A=`
49
2
  mutation GET_ESTIMATED_TOTALS_MUTATION(
50
3
  $cartId: String!
51
4
  $address: EstimateAddressInput!,
52
5
  $shipping_method: ShippingMethodInput,
53
- ${m}
6
+ ${_}
54
7
 
55
8
  ) {
56
9
  estimateTotals(
@@ -66,4 +19,4 @@ query REGIONS_QUERY($id: String) {
66
19
  }
67
20
  }
68
21
  ${T}
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};
22
+ `,N=async r=>{var e,a;const o=m.cartId;if(!o)throw new Error("No cart ID found");if(!r)throw new Error("No address parameter found");const{countryCode:s,postcode:n,region:t}=r,c=(e=r.shipping_method)==null?void 0:e.carrier_code,p=(a=r.shipping_method)==null?void 0:a.method_code;return I(A,{variables:{cartId:o,address:{country_code:s||"US",postcode:n,region:(t==null?void 0:t.id)!==void 0?{region_id:t.id}:{region:(t==null?void 0:t.region)??""}},shipping_method:{carrier_code:c||"",method_code:p||""}}}).then(({errors:d,data:h})=>{if(d)return u(d);const i=h.estimateTotals;return i?E(i.cart):null})};export{N as g};
@@ -1,4 +1,4 @@
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=`
1
+ import{events as e}from"@dropins/tools/event-bus.js";import{s as a,b as y}from"./state.js";import{C as u,a as l,b as f,t as p}from"./CartFragment.js";import{c as m,f as s,h as o}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:()=>[e.on("authenticated",t=>{a.authenticated&&!t?e.emit("cart/reset",void 0):t&&!a.authenticated&&(a.authenticated=t,c().catch(console.error))},{eager:!0}),e.on("locale",async t=>{t!==a.locale&&(a.locale=t,c().catch(console.error))}),e.on("cart/reset",()=>{m().catch(console.error),e.emit("cart/data",null)}),e.on("cart/data",t=>{y(t)})]}),h=d.config;function T(t){if(!t)return null;const r=i=>{switch(i){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=`
2
2
  query GUEST_CART_QUERY(
3
3
  $cartId: String!,
4
4
  ${u}
@@ -22,7 +22,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
22
22
  }
23
23
 
24
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=`
25
+ `,_=async()=>{const t=a.authenticated,r=a.cartId;if(t)return s(I,{method:"POST"}).then(({errors:i,data:n})=>{if(i)return o(i);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:i,data:n})=>i?o(i):p(n.cart))},E=`
26
26
  mutation MERGE_CARTS_MUTATION(
27
27
  $guestCartId: String!,
28
28
  $customerCartId: String!,
@@ -37,7 +37,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
37
37
  }
38
38
 
39
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=`
40
+ `,c=async()=>{if(a.initializing)return null;a.initializing=!0,a.config||(a.config=await A());const t=a.authenticated?await S():await R();return e.emit("cart/initialized",t),e.emit("cart/data",t),a.initializing=!1,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(i=>{const n={oldCartItems:r.items,newCart:i};return e.emit("cart/merged",n),i}).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=`
41
41
  query STORE_CONFIG_QUERY {
42
42
  storeConfig {
43
43
  minicart_display
@@ -58,4 +58,4 @@ query STORE_CONFIG_QUERY {
58
58
  configurable_thumbnail_source
59
59
  }
60
60
  }
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};
61
+ `,A=async()=>s(G,{method:"GET",cache:"force-cache"}).then(({errors:t,data:r})=>t?o(t):T(r.storeConfig));export{R as a,_ as b,h as c,c as d,A as e,S as g,d as i};