@dropins/storefront-wishlist 2.0.0 → 2.0.1-beta1

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.
@@ -1,4 +1,4 @@
1
1
  import { Wishlist } from '../../data/models';
2
2
 
3
- export declare const getWishlistById: (wishlistId: string, currentPage: number, pageSize: number) => Promise<void | Wishlist | null>;
3
+ export declare const getWishlistById: (wishlistId: string) => Promise<void | Wishlist | null>;
4
4
  //# sourceMappingURL=getWishlistById.d.ts.map
package/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{W as _,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 l,g as m,f as n,h as I}from"./chunks/removeProductsFromWishlist.js";import{k as O,e as Q,l as y,c as b,r as C,a as Y,b as x,d as z,j as B}from"./chunks/removeProductsFromWishlist.js";import{events as u}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const d=`
3
+ import{W as c,t as h,b as m}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 l,g as u,f as a,h as I}from"./chunks/removeProductsFromWishlist.js";import{k as O,e as Q,l as y,c as b,r as C,a as Y,b as x,d as B,j as z}from"./chunks/removeProductsFromWishlist.js";import{events as _}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const d=`
4
4
  query GET_WISHLIST_BY_ID_QUERY(
5
5
  $wishlistId: ID!,
6
6
  ) {
@@ -14,18 +14,13 @@ import{W as _,t as h,b as c}from"./chunks/mergeWishlists.js";import{a as G,c as
14
14
  items {
15
15
  ...WISHLIST_ITEM_FRAGMENT
16
16
  }
17
- page_info {
18
- page_size
19
- current_page
20
- total_pages
21
- }
22
17
  }
23
18
  }
24
19
  }
25
20
  }
26
21
 
27
- ${_}
28
- `,w=async(r,o,e)=>{if(!l.authenticated)return m();if(!r)throw Error("Wishlist ID is not set");return n(d,{variables:{wishlistId:r,currentPage:o,pageSize:e}}).then(({errors:s,data:t})=>{var a;if(s)return I(s);if(!((a=t==null?void 0:t.customer)!=null&&a.wishlist_v2))return null;const i=h(t.customer.wishlist_v2);return u.emit("wishlist/data",i),i})},W=`
22
+ ${c}
23
+ `,w=async r=>{if(!l.authenticated)return u();if(!r)throw Error("Wishlist ID is not set");return a(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=`
29
24
  mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(
30
25
  $wishlistId: ID!,
31
26
  $wishlistItems: [WishlistItemUpdateInput!]!,
@@ -44,6 +39,6 @@ ${_}
44
39
  }
45
40
  }
46
41
 
