@dropins/storefront-wishlist 3.2.0 → 3.3.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @dropins/storefront-wishlist
2
2
 
3
+ ## 3.3.0-beta.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ebcbb7e: Removed the `engines.node` constraint from `package.json`. This package targets browser environments exclusively and does not depend on a specific Node.js runtime version. The package is now built and distributed using Node.js 22 LTS.
8
+
9
+ ### Patch Changes
10
+
11
+ - ebcbb7e: Replaced PaaS & SaaS instances and some products to fix Cypress tests
12
+
3
13
  ## 3.2.0
4
14
 
5
15
  ### Minor Changes
package/api.js CHANGED
@@ -1,6 +1,121 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{W as m,t as h,b as c}from"./chunks/mergeWishlists.js";import{a as G,c as H,f as F,h as v,g as L,d as U,i as A,e as M,m as N,r as R}from"./chunks/mergeWishlists.js";import{s as a,g as u,f as l,h as I}from"./chunks/fetch-error.js";import{j as O,d as Q,k as y,r as b,a as x,b as C,c as Y,e as B}from"./chunks/fetch-error.js";import{events as _}from"@dropins/tools/event-bus.js";import{r as j}from"./chunks/removeProductsFromWishlist.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const d=`
3
+ import{events as c}from"@dropins/tools/event-bus.js";import{Initializer as C}from"@dropins/tools/lib.js";import{FetchGraphQL as A}from"@dropins/tools/fetch-graphql.js";function b(t){const s=document.cookie.split(";");for(const e of s)if(e.trim().startsWith(`${t}=`))return e.trim().substring(t.length+1);return null}const f={wishlistId:null,authenticated:!1,isLoading:!0},W=()=>f.storeCode&&f.storeCode!=="default"?`DROPIN__WISHLIST__WISHLIST-ID__${f.storeCode}`:"DROPIN__WISHLIST__WISHLIST-ID",o=new Proxy(f,{set(t,s,e){if(t[s]=e,s==="wishlistId"){const i=W();if(e===o.wishlistId)return!0;if(e===null)return document.cookie=`${i}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`,!0;const n=new Date;n.setDate(n.getDate()+30),document.cookie=`${i}=${e}; expires=${n.toUTCString()}; path=/`}return Reflect.set(t,s,e)},get(t,s){return s==="wishlistId"?b(W()):t[s]}});function T(t,s){var n;if(t.product.sku!==s.sku)return!1;const e=((n=t.selectedOptions)==null?void 0:n.map(r=>r.uid).filter(r=>!!r).sort())||[],i=(s.optionUIDs||[]).filter(r=>!!r).sort();return JSON.stringify(e)===JSON.stringify(i)}const E="DROPIN__WISHLIST__WISHLIST__DATA",S=()=>o.storeCode&&o.storeCode!=="default"?`${E}__${o.storeCode}`:E;function v(t){const s=o.authenticated?sessionStorage:localStorage,e=S();if(t)try{s.setItem(e,JSON.stringify(t))}catch(i){$(i)?console.error("Storage quota exceeded:",i):console.error("Error saving wishlist:",i)}else s.removeItem(e)}const $=t=>t instanceof DOMException&&t.name==="QuotaExceededError";function h(t=!1){const s=o.authenticated&&!t?sessionStorage:localStorage,e=S();try{const i=s.getItem(e);return i?JSON.parse(i):{id:"",items:[]}}catch(i){return console.error("Error retrieving wishlist:",i),{id:"",items:[]}}}function G(){localStorage.removeItem(S())}function ut(t,s=[]){var u;const e=o.authenticated?sessionStorage:localStorage,i=S(),n=e.getItem(i),r=n?JSON.parse(n):{items:[]};return(u=r==null?void 0:r.items)==null?void 0:u.find(d=>T(d,{sku:t,optionUIDs:s}))}const D=new C({init:async t=>{const s={isGuestWishlistEnabled:!1,...t};D.config.setConfig(s),o.storeCode=t.storeCode||void 0,O().catch(console.error)},listeners:()=>[c.on("wishlist/data",t=>{v(t)},{eager:!0}),c.on("authenticated",async t=>{if(o.authenticated&&!t&&c.emit("wishlist/reset",void 0),t&&!o.authenticated){o.authenticated=t;const s=await O().catch(console.error);s&&nt(s)}},{eager:!0}),c.on("wishlist/reset",()=>{st().catch(console.error),c.emit("wishlist/data",null)})]}),ct=D.config,{setEndpoint:at,setFetchGraphQlHeader:dt,removeFetchGraphQlHeader:_t,setFetchGraphQlHeaders:It,fetchGraphQl:m,getConfig:ht}=new A().getMethods();function H(t){return t?{wishlistIsEnabled:t.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:t.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:t.storeConfig.maximum_number_of_wishlists}:null}function g(t,s){return t?{id:t.id,updated_at:t.updated_at,sharing_code:t.sharing_code,items_count:t.items_count,items:F(t,s??[])}:null}function F(t,s){var e,i;return(i=(e=t==null?void 0:t.items_v2)==null?void 0:e.items)!=null&&i.length?t.items_v2.items.map(n=>{const r=P(n);return{id:n.id,quantity:n.quantity,description:n.description,added_at:n.added_at,enteredOptions:s,selectedOptions:r,product:{sku:n.product.sku}}}):[]}function P(t){return t.__typename==="ConfigurableWishlistItem"?t.configurable_options?t.configurable_options.map(s=>({uid:s.configurable_product_option_value_uid})):[]:t.__typename==="BundleWishlistItem"?(t.bundle_options??[]).flatMap(e=>e.values??[]).map(e=>({uid:e.uid})):[]}const p=t=>{const s=t.map(e=>e.message).join(" ");throw Error(s)},k=`
4
+ query STORE_CONFIG_QUERY {
5
+ storeConfig {
6
+ magento_wishlist_general_is_enabled
7
+ enable_multiple_wishlists
8
+ maximum_number_of_wishlists
9
+ }
10
+ }
11
+ `,x=async()=>m(k,{method:"GET",cache:"force-cache"}).then(({errors:t,data:s})=>t?p(t):H(s)),q=`
12
+ fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
13
+ type
14
+ customizable_option_uid
15
+ label
16
+ is_required
17
+ values {
18
+ label
19
+ value
20
+ price{
21
+ type
22
+ units
23
+ value
24
+ }
25
+ }
26
+ }
27
+ `,Q=`
28
+ ... on ConfigurableWishlistItem {
29
+ configurable_options {
30
+ option_label
31
+ value_label
32
+ configurable_product_option_value_uid
33
+ configurable_product_option_uid
34
+ }
35
+ configured_variant {
36
+ canonical_url
37
+ }
38
+ }
39
+ `,B=`
40
+ ... on DownloadableWishlistItem {
41
+ added_at
42
+ description
43
+ links_v2 {
44
+ sample_url
45
+ sort_order
46
+ title
47
+ uid
48
+ }
49
+ quantity
50
+ }
51
+ `,z=`
52
+ ... on GiftCardWishlistItem {
53
+ added_at
54
+ description
55
+ gift_card_options {
56
+ amount {
57
+ value
58
+ currency
59
+ }
60
+ custom_giftcard_amount {
61
+ value
62
+ currency
63
+ }
64
+ message
65
+ recipient_email
66
+ recipient_name
67
+ sender_email
68
+ sender_name
69
+ }
70
+ }
71
+ `,Y=`
72
+ ... on BundleWishlistItem {
73
+ bundle_options {
74
+ label
75
+ type
76
+ uid
77
+ values {
78
+ uid
79
+ label
80
+ quantity
81
+ }
82
+ }
83
+ }
84
+ `,M=`
85
+ fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
86
+ __typename
87
+ id
88
+ quantity
89
+ description
90
+ added_at
91
+ product {
92
+ sku
93
+ }
94
+ ${Q}
95
+ ${B}
96
+ ${z}
97
+ ${Y}
98
+ customizable_options {
99
+ ...CUSTOMIZABLE_OPTIONS_FRAGMENT
100
+ }
101
+ }
102
+
103
+ ${q}
104
+ `,w=`
105
+ fragment WISHLIST_FRAGMENT on Wishlist {
106
+ id
107
+ updated_at
108
+ sharing_code
109
+ items_count
110
+ items_v2 {
111
+ items {
112
+ ...WISHLIST_ITEM_FRAGMENT
113
+ }
114
+ }
115
+ }
116
+
117
+ ${M}
118
+ `,J=`
4
119
  query GET_WISHLIST_BY_ID_QUERY(
5
120
  $wishlistId: ID!,
6
121
  ) {
@@ -19,8 +134,52 @@ import{W as m,t as h,b as c}from"./chunks/mergeWishlists.js";import{a as G,c as
19
134
  }
20
135
  }
21
136
 
22
- ${m}
23
- `,w=async r=>{if(!a.authenticated)return u();if(!r)throw Error("Wishlist ID is not set");return l(d,{variables:{wishlistId:r}}).then(({errors:e,data:t})=>{var i;if(e)return I(e);if(!((i=t==null?void 0:t.customer)!=null&&i.wishlist_v2))return null;const s=h(t.customer.wishlist_v2);return _.emit("wishlist/data",s),s})},W=`
137
+ ${M}
138
+ `,mt=async t=>{if(!o.authenticated)return h();if(!t)throw Error("Wishlist ID is not set");return m(J,{variables:{wishlistId:t}}).then(({errors:s,data:e})=>{var n;if(s)return p(s);if(!((n=e==null?void 0:e.customer)!=null&&n.wishlist_v2))return null;const i=g(e.customer.wishlist_v2);return c.emit("wishlist/data",i),i})},Z=`
139
+ query GET_WISHLISTS_QUERY {
140
+ customer {
141
+ wishlists {
142
+ ...WISHLIST_FRAGMENT
143
+ }
144
+ }
145
+ }
146
+
147
+ ${w}
148
+ `,K=async()=>o.authenticated?m(Z).then(({errors:t,data:s})=>{var e;return t?p(t):(e=s==null?void 0:s.customer)!=null&&e.wishlists?s.customer.wishlists.map(i=>g(i)):null}):h(),V=`
149
+ mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
150
+ $wishlistId: ID!,
151
+ $wishlistItems: [WishlistItemInput!]!,
152
+ ) {
153
+ addProductsToWishlist(
154
+ wishlistId: $wishlistId
155
+ wishlistItems: $wishlistItems
156
+ ) {
157
+ wishlist {
158
+ ...WISHLIST_FRAGMENT
159
+ }
160
+ user_errors {
161
+ code
162
+ message
163
+ }
164
+ }
165
+ }
166
+ ${w}
167
+ `,j=async t=>{var i,n,r,u,d;if(!t)return null;const s=h();let e={id:(s==null?void 0:s.id)??"",updated_at:"",sharing_code:"",items_count:0,items:(s==null?void 0:s.items)??[]};for(const l of t){if((i=e.items)==null?void 0:i.some(I=>T(I,{sku:l.sku,optionUIDs:l.optionsUIDs})))continue;const _=l.optionsUIDs?(n=l.optionsUIDs)==null?void 0:n.map(I=>({uid:I})):[];e.items=[...e.items,{id:crypto.randomUUID(),quantity:l.quantity,selectedOptions:_,enteredOptions:l.enteredOptions??[],product:{sku:l.sku}}]}if(e.items_count=(r=e.items)==null?void 0:r.length,c.emit("wishlist/data",e),o.authenticated){if(!o.wishlistId)throw c.emit("wishlist/data",s),Error("Wishlist ID is not set");const l={wishlistId:o.wishlistId,wishlistItems:t.map(({sku:N,quantity:L,optionsUIDs:R,enteredOptions:U})=>({sku:N,quantity:L,selected_options:R,entered_options:U}))},{errors:a,data:_}=await m(V,{variables:l}),I=[...((u=_==null?void 0:_.addProductsToWishlist)==null?void 0:u.user_errors)??[],...a??[]];if(I.length>0)return c.emit("wishlist/data",s),p(I);const y=g(_.addProductsToWishlist.wishlist,((d=t[0])==null?void 0:d.enteredOptions)??[]);c.emit("wishlist/data",y)}return null},X=`
168
+ mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(
169
+ $wishlistId: ID!,
170
+ $wishlistItemsIds: [ID!]!,
171
+ ) {
172
+ removeProductsFromWishlist(
173
+ wishlistId: $wishlistId
174
+ wishlistItemsIds: $wishlistItemsIds
175
+ ) {
176
+ user_errors {
177
+ code
178
+ message
179
+ }
180
+ }
181
+ }
182
+ `,pt=async t=>{var i,n,r;const s=h(),e={...s,items:(i=s.items)==null?void 0:i.filter(u=>!t.some(d=>{var l;return T(u,{sku:d.product.sku,optionUIDs:(l=d.selectedOptions)==null?void 0:l.map(a=>a.uid)})}))};if(o.authenticated){if(!o.wishlistId)throw Error("Wishlist ID is not set");const u=t.map(_=>_.id),{errors:d,data:l}=await m(X,{variables:{wishlistId:o.wishlistId,wishlistItemsIds:u}}),a=[...((n=l==null?void 0:l.removeProductsFromWishlist)==null?void 0:n.user_errors)??[],...d??[]];if(a.length>0)return c.emit("wishlist/data",s),p(a)}return e.items_count=(r=e.items)==null?void 0:r.length,c.emit("wishlist/data",e),null},tt=`
24
183
  mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(
25
184
  $wishlistId: ID!,
26
185
  $wishlistItems: [WishlistItemUpdateInput!]!,
@@ -39,6 +198,6 @@ ${m}
39
198
  }
40
199
  }
41
200
 
42
- ${c}
43
- `,E=async r=>{const e=a.wishlistId;if(!e)throw Error("Wishlist ID is not set");return l(W,{variables:{wishlistId:e,wishlistItems:r.map(({wishlistItemId:t,quantity:s,description:i,selectedOptions:o,enteredOptions:n})=>({wishlistItemId:t,quantity:s,description:i,selected_options:o,entered_options:n}))}}).then(({errors:t,data:s})=>{var o;const i=[...((o=s==null?void 0:s.updateProductsInWishlist)==null?void 0:o.user_errors)??[],...t??[]];return i.length>0?I(i):h(s.updateProductsInWishlist.wishlist)})};export{G as addProductsToWishlist,O as clearPersistedLocalStorage,H as config,l as fetchGraphQl,Q as getConfig,F as getDefaultWishlist,v as getGuestWishlist,u as getPersistedWishlistData,L as getStoreConfig,w as getWishlistById,y as getWishlistItemFromStorage,U as getWishlists,A as initialize,M as initializeWishlist,N as mergeWishlists,b as removeFetchGraphQlHeader,j as removeProductsFromWishlist,R as resetWishlist,x as setEndpoint,C as setFetchGraphQlHeader,Y as setFetchGraphQlHeaders,B as setPersistedWishlistData,E as updateProductsInWishlist};
201
+ ${w}
202
+ `,ft=async t=>{const s=o.wishlistId;if(!s)throw Error("Wishlist ID is not set");return m(tt,{variables:{wishlistId:s,wishlistItems:t.map(({wishlistItemId:e,quantity:i,description:n,selectedOptions:r,enteredOptions:u})=>({wishlistItemId:e,quantity:i,description:n,selected_options:r,entered_options:u}))}}).then(({errors:e,data:i})=>{var r;const n=[...((r=i==null?void 0:i.updateProductsInWishlist)==null?void 0:r.user_errors)??[],...e??[]];return n.length>0?p(n):g(i.updateProductsInWishlist.wishlist)})},st=()=>(o.wishlistId=null,o.authenticated=!1,Promise.resolve(null)),O=async()=>{if(o.initializing)return null;o.initializing=!0,o.config||(o.config=await x());const t=o.authenticated?await et():await it();return c.emit("wishlist/initialized",t),c.emit("wishlist/data",t),o.initializing=!1,t};async function et(){const t=await K(),s=t?t[0]:null;return s?(o.wishlistId=s.id,s):null}async function it(){try{return await h()}catch(t){throw console.error(t),t}}const nt=async t=>{var n;if(!t)return null;const s=h(!0),e=[];if((n=s==null?void 0:s.items)==null||n.forEach(r=>{var l;const u=((l=r.selectedOptions)==null?void 0:l.map(a=>a.uid))||[];if(!t.items.some(a=>T(a,{sku:r.product.sku,optionUIDs:u}))){const a={sku:r.product.sku,quantity:1,optionsUIDs:u,enteredOptions:r.enteredOptions||void 0};e.push(a)}}),e.length===0)return null;const i=await j(e);return G(),i};export{j as addProductsToWishlist,G as clearPersistedLocalStorage,ct as config,m as fetchGraphQl,ht as getConfig,et as getDefaultWishlist,it as getGuestWishlist,h as getPersistedWishlistData,x as getStoreConfig,mt as getWishlistById,ut as getWishlistItemFromStorage,K as getWishlists,T as i,D as initialize,O as initializeWishlist,nt as mergeWishlists,_t as removeFetchGraphQlHeader,pt as removeProductsFromWishlist,st as resetWishlist,o as s,at as setEndpoint,dt as setFetchGraphQlHeader,It as setFetchGraphQlHeaders,v as setPersistedWishlistData,ft as updateProductsInWishlist};
44
203
  //# sourceMappingURL=api.js.map
package/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sources":["/@dropins/storefront-wishlist/src/api/getWishlistById/graphql/getWishlistById.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlistById/getWishlistById.ts","/@dropins/storefront-wishlist/src/api/updateProductsInWishlist/graphql/updateProductsInWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/updateProductsInWishlist/updateProductsInWishlist.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_ITEM_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const GET_WISHLIST_BY_ID_QUERY = `\n query GET_WISHLIST_BY_ID_QUERY(\n $wishlistId: ID!,\n ) {\n customer {\n wishlist_v2(id: $wishlistId) {\n id\n updated_at\n sharing_code\n items_count\n items_v2 {\n items {\n ...WISHLIST_ITEM_FRAGMENT\n }\n }\n }\n }\n }\n\n${WISHLIST_ITEM_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GET_WISHLIST_BY_ID_QUERY } from '@/wishlist/api/getWishlistById/graphql/getWishlistById.graphql';\nimport { Wishlist } from '@/wishlist/data/models';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { state } from '@/wishlist/lib/state';\nimport { fetchGraphQl, getPersistedWishlistData } from '@/wishlist/api';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getWishlistById = async (\n wishlistId: string\n): Promise<void | Wishlist | null> => {\n // When the user is not authenticated, we just have a single wishlist\n // There is no necessity to check any IDs\n if (!state.authenticated) {\n return getPersistedWishlistData();\n }\n\n if (!wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n // @ts-ignore\n return fetchGraphQl(GET_WISHLIST_BY_ID_QUERY, {\n variables: {\n wishlistId,\n },\n }).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n if (!data?.customer?.wishlist_v2) {\n return null;\n }\n\n const payload = transformWishlist(data.customer.wishlist_v2);\n events.emit('wishlist/data', payload);\n return payload;\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_FRAGMENT } from '@/wishlist/api/graphql/WishlistFragment.graphql';\n\nexport const UPDATE_PRODUCTS_IN_WISHLIST_MUTATION = `\n mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItems: [WishlistItemUpdateInput!]!,\n ) {\n updateProductsInWishlist(\n wishlistId: $wishlistId\n wishlistItems: $wishlistItems\n ) {\n wishlist {\n ...WISHLIST_FRAGMENT\n }\n user_errors {\n code\n message\n }\n }\n }\n \n ${WISHLIST_FRAGMENT} \n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist//lib/fetch-error';\n\nimport { UPDATE_PRODUCTS_IN_WISHLIST_MUTATION } from './graphql/updateProductsInWishlistMutation';\nimport { Wishlist } from '@/wishlist/data/models/wishlist';\nimport { transformWishlist } from '@/wishlist/data/transforms';\n\nexport const updateProductsInWishlist = async (\n items: {\n wishlistItemId: string;\n quantity: number;\n description: string;\n selectedOptions?: string[];\n enteredOptions?: { uid: string; value: string }[];\n }[]\n): Promise<Wishlist | null> => {\n const wishlistId = state.wishlistId;\n\n if (!wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n return fetchGraphQl(UPDATE_PRODUCTS_IN_WISHLIST_MUTATION, {\n variables: {\n wishlistId,\n wishlistItems: items.map(\n ({\n wishlistItemId,\n quantity,\n description,\n selectedOptions: selected_options,\n enteredOptions: entered_options,\n }) => ({\n wishlistItemId,\n quantity,\n description,\n selected_options,\n entered_options,\n })\n ),\n },\n }).then(({ errors, data }) => {\n // handle errors\n const _errors = [\n ...(data?.updateProductsInWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n if (_errors.length > 0) return handleFetchError(_errors);\n\n return transformWishlist(data.updateProductsInWishlist.wishlist);\n });\n};\n"],"names":["GET_WISHLIST_BY_ID_QUERY","WISHLIST_ITEM_FRAGMENT","getWishlistById","wishlistId","state","getPersistedWishlistData","fetchGraphQl","errors","data","handleFetchError","_a","payload","transformWishlist","events","UPDATE_PRODUCTS_IN_WISHLIST_MUTATION","WISHLIST_FRAGMENT","updateProductsInWishlist","items","wishlistItemId","quantity","description","selected_options","entered_options","_errors"],"mappings":"+fAmBO,MAAMA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBtCC,CAAsB;AAAA,ECbXC,EAAkB,MAC7BC,GACoC,CAGhC,GAAA,CAACC,EAAM,cACT,OAAOC,EAAyB,EAGlC,GAAI,CAACF,EACH,MAAM,MAAM,wBAAwB,EAItC,OAAOG,EAAaN,EAA0B,CAC5C,UAAW,CACT,WAAAG,CAAA,CAEH,CAAA,EAAE,KAAK,CAAC,CAAE,OAAAI,EAAQ,KAAAC,KAAW,OACxB,GAAAD,EAAe,OAAAE,EAAiBF,CAAM,EAEtC,GAAA,GAACG,EAAAF,GAAA,YAAAA,EAAM,WAAN,MAAAE,EAAgB,aACZ,OAAA,KAGT,MAAMC,EAAUC,EAAkBJ,EAAK,SAAS,WAAW,EACpD,OAAAK,EAAA,KAAK,gBAAiBF,CAAO,EAC7BA,CAAA,CACR,CACH,ECnCaG,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAmB/CC,CAAiB;AAAA,ECbTC,EAA2B,MACtCC,GAO6B,CAC7B,MAAMd,EAAaC,EAAM,WAEzB,GAAI,CAACD,EACH,MAAM,MAAM,wBAAwB,EAGtC,OAAOG,EAAaQ,EAAsC,CACxD,UAAW,CACT,WAAAX,EACA,cAAec,EAAM,IACnB,CAAC,CACC,eAAAC,EACA,SAAAC,EACA,YAAAC,EACA,gBAAiBC,EACjB,eAAgBC,CAAA,KACX,CACL,eAAAJ,EACA,SAAAC,EACA,YAAAC,EACA,iBAAAC,EACA,gBAAAC,CACF,EAAA,CACF,CAEH,CAAA,EAAE,KAAK,CAAC,CAAE,OAAAf,EAAQ,KAAAC,KAAW,OAE5B,MAAMe,EAAU,CACd,KAAIb,EAAAF,GAAA,YAAAA,EAAM,2BAAN,YAAAE,EAAgC,cAAe,CAAC,EACpD,GAAIH,GAAU,CAAA,CAChB,EAEA,OAAIgB,EAAQ,OAAS,EAAUd,EAAiBc,CAAO,EAEhDX,EAAkBJ,EAAK,yBAAyB,QAAQ,CAAA,CAChE,CACH"}
1
+ {"version":3,"file":"api.js","sources":["/@dropins/storefront-wishlist/src/lib/cookies.ts","/@dropins/storefront-wishlist/src/lib/state.ts","/@dropins/storefront-wishlist/src/lib/wishlist-item-comparator.ts","/@dropins/storefront-wishlist/src/lib/persisted-data.ts","/@dropins/storefront-wishlist/src/api/initialize/initialize.ts","/@dropins/storefront-wishlist/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-store-config.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-wishlist.ts","/@dropins/storefront-wishlist/src/lib/fetch-error.ts","/@dropins/storefront-wishlist/src/api/getStoreConfig/graphql/StoreConfigQuery.ts","/@dropins/storefront-wishlist/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-wishlist/src/api/graphql/CustomizableOptionsFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/graphql/WishlistItemFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/graphql/WishlistFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlistById/graphql/getWishlistById.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlistById/getWishlistById.ts","/@dropins/storefront-wishlist/src/api/getWishlists/graphql/getWishlists.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlists/getWishlists.ts","/@dropins/storefront-wishlist/src/api/addProductsToWishlist/graphql/addProductsToWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/addProductsToWishlist/addProductsToWishlist.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/graphql/removeProductsFromWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/removeProductsFromWishlist.ts","/@dropins/storefront-wishlist/src/api/updateProductsInWishlist/graphql/updateProductsInWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/updateProductsInWishlist/updateProductsInWishlist.ts","/@dropins/storefront-wishlist/src/api/resetWishlist/resetWishlist.ts","/@dropins/storefront-wishlist/src/api/initializeWishlist/initializeWishlist.ts","/@dropins/storefront-wishlist/src/api/mergeWishlists/mergeWishlists.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport function getCookie(cookieName: string) {\n // Split the cookie string into an array of individual cookies\n const cookies = document.cookie.split(';');\n\n // Loop through the cookies to find the one with the specified name\n for (const cookie of cookies) {\n // Check if this cookie starts with the name you're looking for\n if (cookie.trim().startsWith(`${cookieName}=`)) {\n // Extract and return the cookie's value\n return cookie.trim().substring(cookieName.length + 1);\n }\n }\n\n // If the cookie is not found, return null\n return null;\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { StoreConfigModel } from '@/wishlist/data/models/store-config';\nimport { getCookie } from '@/wishlist/lib/cookies';\n\ntype State = {\n wishlistId: string | null;\n initializing?: boolean;\n isLoading?: boolean;\n locale?: string;\n config?: StoreConfigModel | null;\n authenticated: boolean;\n storeCode?: string;\n};\n\nconst _state: State = (() => {\n return {\n wishlistId: null,\n authenticated: false,\n isLoading: true,\n };\n})();\n\nconst getWishlistCookieName = (): string =>\n _state.storeCode && _state.storeCode !== 'default'\n ? `DROPIN__WISHLIST__WISHLIST-ID__${_state.storeCode}`\n : 'DROPIN__WISHLIST__WISHLIST-ID';\n\n// Proxy state to allow reactivity\nexport const state = new Proxy(_state, {\n set(target, key, value) {\n // @ts-ignore\n target[key] = value;\n\n if (key === 'wishlistId') {\n const cookieName = getWishlistCookieName();\n\n // only update cookie if value has changed\n if (value === state.wishlistId) return true;\n\n if (value === null) {\n document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;\n return true;\n }\n\n // set expiration date\n const expires = new Date();\n expires.setDate(expires.getDate() + 30);\n document.cookie = `${cookieName}=${value}; expires=${expires.toUTCString()}; path=/`;\n }\n\n return Reflect.set(target, key, value);\n },\n get(target, key) {\n if (key === 'wishlistId') {\n return getCookie(getWishlistCookieName());\n }\n\n return target[key as keyof State];\n },\n});\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Item } from '@/wishlist/data/models/wishlist';\n\ninterface ProductLike {\n sku: string;\n optionUIDs?: string[];\n}\n\n/**\n * Helper function to compare wishlist items by their SKU and selected options\n */\nexport function isMatchingWishlistItem(\n wishlistItem: Item,\n product: ProductLike\n): boolean {\n // Compare SKUs first for early return\n if (wishlistItem.product.sku !== product.sku) {\n return false;\n }\n\n // Compare selected options\n const wishlistItemOptions =\n wishlistItem.selectedOptions\n ?.map((option: any) => option.uid)\n .filter((uid: any) => !!uid)\n .sort() || [];\n const productOptionUIDs = (product.optionUIDs || [])\n .filter((uid: any) => !!uid)\n .sort();\n\n // If options match (or both are empty), items are considered matching\n return (\n JSON.stringify(wishlistItemOptions) === JSON.stringify(productOptionUIDs)\n );\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Wishlist } from '@/wishlist/data/models';\nimport { state } from '@/wishlist/lib/state';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nconst WISHLIST_KEY_BASE = 'DROPIN__WISHLIST__WISHLIST__DATA';\n\nconst getWishlistKey = (): string =>\n state.storeCode && state.storeCode !== 'default'\n ? `${WISHLIST_KEY_BASE}__${state.storeCode}`\n : WISHLIST_KEY_BASE;\n\nexport function setPersistedWishlistData(data: Wishlist | null) {\n const $storage = state.authenticated ? sessionStorage : localStorage;\n const key = getWishlistKey();\n if (data) {\n try {\n $storage.setItem(key, JSON.stringify(data));\n } catch (error) {\n if (isQuotaExceededError(error)) {\n console.error('Storage quota exceeded:', error);\n } else {\n console.error('Error saving wishlist:', error);\n }\n }\n } else {\n $storage.removeItem(key);\n }\n}\n\nconst isQuotaExceededError = (error: unknown) => {\n //https://mmazzarolo.com/blog/2022-06-25-local-storage-status/\n return error instanceof DOMException && error.name === 'QuotaExceededError';\n};\n\nexport function getPersistedWishlistData(\n guest: boolean = false\n): Wishlist | {} {\n const $storage =\n state.authenticated && !guest ? sessionStorage : localStorage;\n const key = getWishlistKey();\n try {\n const wishlist = $storage.getItem(key);\n return wishlist ? JSON.parse(wishlist) : { id: '', items: [] };\n } catch (error) {\n console.error('Error retrieving wishlist:', error);\n return { id: '', items: [] };\n }\n}\n\nexport function clearPersistedLocalStorage() {\n localStorage.removeItem(getWishlistKey());\n}\n\nexport function getWishlistItemFromStorage(\n productSku: string,\n optionUIDs: string[] = []\n) {\n const storage = state.authenticated ? sessionStorage : localStorage;\n const key = getWishlistKey();\n const raw = storage.getItem(key);\n const wishlist = raw ? JSON.parse(raw) : { id: '', items: [] };\n\n return wishlist?.items?.find((item: any) =>\n isMatchingWishlistItem(item, {\n sku: productSku,\n optionUIDs,\n })\n );\n}\n","import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/wishlist/lib/state';\nimport {\n initializeWishlist,\n resetWishlist,\n mergeWishlists,\n} from '@/wishlist/api';\nimport { setPersistedWishlistData } from '@/wishlist/lib/persisted-data';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n isGuestWishlistEnabled?: boolean;\n storeCode?: string;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = { isGuestWishlistEnabled: false, ...config };\n\n initialize.config.setConfig(defaultConfig);\n\n state.storeCode = config.storeCode || undefined;\n\n initializeWishlist().catch(console.error);\n },\n\n listeners: () => [\n events.on(\n 'wishlist/data',\n (payload) => {\n setPersistedWishlistData(payload);\n },\n { eager: true }\n ),\n events.on(\n 'authenticated',\n async (authenticated) => {\n if (state.authenticated && !authenticated) {\n // Reset wishlist if the user is no longer authenticated\n events.emit('wishlist/reset', undefined);\n }\n // Login event occurred\n if (authenticated && !state.authenticated) {\n state.authenticated = authenticated;\n const wishlist = await initializeWishlist().catch(console.error);\n if (wishlist) {\n mergeWishlists(wishlist);\n }\n }\n },\n { eager: true }\n ),\n events.on('wishlist/reset', () => {\n resetWishlist().catch(console.error);\n events.emit('wishlist/data', null);\n }),\n ],\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { StoreConfigModel } from '@/wishlist/data/models';\n\nexport function transformStoreConfig(data: any): StoreConfigModel | null {\n if (!data) return null;\n\n return {\n wishlistIsEnabled: data.storeConfig.magento_wishlist_general_is_enabled,\n wishlistMultipleListIsEnabled: data.storeConfig.enable_multiple_wishlists,\n wishlistMaxNumber: data.storeConfig.maximum_number_of_wishlists,\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { Wishlist, Item, Option } from '@/wishlist/data/models/wishlist';\n\nexport function transformWishlist(\n data: any,\n enteredOptions?: { uid: string; value: string }[]\n): Wishlist | null {\n if (!data) return null;\n\n return {\n id: data.id,\n updated_at: data.updated_at,\n sharing_code: data.sharing_code,\n items_count: data.items_count,\n items: transformItems(data, enteredOptions ?? []),\n };\n}\n\nfunction transformItems(\n data: any,\n enteredOptions: { uid: string; value: string }[]\n): Item[] {\n if (!data?.items_v2?.items?.length) return [];\n\n return data.items_v2.items.map((item: any) => {\n const selectedOptions = getSelectedOptions(item);\n return {\n id: item.id,\n quantity: item.quantity,\n description: item.description,\n added_at: item.added_at,\n enteredOptions,\n selectedOptions,\n product: { sku: item.product.sku },\n };\n });\n}\n\nfunction getSelectedOptions(item: Item): Option[] {\n if (item.__typename === 'ConfigurableWishlistItem') {\n return item.configurable_options\n ? item.configurable_options.map((option: any) => ({\n uid: option.configurable_product_option_value_uid,\n }))\n : [];\n }\n if (item.__typename === 'BundleWishlistItem') {\n const values = (item.bundle_options ?? []).flatMap(\n (option: any) => option.values ?? []\n );\n return values.map((value: any) => ({ uid: value.uid }));\n }\n return [];\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const STORE_CONFIG_QUERY = `\nquery STORE_CONFIG_QUERY {\n storeConfig {\n magento_wishlist_general_is_enabled\n enable_multiple_wishlists\n maximum_number_of_wishlists\n }\n}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/wishlist/api';\nimport { StoreConfigModel } from '@/wishlist/data/models';\nimport { transformStoreConfig } from '@/wishlist/data/transforms';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\n\nimport { STORE_CONFIG_QUERY } from './graphql/StoreConfigQuery';\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel | null> => {\n return fetchGraphQl(STORE_CONFIG_QUERY, {\n method: 'GET',\n cache: 'force-cache',\n }).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n return transformStoreConfig(data);\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const CUSTOMIZABLE_OPTIONS_FRAGMENT = `\n fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {\n type\n customizable_option_uid\n label\n is_required\n values {\n label\n value\n price{\n type\n units\n value\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMIZABLE_OPTIONS_FRAGMENT } from './CustomizableOptionsFragment.graphql';\n\nconst CONFIGURABLE_WISHLIST_ITEM_FRAGMENT = `\n ... on ConfigurableWishlistItem {\n configurable_options {\n option_label\n value_label\n configurable_product_option_value_uid\n configurable_product_option_uid\n }\n configured_variant {\n canonical_url\n }\n }\n`;\n\nconst DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT = `\n ... on DownloadableWishlistItem {\n added_at\n description\n links_v2 {\n sample_url\n sort_order\n title\n uid\n }\n quantity\n }\n`;\n\nconst GIFT_CARD_WISHLIST_ITEM_FRAGMENT = `\n ... on GiftCardWishlistItem {\n added_at\n description\n gift_card_options {\n amount {\n value\n currency\n }\n custom_giftcard_amount {\n value\n currency\n }\n message\n recipient_email\n recipient_name\n sender_email\n sender_name\n }\n }\n`;\n\nconst BUNDLE_WISHLIST_ITEM_FRAGMENT = `\n ... on BundleWishlistItem {\n bundle_options {\n label\n type\n uid\n values {\n uid\n label\n quantity\n }\n }\n }\n`;\n\nexport const WISHLIST_ITEM_FRAGMENT = `\nfragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {\n __typename\n id\n quantity\n description\n added_at\n product {\n sku\n }\n ${CONFIGURABLE_WISHLIST_ITEM_FRAGMENT}\n ${DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT}\n ${GIFT_CARD_WISHLIST_ITEM_FRAGMENT}\n ${BUNDLE_WISHLIST_ITEM_FRAGMENT}\n customizable_options {\n ...CUSTOMIZABLE_OPTIONS_FRAGMENT\n }\n }\n \n ${CUSTOMIZABLE_OPTIONS_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_ITEM_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const WISHLIST_FRAGMENT = `\nfragment WISHLIST_FRAGMENT on Wishlist {\n id\n updated_at\n sharing_code\n items_count\n items_v2 {\n items {\n ...WISHLIST_ITEM_FRAGMENT\n }\n }\n }\n\n${WISHLIST_ITEM_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_ITEM_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const GET_WISHLIST_BY_ID_QUERY = `\n query GET_WISHLIST_BY_ID_QUERY(\n $wishlistId: ID!,\n ) {\n customer {\n wishlist_v2(id: $wishlistId) {\n id\n updated_at\n sharing_code\n items_count\n items_v2 {\n items {\n ...WISHLIST_ITEM_FRAGMENT\n }\n }\n }\n }\n }\n\n${WISHLIST_ITEM_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GET_WISHLIST_BY_ID_QUERY } from '@/wishlist/api/getWishlistById/graphql/getWishlistById.graphql';\nimport { Wishlist } from '@/wishlist/data/models';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { state } from '@/wishlist/lib/state';\nimport { fetchGraphQl, getPersistedWishlistData } from '@/wishlist/api';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getWishlistById = async (\n wishlistId: string\n): Promise<void | Wishlist | null> => {\n // When the user is not authenticated, we just have a single wishlist\n // There is no necessity to check any IDs\n if (!state.authenticated) {\n return getPersistedWishlistData();\n }\n\n if (!wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n // @ts-ignore\n return fetchGraphQl(GET_WISHLIST_BY_ID_QUERY, {\n variables: {\n wishlistId,\n },\n }).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n if (!data?.customer?.wishlist_v2) {\n return null;\n }\n\n const payload = transformWishlist(data.customer.wishlist_v2);\n events.emit('wishlist/data', payload);\n return payload;\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const GET_WISHLISTS_QUERY = `\n query GET_WISHLISTS_QUERY {\n customer {\n wishlists {\n ...WISHLIST_FRAGMENT\n }\n }\n }\n\n ${WISHLIST_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GET_WISHLISTS_QUERY } from '@/wishlist/api/getWishlists/graphql/getWishlists.graphql';\nimport { Wishlist } from '@/wishlist/data/models';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { state } from '@/wishlist/lib/state';\nimport { fetchGraphQl, getPersistedWishlistData } from '@/wishlist/api';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\n\nexport const getWishlists = async (): Promise<void | Wishlist[] | null> => {\n // When the user is not authenticated, we just have a single wishlist\n // There is no necessity to check any IDs\n if (!state.authenticated) {\n return getPersistedWishlistData();\n }\n\n return fetchGraphQl(GET_WISHLISTS_QUERY).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n if (!data?.customer?.wishlists) {\n return null;\n }\n\n return data.customer.wishlists.map((wishlist: any) =>\n transformWishlist(wishlist)\n );\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const ADD_PRODUCTS_TO_WISHLIST_MUTATION = `\n mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItems: [WishlistItemInput!]!,\n ) {\n addProductsToWishlist(\n wishlistId: $wishlistId\n wishlistItems: $wishlistItems\n ) {\n wishlist {\n ...WISHLIST_FRAGMENT\n }\n user_errors {\n code\n message\n }\n }\n }\n${WISHLIST_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl, getPersistedWishlistData } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { ADD_PRODUCTS_TO_WISHLIST_MUTATION } from './graphql/addProductsToWishlistMutation';\nimport { Wishlist } from '@/wishlist/data/models/wishlist';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { events } from '@adobe-commerce/event-bus';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const addProductsToWishlist = async (\n items: [\n {\n sku: string;\n quantity: number;\n optionsUIDs?: string[]; // should be the options available for the product\n enteredOptions?: { uid: string; value: string }[]; // refer to both selected and entered options\n }\n ]\n): Promise<Wishlist | null> => {\n if (!items) return null;\n\n const wishlist = getPersistedWishlistData();\n let updatedWishlist = {\n id: wishlist?.id ?? '',\n updated_at: '',\n sharing_code: '',\n items_count: 0,\n items: wishlist?.items ?? [],\n };\n\n for (const item of items) {\n const skuExists = updatedWishlist.items?.some((wishlistItem: any) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.sku,\n optionUIDs: item.optionsUIDs,\n })\n );\n\n if (skuExists) {\n continue;\n }\n\n const selectedOptions: { uid: string }[] = item.optionsUIDs\n ? item.optionsUIDs?.map((option: any) => ({\n uid: option,\n }))\n : [];\n\n updatedWishlist.items = [\n ...updatedWishlist.items,\n {\n id: crypto.randomUUID(),\n quantity: item.quantity,\n selectedOptions,\n enteredOptions: item.enteredOptions ?? [],\n product: { sku: item.sku },\n },\n ];\n }\n\n updatedWishlist.items_count = updatedWishlist.items?.length;\n events.emit('wishlist/data', updatedWishlist);\n\n if (state.authenticated) {\n if (!state.wishlistId) {\n events.emit('wishlist/data', wishlist);\n throw Error('Wishlist ID is not set');\n }\n\n const variables = {\n wishlistId: state.wishlistId,\n wishlistItems: items.map(\n ({ sku, quantity, optionsUIDs, enteredOptions }) => ({\n sku,\n quantity,\n selected_options: optionsUIDs,\n entered_options: enteredOptions,\n })\n ),\n };\n\n const { errors, data }: { errors: any; data: any } = await fetchGraphQl(\n ADD_PRODUCTS_TO_WISHLIST_MUTATION,\n { variables }\n );\n\n const _errors = [\n ...(data?.addProductsToWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n // if saving item to wishlist for logged user failed, we need to restore original wishlist in storage:\n if (_errors.length > 0) {\n events.emit('wishlist/data', wishlist);\n return handleFetchError(_errors);\n }\n\n const updatedWishlist = transformWishlist(\n data.addProductsToWishlist.wishlist,\n items[0]?.enteredOptions ?? []\n );\n events.emit('wishlist/data', updatedWishlist);\n }\n\n return null;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION = `\n mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItemsIds: [ID!]!,\n ) {\n removeProductsFromWishlist(\n wishlistId: $wishlistId\n wishlistItemsIds: $wishlistItemsIds\n ) {\n user_errors {\n code\n message\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION } from './graphql/removeProductsFromWishlistMutation';\nimport { Item, Wishlist } from '@/wishlist/data/models/wishlist';\nimport { events } from '@adobe-commerce/event-bus';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const removeProductsFromWishlist = async (\n items: Array<Item>\n): Promise<Wishlist | null> => {\n const wishlist = getPersistedWishlistData();\n const updatedWishlist = {\n ...wishlist,\n items: wishlist.items?.filter((wishlistItem: any) => {\n return !items.some((item) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.product.sku,\n optionUIDs: item.selectedOptions?.map((option: any) => option.uid),\n })\n );\n }),\n };\n\n if (state.authenticated) {\n if (!state.wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n const itemIds = items.map((item) => item.id);\n const { errors, data } = await fetchGraphQl(\n REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION,\n {\n variables: { wishlistId: state.wishlistId, wishlistItemsIds: itemIds },\n }\n );\n\n const _errors = [\n ...(data?.removeProductsFromWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n // restore wishlist if removing item failed:\n if (_errors.length > 0) {\n events.emit('wishlist/data', wishlist);\n return handleFetchError(_errors);\n }\n }\n\n updatedWishlist.items_count = updatedWishlist.items?.length;\n events.emit('wishlist/data', updatedWishlist);\n\n return null;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_FRAGMENT } from '@/wishlist/api/graphql/WishlistFragment.graphql';\n\nexport const UPDATE_PRODUCTS_IN_WISHLIST_MUTATION = `\n mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItems: [WishlistItemUpdateInput!]!,\n ) {\n updateProductsInWishlist(\n wishlistId: $wishlistId\n wishlistItems: $wishlistItems\n ) {\n wishlist {\n ...WISHLIST_FRAGMENT\n }\n user_errors {\n code\n message\n }\n }\n }\n \n ${WISHLIST_FRAGMENT} \n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist//lib/fetch-error';\n\nimport { UPDATE_PRODUCTS_IN_WISHLIST_MUTATION } from './graphql/updateProductsInWishlistMutation';\nimport { Wishlist } from '@/wishlist/data/models/wishlist';\nimport { transformWishlist } from '@/wishlist/data/transforms';\n\nexport const updateProductsInWishlist = async (\n items: {\n wishlistItemId: string;\n quantity: number;\n description: string;\n selectedOptions?: string[];\n enteredOptions?: { uid: string; value: string }[];\n }[]\n): Promise<Wishlist | null> => {\n const wishlistId = state.wishlistId;\n\n if (!wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n return fetchGraphQl(UPDATE_PRODUCTS_IN_WISHLIST_MUTATION, {\n variables: {\n wishlistId,\n wishlistItems: items.map(\n ({\n wishlistItemId,\n quantity,\n description,\n selectedOptions: selected_options,\n enteredOptions: entered_options,\n }) => ({\n wishlistItemId,\n quantity,\n description,\n selected_options,\n entered_options,\n })\n ),\n },\n }).then(({ errors, data }) => {\n // handle errors\n const _errors = [\n ...(data?.updateProductsInWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n if (_errors.length > 0) return handleFetchError(_errors);\n\n return transformWishlist(data.updateProductsInWishlist.wishlist);\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/wishlist/lib/state';\nimport { Wishlist } from '@/wishlist/data/models';\n\nexport const resetWishlist = (): Promise<Wishlist | null> => {\n state.wishlistId = null;\n state.authenticated = false;\n\n return Promise.resolve(null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/wishlist/lib/state';\nimport { getStoreConfig, getWishlists } from '@/wishlist/api';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { Wishlist } from '@/wishlist/data/models';\n\nexport const initializeWishlist = async (): Promise<Wishlist | null> => {\n if (state.initializing) return null;\n\n state.initializing = true;\n\n // set config\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const payload = state.authenticated\n ? await getDefaultWishlist()\n : await getGuestWishlist();\n\n events.emit('wishlist/initialized', payload);\n events.emit('wishlist/data', payload);\n\n state.initializing = false;\n\n return payload;\n};\n\nexport async function getDefaultWishlist() {\n const wishlists = await getWishlists();\n const wishlist = wishlists ? wishlists[0] : null;\n if (!wishlist) return null;\n\n state.wishlistId = wishlist.id;\n\n return wishlist;\n}\n\nexport async function getGuestWishlist() {\n try {\n return await getPersistedWishlistData();\n } catch (error) {\n console.error(error);\n throw error;\n }\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Wishlist, Item } from '@/wishlist/data/models';\nimport { addProductsToWishlist } from '@/wishlist/api';\nimport {\n getPersistedWishlistData,\n clearPersistedLocalStorage,\n} from '@/wishlist/lib/persisted-data';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const mergeWishlists = async (\n wishlist: Wishlist\n): Promise<Wishlist | null> => {\n if (!wishlist) {\n return null;\n }\n\n const guestWishlist: {\n id?: string;\n items?: Item[];\n } = getPersistedWishlistData(true);\n const itemsToMerge: any[] = [];\n\n guestWishlist?.items?.forEach((item: any) => {\n const optionUIDs =\n item.selectedOptions?.map((option: any) => option.uid) || [];\n\n const exists = wishlist.items.some((wishlistItem: any) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.product.sku,\n optionUIDs,\n })\n );\n\n if (!exists) {\n const mergeItem = {\n sku: item.product.sku,\n quantity: 1,\n optionsUIDs: optionUIDs,\n enteredOptions: item.enteredOptions || undefined,\n };\n\n itemsToMerge.push(mergeItem);\n }\n });\n\n if (itemsToMerge.length === 0) {\n return null;\n }\n\n const result = await addProductsToWishlist(itemsToMerge);\n clearPersistedLocalStorage();\n return result;\n};\n"],"names":["getCookie","cookieName","cookies","cookie","_state","getWishlistCookieName","state","target","key","value","expires","isMatchingWishlistItem","wishlistItem","product","wishlistItemOptions","_a","option","uid","productOptionUIDs","WISHLIST_KEY_BASE","getWishlistKey","setPersistedWishlistData","data","$storage","error","isQuotaExceededError","getPersistedWishlistData","guest","wishlist","clearPersistedLocalStorage","getWishlistItemFromStorage","productSku","optionUIDs","storage","raw","item","initialize","Initializer","config","defaultConfig","initializeWishlist","events","payload","authenticated","mergeWishlists","resetWishlist","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","transformStoreConfig","transformWishlist","enteredOptions","transformItems","_b","selectedOptions","getSelectedOptions","handleFetchError","errors","errorMessage","STORE_CONFIG_QUERY","getStoreConfig","CUSTOMIZABLE_OPTIONS_FRAGMENT","CONFIGURABLE_WISHLIST_ITEM_FRAGMENT","DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT","GIFT_CARD_WISHLIST_ITEM_FRAGMENT","BUNDLE_WISHLIST_ITEM_FRAGMENT","WISHLIST_ITEM_FRAGMENT","WISHLIST_FRAGMENT","GET_WISHLIST_BY_ID_QUERY","getWishlistById","wishlistId","GET_WISHLISTS_QUERY","getWishlists","ADD_PRODUCTS_TO_WISHLIST_MUTATION","addProductsToWishlist","items","updatedWishlist","_c","variables","sku","quantity","optionsUIDs","_errors","_d","_e","REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION","removeProductsFromWishlist","itemIds","UPDATE_PRODUCTS_IN_WISHLIST_MUTATION","updateProductsInWishlist","wishlistItemId","description","selected_options","entered_options","getDefaultWishlist","getGuestWishlist","wishlists","guestWishlist","itemsToMerge","mergeItem","result"],"mappings":"wKAiBO,SAASA,EAAUC,EAAoB,CAE5C,MAAMC,EAAU,SAAS,OAAO,MAAM,GAAG,EAGzC,UAAWC,KAAUD,EAEnB,GAAIC,EAAO,OAAO,WAAW,GAAGF,CAAU,GAAG,EAE3C,OAAOE,EAAO,KAAK,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BA,EAAO,OAAQ,CAAC,EAS7D,GAAI,CAPWY,EAAS,MAAM,KAAMhB,GAClCD,EAAuBC,EAAc,CACnC,IAAKuB,EAAK,QAAQ,IAClB,WAAAH,CACD,CAAA,CACH,EAEa,CACX,MAAMuE,EAAY,CAChB,IAAKpE,EAAK,QAAQ,IAClB,SAAU,EACV,YAAaH,EACb,eAAgBG,EAAK,gBAAkB,MACzC,EAEAmE,EAAa,KAAKC,CAAS,CAAA,CAC7B,GAGED,EAAa,SAAW,EACnB,OAAA,KAGH,MAAAE,EAAS,MAAM1B,EAAsBwB,CAAY,EAC5B,OAAAzE,EAAA,EACpB2E,CACT"}
@@ -1,18 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as i,jsxs as a,Fragment as F}from"@dropins/tools/preact-jsx-runtime.js";import{useState as f,useCallback as A,useEffect as B,useMemo as E,Fragment as R}from"@dropins/tools/preact-compat.js";import{classes as I,Slot as V,VComponent as Y}from"@dropins/tools/lib.js";import{IllustratedMessage as q,Button as G,Icon as J,SkeletonRow as K,Skeleton as O}from"@dropins/tools/components.js";import{W as Q}from"../chunks/WishlistItem.js";import{events as H}from"@dropins/tools/event-bus.js";import{s as $}from"../chunks/fetch-error.js";import{useText as z,Text as j}from"@dropins/tools/i18n.js";import{W as U}from"../chunks/WishlistAlert.js";import{S as X}from"../chunks/Heart.js";import"../chunks/Trash.js";import"../chunks/removeProductsFromWishlist.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/HeartFilled.js";const Z=({className:r,children:t,ctaLinkURL:e,...m})=>{const h=z({emptyWishlist:"Wishlist.EmptyWishlist.heading",message:"Wishlist.EmptyWishlist.message",cta:"Wishlist.EmptyWishlist.cta"});return i("div",{...m,className:I(["wishlist-empty-wishlist",r]),children:i(q,{className:I(["wishlist-empty-wishlist__wrapper",r]),"data-testid":"wishlist-empty-wishlist",heading:h.emptyWishlist,icon:i(J,{className:"wishlist-empty-wishlist__icon",source:X}),message:i("p",{children:h.message}),action:e?i(G,{"data-testid":"wishlist-empty-wishlist-button",size:"medium",variant:"primary",type:"submit",href:e,children:h.cta},"routeHome"):void 0})})},b=()=>i(K,{children:`
4
- <svg
5
- width="100%"
6
- height="100%"
7
- viewBox="0 0 288 658"
8
- fill="none"
9
- xmlns="http://www.w3.org/2000/svg"
10
- preserveAspectRatio="xMinYMin meet"
11
- >
12
- <rect x="6" y="24" width="282px" height="480" rx="8" fill="#E8E8E8" />
13
- <rect x="6" y="522" width="280" height="22" rx="4" fill="#E8E8E8" />
14
- <rect x="6" y="556" width="132" height="22" rx="4" fill="#E8E8E8" />
15
- <rect x="6" y="592" width="280" height="48" rx="24" fill="#D9D9D9" />
16
- </svg>
17
- `}),C=()=>a(O,{"data-testid":"wishlist-loader",children:[i(b,{}),i(b,{}),i(b,{})]}),gi=({routeEmptyWishlistCTA:r,routeToWishlist:t,moveProdToCart:e,routeProdDetailPage:m,getProductData:h,getRefinedProduct:_,slots:W,...x})=>{const[g,S]=f(null),[y,n]=f($.authenticated),[k,p]=f($.isLoading),v=l=>n(l),[w,c]=f(null),N=A(l=>{const{action:d,item:o}=l;c(i(U,{action:d,item:o,routeToWishlist:t}))},[t]);return B(()=>{const l=H.on("authenticated",v),d=H.on("wishlist/alert",s=>N(s)),o=H.on("wishlist/data",s=>{S(s),p(!1)},{eager:!0});return()=>{l==null||l.off(),o==null||o.off(),d==null||d.off()}},[N]),i(T,{...x,wishlistData:g,wishlistAlert:w,routeEmptyWishlistCTA:r,moveProdToCart:e,getProductData:h,getRefinedProduct:_,isLoggedIn:y,isLoading:k,routeProdDetailPage:m,slots:W})},T=({className:r,wishlistData:t,wishlistAlert:e,isLoggedIn:m,isLoading:h,moveProdToCart:_,getProductData:W,getRefinedProduct:x,routeEmptyWishlistCTA:g,onLoginClick:S,routeProdDetailPage:y,slots:n,...k})=>{const[p,v]=f(e),w=z({wishlistHeading:"Wishlist.Wishlist.heading",wishlistLoadingHeading:"Wishlist.Wishlist.loading"}),c=E(()=>{var s;return((s=t==null?void 0:t.items)==null?void 0:s.length)>0?t.items.map(u=>i(Q,{item:u,getProductData:W,getRefinedProduct:x,moveProdToCart:_,routeProdDetailPage:y,imageNode:n!=null&&n.image?({defaultImageProps:L})=>i(V,{name:"image",slot:n.image,context:{defaultImageProps:L,item:u}}):void 0},u.id)):null},[t,_,W,x,y,n==null?void 0:n.image]);B(()=>{if(e){v(e);const s=setTimeout(()=>{v(null)},5e3);return()=>clearTimeout(s)}},[e]);const N=E(()=>p?i(Y,{node:p,className:"wishlist-wishlist__alert"}):null,[p]),l=()=>a(F,{children:[i("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:i("h1",{className:"wishlist-wishlist__heading-text","data-testid":"loader-wishlist-heading",children:w.wishlistLoadingHeading})}),i(C,{})]}),d=()=>c?a(F,{children:[o,i("div",{className:"wishlist-wishlist__content",children:c})]}):i("div",{className:I(["wishlist-wishlist__content","wishlist-wishlist__content--empty"]),children:a("div",{children:[i(Z,{"data-testid":"empty-wishlist",ctaLinkURL:g==null?void 0:g()}),!m&&i(P,{onLoginClick:S})]})}),o=E(()=>{var s;return c?i("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:i("h1",{className:"wishlist-wishlist__heading-text","data-testid":"default-wishlist-heading",children:(s=w.wishlistHeading)==null?void 0:s.split(" {count}").map((u,L)=>{var M;return a(R,{children:[u,L===0&&i("span",{className:"wishlist-wishlist__heading-count","data-testid":"wishlist-heading-count",children:`${t==null?void 0:t.items_count} products`})]},((M=t==null?void 0:t.id)==null?void 0:M.toString())+L)})})}):null},[w,c,t]);return a("div",{...k,className:I(["wishlist-wishlist",r]),children:[N,h?l():d()]})},P=({onLoginClick:r})=>a("div",{className:"wishlist-login__sign-in",children:[i("a",{"data-testid":"log-in-link",className:"wishlist-login__link",href:"",rel:"noreferrer",onClick:r,role:"button",children:i(j,{id:"Wishlist.Login.logIn"})}),i(j,{id:"Wishlist.Login.sync"})]});export{gi as Wishlist,gi as default};
3
+ import{a as l,a as d}from"./WishlistToggle.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../api.js";import"@dropins/tools/fetch-graphql.js";export{l as Wishlist,d as default};
18
4
  //# sourceMappingURL=Wishlist.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Wishlist.js","sources":["/@dropins/storefront-wishlist/src/components/EmptyWishlist/EmptyWishlist.tsx","/@dropins/storefront-wishlist/src/components/Wishlist/WishlistItemSkeleton.tsx","/@dropins/storefront-wishlist/src/components/Wishlist/WishlistSkeleton.tsx","/@dropins/storefront-wishlist/src/containers/Wishlist/Wishlist.tsx","/@dropins/storefront-wishlist/src/components/Wishlist/Wishlist.tsx","/@dropins/storefront-wishlist/src/components/Login/Login.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Button, Icon, IllustratedMessage } from '@adobe-commerce/elsie/components';\nimport { Heart } from '@adobe-commerce/elsie/icons';\n\nimport '@/wishlist/components/EmptyWishlist/EmptyWishlist.css';\n\nexport interface EmptyWishlistProps extends HTMLAttributes<HTMLDivElement> {\n ctaLinkURL?: string;\n}\n\nexport const EmptyWishlist: FunctionComponent<EmptyWishlistProps> = ({\n className,\n children,\n ctaLinkURL,\n ...props\n}) => {\n const labels = useText({\n emptyWishlist: 'Wishlist.EmptyWishlist.heading',\n message: 'Wishlist.EmptyWishlist.message',\n cta: 'Wishlist.EmptyWishlist.cta',\n });\n\n return (\n <div {...props} className={classes(['wishlist-empty-wishlist', className])}>\n <IllustratedMessage\n className={classes(['wishlist-empty-wishlist__wrapper', className])}\n data-testid=\"wishlist-empty-wishlist\"\n heading={labels.emptyWishlist}\n icon={<Icon className=\"wishlist-empty-wishlist__icon\" source={Heart} />}\n message={<p>{labels.message}</p>}\n action={\n ctaLinkURL ? (\n <Button\n data-testid=\"wishlist-empty-wishlist-button\"\n size=\"medium\"\n variant=\"primary\"\n key=\"routeHome\"\n type=\"submit\"\n href={ctaLinkURL}\n >\n {labels.cta}\n </Button>\n ) : undefined\n }\n />\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const WishlistItemSkeleton: FunctionComponent = () => {\n return (\n <SkeletonRow>{`\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=\"0 0 288 658\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n preserveAspectRatio=\"xMinYMin meet\"\n >\n <rect x=\"6\" y=\"24\" width=\"282px\" height=\"480\" rx=\"8\" fill=\"#E8E8E8\" />\n <rect x=\"6\" y=\"522\" width=\"280\" height=\"22\" rx=\"4\" fill=\"#E8E8E8\" />\n <rect x=\"6\" y=\"556\" width=\"132\" height=\"22\" rx=\"4\" fill=\"#E8E8E8\" />\n <rect x=\"6\" y=\"592\" width=\"280\" height=\"48\" rx=\"24\" fill=\"#D9D9D9\" />\n </svg>\n `}</SkeletonRow>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\nimport { WishlistItemSkeleton } from '@/wishlist/components/Wishlist/WishlistItemSkeleton';\n\nexport const WishlistSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"wishlist-loader\">\n <WishlistItemSkeleton />\n <WishlistItemSkeleton />\n <WishlistItemSkeleton />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { Wishlist as WishlistComponent } from '@/wishlist/components';\nimport { events, WishlistActionPayload } from '@adobe-commerce/event-bus';\nimport {\n Item,\n Product,\n Wishlist as WishlistModel,\n} from '@/wishlist/data/models';\nimport { state } from '@/wishlist/lib/state';\nimport { WishlistAlert } from '@/wishlist/containers/WishlistAlert';\nimport { ImageProps } from '@adobe-commerce/elsie/components';\n\nexport interface WishlistProps extends HTMLAttributes<HTMLDivElement> {\n routeEmptyWishlistCTA?: () => string;\n routeToWishlist?: string;\n moveProdToCart: (\n products: { sku: string; quantity: number }[]\n ) => Promise<any>;\n routeProdDetailPage: (product: Product) => string;\n getProductData?: (sku: string) => Promise<Product | null>;\n getRefinedProduct?: (\n sku: string,\n optionUIDs: string[],\n anchorOptions?: string[],\n raw?: boolean\n ) => Promise<Product | null>;\n slots?: {\n image?: SlotProps<{\n defaultImageProps: ImageProps;\n item: Item;\n }>;\n };\n}\n\nexport const Wishlist: Container<WishlistProps> = ({\n routeEmptyWishlistCTA,\n routeToWishlist,\n moveProdToCart,\n routeProdDetailPage,\n getProductData,\n getRefinedProduct,\n slots,\n ...props\n}: WishlistProps) => {\n const [wishlistData, setWishlistData] = useState<WishlistModel | null>(null);\n const [isLoggedIn, setIsLoggedIn] = useState(state.authenticated);\n const [isLoading, setIsLoading] = useState(state.isLoading);\n\n const handleAuthentication = (authenticated: boolean) =>\n setIsLoggedIn(authenticated);\n\n const [wishlistAlert, setWishlistAlert] = useState<Element | null>(null);\n const handleWishlistAlert = useCallback(\n (payload: WishlistActionPayload) => {\n const { action, item } = payload;\n setWishlistAlert(\n <WishlistAlert\n action={action}\n item={item}\n routeToWishlist={routeToWishlist}\n />\n );\n },\n [routeToWishlist]\n );\n\n useEffect(() => {\n const authEvent = events.on('authenticated', handleAuthentication);\n const updateEvent = events.on('wishlist/alert', (payload) =>\n handleWishlistAlert(payload)\n );\n const dataEvent = events.on(\n 'wishlist/data',\n (payload) => {\n setWishlistData(payload as WishlistModel);\n setIsLoading(false);\n },\n { eager: true }\n );\n return () => {\n authEvent?.off();\n dataEvent?.off();\n updateEvent?.off();\n };\n }, [handleWishlistAlert]);\n\n return (\n <WishlistComponent\n {...props}\n wishlistData={wishlistData}\n wishlistAlert={wishlistAlert}\n routeEmptyWishlistCTA={routeEmptyWishlistCTA}\n moveProdToCart={moveProdToCart}\n getProductData={getProductData}\n getRefinedProduct={getRefinedProduct}\n isLoggedIn={isLoggedIn}\n isLoading={isLoading}\n routeProdDetailPage={routeProdDetailPage}\n slots={slots}\n />\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes, useState, useEffect, useMemo } from 'preact/compat';\nimport {\n VComponent,\n classes,\n Slot,\n SlotProps,\n} from '@adobe-commerce/elsie/lib';\nimport { WishlistSkeleton } from '@/wishlist/components/Wishlist/WishlistSkeleton';\nimport '@/wishlist/components/Wishlist/Wishlist.css';\nimport {\n Product,\n Wishlist as WishlistModel,\n Item,\n} from '@/wishlist/data/models';\nimport { WishlistItem, WishlistAlert } from '@/wishlist/containers';\nimport { Fragment } from 'react';\nimport { EmptyWishlist, Login } from '@/wishlist/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { ImageProps } from '@adobe-commerce/elsie/components';\n\nexport interface WishlistProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n wishlistData: WishlistModel;\n wishlistAlert: WishlistAlert | null;\n isLoggedIn: boolean;\n isLoading: boolean;\n moveProdToCart: (\n products: { sku: string; quantity: number }[]\n ) => Promise<any>;\n getProductData?: (sku: string) => Promise<Product | null>;\n getRefinedProduct?: (\n sku: string,\n optionUIDs: string[],\n anchorOptions?: string[],\n raw?: boolean\n ) => Promise<Product | null>;\n routeEmptyWishlistCTA?: () => string;\n onLoginClick?: () => void;\n routeProdDetailPage: (product: Product) => string;\n slots?: {\n image?: SlotProps<{\n defaultImageProps: ImageProps;\n item: Item;\n }>;\n };\n}\n\nexport const Wishlist: FunctionComponent<WishlistProps> = ({\n className,\n wishlistData,\n wishlistAlert,\n isLoggedIn,\n isLoading,\n moveProdToCart,\n getProductData,\n getRefinedProduct,\n routeEmptyWishlistCTA,\n onLoginClick,\n routeProdDetailPage,\n slots,\n ...props\n}) => {\n const [alert, setAlert] = useState<VNode | null>(wishlistAlert);\n\n const dictionary = useText({\n wishlistHeading: 'Wishlist.Wishlist.heading',\n wishlistLoadingHeading: 'Wishlist.Wishlist.loading',\n });\n\n const products = useMemo(() => {\n return wishlistData?.items?.length > 0\n ? wishlistData.items.map((item: Item) => (\n <WishlistItem\n key={item.id}\n item={item}\n getProductData={getProductData}\n getRefinedProduct={getRefinedProduct}\n moveProdToCart={moveProdToCart}\n routeProdDetailPage={routeProdDetailPage}\n imageNode={\n slots?.image\n ? ({ defaultImageProps }) => (\n <Slot\n name=\"image\"\n slot={slots.image}\n context={{\n defaultImageProps,\n item,\n }}\n />\n )\n : undefined\n }\n />\n ))\n : null;\n }, [wishlistData, moveProdToCart, getProductData, getRefinedProduct, routeProdDetailPage, slots?.image]);\n\n useEffect(() => {\n if (wishlistAlert) {\n setAlert(wishlistAlert);\n\n const timer = setTimeout(() => {\n setAlert(null);\n }, 5000);\n\n return () => clearTimeout(timer);\n }\n }, [wishlistAlert]);\n\n const renderAlert = useMemo(\n () =>\n alert ? (\n <VComponent node={alert} className=\"wishlist-wishlist__alert\" />\n ) : null,\n [alert]\n );\n\n const renderLoader = () => {\n return (\n <>\n <div\n className=\"wishlist-wishlist__heading\"\n data-testid=\"wishlist-heading-wrapper\"\n >\n <h1\n className=\"wishlist-wishlist__heading-text\"\n data-testid=\"loader-wishlist-heading\"\n >\n {dictionary.wishlistLoadingHeading}\n </h1>\n </div>\n <WishlistSkeleton />\n </>\n );\n };\n\n const renderWishlist = () => {\n return products ? (\n <>\n {renderHeading}\n <div className=\"wishlist-wishlist__content\">{products}</div>\n </>\n ) : (\n <div\n className={classes([\n 'wishlist-wishlist__content',\n 'wishlist-wishlist__content--empty',\n ])}\n >\n <div>\n <EmptyWishlist\n data-testid=\"empty-wishlist\"\n ctaLinkURL={routeEmptyWishlistCTA?.()}\n />\n {!isLoggedIn && <Login onLoginClick={onLoginClick} />}\n </div>\n </div>\n );\n };\n\n const renderHeading = useMemo(() => {\n if (!products) return null;\n\n return (\n <div\n className=\"wishlist-wishlist__heading\"\n data-testid=\"wishlist-heading-wrapper\"\n >\n <h1\n className=\"wishlist-wishlist__heading-text\"\n data-testid=\"default-wishlist-heading\"\n >\n {dictionary.wishlistHeading\n ?.split(' {count}')\n .map((title: string, index: number) => (\n <Fragment key={wishlistData?.id?.toString() + index}>\n {title}\n {index === 0 && (\n <span\n className=\"wishlist-wishlist__heading-count\"\n data-testid=\"wishlist-heading-count\"\n >\n {`${wishlistData?.items_count} products`}\n </span>\n )}\n </Fragment>\n ))}\n </h1>\n </div>\n );\n }, [dictionary, products, wishlistData]);\n\n return (\n <div {...props} className={classes(['wishlist-wishlist', className])}>\n {renderAlert}\n {isLoading ? renderLoader() : renderWishlist()}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Text } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\nimport '@/wishlist/components/Login/Login.css';\n\nexport interface LoginProps {\n onLoginClick?: () => void;\n}\n\nexport const Login: FunctionComponent<LoginProps> = ({ onLoginClick }) => {\n return (\n <div className=\"wishlist-login__sign-in\">\n <a\n data-testid=\"log-in-link\"\n className=\"wishlist-login__link\"\n href=\"\"\n rel=\"noreferrer\"\n onClick={onLoginClick}\n role=\"button\"\n >\n <Text id=\"Wishlist.Login.logIn\" />\n </a>\n <Text id=\"Wishlist.Login.sync\" />\n </div>\n );\n};\n"],"names":["EmptyWishlist","className","children","ctaLinkURL","props","labels","useText","jsx","classes","IllustratedMessage","Icon","Heart","Button","WishlistItemSkeleton","SkeletonRow","WishlistSkeleton","jsxs","Skeleton","Wishlist","routeEmptyWishlistCTA","routeToWishlist","moveProdToCart","routeProdDetailPage","getProductData","getRefinedProduct","slots","wishlistData","setWishlistData","useState","isLoggedIn","setIsLoggedIn","state","isLoading","setIsLoading","handleAuthentication","authenticated","wishlistAlert","setWishlistAlert","handleWishlistAlert","useCallback","payload","action","item","WishlistAlert","useEffect","authEvent","events","updateEvent","dataEvent","WishlistComponent","onLoginClick","alert","setAlert","dictionary","products","useMemo","_a","WishlistItem","defaultImageProps","Slot","timer","renderAlert","VComponent","renderLoader","Fragment","renderWishlist","renderHeading","Login","title","index","Text"],"mappings":"+zBA8BO,MAAMA,EAAuD,CAAC,CACnE,UAAAC,EACA,SAAAC,EACA,WAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAASC,EAAQ,CACrB,cAAe,iCACf,QAAS,iCACT,IAAK,4BAAA,CACN,EAGC,OAAAC,EAAC,MAAK,CAAA,GAAGH,EAAO,UAAWI,EAAQ,CAAC,0BAA2BP,CAAS,CAAC,EACvE,SAAAM,EAACE,EAAA,CACC,UAAWD,EAAQ,CAAC,mCAAoCP,CAAS,CAAC,EAClE,cAAY,0BACZ,QAASI,EAAO,cAChB,KAAOE,EAAAG,EAAA,CAAK,UAAU,gCAAgC,OAAQC,EAAO,EACrE,QAASJ,EAAC,IAAG,CAAA,SAAAF,EAAO,QAAQ,EAC5B,OACEF,EACEI,EAACK,EAAA,CACC,cAAY,iCACZ,KAAK,SACL,QAAQ,UAER,KAAK,SACL,KAAMT,EAEL,SAAOE,EAAA,GAAA,EAJJ,WAAA,EAMJ,MAAA,CAAA,EAGV,CAEJ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,EA3BoB,IA6BrB,EAAA,CAAChB,EAAYC,EAAU5B,CAAY,CAAC,EAGrC,OAAAV,EAAC,MAAK,CAAA,GAAGZ,EAAO,UAAWI,EAAQ,CAAC,oBAAqBP,CAAS,CAAC,EAChE,SAAA,CAAA4D,EACA7B,EAAY+B,EAAa,EAAIE,EAAe,CAAA,EAC/C,CAEJ,EC/LaE,EAAuC,CAAC,CAAE,aAAAjB,KAEnDlC,EAAC,MAAI,CAAA,UAAU,0BACb,SAAA,CAAAT,EAAC,IAAA,CACC,cAAY,cACZ,UAAU,uBACV,KAAK,GACL,IAAI,aACJ,QAAS2C,EACT,KAAK,SAEL,SAAA3C,EAAC+D,EAAK,CAAA,GAAG,sBAAuB,CAAA,CAAA,CAClC,EACA/D,EAAC+D,EAAK,CAAA,GAAG,qBAAsB,CAAA,CAAA,EACjC"}
