Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appmate/wishlist

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appmate/wishlist - npm Package Compare versions

Comparing version 4.25.26 to 4.25.27

2

components/button.js

@@ -1,2 +0,2 @@

import{LitElement as h,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/components/icon.js";var l=class extends h{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.showIcon=!1;this.showText=!1;this.iconUnstyled=!1;this.fullWidth=!1;this.alignSelf="center";this.alignContent="center";this.floatingUi=new u(this);this.getCounterFloating=()=>{var i,e,n,r;if(!((i=this.counter)!=null&&i.floating))return;let t=((n=(e=this.counter)==null?void 0:e.floating)==null?void 0:n.reference)==="icon"?(r=this.iconElement)!=null?r:this:this;return{...this.counter.floating,reference:t}}}get iconElement(){return this.querySelector(".wk-icon")}render(){var n,r,s,a;let t=(n=this.alignSelf)!=null?n:"center",i=(r=this.alignContent)!=null?r:"center",e=["wk-button",`wk-align-${t}`,`wk-align-content-${i}`,this.selected&&"wk-selected",this.fullWidth&&"wk-full-width"].filter(c=>!!c).join(" ");return this.href?o`
import{LitElement as h,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/components/icon.js";var l=class extends h{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.showIcon=!1;this.showText=!1;this.iconUnstyled=!1;this.fullWidth=!1;this.alignSelf="center";this.alignContent="center";this.floatingUi=new u(this);this.getCounterFloating=()=>{var i,e,n,r;if(!((i=this.counter)!=null&&i.floating))return;let t=((n=(e=this.counter)==null?void 0:e.floating)==null?void 0:n.reference)==="icon"?(r=this.iconElement)!=null?r:this:this;return{...this.counter.floating,reference:t}}}get iconElement(){return this.querySelector(".wk-icon")}render(){var n,r,s,a;let t=(n=this.alignSelf)!=null?n:"center",i=(r=this.alignContent)!=null?r:"center",e=["wk-button",`wk-align-${t}`,`wk-align-content-${i}`,this.selected&&"wk-selected",this.fullWidth&&"wk-full-width"].filter(c=>!!c).join(" ");return this.href?o`
<a

@@ -3,0 +3,0 @@ href=${this.href}

@@ -1,1 +0,1 @@

import{LitElement as s,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as l}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/controllers.js";var t=class extends s{constructor(){super(...arguments);this.value=0;this.showNumber=!1;this.showBrackets=!1;this.floatingUi=new l(this)}render(){let e=this.showNumber?this.value:"",o=["wk-counter",this.showBrackets&&"wk-brackets",this.floating&&"wk-bubble",this.floating&&!this.showNumber&&"wk-dot"].filter(r=>!!r).join(" ");return a`<span class=${o}>${e}</span>`}createRenderRoot(){return this}};t.properties={value:{type:Number},floating:{type:Object},showNumber:{type:Boolean,attribute:"show-number"},showBrackets:{type:Boolean,attribute:"show-brackets"}};customElements.get("wk-counter")||customElements.define("wk-counter",t);export{t as Counter};
import{LitElement as s,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as l}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/controllers.js";var t=class extends s{constructor(){super(...arguments);this.value=0;this.showNumber=!1;this.showBrackets=!1;this.floatingUi=new l(this)}render(){let e=this.showNumber?this.value:"",o=["wk-counter",this.showBrackets&&"wk-brackets",this.floating&&"wk-bubble",this.floating&&!this.showNumber&&"wk-dot"].filter(r=>!!r).join(" ");return a`<span class=${o}>${e}</span>`}createRenderRoot(){return this}};t.properties={value:{type:Number},floating:{type:Object},showNumber:{type:Boolean,attribute:"show-number"},showBrackets:{type:Boolean,attribute:"show-brackets"}};customElements.get("wk-counter")||customElements.define("wk-counter",t);export{t as Counter};

@@ -1,2 +0,2 @@

import{LitElement as l,html as s}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{Icon as a}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/components/icon.js";var i=class extends l{constructor(){super();this.icon="caret"}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}render(){if(!this.option)return;let t=this.option,e=`options[${this.option.name}]`,n=`${this.app.utils.url.handlelize(this.id)}-select`;return s`
import{LitElement as l,html as s}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{Icon as a}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/components/icon.js";var i=class extends l{constructor(){super();this.icon="caret"}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}render(){if(!this.option)return;let t=this.option,e=`options[${this.option.name}]`,n=`${this.app.utils.url.handlelize(this.id)}-select`;return s`
<div class="wk-option-select">

@@ -3,0 +3,0 @@ <label class="wk-label" for=${n}>${t.name}</label>

@@ -1,2 +0,2 @@

import{LitElement as s,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as r}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/controllers.js";var n=class extends s{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new r(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}render(){var e;let t=["wk-popover",this.transition?`wk-${this.transition}`:"",this.elementClass].filter(i=>!!i).join(" ");return o`
import{LitElement as s,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{FloatingUiController as r}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/controllers.js";var n=class extends s{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new r(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}render(){var e;let t=["wk-popover",this.transition?`wk-${this.transition}`:"",this.elementClass].filter(i=>!!i).join(" ");return o`
<div class=${t}>

@@ -3,0 +3,0 @@ <div class="wk-text">${this.getText()}</div>

{
"name": "@appmate/wishlist",
"version": "4.25.26",
"version": "4.25.27",
"description": "Wishlist King SDK",

@@ -5,0 +5,0 @@ "main": "wishlist-app.js",

@@ -1,1 +0,1 @@

var te=Object.create;var J=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var N=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var ne=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ie(e))!oe.call(i,r)&&r!==t&&J(i,r,{get:()=>e[r],enumerable:!(s=se(e,r))||s.enumerable});return i};var ae=(i,e,t)=>(t=i!=null?te(re(i)):{},ne(e||!i||!i.__esModule?J(t,"default",{value:i,enumerable:!0}):t,i));var z=N((He,G)=>{var k=1e3,U=k*60,E=U*60,v=E*24,ce=v*7,he=v*365.25;G.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return pe(i);if(t==="number"&&isFinite(i))return e.long?ue(i):de(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function pe(i){if(i=String(i),!(i.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),s=(e[2]||"ms").toLowerCase();switch(s){case"years":case"year":case"yrs":case"yr":case"y":return t*he;case"weeks":case"week":case"w":return t*ce;case"days":case"day":case"d":return t*v;case"hours":case"hour":case"hrs":case"hr":case"h":return t*E;case"minutes":case"minute":case"mins":case"min":case"m":return t*U;case"seconds":case"second":case"secs":case"sec":case"s":return t*k;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function de(i){var e=Math.abs(i);return e>=v?Math.round(i/v)+"d":e>=E?Math.round(i/E)+"h":e>=U?Math.round(i/U)+"m":e>=k?Math.round(i/k)+"s":i+"ms"}function ue(i){var e=Math.abs(i);return e>=v?H(i,e,v,"day"):e>=E?H(i,e,E,"hour"):e>=U?H(i,e,U,"minute"):e>=k?H(i,e,k,"second"):i+" ms"}function H(i,e,t,s){var r=e>=t*1.5;return Math.round(i/t)+" "+s+(r?"s":"")}});var Z=N((De,Q)=>{function me(i){t.debug=t,t.default=t,t.coerce=h,t.disable=o,t.enable=r,t.enabled=n,t.humanize=z(),t.destroy=u,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let c=0;for(let p=0;p<l.length;p++)c=(c<<5)-c+l.charCodeAt(p),c|=0;return t.colors[Math.abs(c)%t.colors.length]}t.selectColor=e;function t(l){let c,p=null,y,A;function m(...d){if(!m.enabled)return;let w=m,b=Number(new Date),F=b-(c||b);w.diff=F,w.prev=c,w.curr=b,c=b,d[0]=t.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let C=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(S,T)=>{if(S==="%%")return"%";C++;let P=t.formatters[T];if(typeof P=="function"){let L=d[C];S=P.call(w,L),d.splice(C,1),C--}return S}),t.formatArgs.call(w,d),(w.log||t.log).apply(w,d)}return m.namespace=l,m.useColors=t.useColors(),m.color=t.selectColor(l),m.extend=s,m.destroy=t.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(y!==t.namespaces&&(y=t.namespaces,A=t.enabled(l)),A),set:d=>{p=d}}),typeof t.init=="function"&&t.init(m),m}function s(l,c){let p=t(this.namespace+(typeof c=="undefined"?":":c)+l);return p.log=this.log,p}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let c,p=(typeof l=="string"?l:"").split(/[\s,]+/),y=p.length;for(c=0;c<y;c++)p[c]&&(l=p[c].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function o(){let l=[...t.names.map(a),...t.skips.map(a).map(c=>"-"+c)].join(",");return t.enable(""),l}function n(l){if(l[l.length-1]==="*")return!0;let c,p;for(c=0,p=t.skips.length;c<p;c++)if(t.skips[c].test(l))return!1;for(c=0,p=t.names.length;c<p;c++)if(t.names[c].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function h(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Q.exports=me});var Y=N((f,D)=>{f.formatArgs=fe;f.save=we;f.load=ye;f.useColors=ge;f.storage=be();f.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();f.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ge(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function fe(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+D.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,s=0;i[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(s=t))}),i.splice(s,0,e)}f.log=console.debug||console.log||(()=>{});function we(i){try{i?f.storage.setItem("debug",i):f.storage.removeItem("debug")}catch(e){}}function ye(){let i;try{i=f.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function be(){try{return localStorage}catch(i){}}D.exports=Z()(f);var{formatters:Ce}=D.exports;Ce.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var V=(i=21)=>crypto.getRandomValues(new Uint8Array(i)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");var g=class{constructor(e){this.element=e}replace(e){var t;return(t=this.element)==null||t.replaceWith(e),e}append(e){var t;return(t=this.element)==null||t.append(e),e}prepend(e){var t;return(t=this.element)==null||t.prepend(e),e}insertBefore(e){var t;return(t=this.element)==null||t.before(e),e}insertAfter(e){var t;return(t=this.element)==null||t.after(e),e}closest(e,t=5){if(!this.element)return new g;if(typeof e=="object")return this.searchByStyle(e,this.element,r=>r.parentElement,t);let s=this.element.closest(e);return s?new g(s):new g}find(e){var s;let t=(s=this.element)==null?void 0:s.querySelector(e);return t?new g(t):new g}searchByStyle(e,t,s,r=5){if(r<0||!t)return null;let o=getComputedStyle(t);if(Object.entries(e).every(([h,u])=>o.getPropertyValue(h)===u))return new g(t);let a=s(t);return a?this.searchByStyle(e,a,s,r-1):null}};var M=class{constructor({routeUtil:e}){this.subscriber=[],this.routeUtil=e,this.observer=new MutationObserver(t=>{t.reduce((s,r)=>s.concat(Array.from(r.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("wk-skip")).forEach(s=>{s instanceof Element&&this.scan(s)})}),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!1})}watch(e,t){let s={target:e,callback:t};this.subscriber.push(s),K(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document)}shouldSkip(e,{skipHidden:t}){return t&&e instanceof HTMLElement?e.offsetParent===null:!1}scan(e){e&&this.subscriber.filter(t=>K(t,this.routeUtil.parse(window.location.pathname))).forEach(t=>{let s=e instanceof Element&&e.matches(t.target.selector)&&!this.shouldSkip(e,{skipHidden:!!t.target.skipHidden});if(s&&this.notify(t,e),s&&t.target.firstMatch)return;let r=e.querySelectorAll(t.target.selector);for(let o of r)if(!this.shouldSkip(o,{skipHidden:!!t.target.skipHidden})&&(this.notify(t,o),t.target.firstMatch))break})}notify(e,t){if(!t.hasAttribute("wk-skip")){t.setAttribute("wk-skip","");let s=new g(t);e.callback(s)}}};function K({target:i},e){if(!i.pageType)return!0;if(!e.pageType)return!1;let t=Array.isArray(i.pageType)?i.pageType:[i.pageType];return t.includes("all")?!0:t.includes(e.pageType)}var le=[{pageType:"product",match:i=>i.includes("/products/")},{pageType:"collection",match:i=>i.includes("/collections/")&&!i.includes("/products/")},{pageType:"account",match:i=>i.includes("/account/")||i.endsWith("/account")},{pageType:"challenge",match:i=>i.endsWith("/account")},{pageType:"blog",match:i=>i.includes("/blog/")},{pageType:"cart",match:i=>i.includes("/cart/")||i.endsWith("/cart")},{pageType:"wishlist",match:(i,{wishlistUrl:e})=>i.includes(e)},{pageType:"page",match:i=>i.includes("/pages/")},{pageType:"search",match:i=>i.includes("/search")},{pageType:"home",match:i=>i.length<4}],R=class{constructor({wishlistUrl:e}){this.wishlistUrl=e}parse(e){for(let t of le)if(t.match(e,{wishlistUrl:this.wishlistUrl}))return{pageType:t.pageType};return{pageType:"unknown"}}};var _=class{constructor(e){this.locale={};var t;this.initLocale((t=e==null?void 0:e.locale)!=null?t:{})}initLocale(e){this.locale=this.decodeLocale(e)}decodeHtmlEntities(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'")}decodeLocale(e){let t={};for(let s in e){t[s]={};for(let r in e[s])t[s][r]=this.decodeHtmlEntities(e[s][r])}return t}translate(e,t){var n;let[s,r]=e.split("."),o=(n=this.locale[s])==null?void 0:n[r];return o?t?Object.entries(t).reduce((a,[h,u])=>a.replace(new RegExp(`{{\\s*${h}\\s*}}`,"g"),u),o):o:`translation missing: ${e}`}};var I=class{constructor({rootUrl:e,wishlistUrl:t}){this._rootUrl=e,this.route=new R({wishlistUrl:t}),this.observer=new M({routeUtil:this.route}),this.locale=new _,this.watch=this.observer.watch.bind(this.observer)}getPageType(e=window.location.pathname){return this.route.parse(e).pageType}getWishlistId(e){if(!e)return null;e instanceof URL&&(e=e.pathname);let t=e.replace(this._rootUrl,"/").split("/");return t.length===4?t.pop():"mine"}getProductHandle(e){var t,s;return e?(e instanceof URL&&(e=e.pathname),(s=(t=e.split("/").pop())==null?void 0:t.split("?")[0])==null?void 0:s.split("#")[0]):null}getVariantId(e,t){var r;let s=null;if(e&&(e instanceof URL&&(e=e.pathname),s=new URLSearchParams(e.split("?")[1]).get("variant")),!s&&t)try{s=new FormData((r=t.element)!=null?r:t).get("id")}catch(o){console.warn("Failed to parse variant from product form.",o)}return s}translate(e,t){return this.locale.translate(e,t)}createComponent(e,t){var r;let s=document.createElement(e);if(t!=null&&t.dataset&&Object.entries(t==null?void 0:t.dataset).forEach(([o,n])=>{n&&(typeof n=="boolean"?s.dataset[o]="":typeof n=="object"?s.dataset[o]=JSON.stringify(n):s.dataset[o]=n)}),t!=null&&t.props&&Object.entries(t==null?void 0:t.props).forEach(([o,n])=>{if(o==="floating"&&n){let a=n,h=(a==null?void 0:a.reference)instanceof g?a.reference.element:a.reference;if(typeof h=="object"&&"id"in h){h.setAttribute("wk-id",V()),s[o]={...a,reference:`[wk-id="${h.getAttribute("wk-id")}"]`};return}}s[o]=n}),(r=t==null?void 0:t.wrap)!=null&&r.name){let o=this.createElement(t.wrap.name,t.wrap.props,s);return o.setAttribute("wk-skip",""),o}return s}createHeadlessComponent(e,t){var o;let s=t.host.element?t.host.element:t.host;if(!s)throw new Error("Headless host is undefined");t.dataset&&Object.entries(t.dataset).forEach(([n,a])=>{a&&(typeof a=="boolean"?s.dataset[n]="":typeof a=="object"?s.dataset[n]=JSON.stringify(a):s.dataset[n]=a)});let r=(o=window.headlessElements)==null?void 0:o.store.get(e);if(!r)throw new Error(`Headless element not found: ${e}`);return new r(s)}createElement(e,t={},...s){let r=Object.assign(document.createElement(e),t);return s&&r.append(...s),r}};var x=class{constructor(){this.dispatcher=document}publish(e){this.dispatcher.dispatchEvent(new CustomEvent(e.name,{detail:e,bubbles:!1,cancelable:!1}))}once(e,t){let s=r=>{this.dispatcher.removeEventListener(e,s),t(r)};this.subscribe(e,s)}subscribe(e,t){this.dispatcher.addEventListener(e,s=>{let r=s;t({name:r.type,data:r.detail.data})})}subscribeMany(e){return Object.entries(e).map(([t,s])=>this.subscribe(t,s))}};var ee=ae(Y()),W=(0,ee.default)("wk:app");window.headlessElements||(window.headlessElements={store:new Map,define(i,e){var t;(t=window.headlessElements)==null||t.store.set(i,e)}});var X=class{constructor({dependencies:e=[],...t}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=e=>this.state.promise.addToCart(e);this.addAllToCart=e=>this.state.promise.addAllToCart(e);this.addWishlistItem=e=>this.state.promise.addWishlistItem(e);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=e=>this.state.promise.loadProductInfo(e);this.loadShopifyProduct=e=>this.state.promise.loadShopifyProduct(e);this.loadWishlist=e=>this.state.promise.loadWishlist(e);this.loadWishlistItem=e=>this.state.promise.loadWishlistItem(e);this.publishWishlistEvent=e=>this.state.promise.publishWishlistEvent(e);this.publishWishlistProductEvent=e=>this.state.promise.publishWishlistProductEvent(e);this.removeWishlistItem=e=>this.state.promise.removeWishlistItem(e);this.shareWishlist=e=>this.state.promise.shareWishlist(e);this.updateWishlistItem=e=>this.state.promise.updateWishlistItem(e);this.config=this.parseConfig(t),this.settings=this.parseSettings(t),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,W("Create app",{config:this.config,settings:this.settings,customer:this.customer}),this.events=new x,this.theme=new I({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl}),this.initDevMode();let{stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n}=this.parseDependencies(e);W("Init dependecies",{dependencies:e,stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n}),this.initStyles({stylesheets:s,iconSetUrl:o,localeUrl:n}),this.initScripts(r),this.initLoginActionQueue(),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load(),window.WishlistKing=this,this.events.publish({name:"wk:app:created",data:{}})}get loaded(){return this._loaded}get state(){return O(this._state)}get apis(){return O(this._apis)}get utils(){return O(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var e;return!!((e=this.customer)!=null&&e.id)}getSessionId(){let e=window.localStorage.getItem("wk_session_id");if(e)return e;let t=window.localStorage.getItem("appmate-session");if(t)try{let s=JSON.parse(t).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(e){var t;return window.localStorage.setItem("wk_session_id",e),(t=this._apis)==null||t.tracking.setSessionId(e),e}async load(){return this._loadPromise?this._loadPromise:(W("Load remaining app code"),this._loadPromise=(async()=>{let[{WishlistState:e},{ShopifyApi:t,WishlistApi:s,TrackingApi:r},{MoneyUtil:o,UrlUtil:n,ProductUtil:a}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/utils.js")]);this.initUtils({MoneyUtil:o,UrlUtil:n,ProductUtil:a}),this.initApis({WishlistApi:s,ShopifyApi:t,TrackingApi:r}),await this.initState({WishlistState:e}),this.initCustomerSession(),this.initUrlChangeEvents(),this.trackCurrentPage(),this._loaded=!0,this.events.publish({name:"wk:app:loaded",data:{}})})())}initUtils({UrlUtil:e,MoneyUtil:t,ProductUtil:s}){this._utils={url:new e({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:this.config.shop.domain,placeholderImageUrl:this.config.products.fallbackImage,fileUrl:this.routes.fileUrl}),money:new t({moneyFormat:this.config.shop.moneyFormat,moneyFormatWithCurrency:this.config.shop.moneyFormatWithCurrency}),product:new s}}initApis({WishlistApi:e,ShopifyApi:t,TrackingApi:s}){var r,o,n;this._apis={wishlist:new e({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType(),productMetafields:this.config.products.metafields}),shopify:new t({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(o=this.config.customer.id)!=null?o:void 0,customerEmail:(n=this.config.customer.email)!=null?n:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:e}){return this._state=new e({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this._state.init()}async initStyles({stylesheets:e,iconSetUrl:t,localeUrl:s}){if(!(e!=null&&e.length)&&!t){this.onStylesLoaded();return}try{await Promise.all([...(e!=null?e:[]).map(r=>new Promise((o,n)=>{let a=document.createElement("link");a.rel="stylesheet",a.href=r,a.onload=o,a.onerror=n,document.head.appendChild(a)})),t?Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/components/icon.js"),import(t)]).then(([{Icon:r},{icons:o}])=>{if(typeof o!="object")throw new Error("Icon set must export icons object.");r.addIcons(o)}):Promise.resolve(),s?fetch(s).then(r=>r.json()).then(r=>{this.theme.locale.initLocale(r)}):Promise.resolve()]),this.onStylesLoaded()}catch(r){console.warn(r),this.events.publish({name:"wk:app:load-styles:error",data:{}})}}async initScripts(e){if(!(e!=null&&e.length)){this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}});return}try{await Promise.all(e.map(t=>import(t).then(({setup:s})=>{typeof s=="function"&&s({app:this})}))),e.some(t=>t.includes("event-subscribers.js"))||this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}})}catch(t){console.warn(t),this.events.publish({name:"wk:app:load-scripts:error",data:{}})}}initDefaultEventSubscribers(){this.events.subscribe("wk:wishlist:login-required",e=>{window.location.href=this.routes.accountLoginUrl}),this.events.subscribe("wk:customer:login",e=>{if(e.data.pending)switch(e.data.pending.action){case"wishlist:add":this.addWishlistItem(e.data.pending)}}),this.events.subscribe("wk:customer:logout",async e=>{this.clearCustomerSession()})}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let t=this.theme.getWishlistId(window.location.pathname);t&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:t})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success",data:{}})}async initLoginActionQueue(){let e=!!window.localStorage.getItem("wk_logged_in");if(this.events.subscribe("wk:wishlist:login-required",t=>{var r;let s=["wishlist:add","wishlist:view"];(r=t.data)!=null&&r.action&&s.includes(t.data.action)&&window.localStorage.setItem("wk_pending",JSON.stringify({...t.data}))}),!e&&this.isLoggedIn){window.localStorage.setItem("wk_logged_in","1"),await this.load(),await this.loadWishlist({wishlistId:"mine",strategy:"cache-or-network"});let t=this.getPendingWishlistAction();this.events.publish({name:"wk:customer:login",data:{pending:t}})}else e&&!this.isLoggedIn&&(await this.load(),window.localStorage.removeItem("wk_logged_in"),this.events.publish({name:"wk:customer:logout",data:{}}));["challenge","account"].includes(this.theme.getPageType())||window.localStorage.removeItem("wk_pending")}async initCustomerSession(){this.hasSession||(await this.clearCustomerSession(),this.events.once("wk:app:init-sid",e=>{var t,s;(t=e.data)!=null&&t.sessionId&&this.setSessionId((s=e.data)==null?void 0:s.sessionId)}))}async clearCustomerSession(){window.localStorage.removeItem("wk_session_id"),window.localStorage.removeItem("wk_pending"),await this.state.promise.clearCache()}getPendingWishlistAction(){try{let e=window.localStorage.getItem("wk_pending");if(e)return JSON.parse(e)}catch(e){console.warn("Could not parse pending wishlist action",e)}}initUrlChangeEvents(){let e=({productHandle:s,variantId:r})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:r}})},t=s=>(...r)=>{var c;let o=s.apply(history,r),n=typeof r[2]=="string"?r[2]:(c=r[2])==null?void 0:c.toString();if(!n)return o;n.startsWith("?")&&(n=window.location.pathname+n);let a=`${window.location.protocol}//${window.location.host}`,h=new URL(n,a),u=this.theme.getProductHandle(h),l=h.searchParams.get("variant");if(!u)return o;e({productHandle:u,variantId:l?parseInt(l):void 0})};history.replaceState=t(history.replaceState),history.pushState=t(history.pushState)}parseConfig({config:e}){var t,s,r,o,n,a,h,u;return{customer:{id:e.customerId?e.customerId:null,email:(t=e.customerEmail)!=null?t:""},shop:{name:(s=e.shopName)!=null?s:"",domain:(r=e.shopDomain)!=null?r:"",permanentDomain:(o=e.shopPermanentDomain)!=null?o:"",moneyFormat:(n=e.shopMoneyFormat)!=null?n:"",moneyFormatWithCurrency:(a=e.shopMoneyFormatWithCurrency)!=null?a:"",customerAccountsEnabled:e.shopCustomerAccountsEnabled?e.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(h=e.apiHost)!=null?h:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:e.fileUrl},products:{fallbackImage:(u=e.productFallbackImage)!=null?u:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081",metafields:!!e.productMetafields}}}parseSettings({settings:e}){var t,s,r,o,n,a,h,u,l,c,p,y,A,m,d,w,b,F,C,j,S,T,P,L,$,q,B;return{general:{appLoading:(s=(t=e==null?void 0:e.general)==null?void 0:t.appLoading)!=null?s:"LAZY",wishlistAccessMode:(o=(r=e==null?void 0:e.general)==null?void 0:r.wishlistAccessMode)!=null?o:"UNRESTRICTED",wishlistMode:(a=(n=e==null?void 0:e.general)==null?void 0:n.wishlistMode)!=null?a:"PRODUCT",wishlistPath:(u=(h=e==null?void 0:e.general)==null?void 0:h.wishlistPath)!=null?u:"/apps/wishlist"},money:{withCurrency:(c=(l=e==null?void 0:e.money)==null?void 0:l.withCurrency)!=null?c:!1},integrations:{googleAnalytics:{enabled:(A=(y=(p=e.integrations)==null?void 0:p.googleAnalytics)==null?void 0:y.enabled)!=null?A:!1,tracker:(w=(d=(m=e.integrations)==null?void 0:m.googleAnalytics)==null?void 0:d.tracker)!=null?w:""},klaviyo:{enabled:(C=(F=(b=e.integrations)==null?void 0:b.klaviyo)==null?void 0:F.enabled)!=null?C:!1},metaPixel:{enabled:(T=(S=(j=e.integrations)==null?void 0:j.metaPixel)==null?void 0:S.enabled)!=null?T:!1},wishlistAnalytics:{enabled:($=(L=(P=e.integrations)==null?void 0:P.metaPixel)==null?void 0:L.enabled)!=null?$:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4},cart:{ttl:1e3}},colorMap:(q=e.colorMap)!=null?q:{},collectionButtons:(B=e.collectionButtons)!=null?B:{}}}parseRoutes(){let e=this.config.routes.rootUrl;return{rootUrl:e,fileUrl:this.config.routes.fileUrl,wishlistUrl:e+this.settings.general.wishlistPath.split("/").filter(t=>!!t).join("/"),accountUrl:e+"account",accountLoginUrl:e+"account/login",accountLogoutUrl:e+"account/logout",accountRegisterUrl:e+"account/register",accountAddressesUrl:e+"account/addresses",collectionsUrl:e+"collections",allProductsCollectionUrl:e+"collections/all",searchUrl:e+"search",predictiveSearchUrl:e+"search/suggest",cartUrl:e+"cart",cartAddUrl:e+"cart/add",cartChangeUrl:e+"cart/change",cartClearUrl:e+"cart/clear",cartUpdateUrl:e+"cart/update",productRecommendationsUrl:e+"recommendations/products"}}parseDependencies(e){let t=this.isDevMode();return e.map(s=>this.parseDependencyUrl({url:s,noCache:t})).reduce(({stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n},a)=>{let[h]=a.split("?");return h.endsWith(".css")?s.push(a):h.endsWith("icons.js")?o=a:h.endsWith(".js")?r.push(a):h.endsWith(".json")&&(n=a),{stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n}},{stylesheets:[],scripts:[],iconSetUrl:"",localeUrl:""})}parseDependencyUrl({url:e,noCache:t}){return t&&!e.includes("/_templates/")?e.replace("cdn.appmate.io","storage.googleapis.com/appmate-cdn").replace(/v=\d*/,`v=${Date.now()}`):e}isDevMode(){if(!!!document.getElementById("preview-bar-iframe"))return!1;let t=window.localStorage.getItem("wk_dev_mode");return t?Date.now()-parseInt(t)<8*36e5:!1}initDevMode(){window.location.search.includes("wk_dev_mode=on")?(W("Activate dev mode"),window.localStorage.setItem("wk_dev_mode",Date.now().toString())):window.location.search.includes("wk_dev_mode=off")&&(W("Deactivate dev mode"),window.localStorage.removeItem("wk_dev_mode")),this.isDevMode()&&(W("Dev mode active"),window.addEventListener("message",e=>{switch(e.data){case"WK_THEME_RELOAD":window.localStorage.setItem("wk_dev_mode",Date.now().toString()),window.location.reload();break}},!1))}},O=i=>{if(!i)throw new Error("Wishlist app not loaded.");return i};export{X as WishlistApp};
var te=Object.create;var J=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var N=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var ne=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ie(e))!oe.call(i,r)&&r!==t&&J(i,r,{get:()=>e[r],enumerable:!(s=se(e,r))||s.enumerable});return i};var ae=(i,e,t)=>(t=i!=null?te(re(i)):{},ne(e||!i||!i.__esModule?J(t,"default",{value:i,enumerable:!0}):t,i));var z=N((He,G)=>{var S=1e3,U=S*60,E=U*60,v=E*24,ce=v*7,he=v*365.25;G.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return pe(i);if(t==="number"&&isFinite(i))return e.long?ue(i):de(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function pe(i){if(i=String(i),!(i.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),s=(e[2]||"ms").toLowerCase();switch(s){case"years":case"year":case"yrs":case"yr":case"y":return t*he;case"weeks":case"week":case"w":return t*ce;case"days":case"day":case"d":return t*v;case"hours":case"hour":case"hrs":case"hr":case"h":return t*E;case"minutes":case"minute":case"mins":case"min":case"m":return t*U;case"seconds":case"second":case"secs":case"sec":case"s":return t*S;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function de(i){var e=Math.abs(i);return e>=v?Math.round(i/v)+"d":e>=E?Math.round(i/E)+"h":e>=U?Math.round(i/U)+"m":e>=S?Math.round(i/S)+"s":i+"ms"}function ue(i){var e=Math.abs(i);return e>=v?H(i,e,v,"day"):e>=E?H(i,e,E,"hour"):e>=U?H(i,e,U,"minute"):e>=S?H(i,e,S,"second"):i+" ms"}function H(i,e,t,s){var r=e>=t*1.5;return Math.round(i/t)+" "+s+(r?"s":"")}});var Z=N((De,Q)=>{function me(i){t.debug=t,t.default=t,t.coerce=h,t.disable=o,t.enable=r,t.enabled=n,t.humanize=z(),t.destroy=u,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let c=0;for(let p=0;p<l.length;p++)c=(c<<5)-c+l.charCodeAt(p),c|=0;return t.colors[Math.abs(c)%t.colors.length]}t.selectColor=e;function t(l){let c,p=null,y,A;function m(...d){if(!m.enabled)return;let w=m,b=Number(new Date),F=b-(c||b);w.diff=F,w.prev=c,w.curr=b,c=b,d[0]=t.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let C=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(k,T)=>{if(k==="%%")return"%";C++;let P=t.formatters[T];if(typeof P=="function"){let L=d[C];k=P.call(w,L),d.splice(C,1),C--}return k}),t.formatArgs.call(w,d),(w.log||t.log).apply(w,d)}return m.namespace=l,m.useColors=t.useColors(),m.color=t.selectColor(l),m.extend=s,m.destroy=t.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(y!==t.namespaces&&(y=t.namespaces,A=t.enabled(l)),A),set:d=>{p=d}}),typeof t.init=="function"&&t.init(m),m}function s(l,c){let p=t(this.namespace+(typeof c=="undefined"?":":c)+l);return p.log=this.log,p}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let c,p=(typeof l=="string"?l:"").split(/[\s,]+/),y=p.length;for(c=0;c<y;c++)p[c]&&(l=p[c].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function o(){let l=[...t.names.map(a),...t.skips.map(a).map(c=>"-"+c)].join(",");return t.enable(""),l}function n(l){if(l[l.length-1]==="*")return!0;let c,p;for(c=0,p=t.skips.length;c<p;c++)if(t.skips[c].test(l))return!1;for(c=0,p=t.names.length;c<p;c++)if(t.names[c].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function h(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Q.exports=me});var Y=N((f,D)=>{f.formatArgs=fe;f.save=we;f.load=ye;f.useColors=ge;f.storage=be();f.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();f.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ge(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function fe(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+D.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,s=0;i[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(s=t))}),i.splice(s,0,e)}f.log=console.debug||console.log||(()=>{});function we(i){try{i?f.storage.setItem("debug",i):f.storage.removeItem("debug")}catch(e){}}function ye(){let i;try{i=f.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function be(){try{return localStorage}catch(i){}}D.exports=Z()(f);var{formatters:Ce}=D.exports;Ce.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var V=(i=21)=>crypto.getRandomValues(new Uint8Array(i)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");var g=class{constructor(e){this.element=e}replace(e){var t;return(t=this.element)==null||t.replaceWith(e),e}append(e){var t;return(t=this.element)==null||t.append(e),e}prepend(e){var t;return(t=this.element)==null||t.prepend(e),e}insertBefore(e){var t;return(t=this.element)==null||t.before(e),e}insertAfter(e){var t;return(t=this.element)==null||t.after(e),e}closest(e,t=5){if(!this.element)return new g;if(typeof e=="object")return this.searchByStyle(e,this.element,r=>r.parentElement,t);let s=this.element.closest(e);return s?new g(s):new g}find(e){var s;let t=(s=this.element)==null?void 0:s.querySelector(e);return t?new g(t):new g}searchByStyle(e,t,s,r=5){if(r<0||!t)return null;let o=getComputedStyle(t);if(Object.entries(e).every(([h,u])=>o.getPropertyValue(h)===u))return new g(t);let a=s(t);return a?this.searchByStyle(e,a,s,r-1):null}};var M=class{constructor({routeUtil:e}){this.subscriber=[],this.routeUtil=e,this.observer=new MutationObserver(t=>{t.reduce((s,r)=>s.concat(Array.from(r.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("wk-skip")).forEach(s=>{s instanceof Element&&this.scan(s)})}),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!1})}watch(e,t){let s={target:e,callback:t};this.subscriber.push(s),K(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document)}shouldSkip(e,{skipHidden:t}){return t&&e instanceof HTMLElement?e.offsetParent===null:!1}scan(e){e&&this.subscriber.filter(t=>K(t,this.routeUtil.parse(window.location.pathname))).forEach(t=>{let s=e instanceof Element&&e.matches(t.target.selector)&&!this.shouldSkip(e,{skipHidden:!!t.target.skipHidden});if(s&&this.notify(t,e),s&&t.target.firstMatch)return;let r=e.querySelectorAll(t.target.selector);for(let o of r)if(!this.shouldSkip(o,{skipHidden:!!t.target.skipHidden})&&(this.notify(t,o),t.target.firstMatch))break})}notify(e,t){if(!t.hasAttribute("wk-skip")){t.setAttribute("wk-skip","");let s=new g(t);e.callback(s)}}};function K({target:i},e){if(!i.pageType)return!0;if(!e.pageType)return!1;let t=Array.isArray(i.pageType)?i.pageType:[i.pageType];return t.includes("all")?!0:t.includes(e.pageType)}var le=[{pageType:"product",match:i=>i.includes("/products/")},{pageType:"collection",match:i=>i.includes("/collections/")&&!i.includes("/products/")},{pageType:"account",match:i=>i.includes("/account/")||i.endsWith("/account")},{pageType:"challenge",match:i=>i.endsWith("/account")},{pageType:"blog",match:i=>i.includes("/blog/")},{pageType:"cart",match:i=>i.includes("/cart/")||i.endsWith("/cart")},{pageType:"wishlist",match:(i,{wishlistUrl:e})=>i.includes(e)},{pageType:"page",match:i=>i.includes("/pages/")},{pageType:"search",match:i=>i.includes("/search")},{pageType:"home",match:i=>i.length<4}],R=class{constructor({wishlistUrl:e}){this.wishlistUrl=e}parse(e){for(let t of le)if(t.match(e,{wishlistUrl:this.wishlistUrl}))return{pageType:t.pageType};return{pageType:"unknown"}}};var _=class{constructor(e){this.locale={};var t;this.initLocale((t=e==null?void 0:e.locale)!=null?t:{})}initLocale(e){this.locale=this.decodeLocale(e)}decodeHtmlEntities(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'")}decodeLocale(e){let t={};for(let s in e){t[s]={};for(let r in e[s])t[s][r]=this.decodeHtmlEntities(e[s][r])}return t}translate(e,t){var n;let[s,r]=e.split("."),o=(n=this.locale[s])==null?void 0:n[r];return o?t?Object.entries(t).reduce((a,[h,u])=>a.replace(new RegExp(`{{\\s*${h}\\s*}}`,"g"),u),o):o:`translation missing: ${e}`}};var I=class{constructor({rootUrl:e,wishlistUrl:t}){this._rootUrl=e,this.route=new R({wishlistUrl:t}),this.observer=new M({routeUtil:this.route}),this.locale=new _,this.watch=this.observer.watch.bind(this.observer)}getPageType(e=window.location.pathname){return this.route.parse(e).pageType}getWishlistId(e){if(!e)return null;e instanceof URL&&(e=e.pathname);let t=e.replace(this._rootUrl,"/").split("/");return t.length===4?t.pop():"mine"}getProductHandle(e){var t,s;return e?(e instanceof URL&&(e=e.pathname),(s=(t=e.split("/").pop())==null?void 0:t.split("?")[0])==null?void 0:s.split("#")[0]):null}getVariantId(e,t){var r;let s=null;if(e&&(e instanceof URL&&(e=e.pathname),s=new URLSearchParams(e.split("?")[1]).get("variant")),!s&&t)try{s=new FormData((r=t.element)!=null?r:t).get("id")}catch(o){console.warn("Failed to parse variant from product form.",o)}return s}translate(e,t){return this.locale.translate(e,t)}createComponent(e,t){var r;let s=document.createElement(e);if(t!=null&&t.dataset&&Object.entries(t==null?void 0:t.dataset).forEach(([o,n])=>{n&&(typeof n=="boolean"?s.dataset[o]="":typeof n=="object"?s.dataset[o]=JSON.stringify(n):s.dataset[o]=n)}),t!=null&&t.props&&Object.entries(t==null?void 0:t.props).forEach(([o,n])=>{if(o==="floating"&&n){let a=n,h=(a==null?void 0:a.reference)instanceof g?a.reference.element:a.reference;if(typeof h=="object"&&"id"in h){h.setAttribute("wk-id",V()),s[o]={...a,reference:`[wk-id="${h.getAttribute("wk-id")}"]`};return}}s[o]=n}),(r=t==null?void 0:t.wrap)!=null&&r.name){let o=this.createElement(t.wrap.name,t.wrap.props,s);return o.setAttribute("wk-skip",""),o}return s}createHeadlessComponent(e,t){var o;let s=t.host.element?t.host.element:t.host;if(!s)throw new Error("Headless host is undefined");t.dataset&&Object.entries(t.dataset).forEach(([n,a])=>{a&&(typeof a=="boolean"?s.dataset[n]="":typeof a=="object"?s.dataset[n]=JSON.stringify(a):s.dataset[n]=a)});let r=(o=window.headlessElements)==null?void 0:o.store.get(e);if(!r)throw new Error(`Headless element not found: ${e}`);return new r(s)}createElement(e,t={},...s){let r=Object.assign(document.createElement(e),t);return s&&r.append(...s),r}};var x=class{constructor(){this.dispatcher=document}publish(e){this.dispatcher.dispatchEvent(new CustomEvent(e.name,{detail:e,bubbles:!1,cancelable:!1}))}once(e,t){let s=r=>{this.dispatcher.removeEventListener(e,s),t(r)};this.subscribe(e,s)}subscribe(e,t){this.dispatcher.addEventListener(e,s=>{let r=s;t({name:r.type,data:r.detail.data})})}subscribeMany(e){return Object.entries(e).map(([t,s])=>this.subscribe(t,s))}};var ee=ae(Y()),W=(0,ee.default)("wk:app");window.headlessElements||(window.headlessElements={store:new Map,define(i,e){var t;(t=window.headlessElements)==null||t.store.set(i,e)}});var X=class{constructor({dependencies:e=[],...t}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=e=>this.state.promise.addToCart(e);this.addAllToCart=e=>this.state.promise.addAllToCart(e);this.addWishlistItem=e=>this.state.promise.addWishlistItem(e);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=e=>this.state.promise.loadProductInfo(e);this.loadShopifyProduct=e=>this.state.promise.loadShopifyProduct(e);this.loadWishlist=e=>this.state.promise.loadWishlist(e);this.loadWishlistItem=e=>this.state.promise.loadWishlistItem(e);this.publishWishlistEvent=e=>this.state.promise.publishWishlistEvent(e);this.publishWishlistProductEvent=e=>this.state.promise.publishWishlistProductEvent(e);this.removeWishlistItem=e=>this.state.promise.removeWishlistItem(e);this.shareWishlist=e=>this.state.promise.shareWishlist(e);this.updateWishlistItem=e=>this.state.promise.updateWishlistItem(e);this.config=this.parseConfig(t),this.settings=this.parseSettings(t),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,W("Create app",{config:this.config,settings:this.settings,customer:this.customer}),this.events=new x,this.theme=new I({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl}),this.initDevMode();let{stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n}=this.parseDependencies(e);W("Init dependecies",{dependencies:e,stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n}),this.initStyles({stylesheets:s,iconSetUrl:o,localeUrl:n}),this.initScripts(r),this.initLoginActionQueue(),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load(),window.WishlistKing=this,this.events.publish({name:"wk:app:created",data:{}})}get loaded(){return this._loaded}get state(){return O(this._state)}get apis(){return O(this._apis)}get utils(){return O(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var e;return!!((e=this.customer)!=null&&e.id)}getSessionId(){let e=window.localStorage.getItem("wk_session_id");if(e)return e;let t=window.localStorage.getItem("appmate-session");if(t)try{let s=JSON.parse(t).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(e){var t;return window.localStorage.setItem("wk_session_id",e),(t=this._apis)==null||t.tracking.setSessionId(e),e}async load(){return this._loadPromise?this._loadPromise:(W("Load remaining app code"),this._loadPromise=(async()=>{let[{WishlistState:e},{ShopifyApi:t,WishlistApi:s,TrackingApi:r},{MoneyUtil:o,UrlUtil:n,ProductUtil:a}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/utils.js")]);this.initUtils({MoneyUtil:o,UrlUtil:n,ProductUtil:a}),this.initApis({WishlistApi:s,ShopifyApi:t,TrackingApi:r}),await this.initState({WishlistState:e}),this.initCustomerSession(),this.initUrlChangeEvents(),this.trackCurrentPage(),this._loaded=!0,this.events.publish({name:"wk:app:loaded",data:{}})})())}initUtils({UrlUtil:e,MoneyUtil:t,ProductUtil:s}){this._utils={url:new e({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:this.config.shop.domain,placeholderImageUrl:this.config.products.fallbackImage,fileUrl:this.routes.fileUrl}),money:new t({moneyFormat:this.config.shop.moneyFormat,moneyFormatWithCurrency:this.config.shop.moneyFormatWithCurrency}),product:new s}}initApis({WishlistApi:e,ShopifyApi:t,TrackingApi:s}){var r,o,n;this._apis={wishlist:new e({host:this.config.routes.apiHost,shop:this.config.shop.permanentDomain,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType(),productMetafields:this.config.products.metafields}),shopify:new t({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:this.config.shop.permanentDomain,customerId:(o=this.config.customer.id)!=null?o:void 0,customerEmail:(n=this.config.customer.email)!=null?n:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:e}){return this._state=new e({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this._state.init()}async initStyles({stylesheets:e,iconSetUrl:t,localeUrl:s}){if(!(e!=null&&e.length)&&!t){this.onStylesLoaded();return}try{await Promise.all([...(e!=null?e:[]).map(r=>new Promise((o,n)=>{let a=document.createElement("link");a.rel="stylesheet",a.href=r,a.onload=o,a.onerror=n,document.head.appendChild(a)})),t?Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/components/icon.js"),import(t)]).then(([{Icon:r},{icons:o}])=>{if(typeof o!="object")throw new Error("Icon set must export icons object.");r.addIcons(o)}):Promise.resolve(),s?fetch(s).then(r=>r.json()).then(r=>{this.theme.locale.initLocale(r)}):Promise.resolve()]),this.onStylesLoaded()}catch(r){console.warn(r),this.events.publish({name:"wk:app:load-styles:error",data:{}})}}async initScripts(e){if(!(e!=null&&e.length)){this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}});return}try{await Promise.all(e.map(t=>import(t).then(({setup:s})=>{typeof s=="function"&&s({app:this})}))),e.some(t=>t.includes("event-subscribers.js"))||this.initDefaultEventSubscribers(),this.events.publish({name:"wk:app:load-scripts:success",data:{}})}catch(t){console.warn(t),this.events.publish({name:"wk:app:load-scripts:error",data:{}})}}initDefaultEventSubscribers(){this.events.subscribe("wk:wishlist:login-required",e=>{window.location.href=this.routes.accountLoginUrl}),this.events.subscribe("wk:customer:login",e=>{if(e.data.pending)switch(e.data.pending.action){case"wishlist:add":this.addWishlistItem(e.data.pending)}}),this.events.subscribe("wk:customer:logout",async e=>{this.clearCustomerSession()})}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let t=this.theme.getWishlistId(window.location.pathname);t&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:t})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success",data:{}})}async initLoginActionQueue(){let e=!!window.localStorage.getItem("wk_logged_in");if(this.events.subscribe("wk:wishlist:login-required",t=>{var r;let s=["wishlist:add","wishlist:view"];(r=t.data)!=null&&r.action&&s.includes(t.data.action)&&window.localStorage.setItem("wk_pending",JSON.stringify({...t.data}))}),!e&&this.isLoggedIn){window.localStorage.setItem("wk_logged_in","1"),await this.load(),await this.loadWishlist({wishlistId:"mine",strategy:"cache-or-network"});let t=this.getPendingWishlistAction();this.events.publish({name:"wk:customer:login",data:{pending:t}})}else e&&!this.isLoggedIn&&(await this.load(),window.localStorage.removeItem("wk_logged_in"),this.events.publish({name:"wk:customer:logout",data:{}}));["challenge","account"].includes(this.theme.getPageType())||window.localStorage.removeItem("wk_pending")}async initCustomerSession(){this.hasSession||(await this.clearCustomerSession(),this.events.once("wk:app:init-sid",e=>{var t,s;(t=e.data)!=null&&t.sessionId&&this.setSessionId((s=e.data)==null?void 0:s.sessionId)}))}async clearCustomerSession(){window.localStorage.removeItem("wk_session_id"),window.localStorage.removeItem("wk_pending"),await this.state.promise.clearCache()}getPendingWishlistAction(){try{let e=window.localStorage.getItem("wk_pending");if(e)return JSON.parse(e)}catch(e){console.warn("Could not parse pending wishlist action",e)}}initUrlChangeEvents(){let e=({productHandle:s,variantId:r})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:r}})},t=s=>(...r)=>{var c;let o=s.apply(history,r),n=typeof r[2]=="string"?r[2]:(c=r[2])==null?void 0:c.toString();if(!n)return o;n.startsWith("?")&&(n=window.location.pathname+n);let a=`${window.location.protocol}//${window.location.host}`,h=new URL(n,a),u=this.theme.getProductHandle(h),l=h.searchParams.get("variant");if(!u)return o;e({productHandle:u,variantId:l?parseInt(l):void 0})};history.replaceState=t(history.replaceState),history.pushState=t(history.pushState)}parseConfig({config:e}){var t,s,r,o,n,a,h,u;return{customer:{id:e.customerId?e.customerId:null,email:(t=e.customerEmail)!=null?t:""},shop:{name:(s=e.shopName)!=null?s:"",domain:(r=e.shopDomain)!=null?r:"",permanentDomain:(o=e.shopPermanentDomain)!=null?o:"",moneyFormat:(n=e.shopMoneyFormat)!=null?n:"",moneyFormatWithCurrency:(a=e.shopMoneyFormatWithCurrency)!=null?a:"",customerAccountsEnabled:e.shopCustomerAccountsEnabled?e.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(h=e.apiHost)!=null?h:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:e.fileUrl},products:{fallbackImage:(u=e.productFallbackImage)!=null?u:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081",metafields:!!e.productMetafields}}}parseSettings({settings:e}){var t,s,r,o,n,a,h,u,l,c,p,y,A,m,d,w,b,F,C,j,k,T,P,L,$,q,B;return{general:{appLoading:(s=(t=e==null?void 0:e.general)==null?void 0:t.appLoading)!=null?s:"LAZY",wishlistAccessMode:(o=(r=e==null?void 0:e.general)==null?void 0:r.wishlistAccessMode)!=null?o:"UNRESTRICTED",wishlistMode:(a=(n=e==null?void 0:e.general)==null?void 0:n.wishlistMode)!=null?a:"PRODUCT",wishlistPath:(u=(h=e==null?void 0:e.general)==null?void 0:h.wishlistPath)!=null?u:"/apps/wishlist"},money:{withCurrency:(c=(l=e==null?void 0:e.money)==null?void 0:l.withCurrency)!=null?c:!1},integrations:{googleAnalytics:{enabled:(A=(y=(p=e.integrations)==null?void 0:p.googleAnalytics)==null?void 0:y.enabled)!=null?A:!1,tracker:(w=(d=(m=e.integrations)==null?void 0:m.googleAnalytics)==null?void 0:d.tracker)!=null?w:""},klaviyo:{enabled:(C=(F=(b=e.integrations)==null?void 0:b.klaviyo)==null?void 0:F.enabled)!=null?C:!1},metaPixel:{enabled:(T=(k=(j=e.integrations)==null?void 0:j.metaPixel)==null?void 0:k.enabled)!=null?T:!1},wishlistAnalytics:{enabled:($=(L=(P=e.integrations)==null?void 0:P.metaPixel)==null?void 0:L.enabled)!=null?$:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4},cart:{ttl:1e3}},colorMap:(q=e.colorMap)!=null?q:{},collectionButtons:(B=e.collectionButtons)!=null?B:{}}}parseRoutes(){let e=this.config.routes.rootUrl;return{rootUrl:e,fileUrl:this.config.routes.fileUrl,wishlistUrl:e+this.settings.general.wishlistPath.split("/").filter(t=>!!t).join("/"),accountUrl:e+"account",accountLoginUrl:e+"account/login",accountLogoutUrl:e+"account/logout",accountRegisterUrl:e+"account/register",accountAddressesUrl:e+"account/addresses",collectionsUrl:e+"collections",allProductsCollectionUrl:e+"collections/all",searchUrl:e+"search",predictiveSearchUrl:e+"search/suggest",cartUrl:e+"cart",cartAddUrl:e+"cart/add",cartChangeUrl:e+"cart/change",cartClearUrl:e+"cart/clear",cartUpdateUrl:e+"cart/update",productRecommendationsUrl:e+"recommendations/products"}}parseDependencies(e){let t=this.isDevMode();return e.map(s=>this.parseDependencyUrl({url:s,noCache:t})).reduce(({stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n},a)=>{let[h]=a.split("?");return h.endsWith(".css")?s.push(a):h.endsWith("icons.js")?o=a:h.endsWith(".js")?r.push(a):h.endsWith(".json")&&(n=a),{stylesheets:s,scripts:r,iconSetUrl:o,localeUrl:n}},{stylesheets:[],scripts:[],iconSetUrl:"",localeUrl:""})}parseDependencyUrl({url:e,noCache:t}){return t&&!e.includes("/_templates/")?e.replace("cdn.appmate.io","storage.googleapis.com/appmate-cdn").replace(/v=\d*/,`v=${Date.now()}`):e}isDevMode(){if(!!!document.getElementById("preview-bar-iframe"))return!1;let t=window.localStorage.getItem("wk_dev_mode");return t?Date.now()-parseInt(t)<8*36e5:!1}initDevMode(){window.location.search.includes("wk_dev_mode=on")?(W("Activate dev mode"),window.localStorage.setItem("wk_dev_mode",Date.now().toString())):window.location.search.includes("wk_dev_mode=off")&&(W("Deactivate dev mode"),window.localStorage.removeItem("wk_dev_mode")),this.isDevMode()&&(W("Dev mode active"),window.addEventListener("message",e=>{switch(e.data){case"WK_THEME_RELOAD":window.localStorage.setItem("wk_dev_mode",Date.now().toString()),window.location.reload();break}},!1))}},O=i=>{if(!i)throw new Error("Wishlist app not loaded.");return i};export{X as WishlistApp};