47
- ${c}
48
- `,E=async r=>{const o=l.wishlistId;if(!o)throw Error("Wishlist ID is not set");return n(W,{variables:{wishlistId:o,wishlistItems:r.map(({wishlistItemId:e,quantity:s,description:t,selectedOptions:i,enteredOptions:a})=>({wishlistItemId:e,quantity:s,description:t,selected_options:i,entered_options:a}))}}).then(({errors:e,data:s})=>{var i;const t=[...((i=s==null?void 0:s.updateProductsInWishlist)==null?void 0:i.user_errors)??[],...e??[]];return t.length>0?I(t):h(s.updateProductsInWishlist.wishlist)})};export{G as addProductsToWishlist,O as clearPersistedLocalStorage,H as config,n as fetchGraphQl,Q as getConfig,F as getDefaultWishlist,v as getGuestWishlist,m 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,C as removeProductsFromWishlist,R as resetWishlist,Y as setEndpoint,x as setFetchGraphQlHeader,z as setFetchGraphQlHeaders,B as setPersistedWishlistData,E as updateProductsInWishlist};
42
+ ${m}
43
+ `,E=async r=>{const e=l.wishlistId;if(!e)throw Error("Wishlist ID is not set");return a(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,a 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,C as removeProductsFromWishlist,R as resetWishlist,Y as setEndpoint,x as setFetchGraphQlHeader,B as setFetchGraphQlHeaders,z as setPersistedWishlistData,E as updateProductsInWishlist};
49
44
  //# 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 page_info {\n page_size\n current_page\n total_pages\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 currentPage: number,\n pageSize: number\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 currentPage,\n pageSize,\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","currentPage","pageSize","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":"yeAmBO,MAAMA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwBtCC,CAAsB;AAAA,EClBXC,EAAkB,MAC7BC,EACAC,EACAC,IACoC,CAGhC,GAAA,CAACC,EAAM,cACT,OAAOC,EAAyB,EAGlC,GAAI,CAACJ,EACH,MAAM,MAAM,wBAAwB,EAItC,OAAOK,EAAaR,EAA0B,CAC5C,UAAW,CACT,WAAAG,EACA,YAAAC,EACA,SAAAC,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,ECvCaG,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,MAAMhB,EAAaG,EAAM,WAEzB,GAAI,CAACH,EACH,MAAM,MAAM,wBAAwB,EAGtC,OAAOK,EAAaQ,EAAsC,CACxD,UAAW,CACT,WAAAb,EACA,cAAegB,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/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":"yeAmBO,MAAMA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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CAChB,EAEA,OAAIgB,EAAQ,OAAS,EAAUd,EAAiBc,CAAO,EAEhDX,EAAkBJ,EAAK,yBAAyB,QAAQ,CAAA,CAChE,CACH"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as s,jsxs as w,Fragment as B}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as ut,useState as pt,useEffect as vt,useCallback as at}from"@dropins/tools/preact-compat.js";import{classes as v}from"@dropins/tools/lib.js";import{Button as x,Icon as dt,Price as I,Image as yt}from"@dropins/tools/components.js";import{events as lt}from"@dropins/tools/event-bus.js";import{r as bt}from"./removeProductsFromWishlist.js";import{a as Nt,S as At}from"./Trash.js";import{useText as It}from"@dropins/tools/i18n.js";const xt=({className:r,item:t,onCartActionButtonClick:c,onTrashButtonClick:a,routeProdDetailPage:p,imageNode:y,...o})=>{var _,z,k,g,S,q,P;const u=It({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton",customizeActionBtn:"ProductItem.CustomizeActionButton"}),n=((k=(z=(_=t.product)==null?void 0:_.prices)==null?void 0:z.final)==null?void 0:k.amount)<((q=(S=(g=t.product)==null?void 0:g.prices)==null?void 0:S.regular)==null?void 0:q.amount),m=()=>{var e;return s("a",{className:"wishlist-product-item-image","data-testid":"wishlist-product-item-image",href:p(t.product),children:s(Bt,{images:((e=t.product)==null?void 0:e.images)??[],imageNode:y})})},d=()=>{var e,i,h,A,F,W,C,M,T,$,j,E,U,V,Y,G,H,J,K,L,Q,R,X,Z,D,tt,rt,et,st,ct,ot,it,nt;return((h=(i=(e=t.product)==null?void 0:e.prices)==null?void 0:i.final)==null?void 0:h.amount)===void 0&&((W=(F=(A=t.product)==null?void 0:A.prices)==null?void 0:F.final)==null?void 0:W.maximumAmount)!==void 0&&((T=(M=(C=t.product)==null?void 0:C.prices)==null?void 0:M.final)==null?void 0:T.maximumAmount)>0?w(B,{children:[s(I,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(E=(j=($=t.product)==null?void 0:$.prices)==null?void 0:j.final)==null?void 0:E.minimumAmount,currency:(Y=(V=(U=t.product)==null?void 0:U.prices)==null?void 0:V.final)==null?void 0:Y.currency}),"-",s(I,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(J=(H=(G=t.product)==null?void 0:G.prices)==null?void 0:H.final)==null?void 0:J.maximumAmount,currency:(Q=(L=(K=t.product)==null?void 0:K.prices)==null?void 0:L.final)==null?void 0:Q.currency})]}):w(B,{children:[s(I,{className:v(["wishlist-product-item-price",n?"strikethrough":""]),"data-testid":"wishlist-product-item-price",amount:(Z=(X=(R=t.product)==null?void 0:R.prices)==null?void 0:X.regular)==null?void 0:Z.amount,currency:(rt=(tt=(D=t.product)==null?void 0:D.prices)==null?void 0:tt.regular)==null?void 0:rt.currency}),n&&s(I,{className:"wishlist-product-item-discounted-price","data-testid":"wishlist-product-item-discounted-price",amount:(ct=(st=(et=t.product)==null?void 0:et.prices)==null?void 0:st.final)==null?void 0:ct.amount,currency:(nt=(it=(ot=t.product)==null?void 0:ot.prices)==null?void 0:it.final)==null?void 0:nt.currency})]})},l=()=>s(x,{"data-testid":"wishlist-product-item-remove-button",className:"wishlist-product-item-button__remove",variant:"tertiary",onClick:()=>a==null?void 0:a(),icon:s(dt,{source:Nt,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":u.trashActionBtn})}),N=()=>f()?ft():wt(),f=()=>{var e;return((e=t.product)==null?void 0:e.productType)==="complex"?mt():!0},b=ut(()=>{var e;return((e=t.selectedOptions)==null?void 0:e.map(i=>i.uid))||[]},[t.selectedOptions]),O=ut(()=>{const e=t.product.options||[],i=e.filter(h=>h.required);return i.length===0?e:i},[t.product.options]),mt=()=>O.every(e=>{var i;return(i=e.items)==null?void 0:i.some(h=>b.includes(h.id))}),ht=()=>b.length===0?null:s("div",{className:"wishlist-product-item-options",children:O.map(e=>{var h;const i=(h=e.items)==null?void 0:h.find(A=>b.includes(A.id));return i?w("div",{className:"wishlist-product-item-option",children:[w("span",{className:"wishlist-product-item-option__attribute",children:[e.id,":"]})," ",s("span",{className:"wishlist-product-item-option__label",children:i.label})]},e.type):null})}),ft=()=>{var e;return s(x,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:s(dt,{source:At}),disabled:!((e=t.product)!=null&&e.inStock),"aria-label":u.cartActionBtn,onClick:()=>c==null?void 0:c(),children:u.cartActionBtn})},wt=()=>s(x,{"data-testid":"wishlist-product-item-customize-button",size:"medium",type:"submit","aria-label":u.customizeActionBtn,href:p(t.product),children:u.customizeActionBtn});return s("div",{...o,className:v(["wishlist-product-item",r]),children:w("div",{className:"wishlist-product-item__content",children:[m(),w("div",{className:"wishlist-product-item__title","data-testid":"wishlist-product-item-header",children:[s("a",{className:"wishlist-product-item-name","data-testid":"wishlist-product-item-name",href:p(t.product),children:(P=t.product)==null?void 0:P.name}),l(),d()]}),ht(),N()]})})},Bt=({className:r,children:t,images:c,imageNode:a,...p})=>{const[y,o]=pt(0);return w(B,{children:[s("div",{...p,className:v(["image-carousel",r]),children:s("div",{className:v(["overflow-hidden relative max-w-[200px]",r]),children:c==null?void 0:c.map((u,n)=>{const m={className:v(["image-carousel-image",r]),src:u.url,alt:u.label};return n!==y?null:typeof a=="function"?a({defaultImageProps:m}):a||s(yt,{...m})})})}),(c==null?void 0:c.length)>1&&s("div",{className:v(["absolute","image-switcher-area"]),children:c==null?void 0:c.map((u,n)=>s("span",{className:v(["image-switcher",y===n?"image-switcher-active":"image-switcher-inactive"]),onClick:m=>{o(n),m.preventDefault(),m.stopPropagation()}},n))})]})},Ft=({item:r,getProductData:t,getRefinedProduct:c,moveProdToCart:a,routeProdDetailPage:p,imageNode:y})=>{const[o,u]=pt(null);vt(()=>{let d=!1;async function l(){var N;try{let f;c&&((N=r==null?void 0:r.selectedOptions)==null?void 0:N.length)>0?f=await c(r.product.sku,r.selectedOptions.map(b=>b.uid)):f=t?await t(r==null?void 0:r.product.sku):r==null?void 0:r.product,d||u(f)}catch(f){d||console.error("Failed to fetch product data:",f)}}return l(),()=>{d=!0}},[r,t,c]);const n=at(async(d=!0)=>{try{return await bt([r]),console.log(`Product ${o==null?void 0:o.sku} removed from wishlist!`),d&&lt.emit("wishlist/alert",{action:"remove",item:{...r,product:o}}),!0}catch(l){return console.error(`Product ${o.sku} could not be removed from wishlist`,l),!1}},[r,o]),m=at(async()=>{var d;try{return await a([{sku:o.sku,quantity:1,optionsUIDs:(d=r.selectedOptions)==null?void 0:d.map(l=>l.uid),enteredOptions:r.enteredOptions}]),console.log(`Product ${o.sku} successfully moved to cart 🛒`),lt.emit("wishlist/alert",{action:"move",item:{...r,product:o}}),await n(!1)}catch(l){return console.error("Could not move product to cart: ",l),l.toString().includes("You need to choose options for your item.")&&window.location.replace(p(o)),!1}},[o,r,a,p,n]);return!o||!r?null:s(xt,{item:{...r,product:o},onCartActionButtonClick:m,onTrashButtonClick:n,routeProdDetailPage:p,imageNode:y})};export{Ft as W};
3
+ import{jsx as s,jsxs as w,Fragment as B}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as ut,useState as pt,useEffect as vt,useCallback as at}from"@dropins/tools/preact-compat.js";import{classes as v}from"@dropins/tools/lib.js";import{Button as x,Icon as lt,Price as I,Image as yt}from"@dropins/tools/components.js";import{events as dt}from"@dropins/tools/event-bus.js";import{r as bt}from"./removeProductsFromWishlist.js";import{a as Nt,S as At}from"./Trash.js";import{useText as It}from"@dropins/tools/i18n.js";const xt=({className:r,item:t,onCartActionButtonClick:c,onTrashButtonClick:a,routeProdDetailPage:p,imageNode:y,...o})=>{var _,z,k,g,S,q,P;const u=It({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton",customizeActionBtn:"ProductItem.CustomizeActionButton"}),n=((k=(z=(_=t.product)==null?void 0:_.prices)==null?void 0:z.final)==null?void 0:k.amount)<((q=(S=(g=t.product)==null?void 0:g.prices)==null?void 0:S.regular)==null?void 0:q.amount),m=()=>{var e;return s("a",{className:"wishlist-product-item-image","data-testid":"wishlist-product-item-image",href:p(t.product),children:s(Bt,{images:((e=t.product)==null?void 0:e.images)??[],imageNode:y})})},l=()=>{var e,i,h,A,F,W,C,M,T,$,j,E,U,V,Y,G,H,J,K,L,Q,R,X,Z,D,tt,rt,et,st,ct,ot,it,nt;return((h=(i=(e=t.product)==null?void 0:e.prices)==null?void 0:i.final)==null?void 0:h.amount)===void 0&&((W=(F=(A=t.product)==null?void 0:A.prices)==null?void 0:F.final)==null?void 0:W.maximumAmount)!==void 0&&((T=(M=(C=t.product)==null?void 0:C.prices)==null?void 0:M.final)==null?void 0:T.maximumAmount)>0?w(B,{children:[s(I,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(E=(j=($=t.product)==null?void 0:$.prices)==null?void 0:j.final)==null?void 0:E.minimumAmount,currency:(Y=(V=(U=t.product)==null?void 0:U.prices)==null?void 0:V.final)==null?void 0:Y.currency}),"-",s(I,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(J=(H=(G=t.product)==null?void 0:G.prices)==null?void 0:H.final)==null?void 0:J.maximumAmount,currency:(Q=(L=(K=t.product)==null?void 0:K.prices)==null?void 0:L.final)==null?void 0:Q.currency})]}):w(B,{children:[s(I,{className:v(["wishlist-product-item-price",n?"strikethrough":""]),"data-testid":"wishlist-product-item-price",amount:(Z=(X=(R=t.product)==null?void 0:R.prices)==null?void 0:X.regular)==null?void 0:Z.amount,currency:(rt=(tt=(D=t.product)==null?void 0:D.prices)==null?void 0:tt.regular)==null?void 0:rt.currency}),n&&s(I,{className:"wishlist-product-item-discounted-price","data-testid":"wishlist-product-item-discounted-price",amount:(ct=(st=(et=t.product)==null?void 0:et.prices)==null?void 0:st.final)==null?void 0:ct.amount,currency:(nt=(it=(ot=t.product)==null?void 0:ot.prices)==null?void 0:it.final)==null?void 0:nt.currency})]})},d=()=>s(x,{"data-testid":"wishlist-product-item-remove-button",className:"wishlist-product-item-button__remove",variant:"tertiary",onClick:()=>a==null?void 0:a(),icon:s(lt,{source:Nt,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":u.trashActionBtn})}),N=()=>f()?ft():wt(),f=()=>{var e;return((e=t.product)==null?void 0:e.productType)==="complex"?mt():!0},b=ut(()=>{var e;return((e=t.selectedOptions)==null?void 0:e.map(i=>i.uid))||[]},[t.selectedOptions]),O=ut(()=>{const e=t.product.options||[],i=e.filter(h=>h.required);return i.length===0?e:i},[t.product.options]),mt=()=>O.every(e=>{var i;return(i=e.items)==null?void 0:i.some(h=>b.includes(h.id))}),ht=()=>b.length===0?null:s("div",{className:"wishlist-product-item-options",children:O.map(e=>{var h;const i=(h=e.items)==null?void 0:h.find(A=>b.includes(A.id));return i?w("div",{className:"wishlist-product-item-option",children:[w("span",{className:"wishlist-product-item-option__attribute",children:[e.label,":"]})," ",s("span",{className:"wishlist-product-item-option__label",children:i.label})]},e.type):null})}),ft=()=>{var e;return s(x,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:s(lt,{source:At}),disabled:!((e=t.product)!=null&&e.inStock),"aria-label":u.cartActionBtn,onClick:()=>c==null?void 0:c(),children:u.cartActionBtn})},wt=()=>s(x,{"data-testid":"wishlist-product-item-customize-button",size:"medium",type:"submit","aria-label":u.customizeActionBtn,href:p(t.product),children:u.customizeActionBtn});return s("div",{...o,className:v(["wishlist-product-item",r]),children:w("div",{className:"wishlist-product-item__content",children:[m(),w("div",{className:"wishlist-product-item__title","data-testid":"wishlist-product-item-header",children:[s("a",{className:"wishlist-product-item-name","data-testid":"wishlist-product-item-name",href:p(t.product),children:(P=t.product)==null?void 0:P.name}),d(),l()]}),ht(),N()]})})},Bt=({className:r,children:t,images:c,imageNode:a,...p})=>{const[y,o]=pt(0);return w(B,{children:[s("div",{...p,className:v(["image-carousel",r]),children:s("div",{className:v(["overflow-hidden relative max-w-[200px]",r]),children:c==null?void 0:c.map((u,n)=>{const m={className:v(["image-carousel-image",r]),src:u.url,alt:u.label};return n!==y?null:typeof a=="function"?a({defaultImageProps:m}):a||s(yt,{...m})})})}),(c==null?void 0:c.length)>1&&s("div",{className:v(["absolute","image-switcher-area"]),children:c==null?void 0:c.map((u,n)=>s("span",{className:v(["image-switcher",y===n?"image-switcher-active":"image-switcher-inactive"]),onClick:m=>{o(n),m.preventDefault(),m.stopPropagation()}},n))})]})},Ft=({item:r,getProductData:t,getRefinedProduct:c,moveProdToCart:a,routeProdDetailPage:p,imageNode:y})=>{const[o,u]=pt(null);vt(()=>{let l=!1;async function d(){var N;try{let f;c&&((N=r==null?void 0:r.selectedOptions)==null?void 0:N.length)>0?f=await c(r.product.sku,r.selectedOptions.map(b=>b.uid)):f=t?await t(r==null?void 0:r.product.sku):r==null?void 0:r.product,l||u(f)}catch(f){l||console.error("Failed to fetch product data:",f)}}return d(),()=>{l=!0}},[r,t,c]);const n=at(async(l=!0)=>{try{return await bt([r]),console.log(`Product ${o==null?void 0:o.sku} removed from wishlist!`),l&&dt.emit("wishlist/alert",{action:"remove",item:{...r,product:o}}),!0}catch(d){return console.error(`Product ${o.sku} could not be removed from wishlist`,d),!1}},[r,o]),m=at(async()=>{var l;try{return await a([{sku:o.sku,quantity:1,optionsUIDs:(l=r.selectedOptions)==null?void 0:l.map(d=>d.uid),enteredOptions:r.enteredOptions}]),console.log(`Product ${o.sku} successfully moved to cart 🛒`),dt.emit("wishlist/alert",{action:"move",item:{...r,product:o}}),await n(!1)}catch(d){return console.error("Could not move product to cart: ",d),d.toString().includes("You need to choose options for your item.")&&window.location.replace(p(o)),!1}},[o,r,a,p,n]);return!o||!r?null:s(xt,{item:{...r,product:o},onCartActionButtonClick:m,onTrashButtonClick:n,routeProdDetailPage:p,imageNode:y})};export{Ft as W};
4
4
  //# sourceMappingURL=WishlistItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WishlistItem.js","sources":["/@dropins/storefront-wishlist/src/components/ProductItem/ProductItem.tsx","/@dropins/storefront-wishlist/src/components/ImageCarousel/ImageCarousel.tsx","/@dropins/storefront-wishlist/src/containers/WishlistItem/WishlistItem.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 { HTMLAttributes, useMemo } from 'preact/compat';\nimport { FunctionComponent, JSX } from 'preact';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport {\n Button,\n Icon,\n ImageNodeRenderProps,\n Price,\n} from '@adobe-commerce/elsie/components';\nimport { ImageCarousel } from '@/wishlist/components';\nimport { Item, Product } from '@/wishlist/data/models';\nimport { Cart, Trash } from '@adobe-commerce/elsie/icons';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport '@/wishlist/components/ProductItem/ProductItem.css';\n\nexport interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n item?: Item;\n onCartActionButtonClick?: () => boolean;\n onTrashButtonClick?: () => boolean;\n routeProdDetailPage: (product: Product) => string;\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const ProductItem: FunctionComponent<ProductItemProps> = ({\n className,\n item,\n onCartActionButtonClick,\n onTrashButtonClick,\n routeProdDetailPage,\n imageNode,\n ...props\n}) => {\n const labels = useText({\n cartActionBtn: 'ProductItem.CartActionButton',\n trashActionBtn: 'ProductItem.TrashActionButton',\n customizeActionBtn: 'ProductItem.CustomizeActionButton',\n });\n\n const discounted =\n item.product?.prices?.final?.amount < item.product?.prices?.regular?.amount;\n\n const renderImage = () => {\n return (\n <a\n className=\"wishlist-product-item-image\"\n data-testid=\"wishlist-product-item-image\"\n href={routeProdDetailPage(item.product)}\n >\n <ImageCarousel\n images={item.product?.images ?? []}\n imageNode={imageNode}\n />\n </a>\n );\n };\n\n const renderPrices = () => {\n if (\n item.product?.prices?.final?.amount === undefined &&\n item.product?.prices?.final?.maximumAmount !== undefined &&\n item.product?.prices?.final?.maximumAmount > 0\n ) {\n return (\n <>\n <Price\n className=\"wishlist-product-item-price\"\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.final?.minimumAmount}\n currency={item.product?.prices?.final?.currency}\n />\n -\n <Price\n className=\"wishlist-product-item-price\"\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.final?.maximumAmount}\n currency={item.product?.prices?.final?.currency}\n />\n </>\n );\n }\n return (\n <>\n <Price\n className={classes([\n 'wishlist-product-item-price',\n discounted ? 'strikethrough' : '',\n ])}\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.regular?.amount}\n currency={item.product?.prices?.regular?.currency}\n />\n\n {discounted && (\n <Price\n className=\"wishlist-product-item-discounted-price\"\n data-testid=\"wishlist-product-item-discounted-price\"\n amount={item.product?.prices?.final?.amount}\n currency={item.product?.prices?.final?.currency}\n />\n )}\n </>\n );\n };\n\n const renderTrashButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-remove-button\"\n className=\"wishlist-product-item-button__remove\"\n variant=\"tertiary\"\n onClick={() => onTrashButtonClick?.()}\n icon={\n <Icon\n source={Trash}\n size=\"24\"\n stroke=\"2\"\n viewBox=\"0 0 24 24\"\n aria-label={labels.trashActionBtn}\n />\n }\n />\n );\n };\n\n const renderMainActionButton = () => {\n return isProductReady()\n ? renderMoveToCartButton()\n : renderCustomizeButton();\n };\n\n const isProductReady = () => {\n if (item.product?.productType === 'complex') {\n return areAllRequiredOptionsIncluded();\n }\n return true;\n };\n\n const selectedOptions = useMemo(\n () => item.selectedOptions?.map((opt: any) => opt.uid) || [],\n [item.selectedOptions]\n );\n\n const requiredOptions = useMemo(() => {\n const options = item.product.options || [];\n const required = options.filter((option: any) => option.required);\n return required.length === 0 ? options : required;\n }, [item.product.options]);\n\n const areAllRequiredOptionsIncluded = (): boolean => {\n return requiredOptions.every((option: any) =>\n option.items?.some((item: any) => selectedOptions.includes(item.id))\n );\n };\n\n const renderOptions = () => {\n if (selectedOptions.length === 0) return null;\n\n return (\n <div className=\"wishlist-product-item-options\">\n {requiredOptions.map((option: any) => {\n const selectedValue = option.items?.find((item: any) =>\n selectedOptions.includes(item.id)\n );\n return selectedValue ? (\n <div key={option.type} className=\"wishlist-product-item-option\">\n <span className=\"wishlist-product-item-option__attribute\">\n {option.id}:\n </span>\n &nbsp;\n <span className=\"wishlist-product-item-option__label\">\n {selectedValue.label}\n </span>\n </div>\n ) : null;\n })}\n </div>\n );\n };\n\n const renderMoveToCartButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-move-to-cart-button\"\n size=\"medium\"\n type=\"submit\"\n icon={<Icon source={Cart} />}\n disabled={!item.product?.inStock}\n aria-label={labels.cartActionBtn}\n onClick={() => onCartActionButtonClick?.()}\n >\n {labels.cartActionBtn}\n </Button>\n );\n };\n\n const renderCustomizeButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-customize-button\"\n size=\"medium\"\n type=\"submit\"\n aria-label={labels.customizeActionBtn}\n href={routeProdDetailPage(item.product)}\n >\n {labels.customizeActionBtn}\n </Button>\n );\n };\n\n return (\n <div {...props} className={classes(['wishlist-product-item', className])}>\n <div className=\"wishlist-product-item__content\">\n {renderImage()}\n <div\n className=\"wishlist-product-item__title\"\n data-testid=\"wishlist-product-item-header\"\n >\n <a\n className=\"wishlist-product-item-name\"\n data-testid=\"wishlist-product-item-name\"\n href={routeProdDetailPage(item.product)}\n >\n {item.product?.name}\n </a>\n\n {renderTrashButton()}\n {renderPrices()}\n </div>\n {renderOptions()}\n {renderMainActionButton()}\n </div>\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 { FunctionComponent, JSX } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { Image, ImageNodeRenderProps } from '@adobe-commerce/elsie/components';\nimport { useState } from 'react';\n\nimport '@/wishlist/components/ImageCarousel/ImageCarousel.css';\n\nexport interface ImageCarouselProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n children?: any;\n images: Image[];\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const ImageCarousel: FunctionComponent<ImageCarouselProps> = ({\n className,\n children,\n images,\n imageNode,\n ...props\n}) => {\n const [carouselIndex, setCarouselIndex] = useState(0);\n\n return (\n <>\n <div {...props} className={classes(['image-carousel', className])}>\n <div\n className={classes([\n 'overflow-hidden relative max-w-[200px]',\n className,\n ])}\n >\n {images?.map(\n (image: ImageCarouselProps['images'][0], index: number) => {\n const defaultProps = {\n className: classes(['image-carousel-image', className]),\n src: image.url,\n alt: image.label,\n } as const;\n\n if (index !== carouselIndex) {\n return null;\n }\n\n return typeof imageNode === 'function'\n ? imageNode({\n defaultImageProps: defaultProps,\n })\n : imageNode || <Image {...defaultProps} />;\n }\n )}\n </div>\n </div>\n {images?.length > 1 && (\n <div className={classes(['absolute', 'image-switcher-area'])}>\n {images?.map(\n (_image: ImageCarouselProps['images'][0], index: number) => {\n return (\n <span\n className={classes([\n 'image-switcher',\n carouselIndex === index\n ? 'image-switcher-active'\n : 'image-switcher-inactive',\n ])}\n key={index}\n onClick={(event: MouseEvent | TouchEvent) => {\n setCarouselIndex(index);\n event.preventDefault(); // prevent navigate on click since ImageCarousel is wrapped in a link\n event.stopPropagation();\n }}\n />\n );\n }\n )}\n </div>\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 {\n HTMLAttributes,\n useEffect,\n useState,\n useCallback,\n} from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { ProductItem } from '@/wishlist/components';\nimport { Item, Product } from '@/wishlist/data/models';\nimport { removeProductsFromWishlist } from '@/wishlist/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ImageNodeRenderProps } from '@adobe-commerce/elsie/components';\nimport { JSX } from 'preact';\n\nexport interface WishlistItemProps extends HTMLAttributes<HTMLDivElement> {\n item: Item;\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 moveProdToCart: (\n products: {\n sku: string;\n quantity: number;\n optionsUIDs?: [];\n enteredOptions?: [];\n }[]\n ) => Promise<any>;\n routeProdDetailPage: (product: Product) => string;\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const WishlistItem: Container<WishlistItemProps> = ({\n item,\n getProductData,\n getRefinedProduct,\n moveProdToCart,\n routeProdDetailPage,\n imageNode,\n}: WishlistItemProps) => {\n const [productData, setProductData] = useState<Product | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n async function fetchProductData() {\n try {\n let data: Product | null;\n if (getRefinedProduct && item?.selectedOptions?.length > 0) {\n data = await getRefinedProduct(\n item.product.sku,\n item.selectedOptions.map((option: { uid: any }) => option.uid)\n );\n } else {\n data = getProductData\n ? await getProductData(item?.product.sku)\n : item?.product;\n }\n if (!cancelled) setProductData(data);\n } catch (err) {\n if (!cancelled) {\n console.error('Failed to fetch product data:', err);\n }\n }\n }\n\n fetchProductData();\n\n return () => {\n cancelled = true;\n };\n }, [item, getProductData, getRefinedProduct]);\n\n /**\n * Removes product from wishlist\n */\n const removeProductFromWishlist = useCallback(\n async (showAlert: boolean = true): Promise<boolean> => {\n try {\n await removeProductsFromWishlist([item]);\n console.log(`Product ${productData?.sku} removed from wishlist!`);\n if (showAlert) {\n events.emit('wishlist/alert', {\n action: 'remove',\n item: { ...item, product: productData },\n });\n }\n return true;\n } catch (error) {\n console.error(\n `Product ${productData.sku} could not be removed from wishlist`,\n error\n );\n return false;\n }\n },\n [item, productData]\n );\n\n /**\n * Moves product to cart\n */\n const moveProductToCart = useCallback(async (): Promise<boolean> => {\n try {\n await moveProdToCart([\n {\n sku: productData.sku,\n quantity: 1,\n optionsUIDs: item.selectedOptions?.map(\n (option: { uid: any }) => option.uid\n ),\n enteredOptions: item.enteredOptions,\n },\n ]);\n console.log(`Product ${productData.sku} successfully moved to cart 🛒`);\n events.emit('wishlist/alert', {\n action: 'move',\n item: { ...item, product: productData },\n });\n return await removeProductFromWishlist(false);\n } catch (error) {\n console.error('Could not move product to cart: ', error);\n if (\n error.toString().includes('You need to choose options for your item.')\n ) {\n window.location.replace(routeProdDetailPage(productData));\n }\n return false;\n }\n }, [\n productData,\n item,\n moveProdToCart,\n routeProdDetailPage,\n removeProductFromWishlist,\n ]);\n\n if (!productData || !item) return null;\n\n return (\n <ProductItem\n item={{ ...item, product: productData }}\n onCartActionButtonClick={moveProductToCart}\n onTrashButtonClick={removeProductFromWishlist}\n routeProdDetailPage={routeProdDetailPage}\n imageNode={imageNode}\n />\n );\n};\n"],"names":["ProductItem","className","item","onCartActionButtonClick","onTrashButtonClick","routeProdDetailPage","imageNode","props","labels","useText","discounted","_c","_b","_a","_f","_e","_d","renderImage","jsx","ImageCarousel","renderPrices","_i","_h","_g","jsxs","Fragment","Price","_l","_k","_j","_o","_n","_m","_r","_q","_p","_u","_t","_s","classes","_x","_w","_v","_A","_z","_y","_D","_C","_B","_G","_F","_E","renderTrashButton","Button","Icon","Trash","renderMainActionButton","isProductReady","renderMoveToCartButton","renderCustomizeButton","areAllRequiredOptionsIncluded","selectedOptions","useMemo","opt","requiredOptions","options","required","option","renderOptions","selectedValue","Cart","children","images","carouselIndex","setCarouselIndex","useState","image","index","defaultProps","Image","_image","event","WishlistItem","getProductData","getRefinedProduct","moveProdToCart","productData","setProductData","useEffect","cancelled","fetchProductData","data","err","removeProductFromWishlist","useCallback","showAlert","removeProductsFromWishlist","events","error","moveProductToCart"],"mappings":"4gBA4CO,MAAMA,GAAmD,CAAC,CAC/D,UAAAC,EACA,KAAAC,EACA,wBAAAC,EACA,mBAAAC,EACA,oBAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAAM,mBACJ,MAAMC,EAASC,GAAQ,CACrB,cAAe,+BACf,eAAgB,gCAChB,mBAAoB,mCAAA,CACrB,EAEKC,IACJC,GAAAC,GAAAC,EAAAX,EAAK,UAAL,YAAAW,EAAc,SAAd,YAAAD,EAAsB,QAAtB,YAAAD,EAA6B,UAASG,GAAAC,GAAAC,EAAAd,EAAK,UAAL,YAAAc,EAAc,SAAd,YAAAD,EAAsB,UAAtB,YAAAD,EAA+B,QAEjEG,EAAc,IAAM,OAEtB,OAAAC,EAAC,IAAA,CACC,UAAU,8BACV,cAAY,8BACZ,KAAMb,EAAoBH,EAAK,OAAO,EAEtC,SAAAgB,EAACC,GAAA,CACC,SAAQN,EAAAX,EAAK,UAAL,YAAAW,EAAc,SAAU,CAAC,EACjC,UAAAP,CAAA,CAAA,CACF,CACF,CAEJ,EAEMc,EAAe,IAAM,+EACzB,QACET,GAAAC,GAAAC,EAAAX,EAAK,UAAL,YAAAW,EAAc,SAAd,YAAAD,EAAsB,QAAtB,YAAAD,EAA6B,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M,MAAMO,EAA0B,EAAK,QACrCK,EAAO,CACN,eAAA,MAAM,mCAAoCA,CAAK,EAErDA,EAAM,SAAA,EAAW,SAAS,2CAA2C,GAErE,OAAO,SAAS,QAAQ7F,EAAoBiF,CAAW,CAAC,EAEnD,EAAA,CACT,EACC,CACDA,EACApF,EACAmF,EACAhF,EACAwF,CAAA,CACD,EAED,MAAI,CAACP,GAAe,CAACpF,EAAa,KAGhCgB,EAAClB,GAAA,CACC,KAAM,CAAE,GAAGE,EAAM,QAASoF,CAAY,EACtC,wBAAyBa,EACzB,mBAAoBN,EACpB,oBAAAxF,EACA,UAAAC,CAAA,CACF,CAEJ"}
