1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,951678,e=>{e.v({fadeInOpacity:"ToastContent-module-scss-module__R566NW__fadeInOpacity",fadeInUp:"ToastContent-module-scss-module__R566NW__fadeInUp",toastContent:"ToastContent-module-scss-module__R566NW__toastContent",toastText:"ToastContent-module-scss-module__R566NW__toastText",toastThumbnail:"ToastContent-module-scss-module__R566NW__toastThumbnail"})},462547,e=>{e.v({dialog_actions:"SavedListActionsDialog-module-scss-module__RtWwuG__dialog_actions",dialog_content:"SavedListActionsDialog-module-scss-module__RtWwuG__dialog_content",fadeInOpacity:"SavedListActionsDialog-module-scss-module__RtWwuG__fadeInOpacity",fadeInUp:"SavedListActionsDialog-module-scss-module__RtWwuG__fadeInUp",list_selection_card:"SavedListActionsDialog-module-scss-module__RtWwuG__list_selection_card",list_selection_card__image:"SavedListActionsDialog-module-scss-module__RtWwuG__list_selection_card__image",list_selection_card__info:"SavedListActionsDialog-module-scss-module__RtWwuG__list_selection_card__info",list_selection_container:"SavedListActionsDialog-module-scss-module__RtWwuG__list_selection_container","stacked-actions":"SavedListActionsDialog-module-scss-module__RtWwuG__stacked-actions"})},679252,e=>{e.v({content:"ShareListContent-module-scss-module__MoStAq__content","copied-message":"ShareListContent-module-scss-module__MoStAq__copied-message",description:"ShareListContent-module-scss-module__MoStAq__description",fadeInOpacity:"ShareListContent-module-scss-module__MoStAq__fadeInOpacity",fadeInUp:"ShareListContent-module-scss-module__MoStAq__fadeInUp","input-wrapper":"ShareListContent-module-scss-module__MoStAq__input-wrapper"})},512978,408048,e=>{"use strict";e.s(["DEFAULT_SAVED_ITEMS_LIST_NAME",()=>ee,"WishlistContext",()=>Q,"default",()=>es,"defaultWishlistProvider",()=>H,"safeDecodeURIComponent",()=>et,"useWishlist",()=>J],512978);var t=e.i(843476),s=e.i(963489),i=e.i(514089),a=e.i(271645),r=e.i(618566),o=e.i(943518),n=e.i(277491),l=e.i(661687);e.i(105831);var d=e.i(180709),c=e.i(429562),u=e.i(802429),m=e.i(904189);function h(e,t){switch(t.type){case"add":if(!t.listId)return e;return e.map(e=>e.id!==t.listId||e.products.some(e=>e.id===t.product.id)?e:{...e,products:[t.product,...e.products]});case"remove":if(!t.listId)return e;return e.map(e=>e.id!==t.listId?e:{...e,products:e.products.filter(e=>e.nodeId!==t.nodeId)});case"rename":return e.map(e=>e.id===t.listId?{...e,name:t.name}:e);default:return(0,m.assertNever)(t)}}function p(e,t){switch(t.type){case"add":if(e.some(e=>e.id===t.product.id))return e;return[...e,t.product];case"remove":case"rename":return e;default:return(0,m.assertNever)(t)}}var v=e.i(731287),f=e.i(223425),g=e.i(191148),_=e.i(725979),y=e.i(640814),w=e.i(951678),C=e.i(902045),L=e.i(614996),b=e.i(611114),k=e.i(52567);let I=({message:e,thumbnailUrl:s,productName:i})=>(0,t.jsxs)("div",{className:w.default.toastContent,children:[(0,t.jsx)("div",{className:w.default.toastThumbnail,children:(0,t.jsx)(y.default,{src:s,alt:i??"",height:40,width:32})}),(0,t.jsx)("span",{"data-testid":"toast-text",title:e,className:w.default.toastText,children:e})]});var P=e.i(84534);let x=({isOpen:e,content:s,handleClose:i})=>(0,t.jsx)(P.Dialog,{isModalOpen:e,onClose:i,children:s});var S=e.i(942194),j=e.i(20257),W=e.i(681307),A=e.i(123542),E=e.i(462547),T=e.i(165519),M=e.i(447009),D=e.i(690371);let N=({handleClose:e,handleOnPrevious:s})=>{let i=(0,b.useFormatMessage)(),{addWishlist:r,setActionsDialogOpen:n,savedLists:l=[]}=J(),d=(0,a.useRef)(null),[c,m]=(0,a.useState)(null),[h,p]=(0,a.useState)(!1),[v,f]=(0,a.useState)(!1),{analyticsManager:g}=(0,o.useAnalytics)();(0,a.useEffect)(()=>{if(l.length>=10){m(i("list-creation-limit-reached-message")),f(!0),d.current?.setAttribute("disabled","true");return}d.current?.focus()},[l]);let _=W.z.object({name:W.z.string().min(1,i("please-enter-at-least-1-character")).max(55).regex(/^[a-zA-Z0-9 \-_'.!<>"&]+$/,i("checkout-emoji-error")).refine(e=>{let t=e.trim().toLowerCase();return!l.some(e=>e.name?.toLowerCase()===t)},{message:i("list-name-already-exists")})}),{bindFormValidation:y,reset:w,runFormValidation:C}=(0,A.useFormValidation)({onSubmit:k,scrollToError:!1,validationSchema:_}),L=(0,a.useCallback)(()=>{w();let t=document.getElementById("name");t&&(t.value=""),e()},[e,w]);async function k(e){if(m(null),!e.validated){g.fireSavedListsEvent({event:"list_name_throws_error"}),p(!1);return}if(g.fireSavedListsEvent({event:"list_name_submitted"}),await r(e.values.name.trim()))if(s)return void s();else n(!1),L(),p(!1);else p(!1),g.fireSavedListsEvent({event:"list_name_throws_error"}),m(i("server-issue-general-msg"))}let I=(0,a.useCallback)(()=>{C()},[C]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(P.Dialog.Title,{onPrevious:s,children:i("create-new-list")}),(0,t.jsx)(P.Dialog.Content,{children:(0,t.jsxs)("form",{id:"create-list-form",ref:y,children:[(0,t.jsx)("div",{className:E.default.dialog_content,children:(0,t.jsx)(j.InputField,{required:!0,name:"name",id:"name",maxLength:55,disabled:v,showCharacterCount:!0,onKeyUp:I,label:i("list-name"),ref:(0,M.default)((0,T.actSanitizedInputField)(),d)})}),c&&(0,t.jsx)(D.Message,{children:c})]})}),(0,t.jsxs)(P.Dialog.Actions,{className:E.default.dialog_actions,children:[(0,t.jsx)(S.Button,{variant:"secondary",onClick:L,"data-s-object-id":(0,u.buildWishListActivityLinkAttribute)("Cancel Create New List"),children:i("cancel")}),(0,t.jsx)(S.Button,{variant:"primary",onClick:()=>{p(!0);let e=document.getElementById("create-list-form");e&&e.dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))},disabled:v||h,status:h?"pending":"idle","data-s-object-id":(0,u.buildWishListActivityLinkAttribute)("Submit Create New List"),children:i("create-list")})]})]})},F=({handleClose:e})=>{let s=(0,b.useFormatMessage)(),{analyticsManager:i}=(0,o.useAnalytics)(),n=(0,r.useParams)(),l=decodeURIComponent(n?.listId??""),{savedLists:d=[],editWishlist:c,openDeleteListMenu:m}=J(),h=l?d?.find(e=>e.id===l):null,p=W.z.object({name:W.z.string().min(1,s("please-enter-at-least-1-character")).max(55).refine(e=>{let t=e.trim().toLowerCase();return!d.filter(e=>e.id!==h?.id).some(e=>
1e.name?.toLowerCase()===t)},{message:s("list-name-already-exists")})}),{bindFormValidation:v,reset:f,runFormValidation:g}=(0,A.useFormValidation)({onSubmit:y,scrollToError:!1,validationSchema:p}),_=(0,a.useCallback)(()=>{f();let t=document.getElementById("name");t&&(t.value=""),e()},[e,f]);async function y(e){e.validated?(await c(l,e.values.name.trim()),_()):i.fireSavedListsEvent({event:"list_name_throws_error"})}let w=(0,a.useCallback)(()=>{g()},[g]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(P.Dialog.Title,{children:s("settings")}),(0,t.jsx)(P.Dialog.Content,{children:(0,t.jsx)("form",{ref:v,id:"edit-list-form",children:(0,t.jsx)("div",{className:E.default.dialog_content,children:(0,t.jsx)(j.InputField,{defaultValue:h?.name??"",required:!0,name:"name",id:"name",maxLength:55,showCharacterCount:!0,onKeyUp:w,label:s("edit-list-name"),ref:(0,T.actSanitizedInputField)()})})})}),(0,t.jsxs)(P.Dialog.Actions,{className:E.default["stacked-actions"],children:[(0,t.jsx)(S.Button,{variant:"primary",onClick:()=>{let e=document.getElementById("edit-list-form");e&&e.dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))},"data-s-object-id":(0,u.buildWishListActivityLinkAttribute)("Update List Name Settings"),children:s("save-changes")}),(0,t.jsx)(S.Button,{variant:"text",onClick:m,"data-s-object-id":(0,u.buildWishListActivityLinkAttribute)("Delete List"),children:s("delete-list")})]})]})},R=({handleClose:e})=>{let s=(0,r.useParams)(),i=s?.listId?decodeURIComponent(Array.isArray(s.listId)?s.listId[0]:s.listId):void 0,a=(0,b.useFormatMessage)(),{deleteWishlist:o,savedLists:n,openConfigListMenu:l}=J(),d=i?n?.find(e=>e.id===i):null;async function c(){d&&await o(d?.id)}return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(P.Dialog.Title,{onPrevious:l,children:[a("delete")," ",d?.name]}),(0,t.jsx)(P.Dialog.Content,{children:(0,t.jsx)("div",{className:E.default.dialog_content,children:a("list-permanently-deleted-message")})}),(0,t.jsxs)(P.Dialog.Actions,{children:[(0,t.jsx)(S.Button,{variant:"secondary",onClick:e,"data-s-object-id":(0,u.buildWishListActivityLinkAttribute)("Cancel Delete List"),children:a("cancel")}),(0,t.jsx)(S.Button,{variant:"primary",onClick:c,"data-s-object-id":(0,u.buildWishListActivityLinkAttribute)("Confirm Delete List"),children:a("delete-list")})]})]})};var O=e.i(404463);function U(e){let s=(0,a.useRef)(e.selected),[i,r]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{void 0!==s.current&&void 0!==e.selected&&s.current!==e.selected&&r(!0),s.current=e.selected},[e.selected]),(0,t.jsxs)("svg",{...(0,O.getEnhancedIconProps)(e),viewBox:"0 0 40 40",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,className:"uawc-heart_filled_icon_animated","data-selected":e.selected,"data-animating":!!i||void 0,children:[(0,t.jsx)("path",{d:"M20 13.561C19.116 12.453 17.425 11.672 15.929 11.672C12.851 11.672 10.708 13.735 10.708 16.312C10.708 21.121 20 29.768 20 29.768C20 29.768 29.292 21.121 29.292 16.312C29.292 13.735 27.149 11.672 24.071 11.672C22.575 11.672 20.884 12.453 20 13.561Z",vectorEffect:"non-scaling-stroke"}),(0,t.jsx)("path",{d:"M20 13.561C19.116 12.453 17.425 11.672 15.929 11.672C12.851 11.672 10.708 13.735 10.708 16.312C10.708 21.121 20 29.768 20 29.768C20 29.768 29.292 21.121 29.292 16.312C29.292 13.735 27.149 11.672 24.071 11.672C22.575 11.672 20.884 12.453 20 13.561Z",vectorEffect:"non-scaling-stroke"}),(0,t.jsx)("circle",{strokeWidth:"1.5",r:"17",cx:"20",cy:"20"})]})}e.s(["HeartFilledIconAnimated",0,U],408048);let B=({isSelected:e=!1,list:s,onClick:i})=>{let r=(0,b.useFormatMessage)(),o=(0,a.useMemo)(()=>{let e=s.products?.[0];return e?.image?(0,t.jsx)(y.default,{src:e.image.url,alt:e.name??"",width:60,height:60,style:{objectFit:"contain"}}):null},[s.products]);return(0,t.jsxs)("div",{className:E.default.list_selection_card,children:[(0,t.jsx)("div",{className:E.default.list_selection_card__image,children:o}),(0,t.jsxs)("div",{className:E.default.list_selection_card__info,children:[(0,t.jsx)("h6",{children:s.name||r(ee)}),(0,t.jsx)("p",{children:r("cart-items",{quantity:s.products.length})})]}),(0,t.jsx)(U,{selected:e,onClick:()=>i(e?"remove":"add"),size:"XL"})]},s.id)},Y=({onCreateNewList:e,handleModifySavedItems:s})=>{let i=(0,b.useFormatMessage)(),{savedLists:r=[],currentProductManaging:o,findWishlistProduct:n,savedListError:l}=J(),[d,c]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{r.length>=10&&c(!0)},[r.length]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(P.Dialog.Title,{children:i("save-to-lists")}
1),(0,t.jsxs)(P.Dialog.Content,{children:[l&&(0,t.jsx)(D.Message,{type:"error",children:l}),(0,t.jsxs)("div",{className:E.default.dialog_content,children:[i("organize-your-list-message"),(0,t.jsx)("div",{className:E.default.list_selection_container,children:r?.map(e=>(0,t.jsx)(B,{isSelected:n({product:o?.product,selectedVariant:o?.selectedVariant,listId:e.id||void 0}).isSavedItem,list:e,onClick:t=>s(e.id,t,o?.selectedVariant,o?.product?.nodeId)},e.id))})]})]}),(0,t.jsx)(P.Dialog.Actions,{className:E.default.dialog_actions,children:(0,t.jsx)(S.Button,{variant:"primary",onClick:e,disabled:d,"data-s-object-id":(0,u.buildWishListActivityLinkAttribute)("Open Create New List"),children:i("create-new-list")})})]})};var $=e.i(555437),z=e.i(289869),V=e.i(43685),q=e.i(296655),G=e.i(679252);let K=(0,f.createClientLogger)("share-list"),Z=({listId:e})=>{let s=(0,b.useFormatMessage)(),i=(0,C.useLocale)(),o=(0,r.useParams)(),{createWishlistShareToken:n}=J(),l=e??o?.listId??"",d=l?et(l):"",[c,u]=(0,a.useState)(!1),m=(0,a.useRef)(void 0),[h,p]=(0,a.useState)(""),[v,f]=(0,a.useState)("");(0,a.useEffect)(()=>{let e=!0;return d?((async()=>{try{let t=await n(d);e&&p(t??"")}catch(t){e&&p(""),K.error(t,"Unable to create share list token")}})(),()=>{e=!1}):void p("")},[n,d]),(0,a.useEffect)(()=>{if(!h||!i)return void f("");let e=encodeURIComponent(h);f(`${window.location.origin}/${i}/shared-list/${e}`)},[h,i]),(0,a.useEffect)(()=>()=>{void 0!==m.current&&clearTimeout(m.current)},[]);let g=(0,a.useCallback)(async()=>{if(h&&v)try{clearTimeout(m.current),await navigator.clipboard.writeText(v),u(!0),m.current=window.setTimeout(u,3e3,!1)}catch(e){u(!1),K.error(e,"Unable to copy share list link")}},[v,h]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(P.Dialog.Title,{Icon:z.ShareTwoColorIcon,children:s("saved-items-share-your-list-title")}),(0,t.jsxs)(P.Dialog.Content,{className:G.default.content,children:[(0,t.jsx)("h4",{className:G.default.description,children:s("saved-items-share-your-list-description")}),(0,t.jsxs)("div",{className:G.default["input-wrapper"],children:[(0,t.jsx)(j.InputField,{"aria-labelledby":"share-list-link",value:v,floatingLabel:!1,label:s("saved-items-share-your-list-title"),readOnly:!0,type:"text"}),(0,t.jsx)($.IconButton,{onClick:g,variant:"primary",size:"MD",icon:c?q.CheckIcon:V.ExternalLinkIcon,label:s("copy-link")})]}),c&&(0,t.jsx)("div",{className:G.default["copied-message"],children:s("link-copied")})]})]})},X=(0,f.createClientLogger)("wishlist"),H={loadingWishlist:!0,wishListInitialized:!1,removingWishListItem:!1,wishlistProducts:[],savedLists:[],sharedList:null,sharedListLoading:!1,currentProductManaging:void 0,addProductToWishlist:async()=>{throw Error("addProductToWishlist() not implemented. You must include a WishlistProvider in your app.")},removeProductFromWishlist:()=>{throw Error("removeProductFromWishlist() not implemented. You must include a WishlistProvider in your app.")},setWishListProducts:()=>{throw Error("setWishListProducts() not implemented. You must include a WishlistProvider in your app.")},findWishlistProduct:()=>{throw Error("findWishlistProduct() not implemented. You must include a WishlistProvider in your app.")},getProductsByListId:()=>{throw Error("getProductsByListId() not implemented. You must include a WishlistProvider in your app.")},openCreateListMenu:()=>{throw Error("openCreateListMenu() not implemented. You must include a WishlistProvider in your app.")},openConfigListMenu:()=>{throw Error("openConfigListMenu() not implemented. You must include a WishlistProvider in your app.")},openDeleteListMenu:()=>{throw Error("openDeleteListMenu() not implemented. You must include a WishlistProvider in your app.")},openShareListMenu:async e=>{throw Error("openShareListMenu() not implemented. You must include a WishlistProvider in your app.")},setActionsDialogOpen:()=>{throw Error("setActionsDialogOpen() not implemented. You must include a WishlistProvider in your app.")},addWishlist:async()=>{throw Error("addWishlist() not implemented. You must include a WishlistProvider in your app.")},editWishlist:async()=>{throw Error("editWishlist() not implemented. You must include a WishlistProvider in your app.")},deleteWishlist:async()=>{throw Error("deleteWishlist() not implemented. You must include a WishlistProvider in your app.")},refreshProductList:async()=>{throw Error("refreshProductList() not implemented. You must include a WishlistProvider in your app.")},savedListError:null,createWishlistShareToken:async()=>
1{throw Error("createWishlistShareToken() not implemented. You must include a WishlistProvider in your app.")},getSharedWishlistItems:async()=>{throw Error("getSharedWishlistItems() not implemented. You must include a WishlistProvider in your app.")},createWishlistShareTokenLoading:!1},Q=(0,a.createContext)(H);function J(){return(0,a.useContext)(Q)}let ee="my-list";function et(e){try{return decodeURIComponent(e)}catch{return e}}let es=function({children:e}){let f,y,w,P,[S,j]=(0,a.useState)([]),[W,A]=(0,a.useState)([]),[E,T]=(0,a.useOptimistic)(S,p),[M,D]=(0,a.useOptimistic)(W,h),[O,U]=(0,a.useState)(!0),[B,$]=(0,a.useState)(!1),[z,V]=(0,a.useState)(void 0),[q,G]=(0,a.useState)(null),K=(0,a.useRef)(void 0),[H,J]=(0,a.useState)(!1),[es,ei]=(0,a.useState)(null),ea=(0,a.useRef)(null),{analyticsManager:er}=(0,o.useAnalytics)(),{user:eo}=(0,n.useSession)(),en=(0,a.useRef)(!1),{triggerToastFavorites:el}=(f=(0,C.useLocale)(),y=(0,k.default)(),w=(0,b.useFormatMessage)()("view"),P=(e,t,s)=>{let i=t&&"colors"in e&&Array.isArray(e.colors)?e.colors.find(e=>e.color===t.color)??null:!t&&s&&"colors"in e&&Array.isArray(e.colors)?e.colors.find(e=>e.color===s)??null:null,a="name"in e?e.name:void 0,r="image"in e&&e.image?e.image.url:"url"in e?e.url:void 0,o=i&&"object"==typeof i&&i.color?(0,L.getTileImage)(i,e,null,!0):(0,L.getSpecificImages)({product:e,color:i,fallbackUrl:r??void 0,viewType:"pdpMainDesktop"}),n=(()=>{if(Array.isArray(o)&&o.length>0){let e=o[0];return"string"==typeof e?e:e?.url}return"object"==typeof o&&null!==o&&"url"in o?o.url:"string"==typeof o?o:r})();return n?{...e,name:a,image:{..."image"in e&&e.image?e.image:{},url:n}}:e},{triggerToastFavorites:({isChecked:e,toastProduct:s,toastProductColor:i,toastVariantProduct:a,enableToast:r,useNameInToastText:o,formatMessage:n,showToastProgress:l=!1,toastActionLabel:d,toastActionOnClick:c,allowMultiple:u=!1,customMessage:m})=>{let h=P(s,a,i);if(r&&"object"==typeof h&&null!==h&&"name"in h&&"image"in h){let s=m??(o&&P?.name?n(e?"toast-add-product-saved-items":"toast-remove-product-saved-items",{productName:h.name||""}):n(e?"toast-add-saved-items":"toast-remove-saved-items")),i="string"==typeof h.image?h.image:h.image?.url??"",a=h.name??void 0,r=h?.sku??h?.name??"unknown",p=d?.trim()?"Undo":"View",v=`Toast ${p} Clicked-${r}`,g=new CustomEvent(_.TOAST_EVENT_NAME,{detail:{message:(0,t.jsx)(I,{message:s,thumbnailUrl:i,productName:a}),duration:4e3,showProgress:l,allowMultiple:u,action:{label:d??w,onClick:c??(()=>{y.push(`/${f}/saved-items`)}),hideOnClick:!0,activityMapObjectId:v}}});window.dispatchEvent(g)}}}),ed=(0,b.useFormatMessage)(),ec=(0,r.useRouter)(),eu=(0,C.useLocale)(),em=(0,a.useCallback)(e=>{let t=(0,u.mapWishListProductsFromSavedList)(e);j(t.flatMap(e=>e.products)),0===t.length&&t.unshift({id:"",name:null,products:[],isDefault:!0}),A(t)},[]),eh=(0,a.useCallback)(e=>{let t=(0,u.mapWishListProductsFromSavedList)([e]),s=+!!W[0]?.isDefault,i=[...W];i.splice(s,0,t[0]),A(i)},[W]),ep=(0,a.useCallback)(e=>{if("add"===e.type)A(t=>h(t,e)),j(t=>p(t,e));else if("remove"===e.type){let{nodeId:t,listId:s}=e;s?A(s=>{let i=s.flatMap(e=>e.products).find(e=>e.nodeId===t)?.id,a=h(s,e);return i?a.some(e=>e.products.some(e=>e.id===i))||j(e=>e.filter(e=>e.id!==i)):a.some(e=>e.products.some(e=>e.nodeId===t))||j(e=>e.filter(e=>e.nodeId!==t)),a}):j(e=>e.filter(e=>e.nodeId!==t))}else"rename"===e.type&&A(t=>h(t,e))},[]),[ev]=(0,s.useLazyQuery)(l.GetProductListsDocument,{fetchPolicy:"no-cache",variables:{first:10,listType:"WishList"},onCompleted:e=>{en.current=!0,em(e.getProductLists.data??[]),U(!1)}}),ef=(0,a.useCallback)(async()=>{await ev()},[ev]),eg=(0,a.useCallback)(e=>{if(!e)return[];let t=et(e),s=M?.find(e=>e.id===t);return s?s.products:[]},[M]),[e_]=(0,i.useMutation)(l.AddProductToProductListItemDocument),[ey]=(0,i.useMutation)(l.RemoveProductFromListDocument),[ew]=(0,i.useMutation)(l.DeleteProductListDocument),[eC]=(0,i.useMutation)(l.CreateProductListDocument),[eL]=(0,i.useMutation)(l.RenameProductListDocument),[eb]=(0,i.useMutation)(l.CreateWishlistShareTokenDocument),[ek]=(0,i.useMutation)(l.GetSharedWishlistItemsDocument),[eI,eP]=(0,a.useState)(null),[ex,eS]=(0,a.useState)(!1),[ej,eW]=(0,a.useState)(!1),eA=(0,a.useCallback)(async e=>{if(!e)return;let t=et(e);eW(!0);try{let e=await eb({variables:{input:{listId:t}}});return e.data?.createWishlistShareToken?.shareToken}catch(e){X.error(e,"Unable to create share list token");return}finally{eW(!1)}},[eb]),eE=(0,a.useCallback)(async e=>{if(!e)return null;let t=et(e);eS(!0);try{let e=await ek({variables:{input:{shareToken:t}}}),s=e.data?.getSharedWishlistItems?.wishList??null;if(s){let e=(0,u.mapWishListProductsFromSavedList)([s])[0]??null;return eP(e),e}return eP(null),null}catch(e){return X.warn((0,v.safeError)(e).message),eP(null),null}finally{eS(!1)}},[ek]),eT=(0,a.useCallback)((e=!1)=>{let t=ea.current;if(t&&(0,m.isArrayWithItems)(t)){let e=t.filter(e=>"add"===e.action),s=[...new Set(e.map(e=>e.listName))],i=t.filter(e=>"remove"===e.action),a=[...new Set(i.map(e=>e.listName))],r=e.length>0&&i.length>0?ed("toast-updated-your-lists"):e.length>0?1===s.length?ed("toast-added-to-list",{listName:s[0]}):ed("toast-added-to-lists"):1===a.length?ed("toast-removed-from-list",{listName:a[0]}):ed("toast-removed-from-lists"),o=0===e.length&&i.length>0,n=0===i.length&&e.length>0&&1===s.length?e[0].listId:null,l=n?{toastActionOnClick:()=>ec.push(`/${eu}/saved-items/${n}`)}:{},d=i.map(e=>e.undoCallback).filter(e=>void 0!==e);el({...t[0].toastParams,enableToast:!0,customMessage:r,...l,...o&&d.length>0?{showToastProgress:!0,toastActionLabel:ed("undo"),toastActionOnClick:()=>
1d.forEach(e=>e())}:{showToastProgress:!1,toastActionLabel:void 0,toastActionOnClick:void 0}})}ea.current=null,J(!1),e&&er.fireSavedListsEvent({event:"saved_list_modal_closed"}),ei(null),z&&(V(void 0),K.current=void 0)},[er,z,ed,eu,ec,el]),eM=(0,a.useCallback)(e=>{ei((0,t.jsx)(N,{handleClose:eT,handleOnPrevious:e?.handleOnPrevious})),e?.fromAddRemoveDialog||er.fireSavedListsEvent({event:"create_new_list_opened"}),J(!0)},[er,eT]);(0,a.useEffect)(()=>{eo?.uacapiAccessToken&&ev()},[eo?.uacapiAccessToken,ev]);let eD=(0,a.useCallback)(e=>{if(!e)return new Map;let t=M?.find(t=>t.id===e);if(t){let e=new Map;return t.products.forEach(t=>{if(!t.style)return;let{style:s,id:i,nodeId:a,__typename:r}=t,o={style:s,id:i,nodeId:a,__typename:r},n=(0,c.isMasterProduct)(t);if(e.has(s)){let t=e.get(s);t.entries.push(o),n&&(t.hasMasterProduct=!0)}else e.set(s,{hasMasterProduct:n,entries:[o]})}),e}return new Map},[M]),eN=(0,a.useCallback)(({product:e,selectedVariant:t,listId:s,wishlistProducts:i})=>{let a,r,o,n=t||e,l=i||E;if(void 0!==s?o=eD(s):(o=new Map,l.forEach(e=>{if(!e.style)return;let{style:t,id:s,nodeId:i,__typename:a}=e,r={style:t,id:s,nodeId:i,__typename:a},n=(0,c.isMasterProduct)(e);if(o.has(t)){let e=o.get(t);e&&(e.entries.push(r),n&&(e.hasMasterProduct=!0))}else o.set(t,{hasMasterProduct:n,entries:[r]})})),n?.style){let e=o.get(n.style);e&&e.hasMasterProduct?(a=(0,u.findComparableItem)(e,"__typename","MasterProduct"),r=!0):e&&!e.hasMasterProduct&&(a=(0,u.findComparableItem)(e,"id",n?.id),r=!1)}return{isSavedItem:(0,g.ensureBoolean)(l.length>0)&&!!a,hasMasterProduct:r,nodeId:a}},[E,eD]),eF=ed("saved-items-error"),eR=(0,a.useCallback)(async e=>{let{product:t,color:s,selectedVariant:i,toastProduct:a,enableToast:r=!0,productListId:o}=e,n=i?i.id:(0,d.getMasterProductId)(t.style),l=o||W?.[0]?.id||null;if(G(null),!n){X.warn("Cannot add product to wishlist, product id is missing: %o",t),er.fireFavoritesAdd({products:[{product_style:t.style??"",product_color:`${t.style}-${s}`,product_sku:(0,g.ensureString)(i?.sku||t?.sku)}]});return}try{let e=await e_({variables:{input:{productListItem:{productId:n,quantity:1},productListId:l}}});if(e.data?.addProductToProductListItem?.productListItem){let[o]=(0,u.mapWishListProducts)([e.data.addProductToProductListItem.productListItem]);if(o){ep({type:"add",product:o,listId:l}),l||await ef();let e=a&&"name"in a?a:t,n={isChecked:!0,toastProduct:e,toastProductColor:s,toastVariantProduct:i,enableToast:r,useNameInToastText:!1,formatMessage:ed};if(null!==ea.current){let e=W?.find(e=>e.id===l)?.name||ed(ee);ea.current.push({toastParams:n,action:"add",listName:e,listId:l??""})}else el(n)}else G(eF),X.warn("Cannot add product to wishlist, product could not be mapped (missing colors or required fields): %o",e.data.addProductToProductListItem.productListItem),window.dispatchEvent(new CustomEvent(_.TOAST_EVENT_NAME,{detail:{message:eF,duration:4e3,showProgress:!1,allowMultiple:!0}})),l||await ef()}else e.errors?(G(eF),X.warn("Cannot add product to wishlist, result has errors: %o",e.errors)):(G(eF),X.warn("Cannot add product to wishlist, result is missing: %o",e))}catch(e){G(eF),X.warn((0,v.safeError)(e).message)}er.fireFavoritesAdd({products:[{product_style:t.style??"",product_color:`${t.style}-${s}`,product_sku:(0,g.ensureString)(i?.sku||t?.sku)}]})},[e_,er,ep,ed,ef,eF,W,el]),eO=(0,a.useCallback)(async e=>{let{product:t,color:s,toastProduct:i,showAction:r,productListId:o,selectedVariant:n}=e;G(null);let l=o||W?.[0]?.id||null;if(!l){G(eF),X.warn("Cannot remove product from wishlist: no product list id available");return}let{nodeId:d}=eN({product:e.product,listId:l,selectedVariant:n});if(d){let e=i&&"name"in i?i:t,n=(()=>{if(r||!(t&&"name"in t))return t})(),c=()=>{let t="colorCode"in e&&"string"==typeof e.colorCode?e.colorCode:s;eR({product:e,color:t,selectedVariant:n,enableToast:!1,productListId:o})},u={isChecked:!1,toastProduct:e,toastProductColor:s,toastVariantProduct:n,enableToast:!0,useNameInToastText:!1,formatMessage:ed,showToastProgress:r??!1,toastActionLabel:r?ed("undo"):void 0,allowMultiple:!!r,toastActionOnClick:r?c:void 0};$(!0);let m=!1;if(await new Promise(e=>{(0,a.startTransition)(async()=>{let t={type:"remove",nodeId:d,listId:l};D(t);try{let e=await ey({variables:{input:{itemId:d,productListId:l}}});e.data?.removeProductFromProductList?.success&&(ep(t),m=!0)}catch(e){G(eF),X.warn("Failed to remove product from wishlist: %s",(0,v.safeError)(e).message)}finally{$(!1),e()}})}),m){if(null!==ea.current){let e=M?.find(e=>e.id===l)?.name||ed(ee);ea.current.push({toastParams:u,action:"remove",listName:e,listId:l??"",undoCallback:c})}else el(u);t&&er.fireFavoritesRemove({products:[{product_style:t.style??void 0,product_color:`${t.style}-${s}`,product_sku:t.sku||""}]})}}},[eR,er,D,ep,eN,ed,M,ey,eF,W,el]),eU=(0,a.useCallback)(async(e,t,s,i)=>{if(K.current)switch(t){case"add":await eR({...K.current,productListId:e});break;case"remove":await eO({...K.current,productListId:e,selectedVariant:s,nodeId:i})}},[eR,eO]),eB=(0,a.useRef)(eU);eB.current=eU;let eY=(0,a.useCallback)((...e)=>eB.current(...e),[]),e$=(0,a.useCallback)(()=>{G(null),ea.current??=[],ei((0,t.jsx)(Y,{onCreateNewList:()=>{er.fireSavedListsEvent({event:"create_list_modal_opened"}),eM({handleOnPrevious:e$,fromAddRemoveDialog:!0})},handleModifySavedItems:eY})),J(!0)},[eY,er,eM]),ez=(0,a.useCallback)(async e=>{e.product.style?(V(e),K.current=e,W?.length===0)?await eR(e):e$():X.warn("Cannot add product to wishlist, product style is missing: %o",e.product)},[W,e$,eR]),eV=(0,a.useCallback)(async e=>{(!e.product||e.product.style)&&(V(e),K.current=e,e$())},[e$]),eq=(0,a.useCallback)(async e=>{try{let t=await eC({variables:{input:{name:e,type:"WishList"}}}),s=t.data?.createProductList?.productList;if(s)return eh(s),er.fireSavedListsEvent({event:"create_new_list_success"}),!0;return X.warn("Cannot create wishlist, result is missing: %o",t),!1}catch(e){return X.warn((0,v.safeError)(e).message),!1}},[er,eC,eh]),eG=(0,a.useCallback)(async(e,t)=>{await new Promise(s=>{(0,a.startTransition)(async()=>{let i={type:"rename",listId:e,name:t};D(i);try{let s=await eL({variables:{input:{id:e,name:t}}});s.data?.renameProductList?.productList?(ep(i),er.fireSavedListsEvent({event:"list_name_submitted"}),J(!1)):X.warn("Cannot rename wishlist, result is missing: %o",s)}catch(e){X.warn("Failed to rename wishlist: %s",(0,v.safeError)(e).message)}s()})})},[er,D,ep,eL]),eK=(0,a.useCallback)(async e=>{try{let t=await ew({variables:{input:{id:e}}});t.data?.deleteProductList?.success?(ec.push(`/${eu}/saved-items`),A(t=>t.filter(t=>t.id!==e)),J(!1)):X.warn("Cannot delete wishlist, result is missing: %o",t)}catch(e){X.warn((0,v.safeError)(e).message)}},[ew,eu,ec]),eZ=(0,a.useCallback)(()=>{ei((0,t.jsx)(F,{handleClose:eT})),er.fireSavedListsEvent({event:"settings_modal_opened"}),J(!0)},[er,eT]),eX=(0,a.useCallback)(()=>{ei((0,t.jsx)(R,{handleClose:eT})),J(!0)},[eT]),eH=(0,a.useCallback)(async e=>{er.fireSavedListsEvent({event:"share_options_clicked"}),ei((0,t.jsx)(Z,{listId:e})),J(!0)},[er]),eQ=(0,a.useMemo)(()=>({loadingWishlist:O,wishListInitialized:en.current,removingWishListItem:B,addProductToWishlist:ez,removeProductFromWishlist:eV,wishlistProducts:E,setWishListProducts:j,findWishlistProduct:eN,savedLists:M,sharedList:eI,sharedListLoading:ex,getProductsByListId:eg,openCreateListMenu:eM,openConfigListMenu:eZ,openDeleteListMenu:eX,openShareListMenu:eH,setActionsDialogOpen:J,addWishlist:eq,editWishlist:eG,deleteWishlist:eK,currentProductManaging:z,refreshProductList:ef,savedListError:q,createWishlistShareToken:eA,getSharedWishlistItems:eE,createWishlistShareTokenLoading:ej}),[O,B,ez,eV,E,j,eN,M,eE,eg,eM,eZ,eX,eH,J,eq,eG,eK,eI,ex,z,ef,q,eA,ej]);return(0,t.jsxs)(Q.Provider,{value:eQ,children:[e,(0,t.jsx)(x,{isOpen:H,content:es,handleClose:()=>eT(!0)})]})}}]); 2
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.