@@ -1,1 +0,1 @@

import{delayWhen as u,from as o,fromEvent as h,isObservable as f,map as b,of as l}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as c,first as v,switchMap as g,tap as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as m}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/controllers.js";var p=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new m(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),this.host.setAttribute("wk-skip",""),this.initEvents(),this.connect(),this.firstConnect=!1}get app(){return this.stateCtrl.app}static get observedAttributes(){return["data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}addController(t){}appReadyCallback(){this.host.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var s,r,e;if(this.host.dataset.productHandle===((s=t.data)==null?void 0:s.productHandle)&&((r=t.data)!=null&&r.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,i=this.productInfo?this.productInfo.variantId:void 0;n&&!i&&this.app.updateWishlistItem({wishlistItemId:n,changes:{variantId:(e=t.data)==null?void 0:e.variantId}}),this.host.dataset.variantId=t.data.variantId.toString(),this.connected&&this.initState()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){h(document,"wk:app:load-styles:success").pipe(v()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}updated(){}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo,this.updated()}createRenderRoot(){return this}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(s=>this.handleIntersect(s),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var s;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(s=this.observer)==null||s.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let s=Object.entries(t).map(([r,e])=>{let[n,i]=r.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:i,handler:e})});this.cleanupMethods.push(()=>s.forEach(r=>r.unsubscribe()))}subscribeToEvent({eventName:t,handler:s,selector:r}){return h(this.host,t).pipe(d(e=>{this.eventPending&&e.preventDefault()}),c(()=>!this.eventPending),d(()=>{this.eventPending=!0}),b(e=>e.target instanceof Element?{event:e,target:r?e.target.closest(r):e.currentTarget}:{event:e,target:null}),c(({target:e})=>!!e),u(e=>this.app.hasSession?l(e):o(this.app.load())),g(({event:e,target:n})=>{let i;try{i=s.bind(this)(e,n)}catch(a){console.error(a),i=a}return f(i)?i:typeof(i==null?void 0:i.then)=="function"?o(i):l(i)})).subscribe(()=>{this.eventPending=!1})}};export{p as WishlistElementHeadless};
import{delayWhen as u,from as o,fromEvent as h,isObservable as f,map as b,of as l}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as c,first as v,switchMap as g,tap as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as m}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/controllers.js";var p=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new m(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),this.host.setAttribute("wk-skip",""),this.initEvents(),this.connect(),this.firstConnect=!1}get app(){return this.stateCtrl.app}static get observedAttributes(){return["data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}addController(t){}appReadyCallback(){this.host.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var s,r,e;if(this.host.dataset.productHandle===((s=t.data)==null?void 0:s.productHandle)&&((r=t.data)!=null&&r.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,i=this.productInfo?this.productInfo.variantId:void 0;n&&!i&&this.app.updateWishlistItem({wishlistItemId:n,changes:{variantId:(e=t.data)==null?void 0:e.variantId}}),this.host.dataset.variantId=t.data.variantId.toString(),this.connected&&this.initState()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){h(document,"wk:app:load-styles:success").pipe(v()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}updated(){}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo,this.updated()}createRenderRoot(){return this}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(s=>this.handleIntersect(s),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var s;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(s=this.observer)==null||s.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let s=Object.entries(t).map(([r,e])=>{let[n,i]=r.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:i,handler:e})});this.cleanupMethods.push(()=>s.forEach(r=>r.unsubscribe()))}subscribeToEvent({eventName:t,handler:s,selector:r}){return h(this.host,t).pipe(d(e=>{this.eventPending&&e.preventDefault()}),c(()=>!this.eventPending),d(()=>{this.eventPending=!0}),b(e=>e.target instanceof Element?{event:e,target:r?e.target.closest(r):e.currentTarget}:{event:e,target:null}),c(({target:e})=>!!e),u(e=>this.app.hasSession?l(e):o(this.app.load())),g(({event:e,target:n})=>{let i;try{i=s.bind(this)(e,n)}catch(a){console.error(a),i=a}return f(i)?i:typeof(i==null?void 0:i.then)=="function"?o(i):l(i)})).subscribe(()=>{this.eventPending=!1})}};export{p as WishlistElementHeadless};