1
+ {"version":3,"file":"WishlistItem.js","sources":["/@dropins/storefront-wishlist/src/components/ProductItem/ProductItem.tsx","/@dropins/storefront-wishlist/src/components/ImageCarousel/ImageCarousel.tsx","/@dropins/storefront-wishlist/src/containers/WishlistItem/WishlistItem.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 { HTMLAttributes, useMemo } from 'preact/compat';\nimport { FunctionComponent, JSX } from 'preact';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport {\n Button,\n Icon,\n ImageNodeRenderProps,\n Price,\n} from '@adobe-commerce/elsie/components';\nimport { ImageCarousel } from '@/wishlist/components';\nimport { Item, Product } from '@/wishlist/data/models';\nimport { Cart, Trash } from '@adobe-commerce/elsie/icons';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport '@/wishlist/components/ProductItem/ProductItem.css';\n\nexport interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n item?: Item;\n onCartActionButtonClick?: () => boolean;\n onTrashButtonClick?: () => boolean;\n routeProdDetailPage: (product: Product) => string;\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const ProductItem: FunctionComponent<ProductItemProps> = ({\n className,\n item,\n onCartActionButtonClick,\n onTrashButtonClick,\n routeProdDetailPage,\n imageNode,\n ...props\n}) => {\n const labels = useText({\n cartActionBtn: 'ProductItem.CartActionButton',\n trashActionBtn: 'ProductItem.TrashActionButton',\n customizeActionBtn: 'ProductItem.CustomizeActionButton',\n });\n\n const discounted =\n item.product?.prices?.final?.amount < item.product?.prices?.regular?.amount;\n\n const renderImage = () => {\n return (\n <a\n className=\"wishlist-product-item-image\"\n data-testid=\"wishlist-product-item-image\"\n href={routeProdDetailPage(item.product)}\n >\n <ImageCarousel\n images={item.product?.images ?? []}\n imageNode={imageNode}\n />\n </a>\n );\n };\n\n const renderPrices = () => {\n if (\n item.product?.prices?.final?.amount === undefined &&\n item.product?.prices?.final?.maximumAmount !== undefined &&\n item.product?.prices?.final?.maximumAmount > 0\n ) {\n return (\n <>\n <Price\n className=\"wishlist-product-item-price\"\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.final?.minimumAmount}\n currency={item.product?.prices?.final?.currency}\n />\n -\n <Price\n className=\"wishlist-product-item-price\"\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.final?.maximumAmount}\n currency={item.product?.prices?.final?.currency}\n />\n </>\n );\n }\n return (\n <>\n <Price\n className={classes([\n 'wishlist-product-item-price',\n discounted ? 'strikethrough' : '',\n ])}\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.regular?.amount}\n currency={item.product?.prices?.regular?.currency}\n />\n\n {discounted && (\n <Price\n className=\"wishlist-product-item-discounted-price\"\n data-testid=\"wishlist-product-item-discounted-price\"\n amount={item.product?.prices?.final?.amount}\n currency={item.product?.prices?.final?.currency}\n />\n )}\n </>\n );\n };\n\n const renderTrashButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-remove-button\"\n className=\"wishlist-product-item-button__remove\"\n variant=\"tertiary\"\n onClick={() => onTrashButtonClick?.()}\n icon={\n <Icon\n source={Trash}\n size=\"24\"\n stroke=\"2\"\n viewBox=\"0 0 24 24\"\n aria-label={labels.trashActionBtn}\n />\n }\n />\n );\n };\n\n const renderMainActionButton = () => {\n return isProductReady()\n ? renderMoveToCartButton()\n : renderCustomizeButton();\n };\n\n const isProductReady = () => {\n if (item.product?.productType === 'complex') {\n return areAllRequiredOptionsIncluded();\n }\n return true;\n };\n\n const selectedOptions = useMemo(\n () => item.selectedOptions?.map((opt: any) => opt.uid) || [],\n [item.selectedOptions]\n );\n\n const requiredOptions = useMemo(() => {\n const options = item.product.options || [];\n const required = options.filter((option: any) => option.required);\n return required.length === 0 ? options : required;\n }, [item.product.options]);\n\n const areAllRequiredOptionsIncluded = (): boolean => {\n return requiredOptions.every((option: any) =>\n option.items?.some((item: any) => selectedOptions.includes(item.id))\n );\n };\n\n const renderOptions = () => {\n if (selectedOptions.length === 0) return null;\n\n return (\n <div className=\"wishlist-product-item-options\">\n {requiredOptions.map((option: any) => {\n const selectedValue = option.items?.find((item: any) =>\n selectedOptions.includes(item.id)\n );\n return selectedValue ? (\n <div key={option.type} className=\"wishlist-product-item-option\">\n <span className=\"wishlist-product-item-option__attribute\">\n {option.label}:\n </span>\n &nbsp;\n <span className=\"wishlist-product-item-option__label\">\n {selectedValue.label}\n </span>\n </div>\n ) : null;\n })}\n </div>\n );\n };\n\n const renderMoveToCartButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-move-to-cart-button\"\n size=\"medium\"\n type=\"submit\"\n icon={<Icon source={Cart} />}\n disabled={!item.product?.inStock}\n aria-label={labels.cartActionBtn}\n onClick={() => onCartActionButtonClick?.()}\n >\n {labels.cartActionBtn}\n </Button>\n );\n };\n\n const renderCustomizeButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-customize-button\"\n size=\"medium\"\n type=\"submit\"\n aria-label={labels.customizeActionBtn}\n href={routeProdDetailPage(item.product)}\n >\n {labels.customizeActionBtn}\n </Button>\n );\n };\n\n return (\n <div {...props} className={classes(['wishlist-product-item', className])}>\n <div className=\"wishlist-product-item__content\">\n {renderImage()}\n <div\n className=\"wishlist-product-item__title\"\n data-testid=\"wishlist-product-item-header\"\n >\n <a\n className=\"wishlist-product-item-name\"\n data-testid=\"wishlist-product-item-name\"\n href={routeProdDetailPage(item.product)}\n >\n {item.product?.name}\n </a>\n\n {renderTrashButton()}\n {renderPrices()}\n </div>\n {renderOptions()}\n {renderMainActionButton()}\n </div>\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 { FunctionComponent, JSX } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { Image, ImageNodeRenderProps } from '@adobe-commerce/elsie/components';\nimport { useState } from 'react';\n\nimport '@/wishlist/components/ImageCarousel/ImageCarousel.css';\n\nexport interface ImageCarouselProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n children?: any;\n images: Image[];\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const ImageCarousel: FunctionComponent<ImageCarouselProps> = ({\n className,\n children,\n images,\n imageNode,\n ...props\n}) => {\n const [carouselIndex, setCarouselIndex] = useState(0);\n\n return (\n <>\n <div {...props} className={classes(['image-carousel', className])}>\n <div\n className={classes([\n 'overflow-hidden relative max-w-[200px]',\n className,\n ])}\n >\n {images?.map(\n (image: ImageCarouselProps['images'][0], index: number) => {\n const defaultProps = {\n className: classes(['image-carousel-image', className]),\n src: image.url,\n alt: image.label,\n } as const;\n\n if (index !== carouselIndex) {\n return null;\n }\n\n return typeof imageNode === 'function'\n ? imageNode({\n defaultImageProps: defaultProps,\n })\n : imageNode || <Image {...defaultProps} />;\n }\n )}\n </div>\n </div>\n {images?.length > 1 && (\n <div className={classes(['absolute', 'image-switcher-area'])}>\n {images?.map(\n (_image: ImageCarouselProps['images'][0], index: number) => {\n return (\n <span\n className={classes([\n 'image-switcher',\n carouselIndex === index\n ? 'image-switcher-active'\n : 'image-switcher-inactive',\n ])}\n key={index}\n onClick={(event: MouseEvent | TouchEvent) => {\n setCarouselIndex(index);\n event.preventDefault(); // prevent navigate on click since ImageCarousel is wrapped in a link\n event.stopPropagation();\n }}\n />\n );\n }\n )}\n </div>\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 {\n HTMLAttributes,\n useEffect,\n useState,\n useCallback,\n} from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { ProductItem } from '@/wishlist/components';\nimport { Item, Product } from '@/wishlist/data/models';\nimport { removeProductsFromWishlist } from '@/wishlist/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ImageNodeRenderProps } from '@adobe-commerce/elsie/components';\nimport { JSX } from 'preact';\n\nexport interface WishlistItemProps extends HTMLAttributes<HTMLDivElement> {\n item: Item;\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 moveProdToCart: (\n products: {\n sku: string;\n quantity: number;\n optionsUIDs?: [];\n enteredOptions?: [];\n }[]\n ) => Promise<any>;\n routeProdDetailPage: (product: Product) => string;\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const WishlistItem: Container<WishlistItemProps> = ({\n item,\n getProductData,\n getRefinedProduct,\n moveProdToCart,\n routeProdDetailPage,\n imageNode,\n}: WishlistItemProps) => {\n const [productData, setProductData] = useState<Product | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n async function fetchProductData() {\n try {\n let data: Product | null;\n if (getRefinedProduct && item?.selectedOptions?.length > 0) {\n data = await getRefinedProduct(\n item.product.sku,\n item.selectedOptions.map((option: { uid: any }) => option.uid)\n );\n } else {\n data = getProductData\n ? await getProductData(item?.product.sku)\n : item?.product;\n }\n if (!cancelled) setProductData(data);\n } catch (err) {\n if (!cancelled) {\n console.error('Failed to fetch product data:', err);\n }\n }\n }\n\n fetchProductData();\n\n return () => {\n cancelled = true;\n };\n }, [item, getProductData, getRefinedProduct]);\n\n /**\n * Removes product from wishlist\n */\n const removeProductFromWishlist = useCallback(\n async (showAlert: boolean = true): Promise<boolean> => {\n try {\n await removeProductsFromWishlist([item]);\n console.log(`Product ${productData?.sku} removed from wishlist!`);\n if (showAlert) {\n events.emit('wishlist/alert', {\n action: 'remove',\n item: { ...item, product: productData },\n });\n }\n return true;\n } catch (error) {\n console.error(\n `Product ${productData.sku} could not be removed from wishlist`,\n error\n );\n return false;\n }\n },\n [item, productData]\n );\n\n /**\n * Moves product to cart\n */\n const moveProductToCart = useCallback(async (): Promise<boolean> => {\n try {\n await moveProdToCart([\n {\n sku: productData.sku,\n quantity: 1,\n optionsUIDs: item.selectedOptions?.map(\n (option: { uid: any }) => option.uid\n ),\n enteredOptions: item.enteredOptions,\n },\n ]);\n console.log(`Product ${productData.sku} successfully moved to cart 🛒`);\n events.emit('wishlist/alert', {\n action: 'move',\n item: { ...item, product: productData },\n });\n return await removeProductFromWishlist(false);\n } catch (error) {\n console.error('Could not move product to cart: ', error);\n if (\n error.toString().includes('You need to choose options for your item.')\n ) {\n window.location.replace(routeProdDetailPage(productData));\n }\n return false;\n }\n }, [\n productData,\n item,\n moveProdToCart,\n routeProdDetailPage,\n removeProductFromWishlist,\n ]);\n\n if (!productData || !item) return null;\n\n return (\n <ProductItem\n item={{ ...item, product: productData }}\n onCartActionButtonClick={moveProductToCart}\n onTrashButtonClick={removeProductFromWishlist}\n routeProdDetailPage={routeProdDetailPage}\n imageNode={imageNode}\n />\n );\n};\n"],"names":["ProductItem","className","item","onCartActionButtonClick","onTrashButtonClick","routeProdDetailPage","imageNode","props","labels","useText","discounted","_c","_b","_a","_f","_e","_d","renderImage","jsx","ImageCarousel","renderPrices","_i","_h","_g","jsxs","Fragment","Price","_l","_k","_j","_o","_n","_m","_r","_q","_p","_u","_t","_s","classes","_x","_w","_v","_A","_z","_y","_D","_C","_B","_G","_F","_E","renderTrashButton","Button","Icon","Trash","renderMainActionButton","isProductReady","renderMoveToCartButton","renderCustomizeButton","areAllRequiredOptionsIncluded","selectedOptions","useMemo","opt","requiredOptions","options","required","option","renderOptions","selectedValue","Cart","children","images","carouselIndex","setCarouselIndex","useState","image","index","defaultProps","Image","_image","event","WishlistItem","getProductData","getRefinedProduct","moveProdToCart","productData","setProductData","useEffect","cancelled","fetchProductData","data","err","removeProductFromWishlist","useCallback","showAlert","removeProductsFromWishlist","events","error","moveProductToCart"],"mappings":"4gBA4CO,MAAMA,GAAmD,CAAC,CAC/D,UAAAC,EACA,KAAAC,EACA,wBAAAC,EACA,mBAAAC,EACA,oBAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAAM,mBACJ,MAAMC,EAASC,GAAQ,CACrB,cAAe,+BACf,eAAgB,gCAChB,mBAAoB,mCAAA,CACrB,EAEKC,IACJC,GAAAC,GAAAC,EAAAX,EAAK,UAAL,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EAAM,QAASoF,CAAY,CAAA,CACvC,EAEI,SACAY,EAAO,CACN,eAAA,MACN,WAAWZ,EAAY,GAAG,sCAC1BY,CACF,EACO,EAAA,CAEX,EACA,CAAChG,EAAMoF,CAAW,CACpB,EAKMa,EAAoBL,GAAY,SAA8B,OAC9D,GAAA,CACF,aAAMT,EAAe,CACnB,CACE,IAAKC,EAAY,IACjB,SAAU,EACV,aAAazE,EAAAX,EAAK,kBAAL,YAAAW,EAAsB,IAChCsD,GAAyBA,EAAO,KAEnC,eAAgBjE,EAAK,cAAA,CACvB,CACD,EACD,QAAQ,IAAI,WAAWoF,EAAY,GAAG,gCAAgC,EACtEW,GAAO,KAAK,iBAAkB,CAC5B,OAAQ,OACR,KAAM,CAAE,GAAG/F,EAAM,QAASoF,CAAY,CAAA,CACvC,EACM,MAAMO,EAA0B,EAAK,QACrCK,EAAO,CACN,eAAA,MAAM,mCAAoCA,CAAK,EAErDA,EAAM,SAAA,EAAW,SAAS,2CAA2C,GAErE,OAAO,SAAS,QAAQ7F,EAAoBiF,CAAW,CAAC,EAEnD,EAAA,CACT,EACC,CACDA,EACApF,EACAmF,EACAhF,EACAwF,CAAA,CACD,EAED,MAAI,CAACP,GAAe,CAACpF,EAAa,KAGhCgB,EAAClB,GAAA,CACC,KAAM,CAAE,GAAGE,EAAM,QAASoF,CAAY,EACtC,wBAAyBa,EACzB,mBAAoBN,EACpB,oBAAAxF,EACA,UAAAC,CAAA,CACF,CAEJ"}
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{Initializer as y}from"@dropins/tools/lib.js";import{events as r}from"@dropins/tools/event-bus.js";import{j as A,s as e,f as I,h as f,g as h,i as T,k as G}from"./removeProductsFromWishlist.js";const g=new y({init:async t=>{const s={isGuestWishlistEnabled:!1,...t};g.config.setConfig(s),p().catch(console.error)},listeners:()=>[r.on("wishlist/data",t=>{A(t)},{eager:!0}),r.on("authenticated",async t=>{if(e.authenticated&&!t&&r.emit("wishlist/reset",void 0),t&&!e.authenticated){e.authenticated=t;const s=await p().catch(console.error);s&&Z(s)}},{eager:!0}),r.on("wishlist/reset",()=>{B().catch(console.error),r.emit("wishlist/data",null)})]}),V=g.config;function N(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 w(t,s){return t?{id:t.id,updated_at:t.updated_at,sharing_code:t.sharing_code,items_count:t.items_count,items:L(t,s??[])}:null}function L(t,s){var i,a;return(a=(i=t==null?void 0:t.items_v2)==null?void 0:i.items)!=null&&a.length?t.items_v2.items.map(n=>{const l=R(n);return{id:n.id,quantity:n.quantity,description:n.description,added_at:n.added_at,enteredOptions:s,selectedOptions:l,product:{sku:n.product.sku}}}):[]}function R(t){return t.__typename==="ConfigurableWishlistItem"?t.configurable_options?t.configurable_options.map(s=>({uid:s.configurable_product_option_value_uid})):[]:[]}const D=`
3
+ import{Initializer as y}from"@dropins/tools/lib.js";import{events as r}from"@dropins/tools/event-bus.js";import{j as A,s as e,f as I,h as p,g as h,i as T,k as G}from"./removeProductsFromWishlist.js";const g=new y({init:async t=>{const s={isGuestWishlistEnabled:!1,...t};g.config.setConfig(s),f().catch(console.error)},listeners:()=>[r.on("wishlist/data",t=>{A(t)},{eager:!0}),r.on("authenticated",async t=>{if(e.authenticated&&!t&&r.emit("wishlist/reset",void 0),t&&!e.authenticated){e.authenticated=t;const s=await f().catch(console.error);s&&Z(s)}},{eager:!0}),r.on("wishlist/reset",()=>{B().catch(console.error),r.emit("wishlist/data",null)})]}),V=g.config;function N(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 w(t,s){return t?{id:t.id,updated_at:t.updated_at,sharing_code:t.sharing_code,items_count:t.items_count,items:L(t,s??[])}:null}function L(t,s){var i,a;return(a=(i=t==null?void 0:t.items_v2)==null?void 0:i.items)!=null&&a.length?t.items_v2.items.map(n=>{const l=R(n);return{id:n.id,quantity:n.quantity,description:n.description,added_at:n.added_at,enteredOptions:s,selectedOptions:l,product:{sku:n.product.sku}}}):[]}function R(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(i=>i.values??[]).map(i=>({uid:i.uid})):[]}const D=`
4
4
  query STORE_CONFIG_QUERY {
5
5
  storeConfig {
6
6
  magento_wishlist_general_is_enabled
@@ -8,7 +8,7 @@ query STORE_CONFIG_QUERY {
8
8
  maximum_number_of_wishlists
9
9
  }
10
10
  }
11
- `,C=async()=>I(D,{method:"GET",cache:"force-cache"}).then(({errors:t,data:s})=>t?f(t):N(s)),U=`
11
+ `,v=async()=>I(D,{method:"GET",cache:"force-cache"}).then(({errors:t,data:s})=>t?p(t):N(s)),C=`
12
12
  fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
13
13
  type
14
14
  customizable_option_uid
@@ -24,7 +24,7 @@ query STORE_CONFIG_QUERY {
24
24
  }
25
25
  }
26
26
  }
27
- `,v=`
27
+ `,U=`
28
28
  ... on ConfigurableWishlistItem {
29
29
  configurable_options {
30
30
  option_label
@@ -91,7 +91,7 @@ fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
91
91
  product {
92
92
  sku
93
93
  }
94
- ${v}
94
+ ${U}
95
95
  ${F}
96
96
  ${k}
97
97
  ${H}
@@ -100,7 +100,7 @@ fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
100
100
  }
101
101
  }
102
102
 
103
- ${U}
103
+ ${C}
104
104
  `,S=`
105
105
  fragment WISHLIST_FRAGMENT on Wishlist {
106
106
  id
@@ -125,7 +125,7 @@ ${P}
125
125
  }
126
126
 
127
127
  ${S}
128
- `,q=async()=>e.authenticated?I($).then(({errors:t,data:s})=>{var i;return t?f(t):(i=s==null?void 0:s.customer)!=null&&i.wishlists?s.customer.wishlists.map(a=>w(a)):null}):h(),z=`
128
+ `,q=async()=>e.authenticated?I($).then(({errors:t,data:s})=>{var i;return t?p(t):(i=s==null?void 0:s.customer)!=null&&i.wishlists?s.customer.wishlists.map(a=>w(a)):null}):h(),z=`
129
129
  mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