1
+ {"version":3,"file":"Wishlist.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{W as e,W as l}from"../chunks/WishlistAlert.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-compat.js";import"../chunks/Trash.js";import"../chunks/HeartFilled.js";import"@dropins/tools/i18n.js";export{e as WishlistAlert,l as default};
3
+ import{W,W as f}from"./WishlistToggle.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../api.js";import"@dropins/tools/fetch-graphql.js";export{W as WishlistAlert,f as default};
4
4
  //# sourceMappingURL=WishlistAlert.js.map
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{W as d,W as h}from"../chunks/WishlistItem.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/fetch-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/Trash.js";import"@dropins/tools/i18n.js";import"../chunks/removeProductsFromWishlist.js";export{d as WishlistItem,h as default};
3
+ import{b as f,b as l}from"./WishlistToggle.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../api.js";import"@dropins/tools/fetch-graphql.js";export{f as WishlistItem,l as default};
4
4
  //# sourceMappingURL=WishlistItem.js.map
@@ -1,4 +1,18 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{useState as h,useCallback as E,useEffect as I}from"@dropins/tools/preact-compat.js";import{Button as j,Icon as c}from"@dropins/tools/components.js";import{events as a}from"@dropins/tools/event-bus.js";import{s as F,g as P,i as x}from"../chunks/fetch-error.js";import{S as A}from"../chunks/HeartFilled.js";import{S as M}from"../chunks/Heart.js";import{r as R}from"../chunks/removeProductsFromWishlist.js";import{c as q,a as H}from"../chunks/mergeWishlists.js";import{useText as N}from"@dropins/tools/i18n.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const $=({product:s,iconWishlisted:D,iconToWishlist:W,size:d,variant:O,disabled:U,labelToWishlist:g,labelWishlisted:b,onClick:u,removeProdFromCart:f})=>{const[k,w]=h(F.authenticated),[n,o]=h(!1),[L,S]=h(null),{isGuestWishlistEnabled:T}=q.getConfig(),v=N({addToWishlist:"Wishlist.Wishlist.ariaLabelAddToWishlist",removeFromWishlist:"Wishlist.Wishlist.ariaLabelRemoveFromWishlist"}),l=E(()=>{var t;const e=P(),i=(t=e==null?void 0:e.items)==null?void 0:t.find(m=>x(m,{sku:s.topLevelSku??s.sku,optionUIDs:s.optionUIDs??(s.selectedOptionsUIDs?Object.values(s.selectedOptionsUIDs):void 0)??(s.bundleOptionsUIDs?Object.values(s.bundleOptionsUIDs):void 0)}));S(i??null),o(!!i)},[s.topLevelSku,s.sku,s.optionUIDs,s.selectedOptionsUIDs,s.bundleOptionsUIDs]);I(()=>{l()},[l]),I(()=>{const e=m=>w(m),i=a.on("authenticated",e),t=a.on("wishlist/data",l);return()=>{i==null||i.off(),t==null||t.off()}},[l]);const y=async()=>{var e;if(n){try{await R([L])}catch{return a.emit("wishlist/alert",{action:"removeError",item:{product:s}}),null}o(!1),a.emit("wishlist/alert",{action:"remove",item:{product:s}})}else{try{await H([{sku:s.topLevelSku??s.sku,quantity:1,optionsUIDs:s.optionUIDs??(s.selectedOptionsUIDs?Object.values(s.selectedOptionsUIDs):void 0)??(s.bundleOptionsUIDs?Object.values(s.bundleOptionsUIDs):void 0),enteredOptions:(e=s.options)!=null&&e.items?s.options.items.filter(i=>i.selected).map(i=>({uid:i.uid,value:i.value})):void 0}])}catch{return a.emit("wishlist/alert",{action:"addError",item:{product:s}}),null}o(!0),a.emit("wishlist/alert",{action:"add",item:{product:s}}),f&&await f([{uid:s.uid,quantity:0}])}};if(!k&&!T)return null;const C=n?v.removeFromWishlist.replace("{PRODUCT_NAME}",s==null?void 0:s.name):v.addToWishlist.replace("{PRODUCT_NAME}",s==null?void 0:s.name);return r(j,{active:n,"aria-label":C,"data-testid":"wishlist-toggle",size:d??"medium",variant:O??"tertiary",disabled:U,icon:r(c,{source:W??M}),activeIcon:r(c,{source:D??A}),onClick:u??y,children:g,activeChildren:b})};export{$ as WishlistToggle,$ as default};
3
+ import*as n from"@dropins/tools/preact-compat.js";import{useState as A,useCallback as V,useEffect as P,useMemo as U,Fragment as Me}from"@dropins/tools/preact-compat.js";import{classes as x,Slot as Ae,VComponent as Ne}from"@dropins/tools/lib.js";import{useText as j,Text as ye}from"@dropins/tools/i18n.js";import{jsx as t,jsxs as W,Fragment as z}from"@dropins/tools/preact-jsx-runtime.js";import{Button as S,Icon as B,IllustratedMessage as He,SkeletonRow as Oe,Skeleton as Be,InLineAlert as Ue,Price as Z,Image as Se}from"@dropins/tools/components.js";import{events as b}from"@dropins/tools/event-bus.js";import{s as q,config as Pe,getPersistedWishlistData as ze,i as je,removeProductsFromWishlist as Ie,addProductsToWishlist as Fe}from"../api.js";import"@dropins/tools/fetch-graphql.js";const Le=e=>n.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},n.createElement("g",{clipPath:"url(#clip0_102_196)"},n.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"}),n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_102_196"},n.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),be=e=>n.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.734 5.4175C17.8557 3.5275 14.7987 3.5275 12.9105 5.4175L11.9814 6.3475L11.0523 5.4175C9.15407 3.5475 6.09699 3.5775 4.22878 5.4875C2.39054 7.3675 2.39054 10.3675 4.22878 12.2475L5.15789 13.1775L11.9814 20.0075L18.8048 13.1775L19.734 12.2475C21.6221 10.3675 21.6221 7.3075 19.734 5.4175Z",stroke:"currentColor",strokeWidth:1})),xe=e=>n.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e},n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12,20.75h0c-.2,0-.39-.08-.53-.22L3.71,12.77c-2.12-2.16-2.12-5.66,0-7.82,1.04-1.06,2.44-1.66,3.93-1.67h.06c1.47,0,2.85,.57,3.9,1.6l.4,.4,.4-.4c1.05-1.05,2.45-1.63,3.94-1.63h0c1.49,0,2.89,.58,3.94,1.63,.02,.02,.03,.03,.05,.05,1.02,1.05,1.59,2.43,1.59,3.9s-.58,2.89-1.63,3.94l-7.76,7.76c-.14,.14-.33,.22-.53,.22Z",stroke:"currentColor"})),Ce=e=>n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",...e},n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1 5H23",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.3674 22H6.63446C5.67952 22 4.88992 21.2688 4.8379 20.3338L4 5H20L19.1621 20.3338C19.1119 21.2688 18.3223 22 17.3655 22H17.3674Z",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.87189 2H14.1281C14.6085 2 15 2.39766 15 2.88889V5H9V2.88889C9 2.39912 9.39006 2 9.87189 2Z",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.87402 8.58057L9.39348 17.682",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10}),n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M14.6673 8.58057L14.146 17.682",stroke:"currentColor",strokeWidth:1,strokeMiterlimit:10})),_e=e=>n.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},n.createElement("g",{clipPath:"url(#clip0_841_1324)"},n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),n.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),n.createElement("defs",null,n.createElement("clipPath",{id:"clip0_841_1324"},n.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),st=({product:e,iconWishlisted:i,iconToWishlist:s,size:c,variant:h,disabled:w,labelToWishlist:r,labelWishlisted:u,onClick:m,removeProdFromCart:f})=>{const[p,a]=A(q.authenticated),[y,g]=A(!1),[_,C]=A(null),{isGuestWishlistEnabled:M}=Pe.getConfig(),N=j({addToWishlist:"Wishlist.Wishlist.ariaLabelAddToWishlist",removeFromWishlist:"Wishlist.Wishlist.ariaLabelRemoveFromWishlist"}),v=V(()=>{var k;const o=ze(),d=(k=o==null?void 0:o.items)==null?void 0:k.find(H=>je(H,{sku:e.topLevelSku??e.sku,optionUIDs:e.optionUIDs??(e.selectedOptionsUIDs?Object.values(e.selectedOptionsUIDs):void 0)??(e.bundleOptionsUIDs?Object.values(e.bundleOptionsUIDs):void 0)}));C(d??null),g(!!d)},[e.topLevelSku,e.sku,e.optionUIDs,e.selectedOptionsUIDs,e.bundleOptionsUIDs]);P(()=>{v()},[v]),P(()=>{const o=H=>a(H),d=b.on("authenticated",o),k=b.on("wishlist/data",v);return()=>{d==null||d.off(),k==null||k.off()}},[v]);const L=async()=>{var o;if(y){try{await Ie([_])}catch{return b.emit("wishlist/alert",{action:"removeError",item:{product:e}}),null}g(!1),b.emit("wishlist/alert",{action:"remove",item:{product:e}})}else{try{await Fe([{sku:e.topLevelSku??e.sku,quantity:1,optionsUIDs:e.optionUIDs??(e.selectedOptionsUIDs?Object.values(e.selectedOptionsUIDs):void 0)??(e.bundleOptionsUIDs?Object.values(e.bundleOptionsUIDs):void 0),enteredOptions:(o=e.options)!=null&&o.items?e.options.items.filter(d=>d.selected).map(d=>({uid:d.uid,value:d.value})):void 0}])}catch{return b.emit("wishlist/alert",{action:"addError",item:{product:e}}),null}g(!0),b.emit("wishlist/alert",{action:"add",item:{product:e}}),f&&await f([{uid:e.uid,quantity:0}])}};if(!p&&!M)return null;const I=y?N.removeFromWishlist.replace("{PRODUCT_NAME}",e==null?void 0:e.name):N.addToWishlist.replace("{PRODUCT_NAME}",e==null?void 0:e.name);return t(S,{active:y,"aria-label":I,"data-testid":"wishlist-toggle",size:c??"medium",variant:h??"tertiary",disabled:w,icon:t(B,{source:s??be}),activeIcon:t(B,{source:i??xe}),onClick:m??L,children:r,activeChildren:u})},Ze=({className:e,children:i,ctaLinkURL:s,...c})=>{const h=j({emptyWishlist:"Wishlist.EmptyWishlist.heading",message:"Wishlist.EmptyWishlist.message",cta:"Wishlist.EmptyWishlist.cta"});return t("div",{...c,className:x(["wishlist-empty-wishlist",e]),children:t(He,{className:x(["wishlist-empty-wishlist__wrapper",e]),"data-testid":"wishlist-empty-wishlist",heading:h.emptyWishlist,icon:t(B,{className:"wishlist-empty-wishlist__icon",source:be}),message:t("p",{children:h.message}),action:s?t(S,{"data-testid":"wishlist-empty-wishlist-button",size:"medium",variant:"primary",type:"submit",href:s,children:h.cta},"routeHome"):void 0})})},$=()=>t(Oe,{children:`
4
+ <svg
5
+ width="100%"
6
+ height="100%"
7
+ viewBox="0 0 288 658"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ preserveAspectRatio="xMinYMin meet"
11
+ >
12
+ <rect x="6" y="24" width="282px" height="480" rx="8" fill="#E8E8E8" />
13
+ <rect x="6" y="522" width="280" height="22" rx="4" fill="#E8E8E8" />
14
+ <rect x="6" y="556" width="132" height="22" rx="4" fill="#E8E8E8" />
15
+ <rect x="6" y="592" width="280" height="48" rx="24" fill="#D9D9D9" />
16
+ </svg>
17
+ `}),Ve=()=>W(Be,{"data-testid":"wishlist-loader",children:[t($,{}),t($,{}),t($,{})]}),$e=({action:e,item:i,routeToWishlist:s})=>{const c=j({addHeading:"Wishlist.Alert.addProduct.heading",addMessage:"Wishlist.Alert.addProduct.message",removeHeading:"Wishlist.Alert.removeProduct.heading",removeMessage:"Wishlist.Alert.removeProduct.message",moveHeading:"Wishlist.Alert.moveToCart.heading",moveMessage:"Wishlist.Alert.moveToCart.message",viewWishlist:"Wishlist.Alert.viewWishlist",addErrorHeading:"Wishlist.Alert.addError.heading",addErrorMessage:"Wishlist.Alert.addError.message",removeErrorHeading:"Wishlist.Alert.removeError.heading",removeErrorMessage:"Wishlist.Alert.removeError.message"});if(!e)return null;const h=c[`${e}Heading`],w=c[`${e}Message`],r={add:xe,remove:Ce,move:Le,addError:_e,removeError:_e},u=s?location.href.includes(s):!1;return t(Ue,{"data-testid":"wishlist-alert",heading:h,description:i?w.replace("{product}",i.product.name):w,type:e==="addError"||e==="removeError"?"warning":"success",icon:t(B,{source:r[e],size:"16"}),actionButtonPosition:"top",additionalActions:!u&&s?[{label:c.viewWishlist,onClick:()=>{location.href=s}}]:void 0})},rt=({routeEmptyWishlistCTA:e,routeToWishlist:i,moveProdToCart:s,routeProdDetailPage:c,getProductData:h,getRefinedProduct:w,slots:r,...u})=>{const[m,f]=A(null),[p,a]=A(q.authenticated),[y,g]=A(q.isLoading),_=v=>a(v),[C,M]=A(null),N=V(v=>{const{action:L,item:I}=v;M(t($e,{action:L,item:I,routeToWishlist:i}))},[i]);return P(()=>{const v=b.on("authenticated",_),L=b.on("wishlist/alert",o=>N(o)),I=b.on("wishlist/data",o=>{f(o),g(!1)},{eager:!0});return()=>{v==null||v.off(),I==null||I.off(),L==null||L.off()}},[N]),t(qe,{...u,wishlistData:m,wishlistAlert:C,routeEmptyWishlistCTA:e,moveProdToCart:s,getProductData:h,getRefinedProduct:w,isLoggedIn:p,isLoading:y,routeProdDetailPage:c,slots:r})},qe=({className:e,wishlistData:i,wishlistAlert:s,isLoggedIn:c,isLoading:h,moveProdToCart:w,getProductData:r,getRefinedProduct:u,routeEmptyWishlistCTA:m,onLoginClick:f,routeProdDetailPage:p,slots:a,...y})=>{const[g,_]=A(s),C=j({wishlistHeading:"Wishlist.Wishlist.heading",wishlistLoadingHeading:"Wishlist.Wishlist.loading"}),M=U(()=>{var o;return((o=i==null?void 0:i.items)==null?void 0:o.length)>0?i.items.map(d=>t(De,{item:d,getProductData:r,getRefinedProduct:u,moveProdToCart:w,routeProdDetailPage:p,imageNode:a!=null&&a.image?({defaultImageProps:k})=>t(Ae,{name:"image",slot:a.image,context:{defaultImageProps:k,item:d}}):void 0},d.id)):null},[i,w,r,u,p,a==null?void 0:a.image]);P(()=>{if(s){_(s);const o=setTimeout(()=>{_(null)},5e3);return()=>clearTimeout(o)}},[s]);const N=U(()=>g?t(Ne,{node:g,className:"wishlist-wishlist__alert"}):null,[g]),v=()=>W(z,{children:[t("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:t("h1",{className:"wishlist-wishlist__heading-text","data-testid":"loader-wishlist-heading",children:C.wishlistLoadingHeading})}),t(Ve,{})]}),L=()=>M?W(z,{children:[I,t("div",{className:"wishlist-wishlist__content",children:M})]}):t("div",{className:x(["wishlist-wishlist__content","wishlist-wishlist__content--empty"]),children:W("div",{children:[t(Ze,{"data-testid":"empty-wishlist",ctaLinkURL:m==null?void 0:m()}),!c&&t(Ye,{onLoginClick:f})]})}),I=U(()=>{var o;return M?t("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:t("h1",{className:"wishlist-wishlist__heading-text","data-testid":"default-wishlist-heading",children:(o=C.wishlistHeading)==null?void 0:o.split(" {count}").map((d,k)=>{var H;return W(Me,{children:[d,k===0&&t("span",{className:"wishlist-wishlist__heading-count","data-testid":"wishlist-heading-count",children:`${i==null?void 0:i.items_count} products`})]},((H=i==null?void 0:i.id)==null?void 0:H.toString())+k)})})}):null},[C,M,i]);return W("div",{...y,className:x(["wishlist-wishlist",e]),children:[N,h?v():L()]})},Te=({className:e,item:i,onCartActionButtonClick:s,onTrashButtonClick:c,routeProdDetailPage:h,imageNode:w,...r})=>{var I,o,d,k,H,T,R;const u=j({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton",customizeActionBtn:"ProductItem.CustomizeActionButton"}),m=((d=(o=(I=i.product)==null?void 0:I.prices)==null?void 0:o.final)==null?void 0:d.amount)<((T=(H=(k=i.product)==null?void 0:k.prices)==null?void 0:H.regular)==null?void 0:T.amount),f=()=>{var l;return t("a",{className:"wishlist-product-item-image","data-testid":"wishlist-product-item-image",href:h(i.product),children:t(Re,{images:((l=i.product)==null?void 0:l.images)??[],imageNode:w})})},p=()=>{var l,E,O,F,Y,D,G,J,K,Q,X,ee,te,ie,se,re,ne,oe,le,ce,ae,de,he,ue,me,pe,ge,we,fe,ve,ke,We,Ee;return((O=(E=(l=i.product)==null?void 0:l.prices)==null?void 0:E.final)==null?void 0:O.amount)===void 0&&((D=(Y=(F=i.product)==null?void 0:F.prices)==null?void 0:Y.final)==null?void 0:D.maximumAmount)!==void 0&&((K=(J=(G=i.product)==null?void 0:G.prices)==null?void 0:J.final)==null?void 0:K.maximumAmount)>0?W(z,{children:[t(Z,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(ee=(X=(Q=i.product)==null?void 0:Q.prices)==null?void 0:X.final)==null?void 0:ee.minimumAmount,currency:(se=(ie=(te=i.product)==null?void 0:te.prices)==null?void 0:ie.final)==null?void 0:se.currency}),"-",t(Z,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(oe=(ne=(re=i.product)==null?void 0:re.prices)==null?void 0:ne.final)==null?void 0:oe.maximumAmount,currency:(ae=(ce=(le=i.product)==null?void 0:le.prices)==null?void 0:ce.final)==null?void 0:ae.currency})]}):W(z,{children:[t(Z,{className:x(["wishlist-product-item-price",m?"strikethrough":""]),"data-testid":"wishlist-product-item-price",amount:(ue=(he=(de=i.product)==null?void 0:de.prices)==null?void 0:he.regular)==null?void 0:ue.amount,currency:(ge=(pe=(me=i.product)==null?void 0:me.prices)==null?void 0:pe.regular)==null?void 0:ge.currency}),m&&t(Z,{className:"wishlist-product-item-discounted-price","data-testid":"wishlist-product-item-discounted-price",amount:(ve=(fe=(we=i.product)==null?void 0:we.prices)==null?void 0:fe.final)==null?void 0:ve.amount,currency:(Ee=(We=(ke=i.product)==null?void 0:ke.prices)==null?void 0:We.final)==null?void 0:Ee.currency})]})},a=()=>t(S,{"data-testid":"wishlist-product-item-remove-button",className:"wishlist-product-item-button__remove",variant:"tertiary",onClick:()=>c==null?void 0:c(),icon:t(B,{source:Ce,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":u.trashActionBtn})}),y=()=>g()?v():L(),g=()=>{var l;return((l=i.product)==null?void 0:l.productType)==="complex"?M():!0},_=U(()=>{var l;return((l=i.selectedOptions)==null?void 0:l.map(E=>E.uid))||[]},[i.selectedOptions]),C=U(()=>{const l=i.product.options||[],E=l.filter(O=>O.required);return E.length===0?l:E},[i.product.options]),M=()=>C.every(l=>{var E;return(E=l.items)==null?void 0:E.some(O=>_.includes(O.id))}),N=()=>_.length===0?null:t("div",{className:"wishlist-product-item-options",children:C.map(l=>{var O;const E=(O=l.items)==null?void 0:O.find(F=>_.includes(F.id));return E?W("div",{className:"wishlist-product-item-option",children:[W("span",{className:"wishlist-product-item-option__attribute",children:[l.label,":"]})," ",t("span",{className:"wishlist-product-item-option__label",children:E.label})]},l.type):null})}),v=()=>{var l;return t(S,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:t(B,{source:Le}),disabled:!((l=i.product)!=null&&l.inStock),"aria-label":u.cartActionBtn,onClick:()=>s==null?void 0:s(),children:u.cartActionBtn})},L=()=>t(S,{"data-testid":"wishlist-product-item-customize-button",size:"medium",type:"submit","aria-label":u.customizeActionBtn,href:h(i.product),children:u.customizeActionBtn});return t("div",{...r,className:x(["wishlist-product-item",e]),children:W("div",{className:"wishlist-product-item__content",children:[f(),W("div",{className:"wishlist-product-item__title","data-testid":"wishlist-product-item-header",children:[t("a",{className:"wishlist-product-item-name","data-testid":"wishlist-product-item-name",href:h(i.product),children:(R=i.product)==null?void 0:R.name}),a(),p()]}),N(),y()]})})},Re=({className:e,children:i,images:s,imageNode:c,...h})=>{const[w,r]=A(0);return W(z,{children:[t("div",{...h,className:x(["image-carousel",e]),children:t("div",{className:x(["overflow-hidden relative max-w-[200px]",e]),children:s==null?void 0:s.map((u,m)=>{const f={className:x(["image-carousel-image",e]),src:u.url,alt:u.label};return m!==w?null:typeof c=="function"?c({defaultImageProps:f}):c||t(Se,{...f})})})}),(s==null?void 0:s.length)>1&&t("div",{className:x(["absolute","image-switcher-area"]),children:s==null?void 0:s.map((u,m)=>t("span",{className:x(["image-switcher",w===m?"image-switcher-active":"image-switcher-inactive"]),onClick:f=>{r(m),f.preventDefault(),f.stopPropagation()}},m))})]})},Ye=({onLoginClick:e})=>W("div",{className:"wishlist-login__sign-in",children:[t("a",{"data-testid":"log-in-link",className:"wishlist-login__link",href:"",rel:"noreferrer",onClick:e,role:"button",children:t(ye,{id:"Wishlist.Login.logIn"})}),t(ye,{id:"Wishlist.Login.sync"})]}),De=({item:e,getProductData:i,getRefinedProduct:s,moveProdToCart:c,routeProdDetailPage:h,imageNode:w})=>{const[r,u]=A(null);P(()=>{let p=!1;async function a(){var y;try{let g;s&&((y=e==null?void 0:e.selectedOptions)==null?void 0:y.length)>0?g=await s(e.product.sku,e.selectedOptions.map(_=>_.uid)):g=i?await i(e==null?void 0:e.product.sku):e==null?void 0:e.product,p||u(g)}catch(g){p||console.error("Failed to fetch product data:",g)}}return a(),()=>{p=!0}},[e,i,s]);const m=V(async(p=!0)=>{try{return await Ie([e]),console.log(`Product ${r==null?void 0:r.sku} removed from wishlist!`),p&&b.emit("wishlist/alert",{action:"remove",item:{...e,product:r}}),!0}catch(a){return console.error(`Product ${r.sku} could not be removed from wishlist`,a),!1}},[e,r]),f=V(async()=>{var p;try{return await c([{sku:r.sku,quantity:1,optionsUIDs:(p=e.selectedOptions)==null?void 0:p.map(a=>a.uid),enteredOptions:e.enteredOptions}]),console.log(`Product ${r.sku} successfully moved to cart 🛒`),b.emit("wishlist/alert",{action:"move",item:{...e,product:r}}),await m(!1)}catch(a){return console.error("Could not move product to cart: ",a),a.toString().includes("You need to choose options for your item.")&&window.location.replace(h(r)),!1}},[r,e,c,h,m]);return!r||!e?null:t(Te,{item:{...e,product:r},onCartActionButtonClick:f,onTrashButtonClick:m,routeProdDetailPage:h,imageNode:w})};export{$e as W,st as WishlistToggle,rt as a,De as b,st as default};
4
18
  //# sourceMappingURL=WishlistToggle.js.map