@appmate/wishlist
Advanced tools
Comparing version 4.22.10 to 4.22.11
@@ -1,2 +0,2 @@ | ||
var B=Object.create;var M=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var J=(s,i)=>()=>(i||s((i={exports:{}}).exports,i),i.exports);var $=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of H(i))!G.call(s,r)&&r!==e&&M(s,r,{get:()=>i[r],enumerable:!(t=K(i,r))||t.enumerable});return s};var Q=(s,i,e)=>(e=s!=null?B(z(s)):{},$(i||!s||!s.__esModule?M(e,"default",{value:s,enumerable:!0}):e,s));var q=J((Ce,j)=>{"use strict";var oe=function(){function s(e,t){if(typeof e!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+e+"."));this._batchLoadFn=e,this._maxBatchSize=le(t),this._batchScheduleFn=ue(t),this._cacheKeyFn=de(t),this._cacheMap=me(t),this._batch=null,this.name=fe(t)}var i=s.prototype;return i.load=function(t){if(t==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(t)+"."));var r=he(this),n=this._cacheMap,a=this._cacheKeyFn(t);if(n){var o=n.get(a);if(o){var c=r.cacheHits||(r.cacheHits=[]);return new Promise(function(h){c.push(function(){h(o)})})}}r.keys.push(t);var p=new Promise(function(h,b){r.callbacks.push({resolve:h,reject:b})});return n&&n.set(a,p),p},i.loadMany=function(t){if(!O(t))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+t+"."));for(var r=[],n=0;n<t.length;n++)r.push(this.load(t[n]).catch(function(a){return a}));return Promise.all(r)},i.clear=function(t){var r=this._cacheMap;if(r){var n=this._cacheKeyFn(t);r.delete(n)}return this},i.clearAll=function(){var t=this._cacheMap;return t&&t.clear(),this},i.prime=function(t,r){var n=this._cacheMap;if(n){var a=this._cacheKeyFn(t);if(n.get(a)===void 0){var o;r instanceof Error?(o=Promise.reject(r),o.catch(function(){})):o=Promise.resolve(r),n.set(a,o)}}return this},s}(),ce=typeof process=="object"&&typeof process.nextTick=="function"?function(s){I||(I=Promise.resolve()),I.then(function(){process.nextTick(s)})}:typeof setImmediate=="function"?function(s){setImmediate(s)}:function(s){setTimeout(s)},I;function he(s){var i=s._batch;if(i!==null&&!i.hasDispatched&&i.keys.length<s._maxBatchSize)return i;var e={hasDispatched:!1,keys:[],callbacks:[]};return s._batch=e,s._batchScheduleFn(function(){pe(s,e)}),e}function pe(s,i){if(i.hasDispatched=!0,i.keys.length===0){k(i);return}var e;try{e=s._batchLoadFn(i.keys)}catch(t){return P(s,i,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(t)+".")))}if(!e||typeof e.then!="function")return P(s,i,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(e)+".")));e.then(function(t){if(!O(t))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(t)+"."));if(t.length!==i.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(` | ||
var B=Object.create;var M=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var J=(s,i)=>()=>(i||s((i={exports:{}}).exports,i),i.exports);var $=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of H(i))!G.call(s,r)&&r!==e&&M(s,r,{get:()=>i[r],enumerable:!(t=K(i,r))||t.enumerable});return s};var Q=(s,i,e)=>(e=s!=null?B(z(s)):{},$(i||!s||!s.__esModule?M(e,"default",{value:s,enumerable:!0}):e,s));var C=J((qe,j)=>{"use strict";var oe=function(){function s(e,t){if(typeof e!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+e+"."));this._batchLoadFn=e,this._maxBatchSize=le(t),this._batchScheduleFn=ue(t),this._cacheKeyFn=de(t),this._cacheMap=me(t),this._batch=null,this.name=fe(t)}var i=s.prototype;return i.load=function(t){if(t==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(t)+"."));var r=he(this),n=this._cacheMap,a=this._cacheKeyFn(t);if(n){var o=n.get(a);if(o){var c=r.cacheHits||(r.cacheHits=[]);return new Promise(function(h){c.push(function(){h(o)})})}}r.keys.push(t);var p=new Promise(function(h,b){r.callbacks.push({resolve:h,reject:b})});return n&&n.set(a,p),p},i.loadMany=function(t){if(!O(t))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+t+"."));for(var r=[],n=0;n<t.length;n++)r.push(this.load(t[n]).catch(function(a){return a}));return Promise.all(r)},i.clear=function(t){var r=this._cacheMap;if(r){var n=this._cacheKeyFn(t);r.delete(n)}return this},i.clearAll=function(){var t=this._cacheMap;return t&&t.clear(),this},i.prime=function(t,r){var n=this._cacheMap;if(n){var a=this._cacheKeyFn(t);if(n.get(a)===void 0){var o;r instanceof Error?(o=Promise.reject(r),o.catch(function(){})):o=Promise.resolve(r),n.set(a,o)}}return this},s}(),ce=typeof process=="object"&&typeof process.nextTick=="function"?function(s){I||(I=Promise.resolve()),I.then(function(){process.nextTick(s)})}:typeof setImmediate=="function"?function(s){setImmediate(s)}:function(s){setTimeout(s)},I;function he(s){var i=s._batch;if(i!==null&&!i.hasDispatched&&i.keys.length<s._maxBatchSize)return i;var e={hasDispatched:!1,keys:[],callbacks:[]};return s._batch=e,s._batchScheduleFn(function(){pe(s,e)}),e}function pe(s,i){if(i.hasDispatched=!0,i.keys.length===0){k(i);return}var e;try{e=s._batchLoadFn(i.keys)}catch(t){return P(s,i,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function "+("errored synchronously: "+String(t)+".")))}if(!e||typeof e.then!="function")return P(s,i,new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise: "+String(e)+".")));e.then(function(t){if(!O(t))throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did "+("not return a Promise of an Array: "+String(t)+"."));if(t.length!==i.keys.length)throw new TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys."+(` | ||
@@ -7,2 +7,2 @@ Keys: | ||
Values: | ||
`+String(t)));k(i);for(var r=0;r<i.callbacks.length;r++){var n=t[r];n instanceof Error?i.callbacks[r].reject(n):i.callbacks[r].resolve(n)}}).catch(function(t){P(s,i,t)})}function P(s,i,e){k(i);for(var t=0;t<i.keys.length;t++)s.clear(i.keys[t]),i.callbacks[t].reject(e)}function k(s){if(s.cacheHits)for(var i=0;i<s.cacheHits.length;i++)s.cacheHits[i]()}function le(s){var i=!s||s.batch!==!1;if(!i)return 1;var e=s&&s.maxBatchSize;if(e===void 0)return 1/0;if(typeof e!="number"||e<1)throw new TypeError("maxBatchSize must be a positive number: "+e);return e}function ue(s){var i=s&&s.batchScheduleFn;if(i===void 0)return ce;if(typeof i!="function")throw new TypeError("batchScheduleFn must be a function: "+i);return i}function de(s){var i=s&&s.cacheKeyFn;if(i===void 0)return function(e){return e};if(typeof i!="function")throw new TypeError("cacheKeyFn must be a function: "+i);return i}function me(s){var i=!s||s.cache!==!1;if(!i)return null;var e=s&&s.cacheMap;if(e===void 0)return new Map;if(e!==null){var t=["get","set","delete","clear"],r=t.filter(function(n){return e&&typeof e[n]!="function"});if(r.length!==0)throw new TypeError("Custom cacheMap missing methods: "+r.join(", "))}return e}function fe(s){return s&&s.name?s.name:null}function O(s){return typeof s=="object"&&s!==null&&typeof s.length=="number"&&(s.length===0||s.length>0&&Object.prototype.hasOwnProperty.call(s,s.length-1))}j.exports=oe});import{of as U}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{gtag:R}=window,d=class{constructor({tracker:i}){this.tracker=i||"t0",this.eventNames=new Map([["addToWishlist","add_to_wishlist"]])}track({eventName:i,product:e,variant:t,quantity:r=1}){var o,c;let n=this.eventNames.get(i);if(!n||!R||!e)return U(!1);let a=(o=t==null?void 0:t.price)!=null?o:e.variants[0].price;return R("event",n,{currency:a,value:t==null?void 0:t.price,items:[{item_id:(c=(t==null?void 0:t.sku)||(t==null?void 0:t.id))!=null?c:e.id,item_name:e.title,affiliation:"Wishlist King",item_category:e.type,item_brand:e.vendor,item_variant:t==null?void 0:t.title,item_quantity:r,item_price:a}]}),U(!0)}};import{of as N}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var m=class{constructor({urlUtil:i,moneyUtil:e}){this.urlUtil=i,this.moneyUtil=e,this.eventNames=new Map([["addToWishlist","Added To Wishlist"],["removeFromWishlist","Removed From Wishlist"],["clearWishlist","Cleared Wishlist"]])}track({eventName:i,wishlist:e,product:t,variant:r,quantity:n=1}){let a=this.eventNames.get(i);return!a||!e||!t?N(!1):(window._learnq||(window._learnq=[]),window._learnq.push(["track",a,{URL:this.urlUtil.getVariantUrl(t.url,r==null?void 0:r.id),Name:t.title,ProductID:t.id,VariantID:r==null?void 0:r.id,SKU:r==null?void 0:r.sku,Tags:t.tags,Brand:t.vendor,ImageURL:this.urlUtil.getImageUrl(t,{width:1e3}),Price:r==null?void 0:r.price,PriceFormatted:r?this.moneyUtil.formatMoney(r.price):null,CompareAtPrice:r==null?void 0:r.compare_at_price,CompareAtPriceFormatted:r!=null&&r.compare_at_price?this.moneyUtil.formatMoney(r.compare_at_price):null,Quantity:n,WishlistUrl:this.urlUtil.getPublicWishlistUrl(e.id)}]),N(!0))}};import{of as L}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{fbq:F}=window,f=class{constructor({currency:i}){this.currency=i,this.eventNames=new Map([["addToWishlist","AddToWishlist"]])}track({eventName:i,product:e,variant:t}){let r=this.eventNames.get(i);return!r||typeof F!="function"||!e?L(!1):(F("track",r,{value:t==null?void 0:t.price,currency:this.currency,content_ids:[e.id],content_name:[e.title,t==null?void 0:t.title].filter(n=>!!n).join(" - "),content_category:e.type,content_type:"product_group",num_items:1}),L(!0))}};import{catchError as X,from as Y,map as Z,of as w}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var u=class{constructor({host:i,shop:e,sessionId:t,customerId:r}){this.host=i,this.shop=e,this.customerId=r,this.sessionId=t,this.eventNames=new Map([["viewWishlist","wishlist_viewed"],["addToCart","product_added_to_cart"],["shareWishlist","wishlist_shared"]])}setSessionId(i){this.sessionId=i}track({eventName:i,wishlist:e,product:t,variant:r,quantity:n,source:a}){var c,p;if(!this.sessionId)return w(!1);let o=this.eventNames.get(i);return!o||!e?w(!1):Y(window.fetch(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":(c=this.sessionId)!=null?c:"","x-appmate-cid":(p=this.customerId)!=null?p:""},body:JSON.stringify({event:o,wid:e.publicId,pid:t==null?void 0:t.id,vid:r==null?void 0:r.id,qty:n,src:a})})).pipe(Z(()=>!0),X(()=>w(!1)))}getQuerystring(i){if(!i)return"";let e=new URLSearchParams;return Object.entries(i).forEach(([t,r])=>{Array.isArray(r)?r.forEach(n=>e.append(t,n)):r&&e.append(t,r)}),"?"+e.toString()}};import{from as ee,switchMap as te}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var l=class{constructor(i){this.host=i.host,this.headers={"content-type":"application/json"}}fetch({path:i,method:e="GET",query:t,body:r,headers:n={}}){return ee(window.fetch(this.host+i+this.getQuerystring(t),{method:e,headers:{...this.headers,...n},body:r})).pipe(te(a=>{if(a.ok)return a.json();throw Error(`Error ${a.status}`)}))}getQuerystring(i){if(!i)return"";let e=new URLSearchParams;return Object.entries(i).forEach(([t,r])=>{Array.isArray(r)?r.forEach(n=>e.append(t,n)):r&&e.append(t,r)}),"?"+e.toString()}get({path:i,query:e,headers:t}){return this.fetch({method:"GET",path:i,query:e,headers:t})}post({path:i,query:e,body:t,headers:r}){return this.fetch({method:"POST",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}put({path:i,query:e,body:t,headers:r}){return this.fetch({method:"PUT",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}delete({path:i,query:e,body:t,headers:r}){return this.fetch({method:"DELETE",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}};import{shareReplay as ie,tap as re}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var _=class extends l{constructor(){super(...arguments);this.pendingProducts=new Map}loadProduct({productHandle:e}){let t=`/products/${e}.js`,r=this.pendingProducts.get(t);if(r)return r;let n=this.get({path:t}).pipe(re(()=>{this.pendingProducts.delete(t)}),ie());return this.pendingProducts.set(t,n),n}addToCart(e){return this.post({path:"/cart/add.js",body:e})}};import{forkJoin as se,lastValueFrom as ne,of as ae}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var T=class{constructor({settings:i,events:e,notifyHost:t,utils:r,theme:n,shop:a,sessionId:o,customerId:c}){this.utils=r,this.theme=n,this.services=[],i.integrations.wishlistAnalytics.enabled&&this.services.push(new u({host:t,shop:a,customerId:c,sessionId:o})),i.integrations.klaviyo.enabled&&this.services.push(new m({urlUtil:this.utils.url,moneyUtil:this.utils.money})),i.integrations.metaPixel.enabled&&this.services.push(new f({currency:window.Shopify.currency.active})),i.integrations.googleAnalytics.enabled&&this.services.push(new d({tracker:i.integrations.googleAnalytics.tracker}));let p=this.theme.getPageType(),h=b=>g=>{var A,x,W,E;return ne(this.track({eventName:b,source:p,wishlist:(A=g.data)==null?void 0:A.wishlist,product:(x=g.data)==null?void 0:x.product,variant:(W=g.data)==null?void 0:W.variant,quantity:(E=g.data)==null?void 0:E.quantity}))};e.subscribeMany({"wk:wishlist:add-to-cart:success":h("addToCart"),"wk:wishlist:add:success":h("addToWishlist"),"wk:wishlist:change-variant:success":h("changeVariant"),"wk:wishlist:clear:success":h("clearWishlist"),"wk:wishlist:remove:success":h("removeFromWishlist"),"wk:wishlist:share:success":h("shareWishlist"),"wk:wishlist:page-view":h("viewWishlist")})}track(i){return this.services.length?se(this.services.map(e=>e.track(i))):ae([])}setSessionId(i){let e=this.services.find(t=>t instanceof u);e&&e.setSessionId(i)}};var S=Q(q());import{defer as C,from as D,lastValueFrom as V,shareReplay as y,switchMap as ge,tap as ye}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var v=class extends l{constructor(e){super(e);this.productMetafields=!1;this.headers={"content-type":"application/json","x-appmate-api":"2022-11"},e.shop&&(this.headers["x-appmate-shp"]=e.shop),e.sessionId&&(this.headers["x-appmate-sid"]=e.sessionId),e.customerId&&(this.headers["x-appmate-cid"]=e.customerId.toString()),e.trackingSource&&(this.headers["x-appmate-src"]=e.trackingSource),this.productMetafields=!!e.productMetafields,this.wishlistLoader=this.createWishlistLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}get hasSession(){return!!this.headers["x-appmate-sid"]||!!this.headers["x-appmate-cid"]}setSessionId(e){this.headers["x-appmate-sid"]=e}createWishlistLoader(){return new S.default(async e=>{let t=await Promise.all(e.map(r=>V(this.get({path:`/wishlists/${r}`})))).then(r=>r.map(n=>n.wishlist));return e.map(r=>{var n;return(n=t.find(a=>r==="mine"?a.isMine:a.publicId===r))!=null?n:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}createWishlistItemLoader(){return new S.default(async e=>{let t=e.map(n=>n.split("-")).reduce((n,[a,o])=>(n[a]||(n[a]=[]),n[a].push(o),n),{}),r=await Promise.all(Object.entries(t).map(([n,a])=>V(this.get({path:`/wishlists/${n}/items`,headers:{"x-appmate-ids":a.join(","),...this.productMetafields?{"x-appmate-pmf":!0}:{}}})))).then(n=>n.flatMap(a=>a.items));return e.map(n=>{var o;let[,a]=n.split("-");return(o=r.find(c=>c.id===a))!=null?o:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}loadWishlist({wishlistId:e}){return D(C(()=>this.wishlistLoader.load(e).then(t=>({wishlist:t}))))}loadWishlistItem({wishlistId:e,wishlistItemId:t}){return D(C(()=>this.wishlistItemLoader.load([e,t].join("-")).then(({selectedVariantId:r,...n})=>({wishlistItem:n}))))}addItem({productId:e,variantId:t}){if(typeof e=="string"&&(e=parseInt(e)),typeof t=="string"&&(t=parseInt(t)),!this.hasSession&&this._pendingSessionId)return this._pendingSessionId.pipe(ge(()=>this.addItem({productId:e,variantId:t})));let r=this.post({path:"/wishlists/mine/items",body:{productId:e,variantId:t}}).pipe(ye(n=>{n.sessionId&&(this.setSessionId(n.sessionId),this._pendingSessionId=void 0)}),y());return this.hasSession||(this._pendingSessionId=r),r}updateItem({wishlistItemId:e,changes:t}){return this.put({path:"/wishlists/mine/items",body:{changes:{...t,wishlistItemId:e}}}).pipe(y())}removeItem({wishlistId:e,wishlistItemId:t}){return this.delete({path:`/wishlists/${e}/items`,body:{wishlistItemId:t}}).pipe(y())}clearWishlist(){return this.delete({path:"/wishlists/mine"}).pipe(y())}};export{d as GoogleAnalytics,m as KlaviyoTracking,f as MetaPixel,u as NotifyApi,l as RestApi,_ as ShopifyApi,T as TrackingApi,v as WishlistApi}; | ||
`+String(t)));k(i);for(var r=0;r<i.callbacks.length;r++){var n=t[r];n instanceof Error?i.callbacks[r].reject(n):i.callbacks[r].resolve(n)}}).catch(function(t){P(s,i,t)})}function P(s,i,e){k(i);for(var t=0;t<i.keys.length;t++)s.clear(i.keys[t]),i.callbacks[t].reject(e)}function k(s){if(s.cacheHits)for(var i=0;i<s.cacheHits.length;i++)s.cacheHits[i]()}function le(s){var i=!s||s.batch!==!1;if(!i)return 1;var e=s&&s.maxBatchSize;if(e===void 0)return 1/0;if(typeof e!="number"||e<1)throw new TypeError("maxBatchSize must be a positive number: "+e);return e}function ue(s){var i=s&&s.batchScheduleFn;if(i===void 0)return ce;if(typeof i!="function")throw new TypeError("batchScheduleFn must be a function: "+i);return i}function de(s){var i=s&&s.cacheKeyFn;if(i===void 0)return function(e){return e};if(typeof i!="function")throw new TypeError("cacheKeyFn must be a function: "+i);return i}function me(s){var i=!s||s.cache!==!1;if(!i)return null;var e=s&&s.cacheMap;if(e===void 0)return new Map;if(e!==null){var t=["get","set","delete","clear"],r=t.filter(function(n){return e&&typeof e[n]!="function"});if(r.length!==0)throw new TypeError("Custom cacheMap missing methods: "+r.join(", "))}return e}function fe(s){return s&&s.name?s.name:null}function O(s){return typeof s=="object"&&s!==null&&typeof s.length=="number"&&(s.length===0||s.length>0&&Object.prototype.hasOwnProperty.call(s,s.length-1))}j.exports=oe});import{of as U}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{gtag:R}=window,d=class{constructor({tracker:i}){this.tracker=i||"t0",this.eventNames=new Map([["addToWishlist","add_to_wishlist"]])}track({eventName:i,product:e,variant:t,quantity:r=1}){var o,c;let n=this.eventNames.get(i);if(!n||!R||!e)return U(!1);let a=(o=t==null?void 0:t.price)!=null?o:e.variants[0].price;return R("event",n,{currency:a,value:t==null?void 0:t.price,items:[{item_id:(c=(t==null?void 0:t.sku)||(t==null?void 0:t.id))!=null?c:e.id,item_name:e.title,affiliation:"Wishlist King",item_category:e.type,item_brand:e.vendor,item_variant:t==null?void 0:t.title,item_quantity:r,item_price:a}]}),U(!0)}};import{of as N}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var m=class{constructor({urlUtil:i,moneyUtil:e}){this.urlUtil=i,this.moneyUtil=e,this.eventNames=new Map([["addToWishlist","Added To Wishlist"],["removeFromWishlist","Removed From Wishlist"],["clearWishlist","Cleared Wishlist"]])}track({eventName:i,wishlist:e,product:t,variant:r,quantity:n=1}){let a=this.eventNames.get(i);return!a||!e||!t?N(!1):(window._learnq||(window._learnq=[]),window._learnq.push(["track",a,{URL:this.urlUtil.getVariantUrl(t.url,r==null?void 0:r.id),Name:t.title,ProductID:t.id,VariantID:r==null?void 0:r.id,SKU:r==null?void 0:r.sku,Tags:t.tags,Brand:t.vendor,ImageURL:this.urlUtil.getImageUrl(t,{width:1e3}),Price:r==null?void 0:r.price,PriceFormatted:r?this.moneyUtil.formatMoney(r.price):null,CompareAtPrice:r==null?void 0:r.compare_at_price,CompareAtPriceFormatted:r!=null&&r.compare_at_price?this.moneyUtil.formatMoney(r.compare_at_price):null,Quantity:n,WishlistUrl:this.urlUtil.getPublicWishlistUrl(e.id)}]),N(!0))}};import{of as L}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var{fbq:F}=window,f=class{constructor({currency:i}){this.currency=i,this.eventNames=new Map([["addToWishlist","AddToWishlist"]])}track({eventName:i,product:e,variant:t}){let r=this.eventNames.get(i);return!r||typeof F!="function"||!e?L(!1):(F("track",r,{value:t==null?void 0:t.price,currency:this.currency,content_ids:[e.id],content_name:[e.title,t==null?void 0:t.title].filter(n=>!!n).join(" - "),content_category:e.type,content_type:"product_group",num_items:1}),L(!0))}};import{catchError as X,from as Y,map as Z,of as w}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var u=class{constructor({host:i,shop:e,sessionId:t,customerId:r}){this.host=i,this.shop=e,this.customerId=r,this.sessionId=t,this.eventNames=new Map([["viewWishlist","wishlist_viewed"],["addToCart","product_added_to_cart"],["shareWishlist","wishlist_shared"]])}setSessionId(i){this.sessionId=i}track({eventName:i,wishlist:e,product:t,variant:r,quantity:n,source:a}){var c,p;if(!this.sessionId)return w(!1);let o=this.eventNames.get(i);return!o||!e?w(!1):Y(window.fetch(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":(c=this.sessionId)!=null?c:"","x-appmate-cid":(p=this.customerId)!=null?p:""},body:JSON.stringify({event:o,wid:e.publicId,pid:t==null?void 0:t.id,vid:r==null?void 0:r.id,qty:n,src:a})})).pipe(Z(()=>!0),X(()=>w(!1)))}getQuerystring(i){if(!i)return"";let e=new URLSearchParams;return Object.entries(i).forEach(([t,r])=>{Array.isArray(r)?r.forEach(n=>e.append(t,n)):r&&e.append(t,r)}),"?"+e.toString()}};import{from as ee,switchMap as te}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var l=class{constructor(i){this.host=i.host,this.headers={"content-type":"application/json"}}fetch({path:i,method:e="GET",query:t,body:r,headers:n={}}){return ee(window.fetch(this.host+i+this.getQuerystring(t),{method:e,headers:{...this.headers,...n},body:r})).pipe(te(a=>{if(a.ok)return a.json();throw Error(`Error ${a.status}`)}))}getQuerystring(i){if(!i)return"";let e=new URLSearchParams;return Object.entries(i).forEach(([t,r])=>{Array.isArray(r)?r.forEach(n=>e.append(t,n)):r&&e.append(t,r)}),"?"+e.toString()}get({path:i,query:e,headers:t}){return this.fetch({method:"GET",path:i,query:e,headers:t})}post({path:i,query:e,body:t,headers:r}){return this.fetch({method:"POST",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}put({path:i,query:e,body:t,headers:r}){return this.fetch({method:"PUT",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}delete({path:i,query:e,body:t,headers:r}){return this.fetch({method:"DELETE",path:i,query:e,body:t?JSON.stringify(t):void 0,headers:r})}};import{shareReplay as ie,tap as re}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var _=class extends l{constructor(){super(...arguments);this.pendingProducts=new Map}loadProduct({productHandle:e}){let t=`/products/${e}.js`,r=this.pendingProducts.get(t);if(r)return r;let n=this.get({path:t}).pipe(re(()=>{this.pendingProducts.delete(t)}),ie());return this.pendingProducts.set(t,n),n}addToCart(e){return this.post({path:"/cart/add.js",body:e})}};import{forkJoin as se,lastValueFrom as ne,of as ae}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var T=class{constructor({settings:i,events:e,notifyHost:t,utils:r,theme:n,shop:a,sessionId:o,customerId:c}){this.utils=r,this.theme=n,this.services=[],i.integrations.wishlistAnalytics.enabled&&this.services.push(new u({host:t,shop:a,customerId:c,sessionId:o})),i.integrations.klaviyo.enabled&&this.services.push(new m({urlUtil:this.utils.url,moneyUtil:this.utils.money})),i.integrations.metaPixel.enabled&&this.services.push(new f({currency:window.Shopify.currency.active})),i.integrations.googleAnalytics.enabled&&this.services.push(new d({tracker:i.integrations.googleAnalytics.tracker}));let p=this.theme.getPageType(),h=b=>g=>{var A,x,W,E;return ne(this.track({eventName:b,source:p,wishlist:(A=g.data)==null?void 0:A.wishlist,product:(x=g.data)==null?void 0:x.product,variant:(W=g.data)==null?void 0:W.variant,quantity:(E=g.data)==null?void 0:E.quantity}))};e.subscribeMany({"wk:wishlist:add-to-cart:success":h("addToCart"),"wk:wishlist:add:success":h("addToWishlist"),"wk:wishlist:change-variant:success":h("changeVariant"),"wk:wishlist:clear:success":h("clearWishlist"),"wk:wishlist:remove:success":h("removeFromWishlist"),"wk:wishlist:share:success":h("shareWishlist"),"wk:wishlist:page-view":h("viewWishlist")})}track(i){return this.services.length?se(this.services.map(e=>e.track(i))):ae([])}setSessionId(i){let e=this.services.find(t=>t instanceof u);e&&e.setSessionId(i)}};var S=Q(C());import{defer as q,from as D,lastValueFrom as V,shareReplay as y,switchMap as ge,tap as ye}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";var v=class extends l{constructor(e){super(e);this.productMetafields=!1;this.headers={"content-type":"application/json","x-appmate-api":"2022-11"},e.shop&&(this.headers["x-appmate-shp"]=e.shop),e.sessionId&&(this.headers["x-appmate-sid"]=e.sessionId),e.customerId&&(this.headers["x-appmate-cid"]=e.customerId.toString()),e.trackingSource&&(this.headers["x-appmate-src"]=e.trackingSource),this.productMetafields=!!e.productMetafields,this.wishlistLoader=this.createWishlistLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}get hasSession(){return!!this.headers["x-appmate-sid"]||!!this.headers["x-appmate-cid"]}get hasCustomer(){return!!this.headers["x-appmate-cid"]}setSessionId(e){this.headers["x-appmate-sid"]=e}createWishlistLoader(){return new S.default(async e=>{let t=await Promise.all(e.map(r=>V(this.get({path:`/wishlists/${r}`})))).then(r=>r.map(n=>n.wishlist));return e.map(r=>{var n;return(n=t.find(a=>r==="mine"?a.isMine:a.publicId===r))!=null?n:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}createWishlistItemLoader(){return new S.default(async e=>{let t=e.map(n=>n.split("-")).reduce((n,[a,o])=>(n[a]||(n[a]=[]),n[a].push(o),n),{}),r=await Promise.all(Object.entries(t).map(([n,a])=>V(this.get({path:`/wishlists/${n}/items`,headers:{"x-appmate-ids":a.join(","),...this.productMetafields?{"x-appmate-pmf":!0}:{}}})))).then(n=>n.flatMap(a=>a.items));return e.map(n=>{var o;let[,a]=n.split("-");return(o=r.find(c=>c.id===a))!=null?o:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}loadWishlist({wishlistId:e}){return D(q(()=>this.wishlistLoader.load(e).then(t=>({wishlist:t}))))}loadWishlistItem({wishlistId:e,wishlistItemId:t}){return D(q(()=>this.wishlistItemLoader.load([e,t].join("-")).then(({selectedVariantId:r,...n})=>({wishlistItem:n}))))}addItem({productId:e,variantId:t}){if(typeof e=="string"&&(e=parseInt(e)),typeof t=="string"&&(t=parseInt(t)),!this.hasSession&&this._pendingSessionId)return this._pendingSessionId.pipe(ge(()=>this.addItem({productId:e,variantId:t})));let r=this.post({path:"/wishlists/mine/items",body:{productId:e,variantId:t}}).pipe(ye(n=>{n.sessionId&&(this.setSessionId(n.sessionId),this._pendingSessionId=void 0)}),y());return this.hasSession||(this._pendingSessionId=r),r}updateItem({wishlistItemId:e,changes:t}){return this.put({path:"/wishlists/mine/items",body:{changes:{...t,wishlistItemId:e}}}).pipe(y())}removeItem({wishlistId:e,wishlistItemId:t}){return this.delete({path:`/wishlists/${e}/items`,body:{wishlistItemId:t}}).pipe(y())}clearWishlist(){return this.delete({path:"/wishlists/mine"}).pipe(y())}};export{d as GoogleAnalytics,m as KlaviyoTracking,f as MetaPixel,u as NotifyApi,l as RestApi,_ as ShopifyApi,T as TrackingApi,v as WishlistApi}; |
@@ -1,2 +0,2 @@ | ||
import{LitElement as h,html as i}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.22.10/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/components/icon.js";var s=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 r,e,n,o;if(!((r=this.counter)!=null&&r.floating))return;let t=((n=(e=this.counter)==null?void 0:e.floating)==null?void 0:n.reference)==="icon"?(o=this.iconElement)!=null?o:this:this;return{...this.counter.floating,reference:t}}}get iconElement(){return this.querySelector(".wk-icon")}render(){var n,o,l,a;let t=(n=this.alignSelf)!=null?n:"center",r=(o=this.alignContent)!=null?o:"center",e=["wk-button",`wk-align-${t}`,`wk-align-content-${r}`,this.selected&&"wk-selected",this.fullWidth&&"wk-full-width"].filter(c=>!!c).join(" ");return this.href?i` | ||
import{LitElement as h,html as i}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.22.11/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/components/counter.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/components/icon.js";var s=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 r,e,n,o;if(!((r=this.counter)!=null&&r.floating))return;let t=((n=(e=this.counter)==null?void 0:e.floating)==null?void 0:n.reference)==="icon"?(o=this.iconElement)!=null?o:this:this;return{...this.counter.floating,reference:t}}}get iconElement(){return this.querySelector(".wk-icon")}render(){var n,o,l,a;let t=(n=this.alignSelf)!=null?n:"center",r=(o=this.alignContent)!=null?o:"center",e=["wk-button",`wk-align-${t}`,`wk-align-content-${r}`,this.selected&&"wk-selected",this.fullWidth&&"wk-full-width"].filter(c=>!!c).join(" ");return this.href?i` | ||
<a href=${this.href} aria-label=${(l=this.hint)!=null?l:""} class=${e}> | ||
@@ -3,0 +3,0 @@ ${this.renderIcon()}${this.renderText()}${this.renderCounter()} |
@@ -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 n}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/controllers.js";var t=class extends s{constructor(){super(...arguments);this.value=0;this.showIcon=!1;this.showNumber=!1;this.showBrackets=!1;this.floatingUi=new n(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},showIcon:{type:Boolean,attribute:"show-icon"},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 n}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/controllers.js";var t=class extends s{constructor(){super(...arguments);this.value=0;this.showIcon=!1;this.showNumber=!1;this.showBrackets=!1;this.floatingUi=new n(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},showIcon:{type:Boolean,attribute:"show-icon"},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 n}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.22.10/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}]`,s=`${this.app.utils.url.handlelize(this.id)}-select`;return n` | ||
import{LitElement as l,html as n}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.22.11/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}]`,s=`${this.app.utils.url.handlelize(this.id)}-select`;return n` | ||
<div class="wk-option-select"> | ||
@@ -3,0 +3,0 @@ <label class="wk-label" for=${s}>${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.22.10/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.22.11/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.22.10", | ||
"version": "4.22.11", | ||
"description": "Wishlist King SDK", | ||
@@ -5,0 +5,0 @@ "main": "wishlist-app.js", |
@@ -1,1 +0,1 @@ | ||
var j=(a=21)=>crypto.getRandomValues(new Uint8Array(a)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");var p=class{constructor(t){this.element=t}replace(t){var e;return(e=this.element)==null||e.replaceWith(t),t}append(t){var e;return(e=this.element)==null||e.append(t),t}prepend(t){var e;return(e=this.element)==null||e.prepend(t),t}insertBefore(t){var e;return(e=this.element)==null||e.before(t),t}insertAfter(t){var e;return(e=this.element)==null||e.after(t),t}closest(t,e=5){if(!this.element)return new p;if(typeof t=="object")return this.searchByStyle(t,this.element,i=>i.parentElement,e);let s=this.element.closest(t);return s?new p(s):new p}find(t){var s;let e=(s=this.element)==null?void 0:s.querySelector(t);return e?new p(e):new p}searchByStyle(t,e,s,i=5){if(i<0||!e)return null;let r=getComputedStyle(e);if(Object.entries(t).every(([l,c])=>r.getPropertyValue(l)===c))return new p(e);let o=s(e);return o?this.searchByStyle(t,o,s,i-1):null}};var g=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((s,i)=>s.concat(Array.from(i.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("data-appmate")).forEach(s=>{s instanceof Element&&this.scan(s)})}),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),_(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){t&&this.subscriber.filter(e=>_(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=t instanceof Element&&t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(s&&this.notify(e,t),s&&e.target.firstMatch)return;let i=t.querySelectorAll(e.target.selector);for(let r of i)if(!this.shouldSkip(r,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,r),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("data-appmate")){e.setAttribute("data-appmate","");let s=new p(e);t.callback(s)}}};function _({target:a},t){if(!a.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(a.pageType)?a.pageType:[a.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var O=[{pageType:"product",match:a=>a.includes("/products/")},{pageType:"collection",match:a=>a.includes("/collections/")&&!a.includes("/products/")},{pageType:"account",match:a=>a.includes("/account/")||a.endsWith("/account")},{pageType:"blog",match:a=>a.includes("/blog/")},{pageType:"cart",match:a=>a.includes("/cart/")||a.endsWith("/cart")},{pageType:"wishlist",match:(a,{wishlistUrl:t})=>a.includes(t)},{pageType:"page",match:a=>a.includes("/pages/")},{pageType:"search",match:a=>a.includes("/search")},{pageType:"home",match:a=>a.length<4}],f=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of O)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var w=class{constructor(t){this.locale={};var e;this.initLocale((e=t==null?void 0:t.locale)!=null?e:{})}initLocale(t){this.locale=this.decodeLocale(t)}decodeHtmlEntities(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(t){let e={};for(let s in t){e[s]={};for(let i in t[s])e[s][i]=this.decodeHtmlEntities(t[s][i])}return e}translate(t,e){var n;let[s,i]=t.split("."),r=(n=this.locale[s])==null?void 0:n[i];return r?e?Object.entries(e).reduce((o,[l,c])=>o.replace(new RegExp(`{{\\s*${l}\\s*}}`,"g"),c),r):r:`translation missing: ${t}`}};var u=class{constructor({rootUrl:t,wishlistUrl:e}){this._rootUrl=t,this.route=new f({wishlistUrl:e}),this.observer=new g({routeUtil:this.route}),this.locale=new w,this.watch=this.observer.watch.bind(this.observer)}getPageType(t=window.location.pathname){return this.route.parse(t).pageType}getWishlistId(t){if(!t)return null;t instanceof URL&&(t=t.pathname);let e=t.replace(this._rootUrl,"/").split("/");return e.length===4?e.pop():"mine"}getProductHandle(t){var e;return t?(t instanceof URL&&(t=t.pathname),(e=t.split("/").pop())==null?void 0:e.split("?")[0]):null}getVariantId(t){return t?(t instanceof URL&&(t=t.pathname),new URLSearchParams(t.split("?")[1]).get("variant")):null}translate(t,e){return this.locale.translate(t,e)}createComponent(t,e){var i;let s=document.createElement(t);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,n])=>{n&&(typeof n=="boolean"?s.dataset[r]="":typeof n=="object"?s.dataset[r]=JSON.stringify(n):s.dataset[r]=n)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,n])=>{if(r==="floating"){let o=n,l=(o==null?void 0:o.reference)instanceof p?o.reference.element:o.reference;if(typeof l=="object"&&"id"in l){l.id=l.id||`wk-${j()}`,s[r]={...o,reference:`#${l.id}`};return}}s[r]=n}),(i=e==null?void 0:e.wrap)!=null&&i.name?this.createElement(e.wrap.name,e.wrap.props,s):s}createHeadlessComponent(t,e){var r;let s=e.host.element?e.host.element:e.host;if(!s)throw new Error("Headless host is undefined");e.dataset&&Object.entries(e.dataset).forEach(([n,o])=>{o&&(typeof o=="boolean"?s.dataset[n]="":typeof o=="object"?s.dataset[n]=JSON.stringify(o):s.dataset[n]=o)});let i=(r=window.headlessElements)==null?void 0:r.store.get(t);if(!i)throw new Error(`Headless element not found: ${t}`);return new i(s)}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var y=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};window.headlessElements||(window.headlessElements={store:new Map,define(a,t){var e;(e=window.headlessElements)==null||e.store.set(a,t)}});var N=class{constructor({dependencies:t=[],...e}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=t=>this.state.promise.addToCart(t);this.addAllToCart=t=>this.state.promise.addAllToCart(t);this.addWishlistItem=t=>this.state.promise.addWishlistItem(t);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=t=>this.state.promise.loadProductInfo(t);this.loadShopifyProduct=t=>this.state.promise.loadShopifyProduct(t);this.loadWishlist=t=>this.state.promise.loadWishlist(t);this.loadWishlistItem=t=>this.state.promise.loadWishlistItem(t);this.publishWishlistEvent=t=>this.state.promise.publishWishlistEvent(t);this.publishWishlistProductEvent=t=>this.state.promise.publishWishlistProductEvent(t);this.removeWishlistItem=t=>this.state.promise.removeWishlistItem(t);this.shareWishlist=t=>this.state.promise.shareWishlist(t);this.updateWishlistItem=t=>this.state.promise.updateWishlistItem(t);this.config=this.parseConfig(e),this.settings=this.parseSettings(e),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.events=new y,this.theme=new u({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl});let{stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:n}=t.reduce(({stylesheets:o,scripts:l,iconSetUrl:c,localeUrl:h},d)=>{let[m]=d.split("?");return m.endsWith(".css")?o.push(d):m.endsWith("icons.js")?c=d:m.endsWith(".js")?l.push(d):m.endsWith(".json")&&(h=d),{stylesheets:o,scripts:l,iconSetUrl:c,localeUrl:h}},{stylesheets:[],scripts:[],iconSetUrl:"",localeUrl:""});this.initStyles({stylesheets:s,iconSetUrl:r,localeUrl:n}),this.initScripts(i),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load(),window.WishlistKing=this,this.events.publish({name:"wk:app:created"})}get loaded(){return this._loaded}get state(){return b(this._state)}get apis(){return b(this._apis)}get utils(){return b(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var t;return!!((t=this.customer)!=null&&t.id)}getSessionId(){let t=window.localStorage.getItem("wk_session_id");if(t)return t;let e=window.localStorage.getItem("appmate-session");if(e)try{let s=JSON.parse(e).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(t){var e;return window.localStorage.setItem("wk_session_id",t),(e=this._apis)==null||e.tracking.setSessionId(t),t}async load(){return this._loadPromise?this._loadPromise:this._loadPromise=(async()=>{let[{WishlistState:t},{ShopifyApi:e,WishlistApi:s,TrackingApi:i},{MoneyUtil:r,UrlUtil:n,ProductUtil:o}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:n,ProductUtil:o}),this.initApis({WishlistApi:s,ShopifyApi:e,TrackingApi:i}),this.initState({WishlistState:t}),this.initUrlChangeEvents(),this.trackCurrentPage(),this.hasSession||(await this.state.promise.clearCache(),this.events.once("wk:app:init-sid",l=>{var c,h;(c=l.data)!=null&&c.sessionId&&this.setSessionId((h=l.data)==null?void 0:h.sessionId)})),this._loaded=!0,this.events.publish({name:"wk:app:load:success"})})()}initUtils({UrlUtil:t,MoneyUtil:e,ProductUtil:s}){this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:this.config.shop.domain,placeholderImageUrl:this.config.products.fallbackImage,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:this.config.shop.moneyFormat,moneyFormatWithCurrency:this.config.shop.moneyFormatWithCurrency}),product:new s}}initApis({WishlistApi:t,ShopifyApi:e,TrackingApi:s}){var i,r;this._apis={wishlist:new t({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(i=this.config.customer.id)!=null?i:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType(),productMetafields:this.config.products.metafields}),shopify:new e({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:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils})}async initStyles({stylesheets:t,iconSetUrl:e,localeUrl:s}){if(!(t!=null&&t.length)&&!e){this.onStylesLoaded();return}try{await Promise.all([...(t!=null?t:[]).map(i=>new Promise((r,n)=>{let o=document.createElement("link");o.rel="stylesheet",o.href=i,o.onload=r,o.onerror=n,document.head.appendChild(o)})),e?Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/components/icon.js"),import(e)]).then(([{Icon:i},{icons:r}])=>{if(typeof r!="object")throw new Error("Icon set must export icons object.");i.addIcons(r)}):Promise.resolve(),s?fetch(s).then(i=>i.json()).then(i=>{this.theme.locale.initLocale(i)}):Promise.resolve()]),this.onStylesLoaded()}catch(i){console.warn(i),this.events.publish({name:"wk:app:load-styles:error"})}}async initScripts(t){if(!(t!=null&&t.length)){this.events.publish({name:"wk:app:load-scripts:success"});return}try{await Promise.all(t.map(e=>import(e))),this.events.publish({name:"wk:app:load-scripts:success"})}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-scripts:error"})}}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let e=this.theme.getWishlistId(window.location.pathname);e&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:e})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUrlChangeEvents(){let t=history.replaceState,e=({productHandle:s,variantId:i})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:i}})};history.replaceState=(...s)=>{let i=`${window.location.protocol}//${window.location.host}`,r=typeof s[2]=="string"?new URL(s[2],i):s[2],n=t.apply(history,s);if(!r)return n;let o=this.theme.getProductHandle(r),l=r.searchParams.get("variant");if(!o||!l)return n;e({productHandle:o,variantId:parseInt(l)})}}parseConfig({config:t}){var e,s,i,r,n,o,l,c;return{customer:{id:t.customerId?t.customerId:null,email:(e=t.customerEmail)!=null?e:""},shop:{name:(s=t.shopName)!=null?s:"",domain:(i=t.shopDomain)!=null?i:"",permanentDomain:(r=t.shopPermanentDomain)!=null?r:"",moneyFormat:(n=t.shopMoneyFormat)!=null?n:"",moneyFormatWithCurrency:(o=t.shopMoneyFormatWithCurrency)!=null?o:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(l=t.apiHost)!=null?l:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(c=t.productFallbackImage)!=null?c:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081",metafields:!!t.productMetafields}}}parseSettings({settings:t}){var e,s,i,r,n,o,l,c,h,d,m,U,E,W,v,S,P,T,k,A,I,R,L,M,C,H,x;return{general:{appLoading:(s=(e=t==null?void 0:t.general)==null?void 0:e.appLoading)!=null?s:"LAZY",wishlistAccessMode:this.config.customer.id?"UNRESTRICTED":(r=(i=t==null?void 0:t.general)==null?void 0:i.wishlistAccessMode)!=null?r:"UNRESTRICTED",wishlistMode:(o=(n=t==null?void 0:t.general)==null?void 0:n.wishlistMode)!=null?o:"PRODUCT",wishlistPath:(c=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?c:"/apps/wishlist"},money:{withCurrency:(d=(h=t==null?void 0:t.money)==null?void 0:h.withCurrency)!=null?d:!1},integrations:{googleAnalytics:{enabled:(E=(U=(m=t.integrations)==null?void 0:m.googleAnalytics)==null?void 0:U.enabled)!=null?E:!1,tracker:(S=(v=(W=t.integrations)==null?void 0:W.googleAnalytics)==null?void 0:v.tracker)!=null?S:""},klaviyo:{enabled:(k=(T=(P=t.integrations)==null?void 0:P.klaviyo)==null?void 0:T.enabled)!=null?k:!1},metaPixel:{enabled:(R=(I=(A=t.integrations)==null?void 0:A.metaPixel)==null?void 0:I.enabled)!=null?R:!1},wishlistAnalytics:{enabled:(C=(M=(L=t.integrations)==null?void 0:L.metaPixel)==null?void 0:M.enabled)!=null?C:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4}},colorMap:(H=t.colorMap)!=null?H:{},collectionButtons:(x=t.collectionButtons)!=null?x:{}}}parseRoutes(){let t=this.config.routes.rootUrl;return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+this.settings.general.wishlistPath.split("/").filter(e=>!!e).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}},b=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{N as WishlistApp}; | ||
var j=(a=21)=>crypto.getRandomValues(new Uint8Array(a)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");var p=class{constructor(t){this.element=t}replace(t){var e;return(e=this.element)==null||e.replaceWith(t),t}append(t){var e;return(e=this.element)==null||e.append(t),t}prepend(t){var e;return(e=this.element)==null||e.prepend(t),t}insertBefore(t){var e;return(e=this.element)==null||e.before(t),t}insertAfter(t){var e;return(e=this.element)==null||e.after(t),t}closest(t,e=5){if(!this.element)return new p;if(typeof t=="object")return this.searchByStyle(t,this.element,i=>i.parentElement,e);let s=this.element.closest(t);return s?new p(s):new p}find(t){var s;let e=(s=this.element)==null?void 0:s.querySelector(t);return e?new p(e):new p}searchByStyle(t,e,s,i=5){if(i<0||!e)return null;let r=getComputedStyle(e);if(Object.entries(t).every(([l,c])=>r.getPropertyValue(l)===c))return new p(e);let o=s(e);return o?this.searchByStyle(t,o,s,i-1):null}};var g=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((s,i)=>s.concat(Array.from(i.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("data-appmate")).forEach(s=>{s instanceof Element&&this.scan(s)})}),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),_(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){t&&this.subscriber.filter(e=>_(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=t instanceof Element&&t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(s&&this.notify(e,t),s&&e.target.firstMatch)return;let i=t.querySelectorAll(e.target.selector);for(let r of i)if(!this.shouldSkip(r,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,r),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("data-appmate")){e.setAttribute("data-appmate","");let s=new p(e);t.callback(s)}}};function _({target:a},t){if(!a.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(a.pageType)?a.pageType:[a.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var O=[{pageType:"product",match:a=>a.includes("/products/")},{pageType:"collection",match:a=>a.includes("/collections/")&&!a.includes("/products/")},{pageType:"account",match:a=>a.includes("/account/")||a.endsWith("/account")},{pageType:"blog",match:a=>a.includes("/blog/")},{pageType:"cart",match:a=>a.includes("/cart/")||a.endsWith("/cart")},{pageType:"wishlist",match:(a,{wishlistUrl:t})=>a.includes(t)},{pageType:"page",match:a=>a.includes("/pages/")},{pageType:"search",match:a=>a.includes("/search")},{pageType:"home",match:a=>a.length<4}],f=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of O)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var w=class{constructor(t){this.locale={};var e;this.initLocale((e=t==null?void 0:t.locale)!=null?e:{})}initLocale(t){this.locale=this.decodeLocale(t)}decodeHtmlEntities(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(t){let e={};for(let s in t){e[s]={};for(let i in t[s])e[s][i]=this.decodeHtmlEntities(t[s][i])}return e}translate(t,e){var n;let[s,i]=t.split("."),r=(n=this.locale[s])==null?void 0:n[i];return r?e?Object.entries(e).reduce((o,[l,c])=>o.replace(new RegExp(`{{\\s*${l}\\s*}}`,"g"),c),r):r:`translation missing: ${t}`}};var u=class{constructor({rootUrl:t,wishlistUrl:e}){this._rootUrl=t,this.route=new f({wishlistUrl:e}),this.observer=new g({routeUtil:this.route}),this.locale=new w,this.watch=this.observer.watch.bind(this.observer)}getPageType(t=window.location.pathname){return this.route.parse(t).pageType}getWishlistId(t){if(!t)return null;t instanceof URL&&(t=t.pathname);let e=t.replace(this._rootUrl,"/").split("/");return e.length===4?e.pop():"mine"}getProductHandle(t){var e;return t?(t instanceof URL&&(t=t.pathname),(e=t.split("/").pop())==null?void 0:e.split("?")[0]):null}getVariantId(t){return t?(t instanceof URL&&(t=t.pathname),new URLSearchParams(t.split("?")[1]).get("variant")):null}translate(t,e){return this.locale.translate(t,e)}createComponent(t,e){var i;let s=document.createElement(t);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,n])=>{n&&(typeof n=="boolean"?s.dataset[r]="":typeof n=="object"?s.dataset[r]=JSON.stringify(n):s.dataset[r]=n)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,n])=>{if(r==="floating"){let o=n,l=(o==null?void 0:o.reference)instanceof p?o.reference.element:o.reference;if(typeof l=="object"&&"id"in l){l.id=l.id||`wk-${j()}`,s[r]={...o,reference:`#${l.id}`};return}}s[r]=n}),(i=e==null?void 0:e.wrap)!=null&&i.name?this.createElement(e.wrap.name,e.wrap.props,s):s}createHeadlessComponent(t,e){var r;let s=e.host.element?e.host.element:e.host;if(!s)throw new Error("Headless host is undefined");e.dataset&&Object.entries(e.dataset).forEach(([n,o])=>{o&&(typeof o=="boolean"?s.dataset[n]="":typeof o=="object"?s.dataset[n]=JSON.stringify(o):s.dataset[n]=o)});let i=(r=window.headlessElements)==null?void 0:r.store.get(t);if(!i)throw new Error(`Headless element not found: ${t}`);return new i(s)}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var y=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};window.headlessElements||(window.headlessElements={store:new Map,define(a,t){var e;(e=window.headlessElements)==null||e.store.set(a,t)}});var N=class{constructor({dependencies:t=[],...e}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=t=>this.state.promise.addToCart(t);this.addAllToCart=t=>this.state.promise.addAllToCart(t);this.addWishlistItem=t=>this.state.promise.addWishlistItem(t);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=t=>this.state.promise.loadProductInfo(t);this.loadShopifyProduct=t=>this.state.promise.loadShopifyProduct(t);this.loadWishlist=t=>this.state.promise.loadWishlist(t);this.loadWishlistItem=t=>this.state.promise.loadWishlistItem(t);this.publishWishlistEvent=t=>this.state.promise.publishWishlistEvent(t);this.publishWishlistProductEvent=t=>this.state.promise.publishWishlistProductEvent(t);this.removeWishlistItem=t=>this.state.promise.removeWishlistItem(t);this.shareWishlist=t=>this.state.promise.shareWishlist(t);this.updateWishlistItem=t=>this.state.promise.updateWishlistItem(t);this.config=this.parseConfig(e),this.settings=this.parseSettings(e),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.events=new y,this.theme=new u({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl});let{stylesheets:s,scripts:i,iconSetUrl:r,localeUrl:n}=t.reduce(({stylesheets:o,scripts:l,iconSetUrl:c,localeUrl:h},d)=>{let[m]=d.split("?");return m.endsWith(".css")?o.push(d):m.endsWith("icons.js")?c=d:m.endsWith(".js")?l.push(d):m.endsWith(".json")&&(h=d),{stylesheets:o,scripts:l,iconSetUrl:c,localeUrl:h}},{stylesheets:[],scripts:[],iconSetUrl:"",localeUrl:""});this.initStyles({stylesheets:s,iconSetUrl:r,localeUrl:n}),this.initScripts(i),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load(),window.WishlistKing=this,this.events.publish({name:"wk:app:created"})}get loaded(){return this._loaded}get state(){return b(this._state)}get apis(){return b(this._apis)}get utils(){return b(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var t;return!!((t=this.customer)!=null&&t.id)}getSessionId(){let t=window.localStorage.getItem("wk_session_id");if(t)return t;let e=window.localStorage.getItem("appmate-session");if(e)try{let s=JSON.parse(e).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(t){var e;return window.localStorage.setItem("wk_session_id",t),(e=this._apis)==null||e.tracking.setSessionId(t),t}async load(){return this._loadPromise?this._loadPromise:this._loadPromise=(async()=>{let[{WishlistState:t},{ShopifyApi:e,WishlistApi:s,TrackingApi:i},{MoneyUtil:r,UrlUtil:n,ProductUtil:o}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:n,ProductUtil:o}),this.initApis({WishlistApi:s,ShopifyApi:e,TrackingApi:i}),this.initState({WishlistState:t}),this.initUrlChangeEvents(),this.trackCurrentPage(),this.hasSession||(await this.state.promise.clearCache(),this.events.once("wk:app:init-sid",l=>{var c,h;(c=l.data)!=null&&c.sessionId&&this.setSessionId((h=l.data)==null?void 0:h.sessionId)})),this._loaded=!0,this.events.publish({name:"wk:app:load:success"})})()}initUtils({UrlUtil:t,MoneyUtil:e,ProductUtil:s}){this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:this.config.shop.domain,placeholderImageUrl:this.config.products.fallbackImage,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:this.config.shop.moneyFormat,moneyFormatWithCurrency:this.config.shop.moneyFormatWithCurrency}),product:new s}}initApis({WishlistApi:t,ShopifyApi:e,TrackingApi:s}){var i,r;this._apis={wishlist:new t({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(i=this.config.customer.id)!=null?i:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType(),productMetafields:this.config.products.metafields}),shopify:new e({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:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils})}async initStyles({stylesheets:t,iconSetUrl:e,localeUrl:s}){if(!(t!=null&&t.length)&&!e){this.onStylesLoaded();return}try{await Promise.all([...(t!=null?t:[]).map(i=>new Promise((r,n)=>{let o=document.createElement("link");o.rel="stylesheet",o.href=i,o.onload=r,o.onerror=n,document.head.appendChild(o)})),e?Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/components/icon.js"),import(e)]).then(([{Icon:i},{icons:r}])=>{if(typeof r!="object")throw new Error("Icon set must export icons object.");i.addIcons(r)}):Promise.resolve(),s?fetch(s).then(i=>i.json()).then(i=>{this.theme.locale.initLocale(i)}):Promise.resolve()]),this.onStylesLoaded()}catch(i){console.warn(i),this.events.publish({name:"wk:app:load-styles:error"})}}async initScripts(t){if(!(t!=null&&t.length)){this.events.publish({name:"wk:app:load-scripts:success"});return}try{await Promise.all(t.map(e=>import(e))),this.events.publish({name:"wk:app:load-scripts:success"})}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-scripts:error"})}}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let e=this.theme.getWishlistId(window.location.pathname);e&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:e})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUrlChangeEvents(){let t=history.replaceState,e=({productHandle:s,variantId:i})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:i}})};history.replaceState=(...s)=>{let i=`${window.location.protocol}//${window.location.host}`,r=typeof s[2]=="string"?new URL(s[2],i):s[2],n=t.apply(history,s);if(!r)return n;let o=this.theme.getProductHandle(r),l=r.searchParams.get("variant");if(!o||!l)return n;e({productHandle:o,variantId:parseInt(l)})}}parseConfig({config:t}){var e,s,i,r,n,o,l,c;return{customer:{id:t.customerId?t.customerId:null,email:(e=t.customerEmail)!=null?e:""},shop:{name:(s=t.shopName)!=null?s:"",domain:(i=t.shopDomain)!=null?i:"",permanentDomain:(r=t.shopPermanentDomain)!=null?r:"",moneyFormat:(n=t.shopMoneyFormat)!=null?n:"",moneyFormatWithCurrency:(o=t.shopMoneyFormatWithCurrency)!=null?o:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(l=t.apiHost)!=null?l:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(c=t.productFallbackImage)!=null?c:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081",metafields:!!t.productMetafields}}}parseSettings({settings:t}){var e,s,i,r,n,o,l,c,h,d,m,U,W,E,v,S,P,T,k,A,I,L,R,M,C,H,x;return{general:{appLoading:(s=(e=t==null?void 0:t.general)==null?void 0:e.appLoading)!=null?s:"LAZY",wishlistAccessMode:(r=(i=t==null?void 0:t.general)==null?void 0:i.wishlistAccessMode)!=null?r:"UNRESTRICTED",wishlistMode:(o=(n=t==null?void 0:t.general)==null?void 0:n.wishlistMode)!=null?o:"PRODUCT",wishlistPath:(c=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?c:"/apps/wishlist"},money:{withCurrency:(d=(h=t==null?void 0:t.money)==null?void 0:h.withCurrency)!=null?d:!1},integrations:{googleAnalytics:{enabled:(W=(U=(m=t.integrations)==null?void 0:m.googleAnalytics)==null?void 0:U.enabled)!=null?W:!1,tracker:(S=(v=(E=t.integrations)==null?void 0:E.googleAnalytics)==null?void 0:v.tracker)!=null?S:""},klaviyo:{enabled:(k=(T=(P=t.integrations)==null?void 0:P.klaviyo)==null?void 0:T.enabled)!=null?k:!1},metaPixel:{enabled:(L=(I=(A=t.integrations)==null?void 0:A.metaPixel)==null?void 0:I.enabled)!=null?L:!1},wishlistAnalytics:{enabled:(C=(M=(R=t.integrations)==null?void 0:R.metaPixel)==null?void 0:M.enabled)!=null?C:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4}},colorMap:(H=t.colorMap)!=null?H:{},collectionButtons:(x=t.collectionButtons)!=null?x:{}}}parseRoutes(){let t=this.config.routes.rootUrl;return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+this.settings.general.wishlistPath.split("/").filter(e=>!!e).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}},b=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{N as WishlistApp}; |
@@ -1,1 +0,1 @@ | ||
import{delayWhen as p,from as a,fromEvent as o,isObservable as u,map as f,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as b,switchMap as v,tap as c}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/controllers.js";var d=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new g(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),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 i,n,e;if(this.host.dataset.productHandle===((i=t.data)==null?void 0:i.productHandle)&&((n=t.data)!=null&&n.variantId)){let r=this.productInfo?this.productInfo.wishlistItemId:void 0,s=this.productInfo?this.productInfo.variantId:void 0;r&&!s&&this.app.updateWishlistItem({wishlistItemId:r,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){o(document,"wk:app:load-styles:success").pipe(b()).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:load:success",()=>{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(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var i;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(i=this.observer)==null||i.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([n,e])=>{let[r,s]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:r,selector:s,handler:e})});this.cleanupMethods.push(()=>i.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:n}){return o(this.host,t).pipe(c(e=>{this.eventPending&&e.preventDefault()}),l(()=>!this.eventPending),c(()=>{this.eventPending=!0}),f(e=>e.target instanceof HTMLElement?{event:e,target:n?e.target.closest(n):e.currentTarget}:{event:e,target:null}),l(({target:e})=>!!e),p(e=>this.app.hasSession?h(e):a(this.app.load())),v(({event:e,target:r})=>{let s=i.bind(this)(e,r);return u(s)?s:typeof(s==null?void 0:s.then)=="function"?a(s):h(s)})).subscribe(()=>{this.eventPending=!1})}};export{d as WishlistElementHeadless}; | ||
import{delayWhen as p,from as a,fromEvent as o,isObservable as u,map as f,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as b,switchMap as v,tap as c}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/controllers.js";var d=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new g(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),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 i,n,e;if(this.host.dataset.productHandle===((i=t.data)==null?void 0:i.productHandle)&&((n=t.data)!=null&&n.variantId)){let r=this.productInfo?this.productInfo.wishlistItemId:void 0,s=this.productInfo?this.productInfo.variantId:void 0;r&&!s&&this.app.updateWishlistItem({wishlistItemId:r,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){o(document,"wk:app:load-styles:success").pipe(b()).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:load:success",()=>{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(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var i;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(i=this.observer)==null||i.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([n,e])=>{let[r,s]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:r,selector:s,handler:e})});this.cleanupMethods.push(()=>i.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:n}){return o(this.host,t).pipe(c(e=>{this.eventPending&&e.preventDefault()}),l(()=>!this.eventPending),c(()=>{this.eventPending=!0}),f(e=>e.target instanceof HTMLElement?{event:e,target:n?e.target.closest(n):e.currentTarget}:{event:e,target:null}),l(({target:e})=>!!e),p(e=>this.app.hasSession?h(e):a(this.app.load())),v(({event:e,target:r})=>{let s=i.bind(this)(e,r);return u(s)?s:typeof(s==null?void 0:s.then)=="function"?a(s):h(s)})).subscribe(()=>{this.eventPending=!1})}};export{d as WishlistElementHeadless}; |
@@ -1,1 +0,1 @@ | ||
import{delayWhen as p,from as o,fromEvent as c,isObservable as f,map as b,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as g,switchMap as m,tap as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as y}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{unsafeHTML as u}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{WishlistStateController as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.10/controllers.js";var a=class extends y{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new v(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,s;if(this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((i=t.data)!=null&&i.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,r=this.productInfo?this.productInfo.variantId:void 0;n&&!r&&this.app.updateWishlistItem({wishlistItemId:n,changes:{variantId:(s=t.data)==null?void 0:s.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){c(document,"wk:app:load-styles:success").pipe(g()).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:load:success",()=>{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")?u(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 u(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)}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 c(this,t).pipe(d(s=>{this.eventPending&&s.preventDefault()}),l(()=>!this.eventPending),d(()=>{this.eventPending=!0}),b(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),l(({target:s})=>!!s),p(s=>this.app.hasSession?h(s):o(this.app.load())),m(({event:s,target:n})=>{let r=e.bind(this)(s,n);return f(r)?r:typeof(r==null?void 0:r.then)=="function"?o(r):h(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0},loadWithoutSession:{type:Boolean,attribute:"load-without-session"}};export{a as WishlistElement}; | ||
import{delayWhen as p,from as o,fromEvent as c,isObservable as f,map as b,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as g,switchMap as m,tap as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as y}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{unsafeHTML as u}from"https://cdn.jsdelivr.net/gh/lit/dist@2.7.4/all/lit-all.min.js";import{WishlistStateController as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.22.11/controllers.js";var a=class extends y{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.loadWithoutSession=!1;this.stateCtrl=new v(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,s;if(this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((i=t.data)!=null&&i.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,r=this.productInfo?this.productInfo.variantId:void 0;n&&!r&&this.app.updateWishlistItem({wishlistItemId:n,changes:{variantId:(s=t.data)==null?void 0:s.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){c(document,"wk:app:load-styles:success").pipe(g()).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:load:success",()=>{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")?u(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 u(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)}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 c(this,t).pipe(d(s=>{this.eventPending&&s.preventDefault()}),l(()=>!this.eventPending),d(()=>{this.eventPending=!0}),b(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),l(({target:s})=>!!s),p(s=>this.app.hasSession?h(s):o(this.app.load())),m(({event:s,target:n})=>{let r=e.bind(this)(s,n);return f(r)?r:typeof(r==null?void 0:r.then)=="function"?o(r):h(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0},loadWithoutSession:{type:Boolean,attribute:"load-without-session"}};export{a as WishlistElement}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
969791
1270