130
130
  $wishlistId: ID!,
131
131
  $wishlistItems: [WishlistItemInput!]!,
@@ -144,5 +144,5 @@ ${P}
144
144
  }
145
145
  }
146
146
  ${S}
147
- `,x=async t=>{var a,n,l,d,m;if(!t)return null;const s=h();let i={id:(s==null?void 0:s.id)??"",updated_at:"",sharing_code:"",items_count:0,items:(s==null?void 0:s.items)??[]};for(const o of t){if((a=i.items)==null?void 0:a.some(_=>T(_,{sku:o.sku,optionUIDs:o.optionsUIDs})))continue;const c=o.optionsUIDs?(n=o.optionsUIDs)==null?void 0:n.map(_=>({uid:_})):[];i.items=[...i.items,{id:crypto.randomUUID(),quantity:o.quantity,selectedOptions:c,enteredOptions:o.enteredOptions??[],product:{sku:o.sku}}]}if(i.items_count=(l=i.items)==null?void 0:l.length,r.emit("wishlist/data",i),e.authenticated){if(!e.wishlistId)throw r.emit("wishlist/data",s),Error("Wishlist ID is not set");const o={wishlistId:e.wishlistId,wishlistItems:t.map(({sku:W,quantity:O,optionsUIDs:b,enteredOptions:M})=>({sku:W,quantity:O,selected_options:b,entered_options:M}))},{errors:u,data:c}=await I(z,{variables:o}),_=[...((d=c==null?void 0:c.addProductsToWishlist)==null?void 0:d.user_errors)??[],...u??[]];if(_.length>0)return r.emit("wishlist/data",s),f(_);const E=w(c.addProductsToWishlist.wishlist,((m=t[0])==null?void 0:m.enteredOptions)??[]);r.emit("wishlist/data",E)}return null},B=()=>(e.wishlistId=null,e.authenticated=!1,Promise.resolve(null)),p=async()=>{if(e.initializing)return null;e.initializing=!0,e.config||(e.config=await C());const t=e.authenticated?await Q():await Y();return r.emit("wishlist/initialized",t),r.emit("wishlist/data",t),e.initializing=!1,t};async function Q(){const t=await q(),s=t?t[0]:null;return s?(e.wishlistId=s.id,s):null}async function Y(){try{return await h()}catch(t){throw console.error(t),t}}const Z=async t=>{var n;if(!t)return null;const s=h(!0),i=[];if((n=s==null?void 0:s.items)==null||n.forEach(l=>{var o;const d=((o=l.selectedOptions)==null?void 0:o.map(u=>u.uid))||[];if(!t.items.some(u=>T(u,{sku:l.product.sku,optionUIDs:d}))){const u={sku:l.product.sku,quantity:1,optionsUIDs:d,enteredOptions:l.enteredOptions||void 0};i.push(u)}}),i.length===0)return null;const a=await x(i);return G(),a};export{P as W,x as a,S as b,V as c,q as d,p as e,Q as f,C as g,Y as h,g as i,Z as m,B as r,w as t};
147
+ `,x=async t=>{var a,n,l,d,m;if(!t)return null;const s=h();let i={id:(s==null?void 0:s.id)??"",updated_at:"",sharing_code:"",items_count:0,items:(s==null?void 0:s.items)??[]};for(const o of t){if((a=i.items)==null?void 0:a.some(_=>T(_,{sku:o.sku,optionUIDs:o.optionsUIDs})))continue;const c=o.optionsUIDs?(n=o.optionsUIDs)==null?void 0:n.map(_=>({uid:_})):[];i.items=[...i.items,{id:crypto.randomUUID(),quantity:o.quantity,selectedOptions:c,enteredOptions:o.enteredOptions??[],product:{sku:o.sku}}]}if(i.items_count=(l=i.items)==null?void 0:l.length,r.emit("wishlist/data",i),e.authenticated){if(!e.wishlistId)throw r.emit("wishlist/data",s),Error("Wishlist ID is not set");const o={wishlistId:e.wishlistId,wishlistItems:t.map(({sku:W,quantity:b,optionsUIDs:O,enteredOptions:M})=>({sku:W,quantity:b,selected_options:O,entered_options:M}))},{errors:u,data:c}=await I(z,{variables:o}),_=[...((d=c==null?void 0:c.addProductsToWishlist)==null?void 0:d.user_errors)??[],...u??[]];if(_.length>0)return r.emit("wishlist/data",s),p(_);const E=w(c.addProductsToWishlist.wishlist,((m=t[0])==null?void 0:m.enteredOptions)??[]);r.emit("wishlist/data",E)}return null},B=()=>(e.wishlistId=null,e.authenticated=!1,Promise.resolve(null)),f=async()=>{if(e.initializing)return null;e.initializing=!0,e.config||(e.config=await v());const t=e.authenticated?await Q():await Y();return r.emit("wishlist/initialized",t),r.emit("wishlist/data",t),e.initializing=!1,t};async function Q(){const t=await q(),s=t?t[0]:null;return s?(e.wishlistId=s.id,s):null}async function Y(){try{return await h()}catch(t){throw console.error(t),t}}const Z=async t=>{var n;if(!t)return null;const s=h(!0),i=[];if((n=s==null?void 0:s.items)==null||n.forEach(l=>{var o;const d=((o=l.selectedOptions)==null?void 0:o.map(u=>u.uid))||[];if(!t.items.some(u=>T(u,{sku:l.product.sku,optionUIDs:d}))){const u={sku:l.product.sku,quantity:1,optionsUIDs:d,enteredOptions:l.enteredOptions||void 0};i.push(u)}}),i.length===0)return null;const a=await x(i);return G(),a};export{P as W,x as a,S as b,V as c,q as d,f as e,Q as f,v as g,Y as h,g as i,Z as m,B as r,w as t};
148
148
  //# sourceMappingURL=mergeWishlists.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeWishlists.js","sources":["/@dropins/storefront-wishlist/src/api/initialize/initialize.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-store-config.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-wishlist.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/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/resetWishlist/resetWishlist.ts","/@dropins/storefront-wishlist/src/api/initializeWishlist/initializeWishlist.ts","/@dropins/storefront-wishlist/src/api/mergeWishlists/mergeWishlists.ts"],"sourcesContent":["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};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = { isGuestWishlistEnabled: false, ...config };\n\n initialize.config.setConfig(defaultConfig);\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 { 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 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\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_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 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":["initialize","Initializer","config","defaultConfig","initializeWishlist","events","payload","setPersistedWishlistData","authenticated","state","wishlist","mergeWishlists","resetWishlist","transformStoreConfig","data","transformWishlist","enteredOptions","transformItems","_b","_a","item","selectedOptions","getSelectedOptions","option","STORE_CONFIG_QUERY","getStoreConfig","fetchGraphQl","errors","handleFetchError","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_WISHLISTS_QUERY","getWishlists","getPersistedWishlistData","ADD_PRODUCTS_TO_WISHLIST_MUTATION","addProductsToWishlist","items","updatedWishlist","wishlistItem","isMatchingWishlistItem","_c","variables","sku","quantity","optionsUIDs","_errors","_d","_e","getDefaultWishlist","getGuestWishlist","wishlists","error","guestWishlist","itemsToMerge","optionUIDs","mergeItem","result","clearPersistedLocalStorage"],"mappings":"uMAgBa,MAAAA,EAAa,IAAIC,EAAyB,CACrD,KAAM,MAAOC,GAAW,CACtB,MAAMC,EAAgB,CAAE,uBAAwB,GAAO,GAAGD,CAAO,EAEtDF,EAAA,OAAO,UAAUG,CAAa,EACtBC,IAAE,MAAM,QAAQ,KAAK,CAC1C,EAEA,UAAW,IAAM,CACfC,EAAO,GACL,gBACCC,GAAY,CACXC,EAAyBD,CAAO,CAClC,EACA,CAAE,MAAO,EAAK,CAChB,EACAD,EAAO,GACL,gBACA,MAAOG,GAAkB,CAMnB,GALAC,EAAM,eAAiB,CAACD,GAEnBH,EAAA,KAAK,iBAAkB,MAAS,EAGrCG,GAAiB,CAACC,EAAM,cAAe,CACzCA,EAAM,cAAgBD,EACtB,MAAME,EAAW,MAAMN,EAAA,EAAqB,MAAM,QAAQ,KAAK,EAC3DM,GACFC,EAAeD,CAAQ,CACzB,CAEJ,EACA,CAAE,MAAO,EAAK,CAChB,EACAL,EAAO,GAAG,iBAAkB,IAAM,CAClBO,IAAE,MAAM,QAAQ,KAAK,EAC5BP,EAAA,KAAK,gBAAiB,IAAI,CAClC,CAAA,CAAA,CAEL,CAAC,EAEYH,EAASF,EAAW,OCtC1B,SAASa,EAAqBC,EAAoC,CACnE,OAACA,EAEE,CACL,kBAAmBA,EAAK,YAAY,oCACpC,8BAA+BA,EAAK,YAAY,0BAChD,kBAAmBA,EAAK,YAAY,2BACtC,EANkB,IAOpB,CCTgB,SAAAC,EACdD,EACAE,EACiB,CACb,OAACF,EAEE,CACL,GAAIA,EAAK,GACT,WAAYA,EAAK,WACjB,aAAcA,EAAK,aACnB,YAAaA,EAAK,YAClB,MAAOG,EAAeH,EAAME,GAAkB,CAAE,CAAA,CAClD,EARkB,IASpB,CAEA,SAASC,EACPH,EACAE,EACQ,SAC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AK,gBAAkB,MACzC,EAEAsC,EAAa,KAAKE,CAAS,CAAA,CAC7B,GAGEF,EAAa,SAAW,EACnB,OAAA,KAGH,MAAAG,EAAS,MAAMrB,EAAsBkB,CAAY,EAC5B,OAAAI,EAAA,EACpBD,CACT"}
1
+ {"version":3,"file":"mergeWishlists.js","sources":["/@dropins/storefront-wishlist/src/api/initialize/initialize.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-store-config.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-wishlist.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/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/resetWishlist/resetWishlist.ts","/@dropins/storefront-wishlist/src/api/initializeWishlist/initializeWishlist.ts","/@dropins/storefront-wishlist/src/api/mergeWishlists/mergeWishlists.ts"],"sourcesContent":["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};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = { isGuestWishlistEnabled: false, ...config };\n\n initialize.config.setConfig(defaultConfig);\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 { 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\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_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 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":["initialize","Initializer","config","defaultConfig","initializeWishlist","events","payload","setPersistedWishlistData","authenticated","state","wishlist","mergeWishlists","resetWishlist","transformStoreConfig","data","transformWishlist","enteredOptions","transformItems","_b","_a","item","selectedOptions","getSelectedOptions","option","value","STORE_CONFIG_QUERY","getStoreConfig","fetchGraphQl","errors","handleFetchError","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_WISHLISTS_QUERY","getWishlists","getPersistedWishlistData","ADD_PRODUCTS_TO_WISHLIST_MUTATION","addProductsToWishlist","items","updatedWishlist","wishlistItem","isMatchingWishlistItem","_c","variables","sku","quantity","optionsUIDs","_errors","_d","_e","getDefaultWishlist","getGuestWishlist","wishlists","error","guestWishlist","itemsToMerge","optionUIDs","mergeItem","result","clearPersistedLocalStorage"],"mappings":"uMAgBa,MAAAA,EAAa,IAAIC,EAAyB,CACrD,KAAM,MAAOC,GAAW,CACtB,MAAMC,EAAgB,CAAE,uBAAwB,GAAO,GAAGD,CAAO,EAEtDF,EAAA,OAAO,UAAUG,CAAa,EACtBC,IAAE,MAAM,QAAQ,KAAK,CAC1C,EAEA,UAAW,IAAM,CACfC,EAAO,GACL,gBACCC,GAAY,CACXC,EAAyBD,CAAO,CAClC,EACA,CAAE,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efront-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/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-wishlist/src/lib/fetch-error.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/graphql/removeProductsFromWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/removeProductsFromWishlist.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 currentPage?: number;\n pageSize?: number;\n};\n\nconst _state: State = (() => {\n return {\n wishlistId: null,\n authenticated: false,\n isLoading: true,\n };\n})();\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 // only update cookie if value has changed\n if (value === state.wishlistId) return true;\n\n if (value === null) {\n // remove cookie\n document.cookie = `DROPIN__WISHLIST__WISHLIST-ID=; 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 // set cookie\n document.cookie = `DROPIN__WISHLIST__WISHLIST-ID=${value}; expires=${expires.toUTCString()}; path=/`;\n }\n\n return Reflect.set(target, key, value);\n },\n get(target, key) {\n if (key === 'wishlistId') {\n // get value from cookie\n return getCookie('DROPIN__WISHLIST__WISHLIST-ID');\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 = 'DROPIN__WISHLIST__WISHLIST__DATA';\n\nexport function setPersistedWishlistData(data: Wishlist | null) {\n const $storage = state.authenticated ? sessionStorage : localStorage;\n if (data) {\n try {\n $storage.setItem(WISHLIST_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(WISHLIST_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 try {\n const wishlist = $storage.getItem(WISHLIST_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(WISHLIST_KEY);\n}\n\nexport function getWishlistItemFromStorage(\n productSku: string,\n optionUIDs: string[] = []\n) {\n const storage = state.authenticated ? sessionStorage : localStorage;\n const wishlist = storage.getItem(WISHLIST_KEY)\n ? JSON.parse(String(storage.getItem(WISHLIST_KEY)))\n : { id: '', items: [] };\n\n return wishlist?.items?.find((item: any) =>\n isMatchingWishlistItem(item, {\n sku: productSku,\n optionUIDs,\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 '@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\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 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"],"names":["getCookie","cookieName","cookies","cookie","_state","state","target","key","value","expires","isMatchingWishlistItem","wishlistItem","product","wishlistItemOptions","_a","option","uid","productOptionUIDs","WISHLIST_KEY","setPersistedWishlistData","data","$storage","error","isQuotaExceededError","getPersistedWishlistData","guest","wishlist","clearPersistedLocalStorage","getWishlistItemFromStorage","productSku","optionUIDs","storage","item","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","handleFetchError","errors","errorMessage","e","REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION","removeProductsFromWishlist","items","updatedWishlist","itemIds","_errors","_b","events","_c"],"mappings":"oHAiBO,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,EAAE,UAAUF,EAAW,OAAS,CAAC,EAKjD,OAAA,IACT,CCDA,MAAMG,EACG,CACL,WAAY,KACZ,cAAe,GACf,UAAW,EACb,EAIWC,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAIE,EAAQC,EAAKC,EAAO,CAItB,GAFAF,EAAOC,CAAG,EAAIC,EAEV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AAAlB,EAAsB,IAAKC,GAAgBA,EAAO,IAC/D,CAAA,EACH,EAEJ,EAEA,GAAIV,EAAM,cAAe,CACnB,GAAA,CAACA,EAAM,WACT,MAAM,MAAM,wBAAwB,EAGtC,MAAM2C,EAAUF,EAAM,IAAKd,GAASA,EAAK,EAAE,EACrC,CAAE,OAAAS,EAAQ,KAAArB,CAAK,EAAI,MAAMiB,EAC7BO,EACA,CACE,UAAW,CAAE,WAAYvC,EAAM,WAAY,iBAAkB2C,CAAQ,CAAA,CAEzE,EAEMC,EAAU,CACd,KAAIC,EAAA9B,GAAA,YAAAA,EAAM,6BAAN,YAAA8B,EAAkC,cAAe,CAAC,EACtD,GAAIT,GAAU,CAAA,CAChB,EAGI,GAAAQ,EAAQ,OAAS,EACZ,OAAAE,EAAA,KAAK,gBAAiBzB,CAAQ,EAC9Bc,EAAiBS,CAAO,CACjC,CAGc,OAAAF,EAAA,aAAcK,EAAAL,EAAgB,QAAhB,YAAAK,EAAuB,OAC9CD,EAAA,KAAK,gBAAiBJ,CAAe,EAErC,IACT"}
1
+ {"version":3,"file":"removeProductsFromWishlist.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/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-wishlist/src/lib/fetch-error.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/graphql/removeProductsFromWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/removeProductsFromWishlist.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};\n\nconst _state: State = (() => {\n return {\n wishlistId: null,\n authenticated: false,\n isLoading: true,\n };\n})();\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 // only update cookie if value has changed\n if (value === state.wishlistId) return true;\n\n if (value === null) {\n // remove cookie\n document.cookie = `DROPIN__WISHLIST__WISHLIST-ID=; 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 // set cookie\n document.cookie = `DROPIN__WISHLIST__WISHLIST-ID=${value}; expires=${expires.toUTCString()}; path=/`;\n }\n\n return Reflect.set(target, key, value);\n },\n get(target, key) {\n if (key === 'wishlistId') {\n // get value from cookie\n return getCookie('DROPIN__WISHLIST__WISHLIST-ID');\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 = 'DROPIN__WISHLIST__WISHLIST__DATA';\n\nexport function setPersistedWishlistData(data: Wishlist | null) {\n const $storage = state.authenticated ? sessionStorage : localStorage;\n if (data) {\n try {\n $storage.setItem(WISHLIST_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(WISHLIST_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 try {\n const wishlist = $storage.getItem(WISHLIST_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(WISHLIST_KEY);\n}\n\nexport function getWishlistItemFromStorage(\n productSku: string,\n optionUIDs: string[] = []\n) {\n const storage = state.authenticated ? sessionStorage : localStorage;\n const wishlist = storage.getItem(WISHLIST_KEY)\n ? JSON.parse(String(storage.getItem(WISHLIST_KEY)))\n : { id: '', items: [] };\n\n return wishlist?.items?.find((item: any) =>\n isMatchingWishlistItem(item, {\n sku: productSku,\n optionUIDs,\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 '@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\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 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"],"names":["getCookie","cookieName","cookies","cookie","_state","state","target","key","value","expires","isMatchingWishlistItem","wishlistItem","product","wishlistItemOptions","_a","option","uid","productOptionUIDs","WISHLIST_KEY","setPersistedWishlistData","data","$storage","error","isQuotaExceededError","getPersistedWishlistData","guest","wishlist","clearPersistedLocalStorage","getWishlistItemFromStorage","productSku","optionUIDs","storage","item","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","handleFetchError","errors","errorMessage","e","REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION","removeProductsFromWishlist","items","updatedWishlist","itemIds","_errors","_b","events","_c"],"mappings":"oHAiBO,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,EAAE,UAAUF,EAAW,OAAS,CAAC,EAKjD,OAAA,IACT,CCHA,MAAMG,EACG,CACL,WAAY,KACZ,cAAe,GACf,UAAW,EACb,EAIWC,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAIE,EAAQC,EAAKC,EAAO,CAItB,GAFAF,EAAOC,CAAG,EAAIC,EAEVD,IAAQ,aAAc,CAEpB,GAAAC,IAAUH,EAAM,WAAmB,MAAA,GAEvC,GAAIG,IAAU,KAEZ,gBAAS,OAAS,gFACX,GAIH,MAAAC,MAAc,KACpBA,EAAQ,QAAQA,EAAQ,QAAQ,EAAI,EAAE,EAEtC,SAAS,OAAS,iCAAiCD,CAAK,aAAaC,EAAQ,YAAa,CAAA,UAAA,CAG5F,OAAO,QAAQ,IAAIH,EAAQC,EAAKC,CAAK,CACvC,EACA,IAAIF,EAAQC,EAAK,CACf,OAAIA,IAAQ,aAEHP,EAAU,+BAA+B,EAG3CM,EAAOC,CAAkB,CAAA,CAEpC,CAAC,EC3Ce,SAAAG,EACdC,EACAC,EACS,OAET,GAAID,EAAa,QAAQ,MAAQC,EAAQ,IAChC,MAAA,GAIT,MAAMC,IACJC,EAAAH,EAAa,k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AC9Bc,EAAiBS,CAAO,CACjC,CAGc,OAAAF,EAAA,aAAcK,EAAAL,EAAgB,QAAhB,YAAAK,EAAuB,OAC9CD,EAAA,KAAK,gBAAiBJ,CAAe,EAErC,IACT"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 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 v}from"@dropins/tools/preact-compat.js";import{Button as F,Icon as I}from"@dropins/tools/components.js";import{events as a}from"@dropins/tools/event-bus.js";import{s as P,g as j,i as x,r as A}from"../chunks/removeProductsFromWishlist.js";import{c as M,a as R}from"../chunks/mergeWishlists.js";import{S as q}from"../chunks/HeartFilled.js";import{S as H}from"../chunks/Heart.js";import{useText as N}from"@dropins/tools/i18n.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const $=({product:i,iconWishlisted:W,iconToWishlist:g,size:d,variant:D,disabled:u,labelToWishlist:U,labelWishlisted:k,onClick:w,removeProdFromCart:f})=>{const[O,b]=h(P.authenticated),[n,o]=h(!1),[L,S]=h(null),{isGuestWishlistEnabled:T}=M.getConfig(),c=N({addToWishlist:"Wishlist.Wishlist.ariaLabelAddToWishlist",removeFromWishlist:"Wishlist.Wishlist.ariaLabelRemoveFromWishlist"}),l=E(()=>{var t;const e=j(),s=(t=e==null?void 0:e.items)==null?void 0:t.find(m=>x(m,{sku:i.topLevelSku??i.sku,optionUIDs:i.optionUIDs??(i.selectedOptionsUIDs?Object.values(i.selectedOptionsUIDs):void 0)}));S(s??null),o(!!s)},[i.topLevelSku,i.sku,i.optionUIDs,i.selectedOptionsUIDs]);v(()=>{l()},[l]),v(()=>{const e=m=>b(m),s=a.on("authenticated",e),t=a.on("wishlist/data",l);return()=>{s==null||s.off(),t==null||t.off()}},[l]);const y=async()=>{var e;if(n){try{await A([L])}catch{return a.emit("wishlist/alert",{action:"removeError",item:{product:i}}),null}o(!1),a.emit("wishlist/alert",{action:"remove",item:{product:i}})}else{try{await R([{sku:i.topLevelSku??i.sku,quantity:1,optionsUIDs:i.optionUIDs??(i.selectedOptionsUIDs?Object.values(i.selectedOptionsUIDs):void 0),enteredOptions:(e=i.options)!=null&&e.items?i.options.items.filter(s=>s.selected).map(s=>({uid:s.uid,value:s.value})):void 0}])}catch{return a.emit("wishlist/alert",{action:"addError",item:{product:i}}),null}o(!0),a.emit("wishlist/alert",{action:"add",item:{product:i}}),f&&await f([{uid:i.uid,quantity:0}])}};if(!O&&!T)return null;const C=n?c.removeFromWishlist.replace("{PRODUCT_NAME}",i==null?void 0:i.name):c.addToWishlist.replace("{PRODUCT_NAME}",i==null?void 0:i.name);return r(F,{active:n,"aria-label":C,"data-testid":"wishlist-toggle",size:d??"medium",variant:D??"tertiary",disabled:u,icon:r(I,{source:g??H}),activeIcon:r(I,{source:W??q}),onClick:w??y,children:U,activeChildren:k})};export{$ as WishlistToggle,$ as default};
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,r as A}from"../chunks/removeProductsFromWishlist.js";import{c as M,a as R}from"../chunks/mergeWishlists.js";import{S as q}from"../chunks/HeartFilled.js";import{S as H}from"../chunks/Heart.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:v})=>{const[k,w]=h(F.authenticated),[n,o]=h(!1),[L,S]=h(null),{isGuestWishlistEnabled:T}=M.getConfig(),f=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 A([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 R([{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}}),v&&await v([{uid:s.uid,quantity:0}])}};if(!k&&!T)return null;const C=n?f.removeFromWishlist.replace("{PRODUCT_NAME}",s==null?void 0:s.name):f.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??H}),activeIcon:r(c,{source:D??q}),onClick:u??y,children:g,activeChildren:b})};export{$ as WishlistToggle,$ as default};
4
4
  //# sourceMappingURL=WishlistToggle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WishlistToggle.js","sources":["/@dropins/storefront-wishlist/src/containers/WishlistToggle/WishlistToggle.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 {\n useState,\n HTMLAttributes,\n useEffect,\n useCallback,\n} from 'preact/compat';\nimport { Button, Icon } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Heart, HeartFilled } from '@adobe-commerce/elsie/icons';\nimport { state } from '@/wishlist/lib/state';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport {\n addProductsToWishlist,\n removeProductsFromWishlist,\n config,\n} from '@/wishlist/api';\nimport { Product } from '@/wishlist/data/models';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { VNode } from 'preact';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport interface WishlistToggleProps extends HTMLAttributes<HTMLDivElement> {\n product: Product;\n iconWishlisted?: VNode<HTMLAttributes<SVGSVGElement>>;\n iconToWishlist?: VNode<HTMLAttributes<SVGSVGElement>>;\n size?: 'medium' | 'large';\n variant?: 'primary' | 'secondary' | 'tertiary';\n disabled?: boolean;\n labelToWishlist?: string;\n labelWishlisted?: string;\n onClick?: () => void;\n removeProdFromCart?: (\n product: { uid: string; quantity: number }[]\n ) => Promise<any>;\n}\n\nexport const WishlistToggle: Container<WishlistToggleProps> = ({\n product,\n iconWishlisted,\n iconToWishlist,\n size,\n variant,\n disabled,\n labelToWishlist,\n labelWishlisted,\n onClick,\n removeProdFromCart,\n}: WishlistToggleProps) => {\n const [isLoggedIn, setIsLoggedIn] = useState(state.authenticated);\n const [isWishlisted, setIsWishlisted] = useState(false);\n const [wishlistItem, setWishlistItem] = useState(null);\n const { isGuestWishlistEnabled } = config.getConfig();\n\n const dictionary = useText({\n addToWishlist: 'Wishlist.Wishlist.ariaLabelAddToWishlist',\n removeFromWishlist: 'Wishlist.Wishlist.ariaLabelRemoveFromWishlist',\n });\n\n const handleWishlistData = useCallback(() => {\n const updatedWishlist = getPersistedWishlistData();\n const item = updatedWishlist?.items?.find((item: any) =>\n isMatchingWishlistItem(item, {\n sku: product.topLevelSku ?? product.sku,\n optionUIDs:\n product.optionUIDs ??\n (product.selectedOptionsUIDs\n ? Object.values(product.selectedOptionsUIDs)\n : undefined),\n })\n );\n\n setWishlistItem(item ?? null);\n setIsWishlisted(!!item);\n }, [\n product.topLevelSku,\n product.sku,\n product.optionUIDs,\n product.selectedOptionsUIDs,\n ]);\n\n useEffect(() => {\n handleWishlistData();\n }, [handleWishlistData]);\n\n useEffect(() => {\n const handleAuthentication = (authenticated: boolean) =>\n setIsLoggedIn(authenticated);\n\n const onAuthenticated = events.on('authenticated', handleAuthentication);\n const onWishlistData = events.on('wishlist/data', handleWishlistData);\n\n return () => {\n onAuthenticated?.off();\n onWishlistData?.off();\n };\n }, [handleWishlistData]);\n\n const handleClick = async () => {\n if (isWishlisted) {\n try {\n await removeProductsFromWishlist([wishlistItem]);\n } catch (error) {\n events.emit('wishlist/alert', {\n action: 'removeError',\n item: { product },\n });\n return null;\n }\n\n setIsWishlisted(false);\n events.emit('wishlist/alert', {\n action: 'remove',\n item: { product },\n });\n } else {\n try {\n await addProductsToWishlist([\n {\n sku: product.topLevelSku ?? product.sku,\n quantity: 1,\n optionsUIDs:\n product.optionUIDs ??\n (product.selectedOptionsUIDs\n ? Object.values(product.selectedOptionsUIDs)\n : undefined),\n enteredOptions: product.options?.items\n ? product.options.items\n .filter((option: any) => option.selected)\n .map((option: any) => ({\n uid: option.uid,\n value: option.value,\n }))\n : undefined,\n },\n ]);\n } catch (error) {\n events.emit('wishlist/alert', {\n action: 'addError',\n item: { product },\n });\n return null;\n }\n\n setIsWishlisted(true);\n events.emit('wishlist/alert', {\n action: 'add',\n item: { product },\n });\n if (removeProdFromCart) {\n await removeProdFromCart([\n {\n uid: product.uid,\n quantity: 0,\n },\n ]);\n }\n }\n };\n\n if (!isLoggedIn && !isGuestWishlistEnabled) {\n return null;\n }\n\n const ariaLabel: string = isWishlisted\n ? dictionary['removeFromWishlist'].replace('{PRODUCT_NAME}', product?.name)\n : dictionary['addToWishlist'].replace('{PRODUCT_NAME}', product?.name);\n\n return (\n <Button\n active={isWishlisted}\n aria-label={ariaLabel}\n data-testid=\"wishlist-toggle\"\n size={size ?? 'medium'}\n variant={variant ?? 'tertiary'}\n disabled={disabled}\n icon={<Icon source={iconToWishlist ?? Heart} />}\n activeIcon={<Icon source={iconWishlisted ?? HeartFilled} />}\n onClick={onClick ?? handleClick}\n children={labelToWishlist}\n activeChildren={labelWishlisted}\n />\n );\n};\n"],"names":["WishlistToggle","product","iconWishlisted","iconToWishlist","size","variant","disabled","labelToWishlist","labelWishlisted","onClick","removeProdFromCart","isLoggedIn","setIsLoggedIn","useState","state","isWishlisted","setIsWishlisted","wishlistItem","setWishlistItem","isGuestWishlistEnabled","config","dictionary","useText","handleWishlistData","useCallback","updatedWishlist","getPersistedWishlistData","item","_a","isMatchingWishlistItem","useEffect","handleAuthentication","authenticated","onAuthenticated","events","onWishlistData","handleClick","removeProductsFromWishlist","addProductsToWishlist","option","ariaLabel","jsx","Button","Icon","Heart","HeartFilled"],"mappings":"8lBAuDO,MAAMA,EAAiD,CAAC,CAC7D,QAAAC,EACA,eAAAC,EACA,eAAAC,EACA,KAAAC,EACA,QAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,mBAAAC,CACF,IAA2B,CACzB,KAAM,CAACC,EAAYC,CAAa,EAAIC,EAASC,EAAM,aAAa,EAC1D,CAACC,EAAcC,CAAe,EAAIH,EAAS,EAAK,EAChD,CAACI,EAAcC,CAAe,EAAIL,EAAS,IAAI,EAC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,aAAeA,EAAQ,IACpC,SAAU,EACV,YACEA,EAAQ,aACPA,EAAQ,oBACL,OAAO,OAAOA,EAAQ,mBAAmB,EACzC,QACN,gBAAgB2B,EAAA3B,EAAQ,UAAR,MAAA2B,EAAiB,MAC7B3B,EAAQ,QAAQ,MACb,OAAQsC,GAAgBA,EAAO,QAAQ,EACvC,IAAKA,IAAiB,CACrB,IAAKA,EAAO,IACZ,MAAOA,EAAO,OACd,EACJ,MAAA,CACN,CACD,OACa,CACd,OAAAL,EAAO,KAAK,iBAAkB,CAC5B,OAAQ,WACR,KAAM,CAAE,QAAAjC,CAAQ,CAAA,CACjB,EACM,IAAA,CAGTe,EAAgB,EAAI,EACpBkB,EAAO,KAAK,iBAAkB,CAC5B,OAAQ,MACR,KAAM,CAAE,QAAAjC,CAAQ,CAAA,CACjB,EACGS,GACF,MAAMA,EAAmB,CACvB,CACE,IAAKT,EAAQ,IACb,SAAU,CAAA,CACZ,CACD,CACH,CAEJ,EAEI,GAAA,CAACU,GAAc,CAACQ,EACX,OAAA,KAGT,MAAMqB,EAAoBzB,EACtBM,EAAW,mBAAsB,QAAQ,iBAAkBpB,GAAA,YAAAA,EAAS,IAAI,EACxEoB,EAAW,cAAiB,QAAQ,iBAAkBpB,GAAA,YAAAA,EAAS,IAAI,EAGrE,OAAAwC,EAACC,EAAA,CACC,OAAQ3B,EACR,aAAYyB,EACZ,cAAY,kBACZ,KAAMpC,GAAQ,SACd,QAASC,GAAW,WACpB,SAAAC,EACA,KAAMmC,EAACE,EAAK,CAAA,OAAQxC,GAAkByC,EAAO,EAC7C,WAAYH,EAACE,EAAK,CAAA,OAAQzC,GAAkB2C,EAAa,EACzD,QAASpC,GAAW2B,EACpB,SAAU7B,EACV,eAAgBC,CAAA,CAClB,CAEJ"}
1
+ {"version":3,"file":"WishlistToggle.js","sources":["/@dropins/storefront-wishlist/src/containers/WishlistToggle/WishlistToggle.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 {\n useState,\n HTMLAttributes,\n useEffect,\n useCallback,\n} from 'preact/compat';\nimport { Button, Icon } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Heart, HeartFilled } from '@adobe-commerce/elsie/icons';\nimport { state } from '@/wishlist/lib/state';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport {\n addProductsToWishlist,\n removeProductsFromWishlist,\n config,\n} from '@/wishlist/api';\nimport { Product } from '@/wishlist/data/models';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { VNode } from 'preact';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport interface WishlistToggleProps extends HTMLAttributes<HTMLDivElement> {\n product: Product;\n iconWishlisted?: VNode<HTMLAttributes<SVGSVGElement>>;\n iconToWishlist?: VNode<HTMLAttributes<SVGSVGElement>>;\n size?: 'medium' | 'large';\n variant?: 'primary' | 'secondary' | 'tertiary';\n disabled?: boolean;\n labelToWishlist?: string;\n labelWishlisted?: string;\n onClick?: () => void;\n removeProdFromCart?: (\n product: { uid: string; quantity: number }[]\n ) => Promise<any>;\n}\n\nexport const WishlistToggle: Container<WishlistToggleProps> = ({\n product,\n iconWishlisted,\n iconToWishlist,\n size,\n variant,\n disabled,\n labelToWishlist,\n labelWishlisted,\n onClick,\n removeProdFromCart,\n}: WishlistToggleProps) => {\n const [isLoggedIn, setIsLoggedIn] = useState(state.authenticated);\n const [isWishlisted, setIsWishlisted] = useState(false);\n const [wishlistItem, setWishlistItem] = useState(null);\n const { isGuestWishlistEnabled } = config.getConfig();\n\n const dictionary = useText({\n addToWishlist: 'Wishlist.Wishlist.ariaLabelAddToWishlist',\n removeFromWishlist: 'Wishlist.Wishlist.ariaLabelRemoveFromWishlist',\n });\n\n const handleWishlistData = useCallback(() => {\n const updatedWishlist = getPersistedWishlistData();\n const item = updatedWishlist?.items?.find((item: any) =>\n isMatchingWishlistItem(item, {\n sku: product.topLevelSku ?? product.sku,\n optionUIDs:\n product.optionUIDs ??\n (product.selectedOptionsUIDs\n ? Object.values(product.selectedOptionsUIDs)\n : undefined) ??\n (product.bundleOptionsUIDs\n ? Object.values(product.bundleOptionsUIDs)\n : undefined),\n })\n );\n\n setWishlistItem(item ?? null);\n setIsWishlisted(!!item);\n }, [\n product.topLevelSku,\n product.sku,\n product.optionUIDs,\n product.selectedOptionsUIDs,\n product.bundleOptionsUIDs,\n ]);\n\n useEffect(() => {\n handleWishlistData();\n }, [handleWishlistData]);\n\n useEffect(() => {\n const handleAuthentication = (authenticated: boolean) =>\n setIsLoggedIn(authenticated);\n\n const onAuthenticated = events.on('authenticated', handleAuthentication);\n const onWishlistData = events.on('wishlist/data', handleWishlistData);\n\n return () => {\n onAuthenticated?.off();\n onWishlistData?.off();\n };\n }, [handleWishlistData]);\n\n const handleClick = async () => {\n if (isWishlisted) {\n try {\n await removeProductsFromWishlist([wishlistItem]);\n } catch (error) {\n events.emit('wishlist/alert', {\n action: 'removeError',\n item: { product },\n });\n return null;\n }\n\n setIsWishlisted(false);\n events.emit('wishlist/alert', {\n action: 'remove',\n item: { product },\n });\n } else {\n try {\n await addProductsToWishlist([\n {\n sku: product.topLevelSku ?? product.sku,\n quantity: 1,\n optionsUIDs:\n product.optionUIDs ??\n (product.selectedOptionsUIDs\n ? Object.values(product.selectedOptionsUIDs)\n : undefined) ??\n (product.bundleOptionsUIDs\n ? Object.values(product.bundleOptionsUIDs)\n : undefined),\n enteredOptions: product.options?.items\n ? product.options.items\n .filter((option: any) => option.selected)\n .map((option: any) => ({\n uid: option.uid,\n value: option.value,\n }))\n : undefined,\n },\n ]);\n } catch (error) {\n events.emit('wishlist/alert', {\n action: 'addError',\n item: { product },\n });\n return null;\n }\n\n setIsWishlisted(true);\n events.emit('wishlist/alert', {\n action: 'add',\n item: { product },\n });\n if (removeProdFromCart) {\n await removeProdFromCart([\n {\n uid: product.uid,\n quantity: 0,\n },\n ]);\n }\n }\n };\n\n if (!isLoggedIn && !isGuestWishlistEnabled) {\n return null;\n }\n\n const ariaLabel: string = isWishlisted\n ? dictionary['removeFromWishlist'].replace('{PRODUCT_NAME}', product?.name)\n : dictionary['addToWishlist'].replace('{PRODUCT_NAME}', product?.name);\n\n return (\n <Button\n active={isWishlisted}\n aria-label={ariaLabel}\n data-testid=\"wishlist-toggle\"\n size={size ?? 'medium'}\n variant={variant ?? 'tertiary'}\n disabled={disabled}\n icon={<Icon source={iconToWishlist ?? Heart} />}\n activeIcon={<Icon source={iconWishlisted ?? HeartFilled} />}\n onClick={onClick ?? handleClick}\n children={labelToWishlist}\n activeChildren={labelWishlisted}\n />\n );\n};\n"],"names":["WishlistToggle","product","iconWishlisted","iconToWishlist","size","variant","disabled","labelToWishlist","labelWishlisted","onClick","removeProdFromCart","isLoggedIn","setIsLoggedIn","useState","state","isWishlisted","setIsWishlisted","wishlistItem","setWishlistItem","isGuestWishlistEnabled","config","dictionary","useText","handleWishlistData","useCallback","updatedWishlist","getPersistedWishlistData","item","_a","isMatchingWishlistItem","useEffect","handleAuthentication","authenticated","onAuthenticated","events","onWishlistData","handleClick","removeProductsFromWishlist","addProductsToWishlist","option","ariaLabel","jsx","Button","Icon","Heart","HeartFilled"],"mappings":"8lBAuDO,MAAMA,EAAiD,CAAC,CAC7D,QAAAC,EACA,eAAAC,EACA,eAAAC,EACA,KAAAC,EACA,QAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,mBAAAC,CACF,IAA2B,CACzB,KAAM,CAACC,EAAYC,CAAa,EA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E,EAAK,CAAA,OAAQzC,GAAkB2C,EAAa,EACzD,QAASpC,GAAW2B,EACpB,SAAU7B,EACV,eAAgBC,CAAA,CAClB,CAEJ"}
package/lib/state.d.ts CHANGED
@@ -7,8 +7,6 @@ type State = {
7
7
  locale?: string;
8
8
  config?: StoreConfigModel | null;
9
9
  authenticated: boolean;
10
- currentPage?: number;
11
- pageSize?: number;
12
10
  };
13
11
  export declare const state: State;
