Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appmate/wishlist

Package Overview
Dependencies
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appmate/wishlist - npm Package Compare versions

Comparing version 4.15.1 to 4.15.2

2

api/shopify-api.js

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

import{RestApi as e}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/rest-api.js";var t=class extends e{loadProduct({productHandle:r}){return this.get({path:`/products/${r}.js`})}addToCart(r){return this.post({path:"/cart/add.js",body:r})}};export{t as ShopifyApi};
import{RestApi as e}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/rest-api.js";var t=class extends e{loadProduct({productHandle:r}){return this.get({path:`/products/${r}.js`})}addToCart(r){return this.post({path:"/cart/add.js",body:r})}};export{t as ShopifyApi};

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

import{forkJoin as f,lastValueFrom as w,of as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{NotifyApi as W}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/notify-api.js";import{GoogleAnalytics as k}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/google-analytics-api.js";import{KlaviyoTracking as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/klaviyo-tracking-api.js";import{MetaPixel as T}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/meta-pixel-api.js";var n=class{constructor({settings:s,events:e,notifyHost:l,utils:h,shop:p,sessionId:u,customerId:m}){this.utils=h,this.services=[],s.appmateAnalytics&&this.services.push(new W({host:l,shop:p,customerId:m,sessionId:u})),s.klaviyo&&this.services.push(new g({urlUtil:this.utils.url,moneyUtil:this.utils.money})),s.facebookPixel&&this.services.push(new T({currency:window.Shopify.currency.active})),s.googleAnalytics&&this.services.push(new k);let v=this.utils.route.parse(window.location.pathname).pageType,i=y=>t=>{var r,a,o,c;return w(this.track({eventName:y,source:v,wishlist:(r=t.data)==null?void 0:r.wishlist,product:(a=t.data)==null?void 0:a.product,variant:(o=t.data)==null?void 0:o.variant,quantity:(c=t.data)==null?void 0:c.quantity}))};e.subscribeMany({"wk:wishlist:add-to-cart:success":i("addToCart"),"wk:wishlist:add:success":i("addToWishlist"),"wk:wishlist:change-variant:success":i("changeVariant"),"wk:wishlist:clear:success":i("clearWishlist"),"wk:wishlist:remove:success":i("removeFromWishlist"),"wk:wishlist:share:success":i("shareWishlist"),"wk:wishlist:page-view":i("viewWishlist")})}track(s){return this.services.length?f(this.services.map(e=>e.track(s))):d([])}};export{n as TrackingApi};
import{forkJoin as f,lastValueFrom as w,of as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{NotifyApi as W}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/notify-api.js";import{GoogleAnalytics as k}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/google-analytics-api.js";import{KlaviyoTracking as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/klaviyo-tracking-api.js";import{MetaPixel as T}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/meta-pixel-api.js";var n=class{constructor({settings:s,events:e,notifyHost:l,utils:h,shop:p,sessionId:u,customerId:m}){this.utils=h,this.services=[],s.appmateAnalytics&&this.services.push(new W({host:l,shop:p,customerId:m,sessionId:u})),s.klaviyo&&this.services.push(new g({urlUtil:this.utils.url,moneyUtil:this.utils.money})),s.facebookPixel&&this.services.push(new T({currency:window.Shopify.currency.active})),s.googleAnalytics&&this.services.push(new k);let v=this.utils.route.parse(window.location.pathname).pageType,i=y=>t=>{var r,a,o,c;return w(this.track({eventName:y,source:v,wishlist:(r=t.data)==null?void 0:r.wishlist,product:(a=t.data)==null?void 0:a.product,variant:(o=t.data)==null?void 0:o.variant,quantity:(c=t.data)==null?void 0:c.quantity}))};e.subscribeMany({"wk:wishlist:add-to-cart:success":i("addToCart"),"wk:wishlist:add:success":i("addToWishlist"),"wk:wishlist:change-variant:success":i("changeVariant"),"wk:wishlist:clear:success":i("clearWishlist"),"wk:wishlist:remove:success":i("removeFromWishlist"),"wk:wishlist:share:success":i("shareWishlist"),"wk:wishlist:page-view":i("viewWishlist")})}track(s){return this.services.length?f(this.services.map(e=>e.track(s))):d([])}};export{n as TrackingApi};

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

import h from"https://cdn.jsdelivr.net/npm/dataloader@2.1.0/+esm";import{from as l,lastValueFrom as o}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{RestApi as p}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/rest-api.js";import{version as c}from"https://cdn.jsdelivr.net/npm/..@undefined/../package.json/+esm";var d=class extends p{constructor(t){var s,r,i;super(t);this.headers={"content-type":"application/json","x-appmate-shp":t.shop,"x-appmate-tkv":c,"x-appmate-sid":t.sessionId,"x-appmate-cid":(r=(s=t.customerId)==null?void 0:s.toString())!=null?r:"","x-appmate-src":(i=t.trackingSource)!=null?i:""},this.wishlistLoader=this.createWishlistLoader(),this.productInfoLoader=this.createProductInfoLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}createWishlistLoader(){return new h(async t=>{let s=t.map(i=>i.split("-")).reduce((i,[e,a])=>(i[e]||(i[e]=[]),i[e].push(a),i),{}),r=await Promise.all(Object.entries(s).map(([i,e])=>o(this.get({path:`/wishlists/${i}`,query:{format:e.includes("all")?"all":"minimal"}})))).then(i=>i.map(e=>e.wishlist));return t.map((i,e)=>{var n;let[a]=i.split("-");return(n=r.find(m=>a==="mine"?m.isMine:m.publicId===a))!=null?n:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createProductInfoLoader(){return new h(async t=>{let{productInfo:s}=await o(this.get({path:"/wishlists/mine/product-info",headers:{"X-Appmate-IDS":t.join(",")}}));return t.map(r=>{var i;return(i=s.find(e=>e.productId===r))!=null?i:{productId:r,wishlistItems:[]}})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createWishlistItemLoader(){return new h(async t=>{let s=t.map(i=>i.split("-")).reduce((i,[e,a])=>(i[e]||(i[e]=[]),i[e].push(a),i),{}),r=await Promise.all(Object.entries(s).map(([i,e])=>o(this.get({path:`/wishlists/${i}/items`,headers:{"X-Appmate-IDS":e.join(",")}})))).then(i=>i.flatMap(e=>e.items));return t.map(i=>{var a;let[,e]=i.split("-");return(a=r.find(n=>n.id===e))!=null?a:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}loadWishlist({wishlistId:t,format:s}){return l(this.wishlistLoader.load([t,s].join("-")).then(r=>({wishlist:r})))}loadProductInfo({productId:t}){return l(this.productInfoLoader.load(t).then(s=>({productInfo:s})))}loadWishlistItem({wishlistId:t,wishlistItemId:s}){return l(this.wishlistItemLoader.load([t,s].join("-")).then(r=>({wishlistItem:r})))}loadWishlistItems({wishlistId:t,wishlistItemIds:s}){return o(this.get({path:`/wishlists/${t}/items`,headers:{"X-Appmate-IDS":s.join(",")}}))}addItem({productId:t,variantId:s}){return typeof t=="string"&&(t=parseInt(t)),typeof s=="string"&&(s=parseInt(s)),this.post({path:"/wishlists/mine/items",body:{productId:t,variantId:s}})}updateItem({wishlistItemId:t,changes:s}){return this.put({path:"/wishlists/mine/items",body:{changes:{...s,wishlistItemId:t}}})}removeItem({wishlistId:t,wishlistItemId:s}){return this.delete({path:`/wishlists/${t}/items`,body:{wishlistItemId:s}})}clearWishlist(){return this.delete({path:"/wishlists/mine"})}};export{d as WishlistApi};
import l from"https://cdn.jsdelivr.net/npm/dataloader@2.1.0/+esm";import{from as d,lastValueFrom as o}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{RestApi as c}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/rest-api.js";var h="4.15.2";var m=class extends c{constructor(t){var s,r,i;super(t);this.headers={"content-type":"application/json","x-appmate-shp":t.shop,"x-appmate-tkv":h,"x-appmate-sid":t.sessionId,"x-appmate-cid":(r=(s=t.customerId)==null?void 0:s.toString())!=null?r:"","x-appmate-src":(i=t.trackingSource)!=null?i:""},this.wishlistLoader=this.createWishlistLoader(),this.productInfoLoader=this.createProductInfoLoader(),this.wishlistItemLoader=this.createWishlistItemLoader()}createWishlistLoader(){return new l(async t=>{let s=t.map(i=>i.split("-")).reduce((i,[e,n])=>(i[e]||(i[e]=[]),i[e].push(n),i),{}),r=await Promise.all(Object.entries(s).map(([i,e])=>o(this.get({path:`/wishlists/${i}`,query:{format:e.includes("all")?"all":"minimal"}})))).then(i=>i.map(e=>e.wishlist));return t.map((i,e)=>{var a;let[n]=i.split("-");return(a=r.find(p=>n==="mine"?p.isMine:p.publicId===n))!=null?a:new Error("Wishlist not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createProductInfoLoader(){return new l(async t=>{let{productInfo:s}=await o(this.get({path:"/wishlists/mine/product-info",headers:{"X-Appmate-IDS":t.join(",")}}));return t.map(r=>{var i;return(i=s.find(e=>e.productId===r))!=null?i:{productId:r,wishlistItems:[]}})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}createWishlistItemLoader(){return new l(async t=>{let s=t.map(i=>i.split("-")).reduce((i,[e,n])=>(i[e]||(i[e]=[]),i[e].push(n),i),{}),r=await Promise.all(Object.entries(s).map(([i,e])=>o(this.get({path:`/wishlists/${i}/items`,headers:{"X-Appmate-IDS":e.join(",")}})))).then(i=>i.flatMap(e=>e.items));return t.map(i=>{var n;let[,e]=i.split("-");return(n=r.find(a=>a.id===e))!=null?n:new Error("Wishlist item not found")})},{cache:!0,batchScheduleFn:t=>setTimeout(t,250)})}loadWishlist({wishlistId:t,format:s}){return d(this.wishlistLoader.load([t,s].join("-")).then(r=>({wishlist:r})))}loadProductInfo({productId:t}){return d(this.productInfoLoader.load(t).then(s=>({productInfo:s})))}loadWishlistItem({wishlistId:t,wishlistItemId:s}){return d(this.wishlistItemLoader.load([t,s].join("-")).then(r=>({wishlistItem:r})))}loadWishlistItems({wishlistId:t,wishlistItemIds:s}){return o(this.get({path:`/wishlists/${t}/items`,headers:{"X-Appmate-IDS":s.join(",")}}))}addItem({productId:t,variantId:s}){return typeof t=="string"&&(t=parseInt(t)),typeof s=="string"&&(s=parseInt(s)),this.post({path:"/wishlists/mine/items",body:{productId:t,variantId:s}})}updateItem({wishlistItemId:t,changes:s}){return this.put({path:"/wishlists/mine/items",body:{changes:{...s,wishlistItemId:t}}})}removeItem({wishlistId:t,wishlistItemId:s}){return this.delete({path:`/wishlists/${t}/items`,body:{wishlistItemId:s}})}clearWishlist(){return this.delete({path:"/wishlists/mine"})}};export{m as WishlistApi};

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

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

@@ -3,0 +3,0 @@ display: flex;

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

var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var n=(g,s,e,i)=>{for(var a=i>1?void 0:i?h(s,e):s,r=g.length-1,l;r>=0;r--)(l=g[r])&&(a=(i?l(s,e,a):l(a))||a);return i&&a&&c(s,e,a),a};import{css as p,html as d,LitElement as f}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{customElement as w,property as o}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/directives/class-map/+esm";import y from"https://cdn.jsdelivr.net/npm/memoize-one@6.0.0/+esm";import{FloatingUiController as k}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/controllers/floating-ui-controller.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/components/badge.js";var t=class extends f{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.layout="icon-and-text";this.outline=!1;this.fullWidth=!1;this.alignment="center";this.badgeParentheses=!1;this.badgeHiddenIfEmpty=!1;this.floatingUi=new k(this);this.getBadgeFloating=y((e,i)=>{if(!(!e||!i))return{...e,reference:i}})}updated(e){e.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var a,r,l;let e=(a=this.alignment)!=null?a:"center",i={"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 c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var n=(g,s,e,i)=>{for(var a=i>1?void 0:i?h(s,e):s,r=g.length-1,l;r>=0;r--)(l=g[r])&&(a=(i?l(s,e,a):l(a))||a);return i&&a&&c(s,e,a),a};import{css as p,html as d,LitElement as f}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{customElement as w,property as o}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators/+esm";import{classMap as b}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/directives/class-map/+esm";import y from"https://cdn.jsdelivr.net/npm/memoize-one@6.0.0/+esm";import{FloatingUiController as k}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/controllers/floating-ui-controller.js";import"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/components/badge.js";var t=class extends f{constructor(){super(...arguments);this.text="";this.hint="";this.selected=!1;this.disabled=!1;this.layout="icon-and-text";this.outline=!1;this.fullWidth=!1;this.alignment="center";this.badgeParentheses=!1;this.badgeHiddenIfEmpty=!1;this.floatingUi=new k(this);this.getBadgeFloating=y((e,i)=>{if(!(!e||!i))return{...e,reference:i}})}updated(e){e.has("floating")&&(this.floating?this.floatingUi.float(this.floating):this.floatingUi.destroy())}render(){var a,r,l;let e=(a=this.alignment)!=null?a:"center",i={"wk-button":!0,"wk-selected":!!this.selected,"wk-outline":!!this.outline,"wk-full-width":!!this.fullWidth,[`wk-align-${e}`]:!0};return this.href?d`
<a

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

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

var h=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=(a,n,t,i)=>{for(var o=i>1?void 0:i?p(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&&h(n,t,o),o};import{css as c,html as f,LitElement as u}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{customElement as w,property as v,state as m}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators/+esm";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/directives/class-map/+esm";import{FloatingUiController as x}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/controllers/floating-ui-controller.js";var e=class extends u{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1}get added(){return!!this.parentElement}get floats(){return!!this._floatingCtrl}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}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),f`
var h=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=(a,n,t,i)=>{for(var o=i>1?void 0:i?p(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&&h(n,t,o),o};import{css as c,html as f,LitElement as u}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{customElement as w,property as v,state as m}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators/+esm";import{classMap as g}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/directives/class-map/+esm";import{FloatingUiController as x}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/controllers/floating-ui-controller.js";var e=class extends u{constructor(){super(...arguments);this.text="";this.autoShow=!1;this.autoHide=!1}get added(){return!!this.parentElement}get floats(){return!!this._floatingCtrl}get showing(){return this.transition==="show"}get hiding(){return this.transition==="hide"}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),f`
<div class=${g(t)}>

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

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

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

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

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

import{autoUpdate as w,offset as g,computePosition as b,flip as x,arrow as y,shift as _}from"https://cdn.jsdelivr.net/npm/@floating-ui@undefined/dom/+esm";var u=class{constructor(e){this._middleware=[];(this.host=e).addController(this)}hostDisconnected(){this.destroy()}hostUpdated(){this.updatePosition()}hostResized(){this.updatePosition()}float(e){var o;if(this.destroy(),this._settings=e,this._reference=this.getReference(),this._resizeObserver=new ResizeObserver(()=>this.hostResized()),!this._settings)throw new Error("Floating settings are required");if(!this._reference)throw new Error("Floating reference is required");this.host.classList.add("wk-floating");let{position:i,arrow:r=!1,flip:s=!1,shift:c=!1}=this._settings,t=this.getOffsetSetting();Object.assign(this.host.style,{position:(o=i.strategy)!=null?o:"absolute",top:"0",left:"0",transition:"none",transform:"translate3d(0,0,0)"}),i.inset&&!r?this._middleware.push(g(({rects:n,placement:a})=>{var l,h,p,d,m,f;return a.includes("top")||a.includes("bottom")?{mainAxis:-n.floating.height-((l=t==null?void 0:t.mainAxis)!=null?l:0),crossAxis:(h=t==null?void 0:t.crossAxis)!=null?h:0,alignmentAxis:(p=t==null?void 0:t.alignmentAxis)!=null?p:0}:{mainAxis:-n.floating.width-((d=t==null?void 0:t.mainAxis)!=null?d:0),crossAxis:(m=t==null?void 0:t.crossAxis)!=null?m:0,alignmentAxis:(f=t==null?void 0:t.alignmentAxis)!=null?f:0}})):t&&this._middleware.push(g(t)),s&&this._middleware.push(x()),c&&this._middleware.push(_()),r&&(this.arrowEl=document.createElement("div"),this.arrowEl.classList.add("wk-arrow"),this._middleware.push(y({element:this.arrowEl}))),this.cleanupAutoUpdate=w(this._reference,this.host,()=>{this.updatePosition()}),this._resizeObserver.observe(this.host)}getOffsetSetting(){var i,r;let e=(i=this._settings)==null?void 0:i.offset;if(!(!e||typeof e=="boolean"))return typeof e=="number"?{mainAxis:e,alignmentAxis:(r=this._settings)!=null&&r.position.inset?e:null}:e}destroy(){var e,i,r,s;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"),(r=this.cleanupAutoUpdate)==null||r.call(this),(s=this._resizeObserver)==null||s.disconnect()}updatePosition(){var r;if(!this._reference||!this._settings)return;let{strategy:e="absolute",placement:i="top"}=(r=this._settings.position)!=null?r:{};b(this._reference,this.host,{middleware:this._middleware,strategy:e,placement:i}).then(({x:s,y:c,placement:t,middlewareData:o})=>{if(o.arrow&&this.arrowEl){let{x:n,y:a}=o.arrow,l={top:"bottom",right:"left",bottom:"top",left:"right"}[t.split("-")[0]],h={bottom:"0deg",left:"90deg",top:"180deg",right:"270deg"}[t.split("-")[0]];Object.assign(this.arrowEl.style,{left:n!=null?`${n}px`:"",top:a!=null?`${a}px`:"",right:"",bottom:"",[l]:"-5px",transform:`rotate(${h})`})}Object.assign(this.host.style,{transform:`translate3d(${Math.round(s)}px,${Math.round(c)}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,r,s;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:(s=(r=window.visualViewport)==null?void 0:r.height)!=null?s:0}}}}};export{u as FloatingUiController};
import{autoUpdate as w,offset as g,computePosition as b,flip as x,arrow as y,shift as _}from"https://cdn.jsdelivr.net/npm/@floating-ui/dom@1.0.1/+esm";var u=class{constructor(e){this._middleware=[];(this.host=e).addController(this)}hostDisconnected(){this.destroy()}hostUpdated(){this.updatePosition()}hostResized(){this.updatePosition()}float(e){var o;if(this.destroy(),this._settings=e,this._reference=this.getReference(),this._resizeObserver=new ResizeObserver(()=>this.hostResized()),!this._settings)throw new Error("Floating settings are required");if(!this._reference)throw new Error("Floating reference is required");this.host.classList.add("wk-floating");let{position:i,arrow:r=!1,flip:s=!1,shift:c=!1}=this._settings,t=this.getOffsetSetting();Object.assign(this.host.style,{position:(o=i.strategy)!=null?o:"absolute",top:"0",left:"0",transition:"none",transform:"translate3d(0,0,0)"}),i.inset&&!r?this._middleware.push(g(({rects:n,placement:a})=>{var l,h,p,d,m,f;return a.includes("top")||a.includes("bottom")?{mainAxis:-n.floating.height-((l=t==null?void 0:t.mainAxis)!=null?l:0),crossAxis:(h=t==null?void 0:t.crossAxis)!=null?h:0,alignmentAxis:(p=t==null?void 0:t.alignmentAxis)!=null?p:0}:{mainAxis:-n.floating.width-((d=t==null?void 0:t.mainAxis)!=null?d:0),crossAxis:(m=t==null?void 0:t.crossAxis)!=null?m:0,alignmentAxis:(f=t==null?void 0:t.alignmentAxis)!=null?f:0}})):t&&this._middleware.push(g(t)),s&&this._middleware.push(x()),c&&this._middleware.push(_()),r&&(this.arrowEl=document.createElement("div"),this.arrowEl.classList.add("wk-arrow"),this._middleware.push(y({element:this.arrowEl}))),this.cleanupAutoUpdate=w(this._reference,this.host,()=>{this.updatePosition()}),this._resizeObserver.observe(this.host)}getOffsetSetting(){var i,r;let e=(i=this._settings)==null?void 0:i.offset;if(!(!e||typeof e=="boolean"))return typeof e=="number"?{mainAxis:e,alignmentAxis:(r=this._settings)!=null&&r.position.inset?e:null}:e}destroy(){var e,i,r,s;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"),(r=this.cleanupAutoUpdate)==null||r.call(this),(s=this._resizeObserver)==null||s.disconnect()}updatePosition(){var r;if(!this._reference||!this._settings)return;let{strategy:e="absolute",placement:i="top"}=(r=this._settings.position)!=null?r:{};b(this._reference,this.host,{middleware:this._middleware,strategy:e,placement:i}).then(({x:s,y:c,placement:t,middlewareData:o})=>{if(o.arrow&&this.arrowEl){let{x:n,y:a}=o.arrow,l={top:"bottom",right:"left",bottom:"top",left:"right"}[t.split("-")[0]],h={bottom:"0deg",left:"90deg",top:"180deg",right:"270deg"}[t.split("-")[0]];Object.assign(this.arrowEl.style,{left:n!=null?`${n}px`:"",top:a!=null?`${a}px`:"",right:"",bottom:"",[l]:"-5px",transform:`rotate(${h})`})}Object.assign(this.host.style,{transform:`translate3d(${Math.round(s)}px,${Math.round(c)}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,r,s;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:(s=(r=window.visualViewport)==null?void 0:r.height)!=null?s:0}}}}};export{u as FloatingUiController};

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

import{WishlistApp as i}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/wishlist-app.js";import{WishlistElement as p}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/wishlist-element.js";export{i as WishlistApp,p as WishlistElement};
import{WishlistApp as i}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/wishlist-app.js";import{WishlistElement as p}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/wishlist-element.js";export{i as WishlistApp,p as WishlistElement};

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

import{Liquid as l}from"https://cdn.jsdelivr.net/npm/liquidjs@9.42.0/+esm";import{html as u,unsafeStatic as c}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/static-html.js/+esm";import{LiquidDataUtil as p}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/liquid/liquid-data-util.js";import{liquidShopifyFilters as d}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/liquid/liquid-shopify-filters.js";import{WishlistElement as y}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/state/wishlist-element.js";var a=class extends WishlistElement{static get properties(){return{}}init(){super.init(),this.dataUtil=new p({utils:this.app.utils}),this.globals={settings:{login_required:this.app.settings.loginRequired},customer:this.app.customer,shop:{currency:this.app.config.shop.currency,customer_accounts_enabled:this.app.config.shop.customerAccountsEnabled,domain:this.app.config.shop.domain,money_format:this.app.config.shop.moneyFormat,name:this.app.config.shop.name,permanent_domain:this.app.config.shop.permanentDomain},routes:{root_url:this.app.routes.rootUrl,wishlist_url:this.app.routes.wishlistUrl,account_url:this.app.routes.accountUrl,account_login_url:this.app.routes.accountLoginUrl,account_logout_url:this.app.routes.accountLogoutUrl,account_register_url:this.app.routes.accountRegisterUrl,account_addresses_url:this.app.routes.accountAddressesUrl,collections_url:this.app.routes.collectionsUrl,all_products_collection_url:this.app.routes.allProductsCollectionUrl,search_url:this.app.routes.searchUrl,predictive_search_url:this.app.routes.predictiveSearchUrl,cart_url:this.app.routes.cartUrl,cart_add_url:this.app.routes.cartAddUrl,cart_change_url:this.app.routes.cartChangeUrl,cart_clear_url:this.app.routes.cartClearUrl,cart_update_url:this.app.routes.cartUpdateUrl,product_recommendations_url:this.app.routes.productRecommendationsUrl}},this.liquidEngine=new l({cache:!0,relativeReference:!1}),this.liquidEngine.plugin(d(this.app)),this.initTemplate()}disconnectedCallback(){super.disconnectedCallback(),this.parsedTemplates=void 0}getLiquidTemplate(){return""}getLiquidData(){return{}}initTemplate(){if(this.parsedTemplates)return this.parsedTemplates;if(!this.liquidEngine)throw new Error("Liquid engine not initialized");return this.parsedTemplates=this.liquidEngine.parse(this.getLiquidTemplate()),this.parsedTemplates}render(){var r,s;if(!this.parsedTemplates||!this.liquidEngine||!this.dataUtil)return;let{wishlist:t,wishlistItem:i,productInfo:e}=(r=this.state)!=null?r:{},n={...this.dataUtil.objectToSnakeCase(this.getLiquidData()),wishlist:t?this.dataUtil.mapWishlistState(t,(s=this.stateCtrl.stateConfig.wishlist)==null?void 0:s.format):void 0,wishlist_item:i?this.dataUtil.mapWishlistItem(i):void 0,product_info:e?this.dataUtil.mapProductInfo(e):void 0},o=this.liquidEngine.renderSync(this.parsedTemplates,n,{globals:this.globals});return u`${c(o)}`}};export{a as LiquidElement,y as WishlistElement};
import{Liquid as l}from"https://cdn.jsdelivr.net/npm/liquidjs@9.42.0/+esm";import{html as u,unsafeStatic as c}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/static-html.js/+esm";import{LiquidDataUtil as p}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/liquid/liquid-data-util.js";import{liquidShopifyFilters as d}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/liquid/liquid-shopify-filters.js";import{WishlistElement as y}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/state/wishlist-element.js";var a=class extends WishlistElement{static get properties(){return{}}init(){super.init(),this.dataUtil=new p({utils:this.app.utils}),this.globals={settings:{login_required:this.app.settings.loginRequired},customer:this.app.customer,shop:{currency:this.app.config.shop.currency,customer_accounts_enabled:this.app.config.shop.customerAccountsEnabled,domain:this.app.config.shop.domain,money_format:this.app.config.shop.moneyFormat,name:this.app.config.shop.name,permanent_domain:this.app.config.shop.permanentDomain},routes:{root_url:this.app.routes.rootUrl,wishlist_url:this.app.routes.wishlistUrl,account_url:this.app.routes.accountUrl,account_login_url:this.app.routes.accountLoginUrl,account_logout_url:this.app.routes.accountLogoutUrl,account_register_url:this.app.routes.accountRegisterUrl,account_addresses_url:this.app.routes.accountAddressesUrl,collections_url:this.app.routes.collectionsUrl,all_products_collection_url:this.app.routes.allProductsCollectionUrl,search_url:this.app.routes.searchUrl,predictive_search_url:this.app.routes.predictiveSearchUrl,cart_url:this.app.routes.cartUrl,cart_add_url:this.app.routes.cartAddUrl,cart_change_url:this.app.routes.cartChangeUrl,cart_clear_url:this.app.routes.cartClearUrl,cart_update_url:this.app.routes.cartUpdateUrl,product_recommendations_url:this.app.routes.productRecommendationsUrl}},this.liquidEngine=new l({cache:!0,relativeReference:!1}),this.liquidEngine.plugin(d(this.app)),this.initTemplate()}disconnectedCallback(){super.disconnectedCallback(),this.parsedTemplates=void 0}getLiquidTemplate(){return""}getLiquidData(){return{}}initTemplate(){if(this.parsedTemplates)return this.parsedTemplates;if(!this.liquidEngine)throw new Error("Liquid engine not initialized");return this.parsedTemplates=this.liquidEngine.parse(this.getLiquidTemplate()),this.parsedTemplates}render(){var r,s;if(!this.parsedTemplates||!this.liquidEngine||!this.dataUtil)return;let{wishlist:t,wishlistItem:i,productInfo:e}=(r=this.state)!=null?r:{},n={...this.dataUtil.objectToSnakeCase(this.getLiquidData()),wishlist:t?this.dataUtil.mapWishlistState(t,(s=this.stateCtrl.stateConfig.wishlist)==null?void 0:s.format):void 0,wishlist_item:i?this.dataUtil.mapWishlistItem(i):void 0,product_info:e?this.dataUtil.mapProductInfo(e):void 0},o=this.liquidEngine.renderSync(this.parsedTemplates,n,{globals:this.globals});return u`${c(o)}`}};export{a as LiquidElement,y as WishlistElement};
{
"name": "@appmate/wishlist",
"version": "4.15.1",
"version": "4.15.2",
"description": "Wishlist King SDK",

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

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

import{catchError as P,defer as p,forkJoin as w,from as r,map as u,Observable as U,of as A,switchMap as f}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{Dexie as v,liveQuery as x}from"https://cdn.jsdelivr.net/npm/dexie@3.2.2/+esm";import b from"https://cdn.jsdelivr.net/npm/short-unique-id@4.4.4/+esm";import{filterWishlistItem as S,mapApiToCacheProductInfo as c}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/state/state-util.js";var T=new b({length:10}),W=class extends v{constructor(){super("WishlistKing");this.version(1).stores({shopifyProducts:"handle",wishlists:"id",wishlistItems:"id",productInfo:"productId,*wishlistItemIds"})}storeShopifyProduct({product:t}){return r(p(()=>this.shopifyProducts.put(t)).pipe(u(()=>t)))}storeWishlist({wishlist:t}){return this.getWishlist({wishlistId:t.id}).pipe(P(()=>A(null)),f(i=>{var e;return r(this.wishlists.put({...t,items:(e=t.items)!=null?e:i==null?void 0:i.items}))}),u(()=>t))}storeProductInfo({productInfo:t}){return r(p(()=>this.productInfo.put(c({productInfo:t}))))}storeWishlistItem({wishlistItem:t}){return r(p(()=>this.wishlistItems.put(t)))}getProductInfo({productId:t}){return r(p(()=>this.productInfo.get(t)))}getProductInfoByItemId({wishlistItemId:t}){return r(p(()=>this.productInfo.where("wishlistItemIds").equals(t).first()))}getProductInfos(){return r(p(()=>this.productInfo.toArray()))}getWishlist({wishlistId:t}){return r(p(()=>this.wishlists.get(t)))}getWishlistItems(){return r(p(()=>this.wishlistItems.toArray()))}getShopifyProduct({productHandle:t}){return r(p(()=>this.shopifyProducts.get(t)))}getWishlistItem({wishlistItemId:t}){return r(p(()=>this.wishlistItems.get(t)))}addItemToWishlist({productId:t,variantId:i}){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfo({productId:t})]).pipe(f(([e,s])=>{let h={id:`temp-${T()}`},m=R({wishlistId:"mine",item:h},e),I=()=>this.wishlists.put(m),o=()=>e?this.wishlists.put(e):this.wishlists.delete("mine"),l=()=>this.productInfo.put(c({productInfo:{productId:t,wishlistItems:s?[...s.wishlistItems,{id:h.id,variantId:i}]:[{id:h.id,variantId:i}]}})),a=()=>s?this.productInfo.put(s):this.productInfo.delete(t);return r(p(()=>this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([I(),l()])))).pipe(u(()=>({wishlist:m,item:h,revertStateUpdate:()=>r(this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([o(),a()])))})))}))}removeItemFromWishlist({wishlistItemId:t}){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t}),this.getWishlistItem({wishlistItemId:t})]).pipe(f(([i,e,s])=>{let h=B({wishlistItemId:t},i),m=()=>this.wishlists.put(h),I=()=>i?this.wishlists.put(i):this.wishlists.delete("mine"),o=()=>{if(e)return this.productInfo.put(c({productInfo:{productId:e.productId,wishlistItems:e.wishlistItems.filter(y=>y.id!==t)}}))},l=()=>{if(e)return this.productInfo.put(e)},a=()=>{if(s)return this.wishlistItems.delete(s.id)},g=()=>{if(s)return this.wishlistItems.put(s)};return r(p(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([m(),o(),a()])))).pipe(u(()=>({wishlist:h,revertStateUpdate:()=>r(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([I(),l(),g()])))})))}))}clearWishlist(){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfos(),this.getWishlistItems()]).pipe(f(([t,i,e])=>{let s=D(t),h=()=>{if(s)return this.wishlists.put(s)},m=()=>{var g;return t?this.wishlists.put(t):this.wishlists.delete((g=s==null?void 0:s.id)!=null?g:"mine")},I=()=>this.productInfo.clear(),o=()=>{if(i)return this.productInfo.bulkPut(i)},l=()=>this.wishlistItems.clear(),a=()=>{if(e)return this.wishlistItems.bulkPut(e)};return r(p(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([h(),I(),l()])))).pipe(u(()=>({wishlist:s,revertStateUpdate:()=>r(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([m(),o(),a()])))})))}))}updateWishlistItem({wishlistItemId:t,changes:i}){return w([this.getWishlistItem({wishlistItemId:t}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(f(([e,s])=>{let h=()=>{if(e)return this.wishlistItems.put({...e,selectedVariantId:i.variantId})},m=()=>{if(e)return this.wishlistItems.put(e)},I=()=>{if(s)return this.productInfo.put(c({productInfo:{...s,wishlistItems:s.wishlistItems.map(l=>l.id===t?{...l,variantId:i.variantId}:l)}}))},o=()=>{if(s)return this.productInfo.put(s)};return r(p(()=>this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([h(),I()])))).pipe(u(()=>({revertStateUpdate:()=>r(this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([m(),o()])))})))}))}changeWishlistItemRef({wishlistItemId:t,changes:i}){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(f(([e,s])=>{let h={id:i.id},m=()=>{var o;if(e)return this.wishlists.put({...e,items:(o=e.items)==null?void 0:o.map(l=>l.id===t?h:l)})},I=()=>{if(s)return this.productInfo.put(c({productInfo:{...s,wishlistItems:s.wishlistItems.map(o=>o.id===t?{...o,id:i.id}:o)}}))};return r(Promise.all([m(),I()])).pipe(u(()=>({item:h})))}))}liveQuery(t){return new U(i=>{x(t).subscribe({error:i.error.bind(i),next:i.next.bind(i),complete:i.complete.bind(i)})})}},R=(d,n)=>n?{...n,numItems:n.numItems+1,items:n.items?[...n.items,d.item]:[d.item]}:{id:d.wishlistId,publicId:void 0,isMine:!0,numItems:1,items:[d.item]},B=(d,n)=>n?{...n,numItems:n.numItems-1,items:n.items?S(n.items,d):[]}:{id:"mine",publicId:void 0,isMine:!0,numItems:0},D=d=>{if(!!d)return{...d,numItems:0,items:[]}};export{W as CacheDatabase};
import{catchError as P,defer as p,forkJoin as w,from as r,map as u,Observable as U,of as A,switchMap as f}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{Dexie as v,liveQuery as x}from"https://cdn.jsdelivr.net/npm/dexie@3.2.2/+esm";import b from"https://cdn.jsdelivr.net/npm/short-unique-id@4.4.4/+esm";import{filterWishlistItem as S,mapApiToCacheProductInfo as c}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/state/state-util.js";var T=new b({length:10}),W=class extends v{constructor(){super("WishlistKing");this.version(1).stores({shopifyProducts:"handle",wishlists:"id",wishlistItems:"id",productInfo:"productId,*wishlistItemIds"})}storeShopifyProduct({product:t}){return r(p(()=>this.shopifyProducts.put(t)).pipe(u(()=>t)))}storeWishlist({wishlist:t}){return this.getWishlist({wishlistId:t.id}).pipe(P(()=>A(null)),f(i=>{var e;return r(this.wishlists.put({...t,items:(e=t.items)!=null?e:i==null?void 0:i.items}))}),u(()=>t))}storeProductInfo({productInfo:t}){return r(p(()=>this.productInfo.put(c({productInfo:t}))))}storeWishlistItem({wishlistItem:t}){return r(p(()=>this.wishlistItems.put(t)))}getProductInfo({productId:t}){return r(p(()=>this.productInfo.get(t)))}getProductInfoByItemId({wishlistItemId:t}){return r(p(()=>this.productInfo.where("wishlistItemIds").equals(t).first()))}getProductInfos(){return r(p(()=>this.productInfo.toArray()))}getWishlist({wishlistId:t}){return r(p(()=>this.wishlists.get(t)))}getWishlistItems(){return r(p(()=>this.wishlistItems.toArray()))}getShopifyProduct({productHandle:t}){return r(p(()=>this.shopifyProducts.get(t)))}getWishlistItem({wishlistItemId:t}){return r(p(()=>this.wishlistItems.get(t)))}addItemToWishlist({productId:t,variantId:i}){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfo({productId:t})]).pipe(f(([e,s])=>{let h={id:`temp-${T()}`},m=R({wishlistId:"mine",item:h},e),I=()=>this.wishlists.put(m),o=()=>e?this.wishlists.put(e):this.wishlists.delete("mine"),l=()=>this.productInfo.put(c({productInfo:{productId:t,wishlistItems:s?[...s.wishlistItems,{id:h.id,variantId:i}]:[{id:h.id,variantId:i}]}})),a=()=>s?this.productInfo.put(s):this.productInfo.delete(t);return r(p(()=>this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([I(),l()])))).pipe(u(()=>({wishlist:m,item:h,revertStateUpdate:()=>r(this.transaction("rw",this.wishlists,this.productInfo,()=>Promise.all([o(),a()])))})))}))}removeItemFromWishlist({wishlistItemId:t}){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t}),this.getWishlistItem({wishlistItemId:t})]).pipe(f(([i,e,s])=>{let h=B({wishlistItemId:t},i),m=()=>this.wishlists.put(h),I=()=>i?this.wishlists.put(i):this.wishlists.delete("mine"),o=()=>{if(e)return this.productInfo.put(c({productInfo:{productId:e.productId,wishlistItems:e.wishlistItems.filter(y=>y.id!==t)}}))},l=()=>{if(e)return this.productInfo.put(e)},a=()=>{if(s)return this.wishlistItems.delete(s.id)},g=()=>{if(s)return this.wishlistItems.put(s)};return r(p(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([m(),o(),a()])))).pipe(u(()=>({wishlist:h,revertStateUpdate:()=>r(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([I(),l(),g()])))})))}))}clearWishlist(){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfos(),this.getWishlistItems()]).pipe(f(([t,i,e])=>{let s=D(t),h=()=>{if(s)return this.wishlists.put(s)},m=()=>{var g;return t?this.wishlists.put(t):this.wishlists.delete((g=s==null?void 0:s.id)!=null?g:"mine")},I=()=>this.productInfo.clear(),o=()=>{if(i)return this.productInfo.bulkPut(i)},l=()=>this.wishlistItems.clear(),a=()=>{if(e)return this.wishlistItems.bulkPut(e)};return r(p(()=>this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([h(),I(),l()])))).pipe(u(()=>({wishlist:s,revertStateUpdate:()=>r(this.transaction("rw",this.wishlists,this.productInfo,this.wishlistItems,()=>Promise.all([m(),o(),a()])))})))}))}updateWishlistItem({wishlistItemId:t,changes:i}){return w([this.getWishlistItem({wishlistItemId:t}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(f(([e,s])=>{let h=()=>{if(e)return this.wishlistItems.put({...e,selectedVariantId:i.variantId})},m=()=>{if(e)return this.wishlistItems.put(e)},I=()=>{if(s)return this.productInfo.put(c({productInfo:{...s,wishlistItems:s.wishlistItems.map(l=>l.id===t?{...l,variantId:i.variantId}:l)}}))},o=()=>{if(s)return this.productInfo.put(s)};return r(p(()=>this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([h(),I()])))).pipe(u(()=>({revertStateUpdate:()=>r(this.transaction("rw",this.wishlistItems,this.productInfo,()=>Promise.all([m(),o()])))})))}))}changeWishlistItemRef({wishlistItemId:t,changes:i}){return w([this.getWishlist({wishlistId:"mine"}),this.getProductInfoByItemId({wishlistItemId:t})]).pipe(f(([e,s])=>{let h={id:i.id},m=()=>{var o;if(e)return this.wishlists.put({...e,items:(o=e.items)==null?void 0:o.map(l=>l.id===t?h:l)})},I=()=>{if(s)return this.productInfo.put(c({productInfo:{...s,wishlistItems:s.wishlistItems.map(o=>o.id===t?{...o,id:i.id}:o)}}))};return r(Promise.all([m(),I()])).pipe(u(()=>({item:h})))}))}liveQuery(t){return new U(i=>{x(t).subscribe({error:i.error.bind(i),next:i.next.bind(i),complete:i.complete.bind(i)})})}},R=(d,n)=>n?{...n,numItems:n.numItems+1,items:n.items?[...n.items,d.item]:[d.item]}:{id:d.wishlistId,publicId:void 0,isMine:!0,numItems:1,items:[d.item]},B=(d,n)=>n?{...n,numItems:n.numItems-1,items:n.items?S(n.items,d):[]}:{id:"mine",publicId:void 0,isMine:!0,numItems:0},D=d=>{if(!!d)return{...d,numItems:0,items:[]}};export{W as CacheDatabase};

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

import{defer as W,forkJoin as g,from as b,of as d,throwError as y}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{switchMap as o,map as l,catchError as p,mergeWith as f,startWith as P,distinctUntilChanged as m,shareReplay as I,tap as S}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";import{CacheDatabase as R}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/state/cache-database.js";import{addProductToWishlistItem as D,findProductVariant as q,mapApiToProductInfo as v,mapApiToWishlist as $,mapApiToWishlistItem as A,filterNullish as w}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/state/state-util.js";var C=class{constructor({wishlistApi:i,shopifyApi:s,settings:h,events:a,utils:e}){this.cacheDb=new R;this.cacheDb.open(),this.wishlistApi=i,this.shopifyApi=s,this.settings=h,this.loadWishlistCache=new Map,this.loadWishlistItemCache=new Map,this.loadProductInfoCache=new Map,this.loadShopifyProductCache=new Map,this.events=a,this.utils=e}loadWishlist({wishlistId:i,format:s,strategy:h="network-only"}){let a=[i,s].join("-");if(!this.loadWishlistCache.has(a)){let r=this.wishlistApi.loadWishlist({wishlistId:i,format:s}),t=n=>this.cacheDb.storeWishlist({wishlist:n}).pipe(l(()=>$(n,s)));this.loadWishlistCache.set(a,r.pipe(o(({wishlist:n})=>t(n)),I()))}let e=this.loadWishlistCache.get(a);return h==="cache-first"?this.cacheDb.getWishlist({wishlistId:i}).pipe(o(r=>r?d(r):e)):e}observeWishlist({wishlistId:i,format:s}){let h={id:i,isMine:i==="mine",numItems:0,items:void 0};try{i==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(r){return d(h)}let a=this.loadWishlist({wishlistId:i,format:s}),e=this.cacheDb.liveQuery(()=>this.cacheDb.wishlists.get(i));return a.pipe(f(e),P(s==="minimal"?h:null),w(),m((r,t)=>JSON.stringify(r)===JSON.stringify(t)))}loadProductInfo({productId:i,variantId:s=0,strategy:h}){if(this.throwIfLoginRequired("wishlist:private:load"),!this.loadProductInfoCache.has(i)){let e=this.wishlistApi.loadProductInfo({productId:i}),r=t=>this.cacheDb.storeProductInfo({productInfo:t});this.loadProductInfoCache.set(i,e.pipe(o(({productInfo:t})=>r(t).pipe(l(()=>v({productInfo:t,variantId:s,wishlistMode:this.settings.wishlistMode})))),I()))}let a=this.loadProductInfoCache.get(i);return h==="cache-first"?this.cacheDb.getProductInfo({productId:i}).pipe(o(e=>e?d(v({productInfo:e,variantId:s,wishlistMode:this.settings.wishlistMode})):a)):a}observeProductInfo({productHandle:i,productId:s,variantId:h,strategy:a}){let e={productId:s!=null?s:0,variantId:h,inWishlist:!1};try{this.throwIfLoginRequired("wishlist:private:load")}catch(c){return d(e)}let r=s?d(s):this.loadShopifyProduct({productHandle:i,strategy:"cache-first"}).pipe(l(c=>c.id)),t=r.pipe(o(c=>this.loadProductInfo({productId:c,strategy:a}))),n=r.pipe(o(c=>this.cacheDb.liveQuery(()=>this.cacheDb.productInfo.get(c)).pipe(l(u=>u?v({productInfo:u,variantId:h,wishlistMode:this.settings.wishlistMode}):e))));return a==="cache-first"?n.pipe(o(c=>c?d(c):t),m((c,u)=>JSON.stringify(c)===JSON.stringify(u)),p(c=>(console.error(c),d(e)))):t.pipe(f(n),w(),m((c,u)=>JSON.stringify(c)===JSON.stringify(u)),p(c=>(console.error(c),d(e))))}loadWishlistItem({wishlistId:i,wishlistItemId:s,strategy:h}){let a=s;if(!this.loadWishlistItemCache.has(a)){let r=this.wishlistApi.loadWishlistItem({wishlistId:i,wishlistItemId:s}),t=n=>this.cacheDb.storeWishlistItem({wishlistItem:n}).pipe(l(()=>A(n)));this.loadWishlistItemCache.set(a,r.pipe(o(({wishlistItem:n})=>t(n)),I()))}let e=this.loadWishlistItemCache.get(a);return h==="cache-first"?this.cacheDb.getWishlistItem({wishlistItemId:s}).pipe(o(r=>r?d(r):e)):e}observeWishlistItem({wishlistId:i,wishlistItemId:s}){let h={id:s,product:{id:0,handle:"",hidden:!1}};try{i==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(t){return d(h)}let a=this.loadWishlistItem({wishlistId:i,wishlistItemId:s}),e=this.cacheDb.liveQuery(()=>this.cacheDb.wishlistItems.get(s)).pipe(l(t=>t?A(t):null)),r=t=>!t.product.handle||t.product.hidden?d(t):this.observeShopifyProduct({productHandle:t.product.handle}).pipe(l(n=>D(t,n)));return a.pipe(P(h),f(e),w(),o(t=>r(t)),m((t,n)=>JSON.stringify(t)===JSON.stringify(n)))}loadShopifyProduct({productHandle:i,strategy:s}){let h=i;if(!this.loadShopifyProductCache.has(h)){let e=this.shopifyApi.loadProduct({productHandle:i}),r=t=>this.cacheDb.storeShopifyProduct({product:t}).pipe(l(()=>t));this.loadShopifyProductCache.set(h,e.pipe(o(t=>r(t)),I()))}let a=this.loadShopifyProductCache.get(h);return s==="cache-first"?this.cacheDb.getShopifyProduct({productHandle:i}).pipe(o(e=>e?d(e):a)):a}observeShopifyProduct({productHandle:i}){let s=this.loadShopifyProduct({productHandle:i}),h=this.cacheDb.liveQuery(()=>this.cacheDb.shopifyProducts.get(i));return s.pipe(f(h),w(),m((a,e)=>JSON.stringify(a)===JSON.stringify(e)))}loadWishlistProduct({wishlistId:i,wishlistItemId:s}){return i==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load"),this.loadWishlistItem({wishlistId:i,wishlistItemId:s}).pipe(o(h=>this.loadShopifyProduct({productHandle:h.product.handle})))}addWishlistItem(i){this.throwIfLoginRequired("wishlist:private:add");let s=typeof i.productId=="string"?parseInt(i.productId):i.productId,h=typeof i.variantId=="string"?parseInt(i.variantId):i.variantId,a=this.cacheDb.addItemToWishlist({productId:s,variantId:h}),e=this.wishlistApi.addItem({productId:s,variantId:h});return a.pipe(o(({item:r,revertStateUpdate:t})=>e.pipe(o(({wishlistItem:n})=>g([this.cacheDb.storeWishlistItem({wishlistItem:n}),this.cacheDb.changeWishlistItemRef({wishlistItemId:r.id,changes:{id:n.id}})]).pipe(l(()=>({wishlistItem:n})))),o(n=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add:success",productHandle:n.wishlistItem.product.handle,variantId:n.wishlistItem.selectedVariantId}).pipe(l(()=>n))),p(n=>(console.error(n),this.events.publish({name:"wk:wishlist:add:error",error:n}),t())))))}updateWishlistItem(i){this.throwIfLoginRequired("wishlist:private:change-variant");let s={variantId:typeof i.changes.variantId=="string"?parseInt(i.changes.variantId):i.changes.variantId},h=this.cacheDb.updateWishlistItem({wishlistItemId:i.wishlistItemId,changes:s}),a=this.wishlistApi.updateItem({wishlistItemId:i.wishlistItemId,changes:s});return h.pipe(o(({revertStateUpdate:e})=>a.pipe(o(r=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:change-variant:success",productHandle:r.wishlistItem.product.handle,variantId:r.wishlistItem.selectedVariantId}).pipe(l(()=>r))),p(r=>(console.error(r),this.events.publish({name:"wk:wishlist:change-variant:error",error:r}),e())))))}removeWishlistItem({wishlistItemId:i}){this.throwIfLoginRequired("wishlist:private:remove");let s=this.cacheDb.removeItemFromWishlist({wishlistItemId:i}),h=this.wishlistApi.removeItem({wishlistId:"mine",wishlistItemId:i});return s.pipe(o(({wishlist:a,revertStateUpdate:e})=>h.pipe(l(({wishlistItem:r})=>({wishlist:a,wishlistItem:r})),o(r=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:remove:success",productHandle:r.wishlistItem.product.handle,variantId:r.wishlistItem.selectedVariantId}).pipe(l(()=>r))),p(r=>(console.error(r),this.events.publish({name:"wk:wishlist:remove:error",error:r}),e())))))}clearWishlist(){this.throwIfLoginRequired("wishlist:private:clear");let i=this.cacheDb.clearWishlist(),s=this.wishlistApi.clearWishlist();return i.pipe(o(({revertStateUpdate:h})=>s.pipe(o(()=>this.publishWishlistEvent({wishlistId:"mine",eventName:"wk:wishlist:clear:success"})),p(a=>(console.error(a),this.events.publish({name:"wk:wishlist:clear:error",error:a}),h())))))}addToCart({wishlistId:i,wishlistItemId:s,variantId:h,quantity:a=1,sectionsToRender:e,sectionsUrl:r}){return i==="mine"?this.throwIfLoginRequired("wishlist:private:add-to-cart"):this.throwIfLoginRequired("wishlist:public:add-to-cart"),this.shopifyApi.addToCart({id:h,quantity:a,sections:e,sections_url:r}).pipe(o(t=>g([this.loadWishlist({wishlistId:i,format:"minimal"}),this.loadWishlistItem({wishlistId:i,wishlistItemId:s})]).pipe(l(([n,c])=>({wishlistItem:c,cartResponse:t,wishlist:n})))),o(t=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add-to-cart:success",productHandle:t.wishlistItem.product.handle,variantId:t.wishlistItem.selectedVariantId}).pipe(l(()=>t))),p(t=>(this.events.publish({name:"wk:wishlist:add-to-cart:error",error:t}),y(()=>t))),o(t=>this.settings.moveToCart&&t.wishlist.isMine?this.removeWishlistItem({wishlistItemId:s}).pipe(l(()=>t)):d(t)))}addAllToCart({wishlistId:i,sectionsToRender:s,sectionsUrl:h}){let a=i==="mine";return a?this.throwIfLoginRequired("wishlist:private:add-to-cart"):this.throwIfLoginRequired("wishlist:public:add-to-cart"),this.loadWishlist({wishlistId:i,format:"all"}).pipe(o(e=>{var r,t;return this.wishlistApi.loadWishlistItems({wishlistId:e.id,wishlistItemIds:(t=(r=e.items)==null?void 0:r.map(n=>n.id))!=null?t:[]})}),o(({items:e})=>{var r;return this.shopifyApi.addToCart({items:(r=e.filter(t=>!t.hidden&&!!t.selectedVariantId).map(t=>({id:t.selectedVariantId,quantity:1})))!=null?r:[],sections:s,sections_url:h})}),o(e=>this.settings.moveToCart&&a?this.clearWishlist().pipe(l(()=>({cartResponse:e}))):d({cartResponse:e}))).pipe(o(e=>this.publishWishlistEvent({wishlistId:"mine",eventName:"wk:wishlist:add-all-to-cart:success"}).pipe(l(()=>e))),p(e=>(this.events.publish({name:"wk:wishlist:add-all-to-cart:error",error:e}),y(()=>e))))}shareWishlist({wishlistId:i,title:s,text:h}){i==="mine"?this.throwIfLoginRequired("wishlist:private:share"):this.throwIfLoginRequired("wishlist:public:share");let a={url:this.utils.url.getPublicWishlistUrl(i),title:s,text:h},e=b(W(async()=>{try{await navigator.share(a)}catch(t){throw new Error("Web share api not available")}}).pipe(o(()=>this.publishWishlistEvent({wishlistId:i,eventName:"wk:wishlist:share:success"})),l(()=>({webShare:!0,clipboard:!1})))),r=b(W(async()=>{try{await navigator.clipboard.writeText(a.url)}catch(t){throw new Error("Web clipboard api not available")}}).pipe(o(()=>this.publishWishlistEvent({wishlistId:i,eventName:"wk:wishlist:share:success"})),l(()=>({webShare:!1,clipboard:!0}))));return e.pipe(p(()=>r.pipe(p(t=>(this.events.publish({name:"wk:wishlist:share:error",error:t}),d({webShare:!1,clipboard:!1}))))))}publishWishlistItemEvent({eventName:i,wishlistId:s,productHandle:h,variantId:a}){return g([this.loadWishlist({wishlistId:s,format:"minimal",strategy:"cache-first"}),this.loadShopifyProduct({productHandle:h,strategy:"cache-first"})]).pipe(S(([e,r])=>this.events.publish({name:i,data:{wishlist:e,product:r,variant:q(r,a),quantity:1}})))}publishWishlistEvent({eventName:i,wishlistId:s}){return this.loadWishlist({wishlistId:s,format:"minimal",strategy:"cache-first"}).pipe(S(h=>this.events.publish({name:i,data:{wishlist:h}})))}throwIfLoginRequired(i){var h;if(!this.settings.loginRequired)return;if(!this.settings.loginActions&&i.includes("private")||((h=this.settings.loginActions)==null?void 0:h.includes(i)))throw this.events.publish({name:"wk:wishlist:login-required",data:{action:i}}),new Error("Wishlist requires login")}};export{C as WishlistState};
import{defer as W,forkJoin as g,from as b,of as d,throwError as y}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{switchMap as o,map as l,catchError as p,mergeWith as f,startWith as P,distinctUntilChanged as m,shareReplay as I,tap as S}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";import{CacheDatabase as R}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/state/cache-database.js";import{addProductToWishlistItem as D,findProductVariant as q,mapApiToProductInfo as v,mapApiToWishlist as $,mapApiToWishlistItem as A,filterNullish as w}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/state/state-util.js";var C=class{constructor({wishlistApi:i,shopifyApi:s,settings:h,events:a,utils:e}){this.cacheDb=new R;this.cacheDb.open(),this.wishlistApi=i,this.shopifyApi=s,this.settings=h,this.loadWishlistCache=new Map,this.loadWishlistItemCache=new Map,this.loadProductInfoCache=new Map,this.loadShopifyProductCache=new Map,this.events=a,this.utils=e}loadWishlist({wishlistId:i,format:s,strategy:h="network-only"}){let a=[i,s].join("-");if(!this.loadWishlistCache.has(a)){let r=this.wishlistApi.loadWishlist({wishlistId:i,format:s}),t=n=>this.cacheDb.storeWishlist({wishlist:n}).pipe(l(()=>$(n,s)));this.loadWishlistCache.set(a,r.pipe(o(({wishlist:n})=>t(n)),I()))}let e=this.loadWishlistCache.get(a);return h==="cache-first"?this.cacheDb.getWishlist({wishlistId:i}).pipe(o(r=>r?d(r):e)):e}observeWishlist({wishlistId:i,format:s}){let h={id:i,isMine:i==="mine",numItems:0,items:void 0};try{i==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(r){return d(h)}let a=this.loadWishlist({wishlistId:i,format:s}),e=this.cacheDb.liveQuery(()=>this.cacheDb.wishlists.get(i));return a.pipe(f(e),P(s==="minimal"?h:null),w(),m((r,t)=>JSON.stringify(r)===JSON.stringify(t)))}loadProductInfo({productId:i,variantId:s=0,strategy:h}){if(this.throwIfLoginRequired("wishlist:private:load"),!this.loadProductInfoCache.has(i)){let e=this.wishlistApi.loadProductInfo({productId:i}),r=t=>this.cacheDb.storeProductInfo({productInfo:t});this.loadProductInfoCache.set(i,e.pipe(o(({productInfo:t})=>r(t).pipe(l(()=>v({productInfo:t,variantId:s,wishlistMode:this.settings.wishlistMode})))),I()))}let a=this.loadProductInfoCache.get(i);return h==="cache-first"?this.cacheDb.getProductInfo({productId:i}).pipe(o(e=>e?d(v({productInfo:e,variantId:s,wishlistMode:this.settings.wishlistMode})):a)):a}observeProductInfo({productHandle:i,productId:s,variantId:h,strategy:a}){let e={productId:s!=null?s:0,variantId:h,inWishlist:!1};try{this.throwIfLoginRequired("wishlist:private:load")}catch(c){return d(e)}let r=s?d(s):this.loadShopifyProduct({productHandle:i,strategy:"cache-first"}).pipe(l(c=>c.id)),t=r.pipe(o(c=>this.loadProductInfo({productId:c,strategy:a}))),n=r.pipe(o(c=>this.cacheDb.liveQuery(()=>this.cacheDb.productInfo.get(c)).pipe(l(u=>u?v({productInfo:u,variantId:h,wishlistMode:this.settings.wishlistMode}):e))));return a==="cache-first"?n.pipe(o(c=>c?d(c):t),m((c,u)=>JSON.stringify(c)===JSON.stringify(u)),p(c=>(console.error(c),d(e)))):t.pipe(f(n),w(),m((c,u)=>JSON.stringify(c)===JSON.stringify(u)),p(c=>(console.error(c),d(e))))}loadWishlistItem({wishlistId:i,wishlistItemId:s,strategy:h}){let a=s;if(!this.loadWishlistItemCache.has(a)){let r=this.wishlistApi.loadWishlistItem({wishlistId:i,wishlistItemId:s}),t=n=>this.cacheDb.storeWishlistItem({wishlistItem:n}).pipe(l(()=>A(n)));this.loadWishlistItemCache.set(a,r.pipe(o(({wishlistItem:n})=>t(n)),I()))}let e=this.loadWishlistItemCache.get(a);return h==="cache-first"?this.cacheDb.getWishlistItem({wishlistItemId:s}).pipe(o(r=>r?d(r):e)):e}observeWishlistItem({wishlistId:i,wishlistItemId:s}){let h={id:s,product:{id:0,handle:"",hidden:!1}};try{i==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load")}catch(t){return d(h)}let a=this.loadWishlistItem({wishlistId:i,wishlistItemId:s}),e=this.cacheDb.liveQuery(()=>this.cacheDb.wishlistItems.get(s)).pipe(l(t=>t?A(t):null)),r=t=>!t.product.handle||t.product.hidden?d(t):this.observeShopifyProduct({productHandle:t.product.handle}).pipe(l(n=>D(t,n)));return a.pipe(P(h),f(e),w(),o(t=>r(t)),m((t,n)=>JSON.stringify(t)===JSON.stringify(n)))}loadShopifyProduct({productHandle:i,strategy:s}){let h=i;if(!this.loadShopifyProductCache.has(h)){let e=this.shopifyApi.loadProduct({productHandle:i}),r=t=>this.cacheDb.storeShopifyProduct({product:t}).pipe(l(()=>t));this.loadShopifyProductCache.set(h,e.pipe(o(t=>r(t)),I()))}let a=this.loadShopifyProductCache.get(h);return s==="cache-first"?this.cacheDb.getShopifyProduct({productHandle:i}).pipe(o(e=>e?d(e):a)):a}observeShopifyProduct({productHandle:i}){let s=this.loadShopifyProduct({productHandle:i}),h=this.cacheDb.liveQuery(()=>this.cacheDb.shopifyProducts.get(i));return s.pipe(f(h),w(),m((a,e)=>JSON.stringify(a)===JSON.stringify(e)))}loadWishlistProduct({wishlistId:i,wishlistItemId:s}){return i==="mine"?this.throwIfLoginRequired("wishlist:private:load"):this.throwIfLoginRequired("wishlist:public:load"),this.loadWishlistItem({wishlistId:i,wishlistItemId:s}).pipe(o(h=>this.loadShopifyProduct({productHandle:h.product.handle})))}addWishlistItem(i){this.throwIfLoginRequired("wishlist:private:add");let s=typeof i.productId=="string"?parseInt(i.productId):i.productId,h=typeof i.variantId=="string"?parseInt(i.variantId):i.variantId,a=this.cacheDb.addItemToWishlist({productId:s,variantId:h}),e=this.wishlistApi.addItem({productId:s,variantId:h});return a.pipe(o(({item:r,revertStateUpdate:t})=>e.pipe(o(({wishlistItem:n})=>g([this.cacheDb.storeWishlistItem({wishlistItem:n}),this.cacheDb.changeWishlistItemRef({wishlistItemId:r.id,changes:{id:n.id}})]).pipe(l(()=>({wishlistItem:n})))),o(n=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add:success",productHandle:n.wishlistItem.product.handle,variantId:n.wishlistItem.selectedVariantId}).pipe(l(()=>n))),p(n=>(console.error(n),this.events.publish({name:"wk:wishlist:add:error",error:n}),t())))))}updateWishlistItem(i){this.throwIfLoginRequired("wishlist:private:change-variant");let s={variantId:typeof i.changes.variantId=="string"?parseInt(i.changes.variantId):i.changes.variantId},h=this.cacheDb.updateWishlistItem({wishlistItemId:i.wishlistItemId,changes:s}),a=this.wishlistApi.updateItem({wishlistItemId:i.wishlistItemId,changes:s});return h.pipe(o(({revertStateUpdate:e})=>a.pipe(o(r=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:change-variant:success",productHandle:r.wishlistItem.product.handle,variantId:r.wishlistItem.selectedVariantId}).pipe(l(()=>r))),p(r=>(console.error(r),this.events.publish({name:"wk:wishlist:change-variant:error",error:r}),e())))))}removeWishlistItem({wishlistItemId:i}){this.throwIfLoginRequired("wishlist:private:remove");let s=this.cacheDb.removeItemFromWishlist({wishlistItemId:i}),h=this.wishlistApi.removeItem({wishlistId:"mine",wishlistItemId:i});return s.pipe(o(({wishlist:a,revertStateUpdate:e})=>h.pipe(l(({wishlistItem:r})=>({wishlist:a,wishlistItem:r})),o(r=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:remove:success",productHandle:r.wishlistItem.product.handle,variantId:r.wishlistItem.selectedVariantId}).pipe(l(()=>r))),p(r=>(console.error(r),this.events.publish({name:"wk:wishlist:remove:error",error:r}),e())))))}clearWishlist(){this.throwIfLoginRequired("wishlist:private:clear");let i=this.cacheDb.clearWishlist(),s=this.wishlistApi.clearWishlist();return i.pipe(o(({revertStateUpdate:h})=>s.pipe(o(()=>this.publishWishlistEvent({wishlistId:"mine",eventName:"wk:wishlist:clear:success"})),p(a=>(console.error(a),this.events.publish({name:"wk:wishlist:clear:error",error:a}),h())))))}addToCart({wishlistId:i,wishlistItemId:s,variantId:h,quantity:a=1,sectionsToRender:e,sectionsUrl:r}){return i==="mine"?this.throwIfLoginRequired("wishlist:private:add-to-cart"):this.throwIfLoginRequired("wishlist:public:add-to-cart"),this.shopifyApi.addToCart({id:h,quantity:a,sections:e,sections_url:r}).pipe(o(t=>g([this.loadWishlist({wishlistId:i,format:"minimal"}),this.loadWishlistItem({wishlistId:i,wishlistItemId:s})]).pipe(l(([n,c])=>({wishlistItem:c,cartResponse:t,wishlist:n})))),o(t=>this.publishWishlistItemEvent({wishlistId:"mine",eventName:"wk:wishlist:add-to-cart:success",productHandle:t.wishlistItem.product.handle,variantId:t.wishlistItem.selectedVariantId}).pipe(l(()=>t))),p(t=>(this.events.publish({name:"wk:wishlist:add-to-cart:error",error:t}),y(()=>t))),o(t=>this.settings.moveToCart&&t.wishlist.isMine?this.removeWishlistItem({wishlistItemId:s}).pipe(l(()=>t)):d(t)))}addAllToCart({wishlistId:i,sectionsToRender:s,sectionsUrl:h}){let a=i==="mine";return a?this.throwIfLoginRequired("wishlist:private:add-to-cart"):this.throwIfLoginRequired("wishlist:public:add-to-cart"),this.loadWishlist({wishlistId:i,format:"all"}).pipe(o(e=>{var r,t;return this.wishlistApi.loadWishlistItems({wishlistId:e.id,wishlistItemIds:(t=(r=e.items)==null?void 0:r.map(n=>n.id))!=null?t:[]})}),o(({items:e})=>{var r;return this.shopifyApi.addToCart({items:(r=e.filter(t=>!t.hidden&&!!t.selectedVariantId).map(t=>({id:t.selectedVariantId,quantity:1})))!=null?r:[],sections:s,sections_url:h})}),o(e=>this.settings.moveToCart&&a?this.clearWishlist().pipe(l(()=>({cartResponse:e}))):d({cartResponse:e}))).pipe(o(e=>this.publishWishlistEvent({wishlistId:"mine",eventName:"wk:wishlist:add-all-to-cart:success"}).pipe(l(()=>e))),p(e=>(this.events.publish({name:"wk:wishlist:add-all-to-cart:error",error:e}),y(()=>e))))}shareWishlist({wishlistId:i,title:s,text:h}){i==="mine"?this.throwIfLoginRequired("wishlist:private:share"):this.throwIfLoginRequired("wishlist:public:share");let a={url:this.utils.url.getPublicWishlistUrl(i),title:s,text:h},e=b(W(async()=>{try{await navigator.share(a)}catch(t){throw new Error("Web share api not available")}}).pipe(o(()=>this.publishWishlistEvent({wishlistId:i,eventName:"wk:wishlist:share:success"})),l(()=>({webShare:!0,clipboard:!1})))),r=b(W(async()=>{try{await navigator.clipboard.writeText(a.url)}catch(t){throw new Error("Web clipboard api not available")}}).pipe(o(()=>this.publishWishlistEvent({wishlistId:i,eventName:"wk:wishlist:share:success"})),l(()=>({webShare:!1,clipboard:!0}))));return e.pipe(p(()=>r.pipe(p(t=>(this.events.publish({name:"wk:wishlist:share:error",error:t}),d({webShare:!1,clipboard:!1}))))))}publishWishlistItemEvent({eventName:i,wishlistId:s,productHandle:h,variantId:a}){return g([this.loadWishlist({wishlistId:s,format:"minimal",strategy:"cache-first"}),this.loadShopifyProduct({productHandle:h,strategy:"cache-first"})]).pipe(S(([e,r])=>this.events.publish({name:i,data:{wishlist:e,product:r,variant:q(r,a),quantity:1}})))}publishWishlistEvent({eventName:i,wishlistId:s}){return this.loadWishlist({wishlistId:s,format:"minimal",strategy:"cache-first"}).pipe(S(h=>this.events.publish({name:i,data:{wishlist:h}})))}throwIfLoginRequired(i){var h;if(!this.settings.loginRequired)return;if(!this.settings.loginActions&&i.includes("private")||((h=this.settings.loginActions)==null?void 0:h.includes(i)))throw this.events.publish({name:"wk:wishlist:login-required",data:{action:i}}),new Error("Wishlist requires login")}};export{C as WishlistState};

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

import{ThemeObserver as o}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/theme-observer.js";var m=class{constructor({routeUtil:a}){this.observer=new o({routeUtil:a}),this.watch=this.observer.watch.bind(this.observer)}createComponent(a,e){let t=document.createElement(a);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,s])=>{!s||(typeof s=="boolean"?t.dataset[r]="":typeof s=="object"?t.dataset[r]=JSON.stringify(s):t.dataset[r]=s)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,s])=>{t[r]=s}),t}createElement(a,e={},...t){let r=Object.assign(document.createElement(a),e);return t&&r.append(...t),r}};export{m as DomUtil};
import{ThemeObserver as o}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/theme-observer.js";var m=class{constructor({routeUtil:a}){this.observer=new o({routeUtil:a}),this.watch=this.observer.watch.bind(this.observer)}createComponent(a,e){let t=document.createElement(a);return e!=null&&e.dataset&&Object.entries(e==null?void 0:e.dataset).forEach(([r,s])=>{!s||(typeof s=="boolean"?t.dataset[r]="":typeof s=="object"?t.dataset[r]=JSON.stringify(s):t.dataset[r]=s)}),e!=null&&e.props&&Object.entries(e==null?void 0:e.props).forEach(([r,s])=>{t[r]=s}),t}createElement(a,e={},...t){let r=Object.assign(document.createElement(a),e);return t&&r.append(...t),r}};export{m as DomUtil};

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

import*as t from"https://cdn.jsdelivr.net/npm/@shopify@undefined/theme-currency/+esm";var e=class{constructor(r){this.moneyFormat=r.moneyFormat,this.currencyRate=r.currencyRate,this.activeCurrency=r.activeCurrency}formatMoney(r){return typeof r=="string"&&(r=parseFloat(r)),t.formatMoney(r,this.moneyFormat)}};export{e as MoneyUtil};
import*as t from"https://cdn.jsdelivr.net/npm/@shopify/theme-currency@4.1.1/+esm";var e=class{constructor(r){this.moneyFormat=r.moneyFormat,this.currencyRate=r.currencyRate,this.activeCurrency=r.activeCurrency}formatMoney(r){return typeof r=="string"&&(r=parseFloat(r)),t.formatMoney(r,this.moneyFormat)}};export{e as MoneyUtil};

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

import{lastValueFrom as o}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{ShopifyApi as p}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/shopify-api.js";import{WishlistApi as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/wishlist-api.js";import{TrackingApi as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/api/tracking-api.js";import{WishlistState as f}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/state/wishlist-state.js";import{getSessionId as m}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/state/state-util.js";import{RouteUtil as y}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/route-util.js";import{LocaleUtil as W}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/locale-util.js";import{MoneyUtil as P}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/money-util.js";import{UrlUtil as w}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/url-util.js";import{ProductUtil as U}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/product-util.js";import{WishlistEvents as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/wishlist-events.js";import{DomUtil as I}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/util/dom-util.js";var d=class{constructor({settings:t,stylesheets:a,...i}){this.stylesLoaded=!1;var r,e;this.config=this.parseConfig(i),this.settings={...t,loginRequired:!!t.loginRequired&&!this.config.customer.id},this.events=new v,this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.utils=this.initUtils(),this.apis={wishlist:new u({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:m(),trackingSource:this.utils.route.parse(window.location.pathname).pageType}),shopify:new p({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new g({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(e=this.config.customer.id)!=null?e:void 0,sessionId:m(),utils:this.utils,settings:t})},this.state=new f({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this.addToCart=(...s)=>o(this.state.addToCart(...s)),this.addAllToCart=(...s)=>o(this.state.addAllToCart(...s)),this.addWishlistItem=(...s)=>o(this.state.addWishlistItem(...s)),this.clearWishlist=(...s)=>o(this.state.clearWishlist(...s)),this.loadProductInfo=(...s)=>o(this.state.loadProductInfo(...s)),this.loadShopifyProduct=(...s)=>o(this.state.loadShopifyProduct(...s)),this.loadWishlist=(...s)=>o(this.state.loadWishlist(...s)),this.loadWishlistItem=(...s)=>o(this.state.loadWishlistItem(...s)),this.loadWishlistProduct=(...s)=>o(this.state.loadWishlistProduct(...s)),this.publishWishlistEvent=(...s)=>o(this.state.publishWishlistEvent(...s)),this.publishWishlistItemEvent=(...s)=>o(this.state.publishWishlistItemEvent(...s)),this.removeWishlistItem=(...s)=>o(this.state.removeWishlistItem(...s)),this.shareWishlist=(...s)=>o(this.state.shareWishlist(...s)),this.updateWishlistItem=(...s)=>o(this.state.updateWishlistItem(...s)),this.initStyles(a),this.initUrlChangeEvents(),this.trackCurrentPage(),requestAnimationFrame(()=>{this.events.publish({name:"wk:app:ready"})})}async initStyles(t){if(!(t!=null&&t.length)){this.onStylesLoaded();return}try{await Promise.all(t.map(a=>new Promise((i,r)=>{let e=document.createElement("link");e.rel="stylesheet",e.href=a,e.onload=i,e.onerror=r,document.head.appendChild(e)}))),this.onStylesLoaded()}catch(a){console.warn(a),this.events.publish({name:"wk:app:load-styles:error"})}}trackCurrentPage(){let t=this.utils.route.parse(window.location.pathname).pageType;if(t!=null&&t.includes("wishlist")){let a=this.utils.url.getWishlistIdFromUrl(window.location.pathname);a&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:a})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUtils(){let t=this.config.shop.domain,a=this.config.products.fallbackImage,i=this.config.shop.moneyFormat,r=this.config.locale,e=new y({wishlistUrl:this.routes.wishlistUrl});return{url:new w({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:t,placeholderImageUrl:a,fileUrl:this.routes.fileUrl}),money:new P({moneyFormat:i,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),product:new U,locale:new W({locale:r}),route:e,dom:new I({routeUtil:e})}}initUrlChangeEvents(){let t=history.replaceState,a=({productHandle:i,variantId:r})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:i,variantId:r}})};history.replaceState=(...i)=>{let r=`${window.location.protocol}//${window.location.host}`,e=typeof i[2]=="string"?new URL(i[2],r):i[2],s=t.apply(history,i);if(!e)return s;let l=this.utils.url.getProductHandleFromUrl(e),n=e.searchParams.get("variant");if(!l||!n)return s;a({productHandle:l,variantId:parseInt(n)})}}parseConfig({config:t,locale:a}){var i,r,e,s,l,n,h,c;return{customer:{id:t.customerId?parseInt(t.customerId):null,email:(i=t.customerEmail)!=null?i:""},shop:{name:(r=t.shopName)!=null?r:"",domain:(e=t.shopDomain)!=null?e:"",permanentDomain:(s=t.shopPermanentDomain)!=null?s:"",currency:(l=t.shopCurrency)!=null?l:"",moneyFormat:(n=t.shopMoneyFormat)!=null?n:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(h=t.apiHost)!=null?h:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(c=t.productFallbackImage)!=null?c:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:a}}parseRoutes(){var i;let t=this.config.routes.rootUrl,a=(i=this.settings.wishlistPath)!=null?i:"/apps/wishlist";return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+a.split("/").filter(r=>!!r).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}};export{d as WishlistApp};
import{lastValueFrom as o}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{ShopifyApi as p}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/shopify-api.js";import{WishlistApi as u}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/wishlist-api.js";import{TrackingApi as g}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/api/tracking-api.js";import{WishlistState as f}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/state/wishlist-state.js";import{getSessionId as m}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/state/state-util.js";import{RouteUtil as y}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/route-util.js";import{LocaleUtil as W}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/locale-util.js";import{MoneyUtil as P}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/money-util.js";import{UrlUtil as w}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/url-util.js";import{ProductUtil as U}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/product-util.js";import{WishlistEvents as v}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/wishlist-events.js";import{DomUtil as I}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/util/dom-util.js";var d=class{constructor({settings:t,stylesheets:a,...i}){this.stylesLoaded=!1;var r,e;this.config=this.parseConfig(i),this.settings={...t,loginRequired:!!t.loginRequired&&!this.config.customer.id},this.events=new v,this.routes=this.parseRoutes(),this.customer=this.config.customer.id?{id:this.config.customer.id,email:this.config.customer.email}:null,this.utils=this.initUtils(),this.apis={wishlist:new u({host:this.config.routes.apiHost,shop:window.Shopify.shop,customerId:(r=this.config.customer.id)!=null?r:void 0,sessionId:m(),trackingSource:this.utils.route.parse(window.location.pathname).pageType}),shopify:new p({host:window.Shopify.routes.root.substring(0,window.Shopify.routes.root.length-1)}),tracking:new g({notifyHost:this.config.routes.apiHost,events:this.events,shop:window.Shopify.shop,customerId:(e=this.config.customer.id)!=null?e:void 0,sessionId:m(),utils:this.utils,settings:t})},this.state=new f({wishlistApi:this.apis.wishlist,shopifyApi:this.apis.shopify,settings:this.settings,events:this.events,utils:this.utils}),this.addToCart=(...s)=>o(this.state.addToCart(...s)),this.addAllToCart=(...s)=>o(this.state.addAllToCart(...s)),this.addWishlistItem=(...s)=>o(this.state.addWishlistItem(...s)),this.clearWishlist=(...s)=>o(this.state.clearWishlist(...s)),this.loadProductInfo=(...s)=>o(this.state.loadProductInfo(...s)),this.loadShopifyProduct=(...s)=>o(this.state.loadShopifyProduct(...s)),this.loadWishlist=(...s)=>o(this.state.loadWishlist(...s)),this.loadWishlistItem=(...s)=>o(this.state.loadWishlistItem(...s)),this.loadWishlistProduct=(...s)=>o(this.state.loadWishlistProduct(...s)),this.publishWishlistEvent=(...s)=>o(this.state.publishWishlistEvent(...s)),this.publishWishlistItemEvent=(...s)=>o(this.state.publishWishlistItemEvent(...s)),this.removeWishlistItem=(...s)=>o(this.state.removeWishlistItem(...s)),this.shareWishlist=(...s)=>o(this.state.shareWishlist(...s)),this.updateWishlistItem=(...s)=>o(this.state.updateWishlistItem(...s)),this.initStyles(a),this.initUrlChangeEvents(),this.trackCurrentPage(),requestAnimationFrame(()=>{this.events.publish({name:"wk:app:ready"})})}async initStyles(t){if(!(t!=null&&t.length)){this.onStylesLoaded();return}try{await Promise.all(t.map(a=>new Promise((i,r)=>{let e=document.createElement("link");e.rel="stylesheet",e.href=a,e.onload=i,e.onerror=r,document.head.appendChild(e)}))),this.onStylesLoaded()}catch(a){console.warn(a),this.events.publish({name:"wk:app:load-styles:error"})}}trackCurrentPage(){let t=this.utils.route.parse(window.location.pathname).pageType;if(t!=null&&t.includes("wishlist")){let a=this.utils.url.getWishlistIdFromUrl(window.location.pathname);a&&this.publishWishlistEvent({eventName:"wk:wishlist:page-view",wishlistId:a})}}onStylesLoaded(){this.stylesLoaded=!0,this.events.publish({name:"wk:app:load-styles:success"})}initUtils(){let t=this.config.shop.domain,a=this.config.products.fallbackImage,i=this.config.shop.moneyFormat,r=this.config.locale,e=new y({wishlistUrl:this.routes.wishlistUrl});return{url:new w({rootUrl:this.routes.rootUrl,wishlistUrl:this.routes.wishlistUrl,shopDomain:t,placeholderImageUrl:a,fileUrl:this.routes.fileUrl}),money:new P({moneyFormat:i,currencyRate:parseFloat(window.Shopify.currency.rate),activeCurrency:window.Shopify.currency.active}),product:new U,locale:new W({locale:r}),route:e,dom:new I({routeUtil:e})}}initUrlChangeEvents(){let t=history.replaceState,a=({productHandle:i,variantId:r})=>{this.events.publish({name:"wk:product:change-variant:success",data:{productHandle:i,variantId:r}})};history.replaceState=(...i)=>{let r=`${window.location.protocol}//${window.location.host}`,e=typeof i[2]=="string"?new URL(i[2],r):i[2],s=t.apply(history,i);if(!e)return s;let l=this.utils.url.getProductHandleFromUrl(e),n=e.searchParams.get("variant");if(!l||!n)return s;a({productHandle:l,variantId:parseInt(n)})}}parseConfig({config:t,locale:a}){var i,r,e,s,l,n,h,c;return{customer:{id:t.customerId?parseInt(t.customerId):null,email:(i=t.customerEmail)!=null?i:""},shop:{name:(r=t.shopName)!=null?r:"",domain:(e=t.shopDomain)!=null?e:"",permanentDomain:(s=t.shopPermanentDomain)!=null?s:"",currency:(l=t.shopCurrency)!=null?l:"",moneyFormat:(n=t.shopMoneyFormat)!=null?n:"",customerAccountsEnabled:t.shopCustomerAccountsEnabled?t.shopCustomerAccountsEnabled==="true":!1},routes:{apiHost:(h=t.apiHost)!=null?h:"https://api.appmate.io/v2",rootUrl:window.Shopify.routes.root,fileUrl:t.fileUrl},products:{fallbackImage:(c=t.productFallbackImage)!=null?c:"//cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_large.png?format=webp&v=1530129081"},locale:a}}parseRoutes(){var i;let t=this.config.routes.rootUrl,a=(i=this.settings.wishlistPath)!=null?i:"/apps/wishlist";return{rootUrl:t,fileUrl:this.config.routes.fileUrl,wishlistUrl:t+a.split("/").filter(r=>!!r).join("/"),accountUrl:t+"account",accountLoginUrl:t+"account/login",accountLogoutUrl:t+"account/logout",accountRegisterUrl:t+"account/register",accountAddressesUrl:t+"account/addresses",collectionsUrl:t+"collections",allProductsCollectionUrl:t+"collections/all",searchUrl:t+"search",predictiveSearchUrl:t+"search/suggest",cartUrl:t+"cart",cartAddUrl:t+"cart/add",cartChangeUrl:t+"cart/change",cartClearUrl:t+"cart/clear",cartUpdateUrl:t+"cart/update",productRecommendationsUrl:t+"recommendations/products"}}};export{d as WishlistApp};

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

var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var u=(o,a,t,e)=>{for(var n=e>1?void 0:e?v(a,t):a,s=o.length-1,i;s>=0;s--)(i=o[s])&&(n=(e?i(a,t,n):i(n))||n);return e&&n&&f(a,t,n),n};import{from as g,fromEvent as c,isObservable as h,of as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{filter as y,first as b,switchMap as C,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{state as S}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators.js/+esm";import{WishlistStateController as E}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.1/controllers/wishlist-state-controller.js";var l=class extends m{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.stateCtrl=new E(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}appReadyCallback(){}beforeNextState(t){}connect(){if(!this.connected){if(!window.WishlistKing){c(document,"wk:app:ready").pipe(b()).subscribe(()=>this.connect());return}if(!this.app.stylesLoaded){c(document,"wk:app:load-styles:success").pipe(b()).subscribe(()=>this.connect());return}this.connected=!0,this.init(),this.appReadyCallback()}}getStateConfig(){return{}}getTranslation(t){var e;return(e=window.WishlistKing)!=null&&e.utils.locale?window.WishlistKing.utils.locale.translate(t):t}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var e;this.state={...(e=this.state)!=null?e:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML="",this.initEvents(),this.connect()}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.connected=!1,this.cleanupMethods.forEach(n=>n()),(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}attributeChangedCallback(t,e,n){super.attributeChangedCallback(t,e,n),this.connected&&this.initState("cache-first")}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(t){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe(t).subscribe(e=>{this.updateState(e)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(t)}initObserver(){this.observer=new IntersectionObserver(t=>this.handleIntersect(t),{root:null,rootMargin:"0px"}),this.observer.observe(this)}handleIntersect([t]){var e;t.isIntersecting&&((e=this.observer)==null||e.disconnect(),this.initState())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([n,s])=>{let[i,r]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:i,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:n}){return c(this,t).pipe(p(s=>{this.eventPending&&s.preventDefault()}),y(()=>!this.eventPending),p(()=>{this.eventPending=!0}),C(s=>{let i=null;if(n&&s.target instanceof HTMLElement&&(i=s.target.closest(n)),n&&!i)return d(null);let r=e.bind(this)(s,n?i:s.currentTarget);return h(r)?r:typeof(r==null?void 0:r.then)=="function"?g(r):d(r)})).subscribe(()=>{this.eventPending=!1})}unlessEventPending(t){let e=()=>this.eventPending=!0,n=()=>this.eventPending=!1;return s=>{if(this.eventPending){t.preventDefault();return}e();let i=s.bind(this)(t);h(i)?i.subscribe(()=>n()):typeof(i==null?void 0:i.then)=="function"?i.then(()=>n()).catch(r=>{throw n(),r}):n()}}};u([S()],l.prototype,"state",2);export{l as WishlistElement};
var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var u=(o,a,t,e)=>{for(var n=e>1?void 0:e?v(a,t):a,s=o.length-1,i;s>=0;s--)(i=o[s])&&(n=(e?i(a,t,n):i(n))||n);return e&&n&&f(a,t,n),n};import{from as g,fromEvent as c,isObservable as h,of as d}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/+esm";import{filter as y,first as b,switchMap as C,tap as p}from"https://cdn.jsdelivr.net/npm/rxjs@7.5.6/operators/+esm";import{LitElement as m}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/+esm";import{state as S}from"https://cdn.jsdelivr.net/npm/lit@2.3.1/decorators.js/+esm";import{WishlistStateController as E}from"https://cdn.jsdelivr.net/npm/@appmate/wishlist@4.15.2/controllers/wishlist-state-controller.js";var l=class extends m{constructor(){super();this.connected=!1;this.cleanupMethods=[];this.eventPending=!1;this.state={};this.stateCtrl=new E(this)}get app(){return this.stateCtrl.app}static get observedAttributes(){return[...super.observedAttributes,"data-wishlist-id","data-wishlist-item-id","data-product-handle","data-product-id","data-variant-id"]}appReadyCallback(){}beforeNextState(t){}connect(){if(!this.connected){if(!window.WishlistKing){c(document,"wk:app:ready").pipe(b()).subscribe(()=>this.connect());return}if(!this.app.stylesLoaded){c(document,"wk:app:load-styles:success").pipe(b()).subscribe(()=>this.connect());return}this.connected=!0,this.init(),this.appReadyCallback()}}getStateConfig(){return{}}getTranslation(t){var e;return(e=window.WishlistKing)!=null&&e.utils.locale?window.WishlistKing.utils.locale.translate(t):t}init(){let{loading:t}=this.getStateConfig();t==="lazy"?(this.initFallbackState(),this.initObserver()):this.initState()}updateState(t){var e;this.state={...(e=this.state)!=null?e:{},...t}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.innerHTML="",this.initEvents(),this.connect()}disconnectedCallback(){var t,e;super.disconnectedCallback(),this.connected=!1,this.cleanupMethods.forEach(n=>n()),(t=this.subscription)==null||t.unsubscribe(),(e=this.observer)==null||e.disconnect()}attributeChangedCallback(t,e,n){super.attributeChangedCallback(t,e,n),this.connected&&this.initState("cache-first")}shouldUpdate(t){return this.connected?super.shouldUpdate(t):!1}initState(t){this.subscription&&this.subscription.unsubscribe(),this.subscription=this.stateCtrl.observe(t).subscribe(e=>{this.updateState(e)})}initFallbackState(){let t=this.stateCtrl.getFallback();t&&this.updateState(t)}initObserver(){this.observer=new IntersectionObserver(t=>this.handleIntersect(t),{root:null,rootMargin:"0px"}),this.observer.observe(this)}handleIntersect([t]){var e;t.isIntersecting&&((e=this.observer)==null||e.disconnect(),this.initState())}getEventConfig(){return{}}initEvents(){let t=this.getEventConfig();if(!t)return;let e=Object.entries(t).map(([n,s])=>{let[i,r]=n.split(/ (.*)/s);return this.subscribeToEvent({eventName:i,selector:r,handler:s})});this.cleanupMethods.push(()=>e.forEach(n=>n.unsubscribe()))}subscribeToEvent({eventName:t,handler:e,selector:n}){return c(this,t).pipe(p(s=>{this.eventPending&&s.preventDefault()}),y(()=>!this.eventPending),p(()=>{this.eventPending=!0}),C(s=>{let i=null;if(n&&s.target instanceof HTMLElement&&(i=s.target.closest(n)),n&&!i)return d(null);let r=e.bind(this)(s,n?i:s.currentTarget);return h(r)?r:typeof(r==null?void 0:r.then)=="function"?g(r):d(r)})).subscribe(()=>{this.eventPending=!1})}unlessEventPending(t){let e=()=>this.eventPending=!0,n=()=>this.eventPending=!1;return s=>{if(this.eventPending){t.preventDefault();return}e();let i=s.bind(this)(t);h(i)?i.subscribe(()=>n()):typeof(i==null?void 0:i.then)=="function"?i.then(()=>n()).catch(r=>{throw n(),r}):n()}}};u([S()],l.prototype,"state",2);export{l as WishlistElement};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc