@appmate/wishlist
Advanced tools
Comparing version 4.19.4 to 4.19.5
@@ -1,1 +0,1 @@ | ||
import{LitElement as r,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{FloatingUiController as s}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/controllers.js";var t=class extends r{constructor(){super(...arguments);this.text="";this.layout="text-only";this.parentheses=!1;this.floatingUi=new s(this)}render(){var e,l;let o=(e=this.layout)!=null&&e.includes("text")?this.text:"",n=["wk-badge",!!this.parentheses&&"wk-parentheses",((l=this.layout)==null?void 0:l.includes("pill"))&&"wk-pill"].filter(i=>!!i).join(" ");return a`<span class=${n}>${o}</span>`}createRenderRoot(){return this}};t.properties={text:{type:String},layout:{type:String},parentheses:{type:Boolean},floating:{type:Object}};customElements.get("wk-badge")||customElements.define("wk-badge",t);export{t as Badge}; | ||
import{LitElement as r,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{FloatingUiController as s}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/controllers.js";var t=class extends r{constructor(){super(...arguments);this.text="";this.layout="text-only";this.parentheses=!1;this.floatingUi=new s(this)}render(){var e,l;let o=(e=this.layout)!=null&&e.includes("text")?this.text:"",n=["wk-badge",!!this.parentheses&&"wk-parentheses",((l=this.layout)==null?void 0:l.includes("pill"))&&"wk-pill"].filter(i=>!!i).join(" ");return a`<span class=${n}>${o}</span>`}createRenderRoot(){return this}};t.properties={text:{type:String},layout:{type:String},parentheses:{type:Boolean},floating:{type:Object}};customElements.get("wk-badge")||customElements.define("wk-badge",t);export{t as Badge}; |
@@ -1,2 +0,2 @@ | ||
import{LitElement as b,html as l}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";var g=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function h(i,e){return!!(i===e||g(i)&&g(e))}function f(i,e){if(i.length!==e.length)return!1;for(var t=0;t<i.length;t++)if(!h(i[t],e[t]))return!1;return!0}function d(i,e){e===void 0&&(e=f);var t=null;function n(){for(var a=[],r=0;r<arguments.length;r++)a[r]=arguments[r];if(t&&t.lastThis===this&&e(a,t.lastArgs))return t.lastResult;var o=i.apply(this,a);return t={lastResult:o,lastArgs:a,lastThis:this},o}return n.clear=function(){t=null},n}import{FloatingUiController as c}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/components/icon.js";var s=class extends b{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 c(this);this.getBadgeFloating=d((t,n)=>{if(!(!t||!n))return{...t,reference:n}})}render(){var a,r,o;let n=["wk-button",`wk-align-${(a=this.alignment)!=null?a:"center"}`,this.selected&&"wk-selected",this.outline&&"wk-outline",this.fullWidth&&"wk-full-width"].filter(u=>!!u).join(" ");return this.href?l` | ||
import{LitElement as b,html as l}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";var g=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function h(i,e){return!!(i===e||g(i)&&g(e))}function f(i,e){if(i.length!==e.length)return!1;for(var t=0;t<i.length;t++)if(!h(i[t],e[t]))return!1;return!0}function d(i,e){e===void 0&&(e=f);var t=null;function n(){for(var a=[],r=0;r<arguments.length;r++)a[r]=arguments[r];if(t&&t.lastThis===this&&e(a,t.lastArgs))return t.lastResult;var o=i.apply(this,a);return t={lastResult:o,lastArgs:a,lastThis:this},o}return n.clear=function(){t=null},n}import{FloatingUiController as c}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/controllers.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/components/badge.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/components/icon.js";var s=class extends b{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 c(this);this.getBadgeFloating=d((t,n)=>{if(!(!t||!n))return{...t,reference:n}})}render(){var a,r,o;let n=["wk-button",`wk-align-${(a=this.alignment)!=null?a:"center"}`,this.selected&&"wk-selected",this.outline&&"wk-outline",this.fullWidth&&"wk-full-width"].filter(u=>!!u).join(" ");return this.href?l` | ||
<a href=${this.href} aria-label=${(r=this.hint)!=null?r:""} class=${n}> | ||
@@ -3,0 +3,0 @@ ${this.renderIcon()}${this.renderText()}${this.renderBadge()} |
@@ -1,2 +0,2 @@ | ||
import{LitElement as r,html as n}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{Icon as a}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/components/icon.js";var o=class extends r{constructor(){super();this.icon="caret"}render(){if(!this.option)return;let e=`options[${this.option.name}]`,t=`${this.id}-select`;return n` | ||
import{LitElement as r,html as n}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{Icon as a}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/components/icon.js";var o=class extends r{constructor(){super();this.icon="caret"}render(){if(!this.option)return;let e=`options[${this.option.name}]`,t=`${this.id}-select`;return n` | ||
<div class="wk-option-select"> | ||
@@ -3,0 +3,0 @@ <label class="wk-label" for=${t}>${this.option.name}</label> |
@@ -1,2 +0,2 @@ | ||
import{LitElement as s,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{FloatingUiController as r}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/controllers.js";var n=class extends s{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new r(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}render(){var e;let t=["wk-popover",this.transition?`wk-${this.transition}`:"",this.elementClass].filter(i=>!!i).join(" ");return o` | ||
import{LitElement as s,html as o}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{FloatingUiController as r}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/controllers.js";var n=class extends s{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1;this.floatingUi=new r(this)}get added(){return!!this.parentElement}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}render(){var e;let t=["wk-popover",this.transition?`wk-${this.transition}`:"",this.elementClass].filter(i=>!!i).join(" ");return o` | ||
<div class=${t}> | ||
@@ -3,0 +3,0 @@ <div class="wk-text">${this.getText()}</div> |
@@ -1,2 +0,2 @@ | ||
import{LitElement as s,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{Swatch as i}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/components/swatch.js";var t=class extends s{constructor(){super();this.label="";this.name="";this.options=[]}connectedCallback(){super.connectedCallback();for(let e of this.children)e instanceof i&&this.options.push(e);this.innerHTML=""}render(){return a` | ||
import{LitElement as s,html as a}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{Swatch as i}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/components/swatch.js";var t=class extends s{constructor(){super();this.label="";this.name="";this.options=[]}connectedCallback(){super.connectedCallback();for(let e of this.children)e instanceof i&&this.options.push(e);this.innerHTML=""}render(){return a` | ||
<div class="wk-swatches"> | ||
@@ -3,0 +3,0 @@ <fieldset class="wk-fieldset"> |
{ | ||
"name": "@appmate/wishlist", | ||
"version": "4.19.4", | ||
"version": "4.19.5", | ||
"description": "Wishlist King SDK", | ||
@@ -5,0 +5,0 @@ "main": "wishlist-app.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}createHeadlessComponent(t,e){var r;let s=e.host.element?e.host.element:e.host;if(!s)throw new Error("Headless host is undefined");e.dataset&&Object.entries(e.dataset).forEach(([o,n])=>{n&&(typeof n=="boolean"?s.dataset[o]="":typeof n=="object"?s.dataset[o]=JSON.stringify(n):s.dataset[o]=n)});let i=(r=window.headlessElements)==null?void 0:r.store.get(t);if(!i)throw new Error(`Headless element not found: ${t}`);return new i(s)}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var y=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};window.headlessElements||(window.headlessElements={store:new Map,define(a,t){var e;(e=window.headlessElements)==null||e.store.set(a,t)}});var 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.19.4/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/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(),productMetafields:this.config.products.metafields}),shopify:new e({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils})}async initStyles(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",metafields:!!t.productMetafields},locale:e}}parseSettings({settings:t}){var e,s,i,r,o,n,l,c,h,f,b,E,U,T,S,W,v,P,A,I,k,R,L,H,M,C,_,N,O,x,D,j,B,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:(E=(b=t==null?void 0:t.wishlistPage)==null?void 0:b.buyButtonType)!=null?E:"ADD_TO_CART",shareButtonType:(T=(U=t==null?void 0:t.wishlistPage)==null?void 0:U.shareButtonType)!=null?T:"WEB_SHARE",loginHintType:(W=(S=t==null?void 0:t.wishlistPage)==null?void 0:S.loginHintType)!=null?W:"CALLOUT",variantAutoSelectMode:(P=(v=t==null?void 0:t.wishlistPage)==null?void 0:v.variantAutoSelectMode)!=null?P:"NEVER",variantSelctorType:(I=(A=t==null?void 0:t.wishlistPage)==null?void 0:A.variantSelctorType)!=null?I:"DROPDOWNS"},integrations:{googleAnalytics:{enabled:(L=(R=(k=t.integrations)==null?void 0:k.googleAnalytics)==null?void 0:R.enabled)!=null?L:!1,tracker:(C=(M=(H=t.integrations)==null?void 0:H.googleAnalytics)==null?void 0:M.tracker)!=null?C:""},klaviyo:{enabled:(O=(N=(_=t.integrations)==null?void 0:_.klaviyo)==null?void 0:N.enabled)!=null?O:!1},metaPixel:{enabled:(j=(D=(x=t.integrations)==null?void 0:x.metaPixel)==null?void 0:D.enabled)!=null?j:!1},wishlistAnalytics:{enabled:(F=(V=(B=t.integrations)==null?void 0:B.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}createHeadlessComponent(t,e){var r;let s=e.host.element?e.host.element:e.host;if(!s)throw new Error("Headless host is undefined");e.dataset&&Object.entries(e.dataset).forEach(([o,n])=>{n&&(typeof n=="boolean"?s.dataset[o]="":typeof n=="object"?s.dataset[o]=JSON.stringify(n):s.dataset[o]=n)});let i=(r=window.headlessElements)==null?void 0:r.store.get(t);if(!i)throw new Error(`Headless element not found: ${t}`);return new i(s)}createElement(t,e={},...s){let i=Object.assign(document.createElement(t),e);return s&&i.append(...s),i}};var y=class{constructor(){this.dispatcher=document}publish(t){this.dispatcher.dispatchEvent(new CustomEvent(t.name,{detail:t,bubbles:!1,cancelable:!1}))}once(t,e){let s=i=>{this.dispatcher.removeEventListener(t,s),e(i)};this.subscribe(t,s)}subscribe(t,e){this.dispatcher.addEventListener(t,s=>{let i=s;e({name:i.type,data:i.detail.data})})}subscribeMany(t){return Object.entries(t).map(([e,s])=>this.subscribe(e,s))}};window.headlessElements||(window.headlessElements={store:new Map,define(a,t){var e;(e=window.headlessElements)==null||e.store.set(a,t)}});var 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.19.5/state.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/api.js"),import("https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/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(),productMetafields:this.config.products.metafields}),shopify:new e({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new s({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:this.getSessionId(),utils:this.utils,theme:this.theme,settings:this.settings})}}initState({WishlistState:t}){this._state=new t({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils})}async initStyles(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",metafields:!!t.productMetafields},locale:e}}parseSettings({settings:t}){var e,s,i,r,o,n,l,c,h,f,b,E,U,T,S,W,v,P,A,I,k,R,L,H,M,C,_,N,O,x,D,j,B,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:(E=(b=t==null?void 0:t.wishlistPage)==null?void 0:b.buyButtonType)!=null?E:"ADD_TO_CART",shareButtonType:(T=(U=t==null?void 0:t.wishlistPage)==null?void 0:U.shareButtonType)!=null?T:"WEB_SHARE",loginHintType:(W=(S=t==null?void 0:t.wishlistPage)==null?void 0:S.loginHintType)!=null?W:"CALLOUT",variantAutoSelectMode:(P=(v=t==null?void 0:t.wishlistPage)==null?void 0:v.variantAutoSelectMode)!=null?P:"NEVER",variantSelctorType:(I=(A=t==null?void 0:t.wishlistPage)==null?void 0:A.variantSelctorType)!=null?I:"DROPDOWNS"},integrations:{googleAnalytics:{enabled:(L=(R=(k=t.integrations)==null?void 0:k.googleAnalytics)==null?void 0:R.enabled)!=null?L:!1,tracker:(C=(M=(H=t.integrations)==null?void 0:H.googleAnalytics)==null?void 0:M.tracker)!=null?C:""},klaviyo:{enabled:(O=(N=(_=t.integrations)==null?void 0:_.klaviyo)==null?void 0:N.enabled)!=null?O:!1},metaPixel:{enabled:(j=(D=(x=t.integrations)==null?void 0:x.metaPixel)==null?void 0:D.enabled)!=null?j:!1},wishlistAnalytics:{enabled:(F=(V=(B=t.integrations)==null?void 0:B.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 @@ | ||
import{delayWhen as p,from as a,fromEvent as o,isObservable as u,map as f,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as b,switchMap as v,tap as c}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/controllers.js";var d=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new g(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),this.initEvents(),this.connect(),this.firstConnect=!1}get app(){return this.stateCtrl.app}static get observedAttributes(){return["data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}addController(t){}appReadyCallback(){this.host.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var i,n,e;if(this.host.dataset.productHandle===((i=t.data)==null?void 0:i.productHandle)&&((n=t.data)!=null&&n.variantId)){let r=this.productInfo?this.productInfo.wishlistItemId:void 0,s=this.productInfo?this.productInfo.variantId:void 0;r&&!s&&this.app.updateWishlistItem({wishlistItemId:r,changes:{variantId:(e=t.data)==null?void 0:e.variantId}}),this.host.dataset.variantId=t.data.variantId.toString(),this.connected&&this.initState()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){o(document,"wk:app:load-styles:success").pipe(b()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:load:success",()=>{this.init()}))}}getStateConfig(){return{}}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}updated(){}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo,this.updated()}createRenderRoot(){return this}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var i;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(i=this.observer)==null||i.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([n,e])=>{let[r,s]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:r,selector:s,handler:e})});this.cleanupMethods.push(()=>i.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:n}){return o(this.host,t).pipe(c(e=>{this.eventPending&&e.preventDefault()}),l(()=>!this.eventPending),c(()=>{this.eventPending=!0}),f(e=>e.target instanceof HTMLElement?{event:e,target:n?e.target.closest(n):e.currentTarget}:{event:e,target:null}),l(({target:e})=>!!e),p(e=>this.app.hasSession?h(e):a(this.app.load())),v(({event:e,target:r})=>{let s=i.bind(this)(e,r);return u(s)?s:typeof(s==null?void 0:s.then)=="function"?a(s):h(s)})).subscribe(()=>{this.eventPending=!1})}};export{d as WishlistElementHeadless}; | ||
import{delayWhen as p,from as a,fromEvent as o,isObservable as u,map as f,of as h}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as l,first as b,switchMap as v,tap as c}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{WishlistStateController as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/controllers.js";var d=class{constructor(t){this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;if(this.host=t,this.stateCtrl=new g(this),this.host.hasAttribute("wk-headless"))throw new Error("Headless component already initialised");this.host.setAttribute("wk-headless",""),this.initEvents(),this.connect(),this.firstConnect=!1}get app(){return this.stateCtrl.app}static get observedAttributes(){return["data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}addController(t){}appReadyCallback(){this.host.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var i,n,e;if(this.host.dataset.productHandle===((i=t.data)==null?void 0:i.productHandle)&&((n=t.data)!=null&&n.variantId)){let r=this.productInfo?this.productInfo.wishlistItemId:void 0,s=this.productInfo?this.productInfo.variantId:void 0;r&&!s&&this.app.updateWishlistItem({wishlistItemId:r,changes:{variantId:(e=t.data)==null?void 0:e.variantId}}),this.host.dataset.variantId=t.data.variantId.toString(),this.connected&&this.initState()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){o(document,"wk:app:load-styles:success").pipe(b()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(await this.app.load(),this.init()):(this.initFallbackState(),this.app.events.once("wk:app:load:success",()=>{this.init()}))}}getStateConfig(){return{}}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}updated(){}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo,this.updated()}createRenderRoot(){return this}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(i=>this.handleIntersect(i),{root:null,rootMargin:"0px"}),this.host.setAttribute("wk-lazy",""),this.observer.observe(this.host)}handleIntersect([t]){var i;t.isIntersecting&&(this.host.removeAttribute("wk-lazy"),(i=this.observer)==null||i.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let i=Object.entries(t).map(([n,e])=>{let[r,s]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:r,selector:s,handler:e})});this.cleanupMethods.push(()=>i.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:i,selector:n}){return o(this.host,t).pipe(c(e=>{this.eventPending&&e.preventDefault()}),l(()=>!this.eventPending),c(()=>{this.eventPending=!0}),f(e=>e.target instanceof HTMLElement?{event:e,target:n?e.target.closest(n):e.currentTarget}:{event:e,target:null}),l(({target:e})=>!!e),p(e=>this.app.hasSession?h(e):a(this.app.load())),v(({event:e,target:r})=>{let s=i.bind(this)(e,r);return u(s)?s:typeof(s==null?void 0:s.then)=="function"?a(s):h(s)})).subscribe(()=>{this.eventPending=!1})}};export{d as WishlistElementHeadless}; |
@@ -1,1 +0,1 @@ | ||
import{delayWhen as u,from as o,fromEvent as c,isObservable as f,map as b,of as l}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as h,first as g,switchMap as m,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as y}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{unsafeHTML as d}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{WishlistStateController as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.4/controllers.js";var a=class extends y{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.stateCtrl=new v(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.connected&&this.app.loaded&&this.initState()}appReadyCallback(){this.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var e,s,i;if(this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((s=t.data)!=null&&s.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,r=this.productInfo?this.productInfo.variantId:void 0;n&&!r&&this.app.updateWishlistItem({wishlistItemId:n,changes:{variantId:(i=t.data)==null?void 0:i.variantId}}),this.dataset.variantId=t.data.variantId.toString()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){c(document,"wk:app:load-styles:success").pipe(g()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(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 s=this.app.theme.translate(t,e);return t.endsWith("_html")?d(s):s}formatMoney(t){return this.app.utils.money.formatMoney(t)}renderMoney(t){return d(this.app.utils.money.formatMoney(t))}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,s){var i;return this.app.utils.url.getImageUrl((i=e==null?void 0:e.featured_image)!=null&&i.src?e:t,s)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML&&this.firstConnect&&(this.innerHTML=""),this.initEvents(),this.connect(),this.firstConnect=!1}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(s=>s()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(s=>this.handleIntersect(s),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([s,i])=>{let[n,r]=s.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:i})});this.cleanupMethods.push(()=>e.forEach(s=>s.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:s}){return c(this,t).pipe(p(i=>{this.eventPending&&i.preventDefault()}),h(()=>!this.eventPending),p(()=>{this.eventPending=!0}),b(i=>i.target instanceof HTMLElement?{event:i,target:s?i.target.closest(s):i.currentTarget}:{event:i,target:null}),h(({target:i})=>!!i),u(i=>this.app.hasSession?l(i):o(this.app.load())),m(({event:i,target:n})=>{let r=e.bind(this)(i,n);return f(r)?r:typeof(r==null?void 0:r.then)=="function"?o(r):l(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0}};export{a as WishlistElement}; | ||
import{delayWhen as u,from as o,fromEvent as c,isObservable as f,map as b,of as l}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{filter as h,first as g,switchMap as m,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.8.0/+esm";import{LitElement as y}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{unsafeHTML as d}from"https://cdn.jsdelivr.net/gh/lit/dist@2.6.0/all/lit-all.min.js";import{WishlistStateController as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.19.5/controllers.js";var a=class extends y{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.firstConnect=!0;this.stateCtrl=new v(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),this.connected&&this.app.loaded&&this.initState()}appReadyCallback(){this.dataset.productHandle&&this.app.events.subscribe("wk:product:change-variant:success",t=>{var e,s,i;if(this.dataset.productHandle===((e=t.data)==null?void 0:e.productHandle)&&((s=t.data)!=null&&s.variantId)){let n=this.productInfo?this.productInfo.wishlistItemId:void 0,r=this.productInfo?this.productInfo.variantId:void 0;n&&!r&&this.app.updateWishlistItem({wishlistItemId:n,changes:{variantId:(i=t.data)==null?void 0:i.variantId}}),this.dataset.variantId=t.data.variantId.toString()}})}async connect(){if(!this.connected){if(!this.app.stylesLoaded){c(document,"wk:app:load-styles:success").pipe(g()).subscribe(()=>this.connect());return}this.connected=!0,this.app.loaded?this.init():this.app.hasSession?(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 s=this.app.theme.translate(t,e);return t.endsWith("_html")?d(s):s}formatMoney(t){return this.app.utils.money.formatMoney(t)}renderMoney(t){return d(this.app.utils.money.formatMoney(t))}getProductUrl(t,e){return this.app.utils.url.getVariantUrl(t.url,e==null?void 0:e.id)}getImageUrl(t,e,s){var i;return this.app.utils.url.getImageUrl((i=e==null?void 0:e.featured_image)!=null&&i.src?e:t,s)}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):(this.initState(),this.appReadyCallback())}setState(t){this.wishlist=t.wishlist,this.wishlistItem=t.wishlistItem,this.productInfo=t.productInfo}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML&&this.firstConnect&&(this.innerHTML=""),this.initEvents(),this.connect(),this.firstConnect=!1}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.cleanupMethods.forEach(s=>s()),this.connected=!1,(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe().subscribe(t=>{this.setState(t)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.setState(t)}initObserver(){var t,e;(t=this.observer)==null||t.disconnect(),this.observer=new IntersectionObserver(s=>this.handleIntersect(s),{root:null,rootMargin:"0px"}),this.setAttribute("wk-lazy",""),this.observer.observe((e=this.firstElementChild)!=null?e:this)}handleIntersect([t]){var e;t.isIntersecting&&(this.removeAttribute("wk-lazy"),(e=this.observer)==null||e.disconnect(),this.initState(),this.appReadyCallback())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([s,i])=>{let[n,r]=s.split(/ (.*)/s);return this.subscribeToEvent({eventName:n,selector:r,handler:i})});this.cleanupMethods.push(()=>e.forEach(s=>s.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:s}){return c(this,t).pipe(p(i=>{this.eventPending&&i.preventDefault()}),h(()=>!this.eventPending),p(()=>{this.eventPending=!0}),b(i=>i.target instanceof HTMLElement?{event:i,target:s?i.target.closest(s):i.currentTarget}:{event:i,target:null}),h(({target:i})=>!!i),u(i=>this.app.hasSession?l(i):o(this.app.load())),m(({event:i,target:n})=>{let r=e.bind(this)(i,n);return f(r)?r:typeof(r==null?void 0:r.then)=="function"?o(r):l(r)})).subscribe(()=>{this.eventPending=!1})}};a.properties={wishlist:{state:!0},productInfo:{state:!0},wishlistItem:{state:!0}};export{a 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 4 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 4 instances in 1 package
182265