14
12
  export {};
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-wishlist", "version": "2.0.0", "@dropins/tools": "~1.4.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-wishlist", "version": "2.0.1-beta1", "@dropins/tools": "~1.4.0", "license": "SEE LICENSE IN LICENSE.md"}
package/render.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- (function(r,e){try{if(typeof document<"u"){const t=document.createElement("style"),n=e.styleId;for(const i in e.attributes)t.setAttribute(i,e.attributes[i]);t.setAttribute("data-dropin",n),t.appendChild(document.createTextNode(r));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(t);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(".wishlist-empty-wishlist{container-type:inline-size;container-name:wishlist}.wishlist-empty-wishlist__wrapper .dropin-card--secondary{display:grid;grid-auto-rows:min-content;justify-content:center;text-align:center;border:unset}.wishlist-empty-wishlist .dropin-illustrated-message__heading{font:var(--type-headline-1-font)}.wishlist-empty-wishlist .dropin-illustrated-message__message{font:var(--type-body-1-default-font)}@container wishlist (width < 737px){.wishlist-empty-wishlist__wrapper .dropin-card{border:unset;border-style:hidden}}.wishlist-wishlist{container-type:inline-size;container-name:wishlist-grid;max-width:inherit}.wishlist-wishlist__content{display:grid;gap:var(--spacing-medium);margin:auto;padding:var(--spacing-medium) 0}.wishlist-wishlist__heading{color:var(--color-neutral-800);display:grid;font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);padding:var(--spacing-small) 0;row-gap:var(--spacing-xsmall)}.wishlist-wishlist__heading-text{font-size:inherit;font-weight:inherit;margin:0;line-height:inherit}.wishlist-wishlist__heading-count{color:#6d6d6d;margin-left:var(--spacing-xxsmall);letter-spacing:normal;font:var(--type-details-caption-2-font)}.wishlist-wishlist__content.wishlist-wishlist__content--empty{border:var(--shape-border-width-2) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-2);grid-template-columns:repeat(1,1fr);padding:var(--spacing-xxbig);margin:var(--spacing-xxbig) auto}@media only screen and (max-width: 480px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(1,1fr)}.dropin-skeleton-row:nth-child(n+2){display:none}}@media only screen and (min-width: 480px) and (max-width: 600px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(2,1fr)}.dropin-skeleton-row:nth-child(n+3){display:none}}@media only screen and (min-width: 600px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(2,1fr)}.dropin-skeleton-row:nth-child(n+3){display:none}}@media only screen and (min-width: 768px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(3,1fr)}.dropin-skeleton-row:nth-child(n){display:block}}.wishlist-product-item{background-color:var(--color-neutral-50);margin-bottom:var(--spacing-small)}.wishlist-product-item__content{display:flex;flex-direction:column;gap:var(--spacing-small)}.wishlist-product-item__content .wishlist-product-item-image{background:var(--color-neutral-200);height:100%;padding:0;position:relative;width:100%}.wishlist-product-item__content .wishlist-product-item__title{color:var(--color-neutral-800);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin:0;position:relative}.wishlist-product-item-name{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:85%}a.wishlist-product-item-name:active,a.wishlist-product-item-name:hover,a.wishlist-product-item-name{color:var(--color-neutral-800);cursor:pointer;font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}.wishlist-product-item__content .wishlist-product-item-button__remove{position:absolute;right:0;top:-10px}.wishlist-product-item__content .wishlist-product-item-options{font:var(--type-body-2-default-font)}.wishlist-product-item__content .wishlist-product-item-option__attribute{text-transform:capitalize}.wishlist-product-item__content .wishlist-product-item-option__label{font:var(--type-body-2-strong-font)}.wishlist-product-item__content .wishlist-product-item-price{display:inline;font:var(--type-body-2-default-font)}.strikethrough{text-decoration:line-through}.wishlist-product-item__content .wishlist-product-item-discounted-price{display:inline;margin-left:var(--spacing-xsmall);color:var(--color-alert-800)}.wishlist-product-item-move-to-cart{display:grid;grid-area:product-add-to-cart;justify-content:end}.wishlist-product-item-tax{color:var(--color-neutral-500)}.wishlist-product-item-tax span{margin-right:var(--spacing-xsmall)}.image-carousel{display:flex;flex-direction:column;gap:var(--spacing-medium);padding:var(--spacing-medium)}.image-carousel .image-carousel-image{object-fit:contain;padding:var(--spacing-xxsmall) 0;width:100%}.image-switcher-area{bottom:var(--spacing-xxsmall);left:0;margin-top:var(--spacing-small);position:absolute;text-align:center;width:100%}.image-switcher-area .image-switcher{cursor:pointer;border-radius:50%;display:inline-flex;height:var(--spacing-xsmall);margin:0 var(--spacing-xxsmall);width:var(--spacing-xsmall)}.image-switcher-area .image-switcher-active{background-color:var(--color-neutral-900);border:var(--shape-border-width-1) solid var(--color-brand-700)}.image-switcher-area .image-switcher-inactive{background-color:var(--color-neutral-600);border:var(--shape-border-width-1) solid var(--color-neutral-600)}@media only screen and (max-width: 480px){.image-carousel{gap:var(--spacing-xxsmall)}.image-carousel .image-carousel-image{height:250px}}@media only screen and (min-width: 480px) and (max-width: 600px){.image-carousel{gap:var(--spacing-xsmall)}.image-carousel .image-carousel-image{height:300px}}@media only screen and (min-width: 600px){.image-carousel{gap:var(--spacing-xsmall)}.image-carousel .image-carousel-image{height:300px}}@media only screen and (min-width: 768px){.image-carousel{gap:var(--spacing-small)}.image-carousel .image-carousel-image{height:350px}}@media only screen and (min-width: 1024px){.image-carousel{gap:var(--spacing-medium)}.image-carousel .image-carousel-image{height:400px}}.wishlist-login__sign-in{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:var(--spacing-xxsmall);text-align:center}a.wishlist-login__link{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall);text-decoration:underline;text-decoration-thickness:auto;text-underline-offset:auto;color:var(--color-neutral-800)}a.wishlist-login__link:hover{color:var(--color-neutral-800);text-decoration:underline;text-decoration-thickness:auto;text-underline-offset:auto}",{styleId:"Wishlist"});
3
+ (function(r,e){try{if(typeof document<"u"){const t=document.createElement("style"),n=e.styleId;for(const i in e.attributes)t.setAttribute(i,e.attributes[i]);t.setAttribute("data-dropin",n),t.appendChild(document.createTextNode(r));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(t);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(".wishlist-empty-wishlist{container-type:inline-size;container-name:wishlist}.wishlist-empty-wishlist__wrapper .dropin-card--secondary{display:grid;grid-auto-rows:min-content;justify-content:center;text-align:center;border:unset}.wishlist-empty-wishlist .dropin-illustrated-message__heading{font:var(--type-headline-1-font)}.wishlist-empty-wishlist .dropin-illustrated-message__message{font:var(--type-body-1-default-font)}@container wishlist (width < 737px){.wishlist-empty-wishlist__wrapper .dropin-card{border:unset;border-style:hidden}}.wishlist-wishlist{container-type:inline-size;container-name:wishlist-grid;max-width:inherit}.wishlist-wishlist__content{display:grid;gap:var(--spacing-medium);margin:auto;padding:var(--spacing-medium) 0}.wishlist-wishlist__heading{color:var(--color-neutral-800);display:grid;font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);padding:var(--spacing-small) 0;row-gap:var(--spacing-xsmall)}.wishlist-wishlist__heading-text{font-size:inherit;font-weight:inherit;margin:0;line-height:inherit}.wishlist-wishlist__heading-count{color:#6d6d6d;margin-left:var(--spacing-xxsmall);letter-spacing:normal;font:var(--type-details-caption-2-font)}.wishlist-wishlist__content.wishlist-wishlist__content--empty{border:var(--shape-border-width-2) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-2);grid-template-columns:repeat(1,1fr);padding:var(--spacing-xxbig);margin:var(--spacing-xxbig) auto}@media only screen and (max-width: 480px){.dropin-skeleton{grid-template-columns:repeat(1,1fr)}.dropin-skeleton-row:nth-child(n+2){display:none}.wishlist-wishlist__content{grid-template-columns:repeat(1,1fr);min-height:320px}}@media only screen and (min-width: 480px) and (max-width: 600px){.dropin-skeleton{grid-template-columns:repeat(2,1fr)}.dropin-skeleton-row:nth-child(n+3){display:none}.wishlist-wishlist__content{grid-template-columns:repeat(2,1fr);min-height:320px}}@media only screen and (min-width: 600px){.dropin-skeleton{grid-template-columns:repeat(2,1fr)}.dropin-skeleton-row:nth-child(n+3){display:none}.wishlist-wishlist__content{grid-template-columns:repeat(2,1fr);min-height:320px}}@media only screen and (min-width: 768px){.dropin-skeleton{grid-template-columns:repeat(3,1fr)}.dropin-skeleton-row:nth-child(n){display:block}.wishlist-wishlist__content{grid-template-columns:repeat(3,1fr);min-height:480px}}.wishlist-product-item{background-color:var(--color-neutral-50);margin-bottom:var(--spacing-small)}.wishlist-product-item__content{display:flex;flex-direction:column;gap:var(--spacing-small)}.wishlist-product-item__content .wishlist-product-item-image{background:var(--color-neutral-200);height:100%;padding:0;position:relative;width:100%}.wishlist-product-item__content .wishlist-product-item__title{color:var(--color-neutral-800);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin:0;position:relative}.wishlist-product-item-name{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:85%}a.wishlist-product-item-name:active,a.wishlist-product-item-name:hover,a.wishlist-product-item-name{color:var(--color-neutral-800);cursor:pointer;font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}.wishlist-product-item__content .wishlist-product-item-button__remove{position:absolute;right:0;top:-10px}.wishlist-product-item__content .wishlist-product-item-options{font:var(--type-body-2-default-font)}.wishlist-product-item__content .wishlist-product-item-option__attribute{text-transform:capitalize}.wishlist-product-item__content .wishlist-product-item-option__label{font:var(--type-body-2-strong-font)}.wishlist-product-item__content .wishlist-product-item-price{display:inline;font:var(--type-body-2-default-font)}.strikethrough{text-decoration:line-through}.wishlist-product-item__content .wishlist-product-item-discounted-price{display:inline;margin-left:var(--spacing-xsmall);color:var(--color-alert-800)}.wishlist-product-item-move-to-cart{display:grid;grid-area:product-add-to-cart;justify-content:end}.wishlist-product-item-tax{color:var(--color-neutral-500)}.wishlist-product-item-tax span{margin-right:var(--spacing-xsmall)}.image-carousel{display:flex;flex-direction:column;gap:var(--spacing-medium);padding:var(--spacing-medium)}.image-carousel .image-carousel-image{object-fit:contain;padding:var(--spacing-xxsmall) 0;width:100%}.image-switcher-area{bottom:var(--spacing-xxsmall);left:0;margin-top:var(--spacing-small);position:absolute;text-align:center;width:100%}.image-switcher-area .image-switcher{cursor:pointer;border-radius:50%;display:inline-flex;height:var(--spacing-xsmall);margin:0 var(--spacing-xxsmall);width:var(--spacing-xsmall)}.image-switcher-area .image-switcher-active{background-color:var(--color-neutral-900);border:var(--shape-border-width-1) solid var(--color-brand-700)}.image-switcher-area .image-switcher-inactive{background-color:var(--color-neutral-600);border:var(--shape-border-width-1) solid var(--color-neutral-600)}@media only screen and (max-width: 480px){.image-carousel{gap:var(--spacing-xxsmall)}.image-carousel .image-carousel-image{height:250px}}@media only screen and (min-width: 480px) and (max-width: 600px){.image-carousel{gap:var(--spacing-xsmall)}.image-carousel .image-carousel-image{height:300px}}@media only screen and (min-width: 600px){.image-carousel{gap:var(--spacing-xsmall)}.image-carousel .image-carousel-image{height:300px}}@media only screen and (min-width: 768px){.image-carousel{gap:var(--spacing-small)}.image-carousel .image-carousel-image{height:350px}}@media only screen and (min-width: 1024px){.image-carousel{gap:var(--spacing-medium)}.image-carousel .image-carousel-image{height:400px}}.wishlist-login__sign-in{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:var(--spacing-xxsmall);text-align:center}a.wishlist-login__link{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall);text-decoration:underline;text-decoration-thickness:auto;text-underline-offset:auto;color:var(--color-neutral-800)}a.wishlist-login__link:hover{color:var(--color-neutral-800);text-decoration:underline;text-decoration-thickness:auto;text-underline-offset:auto}",{styleId:"Wishlist"});
4
4
  import{jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import{Render as d}from"@dropins/tools/lib.js";import{useState as a,useEffect as n}from"@dropins/tools/preact-hooks.js";import{UIProvider as m}from"@dropins/tools/components.js";import{events as h}from"@dropins/tools/event-bus.js";const c={EmptyWishlist:{heading:"Your wishlist is empty",message:"Add items by clicking on the heart icon.",cta:"Start shopping"},Wishlist:{heading:"Wishlist {count}",loading:"Loading...",ariaLabelAddToWishlist:"add {PRODUCT_NAME} to wishlist",ariaLabelRemoveFromWishlist:"remove {PRODUCT_NAME} from wishlist"},Alert:{addProduct:{heading:"Added to wishlist",message:"{product} has been added to your wishlist"},removeProduct:{heading:"Removed from wishlist",message:"{product} has been removed from your wishlist"},moveToCart:{heading:"Moved to cart",message:"{product} has been moved to your cart"},addError:{heading:"Error",message:"Failed to add product to wishlist"},removeError:{heading:"Error",message:"Failed to remove {product} from wishlist"},viewWishlist:"View wishlist"},Login:{sync:" to sync your saved items across all your devices.",logIn:"Log in"}},l={CartActionButton:"Move To Cart",TrashActionButton:"Remove this product from wishlist",CustomizeActionButton:"Customize"},u={Wishlist:c,ProductItem:l},g={default:u},v=({children:e})=>{const[s,i]=a("en_US");return n(()=>{const o=h.on("locale",r=>{i(r)},{eager:!0});return()=>{o==null||o.off()}},[]),t(m,{lang:s,langDefinitions:g,children:e})},P=new d(t(v,{}));export{P as render};
5
5
  //# sourceMappingURL=render.js.map