@appmate/wishlist
Advanced tools
Comparing version 4.17.0 to 4.17.1
@@ -1,1 +0,1 @@ | ||
var f=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var n=(p,s,o,l)=>{for(var t=l>1?void 0:l?m(s,o):s,i=p.length-1,r;i>=0;i--)(r=p[i])&&(t=(l?r(s,o,t):r(t))||t);return l&&t&&f(s,o,t),t};import{LitElement as y}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as g,property as a}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as c}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";var e=class extends y{constructor(){super(...arguments);this.text="";this.layout="text-only";this.parentheses=!1;this.floatingUi=new u(this)}updated(o){o.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var t,i,r;let o={"wk-badge":!0,"wk-parentheses":!!this.parentheses,"wk-pill":(i=(t=this.layout)==null?void 0:t.includes("pill"))!=null?i:!1},l=(r=this.layout)!=null&&r.includes("text")?this.text:"";return h`<span class=${c(o)}>${l}</span>`}createRenderRoot(){return this}};n([a({type:String})],e.prototype,"text",2),n([a({type:String})],e.prototype,"layout",2),n([a({type:Boolean})],e.prototype,"parentheses",2),n([a({type:Object})],e.prototype,"floating",2),e=n([g("wk-badge")],e);export{e as Badge}; | ||
var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var n=(p,i,s,o)=>{for(var t=o>1?void 0:o?y(i,s):i,l=p.length-1,r;l>=0;l--)(r=p[l])&&(t=(o?r(i,s,t):r(t))||t);return o&&t&&m(i,s,t),t};import{LitElement as c}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as u,property as a}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";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as h}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/controllers.js";var e=class extends c{constructor(){super(...arguments);this.text="";this.layout="text-only";this.parentheses=!1;this.floatingUi=new h(this)}render(){var t,l,r;let s={"wk-badge":!0,"wk-parentheses":!!this.parentheses,"wk-pill":(l=(t=this.layout)==null?void 0:t.includes("pill"))!=null?l:!1},o=(r=this.layout)!=null&&r.includes("text")?this.text:"";return f`<span class=${g(s)}>${o}</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([u("wk-badge")],e);export{e as Badge}; |
@@ -1,6 +0,6 @@ | ||
var b=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=(o,i,e,n)=>{for(var l=n>1?void 0:n?c(i,e):i,s=o.length-1,g;s>=0;s--)(g=o[s])&&(l=(n?g(i,e,l):g(l))||l);return n&&l&&b(i,e,l),l};import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as x,property as r}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as d}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as u}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";var f=Number.isNaN||function(i){return typeof i=="number"&&i!==i};function p(o,i){return!!(o===i||f(o)&&f(i))}function y(o,i){if(o.length!==i.length)return!1;for(var e=0;e<o.length;e++)if(!p(o[e],i[e]))return!1;return!0}function h(o,i){i===void 0&&(i=y);var e=null;function n(){for(var l=[],s=0;s<arguments.length;s++)l[s]=arguments[s];if(e&&e.lastThis===this&&i(l,e.lastArgs))return e.lastResult;var g=o.apply(this,l);return e={lastResult:g,lastArgs:l,lastThis:this},g}return n.clear=function(){e=null},n}import{FloatingUiController as $}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/components/icon.js";var t=class extends m{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.layout="icon-and-text";this.outline=!1;this.fullWidth=!1;this.alignment="center";this.badgeParentheses=!1;this.badgeHidden=!1;this.badgeHiddenIfEmpty=!1;this.floatingUi=new $(this);this.getBadgeFloating=h((e,n)=>{if(!(!e||!n))return{...e,reference:n}})}updated(e){e.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var l,s,g;let e=(l=this.alignment)!=null?l:"center",n={"wk-button":!0,"wk-selected":!!this.selected,"wk-outline":!!this.outline,"wk-full-width":!!this.fullWidth,[`wk-align-${e}`]:!0};return this.href?d` | ||
var b=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var i=(o,n,e,r)=>{for(var l=r>1?void 0:r?p(n,e):n,s=o.length-1,g;s>=0;s--)(g=o[s])&&(l=(r?g(n,e,l):g(l))||l);return r&&l&&b(n,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 a}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 h=Number.isNaN||function(n){return typeof n=="number"&&n!==n};function c(o,n){return!!(o===n||h(o)&&h(n))}function y(o,n){if(o.length!==n.length)return!1;for(var e=0;e<o.length;e++)if(!c(o[e],n[e]))return!1;return!0}function f(o,n){n===void 0&&(n=y);var e=null;function r(){for(var l=[],s=0;s<arguments.length;s++)l[s]=arguments[s];if(e&&e.lastThis===this&&n(l,e.lastArgs))return e.lastResult;var g=o.apply(this,l);return e={lastResult:g,lastArgs:l,lastThis:this},g}return r.clear=function(){e=null},r}import{FloatingUiController as S}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/components/icon.js";var t=class extends m{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.layout="icon-and-text";this.outline=!1;this.fullWidth=!1;this.alignment="center";this.badgeParentheses=!1;this.badgeHidden=!1;this.badgeHiddenIfEmpty=!1;this.floatingUi=new S(this);this.getBadgeFloating=f((e,r)=>{if(!(!e||!r))return{...e,reference:r}})}render(){var l,s,g;let e=(l=this.alignment)!=null?l:"center",r={"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 | ||
href=${this.href} | ||
aria-label=${(s=this.hint)!=null?s:""} | ||
class=${u(n)} | ||
class=${u(r)} | ||
> | ||
@@ -13,3 +13,3 @@ ${this.renderIcon()}${this.renderText()}${this.renderBadge()} | ||
aria-label=${(g=this.hint)!=null?g:""} | ||
class=${u(n)} | ||
class=${u(r)} | ||
?disabled=${this.disabled} | ||
@@ -19,3 +19,3 @@ > | ||
</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.badgeHidden||this.badgeText===void 0)&&!(this.badgeHiddenIfEmpty&&(!this.badgeText||parseInt(this.badgeText)===0)))return d`<wk-badge | ||
`}renderIcon(){var r;let e=(r=this.layout)!=null?r:"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 r;let e=(r=this.layout)!=null?r:"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} | ||
@@ -25,2 +25,2 @@ .layout=${this.badgeLayout} | ||
.floating=${this.getBadgeFloating(this.badgeFloating,this)} | ||
></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}; | ||
></wk-badge>`}createRenderRoot(){return this}};i([a({type:String})],t.prototype,"href",2),i([a({type:String})],t.prototype,"text",2),i([a({type:String})],t.prototype,"hint",2),i([a({type:Boolean})],t.prototype,"selected",2),i([a({type:Boolean})],t.prototype,"disabled",2),i([a({type:String})],t.prototype,"layout",2),i([a({type:String})],t.prototype,"icon",2),i([a({type:Boolean})],t.prototype,"outline",2),i([a({type:Boolean,attribute:"full-width"})],t.prototype,"fullWidth",2),i([a({type:String})],t.prototype,"alignment",2),i([a({type:Object})],t.prototype,"floating",2),i([a({type:String,attribute:"badge-text"})],t.prototype,"badgeText",2),i([a({type:String,attribute:"badge-layout"})],t.prototype,"badgeLayout",2),i([a({type:Boolean,attribute:"badge-parentheses"})],t.prototype,"badgeParentheses",2),i([a({type:Boolean,attribute:"badge-hidden"})],t.prototype,"badgeHidden",2),i([a({type:Boolean,attribute:"badge-hidden-if-empty"})],t.prototype,"badgeHiddenIfEmpty",2),i([a({type:Object,attribute:"badge-floating"})],t.prototype,"badgeFloating",2),t=i([x("wk-button")],t);export{t as Button}; |
@@ -1,2 +0,2 @@ | ||
var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var c=(a,n,r,o)=>{for(var t=o>1?void 0:o?d(n,r):n,e=a.length-1,i;e>=0;e--)(i=a[e])&&(t=(o?i(n,r,t):i(t))||t);return o&&t&&m(n,r,t),t};import{LitElement as u}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as h,property as l}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/+esm";import{classMap as w}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{Icon as k}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/components/icon.js";var s=class extends u{constructor(){super();this.icon="caret"}render(){if(!this.option)return;let r=w({"wk-select":!0,"wk-single-option":this.option.values.length===1}),o=`options[${this.option.name}]`,t=`wk-input__${o}`;return p` | ||
var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var c=(a,n,r,o)=>{for(var t=o>1?void 0:o?d(n,r):n,e=a.length-1,i;e>=0;e--)(i=a[e])&&(t=(o?i(n,r,t):i(t))||t);return o&&t&&m(n,r,t),t};import{LitElement as u}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as h,property as l}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/+esm";import{classMap as w}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{Icon as k}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/components/icon.js";var s=class extends u{constructor(){super();this.icon="caret"}render(){if(!this.option)return;let r=w({"wk-option-select":!0,"wk-single-option":this.option.values.length===1}),o=`options[${this.option.name}]`,t=`wk-input__${o}`;return p` | ||
<div class=${r}> | ||
@@ -3,0 +3,0 @@ <label class="wk-label" for=${t}>${this.option.name}</label> |
@@ -1,7 +0,7 @@ | ||
var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var r=(a,n,t,i)=>{for(var o=i>1?void 0:i?c(n,t):n,s=a.length-1,d;s>=0;s--)(d=a[s])&&(o=(i?d(n,t,o):d(o))||o);return i&&o&&p(n,t,o),o};import{LitElement as f,css as u}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as w,state as m,property as l}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{html as v}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as x}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";var e=class extends f{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new x(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}updated(t){t.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var i;let t={"wk-popover":!0,"wk-show":this.transition==="show","wk-hide":this.transition==="hide"};return this.elementClass&&(t[this.elementClass]=!0),v` | ||
var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var r=(a,n,t,o)=>{for(var i=o>1?void 0:o?c(n,t):n,s=a.length-1,d;s>=0;s--)(d=a[s])&&(i=(o?d(n,t,i):d(i))||i);return o&&i&&p(n,t,i),i};import{LitElement as u,css as w}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{customElement as m,state as v,property as l}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";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{FloatingUiController as x}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/controllers.js";var e=class extends u{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"}render(){var o;let t={"wk-popover":!0,"wk-show":this.transition==="show","wk-hide":this.transition==="hide"};return this.elementClass&&(t[this.elementClass]=!0),f` | ||
<div class=${g(t)}> | ||
<div class="wk-text">${this.getText()}</div> | ||
${(i=this.floatingUi)==null?void 0:i.arrowEl} | ||
${(o=this.floatingUi)==null?void 0:o.arrowEl} | ||
</div> | ||
`}firstUpdated(){this.autoShow!==!1&&(this._autoShowTimer=setTimeout(()=>this.show(),(this.autoShow===!0?0:this.autoShow)*1e3)),this.autoHide!==!1&&(this._autoHideTimer=setTimeout(()=>this.hide(),(this.autoHide===!0?2:this.autoHide)*1e3))}add(t=document.body){this.added||t.appendChild(this)}show(t){if(this.showing)return;this.clearAllTimer(),this.added||this.add(),requestAnimationFrame(()=>{this.transition="show"});let i=()=>{this.removeEventListener("transitionend",i),this.removeEventListener("transitioncancel",o),t==null||t()},o=()=>{this.removeEventListener("transitionend",i),this.removeEventListener("transitioncancel",o)};this.addEventListener("transitionend",i),this.addEventListener("transitioncancel",o)}hide(){if(!this.showing)return;this.clearAllTimer(),requestAnimationFrame(()=>{this.transition="hide"});let t=()=>{this.removeEventListener("transitionend",t),this.removeEventListener("transitioncancel",i),this.remove()},i=()=>{this.removeEventListener("transitionend",t),this.removeEventListener("transitioncancel",i)};this.addEventListener("transitionend",t),this.addEventListener("transitioncancel",i)}remove(){this.parentElement&&this.parentElement.removeChild(this),this.transition=void 0,this.dispatchEvent(new Event("removed"))}clearAllTimer(){this._autoShowTimer&&(clearTimeout(this._autoShowTimer),this._autoShowTimer=void 0),this._autoHideTimer&&(clearTimeout(this._autoHideTimer),this._autoHideTimer=void 0)}getText(){return typeof this.text=="function"?this.text():this.text}createRenderRoot(){return this}};r([l({attribute:!1})],e.prototype,"text",2),r([m()],e.prototype,"transition",2),r([l({type:Object})],e.prototype,"floating",2),e=r([w("wk-popover")],e);var b=u` | ||
`}firstUpdated(){this.autoShow!==!1&&(this._autoShowTimer=setTimeout(()=>this.show(),(this.autoShow===!0?0:this.autoShow)*1e3)),this.autoHide!==!1&&(this._autoHideTimer=setTimeout(()=>this.hide(),(this.autoHide===!0?2:this.autoHide)*1e3))}add(t=document.body){this.added||t.appendChild(this)}show(t){if(this.showing)return;this.clearAllTimer(),this.added||this.add(),requestAnimationFrame(()=>{this.transition="show"});let o=()=>{this.removeEventListener("transitionend",o),this.removeEventListener("transitioncancel",i),t==null||t()},i=()=>{this.removeEventListener("transitionend",o),this.removeEventListener("transitioncancel",i)};this.addEventListener("transitionend",o),this.addEventListener("transitioncancel",i)}hide(){if(!this.showing)return;this.clearAllTimer(),requestAnimationFrame(()=>{this.transition="hide"});let t=()=>{this.removeEventListener("transitionend",t),this.removeEventListener("transitioncancel",o),this.remove()},o=()=>{this.removeEventListener("transitionend",t),this.removeEventListener("transitioncancel",o)};this.addEventListener("transitionend",t),this.addEventListener("transitioncancel",o)}remove(){this.parentElement&&this.parentElement.removeChild(this),this.transition=void 0,this.dispatchEvent(new Event("removed"))}clearAllTimer(){this._autoShowTimer&&(clearTimeout(this._autoShowTimer),this._autoShowTimer=void 0),this._autoHideTimer&&(clearTimeout(this._autoHideTimer),this._autoHideTimer=void 0)}getText(){return typeof this.text=="function"?this.text():this.text}createRenderRoot(){return this}};r([l({attribute:!1})],e.prototype,"text",2),r([v()],e.prototype,"transition",2),r([l({type:Object})],e.prototype,"floating",2),e=r([m("wk-popover")],e);var b=w` | ||
wk-popover { | ||
@@ -8,0 +8,0 @@ --text-color: white; |
@@ -1,2 +0,2 @@ | ||
var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var o=(r,n,t,s)=>{for(var e=s>1?void 0:s?m(n,t):n,l=r.length-1,a;l>=0;l--)(a=r[l])&&(e=(s?a(n,t,e):a(e))||e);return s&&e&&p(n,t,e),e};import{LitElement as d}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{html as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{customElement as f,property as c}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{Swatch as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/components/swatch.js";var i=class extends d{constructor(){super();this.label="";this.name="";this.options=[]}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof g&&this.options.push(t);this.innerHTML=""}render(){let t=b({"wk-swatches":!0,"wk-single-option":this.options.length===1});return h` | ||
var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var o=(r,n,t,s)=>{for(var e=s>1?void 0:s?m(n,t):n,l=r.length-1,a;l>=0;l--)(a=r[l])&&(e=(s?a(n,t,e):a(e))||e);return s&&e&&p(n,t,e),e};import{LitElement as d}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{html as h}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/+esm";import{customElement as f,property as c}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/class-map/+esm";import{Swatch as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/components/swatch.js";var i=class extends d{constructor(){super();this.label="";this.name="";this.options=[]}connectedCallback(){super.connectedCallback();for(let t of this.children)t instanceof g&&this.options.push(t);this.innerHTML=""}render(){let t=b({"wk-swatches":!0,"wk-single-option":this.options.length===1});return h` | ||
<div class=${t}> | ||
@@ -3,0 +3,0 @@ <fieldset class="wk-fieldset"> |
@@ -1,1 +0,1 @@ | ||
function _(t){return t.split("-")[0]}function B(t){return t.split("-")[1]}function D(t){return["top","bottom"].includes(_(t))?"x":"y"}function J(t){return t==="y"?"height":"width"}function at(t,e,i){let{reference:n,floating:o}=t,l=n.x+n.width/2-o.width/2,s=n.y+n.height/2-o.height/2,r=D(e),c=J(r),f=n[c]/2-o[c]/2,d=r==="x",a;switch(_(e)){case"top":a={x:l,y:n.y-o.height};break;case"bottom":a={x:l,y:n.y+n.height};break;case"right":a={x:n.x+n.width,y:s};break;case"left":a={x:n.x-o.width,y:s};break;default:a={x:n.x,y:n.y}}switch(B(e)){case"start":a[r]-=f*(i&&d?-1:1);break;case"end":a[r]+=f*(i&&d?-1:1)}return a}var ct=async(t,e,i)=>{let{placement:n="bottom",strategy:o="absolute",middleware:l=[],platform:s}=i,r=l.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e)),f=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:a}=at(f,n,c),u=n,h={},p=0;for(let m=0;m<r.length;m++){let{name:g,fn:y}=r[m],{x:v,y:x,data:I,reset:b}=await y({x:d,y:a,initialPlacement:n,placement:u,strategy:o,middlewareData:h,rects:f,platform:s,elements:{reference:t,floating:e}});d=v!=null?v:d,a=x!=null?x:a,h={...h,[g]:{...h[g],...I}},b&&p<=50&&(p++,typeof b=="object"&&(b.placement&&(u=b.placement),b.rects&&(f=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):b.rects),{x:d,y:a}=at(f,u,c)),m=-1)}return{x:d,y:a,placement:u,strategy:o,middlewareData:h}};function ft(t){return typeof t!="number"?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(t):{top:t,right:t,bottom:t,left:t}}function V(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function Q(t,e){var i;e===void 0&&(e={});let{x:n,y:o,platform:l,rects:s,elements:r,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:a="floating",altBoundary:u=!1,padding:h=0}=e,p=ft(h),m=r[u?a==="floating"?"reference":"floating":a],g=V(await l.getClippingRect({element:(i=await(l.isElement==null?void 0:l.isElement(m)))==null||i?m:m.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(r.floating)),boundary:f,rootBoundary:d,strategy:c})),y=V(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({rect:a==="floating"?{...s.floating,x:n,y:o}:s.reference,offsetParent:await(l.getOffsetParent==null?void 0:l.getOffsetParent(r.floating)),strategy:c}):s[a]);return{top:g.top-y.top+p.top,bottom:y.bottom-g.bottom+p.bottom,left:g.left-y.left+p.left,right:y.right-g.right+p.right}}var St=Math.min,Et=Math.max;function Y(t,e,i){return Et(t,St(e,i))}var G=t=>({name:"arrow",options:t,async fn(e){let{element:i,padding:n=0}=t!=null?t:{},{x:o,y:l,placement:s,rects:r,platform:c}=e;if(i==null)return{};let f=ft(n),d={x:o,y:l},a=D(s),u=B(s),h=J(a),p=await c.getDimensions(i),m=a==="y"?"top":"left",g=a==="y"?"bottom":"right",y=r.reference[h]+r.reference[a]-d[a]-r.floating[h],v=d[a]-r.reference[a],x=await(c.getOffsetParent==null?void 0:c.getOffsetParent(i)),I=x?a==="y"?x.clientHeight||0:x.clientWidth||0:0;I===0&&(I=r.floating[h]);let b=y/2-v/2,L=f[m],F=I-p[h]-f[g],w=I/2-p[h]/2+b,R=Y(L,w,F),T=(u==="start"?f[m]:f[g])>0&&w!==R&&r.reference[h]<=r.floating[h];return{[a]:d[a]-(T?w<L?L-w:F-w:0),data:{[a]:R,centerOffset:w-R}}}}),Pt={left:"right",right:"left",bottom:"top",top:"bottom"};function q(t){return t.replace(/left|right|bottom|top/g,e=>Pt[e])}function At(t,e,i){i===void 0&&(i=!1);let n=B(t),o=D(t),l=J(o),s=o==="x"?n===(i?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[l]>e.floating[l]&&(s=q(s)),{main:s,cross:q(s)}}var Ot={start:"end",end:"start"};function lt(t){return t.replace(/start|end/g,e=>Ot[e])}var Wt=["top","right","bottom","left"],zt=Wt.reduce((t,e)=>t.concat(e,e+"-start",e+"-end"),[]);var Z=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i;let{placement:n,middlewareData:o,rects:l,initialPlacement:s,platform:r,elements:c}=e,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:a,fallbackStrategy:u="bestFit",flipAlignment:h=!0,...p}=t,m=_(n),g=a||(m===s||!h?[q(s)]:function(w){let R=q(w);return[lt(w),R,lt(R)]}(s)),y=[s,...g],v=await Q(e,p),x=[],I=((i=o.flip)==null?void 0:i.overflows)||[];if(f&&x.push(v[m]),d){let{main:w,cross:R}=At(n,l,await(r.isRTL==null?void 0:r.isRTL(c.floating)));x.push(v[w],v[R])}if(I=[...I,{placement:n,overflows:x}],!x.every(w=>w<=0)){var b,L;let w=((b=(L=o.flip)==null?void 0:L.index)!=null?b:0)+1,R=y[w];if(R)return{data:{index:w,overflows:I},reset:{placement:R}};let T="bottom";switch(u){case"bestFit":{var F;let st=(F=I.map(M=>[M,M.overflows.filter(H=>H>0).reduce((H,Ct)=>H+Ct,0)]).sort((M,H)=>M[1]-H[1])[0])==null?void 0:F[0].placement;st&&(T=st);break}case"initialPlacement":T=s}if(n!==T)return{reset:{placement:T}}}return{}}}};var U=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:i,y:n}=e,o=await async function(l,s){let{placement:r,platform:c,elements:f}=l,d=await(c.isRTL==null?void 0:c.isRTL(f.floating)),a=_(r),u=B(r),h=D(r)==="x",p=["left","top"].includes(a)?-1:1,m=d&&h?-1:1,g=typeof s=="function"?s(l):s,{mainAxis:y,crossAxis:v,alignmentAxis:x}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...g};return u&&typeof x=="number"&&(v=u==="end"?-1*x:x),h?{x:v*m,y:y*p}:{x:y*p,y:v*m}}(e,t);return{x:i+o.x,y:n+o.y,data:o}}}};function Lt(t){return t==="x"?"y":"x"}var tt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:i,y:n,placement:o}=e,{mainAxis:l=!0,crossAxis:s=!1,limiter:r={fn:g=>{let{x:y,y:v}=g;return{x:y,y:v}}},...c}=t,f={x:i,y:n},d=await Q(e,c),a=D(_(o)),u=Lt(a),h=f[a],p=f[u];if(l){let g=a==="y"?"bottom":"right";h=Y(h+d[a==="y"?"top":"left"],h,h-d[g])}if(s){let g=u==="y"?"bottom":"right";p=Y(p+d[u==="y"?"top":"left"],p,p-d[g])}let m=r.fn({...e,[a]:h,[u]:p});return{...m,data:{x:m.x-i,y:m.y-n}}}}};function wt(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function P(t){if(t==null)return window;if(!wt(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function O(t){return P(t).getComputedStyle(t)}function W(t){return wt(t)?"":t?(t.nodeName||"").toLowerCase():""}function yt(){let t=navigator.userAgentData;return t!=null&&t.brands?t.brands.map(e=>e.brand+"/"+e.version).join(" "):navigator.userAgent}function E(t){return t instanceof P(t).HTMLElement}function C(t){return t instanceof P(t).Element}function ht(t){return typeof ShadowRoot=="undefined"?!1:t instanceof P(t).ShadowRoot||t instanceof ShadowRoot}function $(t){let{overflow:e,overflowX:i,overflowY:n,display:o}=O(t);return/auto|scroll|overlay|hidden/.test(e+n+i)&&!["inline","contents"].includes(o)}function Tt(t){return["table","td","th"].includes(W(t))}function et(t){let e=/firefox/i.test(yt()),i=O(t),n=i.backdropFilter||i.WebkitBackdropFilter;return i.transform!=="none"||i.perspective!=="none"||!!n&&n!=="none"||e&&i.willChange==="filter"||e&&!!i.filter&&i.filter!=="none"||["transform","perspective"].some(o=>i.willChange.includes(o))||["paint","layout","strict","content"].some(o=>{let l=i.contain;return l!=null&&l.includes(o)})}function xt(){return!/^((?!chrome|android).)*safari/i.test(yt())}function it(t){return["html","body","#document"].includes(W(t))}var dt=Math.min,z=Math.max,j=Math.round;function S(t,e,i){var n,o,l,s;e===void 0&&(e=!1),i===void 0&&(i=!1);let r=t.getBoundingClientRect(),c=1,f=1;e&&E(t)&&(c=t.offsetWidth>0&&j(r.width)/t.offsetWidth||1,f=t.offsetHeight>0&&j(r.height)/t.offsetHeight||1);let d=C(t)?P(t):window,a=!xt()&&i,u=(r.left+(a&&(n=(o=d.visualViewport)==null?void 0:o.offsetLeft)!=null?n:0))/c,h=(r.top+(a&&(l=(s=d.visualViewport)==null?void 0:s.offsetTop)!=null?l:0))/f,p=r.width/c,m=r.height/f;return{width:p,height:m,top:h,right:u+p,bottom:h+m,left:u,x:u,y:h}}function A(t){return(e=t,(e instanceof P(e).Node?t.ownerDocument:t.document)||window.document).documentElement;var e}function K(t){return C(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function vt(t){return S(A(t)).left+K(t).scrollLeft}function Ft(t,e,i){let n=E(e),o=A(e),l=S(t,n&&function(c){let f=S(c);return j(f.width)!==c.offsetWidth||j(f.height)!==c.offsetHeight}(e),i==="fixed"),s={scrollLeft:0,scrollTop:0},r={x:0,y:0};if(n||!n&&i!=="fixed")if((W(e)!=="body"||$(o))&&(s=K(e)),E(e)){let c=S(e,!0);r.x=c.x+e.clientLeft,r.y=c.y+e.clientTop}else o&&(r.x=vt(o));return{x:l.left+s.scrollLeft-r.x,y:l.top+s.scrollTop-r.y,width:l.width,height:l.height}}function N(t){if(W(t)==="html")return t;let e=t.assignedSlot||t.parentNode||(ht(t)?t.host:null)||A(t);return ht(e)?e.host:e}function ut(t){return E(t)&&O(t).position!=="fixed"?t.offsetParent:null}function pt(t){let e=P(t),i=ut(t);for(;i&&Tt(i)&&O(i).position==="static";)i=ut(i);return i&&(W(i)==="html"||W(i)==="body"&&O(i).position==="static"&&!et(i))?e:i||function(n){let o=N(n);for(;E(o)&&!it(o);){if(et(o))return o;o=N(o)}return null}(t)||e}function mt(t){if(E(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=S(t);return{width:e.width,height:e.height}}function bt(t){let e=N(t);return it(e)?t.ownerDocument.body:E(e)&&$(e)?e:bt(e)}function k(t,e){var i;e===void 0&&(e=[]);let n=bt(t),o=n===((i=t.ownerDocument)==null?void 0:i.body),l=P(n),s=o?[l].concat(l.visualViewport||[],$(n)?n:[]):n,r=e.concat(s);return o?r:r.concat(k(s))}function gt(t,e,i){return e==="viewport"?V(function(n,o){let l=P(n),s=A(n),r=l.visualViewport,c=s.clientWidth,f=s.clientHeight,d=0,a=0;if(r){c=r.width,f=r.height;let u=xt();(u||!u&&o==="fixed")&&(d=r.offsetLeft,a=r.offsetTop)}return{width:c,height:f,x:d,y:a}}(t,i)):C(e)?function(n,o){let l=S(n,!1,o==="fixed"),s=l.top+n.clientTop,r=l.left+n.clientLeft;return{top:s,left:r,x:r,y:s,right:r+n.clientWidth,bottom:s+n.clientHeight,width:n.clientWidth,height:n.clientHeight}}(e,i):V(function(n){var o;let l=A(n),s=K(n),r=(o=n.ownerDocument)==null?void 0:o.body,c=z(l.scrollWidth,l.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),f=z(l.scrollHeight,l.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),d=-s.scrollLeft+vt(n),a=-s.scrollTop;return O(r||l).direction==="rtl"&&(d+=z(l.clientWidth,r?r.clientWidth:0)-c),{width:c,height:f,x:d,y:a}}(A(t)))}var Ht={getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:n,strategy:o}=t,l=i==="clippingAncestors"?function(f){let d=k(f).filter(h=>C(h)&&W(h)!=="body"),a=f,u=null;for(;C(a)&&!it(a);){let h=O(a);h.position==="static"&&u&&["absolute","fixed"].includes(u.position)&&!et(a)?d=d.filter(p=>p!==a):u=h,a=N(a)}return d}(e):[].concat(i),s=[...l,n],r=s[0],c=s.reduce((f,d)=>{let a=gt(e,d,o);return f.top=z(a.top,f.top),f.right=dt(a.right,f.right),f.bottom=dt(a.bottom,f.bottom),f.left=z(a.left,f.left),f},gt(e,r,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:i,strategy:n}=t,o=E(i),l=A(i);if(i===l)return e;let s={scrollLeft:0,scrollTop:0},r={x:0,y:0};if((o||!o&&n!=="fixed")&&((W(i)!=="body"||$(l))&&(s=K(i)),E(i))){let c=S(i,!0);r.x=c.x+i.clientLeft,r.y=c.y+i.clientTop}return{...e,x:e.x-s.scrollLeft+r.x,y:e.y-s.scrollTop+r.y}},isElement:C,getDimensions:mt,getOffsetParent:pt,getDocumentElement:A,getElementRects:t=>{let{reference:e,floating:i,strategy:n}=t;return{reference:Ft(e,pt(i),n),floating:{...mt(i),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>O(t).direction==="rtl"};function It(t,e,i,n){n===void 0&&(n={});let{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:s=!0,animationFrame:r=!1}=n,c=o&&!r,f=c||l?[...C(t)?k(t):t.contextElement?k(t.contextElement):[],...k(e)]:[];f.forEach(h=>{c&&h.addEventListener("scroll",i,{passive:!0}),l&&h.addEventListener("resize",i)});let d,a=null;if(s){let h=!0;a=new ResizeObserver(()=>{h||i(),h=!1}),C(t)&&!r&&a.observe(t),C(t)||!t.contextElement||r||a.observe(t.contextElement),a.observe(e)}let u=r?S(t):null;return r&&function h(){let p=S(t);!u||p.x===u.x&&p.y===u.y&&p.width===u.width&&p.height===u.height||i(),u=p,d=requestAnimationFrame(h)}(),i(),()=>{var h;f.forEach(p=>{c&&p.removeEventListener("scroll",i),l&&p.removeEventListener("resize",i)}),(h=a)==null||h.disconnect(),a=null,r&&cancelAnimationFrame(d)}}var Rt=(t,e,i)=>ct(t,e,{platform:Ht,...i});var nt=class{constructor(e){this._middleware=[];(this.host=e).addController(this)}hostDisconnected(){this.destroy()}hostUpdated(){this.updatePosition()}hostResized(){this.updatePosition()}float(e){var r;if(this.destroy(),this._settings=e,this._reference=this.getReference(),this._resizeObserver=new ResizeObserver(()=>this.hostResized()),!this._settings)throw new Error("Floating settings are required");if(!this._reference)throw new Error("Floating reference is required");this.host.classList.add("wk-floating");let{position:i,arrow:n=!1,flip:o=!1,shift:l=!1}=this._settings,s=this.getOffsetSetting();Object.assign(this.host.style,{position:(r=i.strategy)!=null?r:"absolute",top:"0",left:"0",transition:"none",transform:"translate3d(0,0,0)"}),i.inset&&!n?this._middleware.push(U(({rects:c,placement:f})=>{var d,a,u,h,p,m;return f.includes("top")||f.includes("bottom")?{mainAxis:-c.floating.height-((d=s==null?void 0:s.mainAxis)!=null?d:0),crossAxis:(a=s==null?void 0:s.crossAxis)!=null?a:0,alignmentAxis:(u=s==null?void 0:s.alignmentAxis)!=null?u:0}:{mainAxis:-c.floating.width-((h=s==null?void 0:s.mainAxis)!=null?h:0),crossAxis:(p=s==null?void 0:s.crossAxis)!=null?p:0,alignmentAxis:(m=s==null?void 0:s.alignmentAxis)!=null?m:0}})):s&&this._middleware.push(U(s)),o&&this._middleware.push(Z()),l&&this._middleware.push(tt()),n&&(this.arrowEl=document.createElement("div"),this.arrowEl.classList.add("wk-arrow"),this._middleware.push(G({element:this.arrowEl}))),this.cleanupAutoUpdate=It(this._reference,this.host,()=>{this.updatePosition()}),this._resizeObserver.observe(this.host)}getOffsetSetting(){var i,n;let e=(i=this._settings)==null?void 0:i.offset;if(!(!e||typeof e=="boolean"))return typeof e=="number"?{mainAxis:e,alignmentAxis:(n=this._settings)!=null&&n.position.inset?e:null}:e}destroy(){var e,i,n,o;Object.assign(this.host.style,{position:"",top:"",left:""}),(i=(e=this.arrowEl)==null?void 0:e.parentElement)==null||i.removeChild(this.arrowEl),this.arrowEl=void 0,this._middleware=[],this.host.classList.remove("wk-floating"),(n=this.cleanupAutoUpdate)==null||n.call(this),(o=this._resizeObserver)==null||o.disconnect()}updatePosition(){var n;if(!this._reference||!this._settings)return;let{strategy:e="absolute",placement:i="top"}=(n=this._settings.position)!=null?n:{};Rt(this._reference,this.host,{middleware:this._middleware,strategy:e,placement:i}).then(({x:o,y:l,placement:s,middlewareData:r})=>{if(r.arrow&&this.arrowEl){let{x:c,y:f}=r.arrow,d={top:"bottom",right:"left",bottom:"top",left:"right"}[s.split("-")[0]],a={bottom:"0deg",left:"90deg",top:"180deg",right:"270deg"}[s.split("-")[0]];Object.assign(this.arrowEl.style,{left:c!=null?`${c}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",[d]:"-5px",transform:`rotate(${a})`})}Object.assign(this.host.style,{transform:`translate3d(${Math.round(o)}px,${Math.round(l)}px,0)`})})}getReference(){if(!this._settings)return;let e=this._settings.reference;if(typeof e=="string"){if(e==="viewport")return this.createViewportReference();let i=document.querySelector(e);if(!i)throw new Error(`Floating reference element (${e}) not found`);return i}return e.hasOwnProperty("element")?e.element:e}createViewportReference(){return{getBoundingClientRect(){var e,i,n,o;return{x:0,y:0,top:0,left:0,bottom:0,right:0,width:(i=(e=window.visualViewport)==null?void 0:e.width)!=null?i:0,height:(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:0}}}}};var ot=class{constructor(e,{app:i}){this.product=null,this.app=i,this.state={selectedVariant:null,selectedOptions:{},hasSelection:!1,optionsWithValues:[],hasOnlyDefaultVariant:!1},(this.host=e).addController(this)}setProduct({product:e,selectedVariantId:i=null,autoSelect:n=!1}){!(e!=null&&e.variants)||(this.product=e,this.initFormState({selectedVariantId:i,autoSelect:n}))}initFormState({selectedVariantId:e,autoSelect:i}){if(!this.product)throw new Error("Product not set");let n=this.initializedVariantId!==e?this.product.variants.find(l=>l.id===e):this.state.selectedVariant;this.initializedVariantId=e;let o=this.app.utils.product.getVariantOptions({variant:n});this.updateFormState({options:o,autoSelect:i})}updateFormState({options:e,change:i,autoSelect:n=!1}){if(!this.product)throw new Error("Product not set");let{hasSelection:o,optionsWithValues:l,selectedOptions:s,selectedVariant:r}=this.app.utils.product.getFormState({product:this.product,options:e,change:i,autoSelect:n});this.state.hasSelection=o,this.state.optionsWithValues=l,this.state.selectedOptions=s,this.state.selectedVariant=r,this.host.requestUpdate()}changeOption({input:e,autoSelect:i=!1}){if(!this.product)throw new Error("Product not set");let n=this.getInputOption(e);if(!n)throw new Error("Cannot parse options from input");this.updateFormState({options:this.state.selectedOptions,change:n,autoSelect:i})}async addToCart({wishlistId:e,wishlistItemId:i}){if(!this.state.selectedVariant)throw new Error("No variant selected");let n=this.host.querySelector("form");if(!n)throw new Error("Form not found");n.classList.add("wk-submitting"),await this.app.addToCart({wishlistId:e,wishlistItemId:i,variantId:this.state.selectedVariant.id,quantity:this.app.utils.product.getFormQuantity({form:n})}),n.classList.remove("wk-submitting")}getInputOption(e){if(!this.product)throw new Error("Product not set");return this.app.utils.product.getInputOption({input:e,product:this.product})}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}};import{combineLatest as Vt,distinctUntilChanged as _t,map as X,of as Dt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var rt=class{constructor(e){this.stateConfig={loading:"eager"};(this.host=e).addController(this)}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}hostConnected(){}hostDisconnected(){}parseStateConfig(e){var i;return{loading:(i=e.loading)!=null?i:"eager",wishlist:this.parseWishlistStateConfig(e),wishlistItem:this.parseWishlistItemStateConfig(e),productInfo:this.parseProductInfoStateConfig(e)}}parseWishlistStateConfig({wishlist:e}){var n;let i=(n=this.host.dataset.wishlistId)!=null?n:"mine";if(!!e)return{params:{wishlistId:i}}}parseWishlistItemStateConfig({wishlistItem:e}){let{wishlistId:i="mine",wishlistItemId:n}=this.host.dataset;if(!(!e||!n))return{params:{wishlistId:i,wishlistItemId:n}}}parseProductInfoStateConfig({productInfo:e}){if(!e)return;let{wishlistId:i="mine",productHandle:n="",productId:o,variantId:l}=this.host.dataset;return{params:{wishlistId:i,productHandle:n,variantId:l?parseInt(l):void 0}}}observe(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e=[];if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.push(this.app.state.observeWishlist({wishlistId:i}).pipe(X(n=>({wishlist:n}))))}if(this.stateConfig.productInfo){let{productHandle:i,variantId:n}=this.stateConfig.productInfo.params;if(!i)throw new Error("Product handle is required");e.push(this.app.state.observeProductInfo({productHandle:i,variantId:n}).pipe(X(o=>({productInfo:o}))))}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.push(this.app.state.observeWishlistItem({wishlistId:i,wishlistItemId:n}).pipe(X(o=>({wishlistItem:o}))))}return e.length||e.push(Dt({})),Vt(e).pipe(X(i=>i.reduce((n,o)=>o.wishlist?{...n,wishlist:o.wishlist}:o.wishlistItem?{...n,wishlistItem:o.wishlistItem}:o.productInfo?{...n,productInfo:o.productInfo}:n,{})),_t((i,n)=>JSON.stringify(i)===JSON.stringify(n)))}getFallback(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e={};if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.wishlist={id:i,isMine:i==="mine",numItems:0,items:[]}}if(this.stateConfig.productInfo){let{variantId:i=0,productHandle:n}=this.stateConfig.productInfo.params;e.productInfo={productId:0,variantId:i,productHandle:n,inWishlist:!1}}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.wishlistItem={id:n,product:{id:0,handle:"",hidden:!1}}}return e}};export{nt as FloatingUiController,ot as ProductFormController,rt as WishlistStateController}; | ||
function V(t){return t.split("-")[0]}function B(t){return t.split("-")[1]}function D(t){return["top","bottom"].includes(V(t))?"x":"y"}function J(t){return t==="y"?"height":"width"}function at(t,e,i){let{reference:n,floating:o}=t,l=n.x+n.width/2-o.width/2,s=n.y+n.height/2-o.height/2,r=D(e),c=J(r),f=n[c]/2-o[c]/2,u=r==="x",a;switch(V(e)){case"top":a={x:l,y:n.y-o.height};break;case"bottom":a={x:l,y:n.y+n.height};break;case"right":a={x:n.x+n.width,y:s};break;case"left":a={x:n.x-o.width,y:s};break;default:a={x:n.x,y:n.y}}switch(B(e)){case"start":a[r]-=f*(i&&u?-1:1);break;case"end":a[r]+=f*(i&&u?-1:1)}return a}var ct=async(t,e,i)=>{let{placement:n="bottom",strategy:o="absolute",middleware:l=[],platform:s}=i,r=l.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e)),f=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:a}=at(f,n,c),d=n,h={},p=0;for(let m=0;m<r.length;m++){let{name:g,fn:y}=r[m],{x:v,y:x,data:I,reset:b}=await y({x:u,y:a,initialPlacement:n,placement:d,strategy:o,middlewareData:h,rects:f,platform:s,elements:{reference:t,floating:e}});u=v!=null?v:u,a=x!=null?x:a,h={...h,[g]:{...h[g],...I}},b&&p<=50&&(p++,typeof b=="object"&&(b.placement&&(d=b.placement),b.rects&&(f=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):b.rects),{x:u,y:a}=at(f,d,c)),m=-1)}return{x:u,y:a,placement:d,strategy:o,middlewareData:h}};function ft(t){return typeof t!="number"?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(t):{top:t,right:t,bottom:t,left:t}}function _(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function Q(t,e){var i;e===void 0&&(e={});let{x:n,y:o,platform:l,rects:s,elements:r,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:a="floating",altBoundary:d=!1,padding:h=0}=e,p=ft(h),m=r[d?a==="floating"?"reference":"floating":a],g=_(await l.getClippingRect({element:(i=await(l.isElement==null?void 0:l.isElement(m)))==null||i?m:m.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(r.floating)),boundary:f,rootBoundary:u,strategy:c})),y=_(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({rect:a==="floating"?{...s.floating,x:n,y:o}:s.reference,offsetParent:await(l.getOffsetParent==null?void 0:l.getOffsetParent(r.floating)),strategy:c}):s[a]);return{top:g.top-y.top+p.top,bottom:y.bottom-g.bottom+p.bottom,left:g.left-y.left+p.left,right:y.right-g.right+p.right}}var St=Math.min,Et=Math.max;function Y(t,e,i){return Et(t,St(e,i))}var G=t=>({name:"arrow",options:t,async fn(e){let{element:i,padding:n=0}=t!=null?t:{},{x:o,y:l,placement:s,rects:r,platform:c}=e;if(i==null)return{};let f=ft(n),u={x:o,y:l},a=D(s),d=B(s),h=J(a),p=await c.getDimensions(i),m=a==="y"?"top":"left",g=a==="y"?"bottom":"right",y=r.reference[h]+r.reference[a]-u[a]-r.floating[h],v=u[a]-r.reference[a],x=await(c.getOffsetParent==null?void 0:c.getOffsetParent(i)),I=x?a==="y"?x.clientHeight||0:x.clientWidth||0:0;I===0&&(I=r.floating[h]);let b=y/2-v/2,L=f[m],F=I-p[h]-f[g],w=I/2-p[h]/2+b,C=Y(L,w,F),T=(d==="start"?f[m]:f[g])>0&&w!==C&&r.reference[h]<=r.floating[h];return{[a]:u[a]-(T?w<L?L-w:F-w:0),data:{[a]:C,centerOffset:w-C}}}}),Pt={left:"right",right:"left",bottom:"top",top:"bottom"};function q(t){return t.replace(/left|right|bottom|top/g,e=>Pt[e])}function At(t,e,i){i===void 0&&(i=!1);let n=B(t),o=D(t),l=J(o),s=o==="x"?n===(i?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[l]>e.floating[l]&&(s=q(s)),{main:s,cross:q(s)}}var Ot={start:"end",end:"start"};function lt(t){return t.replace(/start|end/g,e=>Ot[e])}var Wt=["top","right","bottom","left"],zt=Wt.reduce((t,e)=>t.concat(e,e+"-start",e+"-end"),[]);var Z=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i;let{placement:n,middlewareData:o,rects:l,initialPlacement:s,platform:r,elements:c}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:a,fallbackStrategy:d="bestFit",flipAlignment:h=!0,...p}=t,m=V(n),g=a||(m===s||!h?[q(s)]:function(w){let C=q(w);return[lt(w),C,lt(C)]}(s)),y=[s,...g],v=await Q(e,p),x=[],I=((i=o.flip)==null?void 0:i.overflows)||[];if(f&&x.push(v[m]),u){let{main:w,cross:C}=At(n,l,await(r.isRTL==null?void 0:r.isRTL(c.floating)));x.push(v[w],v[C])}if(I=[...I,{placement:n,overflows:x}],!x.every(w=>w<=0)){var b,L;let w=((b=(L=o.flip)==null?void 0:L.index)!=null?b:0)+1,C=y[w];if(C)return{data:{index:w,overflows:I},reset:{placement:C}};let T="bottom";switch(d){case"bestFit":{var F;let st=(F=I.map(M=>[M,M.overflows.filter(H=>H>0).reduce((H,Rt)=>H+Rt,0)]).sort((M,H)=>M[1]-H[1])[0])==null?void 0:F[0].placement;st&&(T=st);break}case"initialPlacement":T=s}if(n!==T)return{reset:{placement:T}}}return{}}}};var U=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:i,y:n}=e,o=await async function(l,s){let{placement:r,platform:c,elements:f}=l,u=await(c.isRTL==null?void 0:c.isRTL(f.floating)),a=V(r),d=B(r),h=D(r)==="x",p=["left","top"].includes(a)?-1:1,m=u&&h?-1:1,g=typeof s=="function"?s(l):s,{mainAxis:y,crossAxis:v,alignmentAxis:x}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...g};return d&&typeof x=="number"&&(v=d==="end"?-1*x:x),h?{x:v*m,y:y*p}:{x:y*p,y:v*m}}(e,t);return{x:i+o.x,y:n+o.y,data:o}}}};function Lt(t){return t==="x"?"y":"x"}var tt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:i,y:n,placement:o}=e,{mainAxis:l=!0,crossAxis:s=!1,limiter:r={fn:g=>{let{x:y,y:v}=g;return{x:y,y:v}}},...c}=t,f={x:i,y:n},u=await Q(e,c),a=D(V(o)),d=Lt(a),h=f[a],p=f[d];if(l){let g=a==="y"?"bottom":"right";h=Y(h+u[a==="y"?"top":"left"],h,h-u[g])}if(s){let g=d==="y"?"bottom":"right";p=Y(p+u[d==="y"?"top":"left"],p,p-u[g])}let m=r.fn({...e,[a]:h,[d]:p});return{...m,data:{x:m.x-i,y:m.y-n}}}}};function wt(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function P(t){if(t==null)return window;if(!wt(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function O(t){return P(t).getComputedStyle(t)}function W(t){return wt(t)?"":t?(t.nodeName||"").toLowerCase():""}function yt(){let t=navigator.userAgentData;return t!=null&&t.brands?t.brands.map(e=>e.brand+"/"+e.version).join(" "):navigator.userAgent}function E(t){return t instanceof P(t).HTMLElement}function R(t){return t instanceof P(t).Element}function ht(t){return typeof ShadowRoot=="undefined"?!1:t instanceof P(t).ShadowRoot||t instanceof ShadowRoot}function $(t){let{overflow:e,overflowX:i,overflowY:n,display:o}=O(t);return/auto|scroll|overlay|hidden/.test(e+n+i)&&!["inline","contents"].includes(o)}function Tt(t){return["table","td","th"].includes(W(t))}function et(t){let e=/firefox/i.test(yt()),i=O(t),n=i.backdropFilter||i.WebkitBackdropFilter;return i.transform!=="none"||i.perspective!=="none"||!!n&&n!=="none"||e&&i.willChange==="filter"||e&&!!i.filter&&i.filter!=="none"||["transform","perspective"].some(o=>i.willChange.includes(o))||["paint","layout","strict","content"].some(o=>{let l=i.contain;return l!=null&&l.includes(o)})}function xt(){return!/^((?!chrome|android).)*safari/i.test(yt())}function it(t){return["html","body","#document"].includes(W(t))}var ut=Math.min,z=Math.max,j=Math.round;function S(t,e,i){var n,o,l,s;e===void 0&&(e=!1),i===void 0&&(i=!1);let r=t.getBoundingClientRect(),c=1,f=1;e&&E(t)&&(c=t.offsetWidth>0&&j(r.width)/t.offsetWidth||1,f=t.offsetHeight>0&&j(r.height)/t.offsetHeight||1);let u=R(t)?P(t):window,a=!xt()&&i,d=(r.left+(a&&(n=(o=u.visualViewport)==null?void 0:o.offsetLeft)!=null?n:0))/c,h=(r.top+(a&&(l=(s=u.visualViewport)==null?void 0:s.offsetTop)!=null?l:0))/f,p=r.width/c,m=r.height/f;return{width:p,height:m,top:h,right:d+p,bottom:h+m,left:d,x:d,y:h}}function A(t){return(e=t,(e instanceof P(e).Node?t.ownerDocument:t.document)||window.document).documentElement;var e}function K(t){return R(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function vt(t){return S(A(t)).left+K(t).scrollLeft}function Ft(t,e,i){let n=E(e),o=A(e),l=S(t,n&&function(c){let f=S(c);return j(f.width)!==c.offsetWidth||j(f.height)!==c.offsetHeight}(e),i==="fixed"),s={scrollLeft:0,scrollTop:0},r={x:0,y:0};if(n||!n&&i!=="fixed")if((W(e)!=="body"||$(o))&&(s=K(e)),E(e)){let c=S(e,!0);r.x=c.x+e.clientLeft,r.y=c.y+e.clientTop}else o&&(r.x=vt(o));return{x:l.left+s.scrollLeft-r.x,y:l.top+s.scrollTop-r.y,width:l.width,height:l.height}}function N(t){if(W(t)==="html")return t;let e=t.assignedSlot||t.parentNode||(ht(t)?t.host:null)||A(t);return ht(e)?e.host:e}function dt(t){return E(t)&&O(t).position!=="fixed"?t.offsetParent:null}function pt(t){let e=P(t),i=dt(t);for(;i&&Tt(i)&&O(i).position==="static";)i=dt(i);return i&&(W(i)==="html"||W(i)==="body"&&O(i).position==="static"&&!et(i))?e:i||function(n){let o=N(n);for(;E(o)&&!it(o);){if(et(o))return o;o=N(o)}return null}(t)||e}function mt(t){if(E(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=S(t);return{width:e.width,height:e.height}}function bt(t){let e=N(t);return it(e)?t.ownerDocument.body:E(e)&&$(e)?e:bt(e)}function k(t,e){var i;e===void 0&&(e=[]);let n=bt(t),o=n===((i=t.ownerDocument)==null?void 0:i.body),l=P(n),s=o?[l].concat(l.visualViewport||[],$(n)?n:[]):n,r=e.concat(s);return o?r:r.concat(k(s))}function gt(t,e,i){return e==="viewport"?_(function(n,o){let l=P(n),s=A(n),r=l.visualViewport,c=s.clientWidth,f=s.clientHeight,u=0,a=0;if(r){c=r.width,f=r.height;let d=xt();(d||!d&&o==="fixed")&&(u=r.offsetLeft,a=r.offsetTop)}return{width:c,height:f,x:u,y:a}}(t,i)):R(e)?function(n,o){let l=S(n,!1,o==="fixed"),s=l.top+n.clientTop,r=l.left+n.clientLeft;return{top:s,left:r,x:r,y:s,right:r+n.clientWidth,bottom:s+n.clientHeight,width:n.clientWidth,height:n.clientHeight}}(e,i):_(function(n){var o;let l=A(n),s=K(n),r=(o=n.ownerDocument)==null?void 0:o.body,c=z(l.scrollWidth,l.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),f=z(l.scrollHeight,l.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),u=-s.scrollLeft+vt(n),a=-s.scrollTop;return O(r||l).direction==="rtl"&&(u+=z(l.clientWidth,r?r.clientWidth:0)-c),{width:c,height:f,x:u,y:a}}(A(t)))}var Ht={getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:n,strategy:o}=t,l=i==="clippingAncestors"?function(f){let u=k(f).filter(h=>R(h)&&W(h)!=="body"),a=f,d=null;for(;R(a)&&!it(a);){let h=O(a);h.position==="static"&&d&&["absolute","fixed"].includes(d.position)&&!et(a)?u=u.filter(p=>p!==a):d=h,a=N(a)}return u}(e):[].concat(i),s=[...l,n],r=s[0],c=s.reduce((f,u)=>{let a=gt(e,u,o);return f.top=z(a.top,f.top),f.right=ut(a.right,f.right),f.bottom=ut(a.bottom,f.bottom),f.left=z(a.left,f.left),f},gt(e,r,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:i,strategy:n}=t,o=E(i),l=A(i);if(i===l)return e;let s={scrollLeft:0,scrollTop:0},r={x:0,y:0};if((o||!o&&n!=="fixed")&&((W(i)!=="body"||$(l))&&(s=K(i)),E(i))){let c=S(i,!0);r.x=c.x+i.clientLeft,r.y=c.y+i.clientTop}return{...e,x:e.x-s.scrollLeft+r.x,y:e.y-s.scrollTop+r.y}},isElement:R,getDimensions:mt,getOffsetParent:pt,getDocumentElement:A,getElementRects:t=>{let{reference:e,floating:i,strategy:n}=t;return{reference:Ft(e,pt(i),n),floating:{...mt(i),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>O(t).direction==="rtl"};function It(t,e,i,n){n===void 0&&(n={});let{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:s=!0,animationFrame:r=!1}=n,c=o&&!r,f=c||l?[...R(t)?k(t):t.contextElement?k(t.contextElement):[],...k(e)]:[];f.forEach(h=>{c&&h.addEventListener("scroll",i,{passive:!0}),l&&h.addEventListener("resize",i)});let u,a=null;if(s){let h=!0;a=new ResizeObserver(()=>{h||i(),h=!1}),R(t)&&!r&&a.observe(t),R(t)||!t.contextElement||r||a.observe(t.contextElement),a.observe(e)}let d=r?S(t):null;return r&&function h(){let p=S(t);!d||p.x===d.x&&p.y===d.y&&p.width===d.width&&p.height===d.height||i(),d=p,u=requestAnimationFrame(h)}(),i(),()=>{var h;f.forEach(p=>{c&&p.removeEventListener("scroll",i),l&&p.removeEventListener("resize",i)}),(h=a)==null||h.disconnect(),a=null,r&&cancelAnimationFrame(u)}}var Ct=(t,e,i)=>ct(t,e,{platform:Ht,...i});var nt=class{constructor(e){this._middleware=[];this._floating=!1;(this.host=e).addController(this)}hostConnected(){this.host.floating&&this.float(this.host.floating)}hostDisconnected(){this.destroy()}hostUpdated(){this._floating&&this.updatePosition()}hostResized(){this._floating&&this.updatePosition()}float(e){var r;if(this._floating)return;if(this._floating=!0,this._settings=e,this._reference=this.getReference(),this._resizeObserver=new ResizeObserver(()=>this.hostResized()),!this._settings)throw new Error("Floating settings are required");if(!this._reference)throw new Error("Floating reference is required");this.host.classList.add("wk-floating");let{position:i,arrow:n=!1,flip:o=!1,shift:l=!1}=this._settings,s=this.getOffsetSetting();Object.assign(this.host.style,{position:(r=i.strategy)!=null?r:"absolute",top:"0",left:"0",transition:"none",transform:"translate3d(0,0,0)"}),i.inset&&!n?this._middleware.push(U(({rects:c,placement:f})=>{var u,a,d,h,p,m;return f.includes("top")||f.includes("bottom")?{mainAxis:-c.floating.height-((u=s==null?void 0:s.mainAxis)!=null?u:0),crossAxis:(a=s==null?void 0:s.crossAxis)!=null?a:0,alignmentAxis:(d=s==null?void 0:s.alignmentAxis)!=null?d:0}:{mainAxis:-c.floating.width-((h=s==null?void 0:s.mainAxis)!=null?h:0),crossAxis:(p=s==null?void 0:s.crossAxis)!=null?p:0,alignmentAxis:(m=s==null?void 0:s.alignmentAxis)!=null?m:0}})):s&&this._middleware.push(U(s)),o&&this._middleware.push(Z()),l&&this._middleware.push(tt()),n&&(this.arrowEl=document.createElement("div"),this.arrowEl.classList.add("wk-arrow"),this._middleware.push(G({element:this.arrowEl}))),this.cleanupAutoUpdate=It(this._reference,this.host,()=>{this.updatePosition()}),this._resizeObserver.observe(this.host)}getOffsetSetting(){var i,n;let e=(i=this._settings)==null?void 0:i.offset;if(!(!e||typeof e=="boolean"))return typeof e=="number"?{mainAxis:e,alignmentAxis:(n=this._settings)!=null&&n.position.inset?e:null}:e}destroy(){var e,i,n,o;this._floating&&(Object.assign(this.host.style,{position:"",top:"",left:"",transition:"",transform:""}),(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(),this._floating=!1)}updatePosition(){var n;if(!this._reference||!this._settings)return;let{strategy:e="absolute",placement:i="top"}=(n=this._settings.position)!=null?n:{};Ct(this._reference,this.host,{middleware:this._middleware,strategy:e,placement:i}).then(({x:o,y:l,placement:s,middlewareData:r})=>{if(r.arrow&&this.arrowEl){let{x:c,y:f}=r.arrow,u={top:"bottom",right:"left",bottom:"top",left:"right"}[s.split("-")[0]],a={bottom:"0deg",left:"90deg",top:"180deg",right:"270deg"}[s.split("-")[0]];Object.assign(this.arrowEl.style,{left:c!=null?`${c}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",[u]:"-5px",transform:`rotate(${a})`})}Object.assign(this.host.style,{transform:`translate3d(${Math.round(o)}px,${Math.round(l)}px,0)`})})}getReference(){if(!this._settings)return;let e=this._settings.reference;if(typeof e=="string"){if(e==="viewport")return this.createViewportReference();let i=document.querySelector(e);if(!i)throw new Error(`Floating reference element (${e}) not found`);return i}return e.hasOwnProperty("element")?e.element:e}createViewportReference(){return{getBoundingClientRect(){var e,i,n,o;return{x:0,y:0,top:0,left:0,bottom:0,right:0,width:(i=(e=window.visualViewport)==null?void 0:e.width)!=null?i:0,height:(o=(n=window.visualViewport)==null?void 0:n.height)!=null?o:0}}}}};var ot=class{constructor(e,{app:i}){this.product=null,this.app=i,this.state={selectedVariant:null,selectedOptions:{},hasSelection:!1,optionsWithValues:[],hasOnlyDefaultVariant:!1},(this.host=e).addController(this)}setProduct({product:e,selectedVariantId:i=null,autoSelect:n=!1}){!(e!=null&&e.variants)||(this.product=e,this.initFormState({selectedVariantId:i,autoSelect:n}))}initFormState({selectedVariantId:e,autoSelect:i}){if(!this.product)throw new Error("Product not set");let n=this.initializedVariantId!==e?this.product.variants.find(l=>l.id===e):this.state.selectedVariant;this.initializedVariantId=e;let o=this.app.utils.product.getVariantOptions({variant:n});this.updateFormState({options:o,autoSelect:i})}updateFormState({options:e,change:i,autoSelect:n=!1}){if(!this.product)throw new Error("Product not set");let{hasSelection:o,optionsWithValues:l,selectedOptions:s,selectedVariant:r}=this.app.utils.product.getFormState({product:this.product,options:e,change:i,autoSelect:n});this.state.hasSelection=o,this.state.optionsWithValues=l,this.state.selectedOptions=s,this.state.selectedVariant=r,this.host.requestUpdate()}changeOption({input:e,autoSelect:i=!1}){if(!this.product)throw new Error("Product not set");let n=this.getInputOption(e);if(!n)throw new Error("Cannot parse options from input");this.updateFormState({options:this.state.selectedOptions,change:n,autoSelect:i})}async addToCart({wishlistId:e,wishlistItemId:i}){if(!this.state.selectedVariant)throw new Error("No variant selected");let n=this.host.querySelector("form");if(!n)throw new Error("Form not found");n.classList.add("wk-submitting"),await this.app.addToCart({wishlistId:e,wishlistItemId:i,variantId:this.state.selectedVariant.id,quantity:this.app.utils.product.getFormQuantity({form:n})}),n.classList.remove("wk-submitting")}getInputOption(e){if(!this.product)throw new Error("Product not set");return this.app.utils.product.getInputOption({input:e,product:this.product})}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}};import{combineLatest as _t,distinctUntilChanged as Vt,map as X,of as Dt}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";var rt=class{constructor(e){this.stateConfig={loading:"eager"};(this.host=e).addController(this)}get app(){if(!window.WishlistKing)throw new Error("Wishlist King SDK not initialized");return window.WishlistKing}hostConnected(){}hostDisconnected(){}parseStateConfig(e){var i;return{loading:(i=e.loading)!=null?i:"eager",wishlist:this.parseWishlistStateConfig(e),wishlistItem:this.parseWishlistItemStateConfig(e),productInfo:this.parseProductInfoStateConfig(e)}}parseWishlistStateConfig({wishlist:e}){var n;let i=(n=this.host.dataset.wishlistId)!=null?n:"mine";if(!!e)return{params:{wishlistId:i}}}parseWishlistItemStateConfig({wishlistItem:e}){let{wishlistId:i="mine",wishlistItemId:n}=this.host.dataset;if(!(!e||!n))return{params:{wishlistId:i,wishlistItemId:n}}}parseProductInfoStateConfig({productInfo:e}){if(!e)return;let{wishlistId:i="mine",productHandle:n="",productId:o,variantId:l}=this.host.dataset;return{params:{wishlistId:i,productHandle:n,variantId:l?parseInt(l):void 0}}}observe(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e=[];if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.push(this.app.state.observeWishlist({wishlistId:i}).pipe(X(n=>({wishlist:n}))))}if(this.stateConfig.productInfo){let{productHandle:i,variantId:n}=this.stateConfig.productInfo.params;if(!i)throw new Error("Product handle is required");e.push(this.app.state.observeProductInfo({productHandle:i,variantId:n}).pipe(X(o=>({productInfo:o}))))}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.push(this.app.state.observeWishlistItem({wishlistId:i,wishlistItemId:n}).pipe(X(o=>({wishlistItem:o}))))}return e.length||e.push(Dt({})),_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,{})),Vt((i,n)=>JSON.stringify(i)===JSON.stringify(n)))}getFallback(){this.stateConfig=this.parseStateConfig(this.host.getStateConfig());let e={};if(this.stateConfig.wishlist){let{wishlistId:i="mine"}=this.stateConfig.wishlist.params;e.wishlist={id:i,isMine:i==="mine",numItems:0,items:[]}}if(this.stateConfig.productInfo){let{variantId:i=0,productHandle:n}=this.stateConfig.productInfo.params;e.productInfo={productId:0,variantId:i,productHandle:n,inWishlist:!1}}if(this.stateConfig.wishlistItem){let{wishlistId:i,wishlistItemId:n}=this.stateConfig.wishlistItem.params;if(!i)throw new Error("Wishlist id is required");if(!n)throw new Error("Wishlist item id is required");e.wishlistItem={id:n,product:{id:0,handle:"",hidden:!1}}}return e}};export{nt as FloatingUiController,ot as ProductFormController,rt as WishlistStateController}; |
@@ -12,2 +12,2 @@ var V=class{constructor(){this.mapWishlistState=t=>({id:t.id,public_id:t.publicId,is_mine:t.isMine,num_items:t.numItems,items:t.items.map(i=>({id:i.id,product_id:i.productId,variant_id:i.variantId}))});this.mapProductInfo=t=>({product_id:t.productId,variant_id:t.variantId,in_wishlist:t.inWishlist,wishlist_item_id:t.wishlistItemId});this.mapWishlistItem=t=>{var i,r,s;return{id:t.id,loading:!((i=t.product)!=null&&i.url)&&!((r=t.product)!=null&&r.hidden),hidden:!!((s=t.product)!=null&&s.hidden),selected_variant_id:t.variantId,product:t.product}}}camelToSnakeCase(t){return t.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`)}objectToSnakeCase(t){return typeof t!="object"?t:Object.fromEntries(Object.entries(t).map(([i,r])=>{if(typeof r=="function")return[i,null];let s=this.camelToSnakeCase(i);return Array.isArray(r)?[s,r.map(n=>this.objectToSnakeCase(n))]:r&&typeof r=="object"?[s,this.objectToSnakeCase(r)]:[s,r]}))}};var X=function(){return X=Object.assign||function(t){for(var i,r=1,s=arguments.length;r<s;r++){i=arguments[r];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},X.apply(this,arguments)};function O(e,t,i,r){function s(n){return n instanceof i?n:new i(function(o){o(n)})}return new(i||(i=Promise))(function(n,o){function l(p){try{u(r.next(p))}catch(y){o(y)}}function a(p){try{u(r.throw(p))}catch(y){o(y)}}function u(p){p.done?n(p.value):s(p.value).then(l,a)}u((r=r.apply(e,t||[])).next())})}var x=class{liquidMethodMissing(t){}},Mt=Object.prototype.toString,tt=String.prototype.toLowerCase,ft=Object.hasOwnProperty;function L(e){return typeof e=="string"}function q(e){return typeof e=="function"}function At(e){return e&&q(e.then)}function K(e){return e&&q(e.next)&&q(e.throw)&&q(e.return)}function $t(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function c(e){return e=h(e),L(e)?e:E(e)?"":T(e)?e.map(t=>c(t)).join(""):String(e)}function h(e){return e instanceof x&&q(e.valueOf)?e.valueOf():e}function De(e){return typeof e=="number"}function gt(e){return e&&q(e.toLiquid)?gt(e.toLiquid()):e}function E(e){return e==null}function T(e){return Mt.call(e)==="[object Array]"}function Ct(e){return Ve(e)&&Symbol.iterator in e}function le(e,t){e=e||{};for(let i in e)if(ft.call(e,i)&&t(e[i],i,e)===!1)break;return e}function We(e){return e[e.length-1]}function Ve(e){let t=typeof e;return e!==null&&(t==="object"||t==="function")}function mt(e,t,i=1){let r=[];for(let s=e;s<t;s+=i)r.push(s);return r}function ee(e,t,i=" "){return wt(e,t,i,(r,s)=>s+r)}function Ut(e,t,i=" "){return wt(e,t,i,(r,s)=>r+s)}function wt(e,t,i,r){e=String(e);let s=t-e.length;for(;s-- >0;)e=r(e,i);return e}function yt(e){return e}function ue(e){return e.replace(/(\w?)([A-Z])/g,(t,i,r)=>(i?i+"_":"")+r.toLowerCase())}function zt(e){return[...e].some(i=>i>="a"&&i<="z")?e.toUpperCase():e.toLowerCase()}function Dt(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function it(e,t){return e==null&&t==null?0:e==null?1:t==null||(e=tt.call(e),t=tt.call(t),e<t)?-1:e>t?1:0}function k(e){return(...t)=>e(...t.map(h))}function Be(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}var B=class{constructor(t,i,r,s){this.key=t,this.value=i,this.next=r,this.prev=s}},te=class{constructor(t,i=0){this.limit=t,this.size=i,this.cache={},this.head=new B("HEAD",null,null,null),this.tail=new B("TAIL",null,null,null),this.head.next=this.tail,this.tail.prev=this.head}write(t,i){if(this.cache[t])this.cache[t].value=i;else{let r=new B(t,i,this.head.next,this.head);this.head.next.prev=r,this.head.next=r,this.cache[t]=r,this.size++,this.ensureLimit()}}read(t){if(!this.cache[t])return;let{value:i}=this.cache[t];return this.remove(t),this.write(t,i),i}remove(t){let i=this.cache[t];i.prev.next=i.next,i.next.prev=i.prev,delete this.cache[t],this.size--}clear(){this.head.next=this.tail,this.tail.prev=this.head,this.size=0,this.cache={}}ensureLimit(){this.size>this.limit&&this.remove(this.tail.prev.key)}};function Tt(e,t){let i=document.createElement("base");i.href=e;let r=document.getElementsByTagName("head")[0];r.insertBefore(i,r.firstChild);let s=document.createElement("a");s.href=t;let n=s.href;return r.removeChild(i),n}function Wt(e,t,i){return e.length&&We(e)!=="/"&&(e+="/"),Tt(e,t).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,(s,n,o)=>{let l=o.split("/").pop();return/\.\w+$/.test(l)?s:n+o+i})}function Vt(e){return O(this,void 0,void 0,function*(){return new Promise((t,i)=>{let r=new XMLHttpRequest;r.onload=()=>{r.status>=200&&r.status<300?t(r.responseText):i(new Error(r.statusText))},r.onerror=()=>{i(new Error("An error occurred whilst receiving the response."))},r.open("GET",e),r.send()})})}function Bt(e){let t=new XMLHttpRequest;if(t.open("GET",e,!1),t.send(),t.status<200||t.status>=300)throw new Error(t.statusText);return t.responseText}function jt(e){return O(this,void 0,void 0,function*(){return!0})}function Ht(e){return!0}function Qt(e){return Tt(e,".")}var Yt="/",Jt=Object.freeze({__proto__:null,resolve:Wt,readFile:Vt,readFileSync:Bt,exists:jt,existsSync:Ht,dirname:Qt,sep:Yt});function b(e){return e&&q(e.equals)}function N(e,t){return!je(e,t)}function je(e,t){return t.opts.jsTruthy?!e:e===!1||e===void 0||e===null}var rt={"==":(e,t)=>b(e)?e.equals(t):b(t)?t.equals(e):h(e)===h(t),"!=":(e,t)=>b(e)?!e.equals(t):b(t)?!t.equals(e):h(e)!==h(t),">":(e,t)=>b(e)?e.gt(t):b(t)?t.lt(e):h(e)>h(t),"<":(e,t)=>b(e)?e.lt(t):b(t)?t.gt(e):h(e)<h(t),">=":(e,t)=>b(e)?e.geq(t):b(t)?t.leq(e):h(e)>=h(t),"<=":(e,t)=>b(e)?e.leq(t):b(t)?t.geq(e):h(e)<=h(t),contains:(e,t)=>(e=h(e),t=h(t),e&&q(e.indexOf)?e.indexOf(t)>-1:!1),and:(e,t,i)=>N(h(e),i)&&N(h(t),i),or:(e,t,i)=>N(h(e),i)||N(h(t),i)},d=[0,0,0,0,0,0,0,0,0,20,4,4,4,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,2,8,0,0,0,0,8,0,0,0,64,0,65,0,0,33,33,33,33,33,33,33,33,33,33,0,0,2,2,2,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],He=1,ae=4,st=8,bt=16,Gt=32,Zt=64;d[160]=d[5760]=d[6158]=d[8192]=d[8193]=d[8194]=d[8195]=d[8196]=d[8197]=d[8198]=d[8199]=d[8200]=d[8201]=d[8202]=d[8232]=d[8233]=d[8239]=d[8287]=d[12288]=ae;function _t(e){let t={};for(let[i,r]of Object.entries(e)){let s=t;for(let n=0;n<i.length;n++){let o=i[n];s[o]=s[o]||{},n===i.length-1&&d[i.charCodeAt(n)]&He&&(s[o].needBoundary=!0),s=s[o]}s.handler=r,s.end=!0}return t}var Xt={"&":"&","<":"<",">":">",'"':""","'":"'"},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 /> | ||
`&&e.trimLeft++}var ye=class extends _{constructor(t,i){super(f.Number,t.input,t.begin,i?i.end:t.end,t.file),this.whole=t,this.decimal=i}},U=class extends _{constructor(t,i,r,s){super(f.Word,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.content=this.getText()}isNumber(t=!1){let i=t&&d[this.input.charCodeAt(this.begin)]&Zt?this.begin+1:this.begin;for(let r=i;r<this.end;r++)if(!(d[this.input.charCodeAt(r)]&Gt))return!1;return!0}},Te=class extends _{constructor(t,i,r,s){super(f.Literal,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.literal=this.getText()}},ht={"==":1,"!=":1,">":1,"<":1,">=":1,"<=":1,contains:1,and:0,or:0},be=class extends _{constructor(t,i,r,s){super(f.Operator,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.operator=this.getText()}getPrecedence(){let t=this.getText();return t in ht?ht[t]:1}},re=class extends _{constructor(t,i,r){super(f.PropertyAccess,t.input,t.begin,r,t.file),this.variable=t,this.props=i,this.propertyName=this.variable instanceof U?this.variable.getText():It(this.variable.getText())}},_e=class extends _{constructor(t,i,r,s,n,o){super(f.Filter,r,s,n,o),this.name=t,this.args=i}},ke=class extends _{constructor(t,i,r,s,n,o){super(f.Hash,t,i,r,o),this.input=t,this.begin=i,this.end=r,this.name=s,this.value=n,this.file=o}},qe=class extends _{constructor(t,i,r,s){super(f.Quoted,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s}},se=class extends _{constructor(t,i,r,s){super(f.HTML,t,i,r,s),this.input=t,this.begin=i,this.end=r,this.file=s,this.trimLeft=0,this.trimRight=0}getContent(){return this.input.slice(this.begin+this.trimLeft,this.end-this.trimRight)}},Se=class extends _{constructor(t,i,r,s,n,o){super(f.Range,t,i,r,o),this.input=t,this.begin=i,this.end=r,this.lhs=s,this.rhs=n,this.file=o}},ve=class extends Q{constructor(t,i,r,s,n){let{trimOutputLeft:o,trimOutputRight:l,outputDelimiterLeft:a,outputDelimiterRight:u}=s,p=t.slice(i+a.length,r-u.length);super(f.Output,p,t,i,r,o,l,n)}};function xr(e,t,i,r=e.length){let s=i,n=t,o;for(;s[e[n]]&&n<r;)s=s[e[n++]],s.end&&(o=s);return!o||o.needBoundary&&d[e.charCodeAt(n)]&He?-1:n}var Le=class extends Q{constructor(t,i,r,s,n){let o=t.slice(i,r);if(super(f.Tag,o,t,i,r,!1,!1,n),!/\S/.test(o))this.name="",this.args="";else{let l=new m(this.content,s.operatorsTrie);if(this.name=l.readTagName(),!this.name)throw new H("illegal liquid tag syntax",this);l.skipBlank(),this.args=l.remaining()}}},m=class{constructor(t,i=P.operatorsTrie,r=""){this.input=t,this.trie=i,this.file=r,this.p=0,this.rawBeginAt=-1,this.N=t.length}readExpression(){return new we(this.readExpressionTokens())}*readExpressionTokens(){let t=this.readValue();if(!!t)for(yield t;this.p<this.N;){let i=this.readOperator();if(!i)return;let r=this.readValue();if(!r)return;yield i,yield r}}readOperator(){this.skipBlank();let t=xr(this.input,this.p,this.trie);if(t!==-1)return new be(this.input,this.p,this.p=t,this.file)}readFilters(){let t=[];for(;;){let i=this.readFilter();if(!i)return t;t.push(i)}}readFilter(){if(this.skipBlank(),this.end())return null;g(this.peek()==="|",()=>`unexpected token at ${this.snapshot()}`),this.p++;let t=this.p,i=this.readIdentifier();if(!i.size())return null;let r=[];if(this.skipBlank(),this.peek()===":")do{++this.p;let s=this.readFilterArg();s&&r.push(s),this.skipBlank(),g(this.end()||this.peek()===","||this.peek()==="|",()=>`unexpected character ${this.snapshot()}`)}while(this.peek()===",");return new _e(i.getText(),r,this.input,t,this.p,this.file)}readFilterArg(){let t=this.readValue();if(!t)return;if(this.skipBlank(),this.peek()!==":")return t;++this.p;let i=this.readValue();return[t.getText(),i]}readTopLevelTokens(t=P){let i=[];for(;this.p<this.N;){let r=this.readTopLevelToken(t);i.push(r)}return Or(i,t),i}readTopLevelToken(t){let{tagDelimiterLeft:i,outputDelimiterLeft:r}=t;return this.rawBeginAt>-1?this.readEndrawOrRawContent(t):this.match(i)?this.readTagToken(t):this.match(r)?this.readOutputToken(t):this.readHTMLToken([i,r])}readHTMLToken(t){let i=this.p;for(;this.p<this.N&&!t.some(r=>this.match(r));)++this.p;return new se(this.input,i,this.p,this.file)}readTagToken(t=P){let{file:i,input:r}=this,s=this.p;if(this.readToDelimiter(t.tagDelimiterRight)===-1)throw this.mkError(`tag ${this.snapshot(s)} not closed`,s);let n=new ne(r,s,this.p,t,i);return n.name==="raw"&&(this.rawBeginAt=s),n}readToDelimiter(t){for(;this.p<this.N;){if(this.peekType()&st){this.readQuoted();continue}if(++this.p,this.rmatch(t))return this.p}return-1}readOutputToken(t=P){let{file:i,input:r}=this,{outputDelimiterRight:s}=t,n=this.p;if(this.readToDelimiter(s)===-1)throw this.mkError(`output ${this.snapshot(n)} not closed`,n);return new ve(r,n,this.p,t,i)}readEndrawOrRawContent(t){let{tagDelimiterLeft:i,tagDelimiterRight:r}=t,s=this.p,n=this.readTo(i)-i.length;for(;this.p<this.N;){if(this.readIdentifier().getText()!=="endraw"){n=this.readTo(i)-i.length;continue}for(;this.p<=this.N;){if(this.rmatch(r)){let o=this.p;return s===n?(this.rawBeginAt=-1,new ne(this.input,s,o,t,this.file)):(this.p=n,new se(this.input,s,n,this.file))}if(this.rmatch(i))break;this.p++}}throw this.mkError(`raw ${this.snapshot(this.rawBeginAt)} not closed`,s)}readLiquidTagTokens(t=P){let i=[];for(;this.p<this.N;){let r=this.readLiquidTagToken(t);r.name&&i.push(r)}return i}readLiquidTagToken(t){let{file:i,input:r}=this,s=this.p,n=this.N;return this.readToDelimiter(` | ||
`)!==-1&&(n=this.p),new Le(r,s,n,t,i)}mkError(t,i){return new H(t,new U(this.input,i,this.N,this.file))}snapshot(t=this.p){return JSON.stringify(Dt(this.input.slice(t),16))}readWord(){return console.warn("Tokenizer#readWord() will be removed, use #readIdentifier instead"),this.readIdentifier()}readIdentifier(){this.skipBlank();let t=this.p;for(;this.peekType()&He;)++this.p;return new U(this.input,t,this.p,this.file)}readTagName(){return this.skipBlank(),this.input[this.p]==="#"?this.input.slice(this.p,++this.p):this.readIdentifier().getText()}readHashes(t){let i=[];for(;;){let r=this.readHash(t);if(!r)return i;i.push(r)}}readHash(t){this.skipBlank(),this.peek()===","&&++this.p;let i=this.p,r=this.readIdentifier();if(!r.size())return;let s;this.skipBlank();let n=t?"=":":";return this.peek()===n&&(++this.p,s=this.readValue()),new ke(this.input,i,this.p,r,s,this.file)}remaining(){return this.input.slice(this.p)}advance(t=1){this.p+=t}end(){return this.p>=this.N}readTo(t){for(;this.p<this.N;)if(++this.p,this.rmatch(t))return this.p;return-1}readValue(){let t=this.readQuoted()||this.readRange();if(t)return t;if(this.peek()==="["){this.p++;let n=this.readQuoted();return!n||this.peek()!=="]"?void 0:(this.p++,new re(n,[],this.p))}let i=this.readIdentifier();if(!i.size())return;let r=i.isNumber(!0),s=[];for(;;)if(this.peek()==="["){r=!1,this.p++;let n=this.readValue()||new U(this.input,this.p,this.p,this.file);this.readTo("]"),s.push(n)}else if(this.peek()==="."&&this.peek(1)!=="."){this.p++;let n=this.readIdentifier();if(!n.size())break;n.isNumber()||(r=!1),s.push(n)}else break;return!s.length&&xt.hasOwnProperty(i.content)?new Te(this.input,i.begin,i.end,this.file):r?new ye(i,s[0]):new re(i,s,this.p)}readRange(){this.skipBlank();let t=this.p;if(this.peek()!=="(")return;++this.p;let i=this.readValueOrThrow();this.p+=2;let r=this.readValueOrThrow();return++this.p,new Se(this.input,t,this.p,i,r,this.file)}readValueOrThrow(){let t=this.readValue();return g(t,()=>`unexpected token ${this.snapshot()}, value expected`),t}readQuoted(){this.skipBlank();let t=this.p;if(!(this.peekType()&st))return;++this.p;let i=!1;for(;this.p<this.N&&(++this.p,!(this.input[this.p-1]===this.input[t]&&!i));)i?i=!1:this.input[this.p-1]==="\\"&&(i=!0);return new qe(this.input,t,this.p,this.file)}*readFileNameTemplate(t){let{outputDelimiterLeft:i}=t,r=[","," ",i],s=new Set(r);for(;this.p<this.N&&!s.has(this.peek());)yield this.match(i)?this.readOutputToken(t):this.readHTMLToken(r)}match(t){for(let i=0;i<t.length;i++)if(t[i]!==this.input[this.p+i])return!1;return!0}rmatch(t){for(let i=0;i<t.length;i++)if(t[t.length-1-i]!==this.input[this.p-1-i])return!1;return!0}peekType(t=0){return d[this.input.charCodeAt(this.p+t)]}peek(t=0){return this.input[this.p+t]}skipBlank(){for(;this.peekType()&ae;)++this.p}},ne=class extends Q{constructor(t,i,r,s,n){let{trimTagLeft:o,trimTagRight:l,tagDelimiterLeft:a,tagDelimiterRight:u}=s,p=t.slice(i+a.length,r-u.length);super(f.Tag,p,t,i,r,o,l,n);let y=new m(this.content,s.operatorsTrie);if(this.name=y.readTagName(),!this.name)throw new H("illegal tag syntax",this);y.skipBlank(),this.args=y.remaining()}},Oe=class{constructor(t,i){this.handlers={},this.stopRequested=!1,this.tokens=t,this.parseToken=i}on(t,i){return this.handlers[t]=i,this}trigger(t,i){let r=this.handlers[t];return r?(r.call(this,i),!0):!1}start(){this.trigger("start");let t;for(;!this.stopRequested&&(t=this.tokens.shift());){if(this.trigger("token",t)||Je(t)&&this.trigger(`tag:${t.name}`,t))continue;let i=this.parseToken(t,this.tokens);this.trigger("template",i)}return this.stopRequested||this.trigger("end"),this}stop(){return this.stopRequested=!0,this}},I=class{constructor(t,i){this.hash={};let r=new m(t,{});for(let s of r.readHashes(i))this.hash[s.name.content]=s.value}*render(t){let i={};for(let r of Object.keys(this.hash))i[r]=this.hash[r]===void 0?!0:yield w(this.hash[r],t);return i}};function Ir(e){return T(e)}var Y=class{constructor(t,i,r,s){this.name=t,this.impl=i||yt,this.args=r,this.liquid=s}*render(t,i){let r=[];for(let s of this.args)Ir(s)?r.push([s[0],yield w(s[1],i)]):r.push(yield w(s,i));return this.impl.apply({context:i,liquid:this.liquid},[t,...r])}},S=class{constructor(t,i){this.filters=[];let r=new m(t,i.options.operatorsTrie);this.initial=r.readExpression(),this.filters=r.readFilters().map(({name:s,args:n})=>new Y(s,i.filters.get(s),n,i))}*value(t,i){i=i||t.opts.lenientIf&&this.filters.length>0&&this.filters[0].name==="default";let r=yield this.initial.evaluate(t,i);for(let s of this.filters)r=yield s.render(r,t);return r}},Er={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.key=t.readIdentifier().content,t.skipBlank(),g(t.peek()==="=",()=>`illegal token ${e.getText()}`),t.advance(),this.value=new S(t.remaining(),this.liquid)},render:function*(e){e.bottom()[this.key]=yield this.value.value(e,this.liquid.options.lenientIf)}},J=class extends x{constructor(t,i,r){super(),this.i=0,this.length=t,this.name=`${r}-${i}`}next(){this.i++}index0(){return this.i}index(){return this.i+1}first(){return this.i===0}last(){return this.i===this.length-1}rindex(){return this.length-this.i}rindex0(){return this.length-this.i-1}valueOf(){return JSON.stringify(this)}},pt=["offset","limit","reversed"],Pr={type:"block",parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier(),s=i.readIdentifier(),n=i.readValue();g(r.size()&&s.content==="in"&&n,()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=n,this.hash=new I(i.remaining()),this.templates=[],this.elseTemplates=[];let o,l=this.liquid.parser.parseStream(t).on("start",()=>o=this.templates).on("tag:else",()=>o=this.elseTemplates).on("tag:endfor",()=>l.stop()).on("template",a=>o.push(a)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});l.start()},render:function*(e,t){let i=this.liquid.renderer,r=Qe(yield w(this.collection,e));if(!r.length){yield i.renderTemplates(this.elseTemplates,e,t);return}let s="continue-"+this.variable+"-"+this.collection.getText();e.push({continue:e.getRegister(s)});let n=yield this.hash.render(e);e.pop(),r=(this.liquid.options.orderedFilterParameters?Object.keys(n).filter(a=>pt.includes(a)):pt.filter(a=>n[a]!==void 0)).reduce((a,u)=>u==="offset"?Mr(a,n.offset):u==="limit"?Ar(a,n.limit):Nr(a),r),e.setRegister(s,(n.offset||0)+r.length);let l={forloop:new J(r.length,this.collection.getText(),this.variable)};e.push(l);for(let a of r){if(l[this.variable]=a,yield i.renderTemplates(this.templates,e,t),t.break){t.break=!1;break}t.continue=!1,l.forloop.next()}e.pop()}};function Nr(e){return[...e].reverse()}function Mr(e,t){return e.slice(t)}function Ar(e,t){return e.slice(0,t)}var $r={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.variable=Cr(i),g(this.variable,()=>`${e.args} not valid identifier`),this.templates=[];let r=this.liquid.parser.parseStream(t);r.on("tag:endcapture",()=>r.stop()).on("template",s=>this.templates.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),r.start()},render:function*(e){let i=yield this.liquid.renderer.renderTemplates(this.templates,e);e.bottom()[this.variable]=i}};function Cr(e){let t=e.readIdentifier().content;if(t)return t;let i=e.readQuoted();if(i)return Ge(i)}var Ur={parse:function(e,t){this.cond=new S(e.args,this.liquid),this.cases=[],this.elseTemplates=[];let i=[],r=this.liquid.parser.parseStream(t).on("tag:when",s=>{i=[];let n=new m(s.args,this.liquid.options.operatorsTrie);for(;!n.end();){let o=n.readValue();this.cases.push({val:o,templates:i}),n.readTo(",")}}).on("tag:else",()=>i=this.elseTemplates).on("tag:endcase",()=>r.stop()).on("template",s=>i.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});r.start()},render:function*(e,t){let i=this.liquid.renderer,r=h(yield this.cond.value(e,e.opts.lenientIf));for(let s of this.cases)if((yield w(s.val,e,e.opts.lenientIf))===r){yield i.renderTemplates(s.templates,e,t);return}yield i.renderTemplates(this.elseTemplates,e,t)}},zr={parse:function(e,t){let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endcomment"&&i.stop()}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()}},Fe;(function(e){e[e.OUTPUT=0]="OUTPUT",e[e.STORE=1]="STORE"})(Fe||(Fe={}));var j=Fe,Dr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);for(this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;!i.end();){i.skipBlank();let r=i.p,s=i.readIdentifier();if((s.content==="with"||s.content==="for")&&(i.skipBlank(),i.peek()!==":")){let n=i.readValue();if(n){let o=i.p,l=i.readIdentifier(),a;l.content==="as"?a=i.readIdentifier():i.p=o,this[s.content]={value:n,alias:a&&a.content},i.skipBlank(),i.peek()===","&&i.advance();continue}}i.p=r;break}this.hash=new I(i.remaining())},render:function*(e,t){let{liquid:i,hash:r}=this,s=yield this.renderFilePath(this.file,e,i);g(s,()=>`illegal filename "${s}"`);let n=new $({},e.opts,{sync:e.sync,globals:e.globals,strictVariables:e.strictVariables}),o=n.bottom();if(X(o,yield r.render(e)),this.with){let{value:l,alias:a}=this.with;o[a||s]=yield w(l,e)}if(this.for){let{value:l,alias:a}=this.for,u=yield w(l,e);u=Qe(u),o.forloop=new J(u.length,l.getText(),a);for(let p of u){o[a]=p;let y=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(y,n,t),o.forloop.next()}}else{let l=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(l,n,t)}}};function Ze(e,t){if(t.options.dynamicPartials){let s=e.readValue();if(s===void 0)throw new TypeError(`illegal argument "${e.input}"`);if(s.getText()==="none")return null;if(Rt(s)){let n=t.parse(Ge(s));return dt(n)}return s}let i=[...e.readFileNameTemplate(t.options)],r=dt(t.parser.parseTokens(i));return r==="none"?null:r}function dt(e){return e.length===1&&Ye(e[0].token)?e[0].token.getContent():e}function*Xe(e,t,i){return typeof e=="string"?e:Array.isArray(e)?i.renderer.renderTemplates(e,t):yield w(e,t)}var Wr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;let r=i.p;i.readIdentifier().content==="with"?(i.skipBlank(),i.peek()!==":"?this.withVar=i.readValue():i.p=r):i.p=r,this.hash=new I(i.remaining(),this.liquid.options.jekyllInclude)},render:function*(e,t){let{liquid:i,hash:r,withVar:s}=this,{renderer:n}=i,o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=e.saveRegister("blocks","blockMode");e.setRegister("blocks",{}),e.setRegister("blockMode",j.OUTPUT);let a=yield r.render(e);s&&(a[o]=yield w(s,e));let u=yield i._parsePartialFile(o,e.sync,this.currentFile);e.push(e.opts.jekyllInclude?{include:a}:a),yield n.renderTemplates(u,e,t),e.pop(),e.restoreRegister(l)}},Vr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0),t.write(c(--i[this.variable]))}},Br={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie),i=t.readValue();for(t.skipBlank(),this.candidates=[],i&&(t.peek()===":"?(this.group=i,t.advance()):this.candidates.push(i));!t.end();){let r=t.readValue();r&&this.candidates.push(r),t.readTo(",")}g(this.candidates.length,()=>`empty candidates: ${e.getText()}`)},render:function*(e,t){let r=`cycle:${yield w(this.group,e)}:`+this.candidates.join(","),s=e.getRegister("cycle"),n=s[r];n===void 0&&(n=s[r]=0);let o=this.candidates[n];n=(n+1)%this.candidates.length,s[r]=n;let l=yield w(o,e);t.write(l)}},jr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endif",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,templates:s}of this.branches){let n=yield r.value(e,e.opts.lenientIf);if(N(n,e)){yield i.renderTemplates(s,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Hr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0);let r=i[this.variable];i[this.variable]++,t.write(c(r))}},Qr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file,this.hash=new I(i.remaining()),this.tpls=this.liquid.parser.parseTokens(t)},render:function*(e,t){let{liquid:i,hash:r,file:s}=this,{renderer:n}=i;if(s===null){e.setRegister("blockMode",j.OUTPUT),yield n.renderTemplates(this.tpls,e,t);return}let o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=yield i._parseLayoutFile(o,e.sync,this.currentFile);e.setRegister("blockMode",j.STORE);let a=yield n.renderTemplates(this.tpls,e),u=e.getRegister("blocks");u[""]===void 0&&(u[""]=(p,y)=>y.write(a)),e.setRegister("blockMode",j.OUTPUT),e.push(yield r.render(e)),yield n.renderTemplates(l,e,t),e.pop()}},oe=class extends x{constructor(t=()=>""){super(),this.superBlockRender=t}super(){return this.superBlockRender()}},Yr={parse(e,t){let i=/\w+/.exec(e.args);this.block=i?i[0]:"",this.tpls=[],this.liquid.parser.parseStream(t).on("tag:endblock",function(){this.stop()}).on("template",r=>this.tpls.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},*render(e,t){let i=this.getBlockRender(e);e.getRegister("blockMode")===j.STORE?e.getRegister("blocks")[this.block]=i:yield i(new oe,t)},getBlockRender(e){let{liquid:t,tpls:i}=this,r=e.getRegister("blocks")[this.block],s=function*(n,o){e.push({block:n}),yield t.renderer.renderTemplates(i,e,o),e.pop()};return r?(n,o)=>r(new oe(()=>s(n,o)),o):s}},Jr={parse:function(e,t){this.tokens=[];let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endraw"?i.stop():this.tokens.push(r)}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()},render:function(){return this.tokens.map(e=>e.getText()).join("")}},Re=class extends J{constructor(t,i,r,s){super(t,r,s),this.length=t,this.cols=i}row(){return Math.floor(this.i/this.cols)+1}col0(){return this.i%this.cols}col(){return this.col0()+1}col_first(){return this.col0()===0}col_last(){return this.col()===this.cols}},Gr={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier();i.skipBlank();let s=i.readIdentifier();g(s&&s.content==="in",()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=i.readValue(),this.hash=new I(i.remaining()),this.templates=[];let n,o=this.liquid.parser.parseStream(t).on("start",()=>n=this.templates).on("tag:endtablerow",()=>o.stop()).on("template",l=>n.push(l)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});o.start()},render:function*(e,t){let i=Qe(yield w(this.collection,e)),r=yield this.hash.render(e),s=r.offset||0,n=r.limit===void 0?i.length:r.limit;i=i.slice(s,s+n);let o=r.cols||i.length,l=this.liquid.renderer,a=new Re(i.length,o,this.collection.getText(),this.variable),u={tablerowloop:a};e.push(u);for(let p=0;p<i.length;p++,a.next())u[this.variable]=i[p],a.col0()===0&&(a.row()!==1&&t.write("</tr>"),t.write(`<tr class="row${a.row()}">`)),t.write(`<td class="col${a.col()}">`),yield l.renderTemplates(this.templates,e,t),t.write("</td>");i.length&&t.write("</tr>"),e.pop()}},Zr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),test:je,templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),test:N,templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endunless",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,test:s,templates:n}of this.branches){let o=yield r.value(e,e.opts.lenientIf);if(s(o,e)){yield i.renderTemplates(n,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Xr={render:function(e,t){t.break=!0}},Kr={render:function(e,t){t.continue=!0}},es={parse:function(e){this.value=new S(e.args,this.liquid)},render:function*(e,t){let i=yield this.value.value(e,!1);t.write(i)}},ts={parse:function(e){let i=new m(e.args,this.liquid.options.operatorsTrie).readLiquidTagTokens(this.liquid.options);this.tpls=this.liquid.parser.parseTokens(i)},render:function*(e,t){yield this.liquid.renderer.renderTemplates(this.tpls,e,t)}},is={parse:function(e,t){if(e.args.search(/\n\s*[^#\s]/g)!==-1)throw new Error("every line of an inline comment must start with a '#' character")}},rs={assign:Er,for:Pr,capture:$r,case:Ur,comment:zr,include:Wr,render:Dr,decrement:Vr,increment:Hr,cycle:Br,if:jr,layout:Qr,block:Yr,raw:Jr,tablerow:Gr,unless:Zr,break:Xr,continue:Kr,echo:es,liquid:ts,"#":is};var Et=new Map;le(Ot,(e,t)=>{Et.set(ue(t),e)});var P={root:["."],layouts:["."],partials:["."],relativeReference:!0,jekyllInclude:!1,cache:void 0,extname:"",fs:Jt,dynamicPartials:!0,jsTruthy:!1,trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",preserveTimezones:!1,strictFilters:!1,strictVariables:!1,ownPropertyOnly:!1,lenientIf:!1,globals:{},keepOutputType:!1,operators:rt,operatorsTrie:_t(rt)};function ss(e){if(e.hasOwnProperty("operators")&&(e.operatorsTrie=_t(e.operators)),e.hasOwnProperty("root")&&(e.hasOwnProperty("partials")||(e.partials=e.root),e.hasOwnProperty("layouts")||(e.layouts=e.root)),e.hasOwnProperty("cache")){let t;typeof e.cache=="number"?t=e.cache>0?new te(e.cache):void 0:typeof e.cache=="object"?t=e.cache:t=e.cache?new te(1024):void 0,e.cache=t}return e=Object.assign(Object.assign(Object.assign({},P),e.jekyllInclude?{dynamicPartials:!1}:{}),e),!e.fs.dirname&&e.relativeReference&&(console.warn("[LiquidJS] `fs.dirname` is required for relativeReference, set relativeReference to `false` to suppress this warning, or provide implementation for `fs.dirname`"),e.relativeReference=!1),e.root=Z(e.root),e.partials=Z(e.partials),e.layouts=Z(e.layouts),e.outputEscape=e.outputEscape&&ns(e.outputEscape),e}function ns(e){if(L(e)){let t=Et.get(e);return g(q(t),`filter "${e}" not found`),t}else return g(q(e),"`outputEscape` need to be of type string or function"),e}function Z(e){let t=[];return T(e)&&(t=e),L(e)&&(t=[e]),t}var $=class{constructor(t={},i=P,r={}){var s,n;this.scopes=[{}],this.registers={},this.sync=!!r.sync,this.opts=i,this.globals=(s=r.globals)!==null&&s!==void 0?s:i.globals,this.environments=t,this.strictVariables=(n=r.strictVariables)!==null&&n!==void 0?n:this.opts.strictVariables}getRegister(t){return this.registers[t]=this.registers[t]||{}}setRegister(t,i){return this.registers[t]=i}saveRegister(...t){return t.map(i=>[i,this.getRegister(i)])}restoreRegister(t){return t.forEach(([i,r])=>this.setRegister(i,r))}getAll(){return[this.globals,this.environments,...this.scopes].reduce((t,i)=>X(t,i),{})}get(t){return A(this._get(t))}*_get(t){let i=this.findScope(t[0]);return yield this._getFromScope(i,t)}getFromScope(t,i){return A(this._getFromScope(t,i))}*_getFromScope(t,i){L(i)&&(i=i.split("."));for(let r=0;r<i.length;r++)if(t=yield os(t,i[r],this.opts.ownPropertyOnly),E(t)&&this.strictVariables)throw new de(i.slice(0,r+1).join("."));return t}push(t){return this.scopes.push(t)}pop(){return this.scopes.pop()}bottom(){return this.scopes[0]}findScope(t){for(let i=this.scopes.length-1;i>=0;i--){let r=this.scopes[i];if(t in r)return r}return t in this.environments?this.environments:this.globals}};function os(e,t,i){if(E(e))return e;if(e=gt(e),T(e)&&t<0)return e[e.length+ +t];let r=as(e,t,i);return r===void 0&&e instanceof x?e.liquidMethodMissing(t):q(r)?r.call(e):t==="size"?cs(e):t==="first"?ls(e):t==="last"?us(e):r}function as(e,t,i){if(!(i&&!Object.hasOwnProperty.call(e,t)))return e[t]}function ls(e){return T(e)?e[0]:e.first}function us(e){return T(e)?e[e.length-1]:e.last}function cs(e){if(e.hasOwnProperty("size")||e.size!==void 0)return e.size;if(T(e)||L(e))return e.length;if(typeof e=="object")return Object.keys(e).length}var C;(function(e){e.Partials="partials",e.Layouts="layouts",e.Root="root"})(C||(C={}));var xe=class{constructor(t){if(this.options=t,t.relativeReference){let i=t.fs.sep;g(i,"`fs.sep` is required for relative reference");let r=new RegExp(["."+i,".."+i,"./","../"].map(s=>$t(s)).join("|"));this.shouldLoadRelative=s=>r.test(s)}else this.shouldLoadRelative=i=>!1;this.contains=this.options.fs.contains||(()=>!0)}*lookup(t,i,r,s){let{fs:n}=this.options,o=this.options[i];for(let l of this.candidates(t,o,s,i!==C.Root))if(r?n.existsSync(l):yield n.exists(l))return l;throw this.lookupError(t,o)}*candidates(t,i,r,s){let{fs:n,extname:o}=this.options;if(this.shouldLoadRelative(t)&&r){let l=n.resolve(this.dirname(r),t,o);for(let a of i)if(!s||this.contains(a,l)){yield l;break}}for(let l of i){let a=n.resolve(l,t,o);(!s||this.contains(l,a))&&(yield a)}if(n.fallback!==void 0){let l=n.fallback(t);l!==void 0&&(yield l)}}dirname(t){let i=this.options.fs;return g(i.dirname,"`fs.dirname` is required for relative reference"),i.dirname(t)}lookupError(t,i){let r=new Error("ENOENT");return r.message=`ENOENT: Failed to lookup "${t}" in "${i}"`,r.code="ENOENT",r}},Ie=class{constructor(){this.buffer=""}write(t){this.buffer+=c(t)}},Ee=class{constructor(){throw this.buffer="",this.stream=null,new Error("streaming not supported in browser")}},Pe=class{constructor(){this.buffer=""}write(t){t=h(t),typeof t!="string"&&this.buffer===""?this.buffer=t:this.buffer=c(this.buffer)+c(t)}},Ne=class{renderTemplatesToNodeStream(t,i){let r=new Ee;return Promise.resolve().then(()=>M(this.renderTemplates(t,i,r))).then(()=>r.end(),s=>r.error(s)),r.stream}*renderTemplates(t,i,r){r||(r=i.opts.keepOutputType?new Pe:new Ie);for(let s of t)try{let n=yield s.render(i,r);if(n&&r.write(n),r.break||r.continue)break}catch(n){throw ie.is(n)?n:new ie(n,s)}return r.buffer}},G=class{constructor(t){this.token=t}},Me=class extends G{constructor(t,i,r){super(t),this.name=t.name;let s=r.tags.get(t.name);this.impl=Object.create(s),this.impl.liquid=r,this.impl.parse&&this.impl.parse(t,i)}*render(t,i){let r=yield new I(this.token.args).render(t),s=this.impl;if(q(s.render))return yield s.render(t,i,r)}},Ae=class extends G{constructor(t,i){super(t),this.value=new S(t.content,i);let r=this.value.filters,s=i.options.outputEscape;r.length&&r[r.length-1].name==="raw"?r.pop():s&&r.push(new Y(toString.call(s),s,[],i))}*render(t,i){let r=yield this.value.value(t,!1);i.write(r)}},$e=class extends G{constructor(t){super(t),this.str=t.getContent()}*render(t,i){i.write(this.str)}},Ce=class{constructor(t){this.liquid=t,this.cache=this.liquid.options.cache,this.fs=this.liquid.options.fs,this.parseFile=this.cache?this._parseFileCached:this._parseFile,this.loader=new xe(this.liquid.options)}parse(t,i){let s=new m(t,this.liquid.options.operatorsTrie,i).readTopLevelTokens(this.liquid.options);return this.parseTokens(s)}parseTokens(t){let i,r=[];for(;i=t.shift();)r.push(this.parseToken(i,t));return r}parseToken(t,i){try{return Je(t)?new Me(t,i,this.liquid):fr(t)?new Ae(t,this.liquid):new $e(t)}catch(r){throw new he(r,t)}}parseStream(t){return new Oe(t,(i,r)=>this.parseToken(i,r))}*_parseFileCached(t,i,r=C.Root,s){let n=this.cache,o=this.loader.shouldLoadRelative(t)?s+","+t:r+":"+t,l=yield n.read(o);if(l)return l;let a=this._parseFile(t,i,r,s),u=i?yield a:M(a);n.write(o,u);try{return yield u}catch(p){throw n.remove(o),p}}*_parseFile(t,i,r=C.Root,s){let n=yield this.loader.lookup(t,r,i,s);return this.liquid.parse(i?this.fs.readFileSync(n):yield this.fs.readFile(n),n)}},Ue=class{constructor(){this.impls={}}get(t){let i=this.impls[t];return g(i,()=>`tag "${t}" not found`),i}set(t,i){this.impls[t]=i}},ze=class{constructor(t,i){this.strictFilters=t,this.liquid=i,this.impls={}}get(t){let i=this.impls[t];return g(i||!this.strictFilters,()=>`undefined filter: ${t}`),i}set(t,i){this.impls[t]=i}create(t,i){return new Y(t,this.get(t),i,this.liquid)}};var W=class{constructor(t={}){this.options=ss(t),this.parser=new Ce(this),this.renderer=new Ne,this.filters=new ze(this.options.strictFilters,this),this.tags=new Ue,le(rs,(i,r)=>this.registerTag(ue(r),i)),le(Ot,(i,r)=>this.registerFilter(ue(r),i))}parse(t,i){return this.parser.parse(t,i)}_render(t,i,r){let s=new $(i,this.options,r);return this.renderer.renderTemplates(t,s)}render(t,i,r){return O(this,void 0,void 0,function*(){return M(this._render(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}renderSync(t,i,r){return A(this._render(t,i,Object.assign(Object.assign({},r),{sync:!0})))}renderToNodeStream(t,i,r={}){let s=new $(i,this.options,r);return this.renderer.renderTemplatesToNodeStream(t,s)}_parseAndRender(t,i,r){let s=this.parse(t);return this._render(s,i,r)}parseAndRender(t,i,r){return O(this,void 0,void 0,function*(){return M(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}parseAndRenderSync(t,i,r){return A(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!0})))}_parsePartialFile(t,i,r){return this.parser.parseFile(t,i,C.Partials,r)}_parseLayoutFile(t,i,r){return this.parser.parseFile(t,i,C.Layouts,r)}parseFile(t){return O(this,void 0,void 0,function*(){return M(this.parser.parseFile(t,!1))})}parseFileSync(t){return A(this.parser.parseFile(t,!0))}renderFile(t,i,r){return O(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.render(s,i,r)})}renderFileSync(t,i,r){let s=this.parseFileSync(t);return this.renderSync(s,i,r)}renderFileToNodeStream(t,i,r){return O(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.renderToNodeStream(s,i,r)})}_evalValue(t,i){let r=new S(t,this),s=i instanceof $?i:new $(i,this.options);return r.value(s,!1)}evalValue(t,i){return O(this,void 0,void 0,function*(){return M(this._evalValue(t,i))})}evalValueSync(t,i){return A(this._evalValue(t,i))}registerFilter(t,i){this.filters.set(t,i)}registerTag(t,i){this.tags.set(t,i)}plugin(t){return t.call(this,W)}express(){let t=this,i=!0;return function(r,s,n){if(i){i=!1;let o=Z(this.root);t.options.root.unshift(...o),t.options.layouts.unshift(...o),t.options.partials.unshift(...o)}t.renderFile(r,s).then(o=>n(null,o),n)}}};import{html as hs,unsafeStatic as ps}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/static/+esm";var Ke=e=>function(){let t=(a,u)=>e.utils.url.getVariantUrl(a.url,u==null?void 0:u.id),i=(a,...u)=>e.utils.url.getImageUrl(a,Pt(u)),r=(a="")=>e.utils.url.getFileUrl(a),s=(a="",u)=>e.utils.url.getImageUrl({src:e.utils.url.getFileUrl(a.replace(".",`_${u}.`))}),n=a=>e.utils.money.formatMoney(a),o=(a,...u)=>{try{return u.length?this.parseAndRenderSync(e.theme.translate(a),Pt(u)):e.theme.translate(a)}catch(p){return a}},l=(a="")=>a.toLowerCase().trim().replace(/[^a-zA-Z0-9]/g,"-").replace(/[-]{2,}/g,"-");this.registerFilter("variant_url",t),this.registerFilter("image_url",i),this.registerFilter("file_url",r),this.registerFilter("file_img_url",s),this.registerFilter("money",n),this.registerFilter("t",o),this.registerFilter("handle",l),this.registerFilter("handleize",l)},Pt=e=>e.reduce((t,[i,r])=>r?{...t,[i]:r}:t,{});import{WishlistElement as ds}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/wishlist-element.js";var et=class extends ds{constructor(){super();this.initLiquid()}static get properties(){return{}}async initLiquid(){await this.app.load(),this.dataUtil=new V,this.globals={settings:{login_required:this.app.settings.general.wishlistAccessMode!=="UNRESTRICTED"},customer:this.app.customer,shop:{currency:this.app.config.shop.currency,customer_accounts_enabled:this.app.config.shop.customerAccountsEnabled,domain:this.app.config.shop.domain,money_format:this.app.config.shop.moneyFormat,name:this.app.config.shop.name,permanent_domain:this.app.config.shop.permanentDomain},routes:{root_url:this.app.routes.rootUrl,wishlist_url:this.app.routes.wishlistUrl,account_url:this.app.routes.accountUrl,account_login_url:this.app.routes.accountLoginUrl,account_logout_url:this.app.routes.accountLogoutUrl,account_register_url:this.app.routes.accountRegisterUrl,account_addresses_url:this.app.routes.accountAddressesUrl,collections_url:this.app.routes.collectionsUrl,all_products_collection_url:this.app.routes.allProductsCollectionUrl,search_url:this.app.routes.searchUrl,predictive_search_url:this.app.routes.predictiveSearchUrl,cart_url:this.app.routes.cartUrl,cart_add_url:this.app.routes.cartAddUrl,cart_change_url:this.app.routes.cartChangeUrl,cart_clear_url:this.app.routes.cartClearUrl,cart_update_url:this.app.routes.cartUpdateUrl,product_recommendations_url:this.app.routes.productRecommendationsUrl}},this.liquidEngine=new W({cache:!0,relativeReference:!1}),this.liquidEngine.plugin(Ke(this.app)),this.parsedTemplates=this.liquidEngine.parse(this.getLiquidTemplate()),this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),this.parsedTemplates=void 0}getLiquidTemplate(){return""}getLiquidData(){return{}}render(){var l;if(!this.parsedTemplates||!this.liquidEngine||!this.dataUtil)return;let{wishlist:i,wishlistItem:r,productInfo:s}=(l=this.state)!=null?l:{},n={...this.dataUtil.objectToSnakeCase(this.getLiquidData()),wishlist:i?this.dataUtil.mapWishlistState(i):void 0,wishlist_item:r?this.dataUtil.mapWishlistItem(r):void 0,product_info:s?this.dataUtil.mapProductInfo(s):void 0},o=this.liquidEngine.renderSync(this.parsedTemplates,n,{globals:this.globals});return hs`${ps(o)}`}};export{V as LiquidDataUtil,et as LiquidElement,Ke as liquidShopifyFilters}; | ||
`)!==-1&&(n=this.p),new Le(r,s,n,t,i)}mkError(t,i){return new H(t,new U(this.input,i,this.N,this.file))}snapshot(t=this.p){return JSON.stringify(Dt(this.input.slice(t),16))}readWord(){return console.warn("Tokenizer#readWord() will be removed, use #readIdentifier instead"),this.readIdentifier()}readIdentifier(){this.skipBlank();let t=this.p;for(;this.peekType()&He;)++this.p;return new U(this.input,t,this.p,this.file)}readTagName(){return this.skipBlank(),this.input[this.p]==="#"?this.input.slice(this.p,++this.p):this.readIdentifier().getText()}readHashes(t){let i=[];for(;;){let r=this.readHash(t);if(!r)return i;i.push(r)}}readHash(t){this.skipBlank(),this.peek()===","&&++this.p;let i=this.p,r=this.readIdentifier();if(!r.size())return;let s;this.skipBlank();let n=t?"=":":";return this.peek()===n&&(++this.p,s=this.readValue()),new ke(this.input,i,this.p,r,s,this.file)}remaining(){return this.input.slice(this.p)}advance(t=1){this.p+=t}end(){return this.p>=this.N}readTo(t){for(;this.p<this.N;)if(++this.p,this.rmatch(t))return this.p;return-1}readValue(){let t=this.readQuoted()||this.readRange();if(t)return t;if(this.peek()==="["){this.p++;let n=this.readQuoted();return!n||this.peek()!=="]"?void 0:(this.p++,new re(n,[],this.p))}let i=this.readIdentifier();if(!i.size())return;let r=i.isNumber(!0),s=[];for(;;)if(this.peek()==="["){r=!1,this.p++;let n=this.readValue()||new U(this.input,this.p,this.p,this.file);this.readTo("]"),s.push(n)}else if(this.peek()==="."&&this.peek(1)!=="."){this.p++;let n=this.readIdentifier();if(!n.size())break;n.isNumber()||(r=!1),s.push(n)}else break;return!s.length&&xt.hasOwnProperty(i.content)?new Te(this.input,i.begin,i.end,this.file):r?new ye(i,s[0]):new re(i,s,this.p)}readRange(){this.skipBlank();let t=this.p;if(this.peek()!=="(")return;++this.p;let i=this.readValueOrThrow();this.p+=2;let r=this.readValueOrThrow();return++this.p,new Se(this.input,t,this.p,i,r,this.file)}readValueOrThrow(){let t=this.readValue();return g(t,()=>`unexpected token ${this.snapshot()}, value expected`),t}readQuoted(){this.skipBlank();let t=this.p;if(!(this.peekType()&st))return;++this.p;let i=!1;for(;this.p<this.N&&(++this.p,!(this.input[this.p-1]===this.input[t]&&!i));)i?i=!1:this.input[this.p-1]==="\\"&&(i=!0);return new qe(this.input,t,this.p,this.file)}*readFileNameTemplate(t){let{outputDelimiterLeft:i}=t,r=[","," ",i],s=new Set(r);for(;this.p<this.N&&!s.has(this.peek());)yield this.match(i)?this.readOutputToken(t):this.readHTMLToken(r)}match(t){for(let i=0;i<t.length;i++)if(t[i]!==this.input[this.p+i])return!1;return!0}rmatch(t){for(let i=0;i<t.length;i++)if(t[t.length-1-i]!==this.input[this.p-1-i])return!1;return!0}peekType(t=0){return d[this.input.charCodeAt(this.p+t)]}peek(t=0){return this.input[this.p+t]}skipBlank(){for(;this.peekType()&ae;)++this.p}},ne=class extends Q{constructor(t,i,r,s,n){let{trimTagLeft:o,trimTagRight:l,tagDelimiterLeft:a,tagDelimiterRight:u}=s,p=t.slice(i+a.length,r-u.length);super(f.Tag,p,t,i,r,o,l,n);let y=new m(this.content,s.operatorsTrie);if(this.name=y.readTagName(),!this.name)throw new H("illegal tag syntax",this);y.skipBlank(),this.args=y.remaining()}},Oe=class{constructor(t,i){this.handlers={},this.stopRequested=!1,this.tokens=t,this.parseToken=i}on(t,i){return this.handlers[t]=i,this}trigger(t,i){let r=this.handlers[t];return r?(r.call(this,i),!0):!1}start(){this.trigger("start");let t;for(;!this.stopRequested&&(t=this.tokens.shift());){if(this.trigger("token",t)||Je(t)&&this.trigger(`tag:${t.name}`,t))continue;let i=this.parseToken(t,this.tokens);this.trigger("template",i)}return this.stopRequested||this.trigger("end"),this}stop(){return this.stopRequested=!0,this}},I=class{constructor(t,i){this.hash={};let r=new m(t,{});for(let s of r.readHashes(i))this.hash[s.name.content]=s.value}*render(t){let i={};for(let r of Object.keys(this.hash))i[r]=this.hash[r]===void 0?!0:yield w(this.hash[r],t);return i}};function Ir(e){return T(e)}var Y=class{constructor(t,i,r,s){this.name=t,this.impl=i||yt,this.args=r,this.liquid=s}*render(t,i){let r=[];for(let s of this.args)Ir(s)?r.push([s[0],yield w(s[1],i)]):r.push(yield w(s,i));return this.impl.apply({context:i,liquid:this.liquid},[t,...r])}},S=class{constructor(t,i){this.filters=[];let r=new m(t,i.options.operatorsTrie);this.initial=r.readExpression(),this.filters=r.readFilters().map(({name:s,args:n})=>new Y(s,i.filters.get(s),n,i))}*value(t,i){i=i||t.opts.lenientIf&&this.filters.length>0&&this.filters[0].name==="default";let r=yield this.initial.evaluate(t,i);for(let s of this.filters)r=yield s.render(r,t);return r}},Er={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.key=t.readIdentifier().content,t.skipBlank(),g(t.peek()==="=",()=>`illegal token ${e.getText()}`),t.advance(),this.value=new S(t.remaining(),this.liquid)},render:function*(e){e.bottom()[this.key]=yield this.value.value(e,this.liquid.options.lenientIf)}},J=class extends x{constructor(t,i,r){super(),this.i=0,this.length=t,this.name=`${r}-${i}`}next(){this.i++}index0(){return this.i}index(){return this.i+1}first(){return this.i===0}last(){return this.i===this.length-1}rindex(){return this.length-this.i}rindex0(){return this.length-this.i-1}valueOf(){return JSON.stringify(this)}},pt=["offset","limit","reversed"],Pr={type:"block",parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier(),s=i.readIdentifier(),n=i.readValue();g(r.size()&&s.content==="in"&&n,()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=n,this.hash=new I(i.remaining()),this.templates=[],this.elseTemplates=[];let o,l=this.liquid.parser.parseStream(t).on("start",()=>o=this.templates).on("tag:else",()=>o=this.elseTemplates).on("tag:endfor",()=>l.stop()).on("template",a=>o.push(a)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});l.start()},render:function*(e,t){let i=this.liquid.renderer,r=Qe(yield w(this.collection,e));if(!r.length){yield i.renderTemplates(this.elseTemplates,e,t);return}let s="continue-"+this.variable+"-"+this.collection.getText();e.push({continue:e.getRegister(s)});let n=yield this.hash.render(e);e.pop(),r=(this.liquid.options.orderedFilterParameters?Object.keys(n).filter(a=>pt.includes(a)):pt.filter(a=>n[a]!==void 0)).reduce((a,u)=>u==="offset"?Mr(a,n.offset):u==="limit"?Ar(a,n.limit):Nr(a),r),e.setRegister(s,(n.offset||0)+r.length);let l={forloop:new J(r.length,this.collection.getText(),this.variable)};e.push(l);for(let a of r){if(l[this.variable]=a,yield i.renderTemplates(this.templates,e,t),t.break){t.break=!1;break}t.continue=!1,l.forloop.next()}e.pop()}};function Nr(e){return[...e].reverse()}function Mr(e,t){return e.slice(t)}function Ar(e,t){return e.slice(0,t)}var $r={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.variable=Cr(i),g(this.variable,()=>`${e.args} not valid identifier`),this.templates=[];let r=this.liquid.parser.parseStream(t);r.on("tag:endcapture",()=>r.stop()).on("template",s=>this.templates.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),r.start()},render:function*(e){let i=yield this.liquid.renderer.renderTemplates(this.templates,e);e.bottom()[this.variable]=i}};function Cr(e){let t=e.readIdentifier().content;if(t)return t;let i=e.readQuoted();if(i)return Ge(i)}var Ur={parse:function(e,t){this.cond=new S(e.args,this.liquid),this.cases=[],this.elseTemplates=[];let i=[],r=this.liquid.parser.parseStream(t).on("tag:when",s=>{i=[];let n=new m(s.args,this.liquid.options.operatorsTrie);for(;!n.end();){let o=n.readValue();this.cases.push({val:o,templates:i}),n.readTo(",")}}).on("tag:else",()=>i=this.elseTemplates).on("tag:endcase",()=>r.stop()).on("template",s=>i.push(s)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});r.start()},render:function*(e,t){let i=this.liquid.renderer,r=h(yield this.cond.value(e,e.opts.lenientIf));for(let s of this.cases)if((yield w(s.val,e,e.opts.lenientIf))===r){yield i.renderTemplates(s.templates,e,t);return}yield i.renderTemplates(this.elseTemplates,e,t)}},zr={parse:function(e,t){let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endcomment"&&i.stop()}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()}},Fe;(function(e){e[e.OUTPUT=0]="OUTPUT",e[e.STORE=1]="STORE"})(Fe||(Fe={}));var j=Fe,Dr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);for(this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;!i.end();){i.skipBlank();let r=i.p,s=i.readIdentifier();if((s.content==="with"||s.content==="for")&&(i.skipBlank(),i.peek()!==":")){let n=i.readValue();if(n){let o=i.p,l=i.readIdentifier(),a;l.content==="as"?a=i.readIdentifier():i.p=o,this[s.content]={value:n,alias:a&&a.content},i.skipBlank(),i.peek()===","&&i.advance();continue}}i.p=r;break}this.hash=new I(i.remaining())},render:function*(e,t){let{liquid:i,hash:r}=this,s=yield this.renderFilePath(this.file,e,i);g(s,()=>`illegal filename "${s}"`);let n=new $({},e.opts,{sync:e.sync,globals:e.globals,strictVariables:e.strictVariables}),o=n.bottom();if(X(o,yield r.render(e)),this.with){let{value:l,alias:a}=this.with;o[a||s]=yield w(l,e)}if(this.for){let{value:l,alias:a}=this.for,u=yield w(l,e);u=Qe(u),o.forloop=new J(u.length,l.getText(),a);for(let p of u){o[a]=p;let y=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(y,n,t),o.forloop.next()}}else{let l=yield i._parsePartialFile(s,n.sync,this.currentFile);yield i.renderer.renderTemplates(l,n,t)}}};function Ze(e,t){if(t.options.dynamicPartials){let s=e.readValue();if(s===void 0)throw new TypeError(`illegal argument "${e.input}"`);if(s.getText()==="none")return null;if(Rt(s)){let n=t.parse(Ge(s));return dt(n)}return s}let i=[...e.readFileNameTemplate(t.options)],r=dt(t.parser.parseTokens(i));return r==="none"?null:r}function dt(e){return e.length===1&&Ye(e[0].token)?e[0].token.getContent():e}function*Xe(e,t,i){return typeof e=="string"?e:Array.isArray(e)?i.renderer.renderTemplates(e,t):yield w(e,t)}var Wr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e){let t=e.args,i=new m(t,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file;let r=i.p;i.readIdentifier().content==="with"?(i.skipBlank(),i.peek()!==":"?this.withVar=i.readValue():i.p=r):i.p=r,this.hash=new I(i.remaining(),this.liquid.options.jekyllInclude)},render:function*(e,t){let{liquid:i,hash:r,withVar:s}=this,{renderer:n}=i,o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=e.saveRegister("blocks","blockMode");e.setRegister("blocks",{}),e.setRegister("blockMode",j.OUTPUT);let a=yield r.render(e);s&&(a[o]=yield w(s,e));let u=yield i._parsePartialFile(o,e.sync,this.currentFile);e.push(e.opts.jekyllInclude?{include:a}:a),yield n.renderTemplates(u,e,t),e.pop(),e.restoreRegister(l)}},Vr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0),t.write(c(--i[this.variable]))}},Br={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie),i=t.readValue();for(t.skipBlank(),this.candidates=[],i&&(t.peek()===":"?(this.group=i,t.advance()):this.candidates.push(i));!t.end();){let r=t.readValue();r&&this.candidates.push(r),t.readTo(",")}g(this.candidates.length,()=>`empty candidates: ${e.getText()}`)},render:function*(e,t){let r=`cycle:${yield w(this.group,e)}:`+this.candidates.join(","),s=e.getRegister("cycle"),n=s[r];n===void 0&&(n=s[r]=0);let o=this.candidates[n];n=(n+1)%this.candidates.length,s[r]=n;let l=yield w(o,e);t.write(l)}},jr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endif",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,templates:s}of this.branches){let n=yield r.value(e,e.opts.lenientIf);if(N(n,e)){yield i.renderTemplates(s,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Hr={parse:function(e){let t=new m(e.args,this.liquid.options.operatorsTrie);this.variable=t.readIdentifier().content},render:function(e,t){let i=e.environments;De(i[this.variable])||(i[this.variable]=0);let r=i[this.variable];i[this.variable]++,t.write(c(r))}},Qr={parseFilePath:Ze,renderFilePath:Xe,parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie);this.file=this.parseFilePath(i,this.liquid),this.currentFile=e.file,this.hash=new I(i.remaining()),this.tpls=this.liquid.parser.parseTokens(t)},render:function*(e,t){let{liquid:i,hash:r,file:s}=this,{renderer:n}=i;if(s===null){e.setRegister("blockMode",j.OUTPUT),yield n.renderTemplates(this.tpls,e,t);return}let o=yield this.renderFilePath(this.file,e,i);g(o,()=>`illegal filename "${o}"`);let l=yield i._parseLayoutFile(o,e.sync,this.currentFile);e.setRegister("blockMode",j.STORE);let a=yield n.renderTemplates(this.tpls,e),u=e.getRegister("blocks");u[""]===void 0&&(u[""]=(p,y)=>y.write(a)),e.setRegister("blockMode",j.OUTPUT),e.push(yield r.render(e)),yield n.renderTemplates(l,e,t),e.pop()}},oe=class extends x{constructor(t=()=>""){super(),this.superBlockRender=t}super(){return this.superBlockRender()}},Yr={parse(e,t){let i=/\w+/.exec(e.args);this.block=i?i[0]:"",this.tpls=[],this.liquid.parser.parseStream(t).on("tag:endblock",function(){this.stop()}).on("template",r=>this.tpls.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},*render(e,t){let i=this.getBlockRender(e);e.getRegister("blockMode")===j.STORE?e.getRegister("blocks")[this.block]=i:yield i(new oe,t)},getBlockRender(e){let{liquid:t,tpls:i}=this,r=e.getRegister("blocks")[this.block],s=function*(n,o){e.push({block:n}),yield t.renderer.renderTemplates(i,e,o),e.pop()};return r?(n,o)=>r(new oe(()=>s(n,o)),o):s}},Jr={parse:function(e,t){this.tokens=[];let i=this.liquid.parser.parseStream(t);i.on("token",r=>{r.name==="endraw"?i.stop():this.tokens.push(r)}).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}),i.start()},render:function(){return this.tokens.map(e=>e.getText()).join("")}},Re=class extends J{constructor(t,i,r,s){super(t,r,s),this.length=t,this.cols=i}row(){return Math.floor(this.i/this.cols)+1}col0(){return this.i%this.cols}col(){return this.col0()+1}col_first(){return this.col0()===0}col_last(){return this.col()===this.cols}},Gr={parse:function(e,t){let i=new m(e.args,this.liquid.options.operatorsTrie),r=i.readIdentifier();i.skipBlank();let s=i.readIdentifier();g(s&&s.content==="in",()=>`illegal tag: ${e.getText()}`),this.variable=r.content,this.collection=i.readValue(),this.hash=new I(i.remaining()),this.templates=[];let n,o=this.liquid.parser.parseStream(t).on("start",()=>n=this.templates).on("tag:endtablerow",()=>o.stop()).on("template",l=>n.push(l)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)});o.start()},render:function*(e,t){let i=Qe(yield w(this.collection,e)),r=yield this.hash.render(e),s=r.offset||0,n=r.limit===void 0?i.length:r.limit;i=i.slice(s,s+n);let o=r.cols||i.length,l=this.liquid.renderer,a=new Re(i.length,o,this.collection.getText(),this.variable),u={tablerowloop:a};e.push(u);for(let p=0;p<i.length;p++,a.next())u[this.variable]=i[p],a.col0()===0&&(a.row()!==1&&t.write("</tr>"),t.write(`<tr class="row${a.row()}">`)),t.write(`<td class="col${a.col()}">`),yield l.renderTemplates(this.templates,e,t),t.write("</td>");i.length&&t.write("</tr>"),e.pop()}},Zr={parse:function(e,t){this.branches=[],this.elseTemplates=[];let i;this.liquid.parser.parseStream(t).on("start",()=>this.branches.push({predicate:new S(e.args,this.liquid),test:je,templates:i=[]})).on("tag:elsif",r=>this.branches.push({predicate:new S(r.args,this.liquid),test:N,templates:i=[]})).on("tag:else",()=>i=this.elseTemplates).on("tag:endunless",function(){this.stop()}).on("template",r=>i.push(r)).on("end",()=>{throw new Error(`tag ${e.getText()} not closed`)}).start()},render:function*(e,t){let i=this.liquid.renderer;for(let{predicate:r,test:s,templates:n}of this.branches){let o=yield r.value(e,e.opts.lenientIf);if(s(o,e)){yield i.renderTemplates(n,e,t);return}}yield i.renderTemplates(this.elseTemplates,e,t)}},Xr={render:function(e,t){t.break=!0}},Kr={render:function(e,t){t.continue=!0}},es={parse:function(e){this.value=new S(e.args,this.liquid)},render:function*(e,t){let i=yield this.value.value(e,!1);t.write(i)}},ts={parse:function(e){let i=new m(e.args,this.liquid.options.operatorsTrie).readLiquidTagTokens(this.liquid.options);this.tpls=this.liquid.parser.parseTokens(i)},render:function*(e,t){yield this.liquid.renderer.renderTemplates(this.tpls,e,t)}},is={parse:function(e,t){if(e.args.search(/\n\s*[^#\s]/g)!==-1)throw new Error("every line of an inline comment must start with a '#' character")}},rs={assign:Er,for:Pr,capture:$r,case:Ur,comment:zr,include:Wr,render:Dr,decrement:Vr,increment:Hr,cycle:Br,if:jr,layout:Qr,block:Yr,raw:Jr,tablerow:Gr,unless:Zr,break:Xr,continue:Kr,echo:es,liquid:ts,"#":is};var Et=new Map;le(Ot,(e,t)=>{Et.set(ue(t),e)});var P={root:["."],layouts:["."],partials:["."],relativeReference:!0,jekyllInclude:!1,cache:void 0,extname:"",fs:Jt,dynamicPartials:!0,jsTruthy:!1,trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",preserveTimezones:!1,strictFilters:!1,strictVariables:!1,ownPropertyOnly:!1,lenientIf:!1,globals:{},keepOutputType:!1,operators:rt,operatorsTrie:_t(rt)};function ss(e){if(e.hasOwnProperty("operators")&&(e.operatorsTrie=_t(e.operators)),e.hasOwnProperty("root")&&(e.hasOwnProperty("partials")||(e.partials=e.root),e.hasOwnProperty("layouts")||(e.layouts=e.root)),e.hasOwnProperty("cache")){let t;typeof e.cache=="number"?t=e.cache>0?new te(e.cache):void 0:typeof e.cache=="object"?t=e.cache:t=e.cache?new te(1024):void 0,e.cache=t}return e=Object.assign(Object.assign(Object.assign({},P),e.jekyllInclude?{dynamicPartials:!1}:{}),e),!e.fs.dirname&&e.relativeReference&&(console.warn("[LiquidJS] `fs.dirname` is required for relativeReference, set relativeReference to `false` to suppress this warning, or provide implementation for `fs.dirname`"),e.relativeReference=!1),e.root=Z(e.root),e.partials=Z(e.partials),e.layouts=Z(e.layouts),e.outputEscape=e.outputEscape&&ns(e.outputEscape),e}function ns(e){if(L(e)){let t=Et.get(e);return g(q(t),`filter "${e}" not found`),t}else return g(q(e),"`outputEscape` need to be of type string or function"),e}function Z(e){let t=[];return T(e)&&(t=e),L(e)&&(t=[e]),t}var $=class{constructor(t={},i=P,r={}){var s,n;this.scopes=[{}],this.registers={},this.sync=!!r.sync,this.opts=i,this.globals=(s=r.globals)!==null&&s!==void 0?s:i.globals,this.environments=t,this.strictVariables=(n=r.strictVariables)!==null&&n!==void 0?n:this.opts.strictVariables}getRegister(t){return this.registers[t]=this.registers[t]||{}}setRegister(t,i){return this.registers[t]=i}saveRegister(...t){return t.map(i=>[i,this.getRegister(i)])}restoreRegister(t){return t.forEach(([i,r])=>this.setRegister(i,r))}getAll(){return[this.globals,this.environments,...this.scopes].reduce((t,i)=>X(t,i),{})}get(t){return A(this._get(t))}*_get(t){let i=this.findScope(t[0]);return yield this._getFromScope(i,t)}getFromScope(t,i){return A(this._getFromScope(t,i))}*_getFromScope(t,i){L(i)&&(i=i.split("."));for(let r=0;r<i.length;r++)if(t=yield os(t,i[r],this.opts.ownPropertyOnly),E(t)&&this.strictVariables)throw new de(i.slice(0,r+1).join("."));return t}push(t){return this.scopes.push(t)}pop(){return this.scopes.pop()}bottom(){return this.scopes[0]}findScope(t){for(let i=this.scopes.length-1;i>=0;i--){let r=this.scopes[i];if(t in r)return r}return t in this.environments?this.environments:this.globals}};function os(e,t,i){if(E(e))return e;if(e=gt(e),T(e)&&t<0)return e[e.length+ +t];let r=as(e,t,i);return r===void 0&&e instanceof x?e.liquidMethodMissing(t):q(r)?r.call(e):t==="size"?cs(e):t==="first"?ls(e):t==="last"?us(e):r}function as(e,t,i){if(!(i&&!Object.hasOwnProperty.call(e,t)))return e[t]}function ls(e){return T(e)?e[0]:e.first}function us(e){return T(e)?e[e.length-1]:e.last}function cs(e){if(e.hasOwnProperty("size")||e.size!==void 0)return e.size;if(T(e)||L(e))return e.length;if(typeof e=="object")return Object.keys(e).length}var C;(function(e){e.Partials="partials",e.Layouts="layouts",e.Root="root"})(C||(C={}));var xe=class{constructor(t){if(this.options=t,t.relativeReference){let i=t.fs.sep;g(i,"`fs.sep` is required for relative reference");let r=new RegExp(["."+i,".."+i,"./","../"].map(s=>$t(s)).join("|"));this.shouldLoadRelative=s=>r.test(s)}else this.shouldLoadRelative=i=>!1;this.contains=this.options.fs.contains||(()=>!0)}*lookup(t,i,r,s){let{fs:n}=this.options,o=this.options[i];for(let l of this.candidates(t,o,s,i!==C.Root))if(r?n.existsSync(l):yield n.exists(l))return l;throw this.lookupError(t,o)}*candidates(t,i,r,s){let{fs:n,extname:o}=this.options;if(this.shouldLoadRelative(t)&&r){let l=n.resolve(this.dirname(r),t,o);for(let a of i)if(!s||this.contains(a,l)){yield l;break}}for(let l of i){let a=n.resolve(l,t,o);(!s||this.contains(l,a))&&(yield a)}if(n.fallback!==void 0){let l=n.fallback(t);l!==void 0&&(yield l)}}dirname(t){let i=this.options.fs;return g(i.dirname,"`fs.dirname` is required for relative reference"),i.dirname(t)}lookupError(t,i){let r=new Error("ENOENT");return r.message=`ENOENT: Failed to lookup "${t}" in "${i}"`,r.code="ENOENT",r}},Ie=class{constructor(){this.buffer=""}write(t){this.buffer+=c(t)}},Ee=class{constructor(){throw this.buffer="",this.stream=null,new Error("streaming not supported in browser")}},Pe=class{constructor(){this.buffer=""}write(t){t=h(t),typeof t!="string"&&this.buffer===""?this.buffer=t:this.buffer=c(this.buffer)+c(t)}},Ne=class{renderTemplatesToNodeStream(t,i){let r=new Ee;return Promise.resolve().then(()=>M(this.renderTemplates(t,i,r))).then(()=>r.end(),s=>r.error(s)),r.stream}*renderTemplates(t,i,r){r||(r=i.opts.keepOutputType?new Pe:new Ie);for(let s of t)try{let n=yield s.render(i,r);if(n&&r.write(n),r.break||r.continue)break}catch(n){throw ie.is(n)?n:new ie(n,s)}return r.buffer}},G=class{constructor(t){this.token=t}},Me=class extends G{constructor(t,i,r){super(t),this.name=t.name;let s=r.tags.get(t.name);this.impl=Object.create(s),this.impl.liquid=r,this.impl.parse&&this.impl.parse(t,i)}*render(t,i){let r=yield new I(this.token.args).render(t),s=this.impl;if(q(s.render))return yield s.render(t,i,r)}},Ae=class extends G{constructor(t,i){super(t),this.value=new S(t.content,i);let r=this.value.filters,s=i.options.outputEscape;r.length&&r[r.length-1].name==="raw"?r.pop():s&&r.push(new Y(toString.call(s),s,[],i))}*render(t,i){let r=yield this.value.value(t,!1);i.write(r)}},$e=class extends G{constructor(t){super(t),this.str=t.getContent()}*render(t,i){i.write(this.str)}},Ce=class{constructor(t){this.liquid=t,this.cache=this.liquid.options.cache,this.fs=this.liquid.options.fs,this.parseFile=this.cache?this._parseFileCached:this._parseFile,this.loader=new xe(this.liquid.options)}parse(t,i){let s=new m(t,this.liquid.options.operatorsTrie,i).readTopLevelTokens(this.liquid.options);return this.parseTokens(s)}parseTokens(t){let i,r=[];for(;i=t.shift();)r.push(this.parseToken(i,t));return r}parseToken(t,i){try{return Je(t)?new Me(t,i,this.liquid):fr(t)?new Ae(t,this.liquid):new $e(t)}catch(r){throw new he(r,t)}}parseStream(t){return new Oe(t,(i,r)=>this.parseToken(i,r))}*_parseFileCached(t,i,r=C.Root,s){let n=this.cache,o=this.loader.shouldLoadRelative(t)?s+","+t:r+":"+t,l=yield n.read(o);if(l)return l;let a=this._parseFile(t,i,r,s),u=i?yield a:M(a);n.write(o,u);try{return yield u}catch(p){throw n.remove(o),p}}*_parseFile(t,i,r=C.Root,s){let n=yield this.loader.lookup(t,r,i,s);return this.liquid.parse(i?this.fs.readFileSync(n):yield this.fs.readFile(n),n)}},Ue=class{constructor(){this.impls={}}get(t){let i=this.impls[t];return g(i,()=>`tag "${t}" not found`),i}set(t,i){this.impls[t]=i}},ze=class{constructor(t,i){this.strictFilters=t,this.liquid=i,this.impls={}}get(t){let i=this.impls[t];return g(i||!this.strictFilters,()=>`undefined filter: ${t}`),i}set(t,i){this.impls[t]=i}create(t,i){return new Y(t,this.get(t),i,this.liquid)}};var W=class{constructor(t={}){this.options=ss(t),this.parser=new Ce(this),this.renderer=new Ne,this.filters=new ze(this.options.strictFilters,this),this.tags=new Ue,le(rs,(i,r)=>this.registerTag(ue(r),i)),le(Ot,(i,r)=>this.registerFilter(ue(r),i))}parse(t,i){return this.parser.parse(t,i)}_render(t,i,r){let s=new $(i,this.options,r);return this.renderer.renderTemplates(t,s)}render(t,i,r){return O(this,void 0,void 0,function*(){return M(this._render(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}renderSync(t,i,r){return A(this._render(t,i,Object.assign(Object.assign({},r),{sync:!0})))}renderToNodeStream(t,i,r={}){let s=new $(i,this.options,r);return this.renderer.renderTemplatesToNodeStream(t,s)}_parseAndRender(t,i,r){let s=this.parse(t);return this._render(s,i,r)}parseAndRender(t,i,r){return O(this,void 0,void 0,function*(){return M(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!1})))})}parseAndRenderSync(t,i,r){return A(this._parseAndRender(t,i,Object.assign(Object.assign({},r),{sync:!0})))}_parsePartialFile(t,i,r){return this.parser.parseFile(t,i,C.Partials,r)}_parseLayoutFile(t,i,r){return this.parser.parseFile(t,i,C.Layouts,r)}parseFile(t){return O(this,void 0,void 0,function*(){return M(this.parser.parseFile(t,!1))})}parseFileSync(t){return A(this.parser.parseFile(t,!0))}renderFile(t,i,r){return O(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.render(s,i,r)})}renderFileSync(t,i,r){let s=this.parseFileSync(t);return this.renderSync(s,i,r)}renderFileToNodeStream(t,i,r){return O(this,void 0,void 0,function*(){let s=yield this.parseFile(t);return this.renderToNodeStream(s,i,r)})}_evalValue(t,i){let r=new S(t,this),s=i instanceof $?i:new $(i,this.options);return r.value(s,!1)}evalValue(t,i){return O(this,void 0,void 0,function*(){return M(this._evalValue(t,i))})}evalValueSync(t,i){return A(this._evalValue(t,i))}registerFilter(t,i){this.filters.set(t,i)}registerTag(t,i){this.tags.set(t,i)}plugin(t){return t.call(this,W)}express(){let t=this,i=!0;return function(r,s,n){if(i){i=!1;let o=Z(this.root);t.options.root.unshift(...o),t.options.layouts.unshift(...o),t.options.partials.unshift(...o)}t.renderFile(r,s).then(o=>n(null,o),n)}}};import{html as hs,unsafeStatic as ps}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/static/+esm";var Ke=e=>function(){let t=(a,u)=>e.utils.url.getVariantUrl(a.url,u==null?void 0:u.id),i=(a,...u)=>e.utils.url.getImageUrl(a,Pt(u)),r=(a="")=>e.utils.url.getFileUrl(a),s=(a="",u)=>e.utils.url.getImageUrl({src:e.utils.url.getFileUrl(a.replace(".",`_${u}.`))}),n=a=>e.utils.money.formatMoney(a),o=(a,...u)=>{try{return u.length?this.parseAndRenderSync(e.theme.translate(a),Pt(u)):e.theme.translate(a)}catch(p){return a}},l=(a="")=>a.toLowerCase().trim().replace(/[^a-zA-Z0-9]/g,"-").replace(/[-]{2,}/g,"-");this.registerFilter("variant_url",t),this.registerFilter("image_url",i),this.registerFilter("file_url",r),this.registerFilter("file_img_url",s),this.registerFilter("money",n),this.registerFilter("t",o),this.registerFilter("handle",l),this.registerFilter("handleize",l)},Pt=e=>e.reduce((t,[i,r])=>r?{...t,[i]:r}:t,{});import{WishlistElement as ds}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/wishlist-element.js";var et=class extends ds{constructor(){super();this.initLiquid()}static get properties(){return{}}async initLiquid(){await this.app.load(),this.dataUtil=new V,this.globals={settings:{login_required:this.app.settings.general.wishlistAccessMode!=="UNRESTRICTED"},customer:this.app.customer,shop:{currency:this.app.config.shop.currency,customer_accounts_enabled:this.app.config.shop.customerAccountsEnabled,domain:this.app.config.shop.domain,money_format:this.app.config.shop.moneyFormat,name:this.app.config.shop.name,permanent_domain:this.app.config.shop.permanentDomain},routes:{root_url:this.app.routes.rootUrl,wishlist_url:this.app.routes.wishlistUrl,account_url:this.app.routes.accountUrl,account_login_url:this.app.routes.accountLoginUrl,account_logout_url:this.app.routes.accountLogoutUrl,account_register_url:this.app.routes.accountRegisterUrl,account_addresses_url:this.app.routes.accountAddressesUrl,collections_url:this.app.routes.collectionsUrl,all_products_collection_url:this.app.routes.allProductsCollectionUrl,search_url:this.app.routes.searchUrl,predictive_search_url:this.app.routes.predictiveSearchUrl,cart_url:this.app.routes.cartUrl,cart_add_url:this.app.routes.cartAddUrl,cart_change_url:this.app.routes.cartChangeUrl,cart_clear_url:this.app.routes.cartClearUrl,cart_update_url:this.app.routes.cartUpdateUrl,product_recommendations_url:this.app.routes.productRecommendationsUrl}},this.liquidEngine=new W({cache:!0,relativeReference:!1}),this.liquidEngine.plugin(Ke(this.app)),this.parsedTemplates=this.liquidEngine.parse(this.getLiquidTemplate()),this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),this.parsedTemplates=void 0}getLiquidTemplate(){return""}getLiquidData(){return{}}render(){var l;if(!this.parsedTemplates||!this.liquidEngine||!this.dataUtil)return;let{wishlist:i,wishlistItem:r,productInfo:s}=(l=this.state)!=null?l:{},n={...this.dataUtil.objectToSnakeCase(this.getLiquidData()),wishlist:i?this.dataUtil.mapWishlistState(i):void 0,wishlist_item:r?this.dataUtil.mapWishlistItem(r):void 0,product_info:s?this.dataUtil.mapProductInfo(s):void 0},o=this.liquidEngine.renderSync(this.parsedTemplates,n,{globals:this.globals});return hs`${ps(o)}`}};export{V as LiquidDataUtil,et as LiquidElement,Ke as liquidShopifyFilters}; |
{ | ||
"name": "@appmate/wishlist", | ||
"version": "4.17.0", | ||
"version": "4.17.1", | ||
"description": "Wishlist King SDK", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,1 +0,1 @@ | ||
var p=class{constructor(t){this.element=t}replace(t){var e;return(e=this.element)==null||e.replaceWith(t),t}append(t){var e;return(e=this.element)==null||e.append(t),t}prepend(t){var e;return(e=this.element)==null||e.prepend(t),t}insertBefore(t){var e;return(e=this.element)==null||e.before(t),t}insertAfter(t){var e;return(e=this.element)==null||e.after(t),t}closest(t,e=5){if(!this.element)return new p;if(typeof t=="object")return this.searchByStyle(t,this.element,i=>i.parentElement,e);let s=this.element.closest(t);return s?new p(s):new p}find(t){var s;let e=(s=this.element)==null?void 0:s.querySelector(t);return e?new p(e):new p}searchByStyle(t,e,s,i=5){if(i<0||!e)return null;let r=getComputedStyle(e);if(Object.entries(t).every(([l,c])=>r.getPropertyValue(l)===c))return new p(e);let n=s(e);return n?this.searchByStyle(t,n,s,i-1):null}};var u=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((s,i)=>s.concat(Array.from(i.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("data-appmate")).forEach(s=>this.scan(s))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),K(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){this.subscriber.filter(e=>K(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(s&&this.notify(e,t),s&&e.target.firstMatch)return;let i=t.querySelectorAll(e.target.selector);for(let r of i)if(!this.shouldSkip(r,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,r),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("data-appmate")){e.setAttribute("data-appmate","");let s=new p(e);t.callback(s)}}};function K({target:a},t){if(!a.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(a.pageType)?a.pageType:[a.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var G=[{pageType:"product",match:a=>a.includes("/products/")},{pageType:"collection",match:a=>a.includes("/collections/")&&!a.includes("/products/")},{pageType:"account",match:a=>a.includes("/account/")||a.endsWith("/account")},{pageType:"blog",match:a=>a.includes("/blog/")},{pageType:"cart",match:a=>a.includes("/cart/")||a.endsWith("/cart")},{pageType:"wishlist",match:(a,{wishlistUrl:t})=>a.includes(t)},{pageType:"page",match:a=>a.includes("/pages/")},{pageType:"home",match:a=>a.length<4}],m=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of G)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var g=class{constructor(t){var e;this.locale=this.decodeLocale((e=t.locale)!=null?e:{})}decodeHtmlEntities(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(t){let e={};for(let s in t){e[s]={};for(let i in t[s])e[s][i]=this.decodeHtmlEntities(t[s][i])}return e}translate(t,e){var o;let[s,i]=t.split("."),r=(o=this.locale[s])==null?void 0:o[i];return r?e?Object.entries(e).reduce((n,[l,c])=>n.replace(new RegExp(`{{\\s*${l}\\s*}}`,"g"),c),r):r:`translation missing: ${t}`}};var d=class{constructor({rootUrl:t,wishlistUrl:e,locale:s}){this._rootUrl=t,this.route=new m({wishlistUrl:e}),this.observer=new u({routeUtil:this.route}),this.locale=new g({locale:s}),this.watch=this.observer.watch.bind(this.observer)}getPageType(t=window.location.pathname){return this.route.parse(t).pageType}getWishlistId(t){if(!t)return null;t instanceof URL&&(t=t.pathname);let e=t.replace(this._rootUrl,"/").split("/");return e.length===4?e.pop():"mine"}getProductHandle(t){var e;return t?(t instanceof URL&&(t=t.pathname),(e=t.split("/").pop())==null?void 0:e.split("?")[0]):null}getVariantId(t){return t?(t instanceof URL&&(t=t.pathname),new URLSearchParams(t.split("?")[1]).get("variant")):null}translate(t,e){return this.locale.translate(t,e)}createComponent(t,e){var i;let s=document.createElement(t);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,o])=>{!o||(typeof o=="boolean"?s.dataset[r]="":typeof o=="object"?s.dataset[r]=JSON.stringify(o):s.dataset[r]=o)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,o])=>{s[r]=o}),(i=e==null?void 0:e.wrap)!=null&&i.name&&this.createElement(e.wrap.name,e.wrap.props,s),s}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var y=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};var q=class{constructor({dependencies:t=[],...e}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=t=>this.state.promise.addToCart(t);this.addAllToCart=t=>this.state.promise.addAllToCart(t);this.addWishlistItem=t=>this.state.promise.addWishlistItem(t);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=t=>this.state.promise.loadProductInfo(t);this.loadShopifyProduct=t=>this.state.promise.loadShopifyProduct(t);this.loadWishlist=t=>this.state.promise.loadWishlist(t);this.loadWishlistItem=t=>this.state.promise.loadWishlistItem(t);this.publishWishlistEvent=t=>this.state.promise.publishWishlistEvent(t);this.publishWishlistProductEvent=t=>this.state.promise.publishWishlistProductEvent(t);this.removeWishlistItem=t=>this.state.promise.removeWishlistItem(t);this.shareWishlist=t=>this.state.promise.shareWishlist(t);this.updateWishlistItem=t=>this.state.promise.updateWishlistItem(t);this.config=this.parseConfig(e),this.settings=this.parseSettings(e),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.events=new y,this.theme=new d({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,locale:this.config.locale});let{stylesheets:s,scripts:i}=t.reduce(({stylesheets:r,scripts:o},n)=>{let[l]=n.split("?");return l.endsWith(".css")?r.push(n):l.endsWith(".js")&&o.push(n),{stylesheets:r,scripts:o}},{stylesheets:[],scripts:[]});this.initStyles(s),this.initScripts(i),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load()}get loaded(){return this._loaded}get state(){return w(this._state)}get apis(){return w(this._apis)}get utils(){return w(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var t;return!!((t=this.customer)!=null&&t.id)}getSessionId(){let t=window.localStorage.getItem("wk_session_id");if(t)return t;let e=window.localStorage.getItem("appmate-session");if(e)try{let s=JSON.parse(e).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(t){var e;return window.localStorage.setItem("wk_session_id",t),(e=this._apis)==null||e.tracking.setSessionId(t),t}async load(){return this._loadPromise?this._loadPromise:this._loadPromise=(async()=>{let[{WishlistState:t},{ShopifyApi:e,WishlistApi:s,TrackingApi:i},{MoneyUtil:r,UrlUtil:o,ProductUtil:n}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:o,ProductUtil:n}),this.initApis({WishlistApi:s,ShopifyApi:e,TrackingApi:i}),this.initState({WishlistState:t}),this.initUrlChangeEvents(),this.trackCurrentPage(),this.hasSession||(await this.state.promise.clearCache(),this.events.once("wk:app:init-sid",l=>{var c,h;(c=l.data)!=null&&c.sessionId&&this.setSessionId((h=l.data)==null?void 0:h.sessionId)})),this._loaded=!0,this.events.publish({name:"wk:app:load:success"})})()}initUtils({UrlUtil:t,MoneyUtil:e,ProductUtil:s}){let i=this.config.shop.domain,r=this.config.products.fallbackImage,o=this.config.shop.moneyFormat;this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:i,placeholderImageUrl:r,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:o,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),product:new s}}initApis({WishlistApi:t,ShopifyApi:e,TrackingApi:s}){var i,r;this._apis={wishlist:new t({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(i=this.config.customer.id)!=null?i:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType()}),shopify:new e({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils})}async initStyles(t){if(!(t!=null&&t.length)){this.onStylesLoaded();return}try{await Promise.all(t.map(e=>new Promise((s,i)=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onload=s,r.onerror=i,document.head.appendChild(r)}))),this.onStylesLoaded()}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-styles:error"})}}async initScripts(t){if(!(t!=null&&t.length)){this.events.publish({name:"wk:app:load-scripts:success"});return}try{await Promise.all(t.map(e=>import(e))),this.events.publish({name:"wk:app:load-scripts:success"})}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-scripts:error"})}}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let e=this.theme.getWishlistId(window.location.pathname);e&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:e})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUrlChangeEvents(){let t=history.replaceState,e=({productHandle:s,variantId:i})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:i}})};history.replaceState=(...s)=>{let i=`${window.location.protocol}//${window.location.host}`,r=typeof s[2]=="string"?new URL(s[2],i):s[2],o=t.apply(history,s);if(!r)return o;let n=this.theme.getProductHandle(r),l=r.searchParams.get("variant");if(!n||!l)return o;e({productHandle:n,variantId:parseInt(l)})}}parseConfig({config:t,locale:e}){var s,i,r,o,n,l,c,h;return{customer:{id:t.customerId?t.customerId:null,email:(s=t.customerEmail)!=null?s:""},shop:{name:(i=t.shopName)!=null?i:"",domain:(r=t.shopDomain)!=null?r:"",permanentDomain:(o=t.shopPermanentDomain)!=null?o:"",currency:(n=t.shopCurrency)!=null?n:"",moneyFormat:(l=t.shopMoneyFormat)!=null?l:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(c=t.apiHost)!=null?c:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(h=t.productFallbackImage)!=null?h:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:e}}parseSettings({settings:t}){var e,s,i,r,o,n,l,c,h,f,b,U,S,v,P,E,W,T,A,k,I,R,L,C,_,N,H,M,O,x,D,B,j,V,F;return{general:{appLoading:(s=(e=t==null?void 0:t.general)==null?void 0:e.appLoading)!=null?s:"LAZY",wishlistAccessMode:this.config.customer.id?"UNRESTRICTED":(r=(i=t==null?void 0:t.general)==null?void 0:i.wishlistAccessMode)!=null?r:"UNRESTRICTED",wishlistMode:(n=(o=t==null?void 0:t.general)==null?void 0:o.wishlistMode)!=null?n:"PRODUCT",wishlistPath:(c=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?c:"/apps/wishlist"},wishlistPage:{addToCartMode:(f=(h=t==null?void 0:t.wishlistPage)==null?void 0:h.addToCartMode)!=null?f:"KEEP_IN_WISHLIST",buyButtonType:(U=(b=t==null?void 0:t.wishlistPage)==null?void 0:b.buyButtonType)!=null?U:"ADD_TO_CART",shareButtonType:(v=(S=t==null?void 0:t.wishlistPage)==null?void 0:S.shareButtonType)!=null?v:"WEB_SHARE",loginHintType:(E=(P=t==null?void 0:t.wishlistPage)==null?void 0:P.loginHintType)!=null?E:"CALLOUT",variantAutoSelectMode:(T=(W=t==null?void 0:t.wishlistPage)==null?void 0:W.variantAutoSelectMode)!=null?T:"NEVER",variantSelctorType:(k=(A=t==null?void 0:t.wishlistPage)==null?void 0:A.variantSelctorType)!=null?k:"DROPDOWNS"},integrations:{googleAnalytics:{enabled:(L=(R=(I=t.integrations)==null?void 0:I.googleAnalytics)==null?void 0:R.enabled)!=null?L:!1,tracker:(N=(_=(C=t.integrations)==null?void 0:C.googleAnalytics)==null?void 0:_.tracker)!=null?N:""},klaviyo:{enabled:(O=(M=(H=t.integrations)==null?void 0:H.klaviyo)==null?void 0:M.enabled)!=null?O:!1},metaPixel:{enabled:(B=(D=(x=t.integrations)==null?void 0:x.metaPixel)==null?void 0:D.enabled)!=null?B:!1},wishlistAnalytics:{enabled:(F=(V=(j=t.integrations)==null?void 0:j.metaPixel)==null?void 0:V.enabled)!=null?F:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4}}}}parseRoutes(){let t=this.config.routes.rootUrl;return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+this.settings.general.wishlistPath.split("/").filter(e=>!!e).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}},w=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{q as WishlistApp}; | ||
var p=class{constructor(t){this.element=t}replace(t){var e;return(e=this.element)==null||e.replaceWith(t),t}append(t){var e;return(e=this.element)==null||e.append(t),t}prepend(t){var e;return(e=this.element)==null||e.prepend(t),t}insertBefore(t){var e;return(e=this.element)==null||e.before(t),t}insertAfter(t){var e;return(e=this.element)==null||e.after(t),t}closest(t,e=5){if(!this.element)return new p;if(typeof t=="object")return this.searchByStyle(t,this.element,i=>i.parentElement,e);let s=this.element.closest(t);return s?new p(s):new p}find(t){var s;let e=(s=this.element)==null?void 0:s.querySelector(t);return e?new p(e):new p}searchByStyle(t,e,s,i=5){if(i<0||!e)return null;let r=getComputedStyle(e);if(Object.entries(t).every(([l,c])=>r.getPropertyValue(l)===c))return new p(e);let n=s(e);return n?this.searchByStyle(t,n,s,i-1):null}};var u=class{constructor({routeUtil:t}){this.subscriber=[],this.routeUtil=t,this.observer=new MutationObserver(e=>{e.reduce((s,i)=>s.concat(Array.from(i.addedNodes)),[]).filter(s=>s instanceof Element&&!s.hasAttribute("data-appmate")).forEach(s=>this.scan(s))}),this.observer.observe(document.body,{subtree:!0,childList:!0,attributes:!1})}watch(t,e){let s={target:t,callback:e};this.subscriber.push(s),K(s,this.routeUtil.parse(window.location.pathname))&&this.scan(document.body)}shouldSkip(t,{skipHidden:e}){return e&&t instanceof HTMLElement?t.offsetParent===null:!1}scan(t){this.subscriber.filter(e=>K(e,this.routeUtil.parse(window.location.pathname))).forEach(e=>{let s=t.matches(e.target.selector)&&!this.shouldSkip(t,{skipHidden:!!e.target.skipHidden});if(s&&this.notify(e,t),s&&e.target.firstMatch)return;let i=t.querySelectorAll(e.target.selector);for(let r of i)if(!this.shouldSkip(r,{skipHidden:!!e.target.skipHidden})&&(this.notify(e,r),e.target.firstMatch))break})}notify(t,e){if(!e.hasAttribute("data-appmate")){e.setAttribute("data-appmate","");let s=new p(e);t.callback(s)}}};function K({target:a},t){if(!a.pageType)return!0;if(!t.pageType)return!1;let e=Array.isArray(a.pageType)?a.pageType:[a.pageType];return e.includes("all")?!0:e.includes(t.pageType)}var G=[{pageType:"product",match:a=>a.includes("/products/")},{pageType:"collection",match:a=>a.includes("/collections/")&&!a.includes("/products/")},{pageType:"account",match:a=>a.includes("/account/")||a.endsWith("/account")},{pageType:"blog",match:a=>a.includes("/blog/")},{pageType:"cart",match:a=>a.includes("/cart/")||a.endsWith("/cart")},{pageType:"wishlist",match:(a,{wishlistUrl:t})=>a.includes(t)},{pageType:"page",match:a=>a.includes("/pages/")},{pageType:"home",match:a=>a.length<4}],m=class{constructor({wishlistUrl:t}){this.wishlistUrl=t}parse(t){for(let e of G)if(e.match(t,{wishlistUrl:this.wishlistUrl}))return{pageType:e.pageType};return{pageType:void 0}}};var g=class{constructor(t){var e;this.locale=this.decodeLocale((e=t.locale)!=null?e:{})}decodeHtmlEntities(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}decodeLocale(t){let e={};for(let s in t){e[s]={};for(let i in t[s])e[s][i]=this.decodeHtmlEntities(t[s][i])}return e}translate(t,e){var o;let[s,i]=t.split("."),r=(o=this.locale[s])==null?void 0:o[i];return r?e?Object.entries(e).reduce((n,[l,c])=>n.replace(new RegExp(`{{\\s*${l}\\s*}}`,"g"),c),r):r:`translation missing: ${t}`}};var d=class{constructor({rootUrl:t,wishlistUrl:e,locale:s}){this._rootUrl=t,this.route=new m({wishlistUrl:e}),this.observer=new u({routeUtil:this.route}),this.locale=new g({locale:s}),this.watch=this.observer.watch.bind(this.observer)}getPageType(t=window.location.pathname){return this.route.parse(t).pageType}getWishlistId(t){if(!t)return null;t instanceof URL&&(t=t.pathname);let e=t.replace(this._rootUrl,"/").split("/");return e.length===4?e.pop():"mine"}getProductHandle(t){var e;return t?(t instanceof URL&&(t=t.pathname),(e=t.split("/").pop())==null?void 0:e.split("?")[0]):null}getVariantId(t){return t?(t instanceof URL&&(t=t.pathname),new URLSearchParams(t.split("?")[1]).get("variant")):null}translate(t,e){return this.locale.translate(t,e)}createComponent(t,e){var i;let s=document.createElement(t);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,o])=>{!o||(typeof o=="boolean"?s.dataset[r]="":typeof o=="object"?s.dataset[r]=JSON.stringify(o):s.dataset[r]=o)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,o])=>{s[r]=o}),(i=e==null?void 0:e.wrap)!=null&&i.name&&this.createElement(e.wrap.name,e.wrap.props,s),s}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var y=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};var q=class{constructor({dependencies:t=[],...e}){this.stylesLoaded=!1;this._loaded=!1;this.addToCart=t=>this.state.promise.addToCart(t);this.addAllToCart=t=>this.state.promise.addAllToCart(t);this.addWishlistItem=t=>this.state.promise.addWishlistItem(t);this.clearWishlist=()=>this.state.promise.clearWishlist();this.loadProductInfo=t=>this.state.promise.loadProductInfo(t);this.loadShopifyProduct=t=>this.state.promise.loadShopifyProduct(t);this.loadWishlist=t=>this.state.promise.loadWishlist(t);this.loadWishlistItem=t=>this.state.promise.loadWishlistItem(t);this.publishWishlistEvent=t=>this.state.promise.publishWishlistEvent(t);this.publishWishlistProductEvent=t=>this.state.promise.publishWishlistProductEvent(t);this.removeWishlistItem=t=>this.state.promise.removeWishlistItem(t);this.shareWishlist=t=>this.state.promise.shareWishlist(t);this.updateWishlistItem=t=>this.state.promise.updateWishlistItem(t);this.config=this.parseConfig(e),this.settings=this.parseSettings(e),this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.events=new y,this.theme=new d({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,locale:this.config.locale});let{stylesheets:s,scripts:i}=t.reduce(({stylesheets:r,scripts:o},n)=>{let[l]=n.split("?");return l.endsWith(".css")?r.push(n):l.endsWith(".js")&&o.push(n),{stylesheets:r,scripts:o}},{stylesheets:[],scripts:[]});this.initStyles(s),this.initScripts(i),(this.hasSession||this.settings.general.appLoading==="EAGER")&&this.load()}get loaded(){return this._loaded}get state(){return w(this._state)}get apis(){return w(this._apis)}get utils(){return w(this._utils)}get hasSession(){return!!this.getSessionId()||!!this.customer}get isLoggedIn(){var t;return!!((t=this.customer)!=null&&t.id)}getSessionId(){let t=window.localStorage.getItem("wk_session_id");if(t)return t;let e=window.localStorage.getItem("appmate-session");if(e)try{let s=JSON.parse(e).state.sid;return this.setSessionId(s)}catch(s){console.error(s)}}setSessionId(t){var e;return window.localStorage.setItem("wk_session_id",t),(e=this._apis)==null||e.tracking.setSessionId(t),t}async load(){return this._loadPromise?this._loadPromise:this._loadPromise=(async()=>{let[{WishlistState:t},{ShopifyApi:e,WishlistApi:s,TrackingApi:i},{MoneyUtil:r,UrlUtil:o,ProductUtil:n}]=await Promise.all([import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/utils.js")]);this.initUtils({MoneyUtil:r,UrlUtil:o,ProductUtil:n}),this.initApis({WishlistApi:s,ShopifyApi:e,TrackingApi:i}),this.initState({WishlistState:t}),this.initUrlChangeEvents(),this.trackCurrentPage(),this.hasSession||(await this.state.promise.clearCache(),this.events.once("wk:app:init-sid",l=>{var c,h;(c=l.data)!=null&&c.sessionId&&this.setSessionId((h=l.data)==null?void 0:h.sessionId)})),this._loaded=!0,this.events.publish({name:"wk:app:load:success"})})()}initUtils({UrlUtil:t,MoneyUtil:e,ProductUtil:s}){let i=this.config.shop.domain,r=this.config.products.fallbackImage,o=this.config.shop.moneyFormat;this._utils={url:new t({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:i,placeholderImageUrl:r,fileUrl:this.routes.fileUrl}),money:new e({moneyFormat:o,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),product:new s}}initApis({WishlistApi:t,ShopifyApi:e,TrackingApi:s}){var i,r;this._apis={wishlist:new t({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(i=this.config.customer.id)!=null?i:void 0,sessionId:this.getSessionId(),trackingSource:this.theme.getPageType()}),shopify:new e({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils})}async initStyles(t){if(!(t!=null&&t.length)){this.onStylesLoaded();return}try{await Promise.all(t.map(e=>new Promise((s,i)=>{let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onload=s,r.onerror=i,document.head.appendChild(r)}))),this.onStylesLoaded()}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-styles:error"})}}async initScripts(t){if(!(t!=null&&t.length)){this.events.publish({name:"wk:app:load-scripts:success"});return}try{await Promise.all(t.map(e=>import(e))),this.events.publish({name:"wk:app:load-scripts:success"})}catch(e){console.warn(e),this.events.publish({name:"wk:app:load-scripts:error"})}}trackCurrentPage(){if(this.theme.getPageType()==="wishlist"){let e=this.theme.getWishlistId(window.location.pathname);e&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:e})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUrlChangeEvents(){let t=history.replaceState,e=({productHandle:s,variantId:i})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:s,variantId:i}})};history.replaceState=(...s)=>{let i=`${window.location.protocol}//${window.location.host}`,r=typeof s[2]=="string"?new URL(s[2],i):s[2],o=t.apply(history,s);if(!r)return o;let n=this.theme.getProductHandle(r),l=r.searchParams.get("variant");if(!n||!l)return o;e({productHandle:n,variantId:parseInt(l)})}}parseConfig({config:t,locale:e}){var s,i,r,o,n,l,c,h;return{customer:{id:t.customerId?t.customerId:null,email:(s=t.customerEmail)!=null?s:""},shop:{name:(i=t.shopName)!=null?i:"",domain:(r=t.shopDomain)!=null?r:"",permanentDomain:(o=t.shopPermanentDomain)!=null?o:"",currency:(n=t.shopCurrency)!=null?n:"",moneyFormat:(l=t.shopMoneyFormat)!=null?l:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(c=t.apiHost)!=null?c:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(h=t.productFallbackImage)!=null?h:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:e}}parseSettings({settings:t}){var e,s,i,r,o,n,l,c,h,f,b,U,S,v,P,E,W,T,A,k,I,R,L,C,_,N,H,M,O,x,D,B,j,V,F;return{general:{appLoading:(s=(e=t==null?void 0:t.general)==null?void 0:e.appLoading)!=null?s:"LAZY",wishlistAccessMode:this.config.customer.id?"UNRESTRICTED":(r=(i=t==null?void 0:t.general)==null?void 0:i.wishlistAccessMode)!=null?r:"UNRESTRICTED",wishlistMode:(n=(o=t==null?void 0:t.general)==null?void 0:o.wishlistMode)!=null?n:"PRODUCT",wishlistPath:(c=(l=t==null?void 0:t.general)==null?void 0:l.wishlistPath)!=null?c:"/apps/wishlist"},wishlistPage:{addToCartMode:(f=(h=t==null?void 0:t.wishlistPage)==null?void 0:h.addToCartMode)!=null?f:"KEEP_IN_WISHLIST",buyButtonType:(U=(b=t==null?void 0:t.wishlistPage)==null?void 0:b.buyButtonType)!=null?U:"ADD_TO_CART",shareButtonType:(v=(S=t==null?void 0:t.wishlistPage)==null?void 0:S.shareButtonType)!=null?v:"WEB_SHARE",loginHintType:(E=(P=t==null?void 0:t.wishlistPage)==null?void 0:P.loginHintType)!=null?E:"CALLOUT",variantAutoSelectMode:(T=(W=t==null?void 0:t.wishlistPage)==null?void 0:W.variantAutoSelectMode)!=null?T:"NEVER",variantSelctorType:(k=(A=t==null?void 0:t.wishlistPage)==null?void 0:A.variantSelctorType)!=null?k:"DROPDOWNS"},integrations:{googleAnalytics:{enabled:(L=(R=(I=t.integrations)==null?void 0:I.googleAnalytics)==null?void 0:R.enabled)!=null?L:!1,tracker:(N=(_=(C=t.integrations)==null?void 0:C.googleAnalytics)==null?void 0:_.tracker)!=null?N:""},klaviyo:{enabled:(O=(M=(H=t.integrations)==null?void 0:H.klaviyo)==null?void 0:M.enabled)!=null?O:!1},metaPixel:{enabled:(B=(D=(x=t.integrations)==null?void 0:x.metaPixel)==null?void 0:D.enabled)!=null?B:!1},wishlistAnalytics:{enabled:(F=(V=(j=t.integrations)==null?void 0:j.metaPixel)==null?void 0:V.enabled)!=null?F:!0}},cache:{wishlist:{ttl:6e4},wishlistItem:{ttl:6e4},productInfo:{ttl:6e4},product:{ttl:3e4}}}}parseRoutes(){let t=this.config.routes.rootUrl;return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+this.settings.general.wishlistPath.split("/").filter(e=>!!e).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}},w=a=>{if(!a)throw new Error("Wishlist app not loaded.");return a};export{q as WishlistApp}; |
@@ -1,1 +0,1 @@ | ||
var g=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=(c,a,t,e)=>{for(var i=e>1?void 0:e?m(a,t):a,s=c.length-1,n;s>=0;s--)(n=c[s])&&(i=(e?n(a,t,i):n(i))||i);return e&&i&&g(a,t,i),i};import{delayWhen as y,from as p,fromEvent as h,isObservable as v,map as S,of as u}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{filter as d,first as C,switchMap as E,tap as f}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{state as b}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{LitElement as P}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{unsafeHTML as k}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/unsafe-html.js/+esm";import{WishlistStateController as M}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.0/controllers.js";var o=class extends P{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.list=[];this.stateCtrl=new M(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}appReadyCallback(){}beforeNextState(t){}async connect(){if(!this.connected){if(!this.app.stylesLoaded){h(document,"wk:app:load-styles:success").pipe(C()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:load:success",()=>{this.init()}))}}getStateConfig(){return{}}getTranslation(t,e){if(!this.app.theme)return t;let i=this.app.theme.translate(t,e);return t.endsWith("_html")?k(i):i}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,i){var s;return this.app.utils.url.getImageUrl((s=e==null?void 0:e.featured_image)!=null&&s.src?e:t,i)}formatMoney(t){return this.app.utils.money.formatMoney(t)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var e;this.state={...(e=this.state)!=null?e:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML="",this.initEvents(),this.connect()}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(i=>i()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.updateState(t)}),this.appReadyCallback()}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([i,s])=>{let[n,r]=i.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(i=>i.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:i}){return h(this,t).pipe(f(s=>{this.eventPending&&s.preventDefault()}),d(()=>!this.eventPending),f(()=>{this.eventPending=!0}),S(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),d(({target:s})=>!!s),y(s=>this.app.hasSession?u(s):p(this.app.load())),E(({event:s,target:n})=>{let r=e.bind(this)(s,n);return v(r)?r:typeof(r==null?void 0:r.then)=="function"?p(r):u(r)})).subscribe(()=>{this.eventPending=!1})}};l([b()],o.prototype,"state",2),l([b()],o.prototype,"list",2);export{o as WishlistElement}; | ||
var g=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=(c,a,t,e)=>{for(var i=e>1?void 0:e?m(a,t):a,s=c.length-1,n;s>=0;s--)(n=c[s])&&(i=(e?n(a,t,i):n(i))||i);return e&&i&&g(a,t,i),i};import{delayWhen as y,from as p,fromEvent as h,isObservable as v,map as S,of as u}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{filter as d,first as C,switchMap as E,tap as f}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.7/+esm";import{state as b}from"https://cdn.jsdelivr.net/npm/@lit/reactive-element@1.4.2/decorators/+esm";import{LitElement as P}from"https://cdn.jsdelivr.net/npm/lit-element@3.2.2/lit-element/+esm";import{unsafeHTML as k}from"https://cdn.jsdelivr.net/npm/lit-html@2.4.0/directives/unsafe-html.js/+esm";import{WishlistStateController as M}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.17.1/controllers.js";var o=class extends P{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.state={};this.list=[];this.stateCtrl=new M(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}appReadyCallback(){}beforeNextState(t){}async connect(){if(!this.connected){if(!this.app.stylesLoaded){h(document,"wk:app:load-styles:success").pipe(C()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:load:success",()=>{this.init()}))}}getStateConfig(){return{}}getTranslation(t,e){if(!this.app.theme)return t;let i=this.app.theme.translate(t,e);return t.endsWith("_html")?k(i):i}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,i){var s;return this.app.utils.url.getImageUrl((s=e==null?void 0:e.featured_image)!=null&&s.src?e:t,i)}formatMoney(t){return this.app.utils.money.formatMoney(t)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var e;this.state={...(e=this.state)!=null?e:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML&&this.firstConnect&&(this.innerHTML=""),this.initEvents(),this.connect(),this.firstConnect=!1}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(i=>i()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.updateState(t)}),this.appReadyCallback()}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([i,s])=>{let[n,r]=i.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(i=>i.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:i}){return h(this,t).pipe(f(s=>{this.eventPending&&s.preventDefault()}),d(()=>!this.eventPending),f(()=>{this.eventPending=!0}),S(s=>s.target instanceof HTMLElement?{event:s,target:i?s.target.closest(i):s.currentTarget}:{event:s,target:null}),d(({target:s})=>!!s),y(s=>this.app.hasSession?u(s):p(this.app.load())),E(({event:s,target:n})=>{let r=e.bind(this)(s,n);return v(r)?r:typeof(r==null?void 0:r.then)=="function"?p(r):u(r)})).subscribe(()=>{this.eventPending=!1})}};l([b()],o.prototype,"state",2),l([b()],o.prototype,"list",2);export{o as WishlistElement}; |
Sorry, the diff of this file is not supported yet
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 5 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 5 instances in 1 package
237816
1059