@@ -1,1 +0,1 @@

import{delayWhen as f,from as c,fromEvent as l,isObservable as b,map as g,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as u,first as m,switchMap as y,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as v}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{unsafeHTML as d}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{WishlistStateController as C}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.26/controllers.js";var a=class extends v{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new C(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),this.connected&&this.app.loaded&&this.initState()}appReadyCallback(){this.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var e,i;this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((i=t.data)!=null&&i.variantId)&&(this.dataset.variantId=t.data.variantId.toString())})}async connect(){if(!this.connected){if(!window.WishlistKing){window.document.addEventListener("wk:app:created",()=>{this.connect()},{once:!0});return}if(!this.app.stylesLoaded){l(document,"wk:app:load-styles:success").pipe(m()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession||this.loadWithoutSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}getTranslation(t,e){if(!this.app.theme)return t;let i=this.app.theme.translate(t,e);return t.endsWith("_html")?d(i):i}formatMoney(t,e){var i;return this.app.utils.money.formatMoney(t,{withCurrency:(i=e==null?void 0:e.withCurrency)!=null?i:this.app.settings.money.withCurrency})}renderMoney(t,e){return d(this.formatMoney(t,e))}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,i){var s;return this.app.utils.url.getImageUrl((s=e==null?void 0:e.featured_image)!=null&&s.src?e:t,i)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}setState(t){t.wishlist&&(this.wishlist=t.wishlist),t.wishlistItem&&(this.wishlistItem=t.wishlistItem),t.productInfo&&(this.productInfo=t.productInfo),t.cart&&(this.cart=t.cart)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML&&this.firstConnect&&(this.innerHTML=""),this.initEvents(),this.connect(),this.firstConnect=!1}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(i=>i()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([i,s])=>{let[n,r]=i.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(i=>i.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:i}){return l(this,t).pipe(p(s=>{this.eventPending&&s.preventDefault()}),u(()=>!this.eventPending),p(()=>{this.eventPending=!0}),g(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),u(({target:s})=>!!s),f(s=>this.app.hasSession?h(s):c(this.app.load())),y(({event:s,target:n})=>{let r;try{r=e.bind(this)(s,n)}catch(o){console.error(o),r=o}return b(r)?r:typeof(r==null?void 0:r.then)=="function"?c(r):h(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0},cart:{state:!0},loadWithoutSession:{type:Boolean,attribute:"load-without-session"}};export{a as WishlistElement};
import{delayWhen as f,from as c,fromEvent as l,isObservable as b,map as g,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as u,first as m,switchMap as y,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as v}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{unsafeHTML as d}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{WishlistStateController as C}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.25.27/controllers.js";var a=class extends v{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new C(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),this.connected&&this.app.loaded&&this.initState()}appReadyCallback(){this.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var e,i;this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((i=t.data)!=null&&i.variantId)&&(this.dataset.variantId=t.data.variantId.toString())})}async connect(){if(!this.connected){if(!window.WishlistKing){window.document.addEventListener("wk:app:created",()=>{this.connect()},{once:!0});return}if(!this.app.stylesLoaded){l(document,"wk:app:load-styles:success").pipe(m()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession||this.loadWithoutSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:loaded",()=>{this.init()}))}}getStateConfig(){return{}}getTranslation(t,e){if(!this.app.theme)return t;let i=this.app.theme.translate(t,e);return t.endsWith("_html")?d(i):i}formatMoney(t,e){var i;return this.app.utils.money.formatMoney(t,{withCurrency:(i=e==null?void 0:e.withCurrency)!=null?i:this.app.settings.money.withCurrency})}renderMoney(t,e){return d(this.formatMoney(t,e))}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,i){var s;return this.app.utils.url.getImageUrl((s=e==null?void 0:e.featured_image)!=null&&s.src?e:t,i)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}setState(t){t.wishlist&&(this.wishlist=t.wishlist),t.wishlistItem&&(this.wishlistItem=t.wishlistItem),t.productInfo&&(this.productInfo=t.productInfo),t.cart&&(this.cart=t.cart)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML&&this.firstConnect&&(this.innerHTML=""),this.initEvents(),this.connect(),this.firstConnect=!1}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(i=>i()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([i,s])=>{let[n,r]=i.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(i=>i.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:i}){return l(this,t).pipe(p(s=>{this.eventPending&&s.preventDefault()}),u(()=>!this.eventPending),p(()=>{this.eventPending=!0}),g(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),u(({target:s})=>!!s),f(s=>this.app.hasSession?h(s):c(this.app.load())),y(({event:s,target:n})=>{let r;try{r=e.bind(this)(s,n)}catch(o){console.error(o),r=o}return b(r)?r:typeof(r==null?void 0:r.then)=="function"?c(r):h(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0},cart:{state:!0},loadWithoutSession:{type:Boolean,attribute:"load-without-session"}};export{a as WishlistElement};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc