@appmate/wishlist
Advanced tools
Comparing version 4.15.7 to 4.16.0
@@ -1,2 +0,2 @@ | ||
var O=Object.create;var E=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var H=(s,i)=>()=>(i||s((i={exports:{}}).exports,i),i.exports);var G=(s,i,t,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of V(i))!z.call(s,r)&&r!==t&&E(s,r,{get:()=>i[r],enumerable:!(e=K(i,r))||e.enumerable});return s};var J=(s,i,t)=>(t=s!=null?O(B(s)):{},G(i||!s||!s.__esModule?E(t,"default",{value:s,enumerable:!0}):t,s));var C=H((Ut,q)=>{"use strict";var rt=function(){function s(t,e){if(typeof t!="function")throw new TypeError("DataLoader must be constructed with a function which accepts "+("Array<key> and returns Promise<Array<value>>, but got: "+t+"."));this._batchLoadFn=t,this._maxBatchSize=ot(e),this._batchScheduleFn=ct(e),this._cacheKeyFn=ht(e),this._cacheMap=lt(e),this._batch=null}var i=s.prototype;return i.load=function(e){if(e==null)throw new TypeError("The loader.load() function must be called with a value, "+("but got: "+String(e)+"."));var r=nt(this),n=this._cacheMap,a=this._cacheKeyFn(e);if(n){var o=n.get(a);if(o){var h=r.cacheHits||(r.cacheHits=[]);return new Promise(function(p){h.push(function(){p(o)})})}}r.keys.push(e);var c=new Promise(function(p,u){r.callbacks.push({resolve:p,reject:u})});return n&&n.set(a,c),c},i.loadMany=function(e){if(!N(e))throw new TypeError("The loader.loadMany() function must be called with Array<key> "+("but got: "+e+"."));for(var r=[],n=0;n<e.length;n++)r.push(this.load(e[n]).catch(function(a){return a}));return Promise.all(r)},i.clear=function(e){var r=this._cacheMap;if(r){var n=this._cacheKeyFn(e);r.delete(n)}return this},i.clearAll=function(){var e=this._cacheMap;return e&&e.clear(),this},i.prime=function(e,r){var n=this._cacheMap;if(n){var a=this._cacheKeyFn(e);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}(),st=typeof process=="object"&&typeof process.nextTick=="function"?function(s){P||(P=Promise.resolve()),P.then(function(){process.nextTick(s)})}:typeof setImmediate=="function"?function(s){setImmediate(s)}:function(s){setTimeout(s)},P;function nt(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 t={hasDispatched:!1,keys:[],callbacks:[]};return s._batch=t,s._batchScheduleFn(function(){at(s,t)}),t}function at(s,i){if(i.hasDispatched=!0,i.keys.length===0){T(i);return}var t=s._batchLoadFn(i.keys);if(!t||typeof t.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(t)+".")));t.then(function(e){if(!N(e))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(e)+"."));if(e.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 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."+(` | ||
@@ -7,2 +7,2 @@ Keys: | ||
Values: | ||
`+String(e)));T(i);for(var r=0;r<i.callbacks.length;r++){var n=e[r];n instanceof Error?i.callbacks[r].reject(n):i.callbacks[r].resolve(n)}}).catch(function(e){F(s,i,e)})}function F(s,i,t){T(i);for(var e=0;e<i.keys.length;e++)s.clear(i.keys[e]),i.callbacks[e].reject(t)}function T(s){if(s.cacheHits)for(var i=0;i<s.cacheHits.length;i++)s.cacheHits[i]()}function ot(s){var i=!s||s.batch!==!1;if(!i)return 1;var t=s&&s.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!="number"||t<1)throw new TypeError("maxBatchSize must be a positive number: "+t);return t}function ct(s){var i=s&&s.batchScheduleFn;if(i===void 0)return st;if(typeof i!="function")throw new TypeError("batchScheduleFn must be a function: "+i);return i}function ht(s){var i=s&&s.cacheKeyFn;if(i===void 0)return function(t){return t};if(typeof i!="function")throw new TypeError("cacheKeyFn must be a function: "+i);return i}function lt(s){var i=!s||s.cache!==!1;if(!i)return null;var t=s&&s.cacheMap;if(t===void 0)return new Map;if(t!==null){var e=["get","set","delete","clear"],r=e.filter(function(n){return t&&typeof t[n]!="function"});if(r.length!==0)throw new TypeError("Custom cacheMap missing methods: "+r.join(", "))}return t}function N(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))}q.exports=rt});import{of as M}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var{ga:d}=window,m=class{constructor(){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:t,variant:e,quantity:r=1}){var a;let n=this.eventNames.get(i);return!n||!(d!=null&&d.loaded)||!t?M(!1):(d("ec:addProduct",{id:(a=(e==null?void 0:e.sku)||(e==null?void 0:e.id))!=null?a:t.id,name:t.title,category:t.type,brand:t.vendor,variant:e==null?void 0:e.title,quantity:r}),d("send",{eventAction:n,hitType:"event",eventCategory:"Wishlist",eventLabel:"Wishlist King"}),M(!0))}};import{of as L}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var f=class{constructor({urlUtil:i,moneyUtil:t}){this.urlUtil=i,this.moneyUtil=t,this.eventNames=new Map([["addToWishlist","Added To Wishlist"],["removeFromWishlist","Removed From Wishlist"],["clearWishlist","Cleared Wishlist"]])}track({eventName:i,wishlist:t,product:e,variant:r,quantity:n=1}){let a=this.eventNames.get(i);return!a||!t||!e?L(!1):(window._learnq||(window._learnq=[]),window._learnq.push(["track",a,{URL:this.urlUtil.getVariantUrl(e.url,r==null?void 0:r.id),Name:e.title,ProductID:e.id,VariantID:r==null?void 0:r.id,SKU:r==null?void 0:r.sku,Tags:e.tags,Brand:e.vendor,ImageURL:this.urlUtil.getImageUrl(e,{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(t.id)}]),L(!0))}};import{of as j}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var{fbq:U}=window,g=class{constructor({currency:i}){this.currency=i,this.eventNames=new Map([["addToWishlist","AddToWishlist"]])}track({eventName:i,product:t,variant:e}){let r=this.eventNames.get(i);return!r||typeof U!="function"||!t?j(!1):(U("track",r,{value:e==null?void 0:e.price,currency:this.currency,content_ids:[t.id],content_name:[t.title,e==null?void 0:e.title].filter(n=>!!n).join(" - "),content_category:t.type,content_type:"product_group",num_items:1}),j(!0))}};import{catchError as $,map as Q,of as R}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{fromFetch as X}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/fetch/+esm";var y=class{constructor({host:i,shop:t,sessionId:e,customerId:r}){this.host=i,this.shop=t,this.customerId=r,this.sessionId=e,this.eventNames=new Map([["viewWishlist","wishlist_viewed"],["addToCart","product_added_to_cart"],["shareWishlist","wishlist_shared"]])}track({eventName:i,wishlist:t,product:e,variant:r,quantity:n,source:a}){var h,c;let o=this.eventNames.get(i);return!o||!t?R(!1):X(this.host+"/notify",{method:"POST",headers:{"content-type":"application/json","x-appmate-shp":this.shop,"x-appmate-sid":this.sessionId,"x-appmate-cid":(c=(h=this.customerId)==null?void 0:h.toString())!=null?c:""},body:JSON.stringify({event:o,wid:t.publicId,pid:e==null?void 0:e.id,vid:r==null?void 0:r.id,qty:n,src:a})}).pipe(Q(()=>!0),$(()=>R(!1)))}getQuerystring(i){if(!i)return"";let t=new URLSearchParams;return Object.entries(i).forEach(([e,r])=>{Array.isArray(r)?r.forEach(n=>t.append(e,n)):r&&t.append(e,r)}),"?"+t.toString()}};import{fromFetch as Y}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/fetch/+esm";import{switchMap as Z}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";var l=class{constructor(i){this.host=i.host,this.headers={"content-type":"application/json"}}fetch({path:i,method:t="GET",query:e,body:r,headers:n={}}){return Y(this.host+i+this.getQuerystring(e),{method:t,headers:{...this.headers,...n},body:r}).pipe(Z(a=>{if(a.ok)return a.json();throw Error(`Error ${a.status}`)}))}getQuerystring(i){if(!i)return"";let t=new URLSearchParams;return Object.entries(i).forEach(([e,r])=>{Array.isArray(r)?r.forEach(n=>t.append(e,n)):r&&t.append(e,r)}),"?"+t.toString()}get({path:i,query:t,headers:e}){return this.fetch({method:"GET",path:i,query:t,headers:e})}post({path:i,query:t,body:e,headers:r}){return this.fetch({method:"POST",path:i,query:t,body:e?JSON.stringify(e):void 0,headers:r})}put({path:i,query:t,body:e,headers:r}){return this.fetch({method:"PUT",path:i,query:t,body:e?JSON.stringify(e):void 0,headers:r})}delete({path:i,query:t,body:e,headers:r}){return this.fetch({method:"DELETE",path:i,query:t,body:e?JSON.stringify(e):void 0,headers:r})}};var _=class extends l{loadProduct({productHandle:i}){return this.get({path:`/products/${i}.js`})}addToCart(i){return this.post({path:"/cart/add.js",body:i})}};import{forkJoin as tt,lastValueFrom as et,of as it}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var v=class{constructor({settings:i,events:t,notifyHost:e,utils:r,shop:n,sessionId:a,customerId:o}){this.utils=r,this.services=[],i.appmateAnalytics&&this.services.push(new y({host:e,shop:n,customerId:o,sessionId:a})),i.klaviyo&&this.services.push(new f({urlUtil:this.utils.url,moneyUtil:this.utils.money})),i.facebookPixel&&this.services.push(new g({currency:window.Shopify.currency.active})),i.googleAnalytics&&this.services.push(new m);let h=this.utils.route.parse(window.location.pathname).pageType,c=p=>u=>{var W,S,A,x;return et(this.track({eventName:p,source:h,wishlist:(W=u.data)==null?void 0:W.wishlist,product:(S=u.data)==null?void 0:S.product,variant:(A=u.data)==null?void 0:A.variant,quantity:(x=u.data)==null?void 0:x.quantity}))};t.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?tt(this.services.map(t=>t.track(i))):it([])}};var w=J(C());import{from as I,lastValueFrom as b}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var D="4.15.7";var k=class extends l{constructor(t){var e,r,n;super(t);this.headers={"content-type":"application/json","x-appmate-shp":t.shop,"x-appmate-tkv":D,"x-appmate-sid":t.sessionId,"x-appmate-cid":(r=(e=t.customerId)==null?void 0:e.toString())!=null?r:"","x-appmate-src":(n=t.trackingSource)!=null?n:""},this.wishlistLoader=this.createWishlistLoader(),this.productInfoLoader=this.createProductInfoLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}createWishlistLoader(){return new w.default(async t=>{let e=t.map(n=>n.split("-")).reduce((n,[a,o])=>(n[a]||(n[a]=[]),n[a].push(o),n),{}),r=await Promise.all(Object.entries(e).map(([n,a])=>b(this.get({path:`/wishlists/${n}`,query:{format:a.includes("all")?"all":"minimal"}})))).then(n=>n.map(a=>a.wishlist));return t.map((n,a)=>{var h;let[o]=n.split("-");return(h=r.find(c=>o==="mine"?c.isMine:c.publicId===o))!=null?h:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createProductInfoLoader(){return new w.default(async t=>{let{productInfo:e}=await b(this.get({path:"/wishlists/mine/product-info",headers:{"X-Appmate-IDS":t.join(",")}}));return t.map(r=>{var n;return(n=e.find(a=>a.productId===r))!=null?n:{productId:r,wishlistItems:[]}})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createWishlistItemLoader(){return new w.default(async t=>{let e=t.map(n=>n.split("-")).reduce((n,[a,o])=>(n[a]||(n[a]=[]),n[a].push(o),n),{}),r=await Promise.all(Object.entries(e).map(([n,a])=>b(this.get({path:`/wishlists/${n}/items`,headers:{"X-Appmate-IDS":a.join(",")}})))).then(n=>n.flatMap(a=>a.items));return t.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:t=>setTimeout(t,250)})}loadWishlist({wishlistId:t,format:e}){return I(this.wishlistLoader.load([t,e].join("-")).then(r=>({wishlist:r})))}loadProductInfo({productId:t}){return I(this.productInfoLoader.load(t).then(e=>({productInfo:e})))}loadWishlistItem({wishlistId:t,wishlistItemId:e}){return I(this.wishlistItemLoader.load([t,e].join("-")).then(r=>({wishlistItem:r})))}loadWishlistItems({wishlistId:t,wishlistItemIds:e}){return b(this.get({path:`/wishlists/${t}/items`,headers:{"X-Appmate-IDS":e.join(",")}}))}addItem({productId:t,variantId:e}){return typeof t=="string"&&(t=parseInt(t)),typeof e=="string"&&(e=parseInt(e)),this.post({path:"/wishlists/mine/items",body:{productId:t,variantId:e}})}updateItem({wishlistItemId:t,changes:e}){return this.put({path:"/wishlists/mine/items",body:{changes:{...e,wishlistItemId:t}}})}removeItem({wishlistId:t,wishlistItemId:e}){return this.delete({path:`/wishlists/${t}/items`,body:{wishlistItemId:e}})}clearWishlist(){return this.delete({path:"/wishlists/mine"})}};export{m as GoogleAnalytics,f as KlaviyoTracking,g as MetaPixel,y as NotifyApi,l as RestApi,_ as ShopifyApi,v as TrackingApi,k as WishlistApi}; | ||
`+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}; |
@@ -1,1 +0,1 @@ | ||
var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=(p,s,o,l)=>{for(var t=l>1?void 0:l?h(s,o):s,n=p.length-1,r;n>=0;n--)(r=p[n])&&(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 m,property as a}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as u}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/lit-html/+esm";import{classMap as c}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/controllers.js";var e=class extends y{constructor(){super(...arguments);this.text="";this.layout="text-only";this.parentheses=!1;this.hiddenIfEmpty=!1;this.floatingUi=new g(this)}updated(o){o.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var t,n,r;let o={"wk-badge":!0,"wk-parentheses":!!this.parentheses,"wk-pill":(n=(t=this.layout)==null?void 0:t.includes("pill"))!=null?n:!1};if(this.hiddenIfEmpty&&(!this.text||parseInt(this.text)===0))return;let l=(r=this.layout)!=null&&r.includes("text")?this.text:"";return u`<span class=${c(o)}>${l}</span>`}createRenderRoot(){return this}};i([a({type:String})],e.prototype,"text",2),i([a({type:String})],e.prototype,"layout",2),i([a({type:Boolean})],e.prototype,"parentheses",2),i([a({type:Boolean,attribute:"hidden-if-empty"})],e.prototype,"hiddenIfEmpty",2),i([a({type:Object})],e.prototype,"floating",2),e=i([m("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.16.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 c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=(o,i,e,n)=>{for(var a=n>1?void 0:n?p(i,e):i,s=o.length-1,g;s>=0;s--)(g=o[s])&&(a=(n?g(i,e,a):g(a))||a);return n&&a&&c(i,e,a),a};import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as x,property as l}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/lit-html/+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 b(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(!b(o[e],i[e]))return!1;return!0}function h(o,i){i===void 0&&(i=y);var e=null;function n(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];if(e&&e.lastThis===this&&i(a,e.lastArgs))return e.lastResult;var g=o.apply(this,a);return e={lastResult:g,lastArgs:a,lastThis:this},g}return n.clear=function(){e=null},n}import{FloatingUiController as $}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/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.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 a,s,g;let e=(a=this.alignment)!=null?a:"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.16.0/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.0/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.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 | ||
@@ -18,8 +18,7 @@ href=${this.href} | ||
</button> | ||
`}renderIcon(){var n;let e=(n=this.layout)!=null?n:"icon-and-text";if(!(!(e!=null&&e.includes("icon"))||!this.icon))return d`<wk-icon icon=${this.icon} class="wk-icon"></wk-icon>`}renderText(){var n;let e=(n=this.layout)!=null?n:"icon-and-text";if(!!(e!=null&&e.includes("text")))return d`<span class="wk-text">${this.text}</span>`}renderBadge(){if(!(!this.badgeLayout||this.badgeText===void 0))return d`<wk-badge | ||
`}renderIcon(){var n;let e=(n=this.layout)!=null?n:"icon-and-text";if(!(!(e!=null&&e.includes("icon"))||!this.icon))return d`<wk-icon icon=${this.icon} class="wk-icon"></wk-icon>`}renderText(){var n;let e=(n=this.layout)!=null?n:"icon-and-text";if(!!(e!=null&&e.includes("text")))return d`<span class="wk-text">${this.text}</span>`}renderBadge(){if(!(!this.badgeLayout||this.badgeHidden||this.badgeText===void 0)&&!(this.badgeHiddenIfEmpty&&(!this.badgeText||parseInt(this.badgeText)===0)))return d`<wk-badge | ||
.text=${this.badgeText} | ||
.layout=${this.badgeLayout} | ||
.parentheses=${!!this.badgeParentheses} | ||
.hiddenIfEmpty=${!!this.badgeHiddenIfEmpty} | ||
.floating=${this.getBadgeFloating(this.badgeFloating,this)} | ||
></wk-badge>`}createRenderRoot(){return this}};r([l({type:String})],t.prototype,"href",2),r([l({type:String})],t.prototype,"text",2),r([l({type:String})],t.prototype,"hint",2),r([l({type:Boolean})],t.prototype,"selected",2),r([l({type:Boolean})],t.prototype,"disabled",2),r([l({type:String})],t.prototype,"layout",2),r([l({type:String})],t.prototype,"icon",2),r([l({type:Boolean})],t.prototype,"outline",2),r([l({type:Boolean,attribute:"full-width"})],t.prototype,"fullWidth",2),r([l({type:String})],t.prototype,"alignment",2),r([l({type:Object})],t.prototype,"floating",2),r([l({type:String,attribute:"badge-text"})],t.prototype,"badgeText",2),r([l({type:String,attribute:"badge-layout"})],t.prototype,"badgeLayout",2),r([l({type:Boolean,attribute:"badge-parentheses"})],t.prototype,"badgeParentheses",2),r([l({type:Boolean,attribute:"badge-hidden-if-empty"})],t.prototype,"badgeHiddenIfEmpty",2),r([l({type:Object,attribute:"badge-floating"})],t.prototype,"badgeFloating",2),t=r([x("wk-button")],t);export{t as Button}; | ||
></wk-badge>`}createRenderRoot(){return this}};a([r({type:String})],t.prototype,"href",2),a([r({type:String})],t.prototype,"text",2),a([r({type:String})],t.prototype,"hint",2),a([r({type:Boolean})],t.prototype,"selected",2),a([r({type:Boolean})],t.prototype,"disabled",2),a([r({type:String})],t.prototype,"layout",2),a([r({type:String})],t.prototype,"icon",2),a([r({type:Boolean})],t.prototype,"outline",2),a([r({type:Boolean,attribute:"full-width"})],t.prototype,"fullWidth",2),a([r({type:String})],t.prototype,"alignment",2),a([r({type:Object})],t.prototype,"floating",2),a([r({type:String,attribute:"badge-text"})],t.prototype,"badgeText",2),a([r({type:String,attribute:"badge-layout"})],t.prototype,"badgeLayout",2),a([r({type:Boolean,attribute:"badge-parentheses"})],t.prototype,"badgeParentheses",2),a([r({type:Boolean,attribute:"badge-hidden"})],t.prototype,"badgeHidden",2),a([r({type:Boolean,attribute:"badge-hidden-if-empty"})],t.prototype,"badgeHiddenIfEmpty",2),a([r({type:Object,attribute:"badge-floating"})],t.prototype,"badgeFloating",2),t=a([x("wk-button")],t);export{t as Button}; |
@@ -1,1 +0,1 @@ | ||
var m=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var l=(s,r,t,n)=>{for(var e=n>1?void 0:n?a(r,t):r,o=s.length-1,c;o>=0;o--)(c=s[o])&&(e=(n?c(r,t,e):c(e))||e);return n&&e&&m(r,t,e),e};import{LitElement as d}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as h}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as f}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/lit-html/+esm";var i=class extends d{constructor(){super();this.gridItems=[]}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof HTMLElement&&this.gridItems.push(t);this.innerHTML=""}render(){return f` <div class="wk-grid">${this.gridItems}</div> `}createRenderRoot(){return this}};i=l([h("wk-grid")],i);export{i as Grid}; | ||
var m=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var l=(s,r,t,n)=>{for(var e=n>1?void 0:n?a(r,t):r,o=s.length-1,c;o>=0;o--)(c=s[o])&&(e=(n?c(r,t,e):c(e))||e);return n&&e&&m(r,t,e),e};import{LitElement as d}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as h}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as f}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";var i=class extends d{constructor(){super();this.gridItems=[]}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof HTMLElement&&this.gridItems.push(t);this.innerHTML=""}render(){return f` <div class="wk-grid">${this.gridItems}</div> `}createRenderRoot(){return this}};i=l([h("wk-grid")],i);export{i as Grid}; |
@@ -1,1 +0,1 @@ | ||
var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var c=(a,r,t,e)=>{for(var n=e>1?void 0:e?m(r,t):r,s=a.length-1,o;s>=0;s--)(o=a[s])&&(n=(e?o(r,t,n):o(n))||n);return e&&n&&d(r,t,n),n};import{LitElement as l}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as f,property as p}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{svg as u,html as g,unsafeStatic as R}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/static/+esm";var i=class extends l{constructor(){super(...arguments);this.icon=""}static setIcons(t){i.icons=t}static addIcons(t){Object.assign(i.icons,t)}static removeIcons(t){Object.entries(i.icons).filter(([e])=>!t.includes(e))}render(){var e;if(!this.icon)return g`<!-- icon not defined -->`;let t=(e=i.icons[this.icon])!=null?e:g`<!-- icon not found -->`;return u`${R(t)}`}createRenderRoot(){return this}};i.icons={},c([p({type:String})],i.prototype,"icon",2),i=c([f("wk-icon")],i);export{i as Icon}; | ||
var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var c=(g,r,i,s)=>{for(var n=s>1?void 0:s?m(r,i):r,e=g.length-1,o;e>=0;e--)(o=g[e])&&(n=(s?o(r,i,n):o(n))||n);return s&&n&&d(r,i,n),n};import{LitElement as p}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as f,property as l}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{svg as a,unsafeStatic as u}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/static/+esm";var t=class extends p{constructor(){super();this.icon="";this.classList.add("wk-icon")}static addIcons(i){this.icons={...this.icons,...i}}render(){var s;if(!this.icon)return a`<svg><!-- icon not defined --></svg>`;let i=(s=t.icons[this.icon])!=null?s:a`<svg><!-- icon not found --></svg>`;return a`${u(i)}`}createRenderRoot(){return this}};t.icons={},c([l({type:String})],t.prototype,"icon",2),t=c([f("wk-icon")],t);export{t as Icon}; |
@@ -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/lit-html/+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.15.7/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.16.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,6 +0,6 @@ | ||
var p=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var n=(l,s,t,o)=>{for(var i=o>1?void 0:o?d(s,t):s,c=l.length-1,a;c>=0;c--)(a=l[c])&&(i=(o?a(s,t,i):a(i))||i);return o&&i&&p(s,t,i),i};import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as h,property as r}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as u}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/lit-html/+esm";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import k from"https://cdn.jsdelivr.net/npm/short-unique-id@4.4.4/+esm";import{Icon as w}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/components/icon.js";var f=new k({length:10}),e=class extends m{constructor(){super();this.icon="caret";this.label="";this.text="";this.name="";this.options=[];this.inputId=`wk-select-${f()}`}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof HTMLOptionElement&&this.options.push(t);this.innerHTML=""}render(){let t=g({"wk-select":!0,"wk-single-option":this.options.length===1});return u` | ||
var p=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var i=(a,o,t,n)=>{for(var s=n>1?void 0:n?d(o,t):o,l=a.length-1,c;l>=0;l--)(c=a[l])&&(s=(n?c(o,t,s):c(s))||s);return n&&s&&p(o,t,s),s};import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as h,property as r}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as k}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{Icon as w}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.0/components/icon.js";var e=class extends m{constructor(){super();this.icon="caret";this.label="";this.text="";this.name="";this.options=[]}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof HTMLOptionElement&&this.options.push(t);this.innerHTML=""}render(){let t=g({"wk-select":!0,"wk-single-option":this.options.length===1}),n=`wk-input__${this.name}`;return k` | ||
<div class=${t}> | ||
<label class="wk-label" for=${this.inputId}>${this.label}</label> | ||
<label class="wk-label" for=${n}>${this.label}</label> | ||
<div class="wk-control"> | ||
<select id=${this.inputId} class="wk-input" name=${this.name}> | ||
<select id=${n} class="wk-input" name=${this.name}> | ||
${this.options} | ||
@@ -14,3 +14,3 @@ </select> | ||
</div> | ||
`}createRenderRoot(){return this}};n([r({type:String})],e.prototype,"icon",2),n([r({type:String})],e.prototype,"label",2),n([r({type:String})],e.prototype,"text",2),n([r({type:String})],e.prototype,"name",2),e=n([h("wk-select")],e);w.addIcons({caret:` | ||
`}createRenderRoot(){return this}};i([r({type:String})],e.prototype,"icon",2),i([r({type:String})],e.prototype,"label",2),i([r({type:String})],e.prototype,"text",2),i([r({type:String})],e.prototype,"name",2),e=i([h("wk-select")],e);w.addIcons({caret:` | ||
<svg aria-hidden="true" focusable="false" role="presentation" viewBox="0 0 24 24"> | ||
@@ -17,0 +17,0 @@ <path d="M6 9l6 6 6-6" /> |
@@ -1,6 +0,6 @@ | ||
var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var t=(a,r,i,o)=>{for(var l=o>1?void 0:o?u(r,i):r,n=a.length-1,d;n>=0;n--)(d=a[n])&&(l=(o?d(r,i,l):d(l))||l);return o&&l&&m(r,i,l),l};import{LitElement as c}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as g,property as s}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as p}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/lit-html/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{styleMap as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/style-map/+esm";import y from"https://cdn.jsdelivr.net/npm/short-unique-id@4.4.4/+esm";var f=new y({length:10}),e=class extends c{constructor(){super();this.label="";this.name="";this.value="";this.selected=!1;this.disabled=!1;this.unavailable=!1;this.inputId=`wk-swatches-${f()}`}render(){let i=b({"wk-swatch":!0,"wk-disabled":this.disabled||this.unavailable,"wk-selected":this.selected,"wk-has-color":!!this.color,"wk-has-image":!!this.image});return p` | ||
<div class=${i}> | ||
var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var t=(r,o,a,s)=>{for(var i=s>1?void 0:s?c(o,a):o,n=r.length-1,d;n>=0;n--)(d=r[n])&&(i=(s?d(o,a,i):d(i))||i);return s&&i&&p(o,a,i),i};import{LitElement as g}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as u,property as l}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as m}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{styleMap as y}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/style-map/+esm";var e=class extends g{constructor(){super();this.label="";this.name="";this.value="";this.selected=!1;this.disabled=!1;this.unavailable=!1}render(){let a=`wk-radio__${this.name}`,s=b({"wk-swatch":!0,"wk-disabled":this.disabled||this.unavailable,"wk-selected":this.selected,"wk-has-color":!!this.color,"wk-has-image":!!this.image});return m` | ||
<div class=${s}> | ||
${this.renderLabel()} | ||
<input | ||
id=${this.inputId} | ||
id=${a} | ||
class="wk-radio" | ||
@@ -14,6 +14,6 @@ type="radio" | ||
</div> | ||
`}renderLabel(){let i={backgroundColor:this.color?this.color:void 0,backgroundImage:this.image?`url(${this.image})`:void 0};return p` | ||
<label class="wk-label" style=${h(i)} for=${this.inputId} | ||
`}renderLabel(){let a=`wk-radio__${this.name}`,s={backgroundColor:this.color?this.color:void 0,backgroundImage:this.image?`url(${this.image})`:void 0};return m` | ||
<label class="wk-label" style=${y(s)} for=${a} | ||
>${this.label}</label | ||
> | ||
`}createRenderRoot(){return this}};t([s({type:String})],e.prototype,"label",2),t([s({type:String})],e.prototype,"name",2),t([s({type:String})],e.prototype,"value",2),t([s({type:Boolean})],e.prototype,"selected",2),t([s({type:Boolean})],e.prototype,"disabled",2),t([s({type:Boolean})],e.prototype,"unavailable",2),t([s({type:String})],e.prototype,"image",2),t([s({type:String})],e.prototype,"color",2),e=t([g("wk-swatch")],e);export{e as Swatch}; | ||
`}createRenderRoot(){return this}};t([l({type:String})],e.prototype,"label",2),t([l({type:String})],e.prototype,"name",2),t([l({type:String})],e.prototype,"value",2),t([l({type:Boolean})],e.prototype,"selected",2),t([l({type:Boolean})],e.prototype,"disabled",2),t([l({type:Boolean})],e.prototype,"unavailable",2),t([l({type:String})],e.prototype,"image",2),t([l({type:String})],e.prototype,"color",2),e=t([u("wk-swatch")],e);export{e as Swatch}; |
@@ -1,5 +0,5 @@ | ||
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/lit-html/+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 u}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import g from"https://cdn.jsdelivr.net/npm/short-unique-id@4.4.4/+esm";import{Swatch as w}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/components/swatch.js";var k=new g({length:10}),i=class extends d{constructor(){super();this.label="";this.name="";this.options=[];this.inputId=`wk-swatch-${k()}`}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof w&&this.options.push(t);this.innerHTML=""}render(){let t=u({"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.16.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}> | ||
<fieldset class="wk-fieldset"> | ||
<label class="wk-label" for=${this.inputId}>${this.label}</label> | ||
<label class="wk-label">${this.label}</label> | ||
<div class="wk-options"> | ||
@@ -6,0 +6,0 @@ ${this.options.map(s=>Object.assign(s,{name:this.name}))} |
@@ -1,1 +0,1 @@ | ||
function _(t){return t.split("-")[0]}function N(t){return t.split("-")[1]}function D(t){return["top","bottom"].includes(_(t))?"x":"y"}function J(t){return t==="y"?"height":"width"}function st(t,e,n){let{reference:i,floating:s}=t,r=i.x+i.width/2-s.width/2,a=i.y+i.height/2-s.height/2,o=D(e),l=J(o),f=i[l]/2-s[l]/2,h=o==="x",c;switch(_(e)){case"top":c={x:r,y:i.y-s.height};break;case"bottom":c={x:r,y:i.y+i.height};break;case"right":c={x:i.x+i.width,y:a};break;case"left":c={x:i.x-s.width,y:a};break;default:c={x:i.x,y:i.y}}switch(N(e)){case"start":c[o]-=f*(n&&h?-1:1);break;case"end":c[o]+=f*(n&&h?-1:1)}return c}var lt=async(t,e,n)=>{let{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:a}=n,o=await(a.isRTL==null?void 0:a.isRTL(e)),l=await a.getElementRects({reference:t,floating:e,strategy:s}),{x:f,y:h}=st(l,i,o),c=i,p={},u=0;for(let d=0;d<r.length;d++){let{name:m,fn:g}=r[d],{x:y,y:x,data:b,reset:w}=await g({x:f,y:h,initialPlacement:i,placement:c,strategy:s,middlewareData:p,rects:l,platform:a,elements:{reference:t,floating:e}});f=y!=null?y:f,h=x!=null?x:h,p={...p,[m]:{...p[m],...b}},w&&u<=50&&(u++,typeof w=="object"&&(w.placement&&(c=w.placement),w.rects&&(l=w.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:s}):w.rects),{x:f,y:h}=st(l,c,o)),d=-1)}return{x:f,y:h,placement:c,strategy:s,middlewareData:p}};function ct(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 n;e===void 0&&(e={});let{x:i,y:s,platform:r,rects:a,elements:o,strategy:l}=t,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:c="floating",altBoundary:p=!1,padding:u=0}=e,d=ct(u),m=o[p?c==="floating"?"reference":"floating":c],g=V(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(m)))==null||n?m:m.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(o.floating)),boundary:f,rootBoundary:h,strategy:l})),y=V(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:c==="floating"?{...a.floating,x:i,y:s}:a.reference,offsetParent:await(r.getOffsetParent==null?void 0:r.getOffsetParent(o.floating)),strategy:l}):a[c]);return{top:g.top-y.top+d.top,bottom:y.bottom-g.bottom+d.bottom,left:g.left-y.left+d.left,right:y.right-g.right+d.right}}var Rt=Math.min,St=Math.max;function Y(t,e,n){return St(t,Rt(e,n))}var G=t=>({name:"arrow",options:t,async fn(e){let{element:n,padding:i=0}=t!=null?t:{},{x:s,y:r,placement:a,rects:o,platform:l}=e;if(n==null)return{};let f=ct(i),h={x:s,y:r},c=D(a),p=N(a),u=J(c),d=await l.getDimensions(n),m=c==="y"?"top":"left",g=c==="y"?"bottom":"right",y=o.reference[u]+o.reference[c]-h[c]-o.floating[u],x=h[c]-o.reference[c],b=await(l.getOffsetParent==null?void 0:l.getOffsetParent(n)),w=b?c==="y"?b.clientHeight||0:b.clientWidth||0:0;w===0&&(w=o.floating[u]);let k=y/2-x/2,W=f[m],F=w-d[u]-f[g],v=w/2-d[u]/2+k,I=Y(W,v,F),L=(p==="start"?f[m]:f[g])>0&&v!==I&&o.reference[u]<=o.floating[u];return{[c]:h[c]-(L?v<W?W-v:F-v:0),data:{[c]:I,centerOffset:v-I}}}}),Pt={left:"right",right:"left",bottom:"top",top:"bottom"};function q(t){return t.replace(/left|right|bottom|top/g,e=>Pt[e])}function Et(t,e,n){n===void 0&&(n=!1);let i=N(t),s=D(t),r=J(s),a=s==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=q(a)),{main:a,cross:q(a)}}var At={start:"end",end:"start"};function at(t){return t.replace(/start|end/g,e=>At[e])}var Ot=["top","right","bottom","left"],zt=Ot.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 n;let{placement:i,middlewareData:s,rects:r,initialPlacement:a,platform:o,elements:l}=e,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:c,fallbackStrategy:p="bestFit",flipAlignment:u=!0,...d}=t,m=_(i),g=c||(m===a||!u?[q(a)]:function(v){let I=q(v);return[at(v),I,at(I)]}(a)),y=[a,...g],x=await Q(e,d),b=[],w=((n=s.flip)==null?void 0:n.overflows)||[];if(f&&b.push(x[m]),h){let{main:v,cross:I}=Et(i,r,await(o.isRTL==null?void 0:o.isRTL(l.floating)));b.push(x[v],x[I])}if(w=[...w,{placement:i,overflows:b}],!b.every(v=>v<=0)){var k,W;let v=((k=(W=s.flip)==null?void 0:W.index)!=null?k:0)+1,I=y[v];if(I)return{data:{index:v,overflows:w},reset:{placement:I}};let L="bottom";switch(p){case"bestFit":{var F;let rt=(F=w.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;rt&&(L=rt);break}case"initialPlacement":L=a}if(i!==L)return{reset:{placement:L}}}return{}}}};var U=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:n,y:i}=e,s=await async function(r,a){let{placement:o,platform:l,elements:f}=r,h=await(l.isRTL==null?void 0:l.isRTL(f.floating)),c=_(o),p=N(o),u=D(o)==="x",d=["left","top"].includes(c)?-1:1,m=h&&u?-1:1,g=typeof a=="function"?a(r):a,{mainAxis:y,crossAxis:x,alignmentAxis:b}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...g};return p&&typeof b=="number"&&(x=p==="end"?-1*b:b),u?{x:x*m,y:y*d}:{x:y*d,y:x*m}}(e,t);return{x:n+s.x,y:i+s.y,data:s}}}};function Wt(t){return t==="x"?"y":"x"}var tt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:i,placement:s}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:o={fn:g=>{let{x:y,y:x}=g;return{x:y,y:x}}},...l}=t,f={x:n,y:i},h=await Q(e,l),c=D(_(s)),p=Wt(c),u=f[c],d=f[p];if(r){let g=c==="y"?"bottom":"right";u=Y(u+h[c==="y"?"top":"left"],u,u-h[g])}if(a){let g=p==="y"?"bottom":"right";d=Y(d+h[p==="y"?"top":"left"],d,d-h[g])}let m=o.fn({...e,[c]:u,[p]:d});return{...m,data:{x:m.x-n,y:m.y-i}}}}};function mt(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function E(t){if(t==null)return window;if(!mt(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function C(t){return E(t).getComputedStyle(t)}function S(t){return mt(t)?"":t?(t.nodeName||"").toLowerCase():""}function gt(){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 O(t){return t instanceof E(t).Element}function T(t){return typeof ShadowRoot=="undefined"?!1:t instanceof E(t).ShadowRoot||t instanceof ShadowRoot}function $(t){let{overflow:e,overflowX:n,overflowY:i}=C(t);return/auto|scroll|overlay|hidden/.test(e+i+n)}function Lt(t){return["table","td","th"].includes(S(t))}function ft(t){let e=/firefox/i.test(gt()),n=C(t);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||e&&n.willChange==="filter"||e&&!!n.filter&&n.filter!=="none"}function wt(){return!/^((?!chrome|android).)*safari/i.test(gt())}var ht=Math.min,z=Math.max,j=Math.round;function P(t,e,n){var i,s,r,a;e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),l=1,f=1;e&&R(t)&&(l=t.offsetWidth>0&&j(o.width)/t.offsetWidth||1,f=t.offsetHeight>0&&j(o.height)/t.offsetHeight||1);let h=O(t)?E(t):window,c=!wt()&&n,p=(o.left+(c&&(i=(s=h.visualViewport)==null?void 0:s.offsetLeft)!=null?i:0))/l,u=(o.top+(c&&(r=(a=h.visualViewport)==null?void 0:a.offsetTop)!=null?r:0))/f,d=o.width/l,m=o.height/f;return{width:d,height:m,top:u,right:p+d,bottom:u+m,left:p,x:p,y:u}}function A(t){return(e=t,(e instanceof E(e).Node?t.ownerDocument:t.document)||window.document).documentElement;var e}function K(t){return O(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function yt(t){return P(A(t)).left+K(t).scrollLeft}function Tt(t,e,n){let i=R(e),s=A(e),r=P(t,i&&function(l){let f=P(l);return j(f.width)!==l.offsetWidth||j(f.height)!==l.offsetHeight}(e),n==="fixed"),a={scrollLeft:0,scrollTop:0},o={x:0,y:0};if(i||!i&&n!=="fixed")if((S(e)!=="body"||$(s))&&(a=K(e)),R(e)){let l=P(e,!0);o.x=l.x+e.clientLeft,o.y=l.y+e.clientTop}else s&&(o.x=yt(s));return{x:r.left+a.scrollLeft-o.x,y:r.top+a.scrollTop-o.y,width:r.width,height:r.height}}function vt(t){return S(t)==="html"?t:t.assignedSlot||t.parentNode||(T(t)?t.host:null)||A(t)}function dt(t){return R(t)&&C(t).position!=="fixed"?function(e){let{offsetParent:n}=e,i=e,s=!1;for(;i&&i!==n;){let{assignedSlot:r}=i;if(r){let a=r.offsetParent;if(C(r).display==="contents"){let o=r.hasAttribute("style"),l=r.style.display;r.style.display=C(i).display,a=r.offsetParent,r.style.display=l,o||r.removeAttribute("style")}i=r,n!==a&&(n=a,s=!0)}else if(T(i)&&i.host&&s)break;i=T(i)&&i.host||i.parentNode}return n}(t):null}function et(t){let e=E(t),n=dt(t);for(;n&&Lt(n)&&C(n).position==="static";)n=dt(n);return n&&(S(n)==="html"||S(n)==="body"&&C(n).position==="static"&&!ft(n))?e:n||function(i){let s=vt(i);for(T(s)&&(s=s.host);R(s)&&!["html","body"].includes(S(s));){if(ft(s))return s;{let r=s.parentNode;s=T(r)?r.host:r}}return null}(t)||e}function ut(t){if(R(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=P(t);return{width:e.width,height:e.height}}function xt(t){let e=vt(t);return["html","body","#document"].includes(S(e))?t.ownerDocument.body:R(e)&&$(e)?e:xt(e)}function B(t,e){var n;e===void 0&&(e=[]);let i=xt(t),s=i===((n=t.ownerDocument)==null?void 0:n.body),r=E(i),a=s?[r].concat(r.visualViewport||[],$(i)?i:[]):i,o=e.concat(a);return s?o:o.concat(B(a))}function pt(t,e,n){return e==="viewport"?V(function(i,s){let r=E(i),a=A(i),o=r.visualViewport,l=a.clientWidth,f=a.clientHeight,h=0,c=0;if(o){l=o.width,f=o.height;let p=wt();(p||!p&&s==="fixed")&&(h=o.offsetLeft,c=o.offsetTop)}return{width:l,height:f,x:h,y:c}}(t,n)):O(e)?function(i,s){let r=P(i,!1,s==="fixed"),a=r.top+i.clientTop,o=r.left+i.clientLeft;return{top:a,left:o,x:o,y:a,right:o+i.clientWidth,bottom:a+i.clientHeight,width:i.clientWidth,height:i.clientHeight}}(e,n):V(function(i){var s;let r=A(i),a=K(i),o=(s=i.ownerDocument)==null?void 0:s.body,l=z(r.scrollWidth,r.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),f=z(r.scrollHeight,r.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),h=-a.scrollLeft+yt(i),c=-a.scrollTop;return C(o||r).direction==="rtl"&&(h+=z(r.clientWidth,o?o.clientWidth:0)-l),{width:l,height:f,x:h,y:c}}(A(t)))}function Ft(t){let e=B(t),n=["absolute","fixed"].includes(C(t).position)&&R(t)?et(t):t;return O(n)?e.filter(i=>O(i)&&function(s,r){let a=r.getRootNode==null?void 0:r.getRootNode();if(s.contains(r))return!0;if(a&&T(a)){let o=r;do{if(o&&s===o)return!0;o=o.parentNode||o.host}while(o)}return!1}(i,n)&&S(i)!=="body"):[]}var Ht={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:i,strategy:s}=t,r=[...n==="clippingAncestors"?Ft(e):[].concat(n),i],a=r[0],o=r.reduce((l,f)=>{let h=pt(e,f,s);return l.top=z(h.top,l.top),l.right=ht(h.right,l.right),l.bottom=ht(h.bottom,l.bottom),l.left=z(h.left,l.left),l},pt(e,a,s));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:i}=t,s=R(n),r=A(n);if(n===r)return e;let a={scrollLeft:0,scrollTop:0},o={x:0,y:0};if((s||!s&&i!=="fixed")&&((S(n)!=="body"||$(r))&&(a=K(n)),R(n))){let l=P(n,!0);o.x=l.x+n.clientLeft,o.y=l.y+n.clientTop}return{...e,x:e.x-a.scrollLeft+o.x,y:e.y-a.scrollTop+o.y}},isElement:O,getDimensions:ut,getOffsetParent:et,getDocumentElement:A,getElementRects:t=>{let{reference:e,floating:n,strategy:i}=t;return{reference:Tt(e,et(n),i),floating:{...ut(n),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>C(t).direction==="rtl"};function bt(t,e,n,i){i===void 0&&(i={});let{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:a=!0,animationFrame:o=!1}=i,l=s&&!o,f=r&&!o,h=l||f?[...O(t)?B(t):[],...B(e)]:[];h.forEach(d=>{l&&d.addEventListener("scroll",n,{passive:!0}),f&&d.addEventListener("resize",n)});let c,p=null;if(a){let d=!0;p=new ResizeObserver(()=>{d||n(),d=!1}),O(t)&&!o&&p.observe(t),p.observe(e)}let u=o?P(t):null;return o&&function d(){let m=P(t);!u||m.x===u.x&&m.y===u.y&&m.width===u.width&&m.height===u.height||n(),u=m,c=requestAnimationFrame(d)}(),n(),()=>{var d;h.forEach(m=>{l&&m.removeEventListener("scroll",n),f&&m.removeEventListener("resize",n)}),(d=p)==null||d.disconnect(),p=null,o&&cancelAnimationFrame(c)}}var It=(t,e,n)=>lt(t,e,{platform:Ht,...n});var it=class{constructor(e){this._middleware=[];(this.host=e).addController(this)}hostDisconnected(){this.destroy()}hostUpdated(){this.updatePosition()}hostResized(){this.updatePosition()}float(e){var o;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:n,arrow:i=!1,flip:s=!1,shift:r=!1}=this._settings,a=this.getOffsetSetting();Object.assign(this.host.style,{position:(o=n.strategy)!=null?o:"absolute",top:"0",left:"0",transition:"none",transform:"translate3d(0,0,0)"}),n.inset&&!i?this._middleware.push(U(({rects:l,placement:f})=>{var h,c,p,u,d,m;return f.includes("top")||f.includes("bottom")?{mainAxis:-l.floating.height-((h=a==null?void 0:a.mainAxis)!=null?h:0),crossAxis:(c=a==null?void 0:a.crossAxis)!=null?c:0,alignmentAxis:(p=a==null?void 0:a.alignmentAxis)!=null?p:0}:{mainAxis:-l.floating.width-((u=a==null?void 0:a.mainAxis)!=null?u:0),crossAxis:(d=a==null?void 0:a.crossAxis)!=null?d:0,alignmentAxis:(m=a==null?void 0:a.alignmentAxis)!=null?m:0}})):a&&this._middleware.push(U(a)),s&&this._middleware.push(Z()),r&&this._middleware.push(tt()),i&&(this.arrowEl=document.createElement("div"),this.arrowEl.classList.add("wk-arrow"),this._middleware.push(G({element:this.arrowEl}))),this.cleanupAutoUpdate=bt(this._reference,this.host,()=>{this.updatePosition()}),this._resizeObserver.observe(this.host)}getOffsetSetting(){var n,i;let e=(n=this._settings)==null?void 0:n.offset;if(!(!e||typeof e=="boolean"))return typeof e=="number"?{mainAxis:e,alignmentAxis:(i=this._settings)!=null&&i.position.inset?e:null}:e}destroy(){var e,n,i,s;Object.assign(this.host.style,{position:"",top:"",left:""}),(n=(e=this.arrowEl)==null?void 0:e.parentElement)==null||n.removeChild(this.arrowEl),this.arrowEl=void 0,this._middleware=[],this.host.classList.remove("wk-floating"),(i=this.cleanupAutoUpdate)==null||i.call(this),(s=this._resizeObserver)==null||s.disconnect()}updatePosition(){var i;if(!this._reference||!this._settings)return;let{strategy:e="absolute",placement:n="top"}=(i=this._settings.position)!=null?i:{};It(this._reference,this.host,{middleware:this._middleware,strategy:e,placement:n}).then(({x:s,y:r,placement:a,middlewareData:o})=>{if(o.arrow&&this.arrowEl){let{x:l,y:f}=o.arrow,h={top:"bottom",right:"left",bottom:"top",left:"right"}[a.split("-")[0]],c={bottom:"0deg",left:"90deg",top:"180deg",right:"270deg"}[a.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(s)}px,${Math.round(r)}px,0)`})})}getReference(){if(!this._settings)return;let e=this._settings.reference;if(typeof e=="string"){if(e==="viewport")return this.createViewportReference();let n=document.querySelector(e);if(!n)throw new Error(`Floating reference element (${e}) not found`);return n}return e.hasOwnProperty("element")?e.element:e}createViewportReference(){return{getBoundingClientRect(){var e,n,i,s;return{x:0,y:0,top:0,left:0,bottom:0,right:0,width:(n=(e=window.visualViewport)==null?void 0:e.width)!=null?n:0,height:(s=(i=window.visualViewport)==null?void 0:i.height)!=null?s:0}}}}};var nt=class{constructor(e,{app:n}){this.product=null,this.app=n,this.state={selectedVariant:null,selectedOptions:{},hasSelection:!1,optionsWithValues:[]},(this.host=e).addController(this)}setProduct({product:e,selectedVariantId:n=null,autoSelect:i=!1}){!(e!=null&&e.variants)||(this.product=e,this.initFormState({selectedVariantId:n,autoSelect:i}))}initFormState({selectedVariantId:e,autoSelect:n}){if(!this.product)throw new Error("Product not set");let i=this.initializedVariantId!==e?this.product.variants.find(r=>r.id===e):this.state.selectedVariant;this.initializedVariantId=e;let s=this.app.utils.product.getVariantOptions({variant:i});this.updateFormState({options:s,autoSelect:n})}updateFormState({options:e,change:n,autoSelect:i=!1}){if(!this.product)throw new Error("Product not set");let{hasSelection:s,optionsWithValues:r,selectedOptions:a,selectedVariant:o}=this.app.utils.product.getFormState({product:this.product,options:e,change:n,autoSelect:i});this.state.hasSelection=s,this.state.optionsWithValues=r,this.state.selectedOptions=a,this.state.selectedVariant=o,this.host.requestUpdate()}changeOption({input:e,autoSelect:n=!1}){if(!this.product)throw new Error("Product not set");let i=this.getInputOption(e);if(!i)throw new Error("Cannot parse options from input");this.updateFormState({options:this.state.selectedOptions,change:i,autoSelect:n})}async addToCart({wishlistId:e,wishlistItemId:n}){if(!this.state.selectedVariant)throw new Error("No variant selected");let i=this.host.querySelector("form");if(!i)throw new Error("Form not found");i.classList.add("wk-submitting"),await this.app.addToCart({wishlistId:e,wishlistItemId:n,variantId:this.state.selectedVariant.id,quantity:this.app.utils.product.getFormQuantity({form:i})}),i.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.6/+esm";var ot=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 n;return{loading:(n=e.loading)!=null?n:"eager",wishlist:this.parseWishlistStateConfig(e),wishlistItem:this.parseWishlistItemStateConfig(e),productInfo:this.parseProductInfoStateConfig(e)}}parseWishlistStateConfig({wishlist:e}){var i;let n=(i=this.host.dataset.wishlistId)!=null?i:"mine";if(!!e)return{format:typeof e=="string"?e:"minimal",params:{wishlistId:n}}}parseWishlistItemStateConfig({wishlistItem:e}){let{wishlistId:n="mine",wishlistItemId:i}=this.host.dataset;if(!(!e||!i))return{params:{wishlistId:n,wishlistItemId:i}}}parseProductInfoStateConfig({productInfo:e}){let{wishlistId:n="mine",productHandle:i,productId:s,variantId:r}=this.host.dataset;if(!!e)return{params:{wishlistId:n,productHandle:i,productId:s?parseInt(s):void 0,variantId:r?parseInt(r):void 0}}}observe(e){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let n=[];if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;n.push(this.app.state.observeWishlist({format:this.stateConfig.wishlist.format,wishlistId:i}).pipe(X(s=>({wishlist:s}))))}if(this.stateConfig.productInfo){let{productId:i,productHandle:s,variantId:r}=this.stateConfig.productInfo.params;if(!i&&!s)throw new Error("Product id or handle is required");n.push(this.app.state.observeProductInfo({productHandle:s,productId:i,variantId:r,strategy:e}).pipe(X(a=>({productInfo:a}))))}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:s}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!s)throw new Error("Wishlist item id is required");n.push(this.app.state.observeWishlistItem({wishlistId:i,wishlistItemId:s}).pipe(X(r=>({wishlistItem:r}))))}return n.length||n.push(Dt({})),Vt(n).pipe(X(i=>i.reduce((s,r)=>r.wishlist?{...s,wishlist:r.wishlist}:r.wishlistItem?{...s,wishlistItem:r.wishlistItem}:r.productInfo?{...s,productInfo:r.productInfo}:s,{})),_t((i,s)=>JSON.stringify(i)===JSON.stringify(s)))}getFallback(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e={};if(this.stateConfig.wishlist){let{wishlistId:n="mine"}=this.stateConfig.wishlist.params;e.wishlist={id:n,isMine:n==="mine",numItems:0,items:void 0}}if(this.stateConfig.productInfo){let{productId:n=0,variantId:i=0}=this.stateConfig.productInfo.params;e.productInfo={productId:n,variantId:i,inWishlist:!1}}if(this.stateConfig.wishlistItem){let{wishlistId:n,wishlistItemId:i}=this.stateConfig.wishlistItem.params;if(!n)throw new Error("Wishlist id is required");if(!i)throw new Error("Wishlist item id is required");e.wishlistItem={id:i,product:{id:0,handle:"",hidden:!1}}}return e}};export{it as FloatingUiController,nt as ProductFormController,ot as WishlistStateController}; | ||
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}; |
@@ -1,12 +0,12 @@ | ||
var V=class{constructor(t){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,n;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:(n=t.product)!=null&&n.url?this.mapShopifyProduct(t):t.product}};this.utils=t.utils}mapShopifyProduct(t){var o;let i=t.product,r=this.utils.product.getFirstAvailableVariant({product:i}),s=this.utils.product.getSelectedVariant({product:i,selectedVariantId:t.selectedVariantId}),n=(o=s!=null?s:r)!=null?o:i.variants[0];return{...i,selected_variant:s,first_available_variant:r,selected_or_first_available_variant:n,has_only_default_variant:i.variants.length===1}}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(d){try{u(r.next(d))}catch(y){o(y)}}function a(d){try{u(r.throw(d))}catch(y){o(y)}}function u(d){d.done?n(d.value):s(d.value).then(l,a)}u((r=r.apply(e,t||[])).next())})}var x=class{liquidMethodMissing(t){}},At=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 Mt(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:I(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 I(e){return e==null}function T(e){return At.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 v(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)},p=[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;p[160]=p[5760]=p[6158]=p[8192]=p[8193]=p[8194]=p[8195]=p[8196]=p[8197]=p[8198]=p[8199]=p[8200]=p[8201]=p[8202]=p[8232]=p[8233]=p[8239]=p[8287]=p[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&&p[i.charCodeAt(n)]&He&&(s[o].needBoundary=!0),s=s[o]}s.handler=r,s.end=!0}return t}var Xt={"&":"&","<":"<",">":">",'"':""","'":"'"},Kt={"&":"&","<":"<",">":">",""":'"',"'":"'"};function vt(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 vt(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=v(Math.abs),ni=v(Math.max),oi=v(Math.min),ai=v(Math.ceil),li=v((e,t,i=!1)=>i?Math.floor(e/t):e/t),ui=v(Math.floor),ci=v((e,t)=>e-t),hi=v((e,t)=>e%t),di=v((e,t)=>e*t);function pi(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 I(e)?[]:T(e)?e:[e]}var wi=v((e,t)=>R(e).join(t===void 0?" ":t)),yi=v(e=>T(e)?We(e):""),Ti=v(e=>T(e)?e[0]:""),bi=v(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 vi(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*ki(e,t){let i=[];for(let r of R(h(e)))i.push(yield this.context._getFromScope(r,c(t).split(".")));return i}function Si(e){return e=h(e),R(e).filter(t=>!I(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),I(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"],kt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Pi=qt.map(St),Ii=kt.map(St),nt={1:"st",2:"nd",3:"rd",default:"th"};function St(e){return e.slice(0,3)}function Ei(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+=Ei(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 Ai(e){let t=e.getDate().toString(),i=parseInt(t.slice(-1));return nt[i]||nt.default}function Mi(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=>Ii[e.getDay()],A:e=>kt[e.getDay()],b:e=>Pi[e.getMonth()],B:e=>qt[e.getMonth()],c:e=>e.toLocaleString(),C:e=>Mi(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=>Ai(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})),d=$i[o]||"0",y=s||Ci[o]||0;return a["^"]?u=u.toUpperCase():a["#"]&&(u=zt(u)),a._?d=" ":a[0]&&(d="0"),a["-"]&&(y=0),ee(u,y,d)}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,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={"&":"&","<":"<",">":">",'"':""","'":"'"},Kt={"&":"&","<":"<",">":">",""":'"',"'":"'"};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+` | ||
`+this.context+` | ||
`+this.stack+` | ||
From `+t.stack}},H=class extends z{constructor(t,i){super(new Error(t),i),this.name="TokenizationError",super.update()}},he=class extends z{constructor(t,i){super(t,i),this.name="ParseError",this.message=t.message,super.update()}},ie=class extends z{constructor(t,i){super(t,i.token),this.name="RenderError",this.message=t.message,super.update()}static is(t){return t.name==="RenderError"}},de=class extends z{constructor(t,i){super(t,i),this.name="UndefinedVariableError",this.message=t.message,super.update()}},pe=class extends Error{constructor(t){super(`undefined variable: ${t}`),this.name="InternalUndefinedVariableError",this.variableName=t}},fe=class extends Error{constructor(t){super(t),this.name="AssertionError",this.message=t+""}};function Ji(e){let[t]=e.getPosition(),i=e.input.split(` | ||
From `+t.stack}},H=class extends z{constructor(t,i){super(new Error(t),i),this.name="TokenizationError",super.update()}},he=class extends z{constructor(t,i){super(t,i),this.name="ParseError",this.message=t.message,super.update()}},ie=class extends z{constructor(t,i){super(t,i.token),this.name="RenderError",this.message=t.message,super.update()}static is(t){return t.name==="RenderError"}},pe=class extends z{constructor(t,i){super(t,i),this.name="UndefinedVariableError",this.message=t.message,super.update()}},de=class extends Error{constructor(t){super(`undefined variable: ${t}`),this.name="InternalUndefinedVariableError",this.variableName=t}},fe=class extends Error{constructor(t){super(t),this.name="AssertionError",this.message=t+""}};function Ji(e){let[t]=e.getPosition(),i=e.input.split(` | ||
`),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 dr(e,t=15,i="..."){let r=c(e).split(/\s+/),s=r.slice(0,t).join(" ");return r.length>=t&&(s+=i),s}var Ft=Object.freeze({__proto__:null,escape:vt,escapeOnce:ti,newlineToBr:ii,stripHtml:ri,abs:si,atLeast:ni,atMost:oi,ceil:ai,dividedBy:li,floor:ui,minus:ci,modulo:hi,times:di,round:pi,plus:fi,urlDecode:gi,urlEncode:mi,join:wi,last:yi,first:Ti,reverse:bi,sort:_i,sortNatural:vi,size:qi,map:ki,compact:Si,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:dr}),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 pr(e){return!!(S(e)&f.Delimited)}function Ot(e){return S(e)===f.Operator}function Ye(e){return S(e)===f.HTML}function fr(e){return S(e)===f.Output}function Je(e){return S(e)===f.Tag}function Rt(e){return S(e)===f.Quoted}function gr(e){return S(e)===f.Literal}function mr(e){return S(e)===f.Number}function wr(e){return S(e)===f.PropertyAccess}function yr(e){return S(e)===f.Word}function Tr(e){return S(e)===f.Range}function S(e){return e?e.kind:-1}var ge=class extends x{equals(t){return I(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||I(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 Pt(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&<.test(e[r]);)s=s*8+ct(e[r++]);i=r-1,t+=String.fromCharCode(s)}}return t}function A(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=A(t)),Mt(t)&&(t=yield t)}catch(n){r="throw",t=n}}while(!i);return t})}function M(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=M(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 Sr(e,t);if(gr(e))return kr(e);if(mr(e))return vr(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 de(s,e)}}function vr(e){let t=e.whole.content+"."+(e.decimal?e.decimal.content:"");return Number(t)}function Ge(e){return Pt(e.getText())}function qr(e,t,i,r,s){let n=e[t.operator];return n(i,r,s)}function kr(e){return xt[e.literal]}function*Sr(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]==="-",d=We(i)==="-";this.content=i.slice(u?1:0,d?-1:i.length).trim(),this.trimLeft=u||o,this.trimRight=d||l}};function Fr(e,t){let i=!1;for(let r=0;r<e.length;r++){let s=e[r];!pr(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(;p[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(;p[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&&p[this.input.charCodeAt(this.begin)]&Zt?this.begin+1:this.begin;for(let r=i;r<this.end;r++)if(!(p[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():Pt(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}},ve=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)}},ke=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}},Se=class extends Q{constructor(t,i,r,s,n){let{trimOutputLeft:o,trimOutputRight:l,outputDelimiterLeft:a,outputDelimiterRight:u}=s,d=t.slice(i+a.length,r-u.length);super(f.Output,d,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&&p[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=E.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=E){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=E){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=E){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 Se(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=E){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 ve(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 ke(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 p[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,d=t.slice(i+a.length,r-u.length);super(f.Tag,d,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}},P=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 Pr(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)Pr(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])}},k=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}},Ir={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 k(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)}},dt=["offset","limit","reversed"],Er={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 P(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=>dt.includes(a)):dt.filter(a=>n[a]!==void 0)).reduce((a,u)=>u==="offset"?Ar(a,n.offset):u==="limit"?Mr(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 Ar(e,t){return e.slice(t)}function Mr(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 k(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 P(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 d of u){o[a]=d;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 pt(n)}return s}let i=[...e.readFileNameTemplate(t.options)],r=pt(t.parser.parseTokens(i));return r==="none"?null:r}function pt(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 P(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 k(e.args,this.liquid),templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new k(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 P(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[""]=(d,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 P(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 d=0;d<i.length;d++,a.next())u[this.variable]=i[d],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 k(e.args,this.liquid),test:je,templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new k(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 k(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:Ir,for:Er,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 It=new Map;le(Ft,(e,t)=>{It.set(ue(t),e)});var E={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({},E),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=It.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=E,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 M(this._get(t))}*_get(t){let i=this.findScope(t[0]);return yield this._getFromScope(i,t)}getFromScope(t,i){return M(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),I(t)&&this.strictVariables)throw new pe(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(I(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}},Pe=class{constructor(){this.buffer=""}write(t){this.buffer+=c(t)}},Ie=class{constructor(){throw this.buffer="",this.stream=null,new Error("streaming not supported in browser")}},Ee=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 Ie;return Promise.resolve().then(()=>A(this.renderTemplates(t,i,r))).then(()=>r.end(),s=>r.error(s)),r.stream}*renderTemplates(t,i,r){r||(r=i.opts.keepOutputType?new Ee:new Pe);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}},Ae=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 P(this.token.args).render(t),s=this.impl;if(q(s.render))return yield s.render(t,i,r)}},Me=class extends G{constructor(t,i){super(t),this.value=new k(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 Ae(t,i,this.liquid):fr(t)?new Me(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:A(a);n.write(o,u);try{return yield u}catch(d){throw n.remove(o),d}}*_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 A(this._render(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}renderSync(t,i,r){return M(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 A(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}parseAndRenderSync(t,i,r){return M(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 A(this.parser.parseFile(t,!1))})}parseFileSync(t){return M(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 k(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 A(this._evalValue(t,i))})}evalValueSync(t,i){return M(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}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/lit-html/+esm";import{unsafeStatic as ds}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/static/+esm";var Ke=e=>function(){let t=a=>{var u;return e.utils.url.getVariantUrl(a.url,(u=a.selected_variant)==null?void 0:u.id)},i=(a,...u)=>e.utils.url.getImageUrl(a,Et(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)=>u.length?this.parseAndRenderSync(e.utils.locale.translate(a),Et(u)):e.utils.locale.translate(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)},Et=e=>e.reduce((t,[i,r])=>r?{...t,[i]:r}:t,{});import{WishlistElement as ps}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/wishlist-element.js";var et=class extends ps{static get properties(){return{}}init(){super.init(),this.dataUtil=new V({utils:this.app.utils}),this.globals={settings:{login_required:this.app.settings.loginRequired},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.initTemplate()}disconnectedCallback(){super.disconnectedCallback(),this.parsedTemplates=void 0}getLiquidTemplate(){return""}getLiquidData(){return{}}initTemplate(){if(this.parsedTemplates)return this.parsedTemplates;if(!this.liquidEngine)throw new Error("Liquid engine not initialized");return this.parsedTemplates=this.liquidEngine.parse(this.getLiquidTemplate()),this.parsedTemplates}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`${ds(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 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&<.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.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,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}; |
{ | ||
"name": "@appmate/wishlist", | ||
"version": "4.15.7", | ||
"version": "4.16.0", | ||
"description": "Wishlist King SDK", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,1 +0,1 @@ | ||
var F=class{constructor({routeUtil:e}){this.subscriber=[],this.routeUtil=e,this.observer=new MutationObserver(t=>{t.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(e,t){if(!e.pageType&&e.handle)throw new Error("Template required when watching for handle.");let r={target:e,callback:t};this.subscriber.push(r),N(r,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(e,{skipHidden:t}){return t&&e instanceof HTMLElement?e.offsetParent===null:!1}scan(e){this.subscriber.filter(t=>N(t,this.routeUtil.parse(window.location.pathname))).forEach(t=>{let r=e.matches(t.target.selector)&&!this.shouldSkip(e,{skipHidden:!!t.target.skipHidden});if(r&&this.notify(t,e),r&&t.target.firstMatch)return;let a=e.querySelectorAll(t.target.selector);for(let i of a)if(!this.shouldSkip(i,{skipHidden:!!t.target.skipHidden})&&(this.notify(t,i),t.target.firstMatch))break})}notify(e,t){if(!t.hasAttribute("data-appmate")){t.setAttribute("data-appmate","");let r=new b(t);e.callback(r)}}};function N({target:n},e){if(!n.pageType)return!0;if(!e.pageType)return!1;if(n.handle)return n.handle===e.handle;let t=Array.isArray(n.pageType)?n.pageType:[n.pageType];return t.includes("all")?!0:t.includes(e.pageType)}var b=class{constructor(e){this.element=e}replace(e){var t;return(t=this.element)==null||t.replaceWith(e),e}append(e){var t;return(t=this.element)==null||t.append(e),e}prepend(e){var t;return(t=this.element)==null||t.prepend(e),e}insertBefore(e){var t;return(t=this.element)==null||t.before(e),e}insertAfter(e){var t;return(t=this.element)==null||t.after(e),e}closest(e,t=5){if(!this.element)return new b;if(typeof e=="object")return this.searchByStyle(e,this.element,a=>a.parentElement,t);let r=this.element.closest(e);return r?new b(r):new b}find(e){var r;let t=(r=this.element)==null?void 0:r.querySelector(e);return t?new b(t):new b}searchByStyle(e,t,r,a=5){if(a<0||!t)return null;let i=getComputedStyle(t);if(Object.entries(e).every(([c,l])=>i.getPropertyValue(c)===l))return new b(t);let s=r(t);return s?this.searchByStyle(e,s,r,a-1):null}};var I=class{constructor({routeUtil:e}){this.observer=new F({routeUtil:e}),this.watch=this.observer.watch.bind(this.observer)}createComponent(e,t){let r=document.createElement(e);return t!=null&&t.dataset&&Object.entries(t==null?void 0:t.dataset).forEach(([a,i])=>{!i||(typeof i=="boolean"?r.dataset[a]="":typeof i=="object"?r.dataset[a]=JSON.stringify(i):r.dataset[a]=i)}),t!=null&&t.props&&Object.entries(t==null?void 0:t.props).forEach(([a,i])=>{r[a]=i}),r}createElement(e,t={},...r){let a=Object.assign(document.createElement(e),t);return r&&a.append(...r),a}};var W=class{constructor(e){this.locale=this.decodeLocale(e.locale)}decodeHtmlEntities(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(e){let t={};for(let r in e){t[r]={};for(let a in e[r])t[r][a]=this.decodeHtmlEntities(e[r][a])}return t}translate(e){var a,i;let[t,r]=e.split(".");return(i=(a=this.locale[t])==null?void 0:a[r])!=null?i:`translation missing: ${e}`}};var _=class{constructor(e){this.placeholderRegex=/\{\{\s*(\w+)\s*\}\}/;var t;this.moneyFormat=(t=e.moneyFormat)!=null?t:"${{amount}}",this.currencyRate=e.currencyRate,this.activeCurrency=e.activeCurrency}formatMoney(e){var t;return typeof e=="string"&&(e=parseInt(e.replace(".",""))),this.moneyFormat.replace(this.placeholderRegex,this.formatCents(e,(t=this.moneyFormat.match(this.placeholderRegex))==null?void 0:t[1]))}formatCents(e,t){switch(t){case"amount_no_decimals":return this.formatWithDelimiters(e,0);case"amount_with_comma_separator":return this.formatWithDelimiters(e,2,".",",");case"amount_no_decimals_with_comma_separator":return this.formatWithDelimiters(e,0,".",",");case"amount":default:return this.formatWithDelimiters(e,2)}}formatWithDelimiters(e,t=2,r=",",a="."){if(isNaN(e)||e==null)return"0";let o=(e/100).toFixed(t).split("."),s=o[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${r}`),c=o[1]?a+o[1]:"";return s+c}};var M=class{constructor(){}getFormState({product:e,options:t,autoSelect:r=!1,change:a}){let i=this.getSelectedOptions({product:e,options:t,change:a,autoSelect:r}),o=i&&Object.values(i).every(l=>!!l),s=this.getOptionsWithValues({product:e,selectedOptions:i});return{selectedVariant:this.getVariantByOptions({product:e,options:i}),selectedOptions:i,hasSelection:o,optionsWithValues:s}}getSelectedOptions({product:e,options:t,autoSelect:r,change:a={}}){let i=Object.fromEntries(Object.entries({...t,...a}).map(([p,f],d)=>{var g;return!f&&((g=e.options[d])==null?void 0:g.values.length)===1?[p,e.options[d].values[0]]:[p,f]}));if(!r)return i;r===!0&&(r="unavailable");let o=this.getVariantByOptions({product:e,options:i});if(r==="unavailable"&&o||r==="soldout"&&(o==null?void 0:o.available))return i;let s=Object.keys(a).pop(),c=Object.fromEntries(Object.entries(i).filter(([p])=>!s||p<=s)),l=Object.fromEntries(Object.entries(i).filter(([p])=>!(p in c)));return Object.entries(l).reduce((p,[f,d])=>{var P;let g=this.getAllVariantsByOptions({product:e,options:p});return g.length?{...p,[f]:((P=g.find(y=>y.available))!=null?P:g[0])[f]}:{...p,[f]:null}},c)}getVariantOptions({variant:e}){var t,r,a;return{option1:(t=e==null?void 0:e.option1)!=null?t:null,option2:(r=e==null?void 0:e.option2)!=null?r:null,option3:(a=e==null?void 0:e.option3)!=null?a:null}}getOptionsWithValues({product:e,selectedOptions:t={}}){return e.options.map(r=>{var c;let a=`option${r.position}`,i=this.getUnavailableOptionValues({product:e,optionKey:a,selectedOptions:t,values:r.values}),o=this.getSoldoutOptionValues({product:e,optionKey:a,selectedOptions:t,values:r.values}),s=(c=t==null?void 0:t[a])!=null?c:null;return{...r,selectedValue:s,soldoutValues:o,unavailableValues:i}})}getSoldoutOptionValues({product:e,optionKey:t,values:r,selectedOptions:a={}}){let i=Object.fromEntries(Object.entries(a).filter(([o])=>o<t));return r.filter(o=>{let s=e.variants.filter(c=>this.matchesVariant({variant:c,options:{...i,[t]:o}}));return s.length?s.every(c=>!c.available):!1})}getUnavailableOptionValues({product:e,optionKey:t,values:r,selectedOptions:a={}}){let i=Object.fromEntries(Object.entries(a).filter(([o])=>o<t));return r.filter(o=>e.variants.every(s=>!this.matchesVariant({variant:s,options:{...i,[t]:o}})))}getFirstAvailableVariant({product:e}){var t;return(t=e.variants.find(r=>r.available))!=null?t:null}getSelectedVariant({product:e,selectedVariantId:t}){var r;return(r=e.variants.find(a=>a.id===t))!=null?r:null}matchesVariant({variant:e,options:t}){return(!(t!=null&&t.option1)||t.option1===e.option1)&&(!(t!=null&&t.option2)||t.option2===e.option2)&&(!(t!=null&&t.option3)||t.option3===e.option3)}getFormData({form:e,product:t}){let r=new FormData(e);return{quantity:this.getFormQuantity({form:e}),options:this.getFormOptions({formData:r,product:t})}}getFormQuantity({form:e}){var a;let r=(a=new FormData(e).get("quantity"))==null?void 0:a.toString();return r?parseInt(r):1}getVariantByOptions({product:e,options:t}){var a;let r=Object.entries(t).reduce((i,[,o],s)=>(i[s]=o,i),new Array(3).fill(null));return(a=e.variants.find(i=>r.every((o,s)=>i[`option${s+1}`]===o)))!=null?a:null}getAllVariantsByOptions({product:e,options:t}){var a;let r=Object.entries(t).reduce((i,[,o],s)=>(i[s]=o,i),new Array(3).fill(null));return(a=e.variants.filter(i=>r.every((o,s)=>!o||i[`option${s+1}`]===o)))!=null?a:[]}getFormOptions({formData:e,product:t}){return Array.from(e.entries()).reduce((r,[a,i])=>{var c;let o=(c=a.match(/\[(.*?)\]/))==null?void 0:c[1];if(!o)return r;let s=t.options.findIndex(l=>l.name===o)+1;if(s>0){let l=`option${s}`;r[l]=i.toString()||null}return r},{})}getInputOption({input:e,product:t}){var i;let r=(i=e.name.match(/\[(.*?)\]/))==null?void 0:i[1];if(!r)return null;let a=t.options.findIndex(o=>o.name===r)+1;return a>0?{[`option${a}`]:e.value.toString()}:null}};function q(n){for(var e=[],t=0;t<n.length;){var r=n[t];if(r==="*"||r==="+"||r==="?"){e.push({type:"MODIFIER",index:t,value:n[t++]});continue}if(r==="\\"){e.push({type:"ESCAPED_CHAR",index:t++,value:n[t++]});continue}if(r==="{"){e.push({type:"OPEN",index:t,value:n[t++]});continue}if(r==="}"){e.push({type:"CLOSE",index:t,value:n[t++]});continue}if(r===":"){for(var a="",i=t+1;i<n.length;){var o=n.charCodeAt(i);if(o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122||o===95){a+=n[i++];continue}break}if(!a)throw new TypeError("Missing parameter name at ".concat(t));e.push({type:"NAME",index:t,value:a}),t=i;continue}if(r==="("){var s=1,c="",i=t+1;if(n[i]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(i));for(;i<n.length;){if(n[i]==="\\"){c+=n[i++]+n[i++];continue}if(n[i]===")"){if(s--,s===0){i++;break}}else if(n[i]==="("&&(s++,n[i+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(i));c+=n[i++]}if(s)throw new TypeError("Unbalanced pattern at ".concat(t));if(!c)throw new TypeError("Missing pattern at ".concat(t));e.push({type:"PATTERN",index:t,value:c}),t=i;continue}e.push({type:"CHAR",index:t,value:n[t++]})}return e.push({type:"END",index:t,value:""}),e}function K(n,e){e===void 0&&(e={});for(var t=q(n),r=e.prefixes,a=r===void 0?"./":r,i="[^".concat(R(e.delimiter||"/#?"),"]+?"),o=[],s=0,c=0,l="",h=function(v){if(c<t.length&&t[c].type===v)return t[c++].value},p=function(v){var O=h(v);if(O!==void 0)return O;var E=t[c],V=E.type,A=E.index;throw new TypeError("Unexpected ".concat(V," at ").concat(A,", expected ").concat(v))},f=function(){for(var v="",O;O=h("CHAR")||h("ESCAPED_CHAR");)v+=O;return v};c<t.length;){var d=h("CHAR"),g=h("NAME"),P=h("PATTERN");if(g||P){var y=d||"";a.indexOf(y)===-1&&(l+=y,y=""),l&&(o.push(l),l=""),o.push({name:g||s++,prefix:y,suffix:"",pattern:P||i,modifier:h("MODIFIER")||""});continue}var m=d||h("ESCAPED_CHAR");if(m){l+=m;continue}l&&(o.push(l),l="");var U=h("OPEN");if(U){var y=f(),T=h("NAME")||"",u=h("PATTERN")||"",S=f();p("CLOSE"),o.push({name:T||(u?s++:""),pattern:T&&!u?i:u,prefix:y,suffix:S,modifier:h("MODIFIER")||""});continue}p("END")}return o}function w(n,e){var t=[],r=$(n,t,e);return B(r,t,e)}function B(n,e,t){t===void 0&&(t={});var r=t.decode,a=r===void 0?function(i){return i}:r;return function(i){var o=n.exec(i);if(!o)return!1;for(var s=o[0],c=o.index,l=Object.create(null),h=function(f){if(o[f]===void 0)return"continue";var d=e[f-1];d.modifier==="*"||d.modifier==="+"?l[d.name]=o[f].split(d.prefix+d.suffix).map(function(g){return a(g,d)}):l[d.name]=a(o[f],d)},p=1;p<o.length;p++)h(p);return{path:s,index:c,params:l}}}function R(n){return n.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function H(n){return n&&n.sensitive?"":"i"}function J(n,e){if(!e)return n;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,r=0,a=t.exec(n.source);a;)e.push({name:a[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),a=t.exec(n.source);return n}function Q(n,e,t){var r=n.map(function(a){return $(a,e,t).source});return new RegExp("(?:".concat(r.join("|"),")"),H(t))}function k(n,e,t){return G(K(n,t),e,t)}function G(n,e,t){t===void 0&&(t={});for(var r=t.strict,a=r===void 0?!1:r,i=t.start,o=i===void 0?!0:i,s=t.end,c=s===void 0?!0:s,l=t.encode,h=l===void 0?function(A){return A}:l,p=t.delimiter,f=p===void 0?"/#?":p,d=t.endsWith,g=d===void 0?"":d,P="[".concat(R(g),"]|$"),y="[".concat(R(f),"]"),m=o?"^":"",U=0,T=n;U<T.length;U++){var u=T[U];if(typeof u=="string")m+=R(h(u));else{var S=R(h(u.prefix)),v=R(h(u.suffix));if(u.pattern)if(e&&e.push(u),S||v)if(u.modifier==="+"||u.modifier==="*"){var O=u.modifier==="*"?"?":"";m+="(?:".concat(S,"((?:").concat(u.pattern,")(?:").concat(v).concat(S,"(?:").concat(u.pattern,"))*)").concat(v,")").concat(O)}else m+="(?:".concat(S,"(").concat(u.pattern,")").concat(v,")").concat(u.modifier);else u.modifier==="+"||u.modifier==="*"?m+="((?:".concat(u.pattern,")").concat(u.modifier,")"):m+="(".concat(u.pattern,")").concat(u.modifier);else m+="(?:".concat(S).concat(v,")").concat(u.modifier)}}if(c)a||(m+="".concat(y,"?")),m+=t.endsWith?"(?=".concat(P,")"):"$";else{var E=n[n.length-1],V=typeof E=="string"?y.indexOf(E[E.length-1])>-1:E===void 0;a||(m+="(?:".concat(y,"(?=").concat(P,"))?")),V||(m+="(?=".concat(y,"|").concat(P,")"))}return new RegExp(m,H(t))}function $(n,e,t){return n instanceof RegExp?J(n,e):Array.isArray(n)?Q(n,e,t):k(n,e,t)}var x={isHome:w("/:locale?"),isCollection:w("/:locale?/collections/(.*)"),isProduct:w("/:locale?/products/:product"),isNestedProduct:w("/:locale?/collections/:collection?/products/:product"),isPage:w("/:locale?/pages/:page/:rest?"),isAccount:w("/:locale?/account/:account?"),isBlog:w("/:locale?/blog/:blog?"),isCart:w("/:locale?/cart/:cart?"),isProxy:w("/:locale?/apps/(.*)")},X=[{pageType:"product",match:n=>x.isProduct(n)||x.isNestedProduct(n)},{pageType:"collection",match:n=>x.isCollection(n)},{pageType:"page",match:n=>x.isPage(n)},{pageType:"account",match:n=>x.isAccount(n)},{pageType:"blog",match:n=>x.isBlog(n)},{pageType:"cart",match:n=>x.isCart(n)},{pageType:"home",match:n=>x.isHome(n)},{pageType:"proxy",match:n=>x.isProxy(n)}],C=class{constructor({wishlistUrl:e}){this.wishlistUrl=e}parse(e){for(let t of X){let r=t.match(e);if(r)return e.startsWith(this.wishlistUrl)?{pageType:"wishlist",handle:r.params.page}:{pageType:t.pageType,handle:r.params.page}}return{pageType:void 0}}};import Y from"https://cdn.jsdelivr.net/npm/short-unique-id@4.4.4/+esm";var j=class{constructor(){this.uid=new Y({length:10})}getSessionId(){if(localStorage.getItem("wk_session_id"))return localStorage.getItem("wk_session_id");let e=localStorage.getItem("appmate-session");if(e)try{let r=JSON.parse(e).state.sid;return localStorage.setItem("wk_session_id",r),r}catch(r){console.error(r)}let t=this.uid();return localStorage.setItem("wk_session_id",t),t}};var L=class{constructor(e){this.rootUrl=e.rootUrl,this.shopDomain=e.shopDomain,this.wishlistUrl=e.wishlistUrl,this.placeholderImageUrl=e.placeholderImageUrl,this.fileUrl=e.fileUrl}getWishlistIdFromUrl(e){if(!e)return;let t=e.replace(this.rootUrl,"/").split("/");return t.length===4?t.pop():"mine"}getProductHandleFromUrl(e){var t;if(!!e)return e instanceof URL&&(e=e.pathname),(t=e.split("/").pop())==null?void 0:t.split("?")[0]}getVariantIdFromUrl(e){return new URLSearchParams(e.split("?")[1]).get("variant")}getPublicWishlistUrl(e){return`https://${this.shopDomain}${this.wishlistUrl}/${e}`}getFileUrl(e=""){return`https:${this.fileUrl.split("?")[0]}${e}`}getImageUrl(e,t){var a,i;if(!e)return(a=this.placeholderImageUrl)!=null?a:"";let r=this.getImage(e);return r!=null&&r.src?this.appendSize(r.src,t):(i=this.placeholderImageUrl)!=null?i:""}getImage(e){var t,r,a,i,o,s;if(e.hasOwnProperty("sku"))return{src:(r=(t=e.featured_image)==null?void 0:t.src)!=null?r:""};if(e!=null&&e.selected_or_first_available_variant){let c=e;return(a=c.selected_or_first_available_variant)!=null&&a.featured_image?this.getImage(c.selected_or_first_available_variant):{src:(i=c.featured_image)!=null?i:c.images[0]}}else if((o=e==null?void 0:e.images)!=null&&o.length){let c=e;return{src:(s=c.featured_image)!=null?s:c.images[0]}}else if(e.hasOwnProperty("src"))return{src:e.src};return null}appendSize(e,t){let r=new URL(e.startsWith("//")?`https://${e}`:e);return t!=null&&t.width&&r.searchParams.set("width",t==null?void 0:t.width.toString()),t!=null&&t.height&&r.searchParams.set("height",t==null?void 0:t.height.toString()),r.href}getVariantUrl(e,t){if(!!e)return t?e+`?variant=${t}`:e}};import{fromEvent as Z,map as z}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";var D=class{constructor(){this.dispatcher=document}publish(e){this.dispatcher.dispatchEvent(new CustomEvent(e.name,{detail:e,bubbles:!1,cancelable:!1}))}subscribe(e,t){return Z(this.dispatcher,e).pipe(z(r=>{let a=r;return{name:a.type,data:a.detail.data}})).subscribe(t)}subscribeMany(e){return Object.entries(e).map(([t,r])=>this.subscribe(t,r))}};export{I as DomUtil,W as LocaleUtil,_ as MoneyUtil,M as ProductUtil,C as RouteUtil,j as SessionUtil,F as ThemeObserver,L as UrlUtil,D as WishlistEvents}; | ||
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}; |
@@ -1,1 +0,1 @@ | ||
import{lastValueFrom as r}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{WishlistState as m}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/state.js";import{ShopifyApi as p,WishlistApi as u,TrackingApi as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/api.js";import{RouteUtil as y,SessionUtil as W,LocaleUtil as f,MoneyUtil as P,UrlUtil as w,ProductUtil as U,WishlistEvents as v,DomUtil as I}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/utils.js";var d=class{constructor({settings:t,stylesheets:a,...i}){this.stylesLoaded=!1;var o,e;this.config=this.parseConfig(i),this.settings={...t,loginRequired:!!t.loginRequired&&!this.config.customer.id},this.events=new v,this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.utils=this.initUtils(),this.apis={wishlist:new u({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(o=this.config.customer.id)!=null?o:void 0,sessionId:this.utils.session.getSessionId(),trackingSource:this.utils.route.parse(window.location.pathname).pageType}),shopify:new p({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new g({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(e=this.config.customer.id)!=null?e:void 0,sessionId:this.utils.session.getSessionId(),utils:this.utils,settings:t})},this.state=new m({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this.addToCart=(...s)=>r(this.state.addToCart(...s)),this.addAllToCart=(...s)=>r(this.state.addAllToCart(...s)),this.addWishlistItem=(...s)=>r(this.state.addWishlistItem(...s)),this.clearWishlist=(...s)=>r(this.state.clearWishlist(...s)),this.loadProductInfo=(...s)=>r(this.state.loadProductInfo(...s)),this.loadShopifyProduct=(...s)=>r(this.state.loadShopifyProduct(...s)),this.loadWishlist=(...s)=>r(this.state.loadWishlist(...s)),this.loadWishlistItem=(...s)=>r(this.state.loadWishlistItem(...s)),this.loadWishlistProduct=(...s)=>r(this.state.loadWishlistProduct(...s)),this.publishWishlistEvent=(...s)=>r(this.state.publishWishlistEvent(...s)),this.publishWishlistItemEvent=(...s)=>r(this.state.publishWishlistItemEvent(...s)),this.removeWishlistItem=(...s)=>r(this.state.removeWishlistItem(...s)),this.shareWishlist=(...s)=>r(this.state.shareWishlist(...s)),this.updateWishlistItem=(...s)=>r(this.state.updateWishlistItem(...s)),this.initStyles(a),this.initUrlChangeEvents(),this.trackCurrentPage(),requestAnimationFrame(()=>{this.events.publish({name:"wk:app:ready"})})}async initStyles(t){if(!(t!=null&&t.length)){this.onStylesLoaded();return}try{await Promise.all(t.map(a=>new Promise((i,o)=>{let e=document.createElement("link");e.rel="stylesheet",e.href=a,e.onload=i,e.onerror=o,document.head.appendChild(e)}))),this.onStylesLoaded()}catch(a){console.warn(a),this.events.publish({name:"wk:app:load-styles:error"})}}trackCurrentPage(){let t=this.utils.route.parse(window.location.pathname).pageType;if(t!=null&&t.includes("wishlist")){let a=this.utils.url.getWishlistIdFromUrl(window.location.pathname);a&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:a})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUtils(){let t=this.config.shop.domain,a=this.config.products.fallbackImage,i=this.config.shop.moneyFormat,o=this.config.locale,e=new y({wishlistUrl:this.routes.wishlistUrl});return{url:new w({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:t,placeholderImageUrl:a,fileUrl:this.routes.fileUrl}),money:new P({moneyFormat:i,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),product:new U,locale:new f({locale:o}),route:e,dom:new I({routeUtil:e}),session:new W}}initUrlChangeEvents(){let t=history.replaceState,a=({productHandle:i,variantId:o})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:i,variantId:o}})};history.replaceState=(...i)=>{let o=`${window.location.protocol}//${window.location.host}`,e=typeof i[2]=="string"?new URL(i[2],o):i[2],s=t.apply(history,i);if(!e)return s;let l=this.utils.url.getProductHandleFromUrl(e),n=e.searchParams.get("variant");if(!l||!n)return s;a({productHandle:l,variantId:parseInt(n)})}}parseConfig({config:t,locale:a}){var i,o,e,s,l,n,h,c;return{customer:{id:t.customerId?parseInt(t.customerId):null,email:(i=t.customerEmail)!=null?i:""},shop:{name:(o=t.shopName)!=null?o:"",domain:(e=t.shopDomain)!=null?e:"",permanentDomain:(s=t.shopPermanentDomain)!=null?s:"",currency:(l=t.shopCurrency)!=null?l:"",moneyFormat:(n=t.shopMoneyFormat)!=null?n:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(h=t.apiHost)!=null?h:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(c=t.productFallbackImage)!=null?c:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:a}}parseRoutes(){var i;let t=this.config.routes.rootUrl,a=(i=this.settings.wishlistPath)!=null?i:"/apps/wishlist";return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+a.split("/").filter(o=>!!o).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"}}};export{d as WishlistApp}; | ||
var c=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 c;if(typeof t=="object")return this.searchByStyle(t,this.element,i=>i.parentElement,e);let s=this.element.closest(t);return s?new c(s):new c}find(t){var s;let e=(s=this.element)==null?void 0:s.querySelector(t);return e?new c(e):new c}searchByStyle(t,e,s,i=5){if(i<0||!e)return null;let r=getComputedStyle(e);if(Object.entries(t).every(([n,p])=>r.getPropertyValue(n)===p))return new c(e);let l=s(e);return l?this.searchByStyle(t,l,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 c(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(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(t){let e={};for(let s in t){e[s]={};for(let i in t[s])e[s][i]=this.decodeHtmlEntities(t[s][i])}return e}translate(t){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}),this.initStyles(t==null?void 0:t.filter(s=>s.includes(".css"))),this.initScripts(t==null?void 0:t.filter(s=>s.includes(".js"))),(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:l}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.0/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.0/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.16.0/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:o,ProductUtil:l}),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",n=>{var p,h;(p=n.data)!=null&&p.sessionId&&this.setSessionId((h=n.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 l=this.theme.getProductHandle(r),n=r.searchParams.get("variant");if(!l||!n)return o;e({productHandle:l,variantId:parseInt(n)})}}parseConfig({config:t,locale:e}){var s,i,r,o,l,n,p,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:(l=t.shopCurrency)!=null?l:"",moneyFormat:(n=t.shopMoneyFormat)!=null?n:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(p=t.apiHost)!=null?p:"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,l,n,p,h,f,b,U,S,v,P,W,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:(l=(o=t==null?void 0:t.general)==null?void 0:o.wishlistMode)!=null?l:"PRODUCT",wishlistPath:(p=(n=t==null?void 0:t.general)==null?void 0:n.wishlistPath)!=null?p:"/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:(W=(P=t==null?void 0:t.wishlistPage)==null?void 0:P.loginHintType)!=null?W:"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}; |
@@ -1,1 +0,1 @@ | ||
var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var u=(o,a,t,e)=>{for(var n=e>1?void 0:e?v(a,t):a,s=o.length-1,i;s>=0;s--)(i=o[s])&&(n=(e?i(a,t,n):i(n))||n);return e&&n&&f(a,t,n),n};import{from as g,fromEvent as c,isObservable as h,of as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{filter as y,first as b,switchMap as m,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";import{state as C}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{LitElement as S}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{WishlistStateController as E}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.7/controllers.js";var l=class extends S{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.stateCtrl=new E(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){}connect(){if(!this.connected){if(!window.WishlistKing){c(document,"wk:app:ready").pipe(b()).subscribe(()=>this.connect());return}if(!this.app.stylesLoaded){c(document,"wk:app:load-styles:success").pipe(b()).subscribe(()=>this.connect());return}this.connected=!0,this.init(),this.appReadyCallback()}}getStateConfig(){return{}}getTranslation(t){var e;return(e=window.WishlistKing)!=null&&e.utils.locale?window.WishlistKing.utils.locale.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(n=>n()),(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}attributeChangedCallback(t,e,n){super.attributeChangedCallback(t,e,n),this.connected&&this.initState("cache-first")}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(t){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe(t).subscribe(e=>{this.updateState(e)})}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(([n,s])=>{let[i,r]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:i,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:n}){return c(this,t).pipe(p(s=>{this.eventPending&&s.preventDefault()}),y(()=>!this.eventPending),p(()=>{this.eventPending=!0}),m(s=>{let i=null;if(n&&s.target instanceof HTMLElement&&(i=s.target.closest(n)),n&&!i)return d(null);let r=e.bind(this)(s,n?i:s.currentTarget);return h(r)?r:typeof(r==null?void 0:r.then)=="function"?g(r):d(r)})).subscribe(()=>{this.eventPending=!1})}unlessEventPending(t){let e=()=>this.eventPending=!0,n=()=>this.eventPending=!1;return s=>{if(this.eventPending){t.preventDefault();return}e();let i=s.bind(this)(t);h(i)?i.subscribe(()=>n()):typeof(i==null?void 0:i.then)=="function"?i.then(()=>n()).catch(r=>{throw n(),r}):n()}}};u([C()],l.prototype,"state",2);export{l as WishlistElement}; | ||
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.0/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}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 8 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 13 instances in 1 package
242063
19
1065
55