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
212
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.16.1 to 4.17.0

components/option-select.js

4

api.js

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

var K=Object.create;var U=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var z=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);var G=(n,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of B(i))!$.call(n,r)&&r!==e&&U(n,r,{get:()=>i[r],enumerable:!(t=V(i,r))||t.enumerable});return n};var J=(n,i,e)=>(e=n!=null?K(H(n)):{},G(i||!n||!n.__esModule?U(e,"default",{value:n,enumerable:!0}):e,n));var D=z((je,q)=>{"use strict";var se=function(){function n(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=ce(t),this._batchScheduleFn=he(t),this._cacheKeyFn=le(t),this._cacheMap=pe(t),this._batch=null}var i=n.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=ae(this),s=this._cacheMap,a=this._cacheKeyFn(t);if(s){var o=s.get(a);if(o){var h=r.cacheHits||(r.cacheHits=[]);return new Promise(function(c){h.push(function(){c(o)})})}}r.keys.push(t);var l=new Promise(function(c,I){r.callbacks.push({resolve:c,reject:I})});return s&&s.set(a,l),l},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=[],s=0;s<t.length;s++)r.push(this.load(t[s]).catch(function(a){return a}));return Promise.all(r)},i.clear=function(t){var r=this._cacheMap;if(r){var s=this._cacheKeyFn(t);r.delete(s)}return this},i.clearAll=function(){var t=this._cacheMap;return t&&t.clear(),this},i.prime=function(t,r){var s=this._cacheMap;if(s){var a=this._cacheKeyFn(t);if(s.get(a)===void 0){var o;r instanceof Error?(o=Promise.reject(r),o.catch(function(){})):o=Promise.resolve(r),s.set(a,o)}}return this},n}(),ne=typeof process=="object"&&typeof process.nextTick=="function"?function(n){v||(v=Promise.resolve()),v.then(function(){process.nextTick(n)})}:typeof setImmediate=="function"?function(n){setImmediate(n)}:function(n){setTimeout(n)},v;function ae(n){var i=n._batch;if(i!==null&&!i.hasDispatched&&i.keys.length<n._maxBatchSize&&(!i.cacheHits||i.cacheHits.length<n._maxBatchSize))return i;var e={hasDispatched:!1,keys:[],callbacks:[]};return n._batch=e,n._batchScheduleFn(function(){oe(n,e)}),e}function oe(n,i){if(i.hasDispatched=!0,i.keys.length===0){S(i);return}var e=n._batchLoadFn(i.keys);if(!e||typeof e.then!="function")return C(n,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 K=Object.create;var M=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var G=(s,i)=>()=>(i||s((i={exports:{}}).exports,i),i.exports);var J=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of H(i))!z.call(s,r)&&r!==e&&M(s,r,{get:()=>i[r],enumerable:!(t=B(i,r))||t.enumerable});return s};var Q=(s,i,e)=>(e=s!=null?K($(s)):{},J(i||!s||!s.__esModule?M(e,"default",{value:s,enumerable:!0}):e,s));var j=G((De,C)=>{"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=pe(t),this._batchScheduleFn=de(t),this._cacheKeyFn=ue(t),this._cacheMap=me(t),this._batch=null}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 h=r.cacheHits||(r.cacheHits=[]);return new Promise(function(c){h.push(function(){c(o)})})}}r.keys.push(t);var l=new Promise(function(c,w){r.callbacks.push({resolve:c,reject:w})});return n&&n.set(a,l),l},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&&(!i.cacheHits||i.cacheHits.length<s._maxBatchSize))return i;var e={hasDispatched:!1,keys:[],callbacks:[]};return s._batch=e,s._batchScheduleFn(function(){le(s,e)}),e}function le(s,i){if(i.hasDispatched=!0,i.keys.length===0){P(i);return}var e=s._batchLoadFn(i.keys);if(!e||typeof e.then!="function")return F(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)));S(i);for(var r=0;r<i.callbacks.length;r++){var s=t[r];s instanceof Error?i.callbacks[r].reject(s):i.callbacks[r].resolve(s)}}).catch(function(t){C(n,i,t)})}function C(n,i,e){S(i);for(var t=0;t<i.keys.length;t++)n.clear(i.keys[t]),i.callbacks[t].reject(e)}function S(n){if(n.cacheHits)for(var i=0;i<n.cacheHits.length;i++)n.cacheHits[i]()}function ce(n){var i=!n||n.batch!==!1;if(!i)return 1;var e=n&&n.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 he(n){var i=n&&n.batchScheduleFn;if(i===void 0)return ne;if(typeof i!="function")throw new TypeError("batchScheduleFn must be a function: "+i);return i}function le(n){var i=n&&n.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 pe(n){var i=!n||n.cache!==!1;if(!i)return null;var e=n&&n.cacheMap;if(e===void 0)return new Map;if(e!==null){var t=["get","set","delete","clear"],r=t.filter(function(s){return e&&typeof e[s]!="function"});if(r.length!==0)throw new TypeError("Custom cacheMap missing methods: "+r.join(", "))}return e}function O(n){return typeof n=="object"&&n!==null&&typeof n.length=="number"&&(n.length===0||n.length>0&&Object.prototype.hasOwnProperty.call(n,n.length-1))}q.exports=se});import{of as R}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var{ga:u}=window,m=class{constructor({tracker:i}){this.tracker=i||"t0",this.eventNames=new Map([["addToWishlist","WK Added Product"],["removeFromWishlist","WK Removed Product"],["addToCart","WK Added to Cart"],["shareWishlist","WK Shared Wishlist"],["clearWishlist","WK Cleared Wishlist"]])}track({eventName:i,product:e,variant:t,quantity:r=1}){var a;let s=this.eventNames.get(i);return!s||!(u!=null&&u.loaded)||!e?R(!1):(u(`${this.tracker}.ec:addProduct`,{id:(a=(t==null?void 0:t.sku)||(t==null?void 0:t.id))!=null?a:e.id,name:e.title,category:e.type,brand:e.vendor,variant:t==null?void 0:t.title,quantity:r}),u(`${this.tracker}.send`,{eventAction:s,hitType:"event",eventCategory:"Wishlist",eventLabel:"Wishlist King"}),R(!0))}};import{of as F}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var f=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:s=1}){let a=this.eventNames.get(i);return!a||!e||!t?F(!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:s,WishlistUrl:this.urlUtil.getPublicWishlistUrl(e.id)}]),F(!0))}};import{of as N}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var{fbq:j}=window,g=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 j!="function"||!e?N(!1):(j("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(s=>!!s).join(" - "),content_category:e.type,content_type:"product_group",num_items:1}),N(!0))}};import{catchError as Q,map as X,of as _}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{fromFetch as Y}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/fetch/+esm";var d=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:s,source:a}){var h,l,c;if(!this.sessionId)return _(!1);let o=this.eventNames.get(i);return!o||!e?_(!1):Y(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":(h=this.sessionId)!=null?h:"","x-appmate-cid":(c=(l=this.customerId)==null?void 0:l.toString())!=null?c:""},body:JSON.stringify({event:o,wid:e.publicId,pid:t==null?void 0:t.id,vid:r==null?void 0:r.id,qty:s,src:a})}).pipe(X(()=>!0),Q(()=>_(!1)))}getQuerystring(i){if(!i)return"";let e=new URLSearchParams;return Object.entries(i).forEach(([t,r])=>{Array.isArray(r)?r.forEach(s=>e.append(t,s)):r&&e.append(t,r)}),"?"+e.toString()}};import{fromFetch as Z}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/fetch/+esm";import{switchMap as ee}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var p=class{constructor(i){this.host=i.host,this.headers={"content-type":"application/json"}}fetch({path:i,method:e="GET",query:t,body:r,headers:s={}}){return Z(this.host+i+this.getQuerystring(t),{method:e,headers:{...this.headers,...s},body:r}).pipe(ee(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(s=>e.append(t,s)):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})}};var T=class extends p{loadProduct({productHandle:i}){return this.get({path:`/products/${i}.js`})}addToCart(i){return this.post({path:"/cart/add.js",body:i})}};import{forkJoin as te,lastValueFrom as ie,of as re}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var P=class{constructor({settings:i,events:e,notifyHost:t,utils:r,theme:s,shop:a,sessionId:o,customerId:h}){this.utils=r,this.theme=s,this.services=[],i.integrations.wishlistAnalytics.enabled&&this.services.push(new d({host:t,shop:a,customerId:h,sessionId:o})),i.integrations.klaviyo.enabled&&this.services.push(new f({urlUtil:this.utils.url,moneyUtil:this.utils.money})),i.integrations.metaPixel.enabled&&this.services.push(new g({currency:window.Shopify.currency.active})),i.integrations.googleAnalytics.enabled&&this.services.push(new m({tracker:i.integrations.googleAnalytics.tracker}));let l=this.theme.getPageType(),c=I=>y=>{var x,E,M,L;return ie(this.track({eventName:I,source:l,wishlist:(x=y.data)==null?void 0:x.wishlist,product:(E=y.data)==null?void 0:E.product,variant:(M=y.data)==null?void 0:M.variant,quantity:(L=y.data)==null?void 0:L.quantity}))};e.subscribeMany({"wk:wishlist:add-to-cart:success":c("addToCart"),"wk:wishlist:add:success":c("addToWishlist"),"wk:wishlist:change-variant:success":c("changeVariant"),"wk:wishlist:clear:success":c("clearWishlist"),"wk:wishlist:remove:success":c("removeFromWishlist"),"wk:wishlist:share:success":c("shareWishlist"),"wk:wishlist:page-view":c("viewWishlist")})}track(i){return this.services.length?te(this.services.map(e=>e.track(i))):re([])}setSessionId(i){let e=this.services.find(t=>t instanceof d);e&&e.setSessionId(i)}};var w=J(D());import{defer as k,from as W,lastValueFrom as b,shareReplay as de,switchMap as ue,tap as me}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var A=class extends p{constructor(e){var t,r,s,a;super(e);this.headers={"content-type":"application/json","x-appmate-shp":e.shop,"x-appmate-sid":(t=e.sessionId)!=null?t:"","x-appmate-cid":(s=(r=e.customerId)==null?void 0:r.toString())!=null?s:"","x-appmate-src":(a=e.trackingSource)!=null?a:""},this.wishlistLoader=this.createWishlistLoader(),this.productInfoLoader=this.createProductInfoLoader(),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 w.default(async e=>{let t=e.map(s=>s.split("-")).reduce((s,[a,o])=>(s[a]||(s[a]=[]),s[a].push(o),s),{}),r=await Promise.all(Object.entries(t).map(([s,a])=>b(this.get({path:`/wishlists/${s}`,query:{format:a.includes("all")?"all":"minimal"}})))).then(s=>s.map(a=>a.wishlist));return e.map((s,a)=>{var h;let[o]=s.split("-");return(h=r.find(l=>o==="mine"?l.isMine:l.publicId===o))!=null?h:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}createProductInfoLoader(){return new w.default(async e=>{let{productInfo:t}=await b(this.get({path:"/wishlists/mine/product-info",headers:{"x-appmate-ids":e.join(",")}}));return e.map(r=>{var s;return(s=t.find(a=>a.productId===r))!=null?s:{productId:r,wishlistItems:[]}})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}createWishlistItemLoader(){return new w.default(async e=>{let t=e.map(s=>s.split("-")).reduce((s,[a,o])=>(s[a]||(s[a]=[]),s[a].push(o),s),{}),r=await Promise.all(Object.entries(t).map(([s,a])=>b(this.get({path:`/wishlists/${s}/items`,headers:{"x-appmate-ids":a.join(",")}})))).then(s=>s.flatMap(a=>a.items));return e.map(s=>{var o;let[,a]=s.split("-");return(o=r.find(h=>h.id===a))!=null?o:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:e=>setTimeout(e,250)})}loadWishlist({wishlistId:e,format:t}){return W(k(()=>this.wishlistLoader.load([e,t].join("-")).then(r=>({wishlist:r}))))}loadProductInfo({productId:e}){return W(k(()=>this.productInfoLoader.load(e).then(t=>({productInfo:t}))))}loadWishlistItem({wishlistId:e,wishlistItemId:t}){return W(k(()=>this.wishlistItemLoader.load([e,t].join("-")).then(r=>({wishlistItem:r}))))}loadWishlistItems({wishlistId:e,wishlistItemIds:t}){return b(this.get({path:`/wishlists/${e}/items`,headers:{"x-appmate-ids":t.join(",")}}))}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(ue(()=>this.addItem({productId:e,variantId:t})));let r=this.post({path:"/wishlists/mine/items",body:{productId:e,variantId:t}}).pipe(me(s=>{s.sessionId&&(this.setSessionId(s.sessionId),this._pendingSessionId=void 0)}),de());return this.hasSession||(this._pendingSessionId=r),r}updateItem({wishlistItemId:e,changes:t}){return this.put({path:"/wishlists/mine/items",body:{changes:{...t,wishlistItemId:e}}})}removeItem({wishlistId:e,wishlistItemId:t}){return this.delete({path:`/wishlists/${e}/items`,body:{wishlistItemId:t}})}clearWishlist(){return this.delete({path:"/wishlists/mine"})}};export{m as GoogleAnalytics,f as KlaviyoTracking,g as MetaPixel,d as NotifyApi,p as RestApi,T as ShopifyApi,P as TrackingApi,A as WishlistApi};
`+String(t)));P(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){F(s,i,t)})}function F(s,i,e){P(i);for(var t=0;t<i.keys.length;t++)s.clear(i.keys[t]),i.callbacks[t].reject(e)}function P(s){if(s.cacheHits)for(var i=0;i<s.cacheHits.length;i++)s.cacheHits[i]()}function pe(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 de(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 ue(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 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))}C.exports=oe});import{of as U}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var{ga:u}=window,m=class{constructor({tracker:i}){this.tracker=i||"t0",this.eventNames=new Map([["addToWishlist","WK Added Product"],["removeFromWishlist","WK Removed Product"],["addToCart","WK Added to Cart"],["shareWishlist","WK Shared Wishlist"],["clearWishlist","WK Cleared Wishlist"]])}track({eventName:i,product:e,variant:t,quantity:r=1}){var a;let n=this.eventNames.get(i);return!n||!(u!=null&&u.loaded)||!e?U(!1):(u(`${this.tracker}.ec:addProduct`,{id:(a=(t==null?void 0:t.sku)||(t==null?void 0:t.id))!=null?a:e.id,name:e.title,category:e.type,brand:e.vendor,variant:t==null?void 0:t.title,quantity:r}),u(`${this.tracker}.send`,{eventAction:n,hitType:"event",eventCategory:"Wishlist",eventLabel:"Wishlist King"}),U(!0))}};import{of as R}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var f=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?R(!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)}]),R(!0))}};import{of as L}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var{fbq:N}=window,g=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 N!="function"||!e?L(!1):(N("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,map as Y,of as _}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{fromFetch as Z}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/fetch/+esm";var d=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 h,l;if(!this.sessionId)return _(!1);let o=this.eventNames.get(i);return!o||!e?_(!1):Z(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":(h=this.sessionId)!=null?h:"","x-appmate-cid":(l=this.customerId)!=null?l:""},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(Y(()=>!0),X(()=>_(!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{fromFetch as ee}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/fetch/+esm";import{switchMap as te}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var p=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(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.5.7/+esm";var T=class extends p{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.5.7/+esm";var v=class{constructor({settings:i,events:e,notifyHost:t,utils:r,theme:n,shop:a,sessionId:o,customerId:h}){this.utils=r,this.theme=n,this.services=[],i.integrations.wishlistAnalytics.enabled&&this.services.push(new d({host:t,shop:a,customerId:h,sessionId:o})),i.integrations.klaviyo.enabled&&this.services.push(new f({urlUtil:this.utils.url,moneyUtil:this.utils.money})),i.integrations.metaPixel.enabled&&this.services.push(new g({currency:window.Shopify.currency.active})),i.integrations.googleAnalytics.enabled&&this.services.push(new m({tracker:i.integrations.googleAnalytics.tracker}));let l=this.theme.getPageType(),c=w=>y=>{var W,A,x,E;return ne(this.track({eventName:w,source:l,wishlist:(W=y.data)==null?void 0:W.wishlist,product:(A=y.data)==null?void 0:A.product,variant:(x=y.data)==null?void 0:x.variant,quantity:(E=y.data)==null?void 0:E.quantity}))};e.subscribeMany({"wk:wishlist:add-to-cart:success":c("addToCart"),"wk:wishlist:add:success":c("addToWishlist"),"wk:wishlist:change-variant:success":c("changeVariant"),"wk:wishlist:clear:success":c("clearWishlist"),"wk:wishlist:remove:success":c("removeFromWishlist"),"wk:wishlist:share:success":c("shareWishlist"),"wk:wishlist:page-view":c("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 d);e&&e.setSessionId(i)}};var k=Q(j());import{defer as q,from as D,lastValueFrom as V,shareReplay as b,switchMap as fe,tap as ge}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var S=class extends p{constructor(e){super(e);this.headers={"content-type":"application/json"},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.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 k.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 k.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(",")}})))).then(n=>n.flatMap(a=>a.items));return e.map(n=>{var o;let[,a]=n.split("-");return(o=r.find(h=>h.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(fe(()=>this.addItem({productId:e,variantId:t})));let r=this.post({path:"/wishlists/mine/items",body:{productId:e,variantId:t}}).pipe(ge(n=>{n.sessionId&&(this.setSessionId(n.sessionId),this._pendingSessionId=void 0)}),b());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(b())}removeItem({wishlistId:e,wishlistItemId:t}){return this.delete({path:`/wishlists/${e}/items`,body:{wishlistItemId:t}}).pipe(b())}clearWishlist(){return this.delete({path:"/wishlists/mine"}).pipe(b())}};export{m as GoogleAnalytics,f as KlaviyoTracking,g as MetaPixel,d as NotifyApi,p as RestApi,T as ShopifyApi,v as TrackingApi,S as WishlistApi};

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

var f=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var n=(p,s,o,l)=>{for(var t=l>1?void 0:l?m(s,o):s,i=p.length-1,r;i>=0;i--)(r=p[i])&&(t=(l?r(s,o,t):r(t))||t);return l&&t&&f(s,o,t),t};import{LitElement as y}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as g,property as a}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as c}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/controllers.js";var e=class extends y{constructor(){super(...arguments);this.text="";this.layout="text-only";this.parentheses=!1;this.floatingUi=new u(this)}updated(o){o.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var t,i,r;let o={"wk-badge":!0,"wk-parentheses":!!this.parentheses,"wk-pill":(i=(t=this.layout)==null?void 0:t.includes("pill"))!=null?i:!1},l=(r=this.layout)!=null&&r.includes("text")?this.text:"";return h`<span class=${c(o)}>${l}</span>`}createRenderRoot(){return this}};n([a({type:String})],e.prototype,"text",2),n([a({type:String})],e.prototype,"layout",2),n([a({type:Boolean})],e.prototype,"parentheses",2),n([a({type:Object})],e.prototype,"floating",2),e=n([g("wk-badge")],e);export{e as Badge};
var f=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var n=(p,s,o,l)=>{for(var t=l>1?void 0:l?m(s,o):s,i=p.length-1,r;i>=0;i--)(r=p[i])&&(t=(l?r(s,o,t):r(t))||t);return l&&t&&f(s,o,t),t};import{LitElement as y}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as g,property as a}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as c}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";var e=class extends y{constructor(){super(...arguments);this.text="";this.layout="text-only";this.parentheses=!1;this.floatingUi=new u(this)}updated(o){o.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var t,i,r;let o={"wk-badge":!0,"wk-parentheses":!!this.parentheses,"wk-pill":(i=(t=this.layout)==null?void 0:t.includes("pill"))!=null?i:!1},l=(r=this.layout)!=null&&r.includes("text")?this.text:"";return h`<span class=${c(o)}>${l}</span>`}createRenderRoot(){return this}};n([a({type:String})],e.prototype,"text",2),n([a({type:String})],e.prototype,"layout",2),n([a({type:Boolean})],e.prototype,"parentheses",2),n([a({type:Object})],e.prototype,"floating",2),e=n([g("wk-badge")],e);export{e as Badge};

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

var b=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=(o,i,e,n)=>{for(var l=n>1?void 0:n?c(i,e):i,s=o.length-1,g;s>=0;s--)(g=o[s])&&(l=(n?g(i,e,l):g(l))||l);return n&&l&&b(i,e,l),l};import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as x,property as r}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as d}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as u}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";var f=Number.isNaN||function(i){return typeof i=="number"&&i!==i};function p(o,i){return!!(o===i||f(o)&&f(i))}function y(o,i){if(o.length!==i.length)return!1;for(var e=0;e<o.length;e++)if(!p(o[e],i[e]))return!1;return!0}function h(o,i){i===void 0&&(i=y);var e=null;function n(){for(var l=[],s=0;s<arguments.length;s++)l[s]=arguments[s];if(e&&e.lastThis===this&&i(l,e.lastArgs))return e.lastResult;var g=o.apply(this,l);return e={lastResult:g,lastArgs:l,lastThis:this},g}return n.clear=function(){e=null},n}import{FloatingUiController as $}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/components/icon.js";var t=class extends m{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.layout="icon-and-text";this.outline=!1;this.fullWidth=!1;this.alignment="center";this.badgeParentheses=!1;this.badgeHidden=!1;this.badgeHiddenIfEmpty=!1;this.floatingUi=new $(this);this.getBadgeFloating=h((e,n)=>{if(!(!e||!n))return{...e,reference:n}})}updated(e){e.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var l,s,g;let e=(l=this.alignment)!=null?l:"center",n={"wk-button":!0,"wk-selected":!!this.selected,"wk-outline":!!this.outline,"wk-full-width":!!this.fullWidth,[`wk-align-${e}`]:!0};return this.href?d`
var b=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=(o,i,e,n)=>{for(var l=n>1?void 0:n?c(i,e):i,s=o.length-1,g;s>=0;s--)(g=o[s])&&(l=(n?g(i,e,l):g(l))||l);return n&&l&&b(i,e,l),l};import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as x,property as r}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as d}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as u}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";var f=Number.isNaN||function(i){return typeof i=="number"&&i!==i};function p(o,i){return!!(o===i||f(o)&&f(i))}function y(o,i){if(o.length!==i.length)return!1;for(var e=0;e<o.length;e++)if(!p(o[e],i[e]))return!1;return!0}function h(o,i){i===void 0&&(i=y);var e=null;function n(){for(var l=[],s=0;s<arguments.length;s++)l[s]=arguments[s];if(e&&e.lastThis===this&&i(l,e.lastArgs))return e.lastResult;var g=o.apply(this,l);return e={lastResult:g,lastArgs:l,lastThis:this},g}return n.clear=function(){e=null},n}import{FloatingUiController as $}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/components/icon.js";var t=class extends m{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.layout="icon-and-text";this.outline=!1;this.fullWidth=!1;this.alignment="center";this.badgeParentheses=!1;this.badgeHidden=!1;this.badgeHiddenIfEmpty=!1;this.floatingUi=new $(this);this.getBadgeFloating=h((e,n)=>{if(!(!e||!n))return{...e,reference:n}})}updated(e){e.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var l,s,g;let e=(l=this.alignment)!=null?l:"center",n={"wk-button":!0,"wk-selected":!!this.selected,"wk-outline":!!this.outline,"wk-full-width":!!this.fullWidth,[`wk-align-${e}`]:!0};return this.href?d`
<a

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

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

var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var r=(a,n,t,i)=>{for(var o=i>1?void 0:i?c(n,t):n,s=a.length-1,d;s>=0;s--)(d=a[s])&&(o=(i?d(n,t,o):d(o))||o);return i&&o&&p(n,t,o),o};import{LitElement as f,css as u}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as w,state as m,property as l}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as v}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as x}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/controllers.js";var e=class extends f{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new x(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}updated(t){t.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var i;let t={"wk-popover":!0,"wk-show":this.transition==="show","wk-hide":this.transition==="hide"};return this.elementClass&&(t[this.elementClass]=!0),v`
var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var r=(a,n,t,i)=>{for(var o=i>1?void 0:i?c(n,t):n,s=a.length-1,d;s>=0;s--)(d=a[s])&&(o=(i?d(n,t,o):d(o))||o);return i&&o&&p(n,t,o),o};import{LitElement as f,css as u}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as w,state as m,property as l}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as v}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as x}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";var e=class extends f{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new x(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}updated(t){t.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var i;let t={"wk-popover":!0,"wk-show":this.transition==="show","wk-hide":this.transition==="hide"};return this.elementClass&&(t[this.elementClass]=!0),v`
<div class=${g(t)}>

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

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

var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var o=(r,n,t,s)=>{for(var e=s>1?void 0:s?m(n,t):n,l=r.length-1,a;l>=0;l--)(a=r[l])&&(e=(s?a(n,t,e):a(e))||e);return s&&e&&p(n,t,e),e};import{LitElement as d}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{html as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{customElement as f,property as c}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{Swatch as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/components/swatch.js";var i=class extends d{constructor(){super();this.label="";this.name="";this.options=[]}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof g&&this.options.push(t);this.innerHTML=""}render(){let t=b({"wk-swatches":!0,"wk-single-option":this.options.length===1});return h`
var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var o=(r,n,t,s)=>{for(var e=s>1?void 0:s?m(n,t):n,l=r.length-1,a;l>=0;l--)(a=r[l])&&(e=(s?a(n,t,e):a(e))||e);return s&&e&&p(n,t,e),e};import{LitElement as d}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{html as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{customElement as f,property as c}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{Swatch as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/components/swatch.js";var i=class extends d{constructor(){super();this.label="";this.name="";this.options=[]}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof g&&this.options.push(t);this.innerHTML=""}render(){let t=b({"wk-swatches":!0,"wk-single-option":this.options.length===1});return h`
<div class=${t}>

@@ -3,0 +3,0 @@ <fieldset class="wk-fieldset">

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

function V(t){return t.split("-")[0]}function j(t){return t.split("-")[1]}function _(t){return["top","bottom"].includes(V(t))?"x":"y"}function J(t){return t==="y"?"height":"width"}function lt(t,e,i){let{reference:n,floating:o}=t,a=n.x+n.width/2-o.width/2,r=n.y+n.height/2-o.height/2,s=_(e),l=J(s),f=n[l]/2-o[l]/2,h=s==="x",c;switch(V(e)){case"top":c={x:a,y:n.y-o.height};break;case"bottom":c={x:a,y:n.y+n.height};break;case"right":c={x:n.x+n.width,y:r};break;case"left":c={x:n.x-o.width,y:r};break;default:c={x:n.x,y:n.y}}switch(j(e)){case"start":c[s]-=f*(i&&h?-1:1);break;case"end":c[s]+=f*(i&&h?-1:1)}return c}var ft=async(t,e,i)=>{let{placement:n="bottom",strategy:o="absolute",middleware:a=[],platform:r}=i,s=await(r.isRTL==null?void 0:r.isRTL(e)),l=await r.getElementRects({reference:t,floating:e,strategy:o}),{x:f,y:h}=lt(l,n,s),c=n,p={},d=0;for(let u=0;u<a.length;u++){let{name:m,fn:g}=a[u],{x:y,y:v,data:b,reset:w}=await g({x:f,y:h,initialPlacement:n,placement:c,strategy:o,middlewareData:p,rects:l,platform:r,elements:{reference:t,floating:e}});f=y!=null?y:f,h=v!=null?v:h,p={...p,[m]:{...p[m],...b}},w&&d<=50&&(d++,typeof w=="object"&&(w.placement&&(c=w.placement),w.rects&&(l=w.rects===!0?await r.getElementRects({reference:t,floating:e,strategy:o}):w.rects),{x:f,y:h}=lt(l,c,s)),u=-1)}return{x:f,y:h,placement:c,strategy:o,middlewareData:p}};function ht(t){return typeof t!="number"?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(t):{top:t,right:t,bottom:t,left:t}}function H(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function Q(t,e){var i;e===void 0&&(e={});let{x:n,y:o,platform:a,rects:r,elements:s,strategy:l}=t,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:c="floating",altBoundary:p=!1,padding:d=0}=e,u=ht(d),m=s[p?c==="floating"?"reference":"floating":c],g=H(await a.getClippingRect({element:(i=await(a.isElement==null?void 0:a.isElement(m)))==null||i?m:m.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:f,rootBoundary:h,strategy:l})),y=H(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({rect:c==="floating"?{...r.floating,x:n,y:o}:r.reference,offsetParent:await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),strategy:l}):r[c]);return{top:g.top-y.top+u.top,bottom:y.bottom-g.bottom+u.bottom,left:g.left-y.left+u.left,right:y.right-g.right+u.right}}var St=Math.min,Et=Math.max;function Y(t,e,i){return Et(t,St(e,i))}var G=t=>({name:"arrow",options:t,async fn(e){let{element:i,padding:n=0}=t!=null?t:{},{x:o,y:a,placement:r,rects:s,platform:l}=e;if(i==null)return{};let f=ht(n),h={x:o,y:a},c=_(r),p=j(r),d=J(c),u=await l.getDimensions(i),m=c==="y"?"top":"left",g=c==="y"?"bottom":"right",y=s.reference[d]+s.reference[c]-h[c]-s.floating[d],v=h[c]-s.reference[c],b=await(l.getOffsetParent==null?void 0:l.getOffsetParent(i)),w=b?c==="y"?b.clientHeight||0:b.clientWidth||0:0;w===0&&(w=s.floating[d]);let q=y/2-v/2,W=f[m],T=w-u[d]-f[g],x=w/2-u[d]/2+q,I=Y(W,x,T),L=(p==="start"?f[m]:f[g])>0&&x!==I&&s.reference[d]<=s.floating[d];return{[c]:h[c]-(L?x<W?W-x:T-x:0),data:{[c]:I,centerOffset:x-I}}}}),Pt={left:"right",right:"left",bottom:"top",top:"bottom"};function U(t){return t.replace(/left|right|bottom|top/g,e=>Pt[e])}function At(t,e,i){i===void 0&&(i=!1);let n=j(t),o=_(t),a=J(o),r=o==="x"?n===(i?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(r=U(r)),{main:r,cross:U(r)}}var Ot={start:"end",end:"start"};function ct(t){return t.replace(/start|end/g,e=>Ot[e])}var Wt=["top","right","bottom","left"],kt=Wt.reduce((t,e)=>t.concat(e,e+"-start",e+"-end"),[]);var Z=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i;let{placement:n,middlewareData:o,rects:a,initialPlacement:r,platform:s,elements:l}=e,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:c,fallbackStrategy:p="bestFit",flipAlignment:d=!0,...u}=t,m=V(n),g=c||(m===r||!d?[U(r)]:function(x){let I=U(x);return[ct(x),I,ct(I)]}(r)),y=[r,...g],v=await Q(e,u),b=[],w=((i=o.flip)==null?void 0:i.overflows)||[];if(f&&b.push(v[m]),h){let{main:x,cross:I}=At(n,a,await(s.isRTL==null?void 0:s.isRTL(l.floating)));b.push(v[x],v[I])}if(w=[...w,{placement:n,overflows:b}],!b.every(x=>x<=0)){var q,W;let x=((q=(W=o.flip)==null?void 0:W.index)!=null?q:0)+1,I=y[x];if(I)return{data:{index:x,overflows:w},reset:{placement:I}};let L="bottom";switch(p){case"bestFit":{var T;let at=(T=w.map(N=>[N,N.overflows.filter(F=>F>0).reduce((F,Ct)=>F+Ct,0)]).sort((N,F)=>N[1]-F[1])[0])==null?void 0:T[0].placement;at&&(L=at);break}case"initialPlacement":L=r}if(n!==L)return{reset:{placement:L}}}return{}}}};var B=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:i,y:n}=e,o=await async function(a,r){let{placement:s,platform:l,elements:f}=a,h=await(l.isRTL==null?void 0:l.isRTL(f.floating)),c=V(s),p=j(s),d=_(s)==="x",u=["left","top"].includes(c)?-1:1,m=h&&d?-1:1,g=typeof r=="function"?r(a):r,{mainAxis:y,crossAxis:v,alignmentAxis:b}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...g};return p&&typeof b=="number"&&(v=p==="end"?-1*b:b),d?{x:v*m,y:y*u}:{x:y*u,y:v*m}}(e,t);return{x:i+o.x,y:n+o.y,data:o}}}};function Lt(t){return t==="x"?"y":"x"}var tt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:i,y:n,placement:o}=e,{mainAxis:a=!0,crossAxis:r=!1,limiter:s={fn:g=>{let{x:y,y:v}=g;return{x:y,y:v}}},...l}=t,f={x:i,y:n},h=await Q(e,l),c=_(V(o)),p=Lt(c),d=f[c],u=f[p];if(a){let g=c==="y"?"bottom":"right";d=Y(d+h[c==="y"?"top":"left"],d,d-h[g])}if(r){let g=p==="y"?"bottom":"right";u=Y(u+h[p==="y"?"top":"left"],u,u-h[g])}let m=s.fn({...e,[c]:d,[p]:u});return{...m,data:{x:m.x-i,y:m.y-n}}}}};function wt(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function E(t){if(t==null)return window;if(!wt(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function A(t){return E(t).getComputedStyle(t)}function O(t){return wt(t)?"":t?(t.nodeName||"").toLowerCase():""}function yt(){let t=navigator.userAgentData;return t!=null&&t.brands?t.brands.map(e=>e.brand+"/"+e.version).join(" "):navigator.userAgent}function R(t){return t instanceof E(t).HTMLElement}function C(t){return t instanceof E(t).Element}function k(t){return typeof ShadowRoot=="undefined"?!1:t instanceof E(t).ShadowRoot||t instanceof ShadowRoot}function M(t){let{overflow:e,overflowX:i,overflowY:n,display:o}=A(t);return/auto|scroll|overlay|hidden/.test(e+n+i)&&!["inline","contents"].includes(o)}function Tt(t){return["table","td","th"].includes(O(t))}function dt(t){let e=/firefox/i.test(yt()),i=A(t);return i.transform!=="none"||i.perspective!=="none"||e&&i.willChange==="filter"||e&&!!i.filter&&i.filter!=="none"||["transform","perspective"].some(n=>i.willChange.includes(n))||["paint","layout","strict","content"].some(n=>{let o=i.contain;return o!=null&&o.includes(n)})}function xt(){return!/^((?!chrome|android).)*safari/i.test(yt())}function it(t){return["html","body","#document"].includes(O(t))}var ut=Math.min,D=Math.max,$=Math.round;function S(t,e,i){var n,o,a,r;e===void 0&&(e=!1),i===void 0&&(i=!1);let s=t.getBoundingClientRect(),l=1,f=1;e&&R(t)&&(l=t.offsetWidth>0&&$(s.width)/t.offsetWidth||1,f=t.offsetHeight>0&&$(s.height)/t.offsetHeight||1);let h=C(t)?E(t):window,c=!xt()&&i,p=(s.left+(c&&(n=(o=h.visualViewport)==null?void 0:o.offsetLeft)!=null?n:0))/l,d=(s.top+(c&&(a=(r=h.visualViewport)==null?void 0:r.offsetTop)!=null?a:0))/f,u=s.width/l,m=s.height/f;return{width:u,height:m,top:d,right:p+u,bottom:d+m,left:p,x:p,y:d}}function P(t){return(e=t,(e instanceof E(e).Node?t.ownerDocument:t.document)||window.document).documentElement;var e}function K(t){return C(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function vt(t){return S(P(t)).left+K(t).scrollLeft}function Ft(t,e,i){let n=R(e),o=P(e),a=S(t,n&&function(l){let f=S(l);return $(f.width)!==l.offsetWidth||$(f.height)!==l.offsetHeight}(e),i==="fixed"),r={scrollLeft:0,scrollTop:0},s={x:0,y:0};if(n||!n&&i!=="fixed")if((O(e)!=="body"||M(o))&&(r=K(e)),R(e)){let l=S(e,!0);s.x=l.x+e.clientLeft,s.y=l.y+e.clientTop}else o&&(s.x=vt(o));return{x:a.left+r.scrollLeft-s.x,y:a.top+r.scrollTop-s.y,width:a.width,height:a.height}}function nt(t){return O(t)==="html"?t:t.assignedSlot||t.parentNode||(k(t)?t.host:null)||P(t)}function pt(t){return R(t)&&A(t).position!=="fixed"?t.offsetParent:null}function et(t){let e=E(t),i=pt(t);for(;i&&Tt(i)&&A(i).position==="static";)i=pt(i);return i&&(O(i)==="html"||O(i)==="body"&&A(i).position==="static"&&!dt(i))?e:i||function(n){let o=nt(n);for(k(o)&&(o=o.host);R(o)&&!it(o);){if(dt(o))return o;{let a=o.parentNode;o=k(a)?a.host:a}}return null}(t)||e}function mt(t){if(R(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=S(t);return{width:e.width,height:e.height}}function bt(t){let e=nt(t);return it(e)?t.ownerDocument.body:R(e)&&M(e)?e:bt(e)}function z(t,e){var i;e===void 0&&(e=[]);let n=bt(t),o=n===((i=t.ownerDocument)==null?void 0:i.body),a=E(n),r=o?[a].concat(a.visualViewport||[],M(n)?n:[]):n,s=e.concat(r);return o?s:s.concat(z(r))}function gt(t,e,i){return e==="viewport"?H(function(n,o){let a=E(n),r=P(n),s=a.visualViewport,l=r.clientWidth,f=r.clientHeight,h=0,c=0;if(s){l=s.width,f=s.height;let p=xt();(p||!p&&o==="fixed")&&(h=s.offsetLeft,c=s.offsetTop)}return{width:l,height:f,x:h,y:c}}(t,i)):C(e)?function(n,o){let a=S(n,!1,o==="fixed"),r=a.top+n.clientTop,s=a.left+n.clientLeft;return{top:r,left:s,x:s,y:r,right:s+n.clientWidth,bottom:r+n.clientHeight,width:n.clientWidth,height:n.clientHeight}}(e,i):H(function(n){var o;let a=P(n),r=K(n),s=(o=n.ownerDocument)==null?void 0:o.body,l=D(a.scrollWidth,a.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),f=D(a.scrollHeight,a.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),h=-r.scrollLeft+vt(n),c=-r.scrollTop;return A(s||a).direction==="rtl"&&(h+=D(a.clientWidth,s?s.clientWidth:0)-l),{width:l,height:f,x:h,y:c}}(P(t)))}function Ht(t){let e=z(t),i=function(o,a){let r=o;for(;r&&!it(r)&&!a.includes(r)&&(!C(r)||!["absolute","fixed"].includes(A(r).position));){let s=nt(r);r=k(s)?s.host:s}return r}(t,e),n=null;if(i&&R(i)){let o=et(i);M(i)?n=i:R(o)&&(n=o)}return C(n)?e.filter(o=>n&&C(o)&&function(a,r){let s=r.getRootNode==null?void 0:r.getRootNode();if(a.contains(r))return!0;if(s&&k(s)){let l=r;do{if(l&&a===l)return!0;l=l.parentNode||l.host}while(l)}return!1}(o,n)&&O(o)!=="body"):[]}var Vt={getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:n,strategy:o}=t,a=[...i==="clippingAncestors"?Ht(e):[].concat(i),n],r=a[0],s=a.reduce((l,f)=>{let h=gt(e,f,o);return l.top=D(h.top,l.top),l.right=ut(h.right,l.right),l.bottom=ut(h.bottom,l.bottom),l.left=D(h.left,l.left),l},gt(e,r,o));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:i,strategy:n}=t,o=R(i),a=P(i);if(i===a)return e;let r={scrollLeft:0,scrollTop:0},s={x:0,y:0};if((o||!o&&n!=="fixed")&&((O(i)!=="body"||M(a))&&(r=K(i)),R(i))){let l=S(i,!0);s.x=l.x+i.clientLeft,s.y=l.y+i.clientTop}return{...e,x:e.x-r.scrollLeft+s.x,y:e.y-r.scrollTop+s.y}},isElement:C,getDimensions:mt,getOffsetParent:et,getDocumentElement:P,getElementRects:t=>{let{reference:e,floating:i,strategy:n}=t;return{reference:Ft(e,et(i),n),floating:{...mt(i),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>A(t).direction==="rtl"};function It(t,e,i,n){n===void 0&&(n={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:r=!0,animationFrame:s=!1}=n,l=o&&!s,f=l||a?[...C(t)?z(t):t.contextElement?z(t.contextElement):[],...z(e)]:[];f.forEach(d=>{l&&d.addEventListener("scroll",i,{passive:!0}),a&&d.addEventListener("resize",i)});let h,c=null;if(r){let d=!0;c=new ResizeObserver(()=>{d||i(),d=!1}),C(t)&&!s&&c.observe(t),C(t)||!t.contextElement||s||c.observe(t.contextElement),c.observe(e)}let p=s?S(t):null;return s&&function d(){let u=S(t);!p||u.x===p.x&&u.y===p.y&&u.width===p.width&&u.height===p.height||i(),p=u,h=requestAnimationFrame(d)}(),i(),()=>{var d;f.forEach(u=>{l&&u.removeEventListener("scroll",i),a&&u.removeEventListener("resize",i)}),(d=c)==null||d.disconnect(),c=null,s&&cancelAnimationFrame(h)}}var Rt=(t,e,i)=>ft(t,e,{platform:Vt,...i});var ot=class{constructor(e){this._middleware=[];(this.host=e).addController(this)}hostDisconnected(){this.destroy()}hostUpdated(){this.updatePosition()}hostResized(){this.updatePosition()}float(e){var s;if(this.destroy(),this._settings=e,this._reference=this.getReference(),this._resizeObserver=new ResizeObserver(()=>this.hostResized()),!this._settings)throw new Error("Floating settings are required");if(!this._reference)throw new Error("Floating reference is required");this.host.classList.add("wk-floating");let{position:i,arrow:n=!1,flip:o=!1,shift:a=!1}=this._settings,r=this.getOffsetSetting();Object.assign(this.host.style,{position:(s=i.strategy)!=null?s:"absolute",top:"0",left:"0",transition:"none",transform:"translate3d(0,0,0)"}),i.inset&&!n?this._middleware.push(B(({rects:l,placement:f})=>{var h,c,p,d,u,m;return f.includes("top")||f.includes("bottom")?{mainAxis:-l.floating.height-((h=r==null?void 0:r.mainAxis)!=null?h:0),crossAxis:(c=r==null?void 0:r.crossAxis)!=null?c:0,alignmentAxis:(p=r==null?void 0:r.alignmentAxis)!=null?p:0}:{mainAxis:-l.floating.width-((d=r==null?void 0:r.mainAxis)!=null?d:0),crossAxis:(u=r==null?void 0:r.crossAxis)!=null?u:0,alignmentAxis:(m=r==null?void 0:r.alignmentAxis)!=null?m:0}})):r&&this._middleware.push(B(r)),o&&this._middleware.push(Z()),a&&this._middleware.push(tt()),n&&(this.arrowEl=document.createElement("div"),this.arrowEl.classList.add("wk-arrow"),this._middleware.push(G({element:this.arrowEl}))),this.cleanupAutoUpdate=It(this._reference,this.host,()=>{this.updatePosition()}),this._resizeObserver.observe(this.host)}getOffsetSetting(){var i,n;let e=(i=this._settings)==null?void 0:i.offset;if(!(!e||typeof e=="boolean"))return typeof e=="number"?{mainAxis:e,alignmentAxis:(n=this._settings)!=null&&n.position.inset?e:null}:e}destroy(){var e,i,n,o;Object.assign(this.host.style,{position:"",top:"",left:""}),(i=(e=this.arrowEl)==null?void 0:e.parentElement)==null||i.removeChild(this.arrowEl),this.arrowEl=void 0,this._middleware=[],this.host.classList.remove("wk-floating"),(n=this.cleanupAutoUpdate)==null||n.call(this),(o=this._resizeObserver)==null||o.disconnect()}updatePosition(){var n;if(!this._reference||!this._settings)return;let{strategy:e="absolute",placement:i="top"}=(n=this._settings.position)!=null?n:{};Rt(this._reference,this.host,{middleware:this._middleware,strategy:e,placement:i}).then(({x:o,y:a,placement:r,middlewareData:s})=>{if(s.arrow&&this.arrowEl){let{x:l,y:f}=s.arrow,h={top:"bottom",right:"left",bottom:"top",left:"right"}[r.split("-")[0]],c={bottom:"0deg",left:"90deg",top:"180deg",right:"270deg"}[r.split("-")[0]];Object.assign(this.arrowEl.style,{left:l!=null?`${l}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",[h]:"-5px",transform:`rotate(${c})`})}Object.assign(this.host.style,{transform:`translate3d(${Math.round(o)}px,${Math.round(a)}px,0)`})})}getReference(){if(!this._settings)return;let e=this._settings.reference;if(typeof e=="string"){if(e==="viewport")return this.createViewportReference();let i=document.querySelector(e);if(!i)throw new Error(`Floating reference element (${e}) not found`);return i}return e.hasOwnProperty("element")?e.element:e}createViewportReference(){return{getBoundingClientRect(){var e,i,n,o;return{x:0,y:0,top:0,left:0,bottom:0,right:0,width:(i=(e=window.visualViewport)==null?void 0:e.width)!=null?i:0,height:(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:0}}}}};var rt=class{constructor(e,{app:i}){this.product=null,this.app=i,this.state={selectedVariant:null,selectedOptions:{},hasSelection:!1,optionsWithValues:[],hasOnlyDefaultVariant:!1},(this.host=e).addController(this)}setProduct({product:e,selectedVariantId:i=null,autoSelect:n=!1}){!(e!=null&&e.variants)||(this.product=e,this.initFormState({selectedVariantId:i,autoSelect:n}))}initFormState({selectedVariantId:e,autoSelect:i}){if(!this.product)throw new Error("Product not set");let n=this.initializedVariantId!==e?this.product.variants.find(a=>a.id===e):this.state.selectedVariant;this.initializedVariantId=e;let o=this.app.utils.product.getVariantOptions({variant:n});this.updateFormState({options:o,autoSelect:i})}updateFormState({options:e,change:i,autoSelect:n=!1}){if(!this.product)throw new Error("Product not set");let{hasSelection:o,optionsWithValues:a,selectedOptions:r,selectedVariant:s}=this.app.utils.product.getFormState({product:this.product,options:e,change:i,autoSelect:n});this.state.hasSelection=o,this.state.optionsWithValues=a,this.state.selectedOptions=r,this.state.selectedVariant=s,this.host.requestUpdate()}changeOption({input:e,autoSelect:i=!1}){if(!this.product)throw new Error("Product not set");let n=this.getInputOption(e);if(!n)throw new Error("Cannot parse options from input");this.updateFormState({options:this.state.selectedOptions,change:n,autoSelect:i})}async addToCart({wishlistId:e,wishlistItemId:i}){if(!this.state.selectedVariant)throw new Error("No variant selected");let n=this.host.querySelector("form");if(!n)throw new Error("Form not found");n.classList.add("wk-submitting"),await this.app.addToCart({wishlistId:e,wishlistItemId:i,variantId:this.state.selectedVariant.id,quantity:this.app.utils.product.getFormQuantity({form:n})}),n.classList.remove("wk-submitting")}getInputOption(e){if(!this.product)throw new Error("Product not set");return this.app.utils.product.getInputOption({input:e,product:this.product})}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}};import{combineLatest as _t,distinctUntilChanged as Dt,map as X,of as zt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var st=class{constructor(e){this.stateConfig={loading:"eager"};(this.host=e).addController(this)}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}hostConnected(){}hostDisconnected(){}parseStateConfig(e){var i;return{loading:(i=e.loading)!=null?i:"eager",wishlist:this.parseWishlistStateConfig(e),wishlistItem:this.parseWishlistItemStateConfig(e),productInfo:this.parseProductInfoStateConfig(e)}}parseWishlistStateConfig({wishlist:e}){var n;let i=(n=this.host.dataset.wishlistId)!=null?n:"mine";if(!!e)return{format:typeof e=="string"?e:"minimal",params:{wishlistId:i}}}parseWishlistItemStateConfig({wishlistItem:e}){let{wishlistId:i="mine",wishlistItemId:n}=this.host.dataset;if(!(!e||!n))return{params:{wishlistId:i,wishlistItemId:n}}}parseProductInfoStateConfig({productInfo:e}){let{wishlistId:i="mine",productHandle:n,productId:o,variantId:a}=this.host.dataset;if(!!e)return{params:{wishlistId:i,productHandle:n,productId:o?parseInt(o):void 0,variantId:a?parseInt(a):void 0}}}observe(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e=[];if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.push(this.app.state.observeWishlist({format:this.stateConfig.wishlist.format,wishlistId:i}).pipe(X(n=>({wishlist:n}))))}if(this.stateConfig.productInfo){let{productId:i,productHandle:n,variantId:o}=this.stateConfig.productInfo.params;if(!i&&!n)throw new Error("Product id or handle is required");e.push(this.app.state.observeProductInfo({productHandle:n,productId:i,variantId:o}).pipe(X(a=>({productInfo:a}))))}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.push(this.app.state.observeWishlistItem({wishlistId:i,wishlistItemId:n}).pipe(X(o=>({wishlistItem:o}))))}return e.length||e.push(zt({})),_t(e).pipe(X(i=>i.reduce((n,o)=>o.wishlist?{...n,wishlist:o.wishlist}:o.wishlistItem?{...n,wishlistItem:o.wishlistItem}:o.productInfo?{...n,productInfo:o.productInfo}:n,{})),Dt((i,n)=>JSON.stringify(i)===JSON.stringify(n)))}getFallback(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e={};if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.wishlist={id:i,isMine:i==="mine",numItems:0,items:void 0}}if(this.stateConfig.productInfo){let{productId:i=0,variantId:n=0,productHandle:o}=this.stateConfig.productInfo.params;e.productInfo={productId:i,variantId:n,productHandle:o,inWishlist:!1}}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.wishlistItem={id:n,product:{id:0,handle:"",hidden:!1}}}return e}};export{ot as FloatingUiController,rt as ProductFormController,st as WishlistStateController};
function _(t){return t.split("-")[0]}function B(t){return t.split("-")[1]}function D(t){return["top","bottom"].includes(_(t))?"x":"y"}function J(t){return t==="y"?"height":"width"}function at(t,e,i){let{reference:n,floating:o}=t,l=n.x+n.width/2-o.width/2,s=n.y+n.height/2-o.height/2,r=D(e),c=J(r),f=n[c]/2-o[c]/2,d=r==="x",a;switch(_(e)){case"top":a={x:l,y:n.y-o.height};break;case"bottom":a={x:l,y:n.y+n.height};break;case"right":a={x:n.x+n.width,y:s};break;case"left":a={x:n.x-o.width,y:s};break;default:a={x:n.x,y:n.y}}switch(B(e)){case"start":a[r]-=f*(i&&d?-1:1);break;case"end":a[r]+=f*(i&&d?-1:1)}return a}var ct=async(t,e,i)=>{let{placement:n="bottom",strategy:o="absolute",middleware:l=[],platform:s}=i,r=l.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e)),f=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:a}=at(f,n,c),u=n,h={},p=0;for(let m=0;m<r.length;m++){let{name:g,fn:y}=r[m],{x:v,y:x,data:I,reset:b}=await y({x:d,y:a,initialPlacement:n,placement:u,strategy:o,middlewareData:h,rects:f,platform:s,elements:{reference:t,floating:e}});d=v!=null?v:d,a=x!=null?x:a,h={...h,[g]:{...h[g],...I}},b&&p<=50&&(p++,typeof b=="object"&&(b.placement&&(u=b.placement),b.rects&&(f=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):b.rects),{x:d,y:a}=at(f,u,c)),m=-1)}return{x:d,y:a,placement:u,strategy:o,middlewareData:h}};function ft(t){return typeof t!="number"?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(t):{top:t,right:t,bottom:t,left:t}}function V(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function Q(t,e){var i;e===void 0&&(e={});let{x:n,y:o,platform:l,rects:s,elements:r,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:a="floating",altBoundary:u=!1,padding:h=0}=e,p=ft(h),m=r[u?a==="floating"?"reference":"floating":a],g=V(await l.getClippingRect({element:(i=await(l.isElement==null?void 0:l.isElement(m)))==null||i?m:m.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(r.floating)),boundary:f,rootBoundary:d,strategy:c})),y=V(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({rect:a==="floating"?{...s.floating,x:n,y:o}:s.reference,offsetParent:await(l.getOffsetParent==null?void 0:l.getOffsetParent(r.floating)),strategy:c}):s[a]);return{top:g.top-y.top+p.top,bottom:y.bottom-g.bottom+p.bottom,left:g.left-y.left+p.left,right:y.right-g.right+p.right}}var St=Math.min,Et=Math.max;function Y(t,e,i){return Et(t,St(e,i))}var G=t=>({name:"arrow",options:t,async fn(e){let{element:i,padding:n=0}=t!=null?t:{},{x:o,y:l,placement:s,rects:r,platform:c}=e;if(i==null)return{};let f=ft(n),d={x:o,y:l},a=D(s),u=B(s),h=J(a),p=await c.getDimensions(i),m=a==="y"?"top":"left",g=a==="y"?"bottom":"right",y=r.reference[h]+r.reference[a]-d[a]-r.floating[h],v=d[a]-r.reference[a],x=await(c.getOffsetParent==null?void 0:c.getOffsetParent(i)),I=x?a==="y"?x.clientHeight||0:x.clientWidth||0:0;I===0&&(I=r.floating[h]);let b=y/2-v/2,L=f[m],F=I-p[h]-f[g],w=I/2-p[h]/2+b,R=Y(L,w,F),T=(u==="start"?f[m]:f[g])>0&&w!==R&&r.reference[h]<=r.floating[h];return{[a]:d[a]-(T?w<L?L-w:F-w:0),data:{[a]:R,centerOffset:w-R}}}}),Pt={left:"right",right:"left",bottom:"top",top:"bottom"};function q(t){return t.replace(/left|right|bottom|top/g,e=>Pt[e])}function At(t,e,i){i===void 0&&(i=!1);let n=B(t),o=D(t),l=J(o),s=o==="x"?n===(i?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[l]>e.floating[l]&&(s=q(s)),{main:s,cross:q(s)}}var Ot={start:"end",end:"start"};function lt(t){return t.replace(/start|end/g,e=>Ot[e])}var Wt=["top","right","bottom","left"],zt=Wt.reduce((t,e)=>t.concat(e,e+"-start",e+"-end"),[]);var Z=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i;let{placement:n,middlewareData:o,rects:l,initialPlacement:s,platform:r,elements:c}=e,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:a,fallbackStrategy:u="bestFit",flipAlignment:h=!0,...p}=t,m=_(n),g=a||(m===s||!h?[q(s)]:function(w){let R=q(w);return[lt(w),R,lt(R)]}(s)),y=[s,...g],v=await Q(e,p),x=[],I=((i=o.flip)==null?void 0:i.overflows)||[];if(f&&x.push(v[m]),d){let{main:w,cross:R}=At(n,l,await(r.isRTL==null?void 0:r.isRTL(c.floating)));x.push(v[w],v[R])}if(I=[...I,{placement:n,overflows:x}],!x.every(w=>w<=0)){var b,L;let w=((b=(L=o.flip)==null?void 0:L.index)!=null?b:0)+1,R=y[w];if(R)return{data:{index:w,overflows:I},reset:{placement:R}};let T="bottom";switch(u){case"bestFit":{var F;let st=(F=I.map(M=>[M,M.overflows.filter(H=>H>0).reduce((H,Ct)=>H+Ct,0)]).sort((M,H)=>M[1]-H[1])[0])==null?void 0:F[0].placement;st&&(T=st);break}case"initialPlacement":T=s}if(n!==T)return{reset:{placement:T}}}return{}}}};var U=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:i,y:n}=e,o=await async function(l,s){let{placement:r,platform:c,elements:f}=l,d=await(c.isRTL==null?void 0:c.isRTL(f.floating)),a=_(r),u=B(r),h=D(r)==="x",p=["left","top"].includes(a)?-1:1,m=d&&h?-1:1,g=typeof s=="function"?s(l):s,{mainAxis:y,crossAxis:v,alignmentAxis:x}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...g};return u&&typeof x=="number"&&(v=u==="end"?-1*x:x),h?{x:v*m,y:y*p}:{x:y*p,y:v*m}}(e,t);return{x:i+o.x,y:n+o.y,data:o}}}};function Lt(t){return t==="x"?"y":"x"}var tt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:i,y:n,placement:o}=e,{mainAxis:l=!0,crossAxis:s=!1,limiter:r={fn:g=>{let{x:y,y:v}=g;return{x:y,y:v}}},...c}=t,f={x:i,y:n},d=await Q(e,c),a=D(_(o)),u=Lt(a),h=f[a],p=f[u];if(l){let g=a==="y"?"bottom":"right";h=Y(h+d[a==="y"?"top":"left"],h,h-d[g])}if(s){let g=u==="y"?"bottom":"right";p=Y(p+d[u==="y"?"top":"left"],p,p-d[g])}let m=r.fn({...e,[a]:h,[u]:p});return{...m,data:{x:m.x-i,y:m.y-n}}}}};function wt(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function P(t){if(t==null)return window;if(!wt(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function O(t){return P(t).getComputedStyle(t)}function W(t){return wt(t)?"":t?(t.nodeName||"").toLowerCase():""}function yt(){let t=navigator.userAgentData;return t!=null&&t.brands?t.brands.map(e=>e.brand+"/"+e.version).join(" "):navigator.userAgent}function E(t){return t instanceof P(t).HTMLElement}function C(t){return t instanceof P(t).Element}function ht(t){return typeof ShadowRoot=="undefined"?!1:t instanceof P(t).ShadowRoot||t instanceof ShadowRoot}function $(t){let{overflow:e,overflowX:i,overflowY:n,display:o}=O(t);return/auto|scroll|overlay|hidden/.test(e+n+i)&&!["inline","contents"].includes(o)}function Tt(t){return["table","td","th"].includes(W(t))}function et(t){let e=/firefox/i.test(yt()),i=O(t),n=i.backdropFilter||i.WebkitBackdropFilter;return i.transform!=="none"||i.perspective!=="none"||!!n&&n!=="none"||e&&i.willChange==="filter"||e&&!!i.filter&&i.filter!=="none"||["transform","perspective"].some(o=>i.willChange.includes(o))||["paint","layout","strict","content"].some(o=>{let l=i.contain;return l!=null&&l.includes(o)})}function xt(){return!/^((?!chrome|android).)*safari/i.test(yt())}function it(t){return["html","body","#document"].includes(W(t))}var dt=Math.min,z=Math.max,j=Math.round;function S(t,e,i){var n,o,l,s;e===void 0&&(e=!1),i===void 0&&(i=!1);let r=t.getBoundingClientRect(),c=1,f=1;e&&E(t)&&(c=t.offsetWidth>0&&j(r.width)/t.offsetWidth||1,f=t.offsetHeight>0&&j(r.height)/t.offsetHeight||1);let d=C(t)?P(t):window,a=!xt()&&i,u=(r.left+(a&&(n=(o=d.visualViewport)==null?void 0:o.offsetLeft)!=null?n:0))/c,h=(r.top+(a&&(l=(s=d.visualViewport)==null?void 0:s.offsetTop)!=null?l:0))/f,p=r.width/c,m=r.height/f;return{width:p,height:m,top:h,right:u+p,bottom:h+m,left:u,x:u,y:h}}function A(t){return(e=t,(e instanceof P(e).Node?t.ownerDocument:t.document)||window.document).documentElement;var e}function K(t){return C(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function vt(t){return S(A(t)).left+K(t).scrollLeft}function Ft(t,e,i){let n=E(e),o=A(e),l=S(t,n&&function(c){let f=S(c);return j(f.width)!==c.offsetWidth||j(f.height)!==c.offsetHeight}(e),i==="fixed"),s={scrollLeft:0,scrollTop:0},r={x:0,y:0};if(n||!n&&i!=="fixed")if((W(e)!=="body"||$(o))&&(s=K(e)),E(e)){let c=S(e,!0);r.x=c.x+e.clientLeft,r.y=c.y+e.clientTop}else o&&(r.x=vt(o));return{x:l.left+s.scrollLeft-r.x,y:l.top+s.scrollTop-r.y,width:l.width,height:l.height}}function N(t){if(W(t)==="html")return t;let e=t.assignedSlot||t.parentNode||(ht(t)?t.host:null)||A(t);return ht(e)?e.host:e}function ut(t){return E(t)&&O(t).position!=="fixed"?t.offsetParent:null}function pt(t){let e=P(t),i=ut(t);for(;i&&Tt(i)&&O(i).position==="static";)i=ut(i);return i&&(W(i)==="html"||W(i)==="body"&&O(i).position==="static"&&!et(i))?e:i||function(n){let o=N(n);for(;E(o)&&!it(o);){if(et(o))return o;o=N(o)}return null}(t)||e}function mt(t){if(E(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=S(t);return{width:e.width,height:e.height}}function bt(t){let e=N(t);return it(e)?t.ownerDocument.body:E(e)&&$(e)?e:bt(e)}function k(t,e){var i;e===void 0&&(e=[]);let n=bt(t),o=n===((i=t.ownerDocument)==null?void 0:i.body),l=P(n),s=o?[l].concat(l.visualViewport||[],$(n)?n:[]):n,r=e.concat(s);return o?r:r.concat(k(s))}function gt(t,e,i){return e==="viewport"?V(function(n,o){let l=P(n),s=A(n),r=l.visualViewport,c=s.clientWidth,f=s.clientHeight,d=0,a=0;if(r){c=r.width,f=r.height;let u=xt();(u||!u&&o==="fixed")&&(d=r.offsetLeft,a=r.offsetTop)}return{width:c,height:f,x:d,y:a}}(t,i)):C(e)?function(n,o){let l=S(n,!1,o==="fixed"),s=l.top+n.clientTop,r=l.left+n.clientLeft;return{top:s,left:r,x:r,y:s,right:r+n.clientWidth,bottom:s+n.clientHeight,width:n.clientWidth,height:n.clientHeight}}(e,i):V(function(n){var o;let l=A(n),s=K(n),r=(o=n.ownerDocument)==null?void 0:o.body,c=z(l.scrollWidth,l.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),f=z(l.scrollHeight,l.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),d=-s.scrollLeft+vt(n),a=-s.scrollTop;return O(r||l).direction==="rtl"&&(d+=z(l.clientWidth,r?r.clientWidth:0)-c),{width:c,height:f,x:d,y:a}}(A(t)))}var Ht={getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:n,strategy:o}=t,l=i==="clippingAncestors"?function(f){let d=k(f).filter(h=>C(h)&&W(h)!=="body"),a=f,u=null;for(;C(a)&&!it(a);){let h=O(a);h.position==="static"&&u&&["absolute","fixed"].includes(u.position)&&!et(a)?d=d.filter(p=>p!==a):u=h,a=N(a)}return d}(e):[].concat(i),s=[...l,n],r=s[0],c=s.reduce((f,d)=>{let a=gt(e,d,o);return f.top=z(a.top,f.top),f.right=dt(a.right,f.right),f.bottom=dt(a.bottom,f.bottom),f.left=z(a.left,f.left),f},gt(e,r,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:i,strategy:n}=t,o=E(i),l=A(i);if(i===l)return e;let s={scrollLeft:0,scrollTop:0},r={x:0,y:0};if((o||!o&&n!=="fixed")&&((W(i)!=="body"||$(l))&&(s=K(i)),E(i))){let c=S(i,!0);r.x=c.x+i.clientLeft,r.y=c.y+i.clientTop}return{...e,x:e.x-s.scrollLeft+r.x,y:e.y-s.scrollTop+r.y}},isElement:C,getDimensions:mt,getOffsetParent:pt,getDocumentElement:A,getElementRects:t=>{let{reference:e,floating:i,strategy:n}=t;return{reference:Ft(e,pt(i),n),floating:{...mt(i),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>O(t).direction==="rtl"};function It(t,e,i,n){n===void 0&&(n={});let{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:s=!0,animationFrame:r=!1}=n,c=o&&!r,f=c||l?[...C(t)?k(t):t.contextElement?k(t.contextElement):[],...k(e)]:[];f.forEach(h=>{c&&h.addEventListener("scroll",i,{passive:!0}),l&&h.addEventListener("resize",i)});let d,a=null;if(s){let h=!0;a=new ResizeObserver(()=>{h||i(),h=!1}),C(t)&&!r&&a.observe(t),C(t)||!t.contextElement||r||a.observe(t.contextElement),a.observe(e)}let u=r?S(t):null;return r&&function h(){let p=S(t);!u||p.x===u.x&&p.y===u.y&&p.width===u.width&&p.height===u.height||i(),u=p,d=requestAnimationFrame(h)}(),i(),()=>{var h;f.forEach(p=>{c&&p.removeEventListener("scroll",i),l&&p.removeEventListener("resize",i)}),(h=a)==null||h.disconnect(),a=null,r&&cancelAnimationFrame(d)}}var Rt=(t,e,i)=>ct(t,e,{platform:Ht,...i});var nt=class{constructor(e){this._middleware=[];(this.host=e).addController(this)}hostDisconnected(){this.destroy()}hostUpdated(){this.updatePosition()}hostResized(){this.updatePosition()}float(e){var r;if(this.destroy(),this._settings=e,this._reference=this.getReference(),this._resizeObserver=new ResizeObserver(()=>this.hostResized()),!this._settings)throw new Error("Floating settings are required");if(!this._reference)throw new Error("Floating reference is required");this.host.classList.add("wk-floating");let{position:i,arrow:n=!1,flip:o=!1,shift:l=!1}=this._settings,s=this.getOffsetSetting();Object.assign(this.host.style,{position:(r=i.strategy)!=null?r:"absolute",top:"0",left:"0",transition:"none",transform:"translate3d(0,0,0)"}),i.inset&&!n?this._middleware.push(U(({rects:c,placement:f})=>{var d,a,u,h,p,m;return f.includes("top")||f.includes("bottom")?{mainAxis:-c.floating.height-((d=s==null?void 0:s.mainAxis)!=null?d:0),crossAxis:(a=s==null?void 0:s.crossAxis)!=null?a:0,alignmentAxis:(u=s==null?void 0:s.alignmentAxis)!=null?u:0}:{mainAxis:-c.floating.width-((h=s==null?void 0:s.mainAxis)!=null?h:0),crossAxis:(p=s==null?void 0:s.crossAxis)!=null?p:0,alignmentAxis:(m=s==null?void 0:s.alignmentAxis)!=null?m:0}})):s&&this._middleware.push(U(s)),o&&this._middleware.push(Z()),l&&this._middleware.push(tt()),n&&(this.arrowEl=document.createElement("div"),this.arrowEl.classList.add("wk-arrow"),this._middleware.push(G({element:this.arrowEl}))),this.cleanupAutoUpdate=It(this._reference,this.host,()=>{this.updatePosition()}),this._resizeObserver.observe(this.host)}getOffsetSetting(){var i,n;let e=(i=this._settings)==null?void 0:i.offset;if(!(!e||typeof e=="boolean"))return typeof e=="number"?{mainAxis:e,alignmentAxis:(n=this._settings)!=null&&n.position.inset?e:null}:e}destroy(){var e,i,n,o;Object.assign(this.host.style,{position:"",top:"",left:""}),(i=(e=this.arrowEl)==null?void 0:e.parentElement)==null||i.removeChild(this.arrowEl),this.arrowEl=void 0,this._middleware=[],this.host.classList.remove("wk-floating"),(n=this.cleanupAutoUpdate)==null||n.call(this),(o=this._resizeObserver)==null||o.disconnect()}updatePosition(){var n;if(!this._reference||!this._settings)return;let{strategy:e="absolute",placement:i="top"}=(n=this._settings.position)!=null?n:{};Rt(this._reference,this.host,{middleware:this._middleware,strategy:e,placement:i}).then(({x:o,y:l,placement:s,middlewareData:r})=>{if(r.arrow&&this.arrowEl){let{x:c,y:f}=r.arrow,d={top:"bottom",right:"left",bottom:"top",left:"right"}[s.split("-")[0]],a={bottom:"0deg",left:"90deg",top:"180deg",right:"270deg"}[s.split("-")[0]];Object.assign(this.arrowEl.style,{left:c!=null?`${c}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",[d]:"-5px",transform:`rotate(${a})`})}Object.assign(this.host.style,{transform:`translate3d(${Math.round(o)}px,${Math.round(l)}px,0)`})})}getReference(){if(!this._settings)return;let e=this._settings.reference;if(typeof e=="string"){if(e==="viewport")return this.createViewportReference();let i=document.querySelector(e);if(!i)throw new Error(`Floating reference element (${e}) not found`);return i}return e.hasOwnProperty("element")?e.element:e}createViewportReference(){return{getBoundingClientRect(){var e,i,n,o;return{x:0,y:0,top:0,left:0,bottom:0,right:0,width:(i=(e=window.visualViewport)==null?void 0:e.width)!=null?i:0,height:(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:0}}}}};var ot=class{constructor(e,{app:i}){this.product=null,this.app=i,this.state={selectedVariant:null,selectedOptions:{},hasSelection:!1,optionsWithValues:[],hasOnlyDefaultVariant:!1},(this.host=e).addController(this)}setProduct({product:e,selectedVariantId:i=null,autoSelect:n=!1}){!(e!=null&&e.variants)||(this.product=e,this.initFormState({selectedVariantId:i,autoSelect:n}))}initFormState({selectedVariantId:e,autoSelect:i}){if(!this.product)throw new Error("Product not set");let n=this.initializedVariantId!==e?this.product.variants.find(l=>l.id===e):this.state.selectedVariant;this.initializedVariantId=e;let o=this.app.utils.product.getVariantOptions({variant:n});this.updateFormState({options:o,autoSelect:i})}updateFormState({options:e,change:i,autoSelect:n=!1}){if(!this.product)throw new Error("Product not set");let{hasSelection:o,optionsWithValues:l,selectedOptions:s,selectedVariant:r}=this.app.utils.product.getFormState({product:this.product,options:e,change:i,autoSelect:n});this.state.hasSelection=o,this.state.optionsWithValues=l,this.state.selectedOptions=s,this.state.selectedVariant=r,this.host.requestUpdate()}changeOption({input:e,autoSelect:i=!1}){if(!this.product)throw new Error("Product not set");let n=this.getInputOption(e);if(!n)throw new Error("Cannot parse options from input");this.updateFormState({options:this.state.selectedOptions,change:n,autoSelect:i})}async addToCart({wishlistId:e,wishlistItemId:i}){if(!this.state.selectedVariant)throw new Error("No variant selected");let n=this.host.querySelector("form");if(!n)throw new Error("Form not found");n.classList.add("wk-submitting"),await this.app.addToCart({wishlistId:e,wishlistItemId:i,variantId:this.state.selectedVariant.id,quantity:this.app.utils.product.getFormQuantity({form:n})}),n.classList.remove("wk-submitting")}getInputOption(e){if(!this.product)throw new Error("Product not set");return this.app.utils.product.getInputOption({input:e,product:this.product})}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}};import{combineLatest as Vt,distinctUntilChanged as _t,map as X,of as Dt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var rt=class{constructor(e){this.stateConfig={loading:"eager"};(this.host=e).addController(this)}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}hostConnected(){}hostDisconnected(){}parseStateConfig(e){var i;return{loading:(i=e.loading)!=null?i:"eager",wishlist:this.parseWishlistStateConfig(e),wishlistItem:this.parseWishlistItemStateConfig(e),productInfo:this.parseProductInfoStateConfig(e)}}parseWishlistStateConfig({wishlist:e}){var n;let i=(n=this.host.dataset.wishlistId)!=null?n:"mine";if(!!e)return{params:{wishlistId:i}}}parseWishlistItemStateConfig({wishlistItem:e}){let{wishlistId:i="mine",wishlistItemId:n}=this.host.dataset;if(!(!e||!n))return{params:{wishlistId:i,wishlistItemId:n}}}parseProductInfoStateConfig({productInfo:e}){if(!e)return;let{wishlistId:i="mine",productHandle:n="",productId:o,variantId:l}=this.host.dataset;return{params:{wishlistId:i,productHandle:n,variantId:l?parseInt(l):void 0}}}observe(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e=[];if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.push(this.app.state.observeWishlist({wishlistId:i}).pipe(X(n=>({wishlist:n}))))}if(this.stateConfig.productInfo){let{productHandle:i,variantId:n}=this.stateConfig.productInfo.params;if(!i)throw new Error("Product handle is required");e.push(this.app.state.observeProductInfo({productHandle:i,variantId:n}).pipe(X(o=>({productInfo:o}))))}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.push(this.app.state.observeWishlistItem({wishlistId:i,wishlistItemId:n}).pipe(X(o=>({wishlistItem:o}))))}return e.length||e.push(Dt({})),Vt(e).pipe(X(i=>i.reduce((n,o)=>o.wishlist?{...n,wishlist:o.wishlist}:o.wishlistItem?{...n,wishlistItem:o.wishlistItem}:o.productInfo?{...n,productInfo:o.productInfo}:n,{})),_t((i,n)=>JSON.stringify(i)===JSON.stringify(n)))}getFallback(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e={};if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.wishlist={id:i,isMine:i==="mine",numItems:0,items:[]}}if(this.stateConfig.productInfo){let{variantId:i=0,productHandle:n}=this.stateConfig.productInfo.params;e.productInfo={productId:0,variantId:i,productHandle:n,inWishlist:!1}}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.wishlistItem={id:n,product:{id:0,handle:"",hidden:!1}}}return e}};export{nt as FloatingUiController,ot as ProductFormController,rt as WishlistStateController};

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

var V=class{constructor(){this.mapWishlistState=(t,i="minimal")=>{var r;return{id:t.id,public_id:t.publicId,is_mine:t.isMine,num_items:t.numItems,items:i==="all"?(r=t.items)==null?void 0:r.map(s=>({id:s.id})):void 0}};this.mapProductInfo=t=>({product_id:t.productId,variant_id:t.variantId,in_wishlist:t.inWishlist,wishlist_item_id:t.wishlistItemId});this.mapWishlistItem=t=>{var i,r,s;return{id:t.id,loading:!((i=t.product)!=null&&i.url)&&!((r=t.product)!=null&&r.hidden),hidden:!!((s=t.product)!=null&&s.hidden),selected_variant_id:t.selectedVariantId,product:t.product}}}camelToSnakeCase(t){return t.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`)}objectToSnakeCase(t){return typeof t!="object"?t:Object.fromEntries(Object.entries(t).map(([i,r])=>{if(typeof r=="function")return[i,null];let s=this.camelToSnakeCase(i);return Array.isArray(r)?[s,r.map(n=>this.objectToSnakeCase(n))]:r&&typeof r=="object"?[s,this.objectToSnakeCase(r)]:[s,r]}))}};var X=function(){return X=Object.assign||function(t){for(var i,r=1,s=arguments.length;r<s;r++){i=arguments[r];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},X.apply(this,arguments)};function F(e,t,i,r){function s(n){return n instanceof i?n:new i(function(o){o(n)})}return new(i||(i=Promise))(function(n,o){function l(p){try{u(r.next(p))}catch(y){o(y)}}function a(p){try{u(r.throw(p))}catch(y){o(y)}}function u(p){p.done?n(p.value):s(p.value).then(l,a)}u((r=r.apply(e,t||[])).next())})}var x=class{liquidMethodMissing(t){}},Mt=Object.prototype.toString,tt=String.prototype.toLowerCase,ft=Object.hasOwnProperty;function L(e){return typeof e=="string"}function q(e){return typeof e=="function"}function At(e){return e&&q(e.then)}function K(e){return e&&q(e.next)&&q(e.throw)&&q(e.return)}function Ct(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function c(e){return e=h(e),L(e)?e:E(e)?"":T(e)?e.map(t=>c(t)).join(""):String(e)}function h(e){return e instanceof x&&q(e.valueOf)?e.valueOf():e}function De(e){return typeof e=="number"}function gt(e){return e&&q(e.toLiquid)?gt(e.toLiquid()):e}function E(e){return e==null}function T(e){return Mt.call(e)==="[object Array]"}function $t(e){return Ve(e)&&Symbol.iterator in e}function le(e,t){e=e||{};for(let i in e)if(ft.call(e,i)&&t(e[i],i,e)===!1)break;return e}function We(e){return e[e.length-1]}function Ve(e){let t=typeof e;return e!==null&&(t==="object"||t==="function")}function mt(e,t,i=1){let r=[];for(let s=e;s<t;s+=i)r.push(s);return r}function ee(e,t,i=" "){return wt(e,t,i,(r,s)=>s+r)}function Ut(e,t,i=" "){return wt(e,t,i,(r,s)=>r+s)}function wt(e,t,i,r){e=String(e);let s=t-e.length;for(;s-- >0;)e=r(e,i);return e}function yt(e){return e}function ue(e){return e.replace(/(\w?)([A-Z])/g,(t,i,r)=>(i?i+"_":"")+r.toLowerCase())}function zt(e){return[...e].some(i=>i>="a"&&i<="z")?e.toUpperCase():e.toLowerCase()}function Dt(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function it(e,t){return e==null&&t==null?0:e==null?1:t==null||(e=tt.call(e),t=tt.call(t),e<t)?-1:e>t?1:0}function k(e){return(...t)=>e(...t.map(h))}function Be(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}var B=class{constructor(t,i,r,s){this.key=t,this.value=i,this.next=r,this.prev=s}},te=class{constructor(t,i=0){this.limit=t,this.size=i,this.cache={},this.head=new B("HEAD",null,null,null),this.tail=new B("TAIL",null,null,null),this.head.next=this.tail,this.tail.prev=this.head}write(t,i){if(this.cache[t])this.cache[t].value=i;else{let r=new B(t,i,this.head.next,this.head);this.head.next.prev=r,this.head.next=r,this.cache[t]=r,this.size++,this.ensureLimit()}}read(t){if(!this.cache[t])return;let{value:i}=this.cache[t];return this.remove(t),this.write(t,i),i}remove(t){let i=this.cache[t];i.prev.next=i.next,i.next.prev=i.prev,delete this.cache[t],this.size--}clear(){this.head.next=this.tail,this.tail.prev=this.head,this.size=0,this.cache={}}ensureLimit(){this.size>this.limit&&this.remove(this.tail.prev.key)}};function Tt(e,t){let i=document.createElement("base");i.href=e;let r=document.getElementsByTagName("head")[0];r.insertBefore(i,r.firstChild);let s=document.createElement("a");s.href=t;let n=s.href;return r.removeChild(i),n}function Wt(e,t,i){return e.length&&We(e)!=="/"&&(e+="/"),Tt(e,t).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,(s,n,o)=>{let l=o.split("/").pop();return/\.\w+$/.test(l)?s:n+o+i})}function Vt(e){return F(this,void 0,void 0,function*(){return new Promise((t,i)=>{let r=new XMLHttpRequest;r.onload=()=>{r.status>=200&&r.status<300?t(r.responseText):i(new Error(r.statusText))},r.onerror=()=>{i(new Error("An error occurred whilst receiving the response."))},r.open("GET",e),r.send()})})}function Bt(e){let t=new XMLHttpRequest;if(t.open("GET",e,!1),t.send(),t.status<200||t.status>=300)throw new Error(t.statusText);return t.responseText}function jt(e){return F(this,void 0,void 0,function*(){return!0})}function Ht(e){return!0}function Qt(e){return Tt(e,".")}var Yt="/",Jt=Object.freeze({__proto__:null,resolve:Wt,readFile:Vt,readFileSync:Bt,exists:jt,existsSync:Ht,dirname:Qt,sep:Yt});function b(e){return e&&q(e.equals)}function N(e,t){return!je(e,t)}function je(e,t){return t.opts.jsTruthy?!e:e===!1||e===void 0||e===null}var rt={"==":(e,t)=>b(e)?e.equals(t):b(t)?t.equals(e):h(e)===h(t),"!=":(e,t)=>b(e)?!e.equals(t):b(t)?!t.equals(e):h(e)!==h(t),">":(e,t)=>b(e)?e.gt(t):b(t)?t.lt(e):h(e)>h(t),"<":(e,t)=>b(e)?e.lt(t):b(t)?t.gt(e):h(e)<h(t),">=":(e,t)=>b(e)?e.geq(t):b(t)?t.leq(e):h(e)>=h(t),"<=":(e,t)=>b(e)?e.leq(t):b(t)?t.geq(e):h(e)<=h(t),contains:(e,t)=>(e=h(e),t=h(t),e&&q(e.indexOf)?e.indexOf(t)>-1:!1),and:(e,t,i)=>N(h(e),i)&&N(h(t),i),or:(e,t,i)=>N(h(e),i)||N(h(t),i)},d=[0,0,0,0,0,0,0,0,0,20,4,4,4,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,2,8,0,0,0,0,8,0,0,0,64,0,65,0,0,33,33,33,33,33,33,33,33,33,33,0,0,2,2,2,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],He=1,ae=4,st=8,bt=16,Gt=32,Zt=64;d[160]=d[5760]=d[6158]=d[8192]=d[8193]=d[8194]=d[8195]=d[8196]=d[8197]=d[8198]=d[8199]=d[8200]=d[8201]=d[8202]=d[8232]=d[8233]=d[8239]=d[8287]=d[12288]=ae;function _t(e){let t={};for(let[i,r]of Object.entries(e)){let s=t;for(let n=0;n<i.length;n++){let o=i[n];s[o]=s[o]||{},n===i.length-1&&d[i.charCodeAt(n)]&He&&(s[o].needBoundary=!0),s=s[o]}s.handler=r,s.end=!0}return t}var Xt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&#34;","'":"&#39;"},Kt={"&amp;":"&","&lt;":"<","&gt;":">","&#34;":'"',"&#39;":"'"};function kt(e){return c(e).replace(/&|<|>|"|'/g,t=>Xt[t])}function ei(e){return c(e).replace(/&(amp|lt|gt|#34|#39);/g,t=>Kt[t])}function ti(e){return kt(ei(c(e)))}function ii(e){return c(e).replace(/\n/g,`<br />
`)}function ri(e){return c(e).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")}var si=k(Math.abs),ni=k(Math.max),oi=k(Math.min),ai=k(Math.ceil),li=k((e,t,i=!1)=>i?Math.floor(e/t):e/t),ui=k(Math.floor),ci=k((e,t)=>e-t),hi=k((e,t)=>e%t),pi=k((e,t)=>e*t);function di(e,t=0){e=h(e),t=h(t);let i=Math.pow(10,t);return Math.round(e*i)/i}function fi(e,t){return e=h(e),t=h(t),Number(e)+Number(t)}var gi=e=>c(e).split("+").map(decodeURIComponent).join(" "),mi=e=>c(e).split(" ").map(encodeURIComponent).join("+");function Qe(e){return e=h(e),T(e)?e:L(e)&&e.length>0?[e]:$t(e)?Array.from(e):Ve(e)?Object.keys(e).map(t=>[t,e[t]]):[]}function R(e){return E(e)?[]:T(e)?e:[e]}var wi=k((e,t)=>R(e).join(t===void 0?" ":t)),yi=k(e=>T(e)?We(e):""),Ti=k(e=>T(e)?e[0]:""),bi=k(e=>[...R(e)].reverse());function*_i(e,t){let i=[];for(let r of R(h(e)))i.push([r,t?yield this.context._getFromScope(r,c(t).split(".")):r]);return i.sort((r,s)=>{let n=r[1],o=s[1];return n<o?-1:n>o?1:0}).map(r=>r[0])}function ki(e,t){e=h(e);let i=c(t),r=t===void 0?it:(s,n)=>it(s[i],n[i]);return[...R(e)].sort(r)}var qi=e=>e&&e.length||0;function*Si(e,t){let i=[];for(let r of R(h(e)))i.push(yield this.context._getFromScope(r,c(t).split(".")));return i}function vi(e){return e=h(e),R(e).filter(t=>!E(h(t)))}function Li(e,t=[]){return e=h(e),t=R(t).map(i=>h(i)),R(e).concat(t)}function Fi(e,t,i=1){return e=h(e),E(e)?[]:(T(e)||(e=c(e)),t=t<0?e.length+t:t,e.slice(t,t+i))}function*Oi(e,t,i){let r=[];e=R(h(e));for(let s of e)r.push(yield this.context._getFromScope(s,c(t).split(".")));return e.filter((s,n)=>i===void 0?N(r[n],this.context):b(i)?i.equals(r[n]):r[n]===i)}function Ri(e){e=h(e);let t={};return(e||[]).filter(i=>ft.call(t,String(i))?!1:(t[String(i)]=!0,!0))}var xi=/%([-_0^#:]+)?(\d+)?([EO])?(.)/,qt=["January","February","March","April","May","June","July","August","September","October","November","December"],St=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ii=qt.map(vt),Ei=St.map(vt),nt={1:"st",2:"nd",3:"rd",default:"th"};function vt(e){return e.slice(0,3)}function Pi(e){return[31,Ni(e)?29:28,31,30,31,30,31,31,30,31,30,31]}function Lt(e){let t=0;for(let i=0;i<e.getMonth();++i)t+=Pi(e)[i];return t+e.getDate()}function ot(e,t){let i=Lt(e)+(t-e.getDay()),s=7-new Date(e.getFullYear(),0,1).getDay()+t;return String(Math.floor((i-s)/7)+1)}function Ni(e){let t=e.getFullYear();return!!((t&3)===0&&(t%100||t%400===0&&t))}function Mi(e){let t=e.getDate().toString(),i=parseInt(t.slice(-1));return nt[i]||nt.default}function Ai(e){return parseInt(e.getFullYear().toString().substring(0,2),10)}var Ci={d:2,e:2,H:2,I:2,j:3,k:2,l:2,L:3,m:2,M:2,S:2,U:2,W:2},$i={a:" ",A:" ",b:" ",B:" ",c:" ",e:" ",k:" ",l:" ",p:" ",P:" "},ce={a:e=>Ei[e.getDay()],A:e=>St[e.getDay()],b:e=>Ii[e.getMonth()],B:e=>qt[e.getMonth()],c:e=>e.toLocaleString(),C:e=>Ai(e),d:e=>e.getDate(),e:e=>e.getDate(),H:e=>e.getHours(),I:e=>String(e.getHours()%12||12),j:e=>Lt(e),k:e=>e.getHours(),l:e=>String(e.getHours()%12||12),L:e=>e.getMilliseconds(),m:e=>e.getMonth()+1,M:e=>e.getMinutes(),N:(e,t)=>{let i=Number(t.width)||9,r=String(e.getMilliseconds()).slice(0,i);return Ut(r,i,"0")},p:e=>e.getHours()<12?"AM":"PM",P:e=>e.getHours()<12?"am":"pm",q:e=>Mi(e),s:e=>Math.round(e.getTime()/1e3),S:e=>e.getSeconds(),u:e=>e.getDay()||7,U:e=>ot(e,0),w:e=>e.getDay(),W:e=>ot(e,1),x:e=>e.toLocaleDateString(),X:e=>e.toLocaleTimeString(),y:e=>e.getFullYear().toString().slice(2,4),Y:e=>e.getFullYear(),z:(e,t)=>{let i=Math.abs(e.getTimezoneOffset()),r=Math.floor(i/60),s=i%60;return(e.getTimezoneOffset()>0?"-":"+")+ee(r,2,"0")+(t.flags[":"]?":":"")+ee(s,2,"0")},t:()=>" ",n:()=>`
`,"%":()=>"%"};ce.h=ce.b;function Ui(e,t){let i="",r=t,s;for(;s=xi.exec(r);)i+=r.slice(0,s.index),r=r.slice(s.index+s[0].length),i+=zi(e,s);return i+r}function zi(e,t){let[i,r="",s,n,o]=t,l=ce[o];if(!l)return i;let a={};for(let Nt of r)a[Nt]=!0;let u=String(l(e,{flags:a,width:s,modifier:n})),p=$i[o]||"0",y=s||Ci[o]||0;return a["^"]?u=u.toUpperCase():a["#"]&&(u=zt(u)),a._?p=" ":a[0]&&(p="0"),a["-"]&&(y=0),ee(u,y,p)}var Di=6e4,Wi=new Date().getTimezoneOffset(),Vi=/([zZ]|([+-])(\d{2}):(\d{2}))$/,O=class{constructor(t,i){if(t instanceof O)this.date=t.date,i=t.timezoneOffset;else{let r=(Wi-i)*Di,s=new Date(t).getTime()+r;this.date=new Date(s)}this.timezoneOffset=i}getTime(){return this.date.getTime()}getMilliseconds(){return this.date.getMilliseconds()}getSeconds(){return this.date.getSeconds()}getMinutes(){return this.date.getMinutes()}getHours(){return this.date.getHours()}getDay(){return this.date.getDay()}getDate(){return this.date.getDate()}getMonth(){return this.date.getMonth()}getFullYear(){return this.date.getFullYear()}toLocaleTimeString(t){return this.date.toLocaleTimeString(t)}toLocaleDateString(t){return this.date.toLocaleDateString(t)}getTimezoneOffset(){return this.timezoneOffset}static createDateFixedToTimezone(t){let i=t.match(Vi);if(i&&i[1]==="Z")return new O(+new Date(t),0);if(i&&i[2]&&i[3]&&i[4]){let[,,r,s,n]=i,o=(r==="+"?-1:1)*(parseInt(s,10)*60+parseInt(n,10));return new O(+new Date(t),o)}return new Date(t)}};function Bi(e,t){let i=this.context.opts,r;return e=h(e),t=c(t),e==="now"||e==="today"?r=new Date:De(e)?r=new Date(e*1e3):L(e)?/^\d+$/.test(e)?r=new Date(+e*1e3):i.preserveTimezones?r=O.createDateFixedToTimezone(e):r=new Date(e):r=e,ji(r)?(i.hasOwnProperty("timezoneOffset")&&(r=new O(r,i.timezoneOffset)),Ui(r,t)):e}function ji(e){return(e instanceof Date||e instanceof O)&&!isNaN(e.getTime())}function Hi(e,t,...i){return e=h(e),T(e)||L(e)?e.length?e:t:e===!1&&new Map(i).get("allow_false")?!1:je(e,this.context)?t:e}function Qi(e){return JSON.stringify(e)}var Yi=yt,z=class extends Error{constructor(t,i){super(t.message),this.originalError=t,this.token=i,this.context=""}update(){let t=this.originalError;this.context=Ji(this.token),this.message=Gi(t.message,this.token),this.stack=this.message+`
var V=class{constructor(){this.mapWishlistState=t=>({id:t.id,public_id:t.publicId,is_mine:t.isMine,num_items:t.numItems,items:t.items.map(i=>({id:i.id,product_id:i.productId,variant_id:i.variantId}))});this.mapProductInfo=t=>({product_id:t.productId,variant_id:t.variantId,in_wishlist:t.inWishlist,wishlist_item_id:t.wishlistItemId});this.mapWishlistItem=t=>{var i,r,s;return{id:t.id,loading:!((i=t.product)!=null&&i.url)&&!((r=t.product)!=null&&r.hidden),hidden:!!((s=t.product)!=null&&s.hidden),selected_variant_id:t.variantId,product:t.product}}}camelToSnakeCase(t){return t.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`)}objectToSnakeCase(t){return typeof t!="object"?t:Object.fromEntries(Object.entries(t).map(([i,r])=>{if(typeof r=="function")return[i,null];let s=this.camelToSnakeCase(i);return Array.isArray(r)?[s,r.map(n=>this.objectToSnakeCase(n))]:r&&typeof r=="object"?[s,this.objectToSnakeCase(r)]:[s,r]}))}};var X=function(){return X=Object.assign||function(t){for(var i,r=1,s=arguments.length;r<s;r++){i=arguments[r];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},X.apply(this,arguments)};function O(e,t,i,r){function s(n){return n instanceof i?n:new i(function(o){o(n)})}return new(i||(i=Promise))(function(n,o){function l(p){try{u(r.next(p))}catch(y){o(y)}}function a(p){try{u(r.throw(p))}catch(y){o(y)}}function u(p){p.done?n(p.value):s(p.value).then(l,a)}u((r=r.apply(e,t||[])).next())})}var x=class{liquidMethodMissing(t){}},Mt=Object.prototype.toString,tt=String.prototype.toLowerCase,ft=Object.hasOwnProperty;function L(e){return typeof e=="string"}function q(e){return typeof e=="function"}function At(e){return e&&q(e.then)}function K(e){return e&&q(e.next)&&q(e.throw)&&q(e.return)}function $t(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function c(e){return e=h(e),L(e)?e:E(e)?"":T(e)?e.map(t=>c(t)).join(""):String(e)}function h(e){return e instanceof x&&q(e.valueOf)?e.valueOf():e}function De(e){return typeof e=="number"}function gt(e){return e&&q(e.toLiquid)?gt(e.toLiquid()):e}function E(e){return e==null}function T(e){return Mt.call(e)==="[object Array]"}function Ct(e){return Ve(e)&&Symbol.iterator in e}function le(e,t){e=e||{};for(let i in e)if(ft.call(e,i)&&t(e[i],i,e)===!1)break;return e}function We(e){return e[e.length-1]}function Ve(e){let t=typeof e;return e!==null&&(t==="object"||t==="function")}function mt(e,t,i=1){let r=[];for(let s=e;s<t;s+=i)r.push(s);return r}function ee(e,t,i=" "){return wt(e,t,i,(r,s)=>s+r)}function Ut(e,t,i=" "){return wt(e,t,i,(r,s)=>r+s)}function wt(e,t,i,r){e=String(e);let s=t-e.length;for(;s-- >0;)e=r(e,i);return e}function yt(e){return e}function ue(e){return e.replace(/(\w?)([A-Z])/g,(t,i,r)=>(i?i+"_":"")+r.toLowerCase())}function zt(e){return[...e].some(i=>i>="a"&&i<="z")?e.toUpperCase():e.toLowerCase()}function Dt(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function it(e,t){return e==null&&t==null?0:e==null?1:t==null||(e=tt.call(e),t=tt.call(t),e<t)?-1:e>t?1:0}function k(e){return(...t)=>e(...t.map(h))}function Be(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}var B=class{constructor(t,i,r,s){this.key=t,this.value=i,this.next=r,this.prev=s}},te=class{constructor(t,i=0){this.limit=t,this.size=i,this.cache={},this.head=new B("HEAD",null,null,null),this.tail=new B("TAIL",null,null,null),this.head.next=this.tail,this.tail.prev=this.head}write(t,i){if(this.cache[t])this.cache[t].value=i;else{let r=new B(t,i,this.head.next,this.head);this.head.next.prev=r,this.head.next=r,this.cache[t]=r,this.size++,this.ensureLimit()}}read(t){if(!this.cache[t])return;let{value:i}=this.cache[t];return this.remove(t),this.write(t,i),i}remove(t){let i=this.cache[t];i.prev.next=i.next,i.next.prev=i.prev,delete this.cache[t],this.size--}clear(){this.head.next=this.tail,this.tail.prev=this.head,this.size=0,this.cache={}}ensureLimit(){this.size>this.limit&&this.remove(this.tail.prev.key)}};function Tt(e,t){let i=document.createElement("base");i.href=e;let r=document.getElementsByTagName("head")[0];r.insertBefore(i,r.firstChild);let s=document.createElement("a");s.href=t;let n=s.href;return r.removeChild(i),n}function Wt(e,t,i){return e.length&&We(e)!=="/"&&(e+="/"),Tt(e,t).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,(s,n,o)=>{let l=o.split("/").pop();return/\.\w+$/.test(l)?s:n+o+i})}function Vt(e){return O(this,void 0,void 0,function*(){return new Promise((t,i)=>{let r=new XMLHttpRequest;r.onload=()=>{r.status>=200&&r.status<300?t(r.responseText):i(new Error(r.statusText))},r.onerror=()=>{i(new Error("An error occurred whilst receiving the response."))},r.open("GET",e),r.send()})})}function Bt(e){let t=new XMLHttpRequest;if(t.open("GET",e,!1),t.send(),t.status<200||t.status>=300)throw new Error(t.statusText);return t.responseText}function jt(e){return O(this,void 0,void 0,function*(){return!0})}function Ht(e){return!0}function Qt(e){return Tt(e,".")}var Yt="/",Jt=Object.freeze({__proto__:null,resolve:Wt,readFile:Vt,readFileSync:Bt,exists:jt,existsSync:Ht,dirname:Qt,sep:Yt});function b(e){return e&&q(e.equals)}function N(e,t){return!je(e,t)}function je(e,t){return t.opts.jsTruthy?!e:e===!1||e===void 0||e===null}var rt={"==":(e,t)=>b(e)?e.equals(t):b(t)?t.equals(e):h(e)===h(t),"!=":(e,t)=>b(e)?!e.equals(t):b(t)?!t.equals(e):h(e)!==h(t),">":(e,t)=>b(e)?e.gt(t):b(t)?t.lt(e):h(e)>h(t),"<":(e,t)=>b(e)?e.lt(t):b(t)?t.gt(e):h(e)<h(t),">=":(e,t)=>b(e)?e.geq(t):b(t)?t.leq(e):h(e)>=h(t),"<=":(e,t)=>b(e)?e.leq(t):b(t)?t.geq(e):h(e)<=h(t),contains:(e,t)=>(e=h(e),t=h(t),e&&q(e.indexOf)?e.indexOf(t)>-1:!1),and:(e,t,i)=>N(h(e),i)&&N(h(t),i),or:(e,t,i)=>N(h(e),i)||N(h(t),i)},d=[0,0,0,0,0,0,0,0,0,20,4,4,4,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,2,8,0,0,0,0,8,0,0,0,64,0,65,0,0,33,33,33,33,33,33,33,33,33,33,0,0,2,2,2,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],He=1,ae=4,st=8,bt=16,Gt=32,Zt=64;d[160]=d[5760]=d[6158]=d[8192]=d[8193]=d[8194]=d[8195]=d[8196]=d[8197]=d[8198]=d[8199]=d[8200]=d[8201]=d[8202]=d[8232]=d[8233]=d[8239]=d[8287]=d[12288]=ae;function _t(e){let t={};for(let[i,r]of Object.entries(e)){let s=t;for(let n=0;n<i.length;n++){let o=i[n];s[o]=s[o]||{},n===i.length-1&&d[i.charCodeAt(n)]&He&&(s[o].needBoundary=!0),s=s[o]}s.handler=r,s.end=!0}return t}var Xt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&#34;","'":"&#39;"},Kt={"&amp;":"&","&lt;":"<","&gt;":">","&#34;":'"',"&#39;":"'"};function kt(e){return c(e).replace(/&|<|>|"|'/g,t=>Xt[t])}function ei(e){return c(e).replace(/&(amp|lt|gt|#34|#39);/g,t=>Kt[t])}function ti(e){return kt(ei(c(e)))}function ii(e){return c(e).replace(/\n/g,`<br />
`)}function ri(e){return c(e).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")}var si=k(Math.abs),ni=k(Math.max),oi=k(Math.min),ai=k(Math.ceil),li=k((e,t,i=!1)=>i?Math.floor(e/t):e/t),ui=k(Math.floor),ci=k((e,t)=>e-t),hi=k((e,t)=>e%t),pi=k((e,t)=>e*t);function di(e,t=0){e=h(e),t=h(t);let i=Math.pow(10,t);return Math.round(e*i)/i}function fi(e,t){return e=h(e),t=h(t),Number(e)+Number(t)}var gi=e=>c(e).split("+").map(decodeURIComponent).join(" "),mi=e=>c(e).split(" ").map(encodeURIComponent).join("+");function Qe(e){return e=h(e),T(e)?e:L(e)&&e.length>0?[e]:Ct(e)?Array.from(e):Ve(e)?Object.keys(e).map(t=>[t,e[t]]):[]}function R(e){return E(e)?[]:T(e)?e:[e]}var wi=k((e,t)=>R(e).join(t===void 0?" ":t)),yi=k(e=>T(e)?We(e):""),Ti=k(e=>T(e)?e[0]:""),bi=k(e=>[...R(e)].reverse());function*_i(e,t){let i=[];for(let r of R(h(e)))i.push([r,t?yield this.context._getFromScope(r,c(t).split(".")):r]);return i.sort((r,s)=>{let n=r[1],o=s[1];return n<o?-1:n>o?1:0}).map(r=>r[0])}function ki(e,t){e=h(e);let i=c(t),r=t===void 0?it:(s,n)=>it(s[i],n[i]);return[...R(e)].sort(r)}var qi=e=>e&&e.length||0;function*Si(e,t){let i=[];for(let r of R(h(e)))i.push(yield this.context._getFromScope(r,c(t).split(".")));return i}function vi(e){return e=h(e),R(e).filter(t=>!E(h(t)))}function Li(e,t=[]){return e=h(e),t=R(t).map(i=>h(i)),R(e).concat(t)}function Oi(e,t,i=1){return e=h(e),E(e)?[]:(T(e)||(e=c(e)),t=t<0?e.length+t:t,e.slice(t,t+i))}function*Fi(e,t,i){let r=[];e=R(h(e));for(let s of e)r.push(yield this.context._getFromScope(s,c(t).split(".")));return e.filter((s,n)=>i===void 0?N(r[n],this.context):b(i)?i.equals(r[n]):r[n]===i)}function Ri(e){e=h(e);let t={};return(e||[]).filter(i=>ft.call(t,String(i))?!1:(t[String(i)]=!0,!0))}var xi=/%([-_0^#:]+)?(\d+)?([EO])?(.)/,qt=["January","February","March","April","May","June","July","August","September","October","November","December"],St=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ii=qt.map(vt),Ei=St.map(vt),nt={1:"st",2:"nd",3:"rd",default:"th"};function vt(e){return e.slice(0,3)}function Pi(e){return[31,Ni(e)?29:28,31,30,31,30,31,31,30,31,30,31]}function Lt(e){let t=0;for(let i=0;i<e.getMonth();++i)t+=Pi(e)[i];return t+e.getDate()}function ot(e,t){let i=Lt(e)+(t-e.getDay()),s=7-new Date(e.getFullYear(),0,1).getDay()+t;return String(Math.floor((i-s)/7)+1)}function Ni(e){let t=e.getFullYear();return!!((t&3)===0&&(t%100||t%400===0&&t))}function Mi(e){let t=e.getDate().toString(),i=parseInt(t.slice(-1));return nt[i]||nt.default}function Ai(e){return parseInt(e.getFullYear().toString().substring(0,2),10)}var $i={d:2,e:2,H:2,I:2,j:3,k:2,l:2,L:3,m:2,M:2,S:2,U:2,W:2},Ci={a:" ",A:" ",b:" ",B:" ",c:" ",e:" ",k:" ",l:" ",p:" ",P:" "},ce={a:e=>Ei[e.getDay()],A:e=>St[e.getDay()],b:e=>Ii[e.getMonth()],B:e=>qt[e.getMonth()],c:e=>e.toLocaleString(),C:e=>Ai(e),d:e=>e.getDate(),e:e=>e.getDate(),H:e=>e.getHours(),I:e=>String(e.getHours()%12||12),j:e=>Lt(e),k:e=>e.getHours(),l:e=>String(e.getHours()%12||12),L:e=>e.getMilliseconds(),m:e=>e.getMonth()+1,M:e=>e.getMinutes(),N:(e,t)=>{let i=Number(t.width)||9,r=String(e.getMilliseconds()).slice(0,i);return Ut(r,i,"0")},p:e=>e.getHours()<12?"AM":"PM",P:e=>e.getHours()<12?"am":"pm",q:e=>Mi(e),s:e=>Math.round(e.getTime()/1e3),S:e=>e.getSeconds(),u:e=>e.getDay()||7,U:e=>ot(e,0),w:e=>e.getDay(),W:e=>ot(e,1),x:e=>e.toLocaleDateString(),X:e=>e.toLocaleTimeString(),y:e=>e.getFullYear().toString().slice(2,4),Y:e=>e.getFullYear(),z:(e,t)=>{let i=Math.abs(e.getTimezoneOffset()),r=Math.floor(i/60),s=i%60;return(e.getTimezoneOffset()>0?"-":"+")+ee(r,2,"0")+(t.flags[":"]?":":"")+ee(s,2,"0")},t:()=>" ",n:()=>`
`,"%":()=>"%"};ce.h=ce.b;function Ui(e,t){let i="",r=t,s;for(;s=xi.exec(r);)i+=r.slice(0,s.index),r=r.slice(s.index+s[0].length),i+=zi(e,s);return i+r}function zi(e,t){let[i,r="",s,n,o]=t,l=ce[o];if(!l)return i;let a={};for(let Nt of r)a[Nt]=!0;let u=String(l(e,{flags:a,width:s,modifier:n})),p=Ci[o]||"0",y=s||$i[o]||0;return a["^"]?u=u.toUpperCase():a["#"]&&(u=zt(u)),a._?p=" ":a[0]&&(p="0"),a["-"]&&(y=0),ee(u,y,p)}var Di=6e4,Wi=new Date().getTimezoneOffset(),Vi=/([zZ]|([+-])(\d{2}):(\d{2}))$/,F=class{constructor(t,i){if(t instanceof F)this.date=t.date,i=t.timezoneOffset;else{let r=(Wi-i)*Di,s=new Date(t).getTime()+r;this.date=new Date(s)}this.timezoneOffset=i}getTime(){return this.date.getTime()}getMilliseconds(){return this.date.getMilliseconds()}getSeconds(){return this.date.getSeconds()}getMinutes(){return this.date.getMinutes()}getHours(){return this.date.getHours()}getDay(){return this.date.getDay()}getDate(){return this.date.getDate()}getMonth(){return this.date.getMonth()}getFullYear(){return this.date.getFullYear()}toLocaleTimeString(t){return this.date.toLocaleTimeString(t)}toLocaleDateString(t){return this.date.toLocaleDateString(t)}getTimezoneOffset(){return this.timezoneOffset}static createDateFixedToTimezone(t){let i=t.match(Vi);if(i&&i[1]==="Z")return new F(+new Date(t),0);if(i&&i[2]&&i[3]&&i[4]){let[,,r,s,n]=i,o=(r==="+"?-1:1)*(parseInt(s,10)*60+parseInt(n,10));return new F(+new Date(t),o)}return new Date(t)}};function Bi(e,t){let i=this.context.opts,r;return e=h(e),t=c(t),e==="now"||e==="today"?r=new Date:De(e)?r=new Date(e*1e3):L(e)?/^\d+$/.test(e)?r=new Date(+e*1e3):i.preserveTimezones?r=F.createDateFixedToTimezone(e):r=new Date(e):r=e,ji(r)?(i.hasOwnProperty("timezoneOffset")&&(r=new F(r,i.timezoneOffset)),Ui(r,t)):e}function ji(e){return(e instanceof Date||e instanceof F)&&!isNaN(e.getTime())}function Hi(e,t,...i){return e=h(e),T(e)||L(e)?e.length?e:t:e===!1&&new Map(i).get("allow_false")?!1:je(e,this.context)?t:e}function Qi(e){return JSON.stringify(e)}var Yi=yt,z=class extends Error{constructor(t,i){super(t.message),this.originalError=t,this.token=i,this.context=""}update(){let t=this.originalError;this.context=Ji(this.token),this.message=Gi(t.message,this.token),this.stack=this.message+`
`+this.context+`

@@ -8,6 +8,6 @@ `+this.stack+`

`),r=Math.max(t-2,1),s=Math.min(t+3,i.length);return mt(r,s+1).map(o=>{let l=o===t?">> ":" ",a=ee(String(o),String(s).length),u=i[o-1];return`${l}${a}| ${u}`}).join(`
`)}function Gi(e,t){t.file&&(e+=`, file:${t.file}`);let[i,r]=t.getPosition();return e+=`, line:${i}, col:${r}`,e}function g(e,t){if(!e){let i=typeof t=="function"?t():t||`expect ${e} to be true`;throw new fe(i)}}function Zi(e,t){return g(arguments.length===2,"append expect 2 arguments"),c(e)+c(t)}function Xi(e,t){return g(arguments.length===2,"prepend expect 2 arguments"),c(t)+c(e)}function Ki(e,t){return t?(t=Be(c(t)),c(e).replace(new RegExp(`^[${t}]+`,"g"),"")):c(e).replace(/^\s+/,"")}function er(e){return c(e).toLowerCase()}function tr(e){return c(e).toUpperCase()}function ir(e,t){return c(e).split(String(t)).join("")}function rr(e,t){return c(e).replace(String(t),"")}function sr(e,t){return t?(t=Be(c(t)),c(e).replace(new RegExp(`[${t}]+$`,"g"),"")):c(e).replace(/\s+$/,"")}function nr(e,t){let i=c(e).split(String(t));for(;i.length&&i[i.length-1]==="";)i.pop();return i}function or(e,t){return t?(t=Be(c(t)),c(e).replace(new RegExp(`^[${t}]+`,"g"),"").replace(new RegExp(`[${t}]+$`,"g"),"")):c(e).trim()}function ar(e){return c(e).replace(/\n/g,"")}function lr(e){return e=c(e),e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function ur(e,t,i){return c(e).split(String(t)).join(i)}function cr(e,t,i){return c(e).replace(String(t),i)}function hr(e,t=50,i="..."){return e=c(e),e.length<=t?e:e.substring(0,t-i.length)+i}function pr(e,t=15,i="..."){let r=c(e).split(/\s+/);t<=0&&(t=1);let s=r.slice(0,t).join(" ");return r.length>=t&&(s+=i),s}var Ft=Object.freeze({__proto__:null,escape:kt,escapeOnce:ti,newlineToBr:ii,stripHtml:ri,abs:si,atLeast:ni,atMost:oi,ceil:ai,dividedBy:li,floor:ui,minus:ci,modulo:hi,times:pi,round:di,plus:fi,urlDecode:gi,urlEncode:mi,join:wi,last:yi,first:Ti,reverse:bi,sort:_i,sortNatural:ki,size:qi,map:Si,compact:vi,concat:Li,slice:Fi,where:Oi,uniq:Ri,date:Bi,Default:Hi,json:Qi,raw:Yi,append:Zi,prepend:Xi,lstrip:Ki,downcase:er,upcase:tr,remove:ir,removeFirst:rr,rstrip:sr,split:nr,strip:or,stripNewlines:ar,capitalize:lr,replace:ur,replaceFirst:cr,truncate:hr,truncatewords:pr}),f;(function(e){e[e.Number=1]="Number",e[e.Literal=2]="Literal",e[e.Tag=4]="Tag",e[e.Output=8]="Output",e[e.HTML=16]="HTML",e[e.Filter=32]="Filter",e[e.Hash=64]="Hash",e[e.PropertyAccess=128]="PropertyAccess",e[e.Word=256]="Word",e[e.Range=512]="Range",e[e.Quoted=1024]="Quoted",e[e.Operator=2048]="Operator",e[e.Delimited=12]="Delimited"})(f||(f={}));function dr(e){return!!(v(e)&f.Delimited)}function Ot(e){return v(e)===f.Operator}function Ye(e){return v(e)===f.HTML}function fr(e){return v(e)===f.Output}function Je(e){return v(e)===f.Tag}function Rt(e){return v(e)===f.Quoted}function gr(e){return v(e)===f.Literal}function mr(e){return v(e)===f.Number}function wr(e){return v(e)===f.PropertyAccess}function yr(e){return v(e)===f.Word}function Tr(e){return v(e)===f.Range}function v(e){return e?e.kind:-1}var ge=class extends x{equals(t){return E(h(t))}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return null}},D=class extends x{equals(t){return t instanceof D?!1:(t=h(t),L(t)||T(t)?t.length===0:Ve(t)?Object.keys(t).length===0:!1)}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return""}},me=class extends D{equals(t){return t===!1||E(h(t))?!0:L(t)?/^\s*$/.test(t):super.equals(t)}},at=new ge,xt={true:!0,false:!1,nil:at,null:at,empty:new D,blank:new me},br=/[\da-fA-F]/,lt=/[0-7]/,ut={b:"\b",f:"\f",n:`
`,r:"\r",t:" ",v:"\v"};function ct(e){let t=e.charCodeAt(0);return t>=97?t-87:t>=65?t-55:t-48}function It(e){let t="";for(let i=1;i<e.length-1;i++){if(e[i]!=="\\"){t+=e[i];continue}if(ut[e[i+1]]!==void 0)t+=ut[e[++i]];else if(e[i+1]==="u"){let r=0,s=i+2;for(;s<=i+5&&br.test(e[s]);)r=r*16+ct(e[s++]);i=s-1,t+=String.fromCharCode(r)}else if(!lt.test(e[i+1]))t+=e[++i];else{let r=i+1,s=0;for(;r<=i+3&&lt.test(e[r]);)s=s*8+ct(e[r++]);i=r-1,t+=String.fromCharCode(s)}}return t}function M(e){return F(this,void 0,void 0,function*(){if(!K(e))return e;let t,i=!1,r="next";do{let s=e[r](t);i=s.done,t=s.value,r="next";try{K(t)&&(t=M(t)),At(t)&&(t=yield t)}catch(n){r="throw",t=n}}while(!i);return t})}function A(e){if(!K(e))return e;let t,i=!1,r="next";do{let s=e[r](t);if(i=s.done,t=s.value,r="next",K(t))try{t=A(t)}catch(n){r="throw",t=n}}while(!i);return t}var we=class{constructor(t){this.postfix=[...Lr(t)]}*evaluate(t,i){g(t,"unable to evaluate: context not defined");let r=[];for(let s of this.postfix)if(Ot(s)){let n=r.pop(),o=r.pop(),l=yield qr(t.opts.operators,s,o,n,t);r.push(l)}else r.push(yield w(s,t,i&&this.postfix.length===1));return r[0]}};function*w(e,t,i=!1){if(wr(e))return yield _r(e,t,i);if(Tr(e))return yield vr(e,t);if(gr(e))return Sr(e);if(mr(e))return kr(e);if(yr(e))return e.getText();if(Rt(e))return Ge(e)}function*_r(e,t,i){let r=[];for(let s of e.props)r.push(yield w(s,t,!1));try{return yield t._get([e.propertyName,...r])}catch(s){if(i&&s.name==="InternalUndefinedVariableError")return null;throw new pe(s,e)}}function kr(e){let t=e.whole.content+"."+(e.decimal?e.decimal.content:"");return Number(t)}function Ge(e){return It(e.getText())}function qr(e,t,i,r,s){let n=e[t.operator];return n(i,r,s)}function Sr(e){return xt[e.literal]}function*vr(e,t){let i=yield w(e.lhs,t),r=yield w(e.rhs,t);return mt(+i,+r+1)}function*Lr(e){let t=[];for(let i of e)if(Ot(i)){for(;t.length&&t[t.length-1].getPrecedence()>i.getPrecedence();)yield t.pop();t.push(i)}else yield i;for(;t.length;)yield t.pop()}var _=class{constructor(t,i,r,s,n){this.kind=t,this.input=i,this.begin=r,this.end=s,this.file=n}getText(){return this.input.slice(this.begin,this.end)}getPosition(){let[t,i]=[1,1];for(let r=0;r<this.begin;r++)this.input[r]===`
`?(t++,i=1):i++;return[t,i]}size(){return this.end-this.begin}},Q=class extends _{constructor(t,i,r,s,n,o,l,a){super(t,r,s,n,a),this.trimLeft=!1,this.trimRight=!1,this.content=this.getText();let u=i[0]==="-",p=We(i)==="-";this.content=i.slice(u?1:0,p?-1:i.length).trim(),this.trimLeft=u||o,this.trimRight=p||l}};function Fr(e,t){let i=!1;for(let r=0;r<e.length;r++){let s=e[r];!dr(s)||(!i&&s.trimLeft&&Or(e[r-1],t.greedy),Je(s)&&(s.name==="raw"?i=!0:s.name==="endraw"&&(i=!1)),!i&&s.trimRight&&Rr(e[r+1],t.greedy))}}function Or(e,t){if(!e||!Ye(e))return;let i=t?ae:bt;for(;d[e.input.charCodeAt(e.end-1-e.trimRight)]&i;)e.trimRight++}function Rr(e,t){if(!e||!Ye(e))return;let i=t?ae:bt;for(;d[e.input.charCodeAt(e.begin+e.trimLeft)]&i;)e.trimLeft++;e.input.charAt(e.begin+e.trimLeft)===`
`&&e.trimLeft++}var ye=class extends _{constructor(t,i){super(f.Number,t.input,t.begin,i?i.end:t.end,t.file),this.whole=t,this.decimal=i}},U=class extends _{constructor(t,i,r,s){super(f.Word,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.content=this.getText()}isNumber(t=!1){let i=t&&d[this.input.charCodeAt(this.begin)]&Zt?this.begin+1:this.begin;for(let r=i;r<this.end;r++)if(!(d[this.input.charCodeAt(r)]&Gt))return!1;return!0}},Te=class extends _{constructor(t,i,r,s){super(f.Literal,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.literal=this.getText()}},ht={"==":1,"!=":1,">":1,"<":1,">=":1,"<=":1,contains:1,and:0,or:0},be=class extends _{constructor(t,i,r,s){super(f.Operator,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.operator=this.getText()}getPrecedence(){let t=this.getText();return t in ht?ht[t]:1}},re=class extends _{constructor(t,i,r){super(f.PropertyAccess,t.input,t.begin,r,t.file),this.variable=t,this.props=i,this.propertyName=this.variable instanceof U?this.variable.getText():It(this.variable.getText())}},_e=class extends _{constructor(t,i,r,s,n,o){super(f.Filter,r,s,n,o),this.name=t,this.args=i}},ke=class extends _{constructor(t,i,r,s,n,o){super(f.Hash,t,i,r,o),this.input=t,this.begin=i,this.end=r,this.name=s,this.value=n,this.file=o}},qe=class extends _{constructor(t,i,r,s){super(f.Quoted,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s}},se=class extends _{constructor(t,i,r,s){super(f.HTML,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.trimLeft=0,this.trimRight=0}getContent(){return this.input.slice(this.begin+this.trimLeft,this.end-this.trimRight)}},Se=class extends _{constructor(t,i,r,s,n,o){super(f.Range,t,i,r,o),this.input=t,this.begin=i,this.end=r,this.lhs=s,this.rhs=n,this.file=o}},ve=class extends Q{constructor(t,i,r,s,n){let{trimOutputLeft:o,trimOutputRight:l,outputDelimiterLeft:a,outputDelimiterRight:u}=s,p=t.slice(i+a.length,r-u.length);super(f.Output,p,t,i,r,o,l,n)}};function xr(e,t,i,r=e.length){let s=i,n=t,o;for(;s[e[n]]&&n<r;)s=s[e[n++]],s.end&&(o=s);return!o||o.needBoundary&&d[e.charCodeAt(n)]&He?-1:n}var Le=class extends Q{constructor(t,i,r,s,n){let o=t.slice(i,r);if(super(f.Tag,o,t,i,r,!1,!1,n),!/\S/.test(o))this.name="",this.args="";else{let l=new m(this.content,s.operatorsTrie);if(this.name=l.readTagName(),!this.name)throw new H("illegal liquid tag syntax",this);l.skipBlank(),this.args=l.remaining()}}},m=class{constructor(t,i=P.operatorsTrie,r=""){this.input=t,this.trie=i,this.file=r,this.p=0,this.rawBeginAt=-1,this.N=t.length}readExpression(){return new we(this.readExpressionTokens())}*readExpressionTokens(){let t=this.readValue();if(!!t)for(yield t;this.p<this.N;){let i=this.readOperator();if(!i)return;let r=this.readValue();if(!r)return;yield i,yield r}}readOperator(){this.skipBlank();let t=xr(this.input,this.p,this.trie);if(t!==-1)return new be(this.input,this.p,this.p=t,this.file)}readFilters(){let t=[];for(;;){let i=this.readFilter();if(!i)return t;t.push(i)}}readFilter(){if(this.skipBlank(),this.end())return null;g(this.peek()==="|",()=>`unexpected token at ${this.snapshot()}`),this.p++;let t=this.p,i=this.readIdentifier();if(!i.size())return null;let r=[];if(this.skipBlank(),this.peek()===":")do{++this.p;let s=this.readFilterArg();s&&r.push(s),this.skipBlank(),g(this.end()||this.peek()===","||this.peek()==="|",()=>`unexpected character ${this.snapshot()}`)}while(this.peek()===",");return new _e(i.getText(),r,this.input,t,this.p,this.file)}readFilterArg(){let t=this.readValue();if(!t)return;if(this.skipBlank(),this.peek()!==":")return t;++this.p;let i=this.readValue();return[t.getText(),i]}readTopLevelTokens(t=P){let i=[];for(;this.p<this.N;){let r=this.readTopLevelToken(t);i.push(r)}return Fr(i,t),i}readTopLevelToken(t){let{tagDelimiterLeft:i,outputDelimiterLeft:r}=t;return this.rawBeginAt>-1?this.readEndrawOrRawContent(t):this.match(i)?this.readTagToken(t):this.match(r)?this.readOutputToken(t):this.readHTMLToken([i,r])}readHTMLToken(t){let i=this.p;for(;this.p<this.N&&!t.some(r=>this.match(r));)++this.p;return new se(this.input,i,this.p,this.file)}readTagToken(t=P){let{file:i,input:r}=this,s=this.p;if(this.readToDelimiter(t.tagDelimiterRight)===-1)throw this.mkError(`tag ${this.snapshot(s)} not closed`,s);let n=new ne(r,s,this.p,t,i);return n.name==="raw"&&(this.rawBeginAt=s),n}readToDelimiter(t){for(;this.p<this.N;){if(this.peekType()&st){this.readQuoted();continue}if(++this.p,this.rmatch(t))return this.p}return-1}readOutputToken(t=P){let{file:i,input:r}=this,{outputDelimiterRight:s}=t,n=this.p;if(this.readToDelimiter(s)===-1)throw this.mkError(`output ${this.snapshot(n)} not closed`,n);return new ve(r,n,this.p,t,i)}readEndrawOrRawContent(t){let{tagDelimiterLeft:i,tagDelimiterRight:r}=t,s=this.p,n=this.readTo(i)-i.length;for(;this.p<this.N;){if(this.readIdentifier().getText()!=="endraw"){n=this.readTo(i)-i.length;continue}for(;this.p<=this.N;){if(this.rmatch(r)){let o=this.p;return s===n?(this.rawBeginAt=-1,new ne(this.input,s,o,t,this.file)):(this.p=n,new se(this.input,s,n,this.file))}if(this.rmatch(i))break;this.p++}}throw this.mkError(`raw ${this.snapshot(this.rawBeginAt)} not closed`,s)}readLiquidTagTokens(t=P){let i=[];for(;this.p<this.N;){let r=this.readLiquidTagToken(t);r.name&&i.push(r)}return i}readLiquidTagToken(t){let{file:i,input:r}=this,s=this.p,n=this.N;return this.readToDelimiter(`
`)!==-1&&(n=this.p),new Le(r,s,n,t,i)}mkError(t,i){return new H(t,new U(this.input,i,this.N,this.file))}snapshot(t=this.p){return JSON.stringify(Dt(this.input.slice(t),16))}readWord(){return console.warn("Tokenizer#readWord() will be removed, use #readIdentifier instead"),this.readIdentifier()}readIdentifier(){this.skipBlank();let t=this.p;for(;this.peekType()&He;)++this.p;return new U(this.input,t,this.p,this.file)}readTagName(){return this.skipBlank(),this.input[this.p]==="#"?this.input.slice(this.p,++this.p):this.readIdentifier().getText()}readHashes(t){let i=[];for(;;){let r=this.readHash(t);if(!r)return i;i.push(r)}}readHash(t){this.skipBlank(),this.peek()===","&&++this.p;let i=this.p,r=this.readIdentifier();if(!r.size())return;let s;this.skipBlank();let n=t?"=":":";return this.peek()===n&&(++this.p,s=this.readValue()),new ke(this.input,i,this.p,r,s,this.file)}remaining(){return this.input.slice(this.p)}advance(t=1){this.p+=t}end(){return this.p>=this.N}readTo(t){for(;this.p<this.N;)if(++this.p,this.rmatch(t))return this.p;return-1}readValue(){let t=this.readQuoted()||this.readRange();if(t)return t;if(this.peek()==="["){this.p++;let n=this.readQuoted();return!n||this.peek()!=="]"?void 0:(this.p++,new re(n,[],this.p))}let i=this.readIdentifier();if(!i.size())return;let r=i.isNumber(!0),s=[];for(;;)if(this.peek()==="["){r=!1,this.p++;let n=this.readValue()||new U(this.input,this.p,this.p,this.file);this.readTo("]"),s.push(n)}else if(this.peek()==="."&&this.peek(1)!=="."){this.p++;let n=this.readIdentifier();if(!n.size())break;n.isNumber()||(r=!1),s.push(n)}else break;return!s.length&&xt.hasOwnProperty(i.content)?new Te(this.input,i.begin,i.end,this.file):r?new ye(i,s[0]):new re(i,s,this.p)}readRange(){this.skipBlank();let t=this.p;if(this.peek()!=="(")return;++this.p;let i=this.readValueOrThrow();this.p+=2;let r=this.readValueOrThrow();return++this.p,new Se(this.input,t,this.p,i,r,this.file)}readValueOrThrow(){let t=this.readValue();return g(t,()=>`unexpected token ${this.snapshot()}, value expected`),t}readQuoted(){this.skipBlank();let t=this.p;if(!(this.peekType()&st))return;++this.p;let i=!1;for(;this.p<this.N&&(++this.p,!(this.input[this.p-1]===this.input[t]&&!i));)i?i=!1:this.input[this.p-1]==="\\"&&(i=!0);return new qe(this.input,t,this.p,this.file)}*readFileNameTemplate(t){let{outputDelimiterLeft:i}=t,r=[","," ",i],s=new Set(r);for(;this.p<this.N&&!s.has(this.peek());)yield this.match(i)?this.readOutputToken(t):this.readHTMLToken(r)}match(t){for(let i=0;i<t.length;i++)if(t[i]!==this.input[this.p+i])return!1;return!0}rmatch(t){for(let i=0;i<t.length;i++)if(t[t.length-1-i]!==this.input[this.p-1-i])return!1;return!0}peekType(t=0){return d[this.input.charCodeAt(this.p+t)]}peek(t=0){return this.input[this.p+t]}skipBlank(){for(;this.peekType()&ae;)++this.p}},ne=class extends Q{constructor(t,i,r,s,n){let{trimTagLeft:o,trimTagRight:l,tagDelimiterLeft:a,tagDelimiterRight:u}=s,p=t.slice(i+a.length,r-u.length);super(f.Tag,p,t,i,r,o,l,n);let y=new m(this.content,s.operatorsTrie);if(this.name=y.readTagName(),!this.name)throw new H("illegal tag syntax",this);y.skipBlank(),this.args=y.remaining()}},Fe=class{constructor(t,i){this.handlers={},this.stopRequested=!1,this.tokens=t,this.parseToken=i}on(t,i){return this.handlers[t]=i,this}trigger(t,i){let r=this.handlers[t];return r?(r.call(this,i),!0):!1}start(){this.trigger("start");let t;for(;!this.stopRequested&&(t=this.tokens.shift());){if(this.trigger("token",t)||Je(t)&&this.trigger(`tag:${t.name}`,t))continue;let i=this.parseToken(t,this.tokens);this.trigger("template",i)}return this.stopRequested||this.trigger("end"),this}stop(){return this.stopRequested=!0,this}},I=class{constructor(t,i){this.hash={};let r=new m(t,{});for(let s of r.readHashes(i))this.hash[s.name.content]=s.value}*render(t){let i={};for(let r of Object.keys(this.hash))i[r]=this.hash[r]===void 0?!0:yield w(this.hash[r],t);return i}};function Ir(e){return T(e)}var Y=class{constructor(t,i,r,s){this.name=t,this.impl=i||yt,this.args=r,this.liquid=s}*render(t,i){let r=[];for(let s of this.args)Ir(s)?r.push([s[0],yield w(s[1],i)]):r.push(yield w(s,i));return this.impl.apply({context:i,liquid:this.liquid},[t,...r])}},S=class{constructor(t,i){this.filters=[];let r=new m(t,i.options.operatorsTrie);this.initial=r.readExpression(),this.filters=r.readFilters().map(({name:s,args:n})=>new Y(s,i.filters.get(s),n,i))}*value(t,i){i=i||t.opts.lenientIf&&this.filters.length>0&&this.filters[0].name==="default";let r=yield this.initial.evaluate(t,i);for(let s of this.filters)r=yield s.render(r,t);return r}},Er={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.key=t.readIdentifier().content,t.skipBlank(),g(t.peek()==="=",()=>`illegal token ${e.getText()}`),t.advance(),this.value=new S(t.remaining(),this.liquid)},render:function*(e){e.bottom()[this.key]=yield this.value.value(e,this.liquid.options.lenientIf)}},J=class extends x{constructor(t,i,r){super(),this.i=0,this.length=t,this.name=`${r}-${i}`}next(){this.i++}index0(){return this.i}index(){return this.i+1}first(){return this.i===0}last(){return this.i===this.length-1}rindex(){return this.length-this.i}rindex0(){return this.length-this.i-1}valueOf(){return JSON.stringify(this)}},pt=["offset","limit","reversed"],Pr={type:"block",parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier(),s=i.readIdentifier(),n=i.readValue();g(r.size()&&s.content==="in"&&n,()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=n,this.hash=new I(i.remaining()),this.templates=[],this.elseTemplates=[];let o,l=this.liquid.parser.parseStream(t).on("start",()=>o=this.templates).on("tag:else",()=>o=this.elseTemplates).on("tag:endfor",()=>l.stop()).on("template",a=>o.push(a)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});l.start()},render:function*(e,t){let i=this.liquid.renderer,r=Qe(yield w(this.collection,e));if(!r.length){yield i.renderTemplates(this.elseTemplates,e,t);return}let s="continue-"+this.variable+"-"+this.collection.getText();e.push({continue:e.getRegister(s)});let n=yield this.hash.render(e);e.pop(),r=(this.liquid.options.orderedFilterParameters?Object.keys(n).filter(a=>pt.includes(a)):pt.filter(a=>n[a]!==void 0)).reduce((a,u)=>u==="offset"?Mr(a,n.offset):u==="limit"?Ar(a,n.limit):Nr(a),r),e.setRegister(s,(n.offset||0)+r.length);let l={forloop:new J(r.length,this.collection.getText(),this.variable)};e.push(l);for(let a of r){if(l[this.variable]=a,yield i.renderTemplates(this.templates,e,t),t.break){t.break=!1;break}t.continue=!1,l.forloop.next()}e.pop()}};function Nr(e){return[...e].reverse()}function Mr(e,t){return e.slice(t)}function Ar(e,t){return e.slice(0,t)}var Cr={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.variable=$r(i),g(this.variable,()=>`${e.args} not valid identifier`),this.templates=[];let r=this.liquid.parser.parseStream(t);r.on("tag:endcapture",()=>r.stop()).on("template",s=>this.templates.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),r.start()},render:function*(e){let i=yield this.liquid.renderer.renderTemplates(this.templates,e);e.bottom()[this.variable]=i}};function $r(e){let t=e.readIdentifier().content;if(t)return t;let i=e.readQuoted();if(i)return Ge(i)}var Ur={parse:function(e,t){this.cond=new S(e.args,this.liquid),this.cases=[],this.elseTemplates=[];let i=[],r=this.liquid.parser.parseStream(t).on("tag:when",s=>{i=[];let n=new m(s.args,this.liquid.options.operatorsTrie);for(;!n.end();){let o=n.readValue();this.cases.push({val:o,templates:i}),n.readTo(",")}}).on("tag:else",()=>i=this.elseTemplates).on("tag:endcase",()=>r.stop()).on("template",s=>i.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});r.start()},render:function*(e,t){let i=this.liquid.renderer,r=h(yield this.cond.value(e,e.opts.lenientIf));for(let s of this.cases)if((yield w(s.val,e,e.opts.lenientIf))===r){yield i.renderTemplates(s.templates,e,t);return}yield i.renderTemplates(this.elseTemplates,e,t)}},zr={parse:function(e,t){let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endcomment"&&i.stop()}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()}},Oe;(function(e){e[e.OUTPUT=0]="OUTPUT",e[e.STORE=1]="STORE"})(Oe||(Oe={}));var j=Oe,Dr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);for(this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;!i.end();){i.skipBlank();let r=i.p,s=i.readIdentifier();if((s.content==="with"||s.content==="for")&&(i.skipBlank(),i.peek()!==":")){let n=i.readValue();if(n){let o=i.p,l=i.readIdentifier(),a;l.content==="as"?a=i.readIdentifier():i.p=o,this[s.content]={value:n,alias:a&&a.content},i.skipBlank(),i.peek()===","&&i.advance();continue}}i.p=r;break}this.hash=new I(i.remaining())},render:function*(e,t){let{liquid:i,hash:r}=this,s=yield this.renderFilePath(this.file,e,i);g(s,()=>`illegal filename "${s}"`);let n=new C({},e.opts,{sync:e.sync,globals:e.globals,strictVariables:e.strictVariables}),o=n.bottom();if(X(o,yield r.render(e)),this.with){let{value:l,alias:a}=this.with;o[a||s]=yield w(l,e)}if(this.for){let{value:l,alias:a}=this.for,u=yield w(l,e);u=Qe(u),o.forloop=new J(u.length,l.getText(),a);for(let p of u){o[a]=p;let y=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(y,n,t),o.forloop.next()}}else{let l=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(l,n,t)}}};function Ze(e,t){if(t.options.dynamicPartials){let s=e.readValue();if(s===void 0)throw new TypeError(`illegal argument "${e.input}"`);if(s.getText()==="none")return null;if(Rt(s)){let n=t.parse(Ge(s));return dt(n)}return s}let i=[...e.readFileNameTemplate(t.options)],r=dt(t.parser.parseTokens(i));return r==="none"?null:r}function dt(e){return e.length===1&&Ye(e[0].token)?e[0].token.getContent():e}function*Xe(e,t,i){return typeof e=="string"?e:Array.isArray(e)?i.renderer.renderTemplates(e,t):yield w(e,t)}var Wr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;let r=i.p;i.readIdentifier().content==="with"?(i.skipBlank(),i.peek()!==":"?this.withVar=i.readValue():i.p=r):i.p=r,this.hash=new I(i.remaining(),this.liquid.options.jekyllInclude)},render:function*(e,t){let{liquid:i,hash:r,withVar:s}=this,{renderer:n}=i,o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=e.saveRegister("blocks","blockMode");e.setRegister("blocks",{}),e.setRegister("blockMode",j.OUTPUT);let a=yield r.render(e);s&&(a[o]=yield w(s,e));let u=yield i._parsePartialFile(o,e.sync,this.currentFile);e.push(e.opts.jekyllInclude?{include:a}:a),yield n.renderTemplates(u,e,t),e.pop(),e.restoreRegister(l)}},Vr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0),t.write(c(--i[this.variable]))}},Br={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie),i=t.readValue();for(t.skipBlank(),this.candidates=[],i&&(t.peek()===":"?(this.group=i,t.advance()):this.candidates.push(i));!t.end();){let r=t.readValue();r&&this.candidates.push(r),t.readTo(",")}g(this.candidates.length,()=>`empty candidates: ${e.getText()}`)},render:function*(e,t){let r=`cycle:${yield w(this.group,e)}:`+this.candidates.join(","),s=e.getRegister("cycle"),n=s[r];n===void 0&&(n=s[r]=0);let o=this.candidates[n];n=(n+1)%this.candidates.length,s[r]=n;let l=yield w(o,e);t.write(l)}},jr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endif",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,templates:s}of this.branches){let n=yield r.value(e,e.opts.lenientIf);if(N(n,e)){yield i.renderTemplates(s,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Hr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0);let r=i[this.variable];i[this.variable]++,t.write(c(r))}},Qr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file,this.hash=new I(i.remaining()),this.tpls=this.liquid.parser.parseTokens(t)},render:function*(e,t){let{liquid:i,hash:r,file:s}=this,{renderer:n}=i;if(s===null){e.setRegister("blockMode",j.OUTPUT),yield n.renderTemplates(this.tpls,e,t);return}let o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=yield i._parseLayoutFile(o,e.sync,this.currentFile);e.setRegister("blockMode",j.STORE);let a=yield n.renderTemplates(this.tpls,e),u=e.getRegister("blocks");u[""]===void 0&&(u[""]=(p,y)=>y.write(a)),e.setRegister("blockMode",j.OUTPUT),e.push(yield r.render(e)),yield n.renderTemplates(l,e,t),e.pop()}},oe=class extends x{constructor(t=()=>""){super(),this.superBlockRender=t}super(){return this.superBlockRender()}},Yr={parse(e,t){let i=/\w+/.exec(e.args);this.block=i?i[0]:"",this.tpls=[],this.liquid.parser.parseStream(t).on("tag:endblock",function(){this.stop()}).on("template",r=>this.tpls.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},*render(e,t){let i=this.getBlockRender(e);e.getRegister("blockMode")===j.STORE?e.getRegister("blocks")[this.block]=i:yield i(new oe,t)},getBlockRender(e){let{liquid:t,tpls:i}=this,r=e.getRegister("blocks")[this.block],s=function*(n,o){e.push({block:n}),yield t.renderer.renderTemplates(i,e,o),e.pop()};return r?(n,o)=>r(new oe(()=>s(n,o)),o):s}},Jr={parse:function(e,t){this.tokens=[];let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endraw"?i.stop():this.tokens.push(r)}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()},render:function(){return this.tokens.map(e=>e.getText()).join("")}},Re=class extends J{constructor(t,i,r,s){super(t,r,s),this.length=t,this.cols=i}row(){return Math.floor(this.i/this.cols)+1}col0(){return this.i%this.cols}col(){return this.col0()+1}col_first(){return this.col0()===0}col_last(){return this.col()===this.cols}},Gr={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier();i.skipBlank();let s=i.readIdentifier();g(s&&s.content==="in",()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=i.readValue(),this.hash=new I(i.remaining()),this.templates=[];let n,o=this.liquid.parser.parseStream(t).on("start",()=>n=this.templates).on("tag:endtablerow",()=>o.stop()).on("template",l=>n.push(l)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});o.start()},render:function*(e,t){let i=Qe(yield w(this.collection,e)),r=yield this.hash.render(e),s=r.offset||0,n=r.limit===void 0?i.length:r.limit;i=i.slice(s,s+n);let o=r.cols||i.length,l=this.liquid.renderer,a=new Re(i.length,o,this.collection.getText(),this.variable),u={tablerowloop:a};e.push(u);for(let p=0;p<i.length;p++,a.next())u[this.variable]=i[p],a.col0()===0&&(a.row()!==1&&t.write("</tr>"),t.write(`<tr class="row${a.row()}">`)),t.write(`<td class="col${a.col()}">`),yield l.renderTemplates(this.templates,e,t),t.write("</td>");i.length&&t.write("</tr>"),e.pop()}},Zr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),test:je,templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),test:N,templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endunless",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,test:s,templates:n}of this.branches){let o=yield r.value(e,e.opts.lenientIf);if(s(o,e)){yield i.renderTemplates(n,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Xr={render:function(e,t){t.break=!0}},Kr={render:function(e,t){t.continue=!0}},es={parse:function(e){this.value=new S(e.args,this.liquid)},render:function*(e,t){let i=yield this.value.value(e,!1);t.write(i)}},ts={parse:function(e){let i=new m(e.args,this.liquid.options.operatorsTrie).readLiquidTagTokens(this.liquid.options);this.tpls=this.liquid.parser.parseTokens(i)},render:function*(e,t){yield this.liquid.renderer.renderTemplates(this.tpls,e,t)}},is={parse:function(e,t){if(e.args.search(/\n\s*[^#\s]/g)!==-1)throw new Error("every line of an inline comment must start with a '#' character")}},rs={assign:Er,for:Pr,capture:Cr,case:Ur,comment:zr,include:Wr,render:Dr,decrement:Vr,increment:Hr,cycle:Br,if:jr,layout:Qr,block:Yr,raw:Jr,tablerow:Gr,unless:Zr,break:Xr,continue:Kr,echo:es,liquid:ts,"#":is};var Et=new Map;le(Ft,(e,t)=>{Et.set(ue(t),e)});var P={root:["."],layouts:["."],partials:["."],relativeReference:!0,jekyllInclude:!1,cache:void 0,extname:"",fs:Jt,dynamicPartials:!0,jsTruthy:!1,trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",preserveTimezones:!1,strictFilters:!1,strictVariables:!1,ownPropertyOnly:!1,lenientIf:!1,globals:{},keepOutputType:!1,operators:rt,operatorsTrie:_t(rt)};function ss(e){if(e.hasOwnProperty("operators")&&(e.operatorsTrie=_t(e.operators)),e.hasOwnProperty("root")&&(e.hasOwnProperty("partials")||(e.partials=e.root),e.hasOwnProperty("layouts")||(e.layouts=e.root)),e.hasOwnProperty("cache")){let t;typeof e.cache=="number"?t=e.cache>0?new te(e.cache):void 0:typeof e.cache=="object"?t=e.cache:t=e.cache?new te(1024):void 0,e.cache=t}return e=Object.assign(Object.assign(Object.assign({},P),e.jekyllInclude?{dynamicPartials:!1}:{}),e),!e.fs.dirname&&e.relativeReference&&(console.warn("[LiquidJS] `fs.dirname` is required for relativeReference, set relativeReference to `false` to suppress this warning, or provide implementation for `fs.dirname`"),e.relativeReference=!1),e.root=Z(e.root),e.partials=Z(e.partials),e.layouts=Z(e.layouts),e.outputEscape=e.outputEscape&&ns(e.outputEscape),e}function ns(e){if(L(e)){let t=Et.get(e);return g(q(t),`filter "${e}" not found`),t}else return g(q(e),"`outputEscape` need to be of type string or function"),e}function Z(e){let t=[];return T(e)&&(t=e),L(e)&&(t=[e]),t}var C=class{constructor(t={},i=P,r={}){var s,n;this.scopes=[{}],this.registers={},this.sync=!!r.sync,this.opts=i,this.globals=(s=r.globals)!==null&&s!==void 0?s:i.globals,this.environments=t,this.strictVariables=(n=r.strictVariables)!==null&&n!==void 0?n:this.opts.strictVariables}getRegister(t){return this.registers[t]=this.registers[t]||{}}setRegister(t,i){return this.registers[t]=i}saveRegister(...t){return t.map(i=>[i,this.getRegister(i)])}restoreRegister(t){return t.forEach(([i,r])=>this.setRegister(i,r))}getAll(){return[this.globals,this.environments,...this.scopes].reduce((t,i)=>X(t,i),{})}get(t){return A(this._get(t))}*_get(t){let i=this.findScope(t[0]);return yield this._getFromScope(i,t)}getFromScope(t,i){return A(this._getFromScope(t,i))}*_getFromScope(t,i){L(i)&&(i=i.split("."));for(let r=0;r<i.length;r++)if(t=yield os(t,i[r],this.opts.ownPropertyOnly),E(t)&&this.strictVariables)throw new de(i.slice(0,r+1).join("."));return t}push(t){return this.scopes.push(t)}pop(){return this.scopes.pop()}bottom(){return this.scopes[0]}findScope(t){for(let i=this.scopes.length-1;i>=0;i--){let r=this.scopes[i];if(t in r)return r}return t in this.environments?this.environments:this.globals}};function os(e,t,i){if(E(e))return e;if(e=gt(e),T(e)&&t<0)return e[e.length+ +t];let r=as(e,t,i);return r===void 0&&e instanceof x?e.liquidMethodMissing(t):q(r)?r.call(e):t==="size"?cs(e):t==="first"?ls(e):t==="last"?us(e):r}function as(e,t,i){if(!(i&&!Object.hasOwnProperty.call(e,t)))return e[t]}function ls(e){return T(e)?e[0]:e.first}function us(e){return T(e)?e[e.length-1]:e.last}function cs(e){if(e.hasOwnProperty("size")||e.size!==void 0)return e.size;if(T(e)||L(e))return e.length;if(typeof e=="object")return Object.keys(e).length}var $;(function(e){e.Partials="partials",e.Layouts="layouts",e.Root="root"})($||($={}));var xe=class{constructor(t){if(this.options=t,t.relativeReference){let i=t.fs.sep;g(i,"`fs.sep` is required for relative reference");let r=new RegExp(["."+i,".."+i,"./","../"].map(s=>Ct(s)).join("|"));this.shouldLoadRelative=s=>r.test(s)}else this.shouldLoadRelative=i=>!1;this.contains=this.options.fs.contains||(()=>!0)}*lookup(t,i,r,s){let{fs:n}=this.options,o=this.options[i];for(let l of this.candidates(t,o,s,i!==$.Root))if(r?n.existsSync(l):yield n.exists(l))return l;throw this.lookupError(t,o)}*candidates(t,i,r,s){let{fs:n,extname:o}=this.options;if(this.shouldLoadRelative(t)&&r){let l=n.resolve(this.dirname(r),t,o);for(let a of i)if(!s||this.contains(a,l)){yield l;break}}for(let l of i){let a=n.resolve(l,t,o);(!s||this.contains(l,a))&&(yield a)}if(n.fallback!==void 0){let l=n.fallback(t);l!==void 0&&(yield l)}}dirname(t){let i=this.options.fs;return g(i.dirname,"`fs.dirname` is required for relative reference"),i.dirname(t)}lookupError(t,i){let r=new Error("ENOENT");return r.message=`ENOENT: Failed to lookup "${t}" in "${i}"`,r.code="ENOENT",r}},Ie=class{constructor(){this.buffer=""}write(t){this.buffer+=c(t)}},Ee=class{constructor(){throw this.buffer="",this.stream=null,new Error("streaming not supported in browser")}},Pe=class{constructor(){this.buffer=""}write(t){t=h(t),typeof t!="string"&&this.buffer===""?this.buffer=t:this.buffer=c(this.buffer)+c(t)}},Ne=class{renderTemplatesToNodeStream(t,i){let r=new Ee;return Promise.resolve().then(()=>M(this.renderTemplates(t,i,r))).then(()=>r.end(),s=>r.error(s)),r.stream}*renderTemplates(t,i,r){r||(r=i.opts.keepOutputType?new Pe:new Ie);for(let s of t)try{let n=yield s.render(i,r);if(n&&r.write(n),r.break||r.continue)break}catch(n){throw ie.is(n)?n:new ie(n,s)}return r.buffer}},G=class{constructor(t){this.token=t}},Me=class extends G{constructor(t,i,r){super(t),this.name=t.name;let s=r.tags.get(t.name);this.impl=Object.create(s),this.impl.liquid=r,this.impl.parse&&this.impl.parse(t,i)}*render(t,i){let r=yield new I(this.token.args).render(t),s=this.impl;if(q(s.render))return yield s.render(t,i,r)}},Ae=class extends G{constructor(t,i){super(t),this.value=new S(t.content,i);let r=this.value.filters,s=i.options.outputEscape;r.length&&r[r.length-1].name==="raw"?r.pop():s&&r.push(new Y(toString.call(s),s,[],i))}*render(t,i){let r=yield this.value.value(t,!1);i.write(r)}},Ce=class extends G{constructor(t){super(t),this.str=t.getContent()}*render(t,i){i.write(this.str)}},$e=class{constructor(t){this.liquid=t,this.cache=this.liquid.options.cache,this.fs=this.liquid.options.fs,this.parseFile=this.cache?this._parseFileCached:this._parseFile,this.loader=new xe(this.liquid.options)}parse(t,i){let s=new m(t,this.liquid.options.operatorsTrie,i).readTopLevelTokens(this.liquid.options);return this.parseTokens(s)}parseTokens(t){let i,r=[];for(;i=t.shift();)r.push(this.parseToken(i,t));return r}parseToken(t,i){try{return Je(t)?new Me(t,i,this.liquid):fr(t)?new Ae(t,this.liquid):new Ce(t)}catch(r){throw new he(r,t)}}parseStream(t){return new Fe(t,(i,r)=>this.parseToken(i,r))}*_parseFileCached(t,i,r=$.Root,s){let n=this.cache,o=this.loader.shouldLoadRelative(t)?s+","+t:r+":"+t,l=yield n.read(o);if(l)return l;let a=this._parseFile(t,i,r,s),u=i?yield a:M(a);n.write(o,u);try{return yield u}catch(p){throw n.remove(o),p}}*_parseFile(t,i,r=$.Root,s){let n=yield this.loader.lookup(t,r,i,s);return this.liquid.parse(i?this.fs.readFileSync(n):yield this.fs.readFile(n),n)}},Ue=class{constructor(){this.impls={}}get(t){let i=this.impls[t];return g(i,()=>`tag "${t}" not found`),i}set(t,i){this.impls[t]=i}},ze=class{constructor(t,i){this.strictFilters=t,this.liquid=i,this.impls={}}get(t){let i=this.impls[t];return g(i||!this.strictFilters,()=>`undefined filter: ${t}`),i}set(t,i){this.impls[t]=i}create(t,i){return new Y(t,this.get(t),i,this.liquid)}};var W=class{constructor(t={}){this.options=ss(t),this.parser=new $e(this),this.renderer=new Ne,this.filters=new ze(this.options.strictFilters,this),this.tags=new Ue,le(rs,(i,r)=>this.registerTag(ue(r),i)),le(Ft,(i,r)=>this.registerFilter(ue(r),i))}parse(t,i){return this.parser.parse(t,i)}_render(t,i,r){let s=new C(i,this.options,r);return this.renderer.renderTemplates(t,s)}render(t,i,r){return F(this,void 0,void 0,function*(){return M(this._render(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}renderSync(t,i,r){return A(this._render(t,i,Object.assign(Object.assign({},r),{sync:!0})))}renderToNodeStream(t,i,r={}){let s=new C(i,this.options,r);return this.renderer.renderTemplatesToNodeStream(t,s)}_parseAndRender(t,i,r){let s=this.parse(t);return this._render(s,i,r)}parseAndRender(t,i,r){return F(this,void 0,void 0,function*(){return M(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}parseAndRenderSync(t,i,r){return A(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!0})))}_parsePartialFile(t,i,r){return this.parser.parseFile(t,i,$.Partials,r)}_parseLayoutFile(t,i,r){return this.parser.parseFile(t,i,$.Layouts,r)}parseFile(t){return F(this,void 0,void 0,function*(){return M(this.parser.parseFile(t,!1))})}parseFileSync(t){return A(this.parser.parseFile(t,!0))}renderFile(t,i,r){return F(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.render(s,i,r)})}renderFileSync(t,i,r){let s=this.parseFileSync(t);return this.renderSync(s,i,r)}renderFileToNodeStream(t,i,r){return F(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.renderToNodeStream(s,i,r)})}_evalValue(t,i){let r=new S(t,this),s=i instanceof C?i:new C(i,this.options);return r.value(s,!1)}evalValue(t,i){return F(this,void 0,void 0,function*(){return M(this._evalValue(t,i))})}evalValueSync(t,i){return A(this._evalValue(t,i))}registerFilter(t,i){this.filters.set(t,i)}registerTag(t,i){this.tags.set(t,i)}plugin(t){return t.call(this,W)}express(){let t=this,i=!0;return function(r,s,n){if(i){i=!1;let o=Z(this.root);t.options.root.unshift(...o),t.options.layouts.unshift(...o),t.options.partials.unshift(...o)}t.renderFile(r,s).then(o=>n(null,o),n)}}};import{html as hs,unsafeStatic as ps}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/static/+esm";var Ke=e=>function(){let t=(a,u)=>e.utils.url.getVariantUrl(a.url,u==null?void 0:u.id),i=(a,...u)=>e.utils.url.getImageUrl(a,Pt(u)),r=(a="")=>e.utils.url.getFileUrl(a),s=(a="",u)=>e.utils.url.getImageUrl({src:e.utils.url.getFileUrl(a.replace(".",`_${u}.`))}),n=a=>e.utils.money.formatMoney(a),o=(a,...u)=>{try{return u.length?this.parseAndRenderSync(e.theme.translate(a),Pt(u)):e.theme.translate(a)}catch(p){return a}},l=(a="")=>a.toLowerCase().trim().replace(/[^a-zA-Z0-9]/g,"-").replace(/[-]{2,}/g,"-");this.registerFilter("variant_url",t),this.registerFilter("image_url",i),this.registerFilter("file_url",r),this.registerFilter("file_img_url",s),this.registerFilter("money",n),this.registerFilter("t",o),this.registerFilter("handle",l),this.registerFilter("handleize",l)},Pt=e=>e.reduce((t,[i,r])=>r?{...t,[i]:r}:t,{});import{WishlistElement as ds}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/wishlist-element.js";var et=class extends ds{constructor(){super();this.initLiquid()}static get properties(){return{}}async initLiquid(){await this.app.load(),this.dataUtil=new V,this.globals={settings:{login_required:this.app.settings.general.wishlistAccessMode!=="UNRESTRICTED"},customer:this.app.customer,shop:{currency:this.app.config.shop.currency,customer_accounts_enabled:this.app.config.shop.customerAccountsEnabled,domain:this.app.config.shop.domain,money_format:this.app.config.shop.moneyFormat,name:this.app.config.shop.name,permanent_domain:this.app.config.shop.permanentDomain},routes:{root_url:this.app.routes.rootUrl,wishlist_url:this.app.routes.wishlistUrl,account_url:this.app.routes.accountUrl,account_login_url:this.app.routes.accountLoginUrl,account_logout_url:this.app.routes.accountLogoutUrl,account_register_url:this.app.routes.accountRegisterUrl,account_addresses_url:this.app.routes.accountAddressesUrl,collections_url:this.app.routes.collectionsUrl,all_products_collection_url:this.app.routes.allProductsCollectionUrl,search_url:this.app.routes.searchUrl,predictive_search_url:this.app.routes.predictiveSearchUrl,cart_url:this.app.routes.cartUrl,cart_add_url:this.app.routes.cartAddUrl,cart_change_url:this.app.routes.cartChangeUrl,cart_clear_url:this.app.routes.cartClearUrl,cart_update_url:this.app.routes.cartUpdateUrl,product_recommendations_url:this.app.routes.productRecommendationsUrl}},this.liquidEngine=new W({cache:!0,relativeReference:!1}),this.liquidEngine.plugin(Ke(this.app)),this.parsedTemplates=this.liquidEngine.parse(this.getLiquidTemplate()),this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),this.parsedTemplates=void 0}getLiquidTemplate(){return""}getLiquidData(){return{}}render(){var l,a;if(!this.parsedTemplates||!this.liquidEngine||!this.dataUtil)return;let{wishlist:i,wishlistItem:r,productInfo:s}=(l=this.state)!=null?l:{},n={...this.dataUtil.objectToSnakeCase(this.getLiquidData()),wishlist:i?this.dataUtil.mapWishlistState(i,(a=this.stateCtrl.stateConfig.wishlist)==null?void 0:a.format):void 0,wishlist_item:r?this.dataUtil.mapWishlistItem(r):void 0,product_info:s?this.dataUtil.mapProductInfo(s):void 0},o=this.liquidEngine.renderSync(this.parsedTemplates,n,{globals:this.globals});return hs`${ps(o)}`}};export{V as LiquidDataUtil,et as LiquidElement,Ke as liquidShopifyFilters};
`)}function Gi(e,t){t.file&&(e+=`, file:${t.file}`);let[i,r]=t.getPosition();return e+=`, line:${i}, col:${r}`,e}function g(e,t){if(!e){let i=typeof t=="function"?t():t||`expect ${e} to be true`;throw new fe(i)}}function Zi(e,t){return g(arguments.length===2,"append expect 2 arguments"),c(e)+c(t)}function Xi(e,t){return g(arguments.length===2,"prepend expect 2 arguments"),c(t)+c(e)}function Ki(e,t){return t?(t=Be(c(t)),c(e).replace(new RegExp(`^[${t}]+`,"g"),"")):c(e).replace(/^\s+/,"")}function er(e){return c(e).toLowerCase()}function tr(e){return c(e).toUpperCase()}function ir(e,t){return c(e).split(String(t)).join("")}function rr(e,t){return c(e).replace(String(t),"")}function sr(e,t){return t?(t=Be(c(t)),c(e).replace(new RegExp(`[${t}]+$`,"g"),"")):c(e).replace(/\s+$/,"")}function nr(e,t){let i=c(e).split(String(t));for(;i.length&&i[i.length-1]==="";)i.pop();return i}function or(e,t){return t?(t=Be(c(t)),c(e).replace(new RegExp(`^[${t}]+`,"g"),"").replace(new RegExp(`[${t}]+$`,"g"),"")):c(e).trim()}function ar(e){return c(e).replace(/\n/g,"")}function lr(e){return e=c(e),e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function ur(e,t,i){return c(e).split(String(t)).join(i)}function cr(e,t,i){return c(e).replace(String(t),i)}function hr(e,t=50,i="..."){return e=c(e),e.length<=t?e:e.substring(0,t-i.length)+i}function pr(e,t=15,i="..."){let r=c(e).split(/\s+/);t<=0&&(t=1);let s=r.slice(0,t).join(" ");return r.length>=t&&(s+=i),s}var Ot=Object.freeze({__proto__:null,escape:kt,escapeOnce:ti,newlineToBr:ii,stripHtml:ri,abs:si,atLeast:ni,atMost:oi,ceil:ai,dividedBy:li,floor:ui,minus:ci,modulo:hi,times:pi,round:di,plus:fi,urlDecode:gi,urlEncode:mi,join:wi,last:yi,first:Ti,reverse:bi,sort:_i,sortNatural:ki,size:qi,map:Si,compact:vi,concat:Li,slice:Oi,where:Fi,uniq:Ri,date:Bi,Default:Hi,json:Qi,raw:Yi,append:Zi,prepend:Xi,lstrip:Ki,downcase:er,upcase:tr,remove:ir,removeFirst:rr,rstrip:sr,split:nr,strip:or,stripNewlines:ar,capitalize:lr,replace:ur,replaceFirst:cr,truncate:hr,truncatewords:pr}),f;(function(e){e[e.Number=1]="Number",e[e.Literal=2]="Literal",e[e.Tag=4]="Tag",e[e.Output=8]="Output",e[e.HTML=16]="HTML",e[e.Filter=32]="Filter",e[e.Hash=64]="Hash",e[e.PropertyAccess=128]="PropertyAccess",e[e.Word=256]="Word",e[e.Range=512]="Range",e[e.Quoted=1024]="Quoted",e[e.Operator=2048]="Operator",e[e.Delimited=12]="Delimited"})(f||(f={}));function dr(e){return!!(v(e)&f.Delimited)}function Ft(e){return v(e)===f.Operator}function Ye(e){return v(e)===f.HTML}function fr(e){return v(e)===f.Output}function Je(e){return v(e)===f.Tag}function Rt(e){return v(e)===f.Quoted}function gr(e){return v(e)===f.Literal}function mr(e){return v(e)===f.Number}function wr(e){return v(e)===f.PropertyAccess}function yr(e){return v(e)===f.Word}function Tr(e){return v(e)===f.Range}function v(e){return e?e.kind:-1}var ge=class extends x{equals(t){return E(h(t))}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return null}},D=class extends x{equals(t){return t instanceof D?!1:(t=h(t),L(t)||T(t)?t.length===0:Ve(t)?Object.keys(t).length===0:!1)}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return""}},me=class extends D{equals(t){return t===!1||E(h(t))?!0:L(t)?/^\s*$/.test(t):super.equals(t)}},at=new ge,xt={true:!0,false:!1,nil:at,null:at,empty:new D,blank:new me},br=/[\da-fA-F]/,lt=/[0-7]/,ut={b:"\b",f:"\f",n:`
`,r:"\r",t:" ",v:"\v"};function ct(e){let t=e.charCodeAt(0);return t>=97?t-87:t>=65?t-55:t-48}function It(e){let t="";for(let i=1;i<e.length-1;i++){if(e[i]!=="\\"){t+=e[i];continue}if(ut[e[i+1]]!==void 0)t+=ut[e[++i]];else if(e[i+1]==="u"){let r=0,s=i+2;for(;s<=i+5&&br.test(e[s]);)r=r*16+ct(e[s++]);i=s-1,t+=String.fromCharCode(r)}else if(!lt.test(e[i+1]))t+=e[++i];else{let r=i+1,s=0;for(;r<=i+3&&lt.test(e[r]);)s=s*8+ct(e[r++]);i=r-1,t+=String.fromCharCode(s)}}return t}function M(e){return O(this,void 0,void 0,function*(){if(!K(e))return e;let t,i=!1,r="next";do{let s=e[r](t);i=s.done,t=s.value,r="next";try{K(t)&&(t=M(t)),At(t)&&(t=yield t)}catch(n){r="throw",t=n}}while(!i);return t})}function A(e){if(!K(e))return e;let t,i=!1,r="next";do{let s=e[r](t);if(i=s.done,t=s.value,r="next",K(t))try{t=A(t)}catch(n){r="throw",t=n}}while(!i);return t}var we=class{constructor(t){this.postfix=[...Lr(t)]}*evaluate(t,i){g(t,"unable to evaluate: context not defined");let r=[];for(let s of this.postfix)if(Ft(s)){let n=r.pop(),o=r.pop(),l=yield qr(t.opts.operators,s,o,n,t);r.push(l)}else r.push(yield w(s,t,i&&this.postfix.length===1));return r[0]}};function*w(e,t,i=!1){if(wr(e))return yield _r(e,t,i);if(Tr(e))return yield vr(e,t);if(gr(e))return Sr(e);if(mr(e))return kr(e);if(yr(e))return e.getText();if(Rt(e))return Ge(e)}function*_r(e,t,i){let r=[];for(let s of e.props)r.push(yield w(s,t,!1));try{return yield t._get([e.propertyName,...r])}catch(s){if(i&&s.name==="InternalUndefinedVariableError")return null;throw new pe(s,e)}}function kr(e){let t=e.whole.content+"."+(e.decimal?e.decimal.content:"");return Number(t)}function Ge(e){return It(e.getText())}function qr(e,t,i,r,s){let n=e[t.operator];return n(i,r,s)}function Sr(e){return xt[e.literal]}function*vr(e,t){let i=yield w(e.lhs,t),r=yield w(e.rhs,t);return mt(+i,+r+1)}function*Lr(e){let t=[];for(let i of e)if(Ft(i)){for(;t.length&&t[t.length-1].getPrecedence()>i.getPrecedence();)yield t.pop();t.push(i)}else yield i;for(;t.length;)yield t.pop()}var _=class{constructor(t,i,r,s,n){this.kind=t,this.input=i,this.begin=r,this.end=s,this.file=n}getText(){return this.input.slice(this.begin,this.end)}getPosition(){let[t,i]=[1,1];for(let r=0;r<this.begin;r++)this.input[r]===`
`?(t++,i=1):i++;return[t,i]}size(){return this.end-this.begin}},Q=class extends _{constructor(t,i,r,s,n,o,l,a){super(t,r,s,n,a),this.trimLeft=!1,this.trimRight=!1,this.content=this.getText();let u=i[0]==="-",p=We(i)==="-";this.content=i.slice(u?1:0,p?-1:i.length).trim(),this.trimLeft=u||o,this.trimRight=p||l}};function Or(e,t){let i=!1;for(let r=0;r<e.length;r++){let s=e[r];!dr(s)||(!i&&s.trimLeft&&Fr(e[r-1],t.greedy),Je(s)&&(s.name==="raw"?i=!0:s.name==="endraw"&&(i=!1)),!i&&s.trimRight&&Rr(e[r+1],t.greedy))}}function Fr(e,t){if(!e||!Ye(e))return;let i=t?ae:bt;for(;d[e.input.charCodeAt(e.end-1-e.trimRight)]&i;)e.trimRight++}function Rr(e,t){if(!e||!Ye(e))return;let i=t?ae:bt;for(;d[e.input.charCodeAt(e.begin+e.trimLeft)]&i;)e.trimLeft++;e.input.charAt(e.begin+e.trimLeft)===`
`&&e.trimLeft++}var ye=class extends _{constructor(t,i){super(f.Number,t.input,t.begin,i?i.end:t.end,t.file),this.whole=t,this.decimal=i}},U=class extends _{constructor(t,i,r,s){super(f.Word,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.content=this.getText()}isNumber(t=!1){let i=t&&d[this.input.charCodeAt(this.begin)]&Zt?this.begin+1:this.begin;for(let r=i;r<this.end;r++)if(!(d[this.input.charCodeAt(r)]&Gt))return!1;return!0}},Te=class extends _{constructor(t,i,r,s){super(f.Literal,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.literal=this.getText()}},ht={"==":1,"!=":1,">":1,"<":1,">=":1,"<=":1,contains:1,and:0,or:0},be=class extends _{constructor(t,i,r,s){super(f.Operator,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.operator=this.getText()}getPrecedence(){let t=this.getText();return t in ht?ht[t]:1}},re=class extends _{constructor(t,i,r){super(f.PropertyAccess,t.input,t.begin,r,t.file),this.variable=t,this.props=i,this.propertyName=this.variable instanceof U?this.variable.getText():It(this.variable.getText())}},_e=class extends _{constructor(t,i,r,s,n,o){super(f.Filter,r,s,n,o),this.name=t,this.args=i}},ke=class extends _{constructor(t,i,r,s,n,o){super(f.Hash,t,i,r,o),this.input=t,this.begin=i,this.end=r,this.name=s,this.value=n,this.file=o}},qe=class extends _{constructor(t,i,r,s){super(f.Quoted,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s}},se=class extends _{constructor(t,i,r,s){super(f.HTML,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.trimLeft=0,this.trimRight=0}getContent(){return this.input.slice(this.begin+this.trimLeft,this.end-this.trimRight)}},Se=class extends _{constructor(t,i,r,s,n,o){super(f.Range,t,i,r,o),this.input=t,this.begin=i,this.end=r,this.lhs=s,this.rhs=n,this.file=o}},ve=class extends Q{constructor(t,i,r,s,n){let{trimOutputLeft:o,trimOutputRight:l,outputDelimiterLeft:a,outputDelimiterRight:u}=s,p=t.slice(i+a.length,r-u.length);super(f.Output,p,t,i,r,o,l,n)}};function xr(e,t,i,r=e.length){let s=i,n=t,o;for(;s[e[n]]&&n<r;)s=s[e[n++]],s.end&&(o=s);return!o||o.needBoundary&&d[e.charCodeAt(n)]&He?-1:n}var Le=class extends Q{constructor(t,i,r,s,n){let o=t.slice(i,r);if(super(f.Tag,o,t,i,r,!1,!1,n),!/\S/.test(o))this.name="",this.args="";else{let l=new m(this.content,s.operatorsTrie);if(this.name=l.readTagName(),!this.name)throw new H("illegal liquid tag syntax",this);l.skipBlank(),this.args=l.remaining()}}},m=class{constructor(t,i=P.operatorsTrie,r=""){this.input=t,this.trie=i,this.file=r,this.p=0,this.rawBeginAt=-1,this.N=t.length}readExpression(){return new we(this.readExpressionTokens())}*readExpressionTokens(){let t=this.readValue();if(!!t)for(yield t;this.p<this.N;){let i=this.readOperator();if(!i)return;let r=this.readValue();if(!r)return;yield i,yield r}}readOperator(){this.skipBlank();let t=xr(this.input,this.p,this.trie);if(t!==-1)return new be(this.input,this.p,this.p=t,this.file)}readFilters(){let t=[];for(;;){let i=this.readFilter();if(!i)return t;t.push(i)}}readFilter(){if(this.skipBlank(),this.end())return null;g(this.peek()==="|",()=>`unexpected token at ${this.snapshot()}`),this.p++;let t=this.p,i=this.readIdentifier();if(!i.size())return null;let r=[];if(this.skipBlank(),this.peek()===":")do{++this.p;let s=this.readFilterArg();s&&r.push(s),this.skipBlank(),g(this.end()||this.peek()===","||this.peek()==="|",()=>`unexpected character ${this.snapshot()}`)}while(this.peek()===",");return new _e(i.getText(),r,this.input,t,this.p,this.file)}readFilterArg(){let t=this.readValue();if(!t)return;if(this.skipBlank(),this.peek()!==":")return t;++this.p;let i=this.readValue();return[t.getText(),i]}readTopLevelTokens(t=P){let i=[];for(;this.p<this.N;){let r=this.readTopLevelToken(t);i.push(r)}return Or(i,t),i}readTopLevelToken(t){let{tagDelimiterLeft:i,outputDelimiterLeft:r}=t;return this.rawBeginAt>-1?this.readEndrawOrRawContent(t):this.match(i)?this.readTagToken(t):this.match(r)?this.readOutputToken(t):this.readHTMLToken([i,r])}readHTMLToken(t){let i=this.p;for(;this.p<this.N&&!t.some(r=>this.match(r));)++this.p;return new se(this.input,i,this.p,this.file)}readTagToken(t=P){let{file:i,input:r}=this,s=this.p;if(this.readToDelimiter(t.tagDelimiterRight)===-1)throw this.mkError(`tag ${this.snapshot(s)} not closed`,s);let n=new ne(r,s,this.p,t,i);return n.name==="raw"&&(this.rawBeginAt=s),n}readToDelimiter(t){for(;this.p<this.N;){if(this.peekType()&st){this.readQuoted();continue}if(++this.p,this.rmatch(t))return this.p}return-1}readOutputToken(t=P){let{file:i,input:r}=this,{outputDelimiterRight:s}=t,n=this.p;if(this.readToDelimiter(s)===-1)throw this.mkError(`output ${this.snapshot(n)} not closed`,n);return new ve(r,n,this.p,t,i)}readEndrawOrRawContent(t){let{tagDelimiterLeft:i,tagDelimiterRight:r}=t,s=this.p,n=this.readTo(i)-i.length;for(;this.p<this.N;){if(this.readIdentifier().getText()!=="endraw"){n=this.readTo(i)-i.length;continue}for(;this.p<=this.N;){if(this.rmatch(r)){let o=this.p;return s===n?(this.rawBeginAt=-1,new ne(this.input,s,o,t,this.file)):(this.p=n,new se(this.input,s,n,this.file))}if(this.rmatch(i))break;this.p++}}throw this.mkError(`raw ${this.snapshot(this.rawBeginAt)} not closed`,s)}readLiquidTagTokens(t=P){let i=[];for(;this.p<this.N;){let r=this.readLiquidTagToken(t);r.name&&i.push(r)}return i}readLiquidTagToken(t){let{file:i,input:r}=this,s=this.p,n=this.N;return this.readToDelimiter(`
`)!==-1&&(n=this.p),new Le(r,s,n,t,i)}mkError(t,i){return new H(t,new U(this.input,i,this.N,this.file))}snapshot(t=this.p){return JSON.stringify(Dt(this.input.slice(t),16))}readWord(){return console.warn("Tokenizer#readWord() will be removed, use #readIdentifier instead"),this.readIdentifier()}readIdentifier(){this.skipBlank();let t=this.p;for(;this.peekType()&He;)++this.p;return new U(this.input,t,this.p,this.file)}readTagName(){return this.skipBlank(),this.input[this.p]==="#"?this.input.slice(this.p,++this.p):this.readIdentifier().getText()}readHashes(t){let i=[];for(;;){let r=this.readHash(t);if(!r)return i;i.push(r)}}readHash(t){this.skipBlank(),this.peek()===","&&++this.p;let i=this.p,r=this.readIdentifier();if(!r.size())return;let s;this.skipBlank();let n=t?"=":":";return this.peek()===n&&(++this.p,s=this.readValue()),new ke(this.input,i,this.p,r,s,this.file)}remaining(){return this.input.slice(this.p)}advance(t=1){this.p+=t}end(){return this.p>=this.N}readTo(t){for(;this.p<this.N;)if(++this.p,this.rmatch(t))return this.p;return-1}readValue(){let t=this.readQuoted()||this.readRange();if(t)return t;if(this.peek()==="["){this.p++;let n=this.readQuoted();return!n||this.peek()!=="]"?void 0:(this.p++,new re(n,[],this.p))}let i=this.readIdentifier();if(!i.size())return;let r=i.isNumber(!0),s=[];for(;;)if(this.peek()==="["){r=!1,this.p++;let n=this.readValue()||new U(this.input,this.p,this.p,this.file);this.readTo("]"),s.push(n)}else if(this.peek()==="."&&this.peek(1)!=="."){this.p++;let n=this.readIdentifier();if(!n.size())break;n.isNumber()||(r=!1),s.push(n)}else break;return!s.length&&xt.hasOwnProperty(i.content)?new Te(this.input,i.begin,i.end,this.file):r?new ye(i,s[0]):new re(i,s,this.p)}readRange(){this.skipBlank();let t=this.p;if(this.peek()!=="(")return;++this.p;let i=this.readValueOrThrow();this.p+=2;let r=this.readValueOrThrow();return++this.p,new Se(this.input,t,this.p,i,r,this.file)}readValueOrThrow(){let t=this.readValue();return g(t,()=>`unexpected token ${this.snapshot()}, value expected`),t}readQuoted(){this.skipBlank();let t=this.p;if(!(this.peekType()&st))return;++this.p;let i=!1;for(;this.p<this.N&&(++this.p,!(this.input[this.p-1]===this.input[t]&&!i));)i?i=!1:this.input[this.p-1]==="\\"&&(i=!0);return new qe(this.input,t,this.p,this.file)}*readFileNameTemplate(t){let{outputDelimiterLeft:i}=t,r=[","," ",i],s=new Set(r);for(;this.p<this.N&&!s.has(this.peek());)yield this.match(i)?this.readOutputToken(t):this.readHTMLToken(r)}match(t){for(let i=0;i<t.length;i++)if(t[i]!==this.input[this.p+i])return!1;return!0}rmatch(t){for(let i=0;i<t.length;i++)if(t[t.length-1-i]!==this.input[this.p-1-i])return!1;return!0}peekType(t=0){return d[this.input.charCodeAt(this.p+t)]}peek(t=0){return this.input[this.p+t]}skipBlank(){for(;this.peekType()&ae;)++this.p}},ne=class extends Q{constructor(t,i,r,s,n){let{trimTagLeft:o,trimTagRight:l,tagDelimiterLeft:a,tagDelimiterRight:u}=s,p=t.slice(i+a.length,r-u.length);super(f.Tag,p,t,i,r,o,l,n);let y=new m(this.content,s.operatorsTrie);if(this.name=y.readTagName(),!this.name)throw new H("illegal tag syntax",this);y.skipBlank(),this.args=y.remaining()}},Oe=class{constructor(t,i){this.handlers={},this.stopRequested=!1,this.tokens=t,this.parseToken=i}on(t,i){return this.handlers[t]=i,this}trigger(t,i){let r=this.handlers[t];return r?(r.call(this,i),!0):!1}start(){this.trigger("start");let t;for(;!this.stopRequested&&(t=this.tokens.shift());){if(this.trigger("token",t)||Je(t)&&this.trigger(`tag:${t.name}`,t))continue;let i=this.parseToken(t,this.tokens);this.trigger("template",i)}return this.stopRequested||this.trigger("end"),this}stop(){return this.stopRequested=!0,this}},I=class{constructor(t,i){this.hash={};let r=new m(t,{});for(let s of r.readHashes(i))this.hash[s.name.content]=s.value}*render(t){let i={};for(let r of Object.keys(this.hash))i[r]=this.hash[r]===void 0?!0:yield w(this.hash[r],t);return i}};function Ir(e){return T(e)}var Y=class{constructor(t,i,r,s){this.name=t,this.impl=i||yt,this.args=r,this.liquid=s}*render(t,i){let r=[];for(let s of this.args)Ir(s)?r.push([s[0],yield w(s[1],i)]):r.push(yield w(s,i));return this.impl.apply({context:i,liquid:this.liquid},[t,...r])}},S=class{constructor(t,i){this.filters=[];let r=new m(t,i.options.operatorsTrie);this.initial=r.readExpression(),this.filters=r.readFilters().map(({name:s,args:n})=>new Y(s,i.filters.get(s),n,i))}*value(t,i){i=i||t.opts.lenientIf&&this.filters.length>0&&this.filters[0].name==="default";let r=yield this.initial.evaluate(t,i);for(let s of this.filters)r=yield s.render(r,t);return r}},Er={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.key=t.readIdentifier().content,t.skipBlank(),g(t.peek()==="=",()=>`illegal token ${e.getText()}`),t.advance(),this.value=new S(t.remaining(),this.liquid)},render:function*(e){e.bottom()[this.key]=yield this.value.value(e,this.liquid.options.lenientIf)}},J=class extends x{constructor(t,i,r){super(),this.i=0,this.length=t,this.name=`${r}-${i}`}next(){this.i++}index0(){return this.i}index(){return this.i+1}first(){return this.i===0}last(){return this.i===this.length-1}rindex(){return this.length-this.i}rindex0(){return this.length-this.i-1}valueOf(){return JSON.stringify(this)}},pt=["offset","limit","reversed"],Pr={type:"block",parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier(),s=i.readIdentifier(),n=i.readValue();g(r.size()&&s.content==="in"&&n,()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=n,this.hash=new I(i.remaining()),this.templates=[],this.elseTemplates=[];let o,l=this.liquid.parser.parseStream(t).on("start",()=>o=this.templates).on("tag:else",()=>o=this.elseTemplates).on("tag:endfor",()=>l.stop()).on("template",a=>o.push(a)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});l.start()},render:function*(e,t){let i=this.liquid.renderer,r=Qe(yield w(this.collection,e));if(!r.length){yield i.renderTemplates(this.elseTemplates,e,t);return}let s="continue-"+this.variable+"-"+this.collection.getText();e.push({continue:e.getRegister(s)});let n=yield this.hash.render(e);e.pop(),r=(this.liquid.options.orderedFilterParameters?Object.keys(n).filter(a=>pt.includes(a)):pt.filter(a=>n[a]!==void 0)).reduce((a,u)=>u==="offset"?Mr(a,n.offset):u==="limit"?Ar(a,n.limit):Nr(a),r),e.setRegister(s,(n.offset||0)+r.length);let l={forloop:new J(r.length,this.collection.getText(),this.variable)};e.push(l);for(let a of r){if(l[this.variable]=a,yield i.renderTemplates(this.templates,e,t),t.break){t.break=!1;break}t.continue=!1,l.forloop.next()}e.pop()}};function Nr(e){return[...e].reverse()}function Mr(e,t){return e.slice(t)}function Ar(e,t){return e.slice(0,t)}var $r={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.variable=Cr(i),g(this.variable,()=>`${e.args} not valid identifier`),this.templates=[];let r=this.liquid.parser.parseStream(t);r.on("tag:endcapture",()=>r.stop()).on("template",s=>this.templates.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),r.start()},render:function*(e){let i=yield this.liquid.renderer.renderTemplates(this.templates,e);e.bottom()[this.variable]=i}};function Cr(e){let t=e.readIdentifier().content;if(t)return t;let i=e.readQuoted();if(i)return Ge(i)}var Ur={parse:function(e,t){this.cond=new S(e.args,this.liquid),this.cases=[],this.elseTemplates=[];let i=[],r=this.liquid.parser.parseStream(t).on("tag:when",s=>{i=[];let n=new m(s.args,this.liquid.options.operatorsTrie);for(;!n.end();){let o=n.readValue();this.cases.push({val:o,templates:i}),n.readTo(",")}}).on("tag:else",()=>i=this.elseTemplates).on("tag:endcase",()=>r.stop()).on("template",s=>i.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});r.start()},render:function*(e,t){let i=this.liquid.renderer,r=h(yield this.cond.value(e,e.opts.lenientIf));for(let s of this.cases)if((yield w(s.val,e,e.opts.lenientIf))===r){yield i.renderTemplates(s.templates,e,t);return}yield i.renderTemplates(this.elseTemplates,e,t)}},zr={parse:function(e,t){let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endcomment"&&i.stop()}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()}},Fe;(function(e){e[e.OUTPUT=0]="OUTPUT",e[e.STORE=1]="STORE"})(Fe||(Fe={}));var j=Fe,Dr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);for(this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;!i.end();){i.skipBlank();let r=i.p,s=i.readIdentifier();if((s.content==="with"||s.content==="for")&&(i.skipBlank(),i.peek()!==":")){let n=i.readValue();if(n){let o=i.p,l=i.readIdentifier(),a;l.content==="as"?a=i.readIdentifier():i.p=o,this[s.content]={value:n,alias:a&&a.content},i.skipBlank(),i.peek()===","&&i.advance();continue}}i.p=r;break}this.hash=new I(i.remaining())},render:function*(e,t){let{liquid:i,hash:r}=this,s=yield this.renderFilePath(this.file,e,i);g(s,()=>`illegal filename "${s}"`);let n=new $({},e.opts,{sync:e.sync,globals:e.globals,strictVariables:e.strictVariables}),o=n.bottom();if(X(o,yield r.render(e)),this.with){let{value:l,alias:a}=this.with;o[a||s]=yield w(l,e)}if(this.for){let{value:l,alias:a}=this.for,u=yield w(l,e);u=Qe(u),o.forloop=new J(u.length,l.getText(),a);for(let p of u){o[a]=p;let y=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(y,n,t),o.forloop.next()}}else{let l=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(l,n,t)}}};function Ze(e,t){if(t.options.dynamicPartials){let s=e.readValue();if(s===void 0)throw new TypeError(`illegal argument "${e.input}"`);if(s.getText()==="none")return null;if(Rt(s)){let n=t.parse(Ge(s));return dt(n)}return s}let i=[...e.readFileNameTemplate(t.options)],r=dt(t.parser.parseTokens(i));return r==="none"?null:r}function dt(e){return e.length===1&&Ye(e[0].token)?e[0].token.getContent():e}function*Xe(e,t,i){return typeof e=="string"?e:Array.isArray(e)?i.renderer.renderTemplates(e,t):yield w(e,t)}var Wr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;let r=i.p;i.readIdentifier().content==="with"?(i.skipBlank(),i.peek()!==":"?this.withVar=i.readValue():i.p=r):i.p=r,this.hash=new I(i.remaining(),this.liquid.options.jekyllInclude)},render:function*(e,t){let{liquid:i,hash:r,withVar:s}=this,{renderer:n}=i,o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=e.saveRegister("blocks","blockMode");e.setRegister("blocks",{}),e.setRegister("blockMode",j.OUTPUT);let a=yield r.render(e);s&&(a[o]=yield w(s,e));let u=yield i._parsePartialFile(o,e.sync,this.currentFile);e.push(e.opts.jekyllInclude?{include:a}:a),yield n.renderTemplates(u,e,t),e.pop(),e.restoreRegister(l)}},Vr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0),t.write(c(--i[this.variable]))}},Br={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie),i=t.readValue();for(t.skipBlank(),this.candidates=[],i&&(t.peek()===":"?(this.group=i,t.advance()):this.candidates.push(i));!t.end();){let r=t.readValue();r&&this.candidates.push(r),t.readTo(",")}g(this.candidates.length,()=>`empty candidates: ${e.getText()}`)},render:function*(e,t){let r=`cycle:${yield w(this.group,e)}:`+this.candidates.join(","),s=e.getRegister("cycle"),n=s[r];n===void 0&&(n=s[r]=0);let o=this.candidates[n];n=(n+1)%this.candidates.length,s[r]=n;let l=yield w(o,e);t.write(l)}},jr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endif",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,templates:s}of this.branches){let n=yield r.value(e,e.opts.lenientIf);if(N(n,e)){yield i.renderTemplates(s,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Hr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0);let r=i[this.variable];i[this.variable]++,t.write(c(r))}},Qr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file,this.hash=new I(i.remaining()),this.tpls=this.liquid.parser.parseTokens(t)},render:function*(e,t){let{liquid:i,hash:r,file:s}=this,{renderer:n}=i;if(s===null){e.setRegister("blockMode",j.OUTPUT),yield n.renderTemplates(this.tpls,e,t);return}let o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=yield i._parseLayoutFile(o,e.sync,this.currentFile);e.setRegister("blockMode",j.STORE);let a=yield n.renderTemplates(this.tpls,e),u=e.getRegister("blocks");u[""]===void 0&&(u[""]=(p,y)=>y.write(a)),e.setRegister("blockMode",j.OUTPUT),e.push(yield r.render(e)),yield n.renderTemplates(l,e,t),e.pop()}},oe=class extends x{constructor(t=()=>""){super(),this.superBlockRender=t}super(){return this.superBlockRender()}},Yr={parse(e,t){let i=/\w+/.exec(e.args);this.block=i?i[0]:"",this.tpls=[],this.liquid.parser.parseStream(t).on("tag:endblock",function(){this.stop()}).on("template",r=>this.tpls.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},*render(e,t){let i=this.getBlockRender(e);e.getRegister("blockMode")===j.STORE?e.getRegister("blocks")[this.block]=i:yield i(new oe,t)},getBlockRender(e){let{liquid:t,tpls:i}=this,r=e.getRegister("blocks")[this.block],s=function*(n,o){e.push({block:n}),yield t.renderer.renderTemplates(i,e,o),e.pop()};return r?(n,o)=>r(new oe(()=>s(n,o)),o):s}},Jr={parse:function(e,t){this.tokens=[];let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endraw"?i.stop():this.tokens.push(r)}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()},render:function(){return this.tokens.map(e=>e.getText()).join("")}},Re=class extends J{constructor(t,i,r,s){super(t,r,s),this.length=t,this.cols=i}row(){return Math.floor(this.i/this.cols)+1}col0(){return this.i%this.cols}col(){return this.col0()+1}col_first(){return this.col0()===0}col_last(){return this.col()===this.cols}},Gr={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier();i.skipBlank();let s=i.readIdentifier();g(s&&s.content==="in",()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=i.readValue(),this.hash=new I(i.remaining()),this.templates=[];let n,o=this.liquid.parser.parseStream(t).on("start",()=>n=this.templates).on("tag:endtablerow",()=>o.stop()).on("template",l=>n.push(l)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});o.start()},render:function*(e,t){let i=Qe(yield w(this.collection,e)),r=yield this.hash.render(e),s=r.offset||0,n=r.limit===void 0?i.length:r.limit;i=i.slice(s,s+n);let o=r.cols||i.length,l=this.liquid.renderer,a=new Re(i.length,o,this.collection.getText(),this.variable),u={tablerowloop:a};e.push(u);for(let p=0;p<i.length;p++,a.next())u[this.variable]=i[p],a.col0()===0&&(a.row()!==1&&t.write("</tr>"),t.write(`<tr class="row${a.row()}">`)),t.write(`<td class="col${a.col()}">`),yield l.renderTemplates(this.templates,e,t),t.write("</td>");i.length&&t.write("</tr>"),e.pop()}},Zr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),test:je,templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),test:N,templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endunless",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,test:s,templates:n}of this.branches){let o=yield r.value(e,e.opts.lenientIf);if(s(o,e)){yield i.renderTemplates(n,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Xr={render:function(e,t){t.break=!0}},Kr={render:function(e,t){t.continue=!0}},es={parse:function(e){this.value=new S(e.args,this.liquid)},render:function*(e,t){let i=yield this.value.value(e,!1);t.write(i)}},ts={parse:function(e){let i=new m(e.args,this.liquid.options.operatorsTrie).readLiquidTagTokens(this.liquid.options);this.tpls=this.liquid.parser.parseTokens(i)},render:function*(e,t){yield this.liquid.renderer.renderTemplates(this.tpls,e,t)}},is={parse:function(e,t){if(e.args.search(/\n\s*[^#\s]/g)!==-1)throw new Error("every line of an inline comment must start with a '#' character")}},rs={assign:Er,for:Pr,capture:$r,case:Ur,comment:zr,include:Wr,render:Dr,decrement:Vr,increment:Hr,cycle:Br,if:jr,layout:Qr,block:Yr,raw:Jr,tablerow:Gr,unless:Zr,break:Xr,continue:Kr,echo:es,liquid:ts,"#":is};var Et=new Map;le(Ot,(e,t)=>{Et.set(ue(t),e)});var P={root:["."],layouts:["."],partials:["."],relativeReference:!0,jekyllInclude:!1,cache:void 0,extname:"",fs:Jt,dynamicPartials:!0,jsTruthy:!1,trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",preserveTimezones:!1,strictFilters:!1,strictVariables:!1,ownPropertyOnly:!1,lenientIf:!1,globals:{},keepOutputType:!1,operators:rt,operatorsTrie:_t(rt)};function ss(e){if(e.hasOwnProperty("operators")&&(e.operatorsTrie=_t(e.operators)),e.hasOwnProperty("root")&&(e.hasOwnProperty("partials")||(e.partials=e.root),e.hasOwnProperty("layouts")||(e.layouts=e.root)),e.hasOwnProperty("cache")){let t;typeof e.cache=="number"?t=e.cache>0?new te(e.cache):void 0:typeof e.cache=="object"?t=e.cache:t=e.cache?new te(1024):void 0,e.cache=t}return e=Object.assign(Object.assign(Object.assign({},P),e.jekyllInclude?{dynamicPartials:!1}:{}),e),!e.fs.dirname&&e.relativeReference&&(console.warn("[LiquidJS] `fs.dirname` is required for relativeReference, set relativeReference to `false` to suppress this warning, or provide implementation for `fs.dirname`"),e.relativeReference=!1),e.root=Z(e.root),e.partials=Z(e.partials),e.layouts=Z(e.layouts),e.outputEscape=e.outputEscape&&ns(e.outputEscape),e}function ns(e){if(L(e)){let t=Et.get(e);return g(q(t),`filter "${e}" not found`),t}else return g(q(e),"`outputEscape` need to be of type string or function"),e}function Z(e){let t=[];return T(e)&&(t=e),L(e)&&(t=[e]),t}var $=class{constructor(t={},i=P,r={}){var s,n;this.scopes=[{}],this.registers={},this.sync=!!r.sync,this.opts=i,this.globals=(s=r.globals)!==null&&s!==void 0?s:i.globals,this.environments=t,this.strictVariables=(n=r.strictVariables)!==null&&n!==void 0?n:this.opts.strictVariables}getRegister(t){return this.registers[t]=this.registers[t]||{}}setRegister(t,i){return this.registers[t]=i}saveRegister(...t){return t.map(i=>[i,this.getRegister(i)])}restoreRegister(t){return t.forEach(([i,r])=>this.setRegister(i,r))}getAll(){return[this.globals,this.environments,...this.scopes].reduce((t,i)=>X(t,i),{})}get(t){return A(this._get(t))}*_get(t){let i=this.findScope(t[0]);return yield this._getFromScope(i,t)}getFromScope(t,i){return A(this._getFromScope(t,i))}*_getFromScope(t,i){L(i)&&(i=i.split("."));for(let r=0;r<i.length;r++)if(t=yield os(t,i[r],this.opts.ownPropertyOnly),E(t)&&this.strictVariables)throw new de(i.slice(0,r+1).join("."));return t}push(t){return this.scopes.push(t)}pop(){return this.scopes.pop()}bottom(){return this.scopes[0]}findScope(t){for(let i=this.scopes.length-1;i>=0;i--){let r=this.scopes[i];if(t in r)return r}return t in this.environments?this.environments:this.globals}};function os(e,t,i){if(E(e))return e;if(e=gt(e),T(e)&&t<0)return e[e.length+ +t];let r=as(e,t,i);return r===void 0&&e instanceof x?e.liquidMethodMissing(t):q(r)?r.call(e):t==="size"?cs(e):t==="first"?ls(e):t==="last"?us(e):r}function as(e,t,i){if(!(i&&!Object.hasOwnProperty.call(e,t)))return e[t]}function ls(e){return T(e)?e[0]:e.first}function us(e){return T(e)?e[e.length-1]:e.last}function cs(e){if(e.hasOwnProperty("size")||e.size!==void 0)return e.size;if(T(e)||L(e))return e.length;if(typeof e=="object")return Object.keys(e).length}var C;(function(e){e.Partials="partials",e.Layouts="layouts",e.Root="root"})(C||(C={}));var xe=class{constructor(t){if(this.options=t,t.relativeReference){let i=t.fs.sep;g(i,"`fs.sep` is required for relative reference");let r=new RegExp(["."+i,".."+i,"./","../"].map(s=>$t(s)).join("|"));this.shouldLoadRelative=s=>r.test(s)}else this.shouldLoadRelative=i=>!1;this.contains=this.options.fs.contains||(()=>!0)}*lookup(t,i,r,s){let{fs:n}=this.options,o=this.options[i];for(let l of this.candidates(t,o,s,i!==C.Root))if(r?n.existsSync(l):yield n.exists(l))return l;throw this.lookupError(t,o)}*candidates(t,i,r,s){let{fs:n,extname:o}=this.options;if(this.shouldLoadRelative(t)&&r){let l=n.resolve(this.dirname(r),t,o);for(let a of i)if(!s||this.contains(a,l)){yield l;break}}for(let l of i){let a=n.resolve(l,t,o);(!s||this.contains(l,a))&&(yield a)}if(n.fallback!==void 0){let l=n.fallback(t);l!==void 0&&(yield l)}}dirname(t){let i=this.options.fs;return g(i.dirname,"`fs.dirname` is required for relative reference"),i.dirname(t)}lookupError(t,i){let r=new Error("ENOENT");return r.message=`ENOENT: Failed to lookup "${t}" in "${i}"`,r.code="ENOENT",r}},Ie=class{constructor(){this.buffer=""}write(t){this.buffer+=c(t)}},Ee=class{constructor(){throw this.buffer="",this.stream=null,new Error("streaming not supported in browser")}},Pe=class{constructor(){this.buffer=""}write(t){t=h(t),typeof t!="string"&&this.buffer===""?this.buffer=t:this.buffer=c(this.buffer)+c(t)}},Ne=class{renderTemplatesToNodeStream(t,i){let r=new Ee;return Promise.resolve().then(()=>M(this.renderTemplates(t,i,r))).then(()=>r.end(),s=>r.error(s)),r.stream}*renderTemplates(t,i,r){r||(r=i.opts.keepOutputType?new Pe:new Ie);for(let s of t)try{let n=yield s.render(i,r);if(n&&r.write(n),r.break||r.continue)break}catch(n){throw ie.is(n)?n:new ie(n,s)}return r.buffer}},G=class{constructor(t){this.token=t}},Me=class extends G{constructor(t,i,r){super(t),this.name=t.name;let s=r.tags.get(t.name);this.impl=Object.create(s),this.impl.liquid=r,this.impl.parse&&this.impl.parse(t,i)}*render(t,i){let r=yield new I(this.token.args).render(t),s=this.impl;if(q(s.render))return yield s.render(t,i,r)}},Ae=class extends G{constructor(t,i){super(t),this.value=new S(t.content,i);let r=this.value.filters,s=i.options.outputEscape;r.length&&r[r.length-1].name==="raw"?r.pop():s&&r.push(new Y(toString.call(s),s,[],i))}*render(t,i){let r=yield this.value.value(t,!1);i.write(r)}},$e=class extends G{constructor(t){super(t),this.str=t.getContent()}*render(t,i){i.write(this.str)}},Ce=class{constructor(t){this.liquid=t,this.cache=this.liquid.options.cache,this.fs=this.liquid.options.fs,this.parseFile=this.cache?this._parseFileCached:this._parseFile,this.loader=new xe(this.liquid.options)}parse(t,i){let s=new m(t,this.liquid.options.operatorsTrie,i).readTopLevelTokens(this.liquid.options);return this.parseTokens(s)}parseTokens(t){let i,r=[];for(;i=t.shift();)r.push(this.parseToken(i,t));return r}parseToken(t,i){try{return Je(t)?new Me(t,i,this.liquid):fr(t)?new Ae(t,this.liquid):new $e(t)}catch(r){throw new he(r,t)}}parseStream(t){return new Oe(t,(i,r)=>this.parseToken(i,r))}*_parseFileCached(t,i,r=C.Root,s){let n=this.cache,o=this.loader.shouldLoadRelative(t)?s+","+t:r+":"+t,l=yield n.read(o);if(l)return l;let a=this._parseFile(t,i,r,s),u=i?yield a:M(a);n.write(o,u);try{return yield u}catch(p){throw n.remove(o),p}}*_parseFile(t,i,r=C.Root,s){let n=yield this.loader.lookup(t,r,i,s);return this.liquid.parse(i?this.fs.readFileSync(n):yield this.fs.readFile(n),n)}},Ue=class{constructor(){this.impls={}}get(t){let i=this.impls[t];return g(i,()=>`tag "${t}" not found`),i}set(t,i){this.impls[t]=i}},ze=class{constructor(t,i){this.strictFilters=t,this.liquid=i,this.impls={}}get(t){let i=this.impls[t];return g(i||!this.strictFilters,()=>`undefined filter: ${t}`),i}set(t,i){this.impls[t]=i}create(t,i){return new Y(t,this.get(t),i,this.liquid)}};var W=class{constructor(t={}){this.options=ss(t),this.parser=new Ce(this),this.renderer=new Ne,this.filters=new ze(this.options.strictFilters,this),this.tags=new Ue,le(rs,(i,r)=>this.registerTag(ue(r),i)),le(Ot,(i,r)=>this.registerFilter(ue(r),i))}parse(t,i){return this.parser.parse(t,i)}_render(t,i,r){let s=new $(i,this.options,r);return this.renderer.renderTemplates(t,s)}render(t,i,r){return O(this,void 0,void 0,function*(){return M(this._render(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}renderSync(t,i,r){return A(this._render(t,i,Object.assign(Object.assign({},r),{sync:!0})))}renderToNodeStream(t,i,r={}){let s=new $(i,this.options,r);return this.renderer.renderTemplatesToNodeStream(t,s)}_parseAndRender(t,i,r){let s=this.parse(t);return this._render(s,i,r)}parseAndRender(t,i,r){return O(this,void 0,void 0,function*(){return M(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}parseAndRenderSync(t,i,r){return A(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!0})))}_parsePartialFile(t,i,r){return this.parser.parseFile(t,i,C.Partials,r)}_parseLayoutFile(t,i,r){return this.parser.parseFile(t,i,C.Layouts,r)}parseFile(t){return O(this,void 0,void 0,function*(){return M(this.parser.parseFile(t,!1))})}parseFileSync(t){return A(this.parser.parseFile(t,!0))}renderFile(t,i,r){return O(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.render(s,i,r)})}renderFileSync(t,i,r){let s=this.parseFileSync(t);return this.renderSync(s,i,r)}renderFileToNodeStream(t,i,r){return O(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.renderToNodeStream(s,i,r)})}_evalValue(t,i){let r=new S(t,this),s=i instanceof $?i:new $(i,this.options);return r.value(s,!1)}evalValue(t,i){return O(this,void 0,void 0,function*(){return M(this._evalValue(t,i))})}evalValueSync(t,i){return A(this._evalValue(t,i))}registerFilter(t,i){this.filters.set(t,i)}registerTag(t,i){this.tags.set(t,i)}plugin(t){return t.call(this,W)}express(){let t=this,i=!0;return function(r,s,n){if(i){i=!1;let o=Z(this.root);t.options.root.unshift(...o),t.options.layouts.unshift(...o),t.options.partials.unshift(...o)}t.renderFile(r,s).then(o=>n(null,o),n)}}};import{html as hs,unsafeStatic as ps}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/static/+esm";var Ke=e=>function(){let t=(a,u)=>e.utils.url.getVariantUrl(a.url,u==null?void 0:u.id),i=(a,...u)=>e.utils.url.getImageUrl(a,Pt(u)),r=(a="")=>e.utils.url.getFileUrl(a),s=(a="",u)=>e.utils.url.getImageUrl({src:e.utils.url.getFileUrl(a.replace(".",`_${u}.`))}),n=a=>e.utils.money.formatMoney(a),o=(a,...u)=>{try{return u.length?this.parseAndRenderSync(e.theme.translate(a),Pt(u)):e.theme.translate(a)}catch(p){return a}},l=(a="")=>a.toLowerCase().trim().replace(/[^a-zA-Z0-9]/g,"-").replace(/[-]{2,}/g,"-");this.registerFilter("variant_url",t),this.registerFilter("image_url",i),this.registerFilter("file_url",r),this.registerFilter("file_img_url",s),this.registerFilter("money",n),this.registerFilter("t",o),this.registerFilter("handle",l),this.registerFilter("handleize",l)},Pt=e=>e.reduce((t,[i,r])=>r?{...t,[i]:r}:t,{});import{WishlistElement as ds}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/wishlist-element.js";var et=class extends ds{constructor(){super();this.initLiquid()}static get properties(){return{}}async initLiquid(){await this.app.load(),this.dataUtil=new V,this.globals={settings:{login_required:this.app.settings.general.wishlistAccessMode!=="UNRESTRICTED"},customer:this.app.customer,shop:{currency:this.app.config.shop.currency,customer_accounts_enabled:this.app.config.shop.customerAccountsEnabled,domain:this.app.config.shop.domain,money_format:this.app.config.shop.moneyFormat,name:this.app.config.shop.name,permanent_domain:this.app.config.shop.permanentDomain},routes:{root_url:this.app.routes.rootUrl,wishlist_url:this.app.routes.wishlistUrl,account_url:this.app.routes.accountUrl,account_login_url:this.app.routes.accountLoginUrl,account_logout_url:this.app.routes.accountLogoutUrl,account_register_url:this.app.routes.accountRegisterUrl,account_addresses_url:this.app.routes.accountAddressesUrl,collections_url:this.app.routes.collectionsUrl,all_products_collection_url:this.app.routes.allProductsCollectionUrl,search_url:this.app.routes.searchUrl,predictive_search_url:this.app.routes.predictiveSearchUrl,cart_url:this.app.routes.cartUrl,cart_add_url:this.app.routes.cartAddUrl,cart_change_url:this.app.routes.cartChangeUrl,cart_clear_url:this.app.routes.cartClearUrl,cart_update_url:this.app.routes.cartUpdateUrl,product_recommendations_url:this.app.routes.productRecommendationsUrl}},this.liquidEngine=new W({cache:!0,relativeReference:!1}),this.liquidEngine.plugin(Ke(this.app)),this.parsedTemplates=this.liquidEngine.parse(this.getLiquidTemplate()),this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),this.parsedTemplates=void 0}getLiquidTemplate(){return""}getLiquidData(){return{}}render(){var l;if(!this.parsedTemplates||!this.liquidEngine||!this.dataUtil)return;let{wishlist:i,wishlistItem:r,productInfo:s}=(l=this.state)!=null?l:{},n={...this.dataUtil.objectToSnakeCase(this.getLiquidData()),wishlist:i?this.dataUtil.mapWishlistState(i):void 0,wishlist_item:r?this.dataUtil.mapWishlistItem(r):void 0,product_info:s?this.dataUtil.mapProductInfo(s):void 0},o=this.liquidEngine.renderSync(this.parsedTemplates,n,{globals:this.globals});return hs`${ps(o)}`}};export{V as LiquidDataUtil,et as LiquidElement,Ke as liquidShopifyFilters};
{
"name": "@appmate/wishlist",
"version": "4.16.1",
"version": "4.17.0",
"description": "Wishlist King SDK",

@@ -5,0 +5,0 @@ "main": "index.js",

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

var n=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 n;if(typeof t=="object")return this.searchByStyle(t,this.element,a=>a.parentElement,e);let r=this.element.closest(t);return r?new n(r):new n}find(t){var r;let e=(r=this.element)==null?void 0:r.querySelector(t);return e?new n(e):new n}searchByStyle(t,e,r,a=5){if(a<0||!e)return null;let i=getComputedStyle(e);if(Object.entries(t).every(([m,g])=>i.getPropertyValue(m)===g))return new n(e);let h=r(e);return h?this.searchByStyle(t,h,r,a-1):null}};var l=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((r,a)=>r.concat(Array.from(a.addedNodes)),[]).filter(r=>r instanceof Element&&!r.hasAttribute("data-appmate")).forEach(r=>this.scan(r))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let r={target:t,callback:e};this.subscriber.push(r),d(r,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){this.subscriber.filter(e=>d(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let r=t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(r&&this.notify(e,t),r&&e.target.firstMatch)return;let a=t.querySelectorAll(e.target.selector);for(let i of a)if(!this.shouldSkip(i,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,i),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("data-appmate")){e.setAttribute("data-appmate","");let r=new n(e);t.callback(r)}}};function d({target:s},t){if(!s.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(s.pageType)?s.pageType:[s.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var y=[{pageType:"product",match:s=>s.includes("/products/")},{pageType:"collection",match:s=>s.includes("/collections/")&&!s.includes("/products/")},{pageType:"account",match:s=>s.includes("/account/")||s.endsWith("/account")},{pageType:"blog",match:s=>s.includes("/blog/")},{pageType:"cart",match:s=>s.includes("/cart/")||s.endsWith("/cart")},{pageType:"wishlist",match:(s,{wishlistUrl:t})=>s.includes(t)},{pageType:"page",match:s=>s.includes("/pages/")},{pageType:"home",match:s=>s.length<4}],c=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of y)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var p=class{constructor(t){var e;this.locale=this.decodeLocale((e=t.locale)!=null?e:{})}decodeHtmlEntities(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'")}decodeLocale(t){let e={};for(let r in t){e[r]={};for(let a in t[r])e[r][a]=this.decodeHtmlEntities(t[r][a])}return e}translate(t){var a,i;let[e,r]=t.split(".");return(i=(a=this.locale[e])==null?void 0:a[r])!=null?i:`translation missing: ${t}`}};var u=class{constructor({rootUrl:t,wishlistUrl:e,locale:r}){this._rootUrl=t,this.route=new c({wishlistUrl:e}),this.observer=new l({routeUtil:this.route}),this.locale=new p({locale:r}),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){return this.locale.translate(t)}createComponent(t,e){var a;let r=document.createElement(t);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([i,o])=>{!o||(typeof o=="boolean"?r.dataset[i]="":typeof o=="object"?r.dataset[i]=JSON.stringify(o):r.dataset[i]=o)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([i,o])=>{r[i]=o}),(a=e==null?void 0:e.wrap)!=null&&a.name&&this.createElement(e.wrap.name,e.wrap.props,r),r}createElement(t,e={},...r){let a=Object.assign(document.createElement(t),e);return r&&a.append(...r),a}};export{u as ThemeHelper};
var o=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 o;if(typeof t=="object")return this.searchByStyle(t,this.element,a=>a.parentElement,e);let r=this.element.closest(t);return r?new o(r):new o}find(t){var r;let e=(r=this.element)==null?void 0:r.querySelector(t);return e?new o(e):new o}searchByStyle(t,e,r,a=5){if(a<0||!e)return null;let n=getComputedStyle(e);if(Object.entries(t).every(([h,d])=>n.getPropertyValue(h)===d))return new o(e);let c=r(e);return c?this.searchByStyle(t,c,r,a-1):null}};var l=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((r,a)=>r.concat(Array.from(a.addedNodes)),[]).filter(r=>r instanceof Element&&!r.hasAttribute("data-appmate")).forEach(r=>this.scan(r))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let r={target:t,callback:e};this.subscriber.push(r),m(r,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){this.subscriber.filter(e=>m(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let r=t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(r&&this.notify(e,t),r&&e.target.firstMatch)return;let a=t.querySelectorAll(e.target.selector);for(let n of a)if(!this.shouldSkip(n,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,n),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("data-appmate")){e.setAttribute("data-appmate","");let r=new o(e);t.callback(r)}}};function m({target:s},t){if(!s.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(s.pageType)?s.pageType:[s.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var y=[{pageType:"product",match:s=>s.includes("/products/")},{pageType:"collection",match:s=>s.includes("/collections/")&&!s.includes("/products/")},{pageType:"account",match:s=>s.includes("/account/")||s.endsWith("/account")},{pageType:"blog",match:s=>s.includes("/blog/")},{pageType:"cart",match:s=>s.includes("/cart/")||s.endsWith("/cart")},{pageType:"wishlist",match:(s,{wishlistUrl:t})=>s.includes(t)},{pageType:"page",match:s=>s.includes("/pages/")},{pageType:"home",match:s=>s.length<4}],p=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of y)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var u=class{constructor(t){var e;this.locale=this.decodeLocale((e=t.locale)!=null?e:{})}decodeHtmlEntities(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'")}decodeLocale(t){let e={};for(let r in t){e[r]={};for(let a in t[r])e[r][a]=this.decodeHtmlEntities(t[r][a])}return e}translate(t,e){var i;let[r,a]=t.split("."),n=(i=this.locale[r])==null?void 0:i[a];return n?e?Object.entries(e).reduce((c,[h,d])=>c.replace(new RegExp(`{{\\s*${h}\\s*}}`,"g"),d),n):n:`translation missing: ${t}`}};var g=class{constructor({rootUrl:t,wishlistUrl:e,locale:r}){this._rootUrl=t,this.route=new p({wishlistUrl:e}),this.observer=new l({routeUtil:this.route}),this.locale=new u({locale:r}),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 a;let r=document.createElement(t);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([n,i])=>{!i||(typeof i=="boolean"?r.dataset[n]="":typeof i=="object"?r.dataset[n]=JSON.stringify(i):r.dataset[n]=i)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([n,i])=>{r[n]=i}),(a=e==null?void 0:e.wrap)!=null&&a.name&&this.createElement(e.wrap.name,e.wrap.props,r),r}createElement(t,e={},...r){let a=Object.assign(document.createElement(t),e);return r&&a.append(...r),a}};export{g as ThemeHelper};

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

var f=class{constructor(t){this.placeholderRegex=/\{\{\s*(\w+)\s*\}\}/;var r;this.moneyFormat=(r=t.moneyFormat)!=null?r:"${{amount}}",this.currencyRate=t.currencyRate,this.activeCurrency=t.activeCurrency}formatMoney(t){var r;return typeof t=="string"&&(t=parseInt(t.replace(".",""))),this.moneyFormat.replace(this.placeholderRegex,this.formatCents(t,(r=this.moneyFormat.match(this.placeholderRegex))==null?void 0:r[1]))}formatCents(t,r){switch(r){case"amount_no_decimals":return this.formatWithDelimiters(t,0);case"amount_with_comma_separator":return this.formatWithDelimiters(t,2,".",",");case"amount_no_decimals_with_comma_separator":return this.formatWithDelimiters(t,0,".",",");case"amount":default:return this.formatWithDelimiters(t,2)}}formatWithDelimiters(t,r=2,e=",",i="."){if(isNaN(t)||t==null)return"0";let n=(t/100).toFixed(r).split("."),a=n[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${e}`),s=n[1]?i+n[1]:"";return a+s}};var m=class{constructor(){}getFormState({product:t,options:r,autoSelect:e=!1,change:i}){let o=this.getSelectedOptions({product:t,options:r,change:i,autoSelect:e}),n=o&&Object.values(o).every(u=>!!u),a=this.getOptionsWithValues({product:t,selectedOptions:o});return{selectedVariant:this.getVariantByOptions({product:t,options:o}),selectedOptions:o,hasSelection:n,optionsWithValues:a,hasOnlyDefaultVariant:t.variants.length===1}}getSelectedOptions({product:t,options:r,autoSelect:e,change:i={}}){let o=Object.fromEntries(Object.entries({...r,...i}).map(([l,c],h)=>{var p;return!c&&((p=t.options[h])==null?void 0:p.values.length)===1?[l,t.options[h].values[0]]:[l,c]}));if(!e)return o;e===!0&&(e="unavailable");let n=this.getVariantByOptions({product:t,options:o});if(e==="unavailable"&&n||e==="soldout"&&(n==null?void 0:n.available))return o;let a=Object.keys(i).pop(),s=Object.fromEntries(Object.entries(o).filter(([l])=>!a||l<=a)),u=Object.fromEntries(Object.entries(o).filter(([l])=>!(l in s)));return Object.entries(u).reduce((l,[c,h])=>{var y;let p=this.getAllVariantsByOptions({product:t,options:l});return p.length?{...l,[c]:((y=p.find(O=>O.available))!=null?y:p[0])[c]}:{...l,[c]:null}},s)}getVariantOptions({variant:t}){var r,e,i;return{option1:(r=t==null?void 0:t.option1)!=null?r:null,option2:(e=t==null?void 0:t.option2)!=null?e:null,option3:(i=t==null?void 0:t.option3)!=null?i:null}}getOptionsWithValues({product:t,selectedOptions:r={}}){return t.options.map(e=>{var s;let i=`option${e.position}`,o=this.getUnavailableOptionValues({product:t,optionKey:i,selectedOptions:r,values:e.values}),n=this.getSoldoutOptionValues({product:t,optionKey:i,selectedOptions:r,values:e.values}),a=(s=r==null?void 0:r[i])!=null?s:null;return{...e,selectedValue:a,soldoutValues:n,unavailableValues:o}})}getSoldoutOptionValues({product:t,optionKey:r,values:e,selectedOptions:i={}}){let o=Object.fromEntries(Object.entries(i).filter(([n])=>n<r));return e.filter(n=>{let a=t.variants.filter(s=>this.matchesVariant({variant:s,options:{...o,[r]:n}}));return a.length?a.every(s=>!s.available):!1})}getUnavailableOptionValues({product:t,optionKey:r,values:e,selectedOptions:i={}}){let o=Object.fromEntries(Object.entries(i).filter(([n])=>n<r));return e.filter(n=>t.variants.every(a=>!this.matchesVariant({variant:a,options:{...o,[r]:n}})))}getFirstAvailableVariant({product:t}){var r;return(r=t.variants.find(e=>e.available))!=null?r:null}getSelectedVariant({product:t,selectedVariantId:r}){var e;return(e=t.variants.find(i=>i.id===r))!=null?e:null}matchesVariant({variant:t,options:r}){return(!(r!=null&&r.option1)||r.option1===t.option1)&&(!(r!=null&&r.option2)||r.option2===t.option2)&&(!(r!=null&&r.option3)||r.option3===t.option3)}getFormData({form:t,product:r}){let e=new FormData(t);return{quantity:this.getFormQuantity({form:t}),options:this.getFormOptions({formData:e,product:r})}}getFormQuantity({form:t}){var i;let e=(i=new FormData(t).get("quantity"))==null?void 0:i.toString();return e?parseInt(e):1}getVariantByOptions({product:t,options:r}){var i;let e=Object.entries(r).reduce((o,[,n],a)=>(o[a]=n,o),new Array(3).fill(null));return(i=t.variants.find(o=>e.every((n,a)=>o[`option${a+1}`]===n)))!=null?i:null}getAllVariantsByOptions({product:t,options:r}){var i;let e=Object.entries(r).reduce((o,[,n],a)=>(o[a]=n,o),new Array(3).fill(null));return(i=t.variants.filter(o=>e.every((n,a)=>!n||o[`option${a+1}`]===n)))!=null?i:[]}getFormOptions({formData:t,product:r}){return Array.from(t.entries()).reduce((e,[i,o])=>{var s;let n=(s=i.match(/\[(.*?)\]/))==null?void 0:s[1];if(!n)return e;let a=r.options.findIndex(u=>u.name===n)+1;if(a>0){let u=`option${a}`;e[u]=o.toString()||null}return e},{})}getInputOption({input:t,product:r}){var o;let e=(o=t.name.match(/\[(.*?)\]/))==null?void 0:o[1];if(!e)return null;let i=r.options.findIndex(n=>n.name===e)+1;return i>0?{[`option${i}`]:t.value.toString()}:null}};var d=class{constructor(t){this.rootUrl=t.rootUrl,this.shopDomain=t.shopDomain,this.wishlistUrl=t.wishlistUrl,this.placeholderImageUrl=t.placeholderImageUrl,this.fileUrl=t.fileUrl}getPublicWishlistUrl(t){return`https://${this.shopDomain}${this.wishlistUrl}/${t}`}getFileUrl(t=""){return`https:${this.fileUrl.split("?")[0]}${t}`}getImageUrl(t,r){var i,o;if(!t)return(i=this.placeholderImageUrl)!=null?i:"";let e=this.getImage(t);return e!=null&&e.src?this.appendSize(e.src,r):(o=this.placeholderImageUrl)!=null?o:""}getImage(t){var r,e,i,o,n,a;if(t.hasOwnProperty("sku"))return{src:(e=(r=t.featured_image)==null?void 0:r.src)!=null?e:""};if(t!=null&&t.selected_or_first_available_variant){let s=t;return(i=s.selected_or_first_available_variant)!=null&&i.featured_image?this.getImage(s.selected_or_first_available_variant):{src:(o=s.featured_image)!=null?o:s.images[0]}}else if((n=t==null?void 0:t.images)!=null&&n.length){let s=t;return{src:(a=s.featured_image)!=null?a:s.images[0]}}else if(t.hasOwnProperty("src"))return{src:t.src};return null}appendSize(t,r){let e=new URL(t.startsWith("//")?`https://${t}`:t);return r!=null&&r.width&&e.searchParams.set("width",r==null?void 0:r.width.toString()),r!=null&&r.height&&e.searchParams.set("height",r==null?void 0:r.height.toString()),e.href}getVariantUrl(t,r){if(!!t)return r?t+`?variant=${r}`:t}};export{f as MoneyUtil,m as ProductUtil,d as UrlUtil};
var m=class{constructor(t){this.placeholderRegex=/\{\{\s*(\w+)\s*\}\}/;var r;this.moneyFormat=(r=t.moneyFormat)!=null?r:"${{amount}}",this.currencyRate=t.currencyRate,this.activeCurrency=t.activeCurrency}formatMoney(t){var r;return typeof t=="string"&&(t=parseInt(t.replace(".",""))),this.moneyFormat.replace(this.placeholderRegex,this.formatCents(t,(r=this.moneyFormat.match(this.placeholderRegex))==null?void 0:r[1]))}formatCents(t,r){switch(r){case"amount_no_decimals":return this.formatWithDelimiters(t,0);case"amount_with_comma_separator":return this.formatWithDelimiters(t,2,".",",");case"amount_no_decimals_with_comma_separator":return this.formatWithDelimiters(t,0,".",",");case"amount":default:return this.formatWithDelimiters(t,2)}}formatWithDelimiters(t,r=2,e=",",i="."){if(isNaN(t)||t==null)return"0";let n=(t/100).toFixed(r).split("."),a=n[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${e}`),s=n[1]?i+n[1]:"";return a+s}};var f=class{constructor(){}getFormState({product:t,options:r,autoSelect:e=!1,change:i}){let o=this.getSelectedOptions({product:t,options:r,change:i,autoSelect:e}),n=o&&Object.values(o).every(u=>!!u),a=this.getOptionsWithValues({product:t,selectedOptions:o});return{selectedVariant:this.getVariantByOptions({product:t,options:o}),selectedOptions:o,hasSelection:n,optionsWithValues:a,hasOnlyDefaultVariant:t.variants.length===1}}getSelectedOptions({product:t,options:r,autoSelect:e,change:i={}}){let o=Object.fromEntries(Object.entries({...r,...i}).map(([l,c],h)=>{var p;return!c&&((p=t.options[h])==null?void 0:p.values.length)===1?[l,t.options[h].values[0]]:[l,c]}));if(!e)return o;e===!0&&(e="unavailable");let n=this.getVariantByOptions({product:t,options:o});if(e==="unavailable"&&n||e==="soldout"&&(n==null?void 0:n.available))return o;let a=Object.keys(i).pop(),s=Object.fromEntries(Object.entries(o).filter(([l])=>!a||l<=a)),u=Object.fromEntries(Object.entries(o).filter(([l])=>!(l in s)));return Object.entries(u).reduce((l,[c,h])=>{var y;let p=this.getAllVariantsByOptions({product:t,options:l});return p.length?{...l,[c]:((y=p.find(O=>O.available))!=null?y:p[0])[c]}:{...l,[c]:null}},s)}getVariantOptions({variant:t}){var r,e,i;return{option1:(r=t==null?void 0:t.option1)!=null?r:null,option2:(e=t==null?void 0:t.option2)!=null?e:null,option3:(i=t==null?void 0:t.option3)!=null?i:null}}getOptionsWithValues({product:t,selectedOptions:r={}}){return t.options.map(e=>{var s;let i=`option${e.position}`,o=this.getUnavailableOptionValues({product:t,optionKey:i,selectedOptions:r,values:e.values}),n=this.getSoldoutOptionValues({product:t,optionKey:i,selectedOptions:r,values:e.values}),a=(s=r==null?void 0:r[i])!=null?s:null;return{...e,selectedValue:a,soldoutValues:n,unavailableValues:o}})}getSoldoutOptionValues({product:t,optionKey:r,values:e,selectedOptions:i={}}){let o=Object.fromEntries(Object.entries(i).filter(([n])=>n<r));return e.filter(n=>{let a=t.variants.filter(s=>this.matchesVariant({variant:s,options:{...o,[r]:n}}));return a.length?a.every(s=>!s.available):!1})}getUnavailableOptionValues({product:t,optionKey:r,values:e,selectedOptions:i={}}){let o=Object.fromEntries(Object.entries(i).filter(([n])=>n<r));return e.filter(n=>t.variants.every(a=>!this.matchesVariant({variant:a,options:{...o,[r]:n}})))}getFirstAvailableVariant({product:t}){var r;return(r=t.variants.find(e=>e.available))!=null?r:null}getSelectedVariant({product:t,variantId:r}){var e;return(e=t.variants.find(i=>i.id===r))!=null?e:null}matchesVariant({variant:t,options:r}){return(!(r!=null&&r.option1)||r.option1===t.option1)&&(!(r!=null&&r.option2)||r.option2===t.option2)&&(!(r!=null&&r.option3)||r.option3===t.option3)}getFormData({form:t,product:r}){let e=new FormData(t);return{quantity:this.getFormQuantity({form:t}),options:this.getFormOptions({formData:e,product:r})}}getFormQuantity({form:t}){var i;let e=(i=new FormData(t).get("quantity"))==null?void 0:i.toString();return e?parseInt(e):1}getVariantByOptions({product:t,options:r}){var i;let e=Object.entries(r).reduce((o,[,n],a)=>(o[a]=n,o),new Array(3).fill(null));return(i=t.variants.find(o=>e.every((n,a)=>o[`option${a+1}`]===n)))!=null?i:null}getAllVariantsByOptions({product:t,options:r}){var i;let e=Object.entries(r).reduce((o,[,n],a)=>(o[a]=n,o),new Array(3).fill(null));return(i=t.variants.filter(o=>e.every((n,a)=>!n||o[`option${a+1}`]===n)))!=null?i:[]}getFormOptions({formData:t,product:r}){return Array.from(t.entries()).reduce((e,[i,o])=>{var s;let n=(s=i.match(/\[(.*?)\]/))==null?void 0:s[1];if(!n)return e;let a=r.options.findIndex(u=>u.name===n)+1;if(a>0){let u=`option${a}`;e[u]=o.toString()||null}return e},{})}getInputOption({input:t,product:r}){var o;let e=(o=t.name.match(/\[(.*?)\]/))==null?void 0:o[1];if(!e)return null;let i=r.options.findIndex(n=>n.name===e)+1;return i>0?{[`option${i}`]:t.value.toString()}:null}};var d=class{constructor(t){this.rootUrl=t.rootUrl,this.shopDomain=t.shopDomain,this.wishlistUrl=t.wishlistUrl,this.placeholderImageUrl=t.placeholderImageUrl,this.fileUrl=t.fileUrl}getPublicWishlistUrl(t){return`https://${this.shopDomain}${this.wishlistUrl}/${t}`}getFileUrl(t=""){return`https:${this.fileUrl.split("?")[0]}${t}`}getImageUrl(t,r){var i,o;if(!t)return(i=this.placeholderImageUrl)!=null?i:"";let e=this.getImage(t);return e!=null&&e.src?this.appendSize(e.src,r):(o=this.placeholderImageUrl)!=null?o:""}getImage(t){var r,e,i,o;if(t.hasOwnProperty("sku"))return{src:(e=(r=t.featured_image)==null?void 0:r.src)!=null?e:""};if((i=t==null?void 0:t.images)!=null&&i.length){let n=t;return{src:(o=n.featured_image)!=null?o:n.images[0]}}else if(t.hasOwnProperty("src"))return{src:t.src};return null}appendSize(t,r){let e=new URL(t.startsWith("//")?`https://${t}`:t);return r!=null&&r.width&&e.searchParams.set("width",r==null?void 0:r.width.toString()),r!=null&&r.height&&e.searchParams.set("height",r==null?void 0:r.height.toString()),e.href}getVariantUrl(t,r){if(!!t)return r?t+`?variant=${r}`:t}};export{m as MoneyUtil,f as ProductUtil,d as UrlUtil};

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

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 n=s(e);return n?this.searchByStyle(t,n,s,i-1):null}};var u=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=>this.scan(s))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),K(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){this.subscriber.filter(e=>K(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=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 K({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 G=[{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:"home",match:a=>a.length<4}],m=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of G)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var g=class{constructor(t){var e;this.locale=this.decodeLocale((e=t.locale)!=null?e:{})}decodeHtmlEntities(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/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){var i,r;let[e,s]=t.split(".");return(r=(i=this.locale[e])==null?void 0:i[s])!=null?r:`translation missing: ${t}`}};var d=class{constructor({rootUrl:t,wishlistUrl:e,locale:s}){this._rootUrl=t,this.route=new m({wishlistUrl:e}),this.observer=new u({routeUtil:this.route}),this.locale=new g({locale:s}),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){return this.locale.translate(t)}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,o])=>{!o||(typeof o=="boolean"?s.dataset[r]="":typeof o=="object"?s.dataset[r]=JSON.stringify(o):s.dataset[r]=o)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,o])=>{s[r]=o}),(i=e==null?void 0:e.wrap)!=null&&i.name&&this.createElement(e.wrap.name,e.wrap.props,s),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))}};var q=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.loadWishlistProduct=t=>this.state.promise.loadWishlistProduct(t);this.publishWishlistEvent=t=>this.state.promise.publishWishlistEvent(t);this.publishWishlistItemEvent=t=>this.state.promise.publishWishlistItemEvent(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 d({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,locale:this.config.locale});let{stylesheets:s,scripts:i}=t.reduce(({stylesheets:r,scripts:o},n)=>{let[l]=n.split("?");return l.endsWith(".css")?r.push(n):l.endsWith(".js")&&o.push(n),{stylesheets:r,scripts:o}},{stylesheets:[],scripts:[]});this.initStyles(s),this.initScripts(i),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load()}get loaded(){return this._loaded}get state(){return w(this._state)}get apis(){return w(this._apis)}get utils(){return w(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}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:o,ProductUtil:n}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:o,ProductUtil:n}),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}){let i=this.config.shop.domain,r=this.config.products.fallbackImage,o=this.config.shop.moneyFormat;this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:i,placeholderImageUrl:r,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:o,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),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()}),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(t){if(!(t!=null&&t.length)){this.onStylesLoaded();return}try{await Promise.all(t.map(e=>new Promise((s,i)=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onload=s,r.onerror=i,document.head.appendChild(r)}))),this.onStylesLoaded()}catch(e){console.warn(e),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],o=t.apply(history,s);if(!r)return o;let n=this.theme.getProductHandle(r),l=r.searchParams.get("variant");if(!n||!l)return o;e({productHandle:n,variantId:parseInt(l)})}}parseConfig({config:t,locale:e}){var s,i,r,o,n,l,c,h;return{customer:{id:t.customerId?parseInt(t.customerId):null,email:(s=t.customerEmail)!=null?s:""},shop:{name:(i=t.shopName)!=null?i:"",domain:(r=t.shopDomain)!=null?r:"",permanentDomain:(o=t.shopPermanentDomain)!=null?o:"",currency:(n=t.shopCurrency)!=null?n:"",moneyFormat:(l=t.shopMoneyFormat)!=null?l:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(c=t.apiHost)!=null?c:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(h=t.productFallbackImage)!=null?h:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:e}}parseSettings({settings:t}){var e,s,i,r,o,n,l,c,h,f,b,U,S,v,W,P,E,T,A,I,k,R,L,C,_,N,H,M,O,x,D,B,j,V,F;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:(n=(o=t==null?void 0:t.general)==null?void 0:o.wishlistMode)!=null?n:"PRODUCT",wishlistPath:(c=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?c:"/apps/wishlist"},wishlistPage:{addToCartMode:(f=(h=t==null?void 0:t.wishlistPage)==null?void 0:h.addToCartMode)!=null?f:"KEEP_IN_WISHLIST",buyButtonType:(U=(b=t==null?void 0:t.wishlistPage)==null?void 0:b.buyButtonType)!=null?U:"ADD_TO_CART",shareButtonType:(v=(S=t==null?void 0:t.wishlistPage)==null?void 0:S.shareButtonType)!=null?v:"WEB_SHARE",loginHintType:(P=(W=t==null?void 0:t.wishlistPage)==null?void 0:W.loginHintType)!=null?P:"CALLOUT",variantAutoSelectMode:(T=(E=t==null?void 0:t.wishlistPage)==null?void 0:E.variantAutoSelectMode)!=null?T:"NEVER",variantSelctorType:(I=(A=t==null?void 0:t.wishlistPage)==null?void 0:A.variantSelctorType)!=null?I:"DROPDOWNS"},integrations:{googleAnalytics:{enabled:(L=(R=(k=t.integrations)==null?void 0:k.googleAnalytics)==null?void 0:R.enabled)!=null?L:!1,tracker:(N=(_=(C=t.integrations)==null?void 0:C.googleAnalytics)==null?void 0:_.tracker)!=null?N:""},klaviyo:{enabled:(O=(M=(H=t.integrations)==null?void 0:H.klaviyo)==null?void 0:M.enabled)!=null?O:!1},metaPixel:{enabled:(B=(D=(x=t.integrations)==null?void 0:x.metaPixel)==null?void 0:D.enabled)!=null?B:!1},wishlistAnalytics:{enabled:(F=(V=(j=t.integrations)==null?void 0:j.metaPixel)==null?void 0:V.enabled)!=null?F:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4}}}}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"}}},w=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{q as WishlistApp};
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 n=s(e);return n?this.searchByStyle(t,n,s,i-1):null}};var u=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=>this.scan(s))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),K(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){this.subscriber.filter(e=>K(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=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 K({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 G=[{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:"home",match:a=>a.length<4}],m=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of G)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var g=class{constructor(t){var e;this.locale=this.decodeLocale((e=t.locale)!=null?e:{})}decodeHtmlEntities(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/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 o;let[s,i]=t.split("."),r=(o=this.locale[s])==null?void 0:o[i];return r?e?Object.entries(e).reduce((n,[l,c])=>n.replace(new RegExp(`{{\\s*${l}\\s*}}`,"g"),c),r):r:`translation missing: ${t}`}};var d=class{constructor({rootUrl:t,wishlistUrl:e,locale:s}){this._rootUrl=t,this.route=new m({wishlistUrl:e}),this.observer=new u({routeUtil:this.route}),this.locale=new g({locale:s}),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,o])=>{!o||(typeof o=="boolean"?s.dataset[r]="":typeof o=="object"?s.dataset[r]=JSON.stringify(o):s.dataset[r]=o)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,o])=>{s[r]=o}),(i=e==null?void 0:e.wrap)!=null&&i.name&&this.createElement(e.wrap.name,e.wrap.props,s),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))}};var q=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 d({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,locale:this.config.locale});let{stylesheets:s,scripts:i}=t.reduce(({stylesheets:r,scripts:o},n)=>{let[l]=n.split("?");return l.endsWith(".css")?r.push(n):l.endsWith(".js")&&o.push(n),{stylesheets:r,scripts:o}},{stylesheets:[],scripts:[]});this.initStyles(s),this.initScripts(i),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load()}get loaded(){return this._loaded}get state(){return w(this._state)}get apis(){return w(this._apis)}get utils(){return w(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:o,ProductUtil:n}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:o,ProductUtil:n}),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}){let i=this.config.shop.domain,r=this.config.products.fallbackImage,o=this.config.shop.moneyFormat;this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:i,placeholderImageUrl:r,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:o,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),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()}),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(t){if(!(t!=null&&t.length)){this.onStylesLoaded();return}try{await Promise.all(t.map(e=>new Promise((s,i)=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onload=s,r.onerror=i,document.head.appendChild(r)}))),this.onStylesLoaded()}catch(e){console.warn(e),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],o=t.apply(history,s);if(!r)return o;let n=this.theme.getProductHandle(r),l=r.searchParams.get("variant");if(!n||!l)return o;e({productHandle:n,variantId:parseInt(l)})}}parseConfig({config:t,locale:e}){var s,i,r,o,n,l,c,h;return{customer:{id:t.customerId?t.customerId:null,email:(s=t.customerEmail)!=null?s:""},shop:{name:(i=t.shopName)!=null?i:"",domain:(r=t.shopDomain)!=null?r:"",permanentDomain:(o=t.shopPermanentDomain)!=null?o:"",currency:(n=t.shopCurrency)!=null?n:"",moneyFormat:(l=t.shopMoneyFormat)!=null?l:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(c=t.apiHost)!=null?c:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(h=t.productFallbackImage)!=null?h:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:e}}parseSettings({settings:t}){var e,s,i,r,o,n,l,c,h,f,b,U,S,v,P,E,W,T,A,k,I,R,L,C,_,N,H,M,O,x,D,B,j,V,F;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:(n=(o=t==null?void 0:t.general)==null?void 0:o.wishlistMode)!=null?n:"PRODUCT",wishlistPath:(c=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?c:"/apps/wishlist"},wishlistPage:{addToCartMode:(f=(h=t==null?void 0:t.wishlistPage)==null?void 0:h.addToCartMode)!=null?f:"KEEP_IN_WISHLIST",buyButtonType:(U=(b=t==null?void 0:t.wishlistPage)==null?void 0:b.buyButtonType)!=null?U:"ADD_TO_CART",shareButtonType:(v=(S=t==null?void 0:t.wishlistPage)==null?void 0:S.shareButtonType)!=null?v:"WEB_SHARE",loginHintType:(E=(P=t==null?void 0:t.wishlistPage)==null?void 0:P.loginHintType)!=null?E:"CALLOUT",variantAutoSelectMode:(T=(W=t==null?void 0:t.wishlistPage)==null?void 0:W.variantAutoSelectMode)!=null?T:"NEVER",variantSelctorType:(k=(A=t==null?void 0:t.wishlistPage)==null?void 0:A.variantSelctorType)!=null?k:"DROPDOWNS"},integrations:{googleAnalytics:{enabled:(L=(R=(I=t.integrations)==null?void 0:I.googleAnalytics)==null?void 0:R.enabled)!=null?L:!1,tracker:(N=(_=(C=t.integrations)==null?void 0:C.googleAnalytics)==null?void 0:_.tracker)!=null?N:""},klaviyo:{enabled:(O=(M=(H=t.integrations)==null?void 0:H.klaviyo)==null?void 0:M.enabled)!=null?O:!1},metaPixel:{enabled:(B=(D=(x=t.integrations)==null?void 0:x.metaPixel)==null?void 0:D.enabled)!=null?B:!1},wishlistAnalytics:{enabled:(F=(V=(j=t.integrations)==null?void 0:j.metaPixel)==null?void 0:V.enabled)!=null?F:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4}}}}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"}}},w=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{q as WishlistApp};

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

var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var l=(o,a,t,e)=>{for(var i=e>1?void 0:e?g(a,t):a,s=o.length-1,r;s>=0;s--)(r=o[s])&&(i=(e?r(a,t,i):r(i))||i);return e&&i&&f(a,t,i),i};import{delayWhen as v,from as p,fromEvent as h,isObservable as m,map as C,of as u}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{filter as d,first as S,switchMap as y,tap as b}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{state as E}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{LitElement as k}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{WishlistStateController as P}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.1/controllers.js";var c=class extends k{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.stateCtrl=new P(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"]}appReadyCallback(){}beforeNextState(t){}async connect(){if(!this.connected){if(!this.app.stylesLoaded){h(document,"wk:app:load-styles:success").pipe(S()).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{}}getTranslation(t){return this.app.theme?this.app.theme.translate(t):t}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var e;this.state={...(e=this.state)!=null?e:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML="",this.initEvents(),this.connect()}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.connected=!1,this.cleanupMethods.forEach(i=>i()),(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),this.connected&&this.initState()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.updateState(t)}),this.appReadyCallback()}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(t)}initObserver(){this.observer=new IntersectionObserver(t=>this.handleIntersect(t),{root:null,rootMargin:"0px"}),this.observer.observe(this)}handleIntersect([t]){var e;t.isIntersecting&&((e=this.observer)==null||e.disconnect(),this.initState())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([i,s])=>{let[r,n]=i.split(/ (.*)/s);return this.subscribeToEvent({eventName:r,selector:n,handler:s})});this.cleanupMethods.push(()=>e.forEach(i=>i.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:i}){return h(this,t).pipe(b(s=>{this.eventPending&&s.preventDefault()}),d(()=>!this.eventPending),b(()=>{this.eventPending=!0}),C(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),d(({target:s})=>!!s),v(s=>this.app.hasSession?u(s):p(this.app.load())),y(({event:s,target:r})=>{let n=e.bind(this)(s,r);return m(n)?n:typeof(n==null?void 0:n.then)=="function"?p(n):u(n)})).subscribe(()=>{this.eventPending=!1})}};l([E()],c.prototype,"state",2);export{c as WishlistElement};
var g=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=(c,a,t,e)=>{for(var i=e>1?void 0:e?m(a,t):a,s=c.length-1,n;s>=0;s--)(n=c[s])&&(i=(e?n(a,t,i):n(i))||i);return e&&i&&g(a,t,i),i};import{delayWhen as y,from as p,fromEvent as h,isObservable as v,map as S,of as u}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{filter as d,first as C,switchMap as E,tap as f}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{state as b}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{LitElement as P}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{unsafeHTML as k}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/unsafe-html.js/+esm";import{WishlistStateController as M}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";var o=class extends P{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.list=[];this.stateCtrl=new M(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"]}appReadyCallback(){}beforeNextState(t){}async connect(){if(!this.connected){if(!this.app.stylesLoaded){h(document,"wk:app:load-styles:success").pipe(C()).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{}}getTranslation(t,e){if(!this.app.theme)return t;let i=this.app.theme.translate(t,e);return t.endsWith("_html")?k(i):i}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)}formatMoney(t){return this.app.utils.money.formatMoney(t)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var e;this.state={...(e=this.state)!=null?e:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML="",this.initEvents(),this.connect()}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.updateState(t)}),this.appReadyCallback()}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(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())}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 h(this,t).pipe(f(s=>{this.eventPending&&s.preventDefault()}),d(()=>!this.eventPending),f(()=>{this.eventPending=!0}),S(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),d(({target:s})=>!!s),y(s=>this.app.hasSession?u(s):p(this.app.load())),E(({event:s,target:n})=>{let r=e.bind(this)(s,n);return v(r)?r:typeof(r==null?void 0:r.then)=="function"?p(r):u(r)})).subscribe(()=>{this.eventPending=!1})}};l([b()],o.prototype,"state",2),l([b()],o.prototype,"list",2);export{o as WishlistElement};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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