import{o as j,d as J,w as y,r as K}from"./en-BuaN5eVt.js";import{t as S}from"./tag_conditions-CMVH7TPX.js";import{e as u}from"./event_dispatcher-C0GCeFv6.js";import{t as B}from"./toast-COidKN2o.js";/* empty css *//* empty css */import"./fetch_wrapper-BtIREoFd.js";const X=`
`,Y=j.deepMerge({},J,window.frcp.wishlist.texts),r={t(t,i={}){let e=Y;t.split(".").forEach(s=>{e=e[s]}),e=e;for(let s in i){const n=i[s];try{e=e.replaceAll(`{ ${s} }`,n)}catch{e=e.replace(`{ ${s} }`,n)}}return e}},Q=`
`,f={html:tt},Z={heart:Q,list:X};function tt(t,i,e,s="100%",n="100%",o=2,c="round",l="round"){return``}const w={product:it,collection:et,collectionBtnString:H,multilistDropdown:st};function it({inWishlist:t,handle:i,productId:e,variantId:s,extraClass:n,needsMultilistPopup:o,title:c}={}){n||(n="frcp-wishlist-product-btn");const l=document.createElement("div");l.className="frcp-wishlist-wrapper";let d="";return frcp.wishlist.blockSettings.button_style.indexOf("icon")>=0&&(d+=`${f.html("heart","currentColor","none")}`),frcp.wishlist.blockSettings.button_style.indexOf("text")>=0&&(d+=`${t?r.t("button.remove_text"):r.t("button.add_text")}`),d+='',l.innerHTML=`${d}`,o&&(l.innerHTML+=`${f.html("list","currentColor","none")}`),l}function et(t,i,e,s,n){const o=document.createElement("div");return o.className=`frcp-wishlist-grid-btn-wrapper ${s}`,o.innerHTML=H(t,i,e,void 0,n),o}function H(t,i,e,s,n){let o="";return o+=`${f.html("heart","currentColor","none")}`,o+='',`${o}`}function $(t,i,e,s,n){const o=t?r.t("button.remove_text"):r.t("button.add_text");let c=`tabindex='0'
aria-label="${o}"
title="${o}"
role='button'
data-frcp-in-wishlist='${t}'
data-frcp-product-handle=${e}
`;return i&&(c+=` data-frcp-product-id=${i}`),s&&(c+=` data-frcp-variant-id=${s}`),n&&(c+=` data-frcp-product-title="${n.replaceAll('"',"'")}"`),c}function E(t){return t?" frcp-wishlist-btn--remove":" frcp-wishlist-btn--add"}function st(t,i,e,s,n,o){let c=`${f.html("heart","currentColor","none")}`;c+='';const l=`${$(t,e,i,s,o)} data-frcp-list-name="${n}"`;return`${c}`}const nt={html:ot};function ot(){const t=window.location.pathname,i=`${Shopify&&Shopify.routes&&Shopify.routes.root||"/"}account/login`,e=`${Shopify&&Shopify.routes&&Shopify.routes.root||"/"}account`;return frcp.wishlist.settings.customer_account_version==="new_customer_accounts"?rt(t):ct(t,i,e)}function rt(t){const i=`/customer_authentication/login?return_to=${t}&locale=${Shopify.locale}`;return`
`}function ct(t,i,e){return`
`}const lt={html:at};function at(t,i,e,s,n){let o="",c;t.forEach(function(a){c=p.inWishlist(i,s,a),o+=`
${w.multilistDropdown(c,i,e,s,a,n)}
${a}
`});const l=document.createElement("div");return l.classList="frcp-multilist frcp-popup",l.innerHTML=`
`,l.querySelector(".frcp-multilist__edit-lists").append(pt()),l}function pt(){let t;return frcp.customerPage&&frcp.customerPage.enabled?(t=document.createElement("a"),t.href=`${Shopify&&Shopify.routes&&Shopify.routes.root||"/"}account#/wishlist`):(t=document.createElement("div"),t.addEventListener("click",()=>T.toggle())),t.classList="frcp-popup__btn frcp-popup__btn--primary",t.innerText=r.t("multilist_popup.manage_lists"),t}let O=!1;const b=".frcp-popup-wrapper";function dt(){const t=k();t.innerHTML=nt.html(),frcp.socialLogins&&frcp.socialLogins.buildWidget&&frcp.socialLogins.buildWidget(),frcp.customFormsLoader&&frcp.customFormsLoader.checkRegistrationForms&&frcp.customFormsLoader.checkRegistrationForms();const i=document.querySelector(".frcp-form__switch--registration"),e=document.querySelector(".frcp-form__switch--login");i&&i.addEventListener("click",ht),e&&e.addEventListener("click",mt)}function ut(t){const i=k(),e=lt.html(frcp.wishlist.data.listNames,frcp.wishlist.product.handle,frcp.wishlist.product.id,t,frcp.wishlist.product.title);i.append(e)}function k(){m();const t=document.createElement("div");return t.className="frcp-popup-wrapper frcp-popup-wrapper--open frcp-popup-wrapper--swall",t.addEventListener("click",i=>{i.target==t&&m(t)}),document.body.append(t),document.body.classList.add("frcp-popup-open"),document.body.classList.add("frcp-popup-open--swall"),ft(),t}function m(t){t=t||document.querySelector(b),t&&t.remove(),!document.querySelector(b)&&(document.body.classList.remove("frcp-popup-open"),document.body.classList.remove("frcp-popup-open--swall"))}function ft(){O||(document.addEventListener("click",t=>{const i=t.target.closest(".frcp-popup__close");if(i){const e=i.closest(b);m(e)}}),document.addEventListener("keyup",t=>{t.key==="Escape"&&document.querySelectorAll(b).forEach(e=>m(e))}),O=!0)}function ht(){const t=document.querySelector(".frcp-login--login");t.classList.remove("frcp-login--login"),t.classList.add("frcp-login--registration")}function mt(){const t=document.querySelector(".frcp-login--registration");t.classList.remove("frcp-login--registration"),t.classList.add("frcp-login--login")}const _={showLogin:dt,showMultilist:ut,showWrapper:k,close:m},_t=".frcp-wishlist-modal";function wt(){if(document.querySelector(_t))_.close();else{const i=_.showWrapper();gt(i)}}function gt(t){frcp.wishlist.buildModal?P(t):(document.addEventListener("frcp.wishlist.modalScriptLoaded",()=>{P(t)}),vt())}function P(t){const i=document.createElement("div");i.classList.add("frcp-wishlist-modal"),frcp.wishlist.buildModal(i),i.append(bt()),t.append(i)}function bt(t){const i=document.createElement("div");return i.classList.add("frcp-popup__close"),i.innerText="×",i}function vt(){A("script",{src:window.frcp.wishlist.modalJsUrl,type:"module",defer:!0}),A("link",{rel:"stylesheet",media:"all",href:window.frcp.wishlist.modalCssUrl})}function A(t,i){const e=document.createElement(t);for(const s in i)e[s]=i[s];document.head.append(e)}const T={toggle:wt},Lt={html:yt};function yt(t,i){const e=document.createElement("div");e.className=`frcp-wishlist-link-wrapper frcp-wishlist-link-wrapper--${t}`;const s=`${i}`,n=Shopify&&Shopify.routes&&Shopify.routes.root||"/",o=frcp.wishlist.settings.customer_account_version==="new_customer_accounts",c=o?`https://shopify.com/${frcp.shopId}/account/pages/${frcp.wishlist.pageHandle}?locale=${Shopify.locale}`:`${n}account#/wishlist`;let l;const d=!frcp.wishlist.settings.wishlist_enable_guest&&!frcp.wishlist.profile.id,a=frcp.customerPage&&frcp.customerPage.enabled;return!(frcp.wishlist.settings.wishlist_enable_modal||!o&&!a)||d?(l=document.createElement("a"),l.href=c):(l=document.createElement("span"),l.addEventListener("click",()=>T.toggle())),l.dataset.count=1,l.classList.add("frcp-wishlist-link"),l.innerHTML=`${s}${f.html("heart","currentColor","currentColor")}`,e.append(l),e}const W={html:St};function St(t){const i=document.createElement("span"),e=f.html("heart","currentColor","none","16px","16px"),s=`${r.t("navigation.text")}`;i.className="frcp-wishlist-nav-link-wrapper";const n=Shopify&&Shopify.routes&&Shopify.routes.root||"/",o=frcp.wishlist.settings.customer_account_version==="new_customer_accounts",c=o?`https://shopify.com/${frcp.shopId}/account/pages/${frcp.wishlist.pageHandle}?locale=${Shopify.locale}`:`${n}account#/wishlist`,d=`${`${t}`}${e}`;let a;const x=!frcp.wishlist.settings.wishlist_enable_guest&&!frcp.wishlist.profile.id,I=frcp.customerPage&&frcp.customerPage.enabled;return!(frcp.wishlist.settings.wishlist_enable_modal||!o&&!I)||x?(a=document.createElement("a"),a.href=c):(a=document.createElement("span"),a.addEventListener("click",()=>T.toggle())),a.dataset.count=1,a.classList.add("frcp-wishlist-nav-link"),a.innerHTML=`${d}${s}`,i.append(a),i}const h={attach:Wt,attachWishlistLinks:R,attachOnCollection:F,attachProductBtnAtPlaceholder:Gt,wishlistCount:v},M="frcp-wishlist-button-added",$t='form[action$="/cart/add"] .product-form__buttons, form[action*="/cart/add?oseid="] .product-form__buttons',Et='.addToCartForm, .product-action, form[action$="/cart/add"], form[action*="/cart/add?oseid="]',kt="floating_botttom_left",Tt="floating_botttom_right",Ct="none",xt='[href*="/account"]',It='[href*="/products/"]',Ot="none",Pt="placeholder",At=[".card-wrapper","#CollectionSection .grid-item",".productgrid--item",".product-index .prod-container",".product-item",".grid__item .indiv-product",".product-wrap",".grid-product__wrapper",".grid__item .grid-product__content",".ProductItem","#product-loop .product",".grid__item .product",".product-card",".card--holder .card--catalog",".gt_productlist-item",".collection-list__item",".grid__item .grid-link",".grid__item .card",".grid-item.grid-product .grid-item__content",".product-block .block-inner",".snize-product",".evm-ws-card"].join(",");function Wt(){Bt(),R(),F()}function R(){Nt(),Mt()}function Mt(){frcp.wishlist.blockSettings.floating_link_placement!=Ct&&document.body.append(Lt.html(frcp.wishlist.blockSettings.floating_link_placement,v()))}function v(t){let i=0;return t||(t=frcp.wishlist.data.activeList),Object.entries(frcp.wishlist.data.lists[t]).forEach(([e,s])=>{i+=s.length}),frcp.wishlist.guestSyncing||(Object.entries(frcp.wishlist.data.guest.add).forEach(([e,s])=>{i+=s.length}),Object.entries(frcp.wishlist.data.guest.remove).forEach(([e,s])=>{i-=s.length})),i}function Nt(){if(!frcp.wishlist.blockSettings.navigation_link)return;const t=frcp.wishlist.blockSettings.navigation_link_css_selector||xt;document.querySelectorAll(t).forEach(e=>qt(e,frcp.wishlist.blockSettings.navigation_link_css_selector))}function qt(t,i){if(!i&&t.href.includes("/account/")&&!t.href.includes("/account/login"))return;const e=t.parentElement;if(e.nodeName=="LI"){const s=document.createElement("li");s.className="frcp-wishlist-nav-link-li",s.append(W.html(v())),e.before(s)}else t.before(W.html(v()))}function Bt(){if(!frcp.wishlist.product)return;const t=frcp.wishlist.product.tags;if(!S.productTagConditonsValid(t))return;const i=p.getVariantId(),e=p.needsMultilistPopup(),s=w.product({inWishlist:p.inWishlist(frcp.wishlist.product.handle,i),handle:frcp.wishlist.product.handle,productId:frcp.wishlist.product.id,variantId:i,extranClass:null,title:frcp.wishlist.product.title,needsMultilistPopup:e});Rt(s)||Vt(s)||Ft(s)||Dt(s)||(Shopify.designMode&&Ht(),s.classList.add("frcp-wishlist-wrapper--left"),document.body.append(s))}function Ht(){alert("We could not add the wishlist button automatically on the selected option. We defaulted to a floating left button. Please use custom placement or contact support@froonze.com")}function Rt(t){if(frcp.wishlist.blockSettings.product_css_selector&&frcp.wishlist.blockSettings.product_css_selector.length>0){const i=document.querySelector(frcp.wishlist.blockSettings.product_css_selector);if(i)return i.after(t),!0}}function Ft(t){const i=document.querySelector($t);if(i)return i.after(t),!0}function Dt(t){const i=document.querySelector(Et);if(i)return i.append(t),!0}function Vt(t){if(frcp.wishlist.blockSettings.placement==kt)return t.classList.add("frcp-wishlist-wrapper--left"),document.body.append(t),!0;if(frcp.wishlist.blockSettings.placement==Tt)return t.classList.add("frcp-wishlist-wrapper--right"),document.body.append(t),!0}function F(){if(frcp.wishlist.blockSettings.collections_wishlist_button!=Ot)if(frcp.wishlist.blockSettings.collections_wishlist_button==Pt)document.querySelectorAll(".frcp-wishlist-grid-btn-wrapper").forEach(zt);else{const t=document.querySelectorAll(It),i=`frcp-wishlist-grid-btn-wrapper--${frcp.wishlist.blockSettings.collections_wishlist_button}`;t.forEach(function(e){Ut(e,i)})}}function Ut(t,i){const e=t.closest(At);if(!e||e.classList.contains("frcp-wishlist-grid-item"))return;e.classList.add("frcp-wishlist-grid-item");const s=t.href.split("/products/")[1].split("?")[0],n=decodeURI(s);e.append(w.collection(p.inWishlist(n),n,void 0,i))}function zt(t){const i=t.dataset.frcpProductHandle,e=t.dataset.frcpProductTitle,s=t.dataset.frcpProductId,n=t.dataset.frcpVariantId;let o=t.dataset.frcpProductTags;o&&(o=JSON.parse(o)),S.productTagConditonsValid(o)&&(t.innerHTML=w.collectionBtnString(p.inWishlist(i,n),i,s,n,e),t.parentElement.classList.add("frcp-wishlist-grid-item"))}function Gt(t,i,e,s,n,o){const c=document.querySelector(t);if(!c||c.classList.contains(M))return;const l=w.product({inWishlist:p.inWishlist(i),handle:i,productId:e,variantId:s,title:o,extraClass:"frcp-wishlist-preview-product-btn",needsMultilistPopup:p.needsMultilistPopup()});n=="after"?c.after(l):n=="before"?c.before(l):(n=="prepend",c.append(l)),c.classList.add(M)}const jt={call(){window.history&&(history.pushState=function(t){return function(){var i=t.apply(this,arguments);return u.history.pushState(),u.history.locationChange(),i}}(history.pushState),history.replaceState=function(t){return function(){var i=t.apply(this,arguments);return u.history.replaceState(),u.history.locationChange(),i}}(history.replaceState))}},p={call:Xt,inWishlist:C,getVariantId:g,submitWishlist:U,updateWishlistStatus:L,needsMultilistPopup:G,updateWishlistButtonsStatus:V},D="product",Jt="collection",Kt="none";function Xt(){if(!window.frcp.plugins.wishlist){Shopify.designMode&&Yt();return}if(S.customerTagsConditionsValid()){if(y.sync(),frcp.wishlist.requestType!=D&&frcp.wishlist.blockSettings.collections_wishlist_button==Kt){h.attachWishlistLinks();return}h.attach(),jt.call(),Qt()}}function Yt(){alert("You have not enabled the Wishlist paid plugin. Please enable it in the Froonze app admin.")}function Qt(){document.addEventListener("click",U),G()&&pi(),document.addEventListener("frcp.locationChange",N),document.addEventListener("theme:loading:end",N)}function L(t,i,e){if(t.dataset.frcpListName&&e!=t.dataset.frcpListName)return;t.dataset.frcpInWishlist=i,t.classList.toggle("frcp-wishlist-btn--remove",i),t.classList.toggle("frcp-wishlist-btn--add",!i);const s=r.t(i?"button.remove_text":"button.add_text");t.setAttribute("title",s),t.setAttribute("aria-label",s);const n=t.querySelector(".frcp-wishlist-btn__text");n&&(n.innerText=s)}function Zt(t,i){if(L(i,t.inWishlist,t.list),t.variantExternalIds.forEach(e=>{y.update({handle:i.dataset.frcpProductHandle,variantId:parseInt(e),remove:!t.inWishlist,guestId:t.guestId,list:t.list})}),V({handle:i.dataset.frcpProductHandle,list:t.list,skipLoading:!0}),i.classList.remove("frcp-wishlist-btn--loading"),t.list==frcp.wishlist.data.activeList){const e=t.variantExternalIds.length;z(t.inWishlist?e:-1*e)}t.inWishlist&&ei(t),ti(t,i),ri(t.productTitle||i.dataset.frcpProductTitle,t.inWishlist),u.wishlist.update({data:t})}function V({handle:t,list:i,resetCount:e,skipLoading:s}){let n=".frcp-wishlist-btn";s&&(n+=":not(.frcp-wishlist-btn--loading)"),t&&(n+=`[data-frcp-product-handle="${t}"]`),document.querySelectorAll(n).forEach(o=>{let c=C(o.dataset.frcpProductHandle,o.dataset.frcpVariantId);L(o,c,i)}),e&&ai()}function ti(t,i){const e=i.dataset.frcpVariantId||g();if(frcp.wishlist.profile.id||e)return;const s=i.dataset.frcpProductHandle,n=t.list;frcp.wishlist.data.lists[n]&&frcp.wishlist.data.lists[n][s]&&(frcp.wishlist.data.lists[n][s].forEach(o=>{y.update({handle:s,variantId:parseInt(o),remove:!0,guestId:t.guestId,list:n})}),z(-1*frcp.wishlist.data.lists[n][s].length))}function ii(){return!frcp.wishlist.profile.id&&!frcp.wishlist.settings.wishlist_enable_guest}function U(t){const i=t.target.closest(".frcp-wishlist-btn");if(!i||i.classList.contains("frcp-wishlist-btn--loading"))return;if(t.preventDefault(),t.stopPropagation(),ii()){_.showLogin();return}i.classList.add("frcp-wishlist-btn--loading");const e={handle:i.dataset.frcpProductHandle,action:i.dataset.frcpInWishlist=="true"?"remove":"add",customerExternalId:frcp.wishlist.profile.id,froonzeToken:frcp.wishlist.profile.froonzeToken,productExternalId:i.dataset.frcpProductId||null,variantExternalId:i.dataset.frcpVariantId||g(),list:i.dataset.frcpListName||frcp.wishlist.data.activeList,guestId:frcp.wishlist.data.guest.guestId};K.updateWishlist(e,function(s){Zt(s.data.updateWishlist,i)},oi)}function ei(t){t.productId&&(frcp.wishlist.integrations.google_analytics&&si(t),frcp.wishlist.integrations.facebook_pixel&&ni(t))}function si(t){if(window.gtag){gtag("event","addToWishlist",{event_action:"add",event_category:"Wishlist",event_label:t.productTitle,value:t.productId});return}window.ga&&ga("send",{hitType:"event",eventCategory:"Wishlist",eventAction:"add",eventLabel:t.productTitle,eventValue:t.productId})}function ni(t){window.fbq&&window.fbq("track","AddToWishlist",{content_ids:[t.productId],content_type:"product_group",content_name:t.productTitle,content_category:"",currency:window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.currency||t.currency,value:t.productPrice})}function g(){let t=window.location.search;if(t.indexOf("variant=")<0)return frcp.wishlist.product&&parseInt(frcp.wishlist.product.variants[0].id);t=t.substring(1);let i=t.split("variant=")[1].split("&")[0];return parseInt(i)}function oi(){B.open({text:r.t("error_message.message"),type:"error",timer:3e3})}function ri(t,i){const e=i?r.t("success_message.added"):r.t("success_message.removed");B.open({text:r.t("success_message.message",{product_title:t||"",added_removed:e}),type:"success",timer:3e3})}function N(){frcp.wishlist.requestType==D&&li(),frcp.wishlist.requestType==Jt&&ci()}function ci(){h.attachOnCollection()}function li(){const t=document.querySelector(".frcp-wishlist-product-btn");if(!t)return;const i=g();t.dataset.frcpVariantId=i;const e=C(t.dataset.frcpProductHandle,i);L(t,e)}function C(t,i=void 0,e=void 0){i&&(i=parseInt(i)),e||(e=frcp.wishlist.data.activeList);const s=frcp.wishlist.data&&frcp.wishlist.data.lists[e]&&frcp.wishlist.data.lists[e][t]&&(!i||frcp.wishlist.data.lists[e][t].indexOf(i)>=0),n=frcp.wishlist.data.guest.add[t]&&(!i||frcp.wishlist.data.guest.add[t].indexOf(i)>=0),o=frcp.wishlist.data.guest.remove[t]&&frcp.wishlist.data.guest.remove[t].indexOf(i)>=0;return(s||n)&&!o||!1}function z(t){let i;document.querySelectorAll(".frcp-wishlist-link-count, .frcp-wishlist-nav-link__count").forEach(e=>{i=(parseInt(e.innerText)||0)+t,i<0&&(i=0),e.innerText=i,e.dataset.count=i,e.closest(".frcp-wishlist-nav-link, .frcp-wishlist-link").dataset.count=i})}function ai(){const t=h.wishlistCount();document.querySelectorAll(".frcp-wishlist-link-count, .frcp-wishlist-nav-link__count").forEach(i=>{i.innerText=t,i.dataset.count=t,i.closest(".frcp-wishlist-nav-link, .frcp-wishlist-link").dataset.count=t})}function G(){return frcp.wishlist.settings.wishlist_enable_multilist&&frcp.wishlist.profile.id&&frcp.wishlist.product&&frcp.wishlist.data.listNames.length>1}function pi(){const t=document.querySelector(".frcp-wishlist-multilist-btn");t&&t.addEventListener("click",di)}function di(t){let i=t.target.closest(".frcp-wishlist-wrapper").querySelector(".frcp-wishlist-btn"),e;i&&(e=i.dataset.frcpVariantId),e=e||g(),t.stopPropagation(),_.showMultilist(e)}const ui={html:fi};function fi(){const t=frcp.wishlist.blockSettings;let i=t.border_radius,e=t.floating_link_border_radius,s=t.collection_button_border_radius;return t.border_radius>0&&(i+="px"),t.floating_link_border_radius>0&&(e+="%"),t.floating_link_border_radius>0&&(s+="%"),`
`}const q=()=>{document.head.insertAdjacentHTML("beforeend",ui.html()),window.frcp||(window.frcp={}),frcp.wishlist||(frcp.wishlist={}),!frcp.wishlist.initialized&&(frcp.wishlist.attachOnCollection=h.attachOnCollection,frcp.wishlist.attachProductBtnAtPlaceholder=h.attachProductBtnAtPlaceholder,frcp.wishlist.submitWishlist=p.submitWishlist,frcp.wishlist.inWishlist=p.inWishlist,frcp.wishlist.updateWishlistStatus=p.updateWishlistStatus,frcp.wishlist.initialize=p.call,frcp.wishlist.showLogin=_.showLogin,frcp.wishlist.updateWishlistButtonsStatus=p.updateWishlistButtonsStatus,p.call(),window.frcp.wishlist.initialized=!0,u.wishlist.installed())};document.readyState!=="loading"?q():document.addEventListener("DOMContentLoaded",q);
//# sourceMappingURL=product_wishlist-BqygoyeF.js.map