@letscooee/web-sdk 12.2.12 → 12.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.min.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as Gs,b as qs,c as Sm,d as Tm,e as Im,f as xm,g as Cm,h as yr,i as zs,j as w,k as Rm,l as Am,m as Dm,n as Om,o as Xr}from"./chunk-QCKYUY43.js";import{a as E,b as Z,c as Di,d as bm,e as Zl,f as Kr,g as To}from"./chunk-V7UGKYBN.js";var eu=Zl(Ys=>{"use strict";Object.defineProperty(Ys,"__esModule",{value:!0});Ys.URLBuilder=void 0;var TE=(function(){function t(e){try{this.base=new URL(e),this.params=new URLSearchParams(this.base.search.slice(1))}catch(r){console.error("Un-parsable URL",r)}}return t.prototype.appendQueryParam=function(e,r){this.params.append(e,r?r.toString():"")},t.prototype.clearQueryParams=function(){return this.params=new URLSearchParams,this},t.prototype.deleteQueryParam=function(e){this.params.delete(e)},t.prototype.getBase=function(){return this.base},t.prototype.getPath=function(){return this.base.pathname},t.prototype.getHostname=function(){return this.base.hostname},t.prototype.getParams=function(){return this.params},t.prototype.getQueryParam=function(e){if(!this.params)return"";var r=this.params.get(e);return!r||r==="undefined"||r==="null"?void 0:r},t.prototype.getQueryString=function(){return this.params.toString()},t.prototype.setPath=function(e){return this.base.pathname=e,this},t.prototype.setQueryParam=function(e,r){return this.params.set(e,r?r.toString():""),this},t.prototype.setQueryString=function(e){if(e)return e[0]==="?"&&(e=e.slice(1)),this.params=new URLSearchParams(e),this},t.prototype.toString=function(){var e=this.params.toString();return e===""?this.base.search="":this.base.search="?"+e,this.base.toString()},t})();Ys.URLBuilder=TE});var Fm=Zl((km,cu)=>{"use strict";(function(t){if(typeof km=="object"&&typeof cu<"u")cu.exports=t();else if(typeof define=="function"&&define.amd)define([],t);else{var e;typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"?e=self:e=this,e.localforage=t()}})(function(){var t,e,r;return(function n(o,i,s){function a(d,m){if(!i[d]){if(!o[d]){var _=typeof Di=="function"&&Di;if(!m&&_)return _(d,!0);if(l)return l(d,!0);var y=new Error("Cannot find module '"+d+"'");throw y.code="MODULE_NOT_FOUND",y}var C=i[d]={exports:{}};o[d][0].call(C.exports,function(N){var A=o[d][1][N];return a(A||N)},C,C.exports,n,o,i,s)}return i[d].exports}for(var l=typeof Di=="function"&&Di,f=0;f<s.length;f++)a(s[f]);return a})({1:[function(n,o,i){(function(s){"use strict";var a=s.MutationObserver||s.WebKitMutationObserver,l;if(a){var f=0,d=new a(N),m=s.document.createTextNode("");d.observe(m,{characterData:!0}),l=function(){m.data=f=++f%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var _=new s.MessageChannel;_.port1.onmessage=N,l=function(){_.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?l=function(){var B=s.document.createElement("script");B.onreadystatechange=function(){N(),B.onreadystatechange=null,B.parentNode.removeChild(B),B=null},s.document.documentElement.appendChild(B)}:l=function(){setTimeout(N,0)};var y,C=[];function N(){y=!0;for(var B,q,P=C.length;P;){for(q=C,C=[],B=-1;++B<P;)q[B]();P=C.length}y=!1}o.exports=A;function A(B){C.push(B)===1&&!y&&l()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,o,i){"use strict";var s=n(1);function a(){}var l={},f=["REJECTED"],d=["FULFILLED"],m=["PENDING"];o.exports=_;function _(X){if(typeof X!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,X!==a&&A(this,X)}_.prototype.catch=function(X){return this.then(null,X)},_.prototype.then=function(X,ce){if(typeof X!="function"&&this.state===d||typeof ce!="function"&&this.state===f)return this;var se=new this.constructor(a);if(this.state!==m){var de=this.state===d?X:ce;C(se,de,this.outcome)}else this.queue.push(new y(se,X,ce));return se};function y(X,ce,se){this.promise=X,typeof ce=="function"&&(this.onFulfilled=ce,this.callFulfilled=this.otherCallFulfilled),typeof se=="function"&&(this.onRejected=se,this.callRejected=this.otherCallRejected)}y.prototype.callFulfilled=function(X){l.resolve(this.promise,X)},y.prototype.otherCallFulfilled=function(X){C(this.promise,this.onFulfilled,X)},y.prototype.callRejected=function(X){l.reject(this.promise,X)},y.prototype.otherCallRejected=function(X){C(this.promise,this.onRejected,X)};function C(X,ce,se){s(function(){var de;try{de=ce(se)}catch(Pe){return l.reject(X,Pe)}de===X?l.reject(X,new TypeError("Cannot resolve promise with itself")):l.resolve(X,de)})}l.resolve=function(X,ce){var se=B(N,ce);if(se.status==="error")return l.reject(X,se.value);var de=se.value;if(de)A(X,de);else{X.state=d,X.outcome=ce;for(var Pe=-1,Se=X.queue.length;++Pe<Se;)X.queue[Pe].callFulfilled(ce)}return X},l.reject=function(X,ce){X.state=f,X.outcome=ce;for(var se=-1,de=X.queue.length;++se<de;)X.queue[se].callRejected(ce);return X};function N(X){var ce=X&&X.then;if(X&&(typeof X=="object"||typeof X=="function")&&typeof ce=="function")return function(){ce.apply(X,arguments)}}function A(X,ce){var se=!1;function de(Ge){se||(se=!0,l.reject(X,Ge))}function Pe(Ge){se||(se=!0,l.resolve(X,Ge))}function Se(){ce(Pe,de)}var Re=B(Se);Re.status==="error"&&de(Re.value)}function B(X,ce){var se={};try{se.value=X(ce),se.status="success"}catch(de){se.status="error",se.value=de}return se}_.resolve=q;function q(X){return X instanceof this?X:l.resolve(new this(a),X)}_.reject=P;function P(X){var ce=new this(a);return l.reject(ce,X)}_.all=Q;function Q(X){var ce=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=X.length,de=!1;if(!se)return this.resolve([]);for(var Pe=new Array(se),Se=0,Re=-1,Ge=new this(a);++Re<se;)Qe(X[Re],Re);return Ge;function Qe(Ft,D){ce.resolve(Ft).then(R,function(V){de||(de=!0,l.reject(Ge,V))});function R(V){Pe[D]=V,++Se===se&&!de&&(de=!0,l.resolve(Ge,Pe))}}}_.race=Ee;function Ee(X){var ce=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=X.length,de=!1;if(!se)return this.resolve([]);for(var Pe=-1,Se=new this(a);++Pe<se;)Re(X[Pe]);return Se;function Re(Ge){ce.resolve(Ge).then(function(Qe){de||(de=!0,l.resolve(Se,Qe))},function(Qe){de||(de=!0,l.reject(Se,Qe))})}}},{1:1}],3:[function(n,o,i){(function(s){"use strict";typeof s.Promise!="function"&&(s.Promise=n(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,o,i){"use strict";var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function a(p,b){if(!(p instanceof b))throw new TypeError("Cannot call a class as a function")}function l(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var f=l();function d(){try{if(!f||!f.open)return!1;var p=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),b=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||b)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function m(p,b){p=p||[],b=b||{};try{return new Blob(p,b)}catch(S){if(S.name!=="TypeError")throw S;for(var g=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,T=new g,I=0;I<p.length;I+=1)T.append(p[I]);return T.getBlob(b.type)}}typeof Promise>"u"&&n(3);var _=Promise;function y(p,b){b&&p.then(function(g){b(null,g)},function(g){b(g)})}function C(p,b,g){typeof b=="function"&&p.then(b),typeof g=="function"&&p.catch(g)}function N(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function A(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var B="local-forage-detect-blob-support",q=void 0,P={},Q=Object.prototype.toString,Ee="readonly",X="readwrite";function ce(p){for(var b=p.length,g=new ArrayBuffer(b),T=new Uint8Array(g),I=0;I<b;I++)T[I]=p.charCodeAt(I);return g}function se(p){return new _(function(b){var g=p.transaction(B,X),T=m([""]);g.objectStore(B).put(T,"key"),g.onabort=function(I){I.preventDefault(),I.stopPropagation(),b(!1)},g.oncomplete=function(){var I=navigator.userAgent.match(/Chrome\/(\d+)/),S=navigator.userAgent.match(/Edge\//);b(S||!I||parseInt(I[1],10)>=43)}}).catch(function(){return!1})}function de(p){return typeof q=="boolean"?_.resolve(q):se(p).then(function(b){return q=b,q})}function Pe(p){var b=P[p.name],g={};g.promise=new _(function(T,I){g.resolve=T,g.reject=I}),b.deferredOperations.push(g),b.dbReady?b.dbReady=b.dbReady.then(function(){return g.promise}):b.dbReady=g.promise}function Se(p){var b=P[p.name],g=b.deferredOperations.pop();if(g)return g.resolve(),g.promise}function Re(p,b){var g=P[p.name],T=g.deferredOperations.pop();if(T)return T.reject(b),T.promise}function Ge(p,b){return new _(function(g,T){if(P[p.name]=P[p.name]||ze(),p.db)if(b)Pe(p),p.db.close();else return g(p.db);var I=[p.name];b&&I.push(p.version);var S=f.open.apply(f,I);b&&(S.onupgradeneeded=function(M){var G=S.result;try{G.createObjectStore(p.storeName),M.oldVersion<=1&&G.createObjectStore(B)}catch(z){if(z.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+M.oldVersion+" to version "+M.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw z}}),S.onerror=function(M){M.preventDefault(),T(S.error)},S.onsuccess=function(){var M=S.result;M.onversionchange=function(G){G.target.close()},g(M),Se(p)}})}function Qe(p){return Ge(p,!1)}function Ft(p){return Ge(p,!0)}function D(p,b){if(!p.db)return!0;var g=!p.db.objectStoreNames.contains(p.storeName),T=p.version<p.db.version,I=p.version>p.db.version;if(T&&(p.version!==b&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),I||g){if(g){var S=p.db.version+1;S>p.version&&(p.version=S)}return!0}return!1}function R(p){return new _(function(b,g){var T=new FileReader;T.onerror=g,T.onloadend=function(I){var S=btoa(I.target.result||"");b({__local_forage_encoded_blob:!0,data:S,type:p.type})},T.readAsBinaryString(p)})}function V(p){var b=ce(atob(p.data));return m([b],{type:p.type})}function k(p){return p&&p.__local_forage_encoded_blob}function H(p){var b=this,g=b._initReady().then(function(){var T=P[b._dbInfo.name];if(T&&T.dbReady)return T.dbReady});return C(g,p,p),g}function ne(p){Pe(p);for(var b=P[p.name],g=b.forages,T=0;T<g.length;T++){var I=g[T];I._dbInfo.db&&(I._dbInfo.db.close(),I._dbInfo.db=null)}return p.db=null,Qe(p).then(function(S){return p.db=S,D(p)?Ft(p):S}).then(function(S){p.db=b.db=S;for(var M=0;M<g.length;M++)g[M]._dbInfo.db=S}).catch(function(S){throw Re(p,S),S})}function ge(p,b,g,T){T===void 0&&(T=1);try{var I=p.db.transaction(p.storeName,b);g(null,I)}catch(S){if(T>0&&(!p.db||S.name==="InvalidStateError"||S.name==="NotFoundError"))return _.resolve().then(function(){if(!p.db||S.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),Ft(p)}).then(function(){return ne(p).then(function(){ge(p,b,g,T-1)})}).catch(g);g(S)}}function ze(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function tt(p){var b=this,g={db:null};if(p)for(var T in p)g[T]=p[T];var I=P[g.name];I||(I=ze(),P[g.name]=I),I.forages.push(b),b._initReady||(b._initReady=b.ready,b.ready=H);var S=[];function M(){return _.resolve()}for(var G=0;G<I.forages.length;G++){var z=I.forages[G];z!==b&&S.push(z._initReady().catch(M))}var Y=I.forages.slice(0);return _.all(S).then(function(){return g.db=I.db,Qe(g)}).then(function(J){return g.db=J,D(g,b._defaultConfig.version)?Ft(g):J}).then(function(J){g.db=I.db=J,b._dbInfo=g;for(var te=0;te<Y.length;te++){var ve=Y[te];ve!==b&&(ve._dbInfo.db=g.db,ve._dbInfo.version=g.version)}})}function rt(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){ge(g._dbInfo,Ee,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=z.get(p);Y.onsuccess=function(){var J=Y.result;J===void 0&&(J=null),k(J)&&(J=V(J)),I(J)},Y.onerror=function(){S(Y.error)}}catch(J){S(J)}})}).catch(S)});return y(T,b),T}function Et(p,b){var g=this,T=new _(function(I,S){g.ready().then(function(){ge(g._dbInfo,Ee,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=z.openCursor(),J=1;Y.onsuccess=function(){var te=Y.result;if(te){var ve=te.value;k(ve)&&(ve=V(ve));var Oe=p(ve,te.key,J++);Oe!==void 0?I(Oe):te.continue()}else I()},Y.onerror=function(){S(Y.error)}}catch(te){S(te)}})}).catch(S)});return y(T,b),T}function _t(p,b,g){var T=this;p=N(p);var I=new _(function(S,M){var G;T.ready().then(function(){return G=T._dbInfo,Q.call(b)==="[object Blob]"?de(G.db).then(function(z){return z?b:R(b)}):b}).then(function(z){ge(T._dbInfo,X,function(Y,J){if(Y)return M(Y);try{var te=J.objectStore(T._dbInfo.storeName);z===null&&(z=void 0);var ve=te.put(z,p);J.oncomplete=function(){z===void 0&&(z=null),S(z)},J.onabort=J.onerror=function(){var Oe=ve.error?ve.error:ve.transaction.error;M(Oe)}}catch(Oe){M(Oe)}})}).catch(M)});return y(I,g),I}function st(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){ge(g._dbInfo,X,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=z.delete(p);G.oncomplete=function(){I()},G.onerror=function(){S(Y.error)},G.onabort=function(){var J=Y.error?Y.error:Y.transaction.error;S(J)}}catch(J){S(J)}})}).catch(S)});return y(T,b),T}function be(p){var b=this,g=new _(function(T,I){b.ready().then(function(){ge(b._dbInfo,X,function(S,M){if(S)return I(S);try{var G=M.objectStore(b._dbInfo.storeName),z=G.clear();M.oncomplete=function(){T()},M.onabort=M.onerror=function(){var Y=z.error?z.error:z.transaction.error;I(Y)}}catch(Y){I(Y)}})}).catch(I)});return y(g,p),g}function He(p){var b=this,g=new _(function(T,I){b.ready().then(function(){ge(b._dbInfo,Ee,function(S,M){if(S)return I(S);try{var G=M.objectStore(b._dbInfo.storeName),z=G.count();z.onsuccess=function(){T(z.result)},z.onerror=function(){I(z.error)}}catch(Y){I(Y)}})}).catch(I)});return y(g,p),g}function Ae(p,b){var g=this,T=new _(function(I,S){if(p<0){I(null);return}g.ready().then(function(){ge(g._dbInfo,Ee,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=!1,J=z.openKeyCursor();J.onsuccess=function(){var te=J.result;if(!te){I(null);return}p===0||Y?I(te.key):(Y=!0,te.advance(p))},J.onerror=function(){S(J.error)}}catch(te){S(te)}})}).catch(S)});return y(T,b),T}function $e(p){var b=this,g=new _(function(T,I){b.ready().then(function(){ge(b._dbInfo,Ee,function(S,M){if(S)return I(S);try{var G=M.objectStore(b._dbInfo.storeName),z=G.openKeyCursor(),Y=[];z.onsuccess=function(){var J=z.result;if(!J){T(Y);return}Y.push(J.key),J.continue()},z.onerror=function(){I(z.error)}}catch(J){I(J)}})}).catch(I)});return y(g,p),g}function De(p,b){b=A.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;if(!p.name)I=_.reject("Invalid arguments");else{var S=p.name===g.name&&T._dbInfo.db,M=S?_.resolve(T._dbInfo.db):Qe(p).then(function(G){var z=P[p.name],Y=z.forages;z.db=G;for(var J=0;J<Y.length;J++)Y[J]._dbInfo.db=G;return G});p.storeName?I=M.then(function(G){if(G.objectStoreNames.contains(p.storeName)){var z=G.version+1;Pe(p);var Y=P[p.name],J=Y.forages;G.close();for(var te=0;te<J.length;te++){var ve=J[te];ve._dbInfo.db=null,ve._dbInfo.version=z}var Oe=new _(function(Ne,ot){var Ze=f.open(p.name,z);Ze.onerror=function(Zt){var Ai=Ze.result;Ai.close(),ot(Zt)},Ze.onupgradeneeded=function(){var Zt=Ze.result;Zt.deleteObjectStore(p.storeName)},Ze.onsuccess=function(){var Zt=Ze.result;Zt.close(),Ne(Zt)}});return Oe.then(function(Ne){Y.db=Ne;for(var ot=0;ot<J.length;ot++){var Ze=J[ot];Ze._dbInfo.db=Ne,Se(Ze._dbInfo)}}).catch(function(Ne){throw(Re(p,Ne)||_.resolve()).catch(function(){}),Ne})}}):I=M.then(function(G){Pe(p);var z=P[p.name],Y=z.forages;G.close();for(var J=0;J<Y.length;J++){var te=Y[J];te._dbInfo.db=null}var ve=new _(function(Oe,Ne){var ot=f.deleteDatabase(p.name);ot.onerror=function(){var Ze=ot.result;Ze&&Ze.close(),Ne(ot.error)},ot.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},ot.onsuccess=function(){var Ze=ot.result;Ze&&Ze.close(),Oe(Ze)}});return ve.then(function(Oe){z.db=Oe;for(var Ne=0;Ne<Y.length;Ne++){var ot=Y[Ne];Se(ot._dbInfo)}}).catch(function(Oe){throw(Re(p,Oe)||_.resolve()).catch(function(){}),Oe})})}return y(I,b),I}var jt={_driver:"asyncStorage",_initStorage:tt,_support:d(),iterate:Et,getItem:rt,setItem:_t,removeItem:st,clear:be,length:He,key:Ae,keys:$e,dropInstance:De};function h(){return typeof openDatabase=="function"}var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="~~local_forage_type~",v=/^~~local_forage_type~([^~]+)~/,x="__lfsc__:",O=x.length,W="arbf",ue="blob",_e="si08",ye="ui08",Le="uic8",ke="si16",nt="si32",dr="ur16",Yr="ui32",bo="fl32",hr="fl64",gr=O+W.length,dm=Object.prototype.toString;function hm(p){var b=p.length*.75,g=p.length,T,I=0,S,M,G,z;p[p.length-1]==="="&&(b--,p[p.length-2]==="="&&b--);var Y=new ArrayBuffer(b),J=new Uint8Array(Y);for(T=0;T<g;T+=4)S=c.indexOf(p[T]),M=c.indexOf(p[T+1]),G=c.indexOf(p[T+2]),z=c.indexOf(p[T+3]),J[I++]=S<<2|M>>4,J[I++]=(M&15)<<4|G>>2,J[I++]=(G&3)<<6|z&63;return Y}function zl(p){var b=new Uint8Array(p),g="",T;for(T=0;T<b.length;T+=3)g+=c[b[T]>>2],g+=c[(b[T]&3)<<4|b[T+1]>>4],g+=c[(b[T+1]&15)<<2|b[T+2]>>6],g+=c[b[T+2]&63];return b.length%3===2?g=g.substring(0,g.length-1)+"=":b.length%3===1&&(g=g.substring(0,g.length-2)+"=="),g}function Hv(p,b){var g="";if(p&&(g=dm.call(p)),p&&(g==="[object ArrayBuffer]"||p.buffer&&dm.call(p.buffer)==="[object ArrayBuffer]")){var T,I=x;p instanceof ArrayBuffer?(T=p,I+=W):(T=p.buffer,g==="[object Int8Array]"?I+=_e:g==="[object Uint8Array]"?I+=ye:g==="[object Uint8ClampedArray]"?I+=Le:g==="[object Int16Array]"?I+=ke:g==="[object Uint16Array]"?I+=dr:g==="[object Int32Array]"?I+=nt:g==="[object Uint32Array]"?I+=Yr:g==="[object Float32Array]"?I+=bo:g==="[object Float64Array]"?I+=hr:b(new Error("Failed to get type for BinaryArray"))),b(I+zl(T))}else if(g==="[object Blob]"){var S=new FileReader;S.onload=function(){var M=u+p.type+"~"+zl(this.result);b(x+ue+M)},S.readAsArrayBuffer(p)}else try{b(JSON.stringify(p))}catch(M){console.error("Couldn't convert value into a JSON string: ",p),b(null,M)}}function $v(p){if(p.substring(0,O)!==x)return JSON.parse(p);var b=p.substring(gr),g=p.substring(O,gr),T;if(g===ue&&v.test(b)){var I=b.match(v);T=I[1],b=b.substring(I[0].length)}var S=hm(b);switch(g){case W:return S;case ue:return m([S],{type:T});case _e:return new Int8Array(S);case ye:return new Uint8Array(S);case Le:return new Uint8ClampedArray(S);case ke:return new Int16Array(S);case dr:return new Uint16Array(S);case nt:return new Int32Array(S);case Yr:return new Uint32Array(S);case bo:return new Float32Array(S);case hr:return new Float64Array(S);default:throw new Error("Unkown type: "+g)}}var Yl={serialize:Hv,deserialize:$v,stringToBuffer:hm,bufferToString:zl};function gm(p,b,g,T){p.executeSql("CREATE TABLE IF NOT EXISTS "+b.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],g,T)}function Vv(p){var b=this,g={db:null};if(p)for(var T in p)g[T]=typeof p[T]!="string"?p[T].toString():p[T];var I=new _(function(S,M){try{g.db=openDatabase(g.name,String(g.version),g.description,g.size)}catch(G){return M(G)}g.db.transaction(function(G){gm(G,g,function(){b._dbInfo=g,S()},function(z,Y){M(Y)})},M)});return g.serializer=Yl,I}function yn(p,b,g,T,I,S){p.executeSql(g,T,I,function(M,G){G.code===G.SYNTAX_ERR?M.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function(z,Y){Y.rows.length?S(z,G):gm(z,b,function(){z.executeSql(g,T,I,S)},S)},S):S(M,G)},S)}function Wv(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"SELECT * FROM "+M.storeName+" WHERE key = ? LIMIT 1",[p],function(z,Y){var J=Y.rows.length?Y.rows.item(0).value:null;J&&(J=M.serializer.deserialize(J)),I(J)},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function jv(p,b){var g=this,T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"SELECT * FROM "+M.storeName,[],function(z,Y){for(var J=Y.rows,te=J.length,ve=0;ve<te;ve++){var Oe=J.item(ve),Ne=Oe.value;if(Ne&&(Ne=M.serializer.deserialize(Ne)),Ne=p(Ne,Oe.key,ve+1),Ne!==void 0){I(Ne);return}}I()},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function ym(p,b,g,T){var I=this;p=N(p);var S=new _(function(M,G){I.ready().then(function(){b===void 0&&(b=null);var z=b,Y=I._dbInfo;Y.serializer.serialize(b,function(J,te){te?G(te):Y.db.transaction(function(ve){yn(ve,Y,"INSERT OR REPLACE INTO "+Y.storeName+" (key, value) VALUES (?, ?)",[p,J],function(){M(z)},function(Oe,Ne){G(Ne)})},function(ve){if(ve.code===ve.QUOTA_ERR){if(T>0){M(ym.apply(I,[p,z,g,T-1]));return}G(ve)}})})}).catch(G)});return y(S,g),S}function Gv(p,b,g){return ym.apply(this,[p,b,g,1])}function qv(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"DELETE FROM "+M.storeName+" WHERE key = ?",[p],function(){I()},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function zv(p){var b=this,g=new _(function(T,I){b.ready().then(function(){var S=b._dbInfo;S.db.transaction(function(M){yn(M,S,"DELETE FROM "+S.storeName,[],function(){T()},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Yv(p){var b=this,g=new _(function(T,I){b.ready().then(function(){var S=b._dbInfo;S.db.transaction(function(M){yn(M,S,"SELECT COUNT(key) as c FROM "+S.storeName,[],function(G,z){var Y=z.rows.item(0).c;T(Y)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Kv(p,b){var g=this,T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"SELECT key FROM "+M.storeName+" WHERE id = ? LIMIT 1",[p+1],function(z,Y){var J=Y.rows.length?Y.rows.item(0).key:null;I(J)},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function Xv(p){var b=this,g=new _(function(T,I){b.ready().then(function(){var S=b._dbInfo;S.db.transaction(function(M){yn(M,S,"SELECT key FROM "+S.storeName,[],function(G,z){for(var Y=[],J=0;J<z.rows.length;J++)Y.push(z.rows.item(J).key);T(Y)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Jv(p){return new _(function(b,g){p.transaction(function(T){T.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(I,S){for(var M=[],G=0;G<S.rows.length;G++)M.push(S.rows.item(G).name);b({db:p,storeNames:M})},function(I,S){g(S)})},function(T){g(T)})})}function Qv(p,b){b=A.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;return p.name?I=new _(function(S){var M;p.name===g.name?M=T._dbInfo.db:M=openDatabase(p.name,"","",0),p.storeName?S({db:M,storeNames:[p.storeName]}):S(Jv(M))}).then(function(S){return new _(function(M,G){S.db.transaction(function(z){function Y(Oe){return new _(function(Ne,ot){z.executeSql("DROP TABLE IF EXISTS "+Oe,[],function(){Ne()},function(Ze,Zt){ot(Zt)})})}for(var J=[],te=0,ve=S.storeNames.length;te<ve;te++)J.push(Y(S.storeNames[te]));_.all(J).then(function(){M()}).catch(function(Oe){G(Oe)})},function(z){G(z)})})}):I=_.reject("Invalid arguments"),y(I,b),I}var Zv={_driver:"webSQLStorage",_initStorage:Vv,_support:h(),iterate:jv,getItem:Wv,setItem:Gv,removeItem:qv,clear:zv,length:Yv,key:Kv,keys:Xv,dropInstance:Qv};function eE(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function vm(p,b){var g=p.name+"/";return p.storeName!==b.storeName&&(g+=p.storeName+"/"),g}function tE(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch{return!0}}function rE(){return!tE()||localStorage.length>0}function nE(p){var b=this,g={};if(p)for(var T in p)g[T]=p[T];return g.keyPrefix=vm(p,b._defaultConfig),rE()?(b._dbInfo=g,g.serializer=Yl,_.resolve()):_.reject()}function oE(p){var b=this,g=b.ready().then(function(){for(var T=b._dbInfo.keyPrefix,I=localStorage.length-1;I>=0;I--){var S=localStorage.key(I);S.indexOf(T)===0&&localStorage.removeItem(S)}});return y(g,p),g}function iE(p,b){var g=this;p=N(p);var T=g.ready().then(function(){var I=g._dbInfo,S=localStorage.getItem(I.keyPrefix+p);return S&&(S=I.serializer.deserialize(S)),S});return y(T,b),T}function sE(p,b){var g=this,T=g.ready().then(function(){for(var I=g._dbInfo,S=I.keyPrefix,M=S.length,G=localStorage.length,z=1,Y=0;Y<G;Y++){var J=localStorage.key(Y);if(J.indexOf(S)===0){var te=localStorage.getItem(J);if(te&&(te=I.serializer.deserialize(te)),te=p(te,J.substring(M),z++),te!==void 0)return te}}});return y(T,b),T}function aE(p,b){var g=this,T=g.ready().then(function(){var I=g._dbInfo,S;try{S=localStorage.key(p)}catch{S=null}return S&&(S=S.substring(I.keyPrefix.length)),S});return y(T,b),T}function cE(p){var b=this,g=b.ready().then(function(){for(var T=b._dbInfo,I=localStorage.length,S=[],M=0;M<I;M++){var G=localStorage.key(M);G.indexOf(T.keyPrefix)===0&&S.push(G.substring(T.keyPrefix.length))}return S});return y(g,p),g}function lE(p){var b=this,g=b.keys().then(function(T){return T.length});return y(g,p),g}function uE(p,b){var g=this;p=N(p);var T=g.ready().then(function(){var I=g._dbInfo;localStorage.removeItem(I.keyPrefix+p)});return y(T,b),T}function fE(p,b,g){var T=this;p=N(p);var I=T.ready().then(function(){b===void 0&&(b=null);var S=b;return new _(function(M,G){var z=T._dbInfo;z.serializer.serialize(b,function(Y,J){if(J)G(J);else try{localStorage.setItem(z.keyPrefix+p,Y),M(S)}catch(te){(te.name==="QuotaExceededError"||te.name==="NS_ERROR_DOM_QUOTA_REACHED")&&G(te),G(te)}})})});return y(I,g),I}function pE(p,b){if(b=A.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var g=this.config();p.name=p.name||g.name,p.storeName=p.storeName||g.storeName}var T=this,I;return p.name?I=new _(function(S){p.storeName?S(vm(p,T._defaultConfig)):S(p.name+"/")}).then(function(S){for(var M=localStorage.length-1;M>=0;M--){var G=localStorage.key(M);G.indexOf(S)===0&&localStorage.removeItem(G)}}):I=_.reject("Invalid arguments"),y(I,b),I}var mE={_driver:"localStorageWrapper",_initStorage:nE,_support:eE(),iterate:sE,getItem:iE,setItem:fE,removeItem:uE,clear:oE,length:lE,key:aE,keys:cE,dropInstance:pE},dE=function(b,g){return b===g||typeof b=="number"&&typeof g=="number"&&isNaN(b)&&isNaN(g)},hE=function(b,g){for(var T=b.length,I=0;I<T;){if(dE(b[I],g))return!0;I++}return!1},Em=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Ri={},_m={},So={INDEXEDDB:jt,WEBSQL:Zv,LOCALSTORAGE:mE},gE=[So.INDEXEDDB._driver,So.WEBSQL._driver,So.LOCALSTORAGE._driver],js=["dropInstance"],Kl=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(js),yE={description:"",driver:gE.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function vE(p,b){p[b]=function(){var g=arguments;return p.ready().then(function(){return p[b].apply(p,g)})}}function Xl(){for(var p=1;p<arguments.length;p++){var b=arguments[p];if(b)for(var g in b)b.hasOwnProperty(g)&&(Em(b[g])?arguments[0][g]=b[g].slice():arguments[0][g]=b[g])}return arguments[0]}var EE=(function(){function p(b){a(this,p);for(var g in So)if(So.hasOwnProperty(g)){var T=So[g],I=T._driver;this[g]=I,Ri[I]||this.defineDriver(T)}this._defaultConfig=Xl({},yE),this._config=Xl({},this._defaultConfig,b),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(g){if((typeof g>"u"?"undefined":s(g))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var T in g){if(T==="storeName"&&(g[T]=g[T].replace(/\W/g,"_")),T==="version"&&typeof g[T]!="number")return new Error("Database version must be a number.");this._config[T]=g[T]}return"driver"in g&&g.driver?this.setDriver(this._config.driver):!0}else return typeof g=="string"?this._config[g]:this._config},p.prototype.defineDriver=function(g,T,I){var S=new _(function(M,G){try{var z=g._driver,Y=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!g._driver){G(Y);return}for(var J=Kl.concat("_initStorage"),te=0,ve=J.length;te<ve;te++){var Oe=J[te],Ne=!hE(js,Oe);if((Ne||g[Oe])&&typeof g[Oe]!="function"){G(Y);return}}var ot=function(){for(var Ai=function(bE){return function(){var SE=new Error("Method "+bE+" is not implemented by the current driver"),wm=_.reject(SE);return y(wm,arguments[arguments.length-1]),wm}},Jl=0,wE=js.length;Jl<wE;Jl++){var Ql=js[Jl];g[Ql]||(g[Ql]=Ai(Ql))}};ot();var Ze=function(Ai){Ri[z]&&console.info("Redefining LocalForage driver: "+z),Ri[z]=g,_m[z]=Ai,M()};"_support"in g?g._support&&typeof g._support=="function"?g._support().then(Ze,G):Ze(!!g._support):Ze(!0)}catch(Zt){G(Zt)}});return C(S,T,I),S},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(g,T,I){var S=Ri[g]?_.resolve(Ri[g]):_.reject(new Error("Driver not found."));return C(S,T,I),S},p.prototype.getSerializer=function(g){var T=_.resolve(Yl);return C(T,g),T},p.prototype.ready=function(g){var T=this,I=T._driverSet.then(function(){return T._ready===null&&(T._ready=T._initDriver()),T._ready});return C(I,g,g),I},p.prototype.setDriver=function(g,T,I){var S=this;Em(g)||(g=[g]);var M=this._getSupportedDrivers(g);function G(){S._config.driver=S.driver()}function z(te){return S._extend(te),G(),S._ready=S._initStorage(S._config),S._ready}function Y(te){return function(){var ve=0;function Oe(){for(;ve<te.length;){var Ne=te[ve];return ve++,S._dbInfo=null,S._ready=null,S.getDriver(Ne).then(z).catch(Oe)}G();var ot=new Error("No available storage method found.");return S._driverSet=_.reject(ot),S._driverSet}return Oe()}}var J=this._driverSet!==null?this._driverSet.catch(function(){return _.resolve()}):_.resolve();return this._driverSet=J.then(function(){var te=M[0];return S._dbInfo=null,S._ready=null,S.getDriver(te).then(function(ve){S._driver=ve._driver,G(),S._wrapLibraryMethodsWithReady(),S._initDriver=Y(M)})}).catch(function(){G();var te=new Error("No available storage method found.");return S._driverSet=_.reject(te),S._driverSet}),C(this._driverSet,T,I),this._driverSet},p.prototype.supports=function(g){return!!_m[g]},p.prototype._extend=function(g){Xl(this,g)},p.prototype._getSupportedDrivers=function(g){for(var T=[],I=0,S=g.length;I<S;I++){var M=g[I];this.supports(M)&&T.push(M)}return T},p.prototype._wrapLibraryMethodsWithReady=function(){for(var g=0,T=Kl.length;g<T;g++)vE(this,Kl[g])},p.prototype.createInstance=function(g){return new p(g)},p})(),_E=new EE;o.exports=_E},{3:3}]},{},[4])(4)})});var Zf=Zl((oc,hg)=>{"use strict";(function(t,e){typeof oc=="object"&&typeof hg<"u"?e(oc):typeof define=="function"&&define.amd?define(["exports"],e):e((t=typeof globalThis<"u"?globalThis:t||self).Sqrl={})})(oc,function(t){"use strict";function e(D){var R,V,k=new Error(D);return R=k,V=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(R,V):R.__proto__=V,k}function r(D,R,V){var k=R.slice(0,V).split(/\n/),H=k.length,ne=k[H-1].length+1;throw e(D+=" at line "+H+" col "+ne+`:
1
+ import{a as Gs,b as qs,c as Sm,d as Tm,e as Im,f as xm,g as Cm,h as yr,i as zs,j as w,k as Rm,l as Am,m as Dm,n as Om,o as Xr}from"./chunk-3YKWFW36.js";import{a as E,b as Z,c as Di,d as bm,e as Zl,f as Kr,g as To}from"./chunk-V7UGKYBN.js";var eu=Zl(Ys=>{"use strict";Object.defineProperty(Ys,"__esModule",{value:!0});Ys.URLBuilder=void 0;var TE=(function(){function t(e){try{this.base=new URL(e),this.params=new URLSearchParams(this.base.search.slice(1))}catch(r){console.error("Un-parsable URL",r)}}return t.prototype.appendQueryParam=function(e,r){this.params.append(e,r?r.toString():"")},t.prototype.clearQueryParams=function(){return this.params=new URLSearchParams,this},t.prototype.deleteQueryParam=function(e){this.params.delete(e)},t.prototype.getBase=function(){return this.base},t.prototype.getPath=function(){return this.base.pathname},t.prototype.getHostname=function(){return this.base.hostname},t.prototype.getParams=function(){return this.params},t.prototype.getQueryParam=function(e){if(!this.params)return"";var r=this.params.get(e);return!r||r==="undefined"||r==="null"?void 0:r},t.prototype.getQueryString=function(){return this.params.toString()},t.prototype.setPath=function(e){return this.base.pathname=e,this},t.prototype.setQueryParam=function(e,r){return this.params.set(e,r?r.toString():""),this},t.prototype.setQueryString=function(e){if(e)return e[0]==="?"&&(e=e.slice(1)),this.params=new URLSearchParams(e),this},t.prototype.toString=function(){var e=this.params.toString();return e===""?this.base.search="":this.base.search="?"+e,this.base.toString()},t})();Ys.URLBuilder=TE});var Fm=Zl((km,cu)=>{"use strict";(function(t){if(typeof km=="object"&&typeof cu<"u")cu.exports=t();else if(typeof define=="function"&&define.amd)define([],t);else{var e;typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"?e=self:e=this,e.localforage=t()}})(function(){var t,e,r;return(function n(o,i,s){function a(d,m){if(!i[d]){if(!o[d]){var _=typeof Di=="function"&&Di;if(!m&&_)return _(d,!0);if(l)return l(d,!0);var y=new Error("Cannot find module '"+d+"'");throw y.code="MODULE_NOT_FOUND",y}var C=i[d]={exports:{}};o[d][0].call(C.exports,function(N){var A=o[d][1][N];return a(A||N)},C,C.exports,n,o,i,s)}return i[d].exports}for(var l=typeof Di=="function"&&Di,f=0;f<s.length;f++)a(s[f]);return a})({1:[function(n,o,i){(function(s){"use strict";var a=s.MutationObserver||s.WebKitMutationObserver,l;if(a){var f=0,d=new a(N),m=s.document.createTextNode("");d.observe(m,{characterData:!0}),l=function(){m.data=f=++f%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var _=new s.MessageChannel;_.port1.onmessage=N,l=function(){_.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?l=function(){var B=s.document.createElement("script");B.onreadystatechange=function(){N(),B.onreadystatechange=null,B.parentNode.removeChild(B),B=null},s.document.documentElement.appendChild(B)}:l=function(){setTimeout(N,0)};var y,C=[];function N(){y=!0;for(var B,q,P=C.length;P;){for(q=C,C=[],B=-1;++B<P;)q[B]();P=C.length}y=!1}o.exports=A;function A(B){C.push(B)===1&&!y&&l()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,o,i){"use strict";var s=n(1);function a(){}var l={},f=["REJECTED"],d=["FULFILLED"],m=["PENDING"];o.exports=_;function _(X){if(typeof X!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,X!==a&&A(this,X)}_.prototype.catch=function(X){return this.then(null,X)},_.prototype.then=function(X,ce){if(typeof X!="function"&&this.state===d||typeof ce!="function"&&this.state===f)return this;var se=new this.constructor(a);if(this.state!==m){var de=this.state===d?X:ce;C(se,de,this.outcome)}else this.queue.push(new y(se,X,ce));return se};function y(X,ce,se){this.promise=X,typeof ce=="function"&&(this.onFulfilled=ce,this.callFulfilled=this.otherCallFulfilled),typeof se=="function"&&(this.onRejected=se,this.callRejected=this.otherCallRejected)}y.prototype.callFulfilled=function(X){l.resolve(this.promise,X)},y.prototype.otherCallFulfilled=function(X){C(this.promise,this.onFulfilled,X)},y.prototype.callRejected=function(X){l.reject(this.promise,X)},y.prototype.otherCallRejected=function(X){C(this.promise,this.onRejected,X)};function C(X,ce,se){s(function(){var de;try{de=ce(se)}catch(Pe){return l.reject(X,Pe)}de===X?l.reject(X,new TypeError("Cannot resolve promise with itself")):l.resolve(X,de)})}l.resolve=function(X,ce){var se=B(N,ce);if(se.status==="error")return l.reject(X,se.value);var de=se.value;if(de)A(X,de);else{X.state=d,X.outcome=ce;for(var Pe=-1,Se=X.queue.length;++Pe<Se;)X.queue[Pe].callFulfilled(ce)}return X},l.reject=function(X,ce){X.state=f,X.outcome=ce;for(var se=-1,de=X.queue.length;++se<de;)X.queue[se].callRejected(ce);return X};function N(X){var ce=X&&X.then;if(X&&(typeof X=="object"||typeof X=="function")&&typeof ce=="function")return function(){ce.apply(X,arguments)}}function A(X,ce){var se=!1;function de(Ge){se||(se=!0,l.reject(X,Ge))}function Pe(Ge){se||(se=!0,l.resolve(X,Ge))}function Se(){ce(Pe,de)}var Re=B(Se);Re.status==="error"&&de(Re.value)}function B(X,ce){var se={};try{se.value=X(ce),se.status="success"}catch(de){se.status="error",se.value=de}return se}_.resolve=q;function q(X){return X instanceof this?X:l.resolve(new this(a),X)}_.reject=P;function P(X){var ce=new this(a);return l.reject(ce,X)}_.all=Q;function Q(X){var ce=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=X.length,de=!1;if(!se)return this.resolve([]);for(var Pe=new Array(se),Se=0,Re=-1,Ge=new this(a);++Re<se;)Qe(X[Re],Re);return Ge;function Qe(Ft,D){ce.resolve(Ft).then(R,function(V){de||(de=!0,l.reject(Ge,V))});function R(V){Pe[D]=V,++Se===se&&!de&&(de=!0,l.resolve(Ge,Pe))}}}_.race=Ee;function Ee(X){var ce=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=X.length,de=!1;if(!se)return this.resolve([]);for(var Pe=-1,Se=new this(a);++Pe<se;)Re(X[Pe]);return Se;function Re(Ge){ce.resolve(Ge).then(function(Qe){de||(de=!0,l.resolve(Se,Qe))},function(Qe){de||(de=!0,l.reject(Se,Qe))})}}},{1:1}],3:[function(n,o,i){(function(s){"use strict";typeof s.Promise!="function"&&(s.Promise=n(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,o,i){"use strict";var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function a(p,b){if(!(p instanceof b))throw new TypeError("Cannot call a class as a function")}function l(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var f=l();function d(){try{if(!f||!f.open)return!1;var p=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),b=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||b)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function m(p,b){p=p||[],b=b||{};try{return new Blob(p,b)}catch(S){if(S.name!=="TypeError")throw S;for(var g=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,T=new g,I=0;I<p.length;I+=1)T.append(p[I]);return T.getBlob(b.type)}}typeof Promise>"u"&&n(3);var _=Promise;function y(p,b){b&&p.then(function(g){b(null,g)},function(g){b(g)})}function C(p,b,g){typeof b=="function"&&p.then(b),typeof g=="function"&&p.catch(g)}function N(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function A(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var B="local-forage-detect-blob-support",q=void 0,P={},Q=Object.prototype.toString,Ee="readonly",X="readwrite";function ce(p){for(var b=p.length,g=new ArrayBuffer(b),T=new Uint8Array(g),I=0;I<b;I++)T[I]=p.charCodeAt(I);return g}function se(p){return new _(function(b){var g=p.transaction(B,X),T=m([""]);g.objectStore(B).put(T,"key"),g.onabort=function(I){I.preventDefault(),I.stopPropagation(),b(!1)},g.oncomplete=function(){var I=navigator.userAgent.match(/Chrome\/(\d+)/),S=navigator.userAgent.match(/Edge\//);b(S||!I||parseInt(I[1],10)>=43)}}).catch(function(){return!1})}function de(p){return typeof q=="boolean"?_.resolve(q):se(p).then(function(b){return q=b,q})}function Pe(p){var b=P[p.name],g={};g.promise=new _(function(T,I){g.resolve=T,g.reject=I}),b.deferredOperations.push(g),b.dbReady?b.dbReady=b.dbReady.then(function(){return g.promise}):b.dbReady=g.promise}function Se(p){var b=P[p.name],g=b.deferredOperations.pop();if(g)return g.resolve(),g.promise}function Re(p,b){var g=P[p.name],T=g.deferredOperations.pop();if(T)return T.reject(b),T.promise}function Ge(p,b){return new _(function(g,T){if(P[p.name]=P[p.name]||ze(),p.db)if(b)Pe(p),p.db.close();else return g(p.db);var I=[p.name];b&&I.push(p.version);var S=f.open.apply(f,I);b&&(S.onupgradeneeded=function(M){var G=S.result;try{G.createObjectStore(p.storeName),M.oldVersion<=1&&G.createObjectStore(B)}catch(z){if(z.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+M.oldVersion+" to version "+M.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw z}}),S.onerror=function(M){M.preventDefault(),T(S.error)},S.onsuccess=function(){var M=S.result;M.onversionchange=function(G){G.target.close()},g(M),Se(p)}})}function Qe(p){return Ge(p,!1)}function Ft(p){return Ge(p,!0)}function D(p,b){if(!p.db)return!0;var g=!p.db.objectStoreNames.contains(p.storeName),T=p.version<p.db.version,I=p.version>p.db.version;if(T&&(p.version!==b&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),I||g){if(g){var S=p.db.version+1;S>p.version&&(p.version=S)}return!0}return!1}function R(p){return new _(function(b,g){var T=new FileReader;T.onerror=g,T.onloadend=function(I){var S=btoa(I.target.result||"");b({__local_forage_encoded_blob:!0,data:S,type:p.type})},T.readAsBinaryString(p)})}function V(p){var b=ce(atob(p.data));return m([b],{type:p.type})}function k(p){return p&&p.__local_forage_encoded_blob}function H(p){var b=this,g=b._initReady().then(function(){var T=P[b._dbInfo.name];if(T&&T.dbReady)return T.dbReady});return C(g,p,p),g}function ne(p){Pe(p);for(var b=P[p.name],g=b.forages,T=0;T<g.length;T++){var I=g[T];I._dbInfo.db&&(I._dbInfo.db.close(),I._dbInfo.db=null)}return p.db=null,Qe(p).then(function(S){return p.db=S,D(p)?Ft(p):S}).then(function(S){p.db=b.db=S;for(var M=0;M<g.length;M++)g[M]._dbInfo.db=S}).catch(function(S){throw Re(p,S),S})}function ge(p,b,g,T){T===void 0&&(T=1);try{var I=p.db.transaction(p.storeName,b);g(null,I)}catch(S){if(T>0&&(!p.db||S.name==="InvalidStateError"||S.name==="NotFoundError"))return _.resolve().then(function(){if(!p.db||S.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),Ft(p)}).then(function(){return ne(p).then(function(){ge(p,b,g,T-1)})}).catch(g);g(S)}}function ze(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function tt(p){var b=this,g={db:null};if(p)for(var T in p)g[T]=p[T];var I=P[g.name];I||(I=ze(),P[g.name]=I),I.forages.push(b),b._initReady||(b._initReady=b.ready,b.ready=H);var S=[];function M(){return _.resolve()}for(var G=0;G<I.forages.length;G++){var z=I.forages[G];z!==b&&S.push(z._initReady().catch(M))}var Y=I.forages.slice(0);return _.all(S).then(function(){return g.db=I.db,Qe(g)}).then(function(J){return g.db=J,D(g,b._defaultConfig.version)?Ft(g):J}).then(function(J){g.db=I.db=J,b._dbInfo=g;for(var te=0;te<Y.length;te++){var ve=Y[te];ve!==b&&(ve._dbInfo.db=g.db,ve._dbInfo.version=g.version)}})}function rt(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){ge(g._dbInfo,Ee,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=z.get(p);Y.onsuccess=function(){var J=Y.result;J===void 0&&(J=null),k(J)&&(J=V(J)),I(J)},Y.onerror=function(){S(Y.error)}}catch(J){S(J)}})}).catch(S)});return y(T,b),T}function Et(p,b){var g=this,T=new _(function(I,S){g.ready().then(function(){ge(g._dbInfo,Ee,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=z.openCursor(),J=1;Y.onsuccess=function(){var te=Y.result;if(te){var ve=te.value;k(ve)&&(ve=V(ve));var Oe=p(ve,te.key,J++);Oe!==void 0?I(Oe):te.continue()}else I()},Y.onerror=function(){S(Y.error)}}catch(te){S(te)}})}).catch(S)});return y(T,b),T}function _t(p,b,g){var T=this;p=N(p);var I=new _(function(S,M){var G;T.ready().then(function(){return G=T._dbInfo,Q.call(b)==="[object Blob]"?de(G.db).then(function(z){return z?b:R(b)}):b}).then(function(z){ge(T._dbInfo,X,function(Y,J){if(Y)return M(Y);try{var te=J.objectStore(T._dbInfo.storeName);z===null&&(z=void 0);var ve=te.put(z,p);J.oncomplete=function(){z===void 0&&(z=null),S(z)},J.onabort=J.onerror=function(){var Oe=ve.error?ve.error:ve.transaction.error;M(Oe)}}catch(Oe){M(Oe)}})}).catch(M)});return y(I,g),I}function st(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){ge(g._dbInfo,X,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=z.delete(p);G.oncomplete=function(){I()},G.onerror=function(){S(Y.error)},G.onabort=function(){var J=Y.error?Y.error:Y.transaction.error;S(J)}}catch(J){S(J)}})}).catch(S)});return y(T,b),T}function be(p){var b=this,g=new _(function(T,I){b.ready().then(function(){ge(b._dbInfo,X,function(S,M){if(S)return I(S);try{var G=M.objectStore(b._dbInfo.storeName),z=G.clear();M.oncomplete=function(){T()},M.onabort=M.onerror=function(){var Y=z.error?z.error:z.transaction.error;I(Y)}}catch(Y){I(Y)}})}).catch(I)});return y(g,p),g}function He(p){var b=this,g=new _(function(T,I){b.ready().then(function(){ge(b._dbInfo,Ee,function(S,M){if(S)return I(S);try{var G=M.objectStore(b._dbInfo.storeName),z=G.count();z.onsuccess=function(){T(z.result)},z.onerror=function(){I(z.error)}}catch(Y){I(Y)}})}).catch(I)});return y(g,p),g}function Ae(p,b){var g=this,T=new _(function(I,S){if(p<0){I(null);return}g.ready().then(function(){ge(g._dbInfo,Ee,function(M,G){if(M)return S(M);try{var z=G.objectStore(g._dbInfo.storeName),Y=!1,J=z.openKeyCursor();J.onsuccess=function(){var te=J.result;if(!te){I(null);return}p===0||Y?I(te.key):(Y=!0,te.advance(p))},J.onerror=function(){S(J.error)}}catch(te){S(te)}})}).catch(S)});return y(T,b),T}function $e(p){var b=this,g=new _(function(T,I){b.ready().then(function(){ge(b._dbInfo,Ee,function(S,M){if(S)return I(S);try{var G=M.objectStore(b._dbInfo.storeName),z=G.openKeyCursor(),Y=[];z.onsuccess=function(){var J=z.result;if(!J){T(Y);return}Y.push(J.key),J.continue()},z.onerror=function(){I(z.error)}}catch(J){I(J)}})}).catch(I)});return y(g,p),g}function De(p,b){b=A.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;if(!p.name)I=_.reject("Invalid arguments");else{var S=p.name===g.name&&T._dbInfo.db,M=S?_.resolve(T._dbInfo.db):Qe(p).then(function(G){var z=P[p.name],Y=z.forages;z.db=G;for(var J=0;J<Y.length;J++)Y[J]._dbInfo.db=G;return G});p.storeName?I=M.then(function(G){if(G.objectStoreNames.contains(p.storeName)){var z=G.version+1;Pe(p);var Y=P[p.name],J=Y.forages;G.close();for(var te=0;te<J.length;te++){var ve=J[te];ve._dbInfo.db=null,ve._dbInfo.version=z}var Oe=new _(function(Ne,ot){var Ze=f.open(p.name,z);Ze.onerror=function(Zt){var Ai=Ze.result;Ai.close(),ot(Zt)},Ze.onupgradeneeded=function(){var Zt=Ze.result;Zt.deleteObjectStore(p.storeName)},Ze.onsuccess=function(){var Zt=Ze.result;Zt.close(),Ne(Zt)}});return Oe.then(function(Ne){Y.db=Ne;for(var ot=0;ot<J.length;ot++){var Ze=J[ot];Ze._dbInfo.db=Ne,Se(Ze._dbInfo)}}).catch(function(Ne){throw(Re(p,Ne)||_.resolve()).catch(function(){}),Ne})}}):I=M.then(function(G){Pe(p);var z=P[p.name],Y=z.forages;G.close();for(var J=0;J<Y.length;J++){var te=Y[J];te._dbInfo.db=null}var ve=new _(function(Oe,Ne){var ot=f.deleteDatabase(p.name);ot.onerror=function(){var Ze=ot.result;Ze&&Ze.close(),Ne(ot.error)},ot.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},ot.onsuccess=function(){var Ze=ot.result;Ze&&Ze.close(),Oe(Ze)}});return ve.then(function(Oe){z.db=Oe;for(var Ne=0;Ne<Y.length;Ne++){var ot=Y[Ne];Se(ot._dbInfo)}}).catch(function(Oe){throw(Re(p,Oe)||_.resolve()).catch(function(){}),Oe})})}return y(I,b),I}var jt={_driver:"asyncStorage",_initStorage:tt,_support:d(),iterate:Et,getItem:rt,setItem:_t,removeItem:st,clear:be,length:He,key:Ae,keys:$e,dropInstance:De};function h(){return typeof openDatabase=="function"}var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="~~local_forage_type~",v=/^~~local_forage_type~([^~]+)~/,x="__lfsc__:",O=x.length,W="arbf",ue="blob",_e="si08",ye="ui08",Le="uic8",ke="si16",nt="si32",dr="ur16",Yr="ui32",bo="fl32",hr="fl64",gr=O+W.length,dm=Object.prototype.toString;function hm(p){var b=p.length*.75,g=p.length,T,I=0,S,M,G,z;p[p.length-1]==="="&&(b--,p[p.length-2]==="="&&b--);var Y=new ArrayBuffer(b),J=new Uint8Array(Y);for(T=0;T<g;T+=4)S=c.indexOf(p[T]),M=c.indexOf(p[T+1]),G=c.indexOf(p[T+2]),z=c.indexOf(p[T+3]),J[I++]=S<<2|M>>4,J[I++]=(M&15)<<4|G>>2,J[I++]=(G&3)<<6|z&63;return Y}function zl(p){var b=new Uint8Array(p),g="",T;for(T=0;T<b.length;T+=3)g+=c[b[T]>>2],g+=c[(b[T]&3)<<4|b[T+1]>>4],g+=c[(b[T+1]&15)<<2|b[T+2]>>6],g+=c[b[T+2]&63];return b.length%3===2?g=g.substring(0,g.length-1)+"=":b.length%3===1&&(g=g.substring(0,g.length-2)+"=="),g}function Hv(p,b){var g="";if(p&&(g=dm.call(p)),p&&(g==="[object ArrayBuffer]"||p.buffer&&dm.call(p.buffer)==="[object ArrayBuffer]")){var T,I=x;p instanceof ArrayBuffer?(T=p,I+=W):(T=p.buffer,g==="[object Int8Array]"?I+=_e:g==="[object Uint8Array]"?I+=ye:g==="[object Uint8ClampedArray]"?I+=Le:g==="[object Int16Array]"?I+=ke:g==="[object Uint16Array]"?I+=dr:g==="[object Int32Array]"?I+=nt:g==="[object Uint32Array]"?I+=Yr:g==="[object Float32Array]"?I+=bo:g==="[object Float64Array]"?I+=hr:b(new Error("Failed to get type for BinaryArray"))),b(I+zl(T))}else if(g==="[object Blob]"){var S=new FileReader;S.onload=function(){var M=u+p.type+"~"+zl(this.result);b(x+ue+M)},S.readAsArrayBuffer(p)}else try{b(JSON.stringify(p))}catch(M){console.error("Couldn't convert value into a JSON string: ",p),b(null,M)}}function $v(p){if(p.substring(0,O)!==x)return JSON.parse(p);var b=p.substring(gr),g=p.substring(O,gr),T;if(g===ue&&v.test(b)){var I=b.match(v);T=I[1],b=b.substring(I[0].length)}var S=hm(b);switch(g){case W:return S;case ue:return m([S],{type:T});case _e:return new Int8Array(S);case ye:return new Uint8Array(S);case Le:return new Uint8ClampedArray(S);case ke:return new Int16Array(S);case dr:return new Uint16Array(S);case nt:return new Int32Array(S);case Yr:return new Uint32Array(S);case bo:return new Float32Array(S);case hr:return new Float64Array(S);default:throw new Error("Unkown type: "+g)}}var Yl={serialize:Hv,deserialize:$v,stringToBuffer:hm,bufferToString:zl};function gm(p,b,g,T){p.executeSql("CREATE TABLE IF NOT EXISTS "+b.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],g,T)}function Vv(p){var b=this,g={db:null};if(p)for(var T in p)g[T]=typeof p[T]!="string"?p[T].toString():p[T];var I=new _(function(S,M){try{g.db=openDatabase(g.name,String(g.version),g.description,g.size)}catch(G){return M(G)}g.db.transaction(function(G){gm(G,g,function(){b._dbInfo=g,S()},function(z,Y){M(Y)})},M)});return g.serializer=Yl,I}function yn(p,b,g,T,I,S){p.executeSql(g,T,I,function(M,G){G.code===G.SYNTAX_ERR?M.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function(z,Y){Y.rows.length?S(z,G):gm(z,b,function(){z.executeSql(g,T,I,S)},S)},S):S(M,G)},S)}function Wv(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"SELECT * FROM "+M.storeName+" WHERE key = ? LIMIT 1",[p],function(z,Y){var J=Y.rows.length?Y.rows.item(0).value:null;J&&(J=M.serializer.deserialize(J)),I(J)},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function jv(p,b){var g=this,T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"SELECT * FROM "+M.storeName,[],function(z,Y){for(var J=Y.rows,te=J.length,ve=0;ve<te;ve++){var Oe=J.item(ve),Ne=Oe.value;if(Ne&&(Ne=M.serializer.deserialize(Ne)),Ne=p(Ne,Oe.key,ve+1),Ne!==void 0){I(Ne);return}}I()},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function ym(p,b,g,T){var I=this;p=N(p);var S=new _(function(M,G){I.ready().then(function(){b===void 0&&(b=null);var z=b,Y=I._dbInfo;Y.serializer.serialize(b,function(J,te){te?G(te):Y.db.transaction(function(ve){yn(ve,Y,"INSERT OR REPLACE INTO "+Y.storeName+" (key, value) VALUES (?, ?)",[p,J],function(){M(z)},function(Oe,Ne){G(Ne)})},function(ve){if(ve.code===ve.QUOTA_ERR){if(T>0){M(ym.apply(I,[p,z,g,T-1]));return}G(ve)}})})}).catch(G)});return y(S,g),S}function Gv(p,b,g){return ym.apply(this,[p,b,g,1])}function qv(p,b){var g=this;p=N(p);var T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"DELETE FROM "+M.storeName+" WHERE key = ?",[p],function(){I()},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function zv(p){var b=this,g=new _(function(T,I){b.ready().then(function(){var S=b._dbInfo;S.db.transaction(function(M){yn(M,S,"DELETE FROM "+S.storeName,[],function(){T()},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Yv(p){var b=this,g=new _(function(T,I){b.ready().then(function(){var S=b._dbInfo;S.db.transaction(function(M){yn(M,S,"SELECT COUNT(key) as c FROM "+S.storeName,[],function(G,z){var Y=z.rows.item(0).c;T(Y)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Kv(p,b){var g=this,T=new _(function(I,S){g.ready().then(function(){var M=g._dbInfo;M.db.transaction(function(G){yn(G,M,"SELECT key FROM "+M.storeName+" WHERE id = ? LIMIT 1",[p+1],function(z,Y){var J=Y.rows.length?Y.rows.item(0).key:null;I(J)},function(z,Y){S(Y)})})}).catch(S)});return y(T,b),T}function Xv(p){var b=this,g=new _(function(T,I){b.ready().then(function(){var S=b._dbInfo;S.db.transaction(function(M){yn(M,S,"SELECT key FROM "+S.storeName,[],function(G,z){for(var Y=[],J=0;J<z.rows.length;J++)Y.push(z.rows.item(J).key);T(Y)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Jv(p){return new _(function(b,g){p.transaction(function(T){T.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(I,S){for(var M=[],G=0;G<S.rows.length;G++)M.push(S.rows.item(G).name);b({db:p,storeNames:M})},function(I,S){g(S)})},function(T){g(T)})})}function Qv(p,b){b=A.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;return p.name?I=new _(function(S){var M;p.name===g.name?M=T._dbInfo.db:M=openDatabase(p.name,"","",0),p.storeName?S({db:M,storeNames:[p.storeName]}):S(Jv(M))}).then(function(S){return new _(function(M,G){S.db.transaction(function(z){function Y(Oe){return new _(function(Ne,ot){z.executeSql("DROP TABLE IF EXISTS "+Oe,[],function(){Ne()},function(Ze,Zt){ot(Zt)})})}for(var J=[],te=0,ve=S.storeNames.length;te<ve;te++)J.push(Y(S.storeNames[te]));_.all(J).then(function(){M()}).catch(function(Oe){G(Oe)})},function(z){G(z)})})}):I=_.reject("Invalid arguments"),y(I,b),I}var Zv={_driver:"webSQLStorage",_initStorage:Vv,_support:h(),iterate:jv,getItem:Wv,setItem:Gv,removeItem:qv,clear:zv,length:Yv,key:Kv,keys:Xv,dropInstance:Qv};function eE(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function vm(p,b){var g=p.name+"/";return p.storeName!==b.storeName&&(g+=p.storeName+"/"),g}function tE(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch{return!0}}function rE(){return!tE()||localStorage.length>0}function nE(p){var b=this,g={};if(p)for(var T in p)g[T]=p[T];return g.keyPrefix=vm(p,b._defaultConfig),rE()?(b._dbInfo=g,g.serializer=Yl,_.resolve()):_.reject()}function oE(p){var b=this,g=b.ready().then(function(){for(var T=b._dbInfo.keyPrefix,I=localStorage.length-1;I>=0;I--){var S=localStorage.key(I);S.indexOf(T)===0&&localStorage.removeItem(S)}});return y(g,p),g}function iE(p,b){var g=this;p=N(p);var T=g.ready().then(function(){var I=g._dbInfo,S=localStorage.getItem(I.keyPrefix+p);return S&&(S=I.serializer.deserialize(S)),S});return y(T,b),T}function sE(p,b){var g=this,T=g.ready().then(function(){for(var I=g._dbInfo,S=I.keyPrefix,M=S.length,G=localStorage.length,z=1,Y=0;Y<G;Y++){var J=localStorage.key(Y);if(J.indexOf(S)===0){var te=localStorage.getItem(J);if(te&&(te=I.serializer.deserialize(te)),te=p(te,J.substring(M),z++),te!==void 0)return te}}});return y(T,b),T}function aE(p,b){var g=this,T=g.ready().then(function(){var I=g._dbInfo,S;try{S=localStorage.key(p)}catch{S=null}return S&&(S=S.substring(I.keyPrefix.length)),S});return y(T,b),T}function cE(p){var b=this,g=b.ready().then(function(){for(var T=b._dbInfo,I=localStorage.length,S=[],M=0;M<I;M++){var G=localStorage.key(M);G.indexOf(T.keyPrefix)===0&&S.push(G.substring(T.keyPrefix.length))}return S});return y(g,p),g}function lE(p){var b=this,g=b.keys().then(function(T){return T.length});return y(g,p),g}function uE(p,b){var g=this;p=N(p);var T=g.ready().then(function(){var I=g._dbInfo;localStorage.removeItem(I.keyPrefix+p)});return y(T,b),T}function fE(p,b,g){var T=this;p=N(p);var I=T.ready().then(function(){b===void 0&&(b=null);var S=b;return new _(function(M,G){var z=T._dbInfo;z.serializer.serialize(b,function(Y,J){if(J)G(J);else try{localStorage.setItem(z.keyPrefix+p,Y),M(S)}catch(te){(te.name==="QuotaExceededError"||te.name==="NS_ERROR_DOM_QUOTA_REACHED")&&G(te),G(te)}})})});return y(I,g),I}function pE(p,b){if(b=A.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var g=this.config();p.name=p.name||g.name,p.storeName=p.storeName||g.storeName}var T=this,I;return p.name?I=new _(function(S){p.storeName?S(vm(p,T._defaultConfig)):S(p.name+"/")}).then(function(S){for(var M=localStorage.length-1;M>=0;M--){var G=localStorage.key(M);G.indexOf(S)===0&&localStorage.removeItem(G)}}):I=_.reject("Invalid arguments"),y(I,b),I}var mE={_driver:"localStorageWrapper",_initStorage:nE,_support:eE(),iterate:sE,getItem:iE,setItem:fE,removeItem:uE,clear:oE,length:lE,key:aE,keys:cE,dropInstance:pE},dE=function(b,g){return b===g||typeof b=="number"&&typeof g=="number"&&isNaN(b)&&isNaN(g)},hE=function(b,g){for(var T=b.length,I=0;I<T;){if(dE(b[I],g))return!0;I++}return!1},Em=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Ri={},_m={},So={INDEXEDDB:jt,WEBSQL:Zv,LOCALSTORAGE:mE},gE=[So.INDEXEDDB._driver,So.WEBSQL._driver,So.LOCALSTORAGE._driver],js=["dropInstance"],Kl=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(js),yE={description:"",driver:gE.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function vE(p,b){p[b]=function(){var g=arguments;return p.ready().then(function(){return p[b].apply(p,g)})}}function Xl(){for(var p=1;p<arguments.length;p++){var b=arguments[p];if(b)for(var g in b)b.hasOwnProperty(g)&&(Em(b[g])?arguments[0][g]=b[g].slice():arguments[0][g]=b[g])}return arguments[0]}var EE=(function(){function p(b){a(this,p);for(var g in So)if(So.hasOwnProperty(g)){var T=So[g],I=T._driver;this[g]=I,Ri[I]||this.defineDriver(T)}this._defaultConfig=Xl({},yE),this._config=Xl({},this._defaultConfig,b),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(g){if((typeof g>"u"?"undefined":s(g))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var T in g){if(T==="storeName"&&(g[T]=g[T].replace(/\W/g,"_")),T==="version"&&typeof g[T]!="number")return new Error("Database version must be a number.");this._config[T]=g[T]}return"driver"in g&&g.driver?this.setDriver(this._config.driver):!0}else return typeof g=="string"?this._config[g]:this._config},p.prototype.defineDriver=function(g,T,I){var S=new _(function(M,G){try{var z=g._driver,Y=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!g._driver){G(Y);return}for(var J=Kl.concat("_initStorage"),te=0,ve=J.length;te<ve;te++){var Oe=J[te],Ne=!hE(js,Oe);if((Ne||g[Oe])&&typeof g[Oe]!="function"){G(Y);return}}var ot=function(){for(var Ai=function(bE){return function(){var SE=new Error("Method "+bE+" is not implemented by the current driver"),wm=_.reject(SE);return y(wm,arguments[arguments.length-1]),wm}},Jl=0,wE=js.length;Jl<wE;Jl++){var Ql=js[Jl];g[Ql]||(g[Ql]=Ai(Ql))}};ot();var Ze=function(Ai){Ri[z]&&console.info("Redefining LocalForage driver: "+z),Ri[z]=g,_m[z]=Ai,M()};"_support"in g?g._support&&typeof g._support=="function"?g._support().then(Ze,G):Ze(!!g._support):Ze(!0)}catch(Zt){G(Zt)}});return C(S,T,I),S},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(g,T,I){var S=Ri[g]?_.resolve(Ri[g]):_.reject(new Error("Driver not found."));return C(S,T,I),S},p.prototype.getSerializer=function(g){var T=_.resolve(Yl);return C(T,g),T},p.prototype.ready=function(g){var T=this,I=T._driverSet.then(function(){return T._ready===null&&(T._ready=T._initDriver()),T._ready});return C(I,g,g),I},p.prototype.setDriver=function(g,T,I){var S=this;Em(g)||(g=[g]);var M=this._getSupportedDrivers(g);function G(){S._config.driver=S.driver()}function z(te){return S._extend(te),G(),S._ready=S._initStorage(S._config),S._ready}function Y(te){return function(){var ve=0;function Oe(){for(;ve<te.length;){var Ne=te[ve];return ve++,S._dbInfo=null,S._ready=null,S.getDriver(Ne).then(z).catch(Oe)}G();var ot=new Error("No available storage method found.");return S._driverSet=_.reject(ot),S._driverSet}return Oe()}}var J=this._driverSet!==null?this._driverSet.catch(function(){return _.resolve()}):_.resolve();return this._driverSet=J.then(function(){var te=M[0];return S._dbInfo=null,S._ready=null,S.getDriver(te).then(function(ve){S._driver=ve._driver,G(),S._wrapLibraryMethodsWithReady(),S._initDriver=Y(M)})}).catch(function(){G();var te=new Error("No available storage method found.");return S._driverSet=_.reject(te),S._driverSet}),C(this._driverSet,T,I),this._driverSet},p.prototype.supports=function(g){return!!_m[g]},p.prototype._extend=function(g){Xl(this,g)},p.prototype._getSupportedDrivers=function(g){for(var T=[],I=0,S=g.length;I<S;I++){var M=g[I];this.supports(M)&&T.push(M)}return T},p.prototype._wrapLibraryMethodsWithReady=function(){for(var g=0,T=Kl.length;g<T;g++)vE(this,Kl[g])},p.prototype.createInstance=function(g){return new p(g)},p})(),_E=new EE;o.exports=_E},{3:3}]},{},[4])(4)})});var Zf=Zl((oc,hg)=>{"use strict";(function(t,e){typeof oc=="object"&&typeof hg<"u"?e(oc):typeof define=="function"&&define.amd?define(["exports"],e):e((t=typeof globalThis<"u"?globalThis:t||self).Sqrl={})})(oc,function(t){"use strict";function e(D){var R,V,k=new Error(D);return R=k,V=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(R,V):R.__proto__=V,k}function r(D,R,V){var k=R.slice(0,V).split(/\n/),H=k.length,ne=k[H-1].length+1;throw e(D+=" at line "+H+" col "+ne+`:
2
2
 
3
3
  `+R.split(/\n/)[H-1]+`
4
4
  `+Array(ne).join(" ")+"^")}e.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var n=new Function("return this")().Promise,o=!1;try{o=new Function("return (async function(){}).constructor")()}catch(D){if(!(D instanceof SyntaxError))throw D}function i(D,R){return Object.prototype.hasOwnProperty.call(D,R)}function s(D,R,V){for(var k in R)i(R,k)&&(R[k]==null||typeof R[k]!="object"||k!=="storage"&&k!=="prefixes"||V?D[k]=R[k]:D[k]=s({},R[k]));return D}var a=/^async +/,l=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,f=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,d=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,m=/[.*+\-?^${}()|[\]\\]/g;function _(D){return m.test(D)?D.replace(m,"\\$&"):D}function y(D,R){R.rmWhitespace&&(D=D.replace(/[\r\n]+/g,`
@@ -58,4 +58,4 @@ mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
58
58
  style="background-color: ${e.pagination.color?.rgba};">
59
59
  </span>
60
60
  `},navigation:{nextEl:t.querySelector(".swiper-button-next"),prevEl:t.querySelector(".swiper-button-prev")},autoplay:e.autoplay?.enabled?{delay:e.autoplay?.delay,disableOnInteraction:!1,pauseOnMouseEnter:!1}:!1,autoHeight:!0};e.marquee&&r.autoplay&&typeof r.autoplay=="object"&&(r.speed=e.speed,r.autoplay.pauseOnMouseEnter=!0,t.style.setProperty("--swiper-wrapper-transition-timing-function","linear"));let n=new window.CooeeSDK.Swiper(t,r);return t.style.setProperty("--swiper-navigation-size",`${e.navigation.size}px`),n}function Dl(t,e,r){let n={color:t.navigation.color?.rgba};return t.pagination.enabled&&(n.transform="translateY(-25%)"),K("div",{class:"swiper-container",ref:e,style:"max-width: 100%",children:[K("div",{class:"swiper-wrapper",children:r()}),t.navigation.enabled&&K("div",{class:"swiper-button-next",style:n,children:K("span",{})}),t.navigation.enabled&&K("div",{class:"swiper-button-prev",style:n,children:K("span",{})}),t.pagination.enabled&&K("div",{className:"swiper-pagination",style:{bottom:0,top:"unset",position:"relative",color:t.pagination.color?.rgba}})]})}var Ms=class extends Ue{componentDidMount(){St(()=>{this.setState(()=>({checked:this.props.item.selected.value}))})}render(){return K("div",{style:this.getCompiledStyles(),className:"lc-checkbox",children:K("input",{type:"checkbox",checked:this.state.checked,onChange:this.onChange.bind(this),style:{appearance:"auto"}})})}onChange(e){let{checked:r}=e.target;this.props.item.selected.value=r}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.textAlign=r.alignment,e.justifyContent=r.alignment,e}getComponentStyles(){return Z(E({},this.getTypoStyles()),{display:"flex"})}};var hn=class extends Ue{constructor(e,r){super(e,r)}render(){let e=this.props.element[this.deviceTypeKey],r=e?.src||this.props.element.src||this.props.element.lg?.src;return K("img",{onClick:this.customOnClick.bind(this),className:"lc-image",alt:e?.name||"Image",onMouseEnter:this.handleMouseEnter.bind(this),onMouseLeave:this.handleMouseLeave.bind(this),src:r,style:this.getCompiledStyles()})}customOnClick(e){this.props.element.clc?.at===we.ADD_TO_CART&&this.props.triggerContext.triggerData.items[0]&&this.onClick(e,{item:this.props.triggerContext.triggerData.items[0]}),this.props.onClick&&this.props.onClick("image")}getComponentStyles(){let e=this.mediaStyle.lout;if(!e||e.pos!=="absolute")return{};let r={zIndex:e.zIndex,cursor:this.props.element.clc?.at?"pointer":"auto"};return this.mediaStyle.size?.w&&(r.width=this.mediaStyle.size.w),this.mediaStyle.size?.h&&(r.height=this.mediaStyle.size.h),r}handleMouseEnter(e){let r=this.props.element[this.deviceTypeKey]?.secondarySrc;r&&(e.currentTarget.src=r)}handleMouseLeave(e){e.currentTarget.src=this.props.element[this.deviceTypeKey]?.src}};var gn=class extends Ue{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return K("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:K($n,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})})}getComponentStyles(){let e=this.mediaStyle.flex??new Jo,r={display:"flex",gap:e.gap+"px",flexWrap:e.wrap,flexDirection:e.dir,justifyContent:e.jc,alignItems:e.ai};return e.wrap==="nowrap"&&e.scroll&&(e.dir==="column"?r["overflow-y"]="auto":r["overflow-x"]="auto"),r}};var Bs=class extends gn{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return K("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:K(Ti,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.props.noLinks})})}};var Us=class extends Ue{render(){return K("select",{style:this.getCompiledStyles(),value:this.props.selectedVariant.selectedSellingPlan.value?.mID??"",onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){St(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.letterSpacing=r.letterSpacing,e.fontSize=r.fs+"px",e.lineHeight=r.lh,e.fontFamily="inherit",e.textAlign=r.alignment,e.fontWeight=r.fw,this.stylesConverter.getColourStyles(r.tc,"color",e),e.boxShadow="none",e}getComponentStyles(){let e={};return this.props.selectedVariant.sellingPlans?.length||(e.visibility="hidden"),E(E({},e),this.getTypoStyles())}createSelectItems(){let e=[],r=this.props.selectedVariant;if(!r.sellingPlans?.length)return[];this.props.triggerContext.triggerData.skipSubscribedItems?r.selectedSellingPlan.value||(r.sellingPlans[0].isSelected=!0,r.changeSellingPlan(r.sellingPlans[0])):e.push(K("option",{value:"",selected:!r.selectedSellingPlan,children:"One time purchase"}));for(let n of r.sellingPlans??[])e.push(K("option",{value:n.mID,selected:n.isSelected,children:n.name}));return e}onChange(e){let r=e.target.value;r?this.props.selectedVariant.selectedSellingPlan.value=this.props.selectedVariant.sellingPlans.find(n=>n.mID===r):this.props.selectedVariant.selectedSellingPlan.value=void 0}};var hT=new RegExp('fill="#[a-zA-Z0-9]+"'),ks=class extends Ue{constructor(){super()}render(){let e=this.getCompiledStyles(),r=this.getRating();return r||(e.display="none",r=""),K("div",{style:e,className:"lc-star-rating",dangerouslySetInnerHTML:{__html:r}})}getRating(){let e={size:this.props.element.iconSize,color:this.props.element.c.hex},r=Wo(this.props.element.fullStar,{svg:e},this.props.triggerContext),n=Wo(this.props.element.halfStart,{svg:e},this.props.triggerContext),o=this.props.review;if(!o?.rating)return"";let i="";if(this.props.element.showSingleStar)i=r;else{let s=5,a=`${o.rating}`.split(".");for(let l=0;l<+a[0];l++)i+=r,s--;a[1]&&(i+=n,s--);for(let l=0;l<s;l++)i+=r.replace(hT,'fill="#f1f1f1"')}return i}getComponentStyles(){return{display:"flex",alignItems:"center"}}};var Fs=class extends Ue{render(){return K("select",{style:this.getCompiledStyles(),value:this.props.item.selectedOrFirstVariant.value.mID,onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){St(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.letterSpacing=r.letterSpacing,e.fontSize=r.fs+"px",e.lineHeight=r.lh,e.fontFamily="inherit",e.textAlign=r.alignment,e.fontWeight=r.fw,this.stylesConverter.getColourStyles(r.tc,"color",e),e.boxShadow="none",e}getComponentStyles(){let e={};return this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"&&(e.visibility="hidden"),E(E({},e),this.getTypoStyles())}createSelectItems(){let e=[];for(let r of this.props.item.vars)e.push(K("option",{value:r.mID,disabled:!r.isAvailable,children:r.name}));return e}onChange(e){let r=e.target.value,n=this.props.item.vars.find(o=>o.mID===r);this.props.item.setSelectedVariant(n)}};var mv=()=>{let t=window.ShopifyAnalytics?.meta??{},e=t.selectedVariantId;if(e)return e;if(t.product?.variants?.length>0)return t.product.variants[0].id},im=t=>{if(!t)return;let e;try{e=new URL(t)}catch{return}if(e.hostname!=="cdn.shopify.com")return t;let r=e.pathname.split(".");return r.length!==2?t:(e.pathname=r[0]+"_large."+r[1],e.toString())};var Ti=class extends Ue{constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"}))}renderElement(e){if(!(e.hide||!this.matchWhenCondition(e.when))){if(e.t===4){let r=e;return r.l==="Star Rating"&&!this.props.item.reviews?.rating?void 0:K(Bs,{element:r,triggerContext:this.props.triggerContext,elements:r.elems,item:this.props.item,noLinks:this.props.noLinks})}if(e.t===6)return this.props.triggerContext.triggerData.isBundle()?K(Ms,{element:e,item:this.props.item,triggerContext:this.props.triggerContext}):void 0;if(e.t===13){let r=e,n=this.props.item,o=im(n.variantImage??n.firstImageURL),i=im(n.variantSecondaryImage??n.secondaryImageURL);r.lg=r.sm={src:o,name:n.name,secondarySrc:i};let s=K(hn,{element:r,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?s:K("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block"},children:s})}if(e.t===14)return this.renderProductTitle(e);if(e.t===15){let r=e;return this.props.triggerContext.triggerData.isCartEmbed()&&this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"?void 0:r.showChips?K("cooee-product-options-picker",{item:this.props.item}):K(Fs,{element:r,item:this.props.item,triggerContext:this.props.triggerContext})}return e.t===16?K(Us,{element:e,selectedVariant:this.props.item.selectedOrFirstVariant.value,item:this.props.item,triggerContext:this.props.triggerContext}):e.t===19?K(ks,{element:e,triggerContext:this.props.triggerContext,review:this.props.item.reviews}):e.t===18||e.t===3?K(_o,{element:e,item:this.props.item,triggerContext:this.props.triggerContext}):K($n,{elements:[e],element:this.props.element,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(e=>this.renderElement(e))}getComponentStyles(){return{}}renderProductTitle(e){let r=K(Qt,{element:e,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?r:K("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block",textDecoration:this.state.decoration},onMouseEnter:this.onMouseEnter.bind(this),onMouseLeave:this.onMouseLeave.bind(this),children:r})}customOnClick(e){this.sendTriggerClicked([this.props.item.toEmbed()],{from:e})}onMouseEnter(){this.setState(()=>({decoration:"underline"}))}onMouseLeave(){this.setState(()=>({decoration:"unset"}))}};var wo=class extends Ue{productElement;constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"}))}render(){let e=Zn(this.props.element,this.getProductData(),this.props.triggerContext);if(this.productElement=new On(e),!(this.productElement.hide||!this.matchWhenCondition(this.productElement.when)))return K("div",{style:E({},this.getCompiledStyles()),class:"lc-single-product",children:K(Ti,{element:this.productElement,elements:this.productElement.elems,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.productElement.noLinks})})}getComponentStyles(){return{flexShrink:0}}getProductData(){if(!this.props.item)return{};let e=this.props.item,r=e.selectedOrFirstVariant.value,n=e.getTemplateVariables();n.product.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(this.props.item.quantity):this.props.item.quantity;let o=this.props.triggerContext.triggerData.discount?.type===er.BXGY;return!r.hasEffectivePrice()&&o&&(n.product=Z(E(E({},n.product),Bt("effective_price",r.effectivePrice.value)),{price:""})),n.variant.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(r.quantity):r.quantity,{product:n.product,variant:n.variant,svg:{color:"{{ svg.color }}",size:"{{ svg.size }}"}}}};var Hs=class extends Ue{swiperRef=null;swiperInstance=null;configuration;gap;constructor(e,r){super(e,r),this.configuration=jr()?this.props.element.conf.sm:this.props.element.conf.lg,this.gap=(this.configuration.gap??15)+"px"}componentDidMount(){this.props.element.conf[this.deviceTypeKey].disp===2&&Nc().then(()=>{this.swiperInstance=Al(this.swiperRef,this.props.element.conf[this.deviceTypeKey])})}componentWillUnmount(){this.swiperInstance&&this.swiperInstance.destroy()}render(){let e=this.props.triggerContext.triggerData.items;e.splice(this.configuration.maxItems??10);let r;if(this.configuration.disp===2){let n=i=>{this.swiperRef=i},o=()=>e?.map(i=>K("div",{class:"swiper-slide",children:this.getProductFragment(i)}));r=K("div",{style:Z(E({},this.getCompiledStyles()),{display:"block"}),class:"lc-product-swiper-list",children:Dl(this.configuration,n,o)})}else r=K("div",{style:this.getCompiledStyles(),class:"lc-product-list",children:e?.map((n,o)=>this.getProductFragment(n,o!==e.length-1))});return r}getComponentStyles(){let e=[0,2].includes(this.configuration.disp),r={display:e?"flex":"grid",justifyContent:"safe "+(this.mediaStyle.flex?.jc??"center"),gap:this.gap,flexDirection:this.mediaStyle.flex?.dir??"row"};if(r.flexDirection==="row"){if(e)r.maxWidth="100%",r.overflowY="auto";else if(this.configuration.disp===1){let n=this.props.triggerContext.triggerData,o=n.items.length,i;n.isBundle()?i=this.props.element.prod.symbol?.hide!==!0?o*2-1:o:i=this.props.element.conf[this.deviceTypeKey].maxInRow,r.gridTemplateColumns=`repeat(${i}, auto)`}}return r}getProductFragment(e,r=!1){return K(Br,{children:[K(wo,{element:this.props.element.prod,item:e,triggerContext:this.props.triggerContext}),this.props.triggerContext.triggerData.isBundle()&&r&&this.props.element.prod.symbol&&!this.props.element.prod.symbol.hide&&K("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:K(Qt,{element:this.props.element.prod.symbol,triggerContext:this.props.triggerContext})})]},e.mID)}};var $s=class extends Ue{swiperRef=null;swiperInstance=null;constructor(e,r){super(e,r)}componentDidMount(){Nc().then(()=>{this.swiperInstance=Al(this.swiperRef,this.props.element.conf)})}componentWillUnmount(){this.swiperInstance&&this.swiperInstance.destroy()}render(){let e=this.props.element,r=o=>{this.swiperRef=o},n=()=>{let o=e.values?.map(a=>K("div",{class:"swiper-slide",onClick:l=>this.onClick(l,{clickAction:this.getClickAction(a)}),children:this.renderElement(a)}));if(!o?.length)return[];let i=e.conf,s=o.length;if(i.marquee&&s<=Number(i.maxInRow)){let a=Number(i.maxInRow)-s+1;for(let l=0;l<a;l++)o.push(o[l%s])}return o};return Dl(e.conf,r,n)}getComponentStyles(){return{}}renderElement(e){let r=this.valueAddedSlide(this.props.element.slide,e);switch(r?.t){case 1:return K(hn,{element:r,triggerContext:this.props.triggerContext});case 4:return K(gn,{elements:r.elems,element:r,triggerContext:this.props.triggerContext});default:w.warn("Unknown slide type for carousal")}}valueAddedSlide(e,r){let n=Zn(e,{form:r},this.props.triggerContext);return Yt.getParsedElement(n)}getClickAction(e){return Zn(this.props.element.clc??{},{form:e},this.props.triggerContext)}};var $n=class extends Ue{constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"})),St(()=>{this.setState(()=>({showButton:!this.props.triggerContext.triggerData.isBundle()||!!this.props.triggerContext.selectedItems.length}))})}renderElement(e){if(!e.hide){if(e.t===4){let r=e;return K(gn,{element:r,triggerContext:this.props.triggerContext,elements:r.elems})}if(e.t===61)return K(Ls,{element:e,triggerContext:this.props.triggerContext});if(e.t===3)return this.state.showButton?K(_o,{element:e,triggerContext:this.props.triggerContext}):void 0;if(e.t===2)return K(Qt,{element:e,triggerContext:this.props.triggerContext});if(e.t===1)return K(hn,{element:e,triggerContext:this.props.triggerContext});if(e.t===11)return K(Hs,{element:e,triggerContext:this.props.triggerContext});if(e.t===12)return K(wo,{element:e,item:this.props.triggerContext.triggerData.items[0],triggerContext:this.props.triggerContext});if(e.t===62)return K($s,{element:e,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(e=>this.renderElement(e))}getComponentStyles(){return{}}};var Vs=class extends Ue{clickAction;isClickable;constructor(e,r){super(e,r),this.clickAction=this.props.element.clc,this.isClickable=this.clickAction?.at===we.GO_TO_URL&&!!ko(this.clickAction.gu?.u)||this.clickAction?.at===we.OPEN_CART||this.clickAction?.at===we.INITIATE_CHECKOUT}componentDidMount(){St(()=>{let e=this.props.triggerContext.triggerData,r=this.props.triggerContext.selectedItems;e.calculateDiscountData(r,this.props.triggerContext.shouldGiveFBTDiscount)})}render(){return K(Br,{children:[K("div",{style:this.getCompiledStyles(),class:"lc-container",onClick:e=>{this.onClick(e,{clickAction:this.clickAction})},children:K($n,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})}),this.props.triggerContext.triggerData.id==="preview"&&K("div",{class:"letscooee-preview-badge",children:["#",this.props.triggerContext.triggerData.shortID," preview"]})]})}getComponentStyles(){let e={position:"relative",overflow:"hidden",display:"block"};return this.isClickable&&(e.cursor="pointer"),e}};var vt=class t{constructor(e){this.engagementTrigger=e;this.triggerContext=new Cr(new Date,this.engagementTrigger)}static currentEngagements=new Set;static engagementIDsWithTrackedDisplay=new Set;static DEBOUNCE_TIME=1e3;rootContainer;widgetElement;widget;triggerContext;observers=[];renderedCount=0;scrollSubscription;variation;isExclusionWithBVariation;isProcessing=!1;renderSilently(){this.acquireProcessingLock()||this.render().finally(()=>this.releaseProcessingLock()).catch(e=>{ae(e,"render-widget",{triggerContext:this.triggerContext})})}destroy(){w.verbose(`${this.engagementTrigger} will be destroyed`),this.preDestroy(),this.removeFromRendered(),this.rootContainer?.remove(),t.engagementIDsWithTrackedDisplay.delete(this.engagementTrigger.shortID),Ep(this.engagementTrigger.content?.afterDeleteJS)}matches(e){return this.engagementTrigger.shortID===e.shortID}async render(){if(this.engagementTrigger.shouldGetVariationImmediately()){let e=await this.getVariation();this.handleVariationResponse(e)}if(this.rootContainer=await this.getWidgetContainer(!0),!this.rootContainer){w.warn(`${this.engagementTrigger} no section found to render the widget`);return}this.afterRootContainerCreated(),this.widget=this.engagementTrigger.widget,await this.getVariationIfRequired(),await this.runChoresBeforeRender(),this.attachScroll(),this.checkAndSendEvent(),this.triggerContext.renderer=this,Ep(this.engagementTrigger.content?.afterRenderJS)}async updateAndReRender(e){if(!this.acquireProcessingLock())try{this.updateItems(e.items,this.engagementTrigger.items),await this.update(e),await this.render()}finally{this.releaseProcessingLock()}}async update(e){}async rerenderIfDeleted(){if(!this.rootContainer?.isConnected&&!this.acquireProcessingLock()){w.info(`${this.engagementTrigger} deleted. Will be re-rendered`);try{this.preDestroy(),await this.render()}finally{this.releaseProcessingLock()}}}updateAngularWidget(){return this.widgetElement?.isConnected?(this.widgetElement.update(),!0):!1}preDestroy(){this.scrollSubscription?.unsubscribe(),this.observers.forEach(e=>{e?.disconnect&&e.disconnect()})}acquireProcessingLock(){return this.isProcessing?!0:(w.info(`Acquiring rendering lock for ${this.engagementTrigger}`),this.isProcessing=!0,!1)}releaseProcessingLock(){w.info(`Releasing rendering lock for ${this.engagementTrigger}`),this.isProcessing=!1}afterRootContainerCreated(){}isAllOkToRender(){return!!this.widget}async getVariationIfRequired(){if(this.engagementTrigger.shouldSkipVariation()){w.verbose(`${this.engagementTrigger} already has necessary data to render`);return}let e=await this.observeWidgetContainerInViewport();this.handleVariationResponse(e)}handleVariationResponse(e){e&&(w.log(`${this.engagementTrigger} visitor has been assigned to variation ${e.variation}`),e.items?.length&&(this.engagementTrigger.items=e.items.map(r=>new Rt(r)),this.engagementTrigger.nonMutableItems=e.items.map(r=>new Rt(r))),e.bundleFrom&&(this.engagementTrigger.bundleFrom=new Rt(e.bundleFrom)),e.discount&&(this.engagementTrigger.discount=e.discount),e.placement&&(this.triggerContext.triggerData.placement=e.placement),e.props&&wt.hasKeys(e.props)&&(this.engagementTrigger.props=E(E({},this.engagementTrigger.props),e.props)),e.content&&(this.triggerContext.triggerData.content=new ss(e.content)),this.triggerContext.triggerData.widget=this.widget=new ti(e.widget),this.triggerContext.triggerData.contentID=e.contentID,this.triggerContext.triggerData.variation=this.variation=e.variation,this.triggerContext.triggerData.placement=e.placement,this.triggerContext.triggerData.manipulation=e.manipulation,this.triggerContext.triggerData.entryAnimation=e.entryAnimation??"NONE",this.isExclusionWithBVariation=this.engagementTrigger.isExclusionTesting()&&this.variation==="b",this.isExclusionWithBVariation&&(this.rootContainer.style.height="0.5px"))}addToRendered(){this.renderedCount++,w.info(`${this.engagementTrigger} rendered \u2705 ${Bh(this.renderedCount)} time`)}removeFromRendered(){this instanceof dt?dt.currentEngagements.delete(this):t.currentEngagements.delete(this)}async getVariation(){w.log(`${this.engagementTrigger} get variation`);let e={engagementID:this.engagementTrigger.engagementID,isPreview:this.engagementTrigger.id==="preview"};try{return(await dv(e)).data}catch(r){if(r instanceof Er&&r.response?.status===400)return;ae(r,"get-variation",{engagementTrigger:this.engagementTrigger});return}}async observeWidgetContainerInViewport(){if(!this.rootContainer){w.warn(`${this.engagementTrigger} No root container found to watch for viewport`);return}let e=window.innerHeight*.3,r={root:null,rootMargin:`${e}px 0px ${e}px 0px`,threshold:0};return this.isInViewport()?this.getVariation():new Promise(n=>{let o=new IntersectionObserver((i,s)=>{i.forEach(async a=>{if(a.isIntersecting){w.log(`${this.engagementTrigger} root container is near the viewport. Fetching variation`);let l=await this.getVariation();n(l),s.unobserve(this.rootContainer)}})},r);o.observe(this.rootContainer),this.observers.push(o)})}attachScroll(){this.scrollSubscription=ho(window,"scroll").pipe(Xt(t.DEBOUNCE_TIME)).subscribe(()=>{this.checkAndSendEvent()})}checkAndSendEvent(){let e=this.engagementTrigger.shortID;if(t.engagementIDsWithTrackedDisplay.has(e)||!this.isInViewport())return;let n={};this.triggerContext.triggerData.items?.length&&(n.promotedMIDs=this.engagementTrigger.items?.map(s=>s.mID));let o=this.isExclusionWithBVariation?"CE Campaign Holdout":"CE Trigger Displayed",i=new xe(o,n,this.engagementTrigger);i.name==="CE Campaign Holdout"&&(i.trigger.holdout=!0),kt(i),t.engagementIDsWithTrackedDisplay.add(e),this.scrollSubscription.unsubscribe()}generateParentElementID(){return`letscooee-${this.engagementTrigger.shortID}`}createAngularWidget(e){let r=this.widgetElement=document.createElement(e);return r.cart=me.getCurrent(),r.triggerContext=this.triggerContext,r.engagementTrigger=this.engagementTrigger,r.setAttribute("engagement",this.engagementTrigger.shortID),this.rootContainer.appendChild(r),this.addToRendered(),this.injectOuterCSSOnly(),r}getParentElement(e,r=document){let n=r.getElementById(e);if(n)return n;let o=this.engagementTrigger.objective.toLowerCase().replaceAll("_","-"),i=this.engagementTrigger.shortID;return n=document.createElement("div"),n.id=e,n.className=`letscooee letscooee-engagement engagement-${i} lc-${o}`,n.dataset.engagementId=i,this.engagementTrigger.id==="preview"&&(n.className+=" letscooee-preview"),n.style.display="block",n.style.minHeight="0.5px",n.style.minWidth="0.5px",n}async startRendering(){let e=this.rootContainer,r=this.triggerContext.triggerData.hasSwiperElement();r&&(e=this.rootContainer?.shadowRoot||this.rootContainer?.attachShadow({mode:"open"}),_p(e)),this.injectCampaignCSS(r,e),Qh(Bf(Vs,{element:this.widget.cont,triggerContext:this.triggerContext,elements:this.widget.elems}),e),this.addToRendered()}injectCampaignCSS(e,r){let n=this.engagementTrigger.content?.outerCSS?.trim()??"",o=this.engagementTrigger.content?.innerCSS?.trim()??"";if(!n&&!o)return;let i=this.rootContainer.id;if(e){ao(o,r),this.injectOuterCSSOnly();return}let s=n+`
61
- ${o}`;ao(`#${i} { ${s} }`)}injectOuterCSSOnly(){let e=this.engagementTrigger.content?.outerCSS?.trim();if(!e)return;let r=this.rootContainer.id;ao(`#${r} { ${e} }`)}isInViewport(){let e=this.rootContainer?.getBoundingClientRect();if(!e)return!1;let r=window.innerHeight||document.documentElement.clientHeight,o=(Math.min(e.bottom,r)-Math.max(e.top,0))*e.width,i=e.width*e.height,s=o/i*100;return this.engagementTrigger.isAnySplit()?s>0:s>=30}async getWidgetContainer(e){if(this.rootContainer?.isConnected)return this.rootContainer;let r=await this.createParentElementWithPlacement(e);if(r)return r;let n=`.letscooee[data-engagement-id="${this.triggerContext.triggerData.shortID}"]`;return document.querySelector(n)}async createParentElementWithPlacement(e){let r=this.engagementTrigger.placement;if(!r?.selector)return w.info(`\u26A0\uFE0F${this.engagementTrigger} does not have a selector`),null;let n=r.selector,o;if(n.includes(":shadow")){let l=n.split(":shadow");o=(await xn(l[0].trim()))?.shadowRoot,n=l[1].trim(),o&&_p(o,!1)}w.verbose(`${this.engagementTrigger} attempt to render ${r.position} "${n}"`);let i=await xn(n,10,o??document);if(!i)return w.warn(`${this.engagementTrigger} no placement found with ${n}`),null;let s=this.generateParentElementID(),a=this.getParentElement(s);if(!e)return a;switch(r.position){case Ot.BEFORE1:case Ot.BEFORE:{i.parentElement?.insertBefore(a,i);break}case Ot.INSIDE_FIRST1:case Ot.INSIDE_FIRST:{i.insertBefore(a,i.firstChild);break}case Ot.INSIDE_LAST1:case Ot.INSIDE_LAST:{i.appendChild(a);break}case Ot.AFTER1:case Ot.AFTER:default:i.parentElement?.insertBefore(a,i.nextSibling)}return a}async runChoresBeforeRender(){if(this.isExclusionWithBVariation)return;if(!this.isAllOkToRender()){w.info(`\u26A0\uFE0F ${this.engagementTrigger} could not be rendered`);return}w.verbose(`${this.engagementTrigger} will be rendered`);let e;try{e=await Rl(this.engagementTrigger)}catch(r){w.info(`\u203C\uFE0F${this.engagementTrigger} could not render as items failed to refresh`,r);return}if(!this.engagementTrigger.isCollectionPromoted()&&!e?.length&&this.engagementTrigger.isProductPromoted()){w.info(`\u203C\uFE0F${this.engagementTrigger} could not render as no products promoted`);return}this.engagementTrigger.items=e,await this.startRendering()}updateItems(e,r){let n=this.getItemDiff(e,r),o=this.getItemDiff(r,e);r.push(...n);for(let i of o)Jr.remove(r,i)}getItemDiff(e,r){return e.filter(n=>!r.some(o=>o.selectedOrFirstVariant.value.mID===n.selectedOrFirstVariant.value.mID))}};var dt=class extends vt{static currentEngagements=new Set;constructor(e){super(e)}rerenderAfterCartOpened(){this.rerenderIfDeleted(),this.checkAndSendEvent()}observeWidgetContainerInViewport(){return this.getVariation()}generateParentElementID(){let e=super.generateParentElementID();return this.engagementTrigger.isSubscriptionUpsell()&&(e+=`-${this.engagementTrigger.items[0].selectedOrFirstVariant.value.mID}`),e}checkAndSendEvent(){if(!et.get().isOpen()&&fe().pageName!=="cart"){w.log("Do not send display event as neither the cart drawer nor the cart page is open.");return}return super.checkAndSendEvent()}};var gT=t=>t,hv=t=>t.filter(e=>e.removedNodes&&e.removedNodes.length>0);function gv(t,e={childList:!0,subtree:!0},r=500,n=gT){return fl(o=>{let i=new MutationObserver(s=>o(s));return i.observe(t,e),i},(o,i)=>i.disconnect()).pipe(pn(o=>n(o)),Yp(o=>o.length>0),Xt(r))}var Ol=class t{constructor(e,r){this.engagementTrigger=e;this.element=r;this.cartItems=me.getCurrent().items}cartItems;static renderCartUpsell(e){let r=e.placement;if(!r?.selector){w.warn(`No placement available for ${e.objective}`,e.shortID);return}let n=Array.from(document.querySelectorAll(r.selector));if(!n?.length){w.warn(`No placement found for ${e.objective}`,e.shortID);return}for(let o of n)new t(e,o).render()}render(){let e=this.findCartItemFromHTMLElement();if(!e||this.engagementTrigger.skipSubscribedItems&&e.selling_plan_allocation)return;let r=this.engagementTrigger.items.find(d=>d.mID===e.product_id.toString());if(!r)return;let n=r.vars.find(d=>d.mID===e.id.toString());if(!n)return;let o=new Ur(n),i=e.selling_plan_allocation?.selling_plan;if(i)for(let d of o.sellingPlans??[])d.mID===i.id.toString()&&(d.isSelected=!0,o.changeSellingPlan(d));let s=new Rt(r);s.vars=[o],s.selectedOrFirstVariant.value=o;let a=`lc-cart-item-${this.engagementTrigger.shortID}-${r.mID}`;this.element.classList.add(a);let l=new Tt(this.engagementTrigger);l.placement.selector=`.${a}`,l.items=[s];let f=new dt(l);f.renderSilently(),this.watchForCartItemDeletion(f,a)}watchForCartItemDeletion(e,r){let n=new MutationObserver(o=>{o.forEach(i=>{i.removedNodes.forEach(s=>{s===this.element&&(w.verbose(`${r} has been removed`),e.destroy(),n.disconnect())})})});n.observe(this.element.parentElement,{childList:!0,subtree:!0})}findCartItemFromHTMLElement(){let e=this.element.innerHTML;return this.cartItems.find(r=>{if(!(e.includes(r.url)||e.includes(r.variant_id))&&(!e.includes(r.product_title)||r.variant_title&&!e.includes(r.variant_title)))return!1;let n=r.selling_plan_allocation?.selling_plan?.name;return!(n&&!e.includes(n))})}};var Nl=class extends dt{constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.progressBarConfig.update(e.progressBarConfig),await this.checkMilestoneTryCatch(),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.progressBarConfig}async startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-progressbar"),await this.checkMilestoneTryCatch()}async checkMilestoneTryCatch(){try{await this.checkMilestone()}catch(e){ae(e,"apply-milestones",{engagementTrigger:this.engagementTrigger})}}async checkMilestone(){let e=await me.getCurrent().getNormalisedCart(),r=this.engagementTrigger.progressBarConfig,n=[],o=[],i=[],s,a,l=[...r.milestones];for(let A of l){if(A.rewardType!==ou.FREE_AUTO_GIFT)continue;if(A.isUIOnly&&!A.allowATC){w.verbose(`Skipping milestone ${A.label} as it is UI only and does not allow ATC`);continue}let B=A.items[0],q=A.reached,P=e.items.find(Q=>(Q.vID===B.vID||Q.mID===B.mID)&&Q.properties._letscooee_campaign===this.engagementTrigger.shortID);q&&(s=A,a=P),P&&n.push(P),!q&&P&&r.removeIneligibleItem?(w.verbose(`Removing free gift ${P.vID} from cart`),i.push(P)):q&&!P&&(w.verbose(`Adding free gift ${B.vID} to cart`),o.push(B))}r.restrictToLatestFreebie&&s&&(a?(n=n.filter(A=>A.vID!==a.vID),o=[]):o=[s.items[0]],i.push(...n));let f={},d={};i.length&&i.forEach(A=>d[A.key??A.vID]=0),o.length&&o.forEach(A=>d[A.vID]=1);let m=r.coupons,_=[];if(m?.length){_=m.map(q=>q.couponCode);let A=me.getCurrent().discount_codes?.map(q=>q.code)??[];_.every(q=>A.some(P=>P===q))||(f.discount=_.join(","))}if(wt.hasKeys(d)&&(f.updates=d),!wt.hasKeys(f))return;let y=await cv(f,this.engagementTrigger);et.get().refreshUI(y,!1);let C=y?.items,N=[];for(let A of o){let B=C.find(q=>_?.length?q.id+""===A.vID&&q.discounts?.some(P=>_.includes(P.title)):q.id+""===A.vID);B&&N.push(B)}N.length&&this.updatePrivateAttributesInItem(N).catch(A=>ae(A,"remove-free-gifts",{engagementTrigger:this.engagementTrigger,extra:{productAddedByCooee:N}}))}async updatePrivateAttributesInItem(e){await Promise.all(e.map(r=>lv(r,{properties:this.engagementTrigger.getPrivateAttributesForLineItem()})))}};var Ws=class extends dt{constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.content.update(e.content),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.content}async startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-savings-bar")}};var Pl=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!!this.engagementTrigger.content?.videoConfig}async startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}let e,r=this.engagementTrigger.content.videoConfig;r.template==="FLOATING_POPUP"?e="cooee-video-popup":r.template==="STORY"?e="cooee-video-stories":e="cooee-video-playlist",this.createAngularWidget(e)}};var Ll=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}async startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-sticky-atc")}};var Ml=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}async startRendering(){let e=this.getParentElement(`inner-letscooee-${this.engagementTrigger.shortID}`);this.rootContainer.appendChild(e),document.addEventListener("letscooee:inbound:cta:add-bundle",this.inboundCTAListener.bind(this),!1)}async inboundCTAListener(e){let r=this.engagementTrigger,n=`Engagement(id: ${r.engagementID}, shortID: ${r.shortID})`,o=e.detail;if(!wt.hasKeys(o)){w.error(`No detail received for ${n}`);return}w.log("Detail received for BYOB",o);let i=o.campaignID??o.campaignId??o.campaign_id;if(i!==r.shortID&&i!==r.engagementID){w.warn(`Current ${n} is not BYOB. Received: ${i}`);return}let s=o.items;if(!s?.length)return;let a=s.map(l=>new Nt({mID:l.product_id,vID:l.variant_id,quantity:l.quantity||1}));await new dn(this.triggerContext).execute({embeddedItems:a,clickAction:{at:we.ADD_BUNDLE,applyDiscount:!0}})}};var sm=!1,am=!1,Bl=null,Ul=null,yv=!1;function vv(){yv||(yv=!0,In(()=>{gv(document.body,{childList:!0,subtree:!0},500,hv).subscribe(()=>{vt.currentEngagements.forEach(t=>t.rerenderIfDeleted()),dt.currentEngagements.forEach(t=>t.rerenderIfDeleted())})}))}function cm(t){if(vv(),sm){w.verbose("Cart widget processing in progress, queuing latest triggers"),Bl=t;return}sm=!0;try{yT(t)}finally{if(sm=!1,Bl){let e=Bl;Bl=null,w.verbose("Processing queued cart triggers"),cm(e)}}}function lm(t){if(vv(),am){w.verbose("Page widget processing in progress, queuing latest triggers"),Ul=t;return}am=!0;try{vT(t)}finally{if(am=!1,Ul){let e=Ul;Ul=null,w.verbose("Processing queued page triggers"),lm(e)}}}function yT(t){_v(dt.currentEngagements,t);for(let e of t){w.info(`${e} received as cart embed`);let r=Ev(dt.currentEngagements,e);if(r&&!e.isSubscriptionUpsell()){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}w.verbose(`${e} is new`);let n;if(e.isProgressBar())n=new Nl(e);else if(e.isSubscriptionUpsell()){Ol.renderCartUpsell(e);continue}else e.isSavingsBar()?n=new Ws(e):n=new dt(e);dt.currentEngagements.add(n),n.renderSilently()}}function vT(t){_v(vt.currentEngagements,t);for(let e of t){w.info(`${e} received as page embed`);let r=Ev(vt.currentEngagements,e);if(r){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}w.verbose(`${e} is new`);let n;e.isShoppableVideo()?n=new Pl(e):e.isBYOB()?n=new Ml(e):e.isStickyATC()?n=new Ll(e):e.isSavingsBar()?n=new Ws(e):n=new vt(e),vt.currentEngagements.add(n),n.renderSilently()}}function Ev(t,e){for(let r of t)if(r.matches(e))return r}function _v(t,e){let r=new Set(e.map(n=>n.shortID));for(let n of t)r.has(n.engagementTrigger.shortID)||n.destroy()}var bv=new Kt,wv=0;bv.pipe(Xt(50),Kp(t=>qp(Promise.all([ET().catch(e=>{ae(e,"load-page-widgets",{extra:{firstLoad:t}})}),_T().catch(e=>{ae(e,"load-cart-widgets",{extra:{firstLoad:t}})})])))).subscribe();function Ii(t=!1){xr(mr).then(()=>{bv.next(t)})}function Sv(){dt.currentEngagements.forEach(t=>t.rerenderAfterCartOpened())}async function dv(t){let e=await mn();return Object.assign(t,e),Jt("/v1/engagement/get-variant",t)}async function ET(){wv++,wv===1?w.info("Fetch page widgets (after \u23F0",Io()+" of SDK load)"):w.info("Fetch page widgets");let t=await mn(),e=E({},t);Jt("/v1/engagement/page-widgets",e).then(r=>{w.info(`Page widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new Tt(o));lm(n)}).catch(r=>{w.error("Error sending widget getter",r)})}async function _T(){w.info("Fetch cart widgets");let t=await mn(),e=E({},t);Jt("/v1/engagement/cart-widgets",e).then(r=>{w.info(`Cart widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new Tt(o));cm(n)}).catch(r=>{w.error("Error sending widget getter",r)})}var kl=class{static processConfiguration(){let e=Ye.get();!e.gaMeasurementID||!e.gaEnabled||this.sendClientID()}static async sendClientID(){let e=await this.getClientID();e&&Fl({gaClientID:e})}static async getClientID(){let e=await qe.get("gacid"),r=await this.getClientIDViaGTag();if(e!==r)return await qe.set("gacid",r),r}static async getClientIDViaGTag(){let r=Ye.get().gaMeasurementID;if(!(!r||!window.gtag))return new Promise(n=>{window.gtag("get",r,"client_id",o=>{n(o)})})}};var Hl=class t{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}init(){Ds.get("conf",{}).then(e=>this.updateGlobalConfig(e)),window.CooeeSDK.cartChange$.subscribe(()=>{Ii()})}async processAppConfigurations(e){w.verbose("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);Ds.set("conf",r).catch(n=>w.error(n)),kl.processConfiguration(),r.website&&(Xg(r.website.commonJS),ao(r.website.commonCSS)),window.CooeeSDK.cartDrawerToggle$.pipe(Xt(10)).subscribe(async({open:n})=>{w.info("Cart drawer is now",n?"open":"closed"),n&&(Sv(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=Ce.globalRef.config.update(e);return et.forceUpdate(),w.verbose("App configurations",r),r}async trackViewCartEvent(){let e=await me.getCurrent().getNormalisedCart(),r={value:e.amount,currency:e.currency},n={items:e.items,amount:r,drawer:!0};xt(new xe("View Cart",n))}};var mr=new Ss(1),Tv="App ID or Shopify shop is not set",um,qr=class t{coreService=Hl.getInstance();userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return um||(um=new t),um}async populateAuthDataFromStorage(){await this.getOrSetDeviceIDSafe(),this.userID=await qe.get("id"),this.updateAPIClient()}async isAuthenticated(){return!this.deviceID||await this.isNewSessionRequired()?!1:!await this.notSynced()}authenticate(e){if(w.verbose("Initialising SDK",e),jy(navigator.userAgent)){w.info("This seems to be a bot. Disabling SDK");return}this.appID=e.appID,this.shopifyShop=e.shopifyShop,this.checkForNewSessionOnPageLoad().then(async()=>{mr.next(!0),mr.complete()}).catch(r=>{r?.message?.includes(Tv)&&ae(r,"initiate-session",{extra:e}),w.error("Unable to initiate session",r)})}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await qe.set("id",e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await qe.set("did",e.deviceID)),this.updateAPIClient())}async checkSessionAndGetContext(){return await this.checkForNewSessionUnsafe(!1),this.getContext()}async checkForNewSessionOnPageLoad(){await this.checkForNewSessionSafe(!0)}async getOrSetDeviceIDSafe(){await dl.request("gen_did",async()=>{let e=await qe.get("did");e||(e=new yt().toHexString(),await qe.set("did",e)),this.deviceID=e,w.info("Device ID:",this.deviceID)})}async getContext(){Ct.set("lastUsedTime",new Date().getTime());let[e,r,n]=await Promise.all([Ct.get("id",""),qe.get("sessionNumber",1),Ct.get("landing",{})]);return Uo({"cooee_session.number":r}),Va("Visitor Session",{id:e,number:r,landing_page:n}),{sessionID:e,sessionNumber:r,landingPage:n}}async checkForNewSessionSafe(e){await this.checkForNewSessionUnsafe(e)}async checkForNewSessionUnsafe(e){let r=!1;if(await this.isNewSessionRequired()?(w.info("New session to be started"),await this.startNewSession(),e=!0,r=!0):await this.notSynced()&&(r=!0),e){let n=await this.getContext();w.info(`Session ID: ${n.sessionID} & number: ${n.sessionNumber}`),await this.validateSessionFromServer(Z(E({},n),{newSession:r})),await Ct.set("synced",!0)}}async startNewSession(){w.verbose("Starting new session"),await Ct.clear(),w.verbose("Cleared SessionStorage before starting new session");let e=new Date,r=new yt().toHexString();w.verbose("New session ID to be used",r);let n=await qe.get("sessionNumber",0)+1;await Promise.all([qe.set("sessionNumber",n),Ct.set("id",r),Ct.set("lastUsedTime",e.getTime()),Ct.set("landing",Ks())])}async isNewSessionRequired(){if(!await Ct.get("id"))return!0;let e=await Ct.get("lastUsedTime",0);return e?(new Date().getTime()-e)/1e3>1800:!0}async notSynced(){return!await Ct.get("synced",!1)}async getSessionValidateData(e){if(!this.appID&&!this.shopifyShop)throw new Error(Tv);let r=await zy(),n=jc();return Z(E(E({deviceID:this.deviceID,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),n),{sdk:Gs,ad:pl.getAdParams(),occurred:wT(fe().jsLoadTime),properties:{}})}async validateSessionFromServer(e){w.verbose("Validating session with server"),await this.populateFirstSeen();let r=await this.getSessionValidateData(e);try{let n=await Jt("/v1/event/validate-session",r),o=n.data;w.info(`Auth finished in \u23F0 ${Xr(n.timeTakenMs)}`),w.verbose("Validate session Response",o),await this.coreService.processAppConfigurations(o.appSettings),await this.storeAndPopulateAuthData(o)}catch(n){throw w.error(n),n}}async populateFirstSeen(){let e=await qe.get("firstSeen"),r=e?new Date(e):new Date;e||await qe.set("firstSeen",r.toISOString()),xv(r),Va("Visitor Info",{first_seen:r.toISOString()})}updateAPIClient(){this.userID&&w.info("User ID:",this.userID),bi.trackDeviceID(this.deviceID),Iv(this.deviceID),Va("Visitor Info",{device_id:this.deviceID,user_id:this.userID}),Dh({id:this.deviceID})}};function wT(t){return(new Date().getTime()-t.getTime())/1e3>1800?new Date:t}var bT="keepalive"in new Request(""),zr=new Headers;xT();async function mn(){let[t]=await Promise.all([qr.getInstance().checkSessionAndGetContext()]);return E(E({},jc()),t)}function Si(t){xr(mr).then(()=>ST(t??{}))}function ST(t){Cv("/v1/user/update",t).then(async e=>{w.verbose("Updated user profile"),await qr.getInstance().storeAndPopulateAuthData(e.data)}).catch(e=>{w.error("Error saving user profile",e)})}function pv(t){return Jt("/v1/event/generate-discount",t)}function Fl(t){xr(mr).then(()=>TT({props:t}))}function TT(t){Cv("/v1/device/update",t).then(()=>{w.verbose("Updated device properties")}).catch(async e=>{w.error("Error saving device property",e)})}function Iv(t){t&&zr.set("cooee-device-id",t)}function xv(t){t&&zr.set("cooee-first-seen",t.toUTCString())}function Jt(t,e){return Rv("POST",t,e)}function Cv(t,e){return Rv("PUT",t,e)}function Rv(t,e,r){if(!os()&&!fe().flags?.allowEvents)return w.log(`Rejecting ${t} ${e} as this is not e-commerce app`),Promise.reject();if(e.startsWith("http")||(e=yr.apiURL+e),r&&!bT&&e.includes(nm))try{return IT(e,zr,r)}catch(o){throw ae(o,"http-request",{extra:{body:JSON.stringify(r)}}),o}let n={method:t,headers:zr,keepalive:!1};return r&&(n.body=JSON.stringify(r)),en(e,n)}function IT(t,e,r){return new Promise((n,o)=>{let i=new XMLHttpRequest;i.open("POST",t,!0),e.forEach((s,a)=>{i.setRequestHeader(a,s)}),i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(i.status>=200&&i.status<300)try{if(i.getResponseHeader("Content-Type")?.includes("application/json")){let a=JSON.parse(i.responseText);n({data:a,headers:e,request:i,status:i.status,statusText:i.statusText})}else o(new Error("Content-Type of response header is not json"))}catch(s){o(s)}else o(new Error(`Received status - ${i.status}(${i.statusText})`))},i.onerror=()=>{o(new Error("Network error occurred during the request."))},i.send(JSON.stringify(r))})}function xT(){zr.set("Content-Type","application/json; charset=utf-8"),zr.set("cooee-sdk",Gs),zr.set("cooee-sdk-code",Sm.toString()),zr.set("cooee-sdk-version",qs),zr.set("cooee-shop-name",ic()??""),yr.debug&&zr.set("cooee-sdk-debug",String(1))}var $l=class{modifications=[];constructor(){}execute(e){for(let r of e){if(!r.experimentConfig)continue;this.executeExperiment(r)&&this.trackExperimentRan(r)}if(document.querySelector("#lc-hide-body")?.remove(),!document.body){Sa("No body element found","error");return}this.setupMutationObserver()}executeExperiment(e){let r=e.experimentConfig?.modifications;if(!r?.length)return w.log("Nothing to experiment",e.toString()),!0;let n=!1;for(let o of r){if(!o.cssSelector){w.verbose("No CSS Selector available",e?.toString());continue}this.modifications.push(o);let i=Array.from(document.querySelectorAll(o.cssSelector));i?.length&&(this.executeSingleModification(o,i),n=!0)}return n}executeSingleModification(e,r){if(r?.length)for(let n of r)Object.assign(n.style,e.style),e.type==="TEXT"&&e.text?n.innerHTML=e.text:e.type==="IMAGE"&&this.updateImage(e,n),e.moveTo?.selector&&this.changePlacement(e,n).catch(console.error)}async changePlacement(e,r){let n=await xn(e.moveTo.selector);if(n)switch(e.moveTo.position){case Ot.BEFORE1:{r.nextElementSibling!==n&&n.parentElement?.insertBefore(r,n);break}case Ot.INSIDE_FIRST1:{n.firstChild!==r&&n.insertBefore(r,n.firstChild);break}case Ot.INSIDE_LAST1:{n.lastChild!==r&&n.appendChild(r);break}case Ot.AFTER1:default:r.previousElementSibling!==n&&n.parentElement?.insertBefore(r,n.nextSibling)}}trackExperimentRan(e){if(e.id==="preview"){w.warn("Skipping experiment attribution as its preview",e.toString());return}Av({name:"CE Experiment Start",experiment:new Pn(e)}).catch(r=>{w.error("Fail to track experiment",r)})}setupMutationObserver(){new MutationObserver(r=>{r.forEach(n=>{n.addedNodes.forEach(o=>{o instanceof HTMLElement&&this.modifications.forEach(i=>{o.matches&&o.matches(i.cssSelector)?(w.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,[o])):o.querySelectorAll&&(w.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,Array.from(o.querySelectorAll(i.cssSelector))))})})})}).observe(document.body,{childList:!0,subtree:!0})}updateImage(e,r){let n=e.image?.lg?.src,o=e.image?.sm?.src;!n&&!o||(r instanceof HTMLPictureElement?this.updatePictureElement({desktop:n,mobile:o},r):this.updateImageElement({desktop:n,mobile:o},r))}updateImageElement(e,r){jr()&&e.mobile?(r.setAttribute("src",e.mobile),r.removeAttribute("srcset")):e.desktop&&(r.setAttribute("src",e.desktop),r.removeAttribute("srcset"))}updatePictureElement(e,r){if(r.innerHTML="",e.mobile){let o=document.createElement("source");o.srcset=e.mobile,o.media="(max-width: 767px)",r.append(o)}if(e.desktop){let o=document.createElement("source");o.srcset=e.desktop,o.media="(min-width: 768px)",r.append(o)}let n=document.createElement("img");n.src=e.desktop??e.mobile??"",r.append(n)}};async function Av(t){let e=await mn(),r=E(E({},t),e);await Jt("/v1/event/experiment",r)}function Vl(){CT().catch(t=>ae(t,"fetch-experiments"))}async function CT(){if(!fe().activeExperiments)return;await qr.getInstance().isAuthenticated()?await Dv():(await xr(mr),await Dv())}async function Dv(){w.info("Fetch experiments after \u23F0",Io()+" of SDK load");let t=await mn(),e=E({},t);Jt("/v1/engagement/experiments",e).then(async r=>{w.info(`Experiments fetched in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.experiments.map(o=>new Tt(o));new $l().execute(n)}).catch(r=>{w.error("Error sending experiment getter",r)})}var Wl=class{runtimeData=fe();meddle(){let e=Ce.globalRef;e.account=e.account??[],e.profile=e.profile??[],e.events=e.events??[],e.page=e.page??[],this.meddlePage(),this.meddleAccount(),this.meddleEvents(),this.meddleProfile(),this.exposeMethods()}exposeMethods(){let e=Ce.globalRef;e.loadWidgets=e.loadCartWidgets=e.loadPageWidgets=()=>{Ii()},e.loadExperiments=()=>{Vl()},e.testCartUpdate=this.testCartUpdate.bind(this),e.previewWidget=Ce.previewWidget.bind(Ce),e.previewPopup=Ce.previewPopup.bind(Ce),e.executeCTA=(r,n)=>{new dn(r).execute(n)},e.sendEvent=r=>{xt(r)}}overwritePush(e,r){Lr(e,"push",r)}meddleAccount(){this.overwritePush(Ce.globalRef.account,(...e)=>{this.processAccount(e[0])}),Ce.globalRef.account.forEach(this.processAccount.bind(this))}meddleEvents(){this.overwritePush(Ce.globalRef.events,(...e)=>{this.processEvent(e[0])}),Ce.globalRef.events.forEach(this.processEvent.bind(this))}meddleProfile(){this.overwritePush(Ce.globalRef.profile,(...e)=>{this.processProfile(e[0])}),Ce.globalRef.profile.forEach(this.processProfile.bind(this))}processAccount(e){e&&(e.appID&&Ce.authenticate(e),e.flags&&(this.runtimeData.flags=e.flags))}processEvent(e){e&&(xm.includes(e[0])?Ce.sendEvent(e[0],e[1],E({occurred:this.runtimeData.jsLoadTime},e[2])):Ce.sendEvent(e[0],e[1],e[2]))}processProfile(e){e&&Ce.updateProfile(e)}processPageName(e){e&&Ce.setPageName(e)}meddlePage(){this.overwritePush(Ce.globalRef.page,(...e)=>{this.processPage(e[0])}),Ce.globalRef.page.forEach(this.processPage.bind(this))}processPage(e){e.currentItem&&RT(e.currentItem),e.currency&&(fe().currencyCode=e.currency),e.shopCurrency&&(this.runtimeData.shopCurrencyCode=e.shopCurrency),e.moneyFormat&&(this.runtimeData.moneyFormat=e.moneyFormat),e.jsLoad&&(this.runtimeData.jsLoadTime=e.jsLoad),e.locale&&(this.runtimeData.locale=e.locale),e.pageName&&Ce.setPageName(e.pageName),e.activeExperiment&&(this.runtimeData.activeExperiments=e.activeExperiment),e.cart&&me.getCurrent().update(e.cart),e.customContext&&(this.runtimeData.customContext=E(E({},this.runtimeData.customContext),e.customContext))}async testCartUpdate(){if(fe().pageName!=="product"){window.alert("This feature is only available on a product page");return}let e=mv();if(e||(e=fe().currentItem?.vID),!e){window.alert("Could not find a variant to test. Please try a different product page");return}let r=new Tt({id:"preview",shortID:"1",redirectBehaviour:tr.CART_DRAWER});await new dn(new Cr(new Date,r)).execute({clickAction:{at:we.ADD_TO_CART},embeddedItem:new Nt({vID:e})})}};function RT(t){let e=fe();if(e.currentItem&&e.currentItem.vID!==t.vID){let r=new CustomEvent("letscooee:variant-change",{detail:{variantID:t.vID}});document.dispatchEvent(r)}e.currentItem=new Nt(t)}var xi=class{static SESSION_STORAGE=window.sessionStorage;static SESSION_STORAGE_KEY_PREFIX="cooee".concat("-");static getString(e,r){return this.getItem(e)||r}static setString(e,r){this.setItem(e,r)}static remove(e){this.removeItem(e)}static getItem(e){return this.SESSION_STORAGE.getItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}static setItem(e,r){this.SESSION_STORAGE.setItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e),r)}static removeItem(e){this.SESSION_STORAGE.removeItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}};var AT=1e3,DT=10,fm=0,pm=new Date;function mm(t){xi.remove("sleid"),pm=t??new Date}function Ov(){if(window.scrollY){let t=Lv();Nv(t)&&Pv(t)}In(()=>{OT()})}function OT(){ho(window,"scroll").pipe(Xt(AT),pn(()=>{let t=Lv();if(t>100){w.warn("Received scroll percent is more than 100",t);return}if(Nv(t))return t})).subscribe(t=>{Pv(t)})}function Nv(t){return Math.abs(fm-t)>=DT||fm!==t&&t===100}function Pv(t){if(t==null)return;let e={percent:t,timeMS:new Date().getTime()-pm.getTime()};fm=t;let r=xi.getString("sleid",""),n=new xe("CE Scroll",e,null,r);xt(n),xi.setString("sleid",n.id.toHexString()),pm=new Date(n.occurred)}function Lv(){let t=window.document.body.scrollHeight,e=window.innerHeight;return Math.ceil((window.scrollY+e)/t*100)}function Mv(){NT()}function NT(){let t=window.fetch;window.fetch=async function(e,r){try{await PT(e,r)}catch(n){ae(n,"modify-graphql-request",{extra:{body:JSON.stringify(r?.body)}})}return t(e,r)},w.verbose("Securely overwritten window.fetch method for graphql query")}async function PT(t,e){let r=typeof t=="string"?t:t instanceof Request?t.url:"";if(!(r.includes("graphql.json")&&e?.method==="POST")||!e.body)return;let n;if(typeof e.body=="string")try{n=JSON.parse(e.body)}catch{return}else n=e.body;n?.variables?.input&&(w.verbose("Intercepted fetch request of:",r),n?.query.includes("cartCreate")&&(e.body=await LT(n),MT()))}async function LT(t){let e=t.variables.input.attributes??[],r=await Ga("Buy Now");return t.variables.input.attributes=[...e,...r],JSON.stringify(t)}function MT(){let t=fe().currentItem;if(!t)return;let e=new xe("Buy Now Clicked",{items:[t]});xt(e)}var Ci=class{constructor(e,r){this.selectors=e;this.eventName=r;this.selectorString=e.join(",")}static INSTANCE;elements;selectorString;clickListenerCallback=e=>{let r=e.currentTarget,n=new xe(this.eventName,{class:r.className||void 0,tagName:r.tagName||void 0,id:r.id||void 0});xt(n),this.removeClickListener(this.clickListenerCallback)};listenSilently(){this.listen().catch(e=>w.error(e))}async listen(){this.elements=await Af(this.selectorString),this.elements.forEach(e=>{e.addEventListener("click",this.clickListenerCallback)})}removeClickListener(e){this.elements?.forEach(r=>{r.removeEventListener("click",e)})}};var jl=class t extends Ci{static selectors=[".product__thumbnail-list-inner > button","product-gallery-navigation > button",".product-media--thumb-container",".product-images-inner > img",".m-product-media",".swiper-button-control",".media__thumb",".slick-arrow",".productView-img-container.product-single__media",".product-gallery__thumbnail_item_inner"];constructor(){super(t.selectors,"Item Thumbnail Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var Gl=class t extends Ci{static selectors=[".jdgm-widget.jdgm-preview-badge.jdgm-preview-badge--with-link.jdgm--done-setup","reviewsio-product-ratings",".ruk_rating_snippet.tracked:not(.hidden)","a > .loox-rating",".yotpo-reviews-star-ratings-widget",".yotpo.lp-hero__reviews",".pr-rating > a",".rivyoReviewWidget"];constructor(){super(t.selectors,"Review Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var BT=[".gokwik-checkout button","button.cart__checkout-button","button.cart__checkout","button#checkout","button#checkout2",'button[id*="checkout" i]','button[name*="checkout" i]','button[class*="checkout" i]'].join(",");function Bv(){In(()=>{w.verbose("Execution order:","document ready"),UT()})}function UT(){let t=window.location.hash?.substring(1);if(t)if(t.includes("initiate-checkout")){document.dispatchEvent(new Event("letscooee:outbound:third-party-initiate-checkout"));let e=document.querySelector(BT);if(!e){w.verbose("No clickable cart checkout button found");return}w.verbose("Clickable cart checkout button found",e),e.click()}else t.includes("open-cart-drawer")&&et.get().open()}function kv(){window.addEventListener("kp-modal:opened",()=>{fe().isGoKwikPopupOpen=!0}),window.addEventListener("user-loggedin",t=>{let{token:e}=t.detail;e&&Si({goKwikToken:e})}),window.gokwikSdk?Uv():window.addEventListener("gokwikLoaded",Uv)}function Uv(){window.gokwikSdk&&window.gokwikSdk.on("checkout_initiated",async()=>{let t=await me.getCurrent().getNormalisedCart(),e={via:"GoKwik",items:t.items,cartToken:t.token,amount:{value:t.amount,currency:t.currency}},r=new xe("Checkout Started",e);xt(r)})}var ql=class{static watch(){let e=Dm();(e==="1"||e==="on")&&Fl({debugTill:this.getDebugMillis()}),e==="on"?sessionStorage.cooeeDebug="1":e==="off"&&sessionStorage.removeItem("cooeeDebug"),sessionStorage.cooeeDebug&&this.renderDebugBar()}static renderDebugBar(){let e=document.createElement("cooee-debugger");e.logs=this.logs,In(()=>{document.body.appendChild(e)})}static getDebugMillis(){return new Date().getTime()+360*60*1e3}};var Ce=class{static globalRef;static authenticated;static async initForMerchantWebsiteOnly(e){window.cooeeSDKPreview||(this.initGlobalReference(e),await qr.getInstance().populateAuthDataFromStorage(),this.autoAuthenticate(),new Wl().meddle(),Bm(),Ii(!0),Vl(),Xy(),nv(),Mv(),Bv(),Ov(),Gl.getInstance().listenSilently(),jl.getInstance().listenSilently(),kv(),kT(),ql.watch())}static async initForAll(){this.injectWidgetAssets()}static initGlobalReference(e){window.CooeeSDK||Lr(window,"CooeeSDK",{}),this.globalRef=window.CooeeSDK,Lr(this.globalRef,"config",new Ye),Lr(this.globalRef,"runtimeData",{sdkLoadTime:e,jsLoadTime:new Date,lastEnterActive:new Date}),Lr(this.globalRef,"uaParser",new Tr,!0),Lr(this.globalRef,"cart",me.getCurrent()),Lr(this.globalRef,"cartChange$",rv()),Lr(this.globalRef,"cartDrawerToggle$",et.cartDrawerToggle$.asObservable()),w.verbose("Global reference initialised"),new Pc(()=>{this.globalRef.uaParser=new Tr})}static injectWidgetAssets(){Yg(yr.widgetURL,"cooee-widget-sdk"),vp()}static autoAuthenticate(){let e=ic();e&&this.authenticate({shopifyShop:e})}static authenticate(e){if(this.authenticated)return;w.info("Begin auth after \u23F0",Io(),"of SDK load");let r=e.appID?.trim(),n=e.shopifyShop;if((Cf(r)||r.length!==24)&&Cf(n)){w.warn("Cooee App ID or Shop name is not configured");return}this.authenticated=!0,qr.getInstance().authenticate(e)}static sendEvent(e,r,n){let o=new xe(e,r,n?.triggerData);n?.occurred&&(o.occurred=n.occurred),xt(o)}static updateProfile(e){for(let r in e)if(r.toLowerCase().startsWith("ce "))throw new Error("User property name cannot start with 'CE '");Si(e)}static setPageName(e){if(!e)return;let r=fe(),n=r.pageName;if(e===n)return;if(r.pageName=e,Tm.some(s=>e.includes(s))){mm();return}let o={};n&&(o.ps=n);let i=new xe("CE Screen View",o);i.occurred=r.jsLoadTime,xt(i),mm(i.occurred)}static previewPopup(e,r){new Hn(r).render(e)}static previewWidget(e){new vt(new Tt(e)).renderSilently()}};function kT(){if(window.opener){try{window.opener.postMessage({action:"COOEE_READY_FOR_PREVIEW"},"*")}catch(t){w.error(t)}window.addEventListener("message",t=>{if(w.verbose("Received event",t),!t.origin.includes("letscooee.com")&&!t.origin.includes("localhost"))return;let e=t.data;typeof e=="object"&&(e.action==="POPUP_PREVIEW"?(Ce.previewPopup(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)):e.action==="WIDGET_PREVIEW"&&(Ce.previewWidget(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)))})}}var Fv=new Date;Rm();Om();w.verbose("Execution order:","top");window.cooeeShopifyScriptLoaded||(window.cooeeShopifyScriptLoaded=!0,(async()=>(w.verbose("Execution order:","IIFE start"),await Ce.initForMerchantWebsiteOnly(Fv),await Ce.initForAll(),FT(),w.verbose("Execution order:","IIFE end")))());w.verbose("Execution order:","bottom");function FT(){Am()&&import("./debug-logs-LR2XJJHM.js").then(({printAllDebugLogs:t})=>t(Fv))}
61
+ ${o}`;ao(`#${i} { ${s} }`)}injectOuterCSSOnly(){let e=this.engagementTrigger.content?.outerCSS?.trim();if(!e)return;let r=this.rootContainer.id;ao(`#${r} { ${e} }`)}isInViewport(){let e=this.rootContainer?.getBoundingClientRect();if(!e)return!1;let r=window.innerHeight||document.documentElement.clientHeight,o=(Math.min(e.bottom,r)-Math.max(e.top,0))*e.width,i=e.width*e.height,s=o/i*100;return this.engagementTrigger.isAnySplit()?s>0:s>=30}async getWidgetContainer(e){if(this.rootContainer?.isConnected)return this.rootContainer;let r=await this.createParentElementWithPlacement(e);if(r)return r;let n=`.letscooee[data-engagement-id="${this.triggerContext.triggerData.shortID}"]`;return document.querySelector(n)}async createParentElementWithPlacement(e){let r=this.engagementTrigger.placement;if(!r?.selector)return w.info(`\u26A0\uFE0F${this.engagementTrigger} does not have a selector`),null;let n=r.selector,o;if(n.includes(":shadow")){let l=n.split(":shadow");o=(await xn(l[0].trim()))?.shadowRoot,n=l[1].trim(),o&&_p(o,!1)}w.verbose(`${this.engagementTrigger} attempt to render ${r.position} "${n}"`);let i=await xn(n,10,o??document);if(!i)return w.warn(`${this.engagementTrigger} no placement found with ${n}`),null;let s=this.generateParentElementID(),a=this.getParentElement(s);if(!e)return a;switch(r.position){case Ot.BEFORE1:case Ot.BEFORE:{i.parentElement?.insertBefore(a,i);break}case Ot.INSIDE_FIRST1:case Ot.INSIDE_FIRST:{i.insertBefore(a,i.firstChild);break}case Ot.INSIDE_LAST1:case Ot.INSIDE_LAST:{i.appendChild(a);break}case Ot.AFTER1:case Ot.AFTER:default:i.parentElement?.insertBefore(a,i.nextSibling)}return a}async runChoresBeforeRender(){if(this.isExclusionWithBVariation)return;if(!this.isAllOkToRender()){w.info(`\u26A0\uFE0F ${this.engagementTrigger} could not be rendered`);return}w.verbose(`${this.engagementTrigger} will be rendered`);let e;try{e=await Rl(this.engagementTrigger)}catch(r){w.info(`\u203C\uFE0F${this.engagementTrigger} could not render as items failed to refresh`,r);return}if(!this.engagementTrigger.isCollectionPromoted()&&!e?.length&&this.engagementTrigger.isProductPromoted()){w.info(`\u203C\uFE0F${this.engagementTrigger} could not render as no products promoted`);return}this.engagementTrigger.items=e,await this.startRendering()}updateItems(e,r){let n=this.getItemDiff(e,r),o=this.getItemDiff(r,e);r.push(...n);for(let i of o)Jr.remove(r,i)}getItemDiff(e,r){return e.filter(n=>!r.some(o=>o.selectedOrFirstVariant.value.mID===n.selectedOrFirstVariant.value.mID))}};var dt=class extends vt{static currentEngagements=new Set;constructor(e){super(e)}rerenderAfterCartOpened(){this.rerenderIfDeleted(),this.checkAndSendEvent()}observeWidgetContainerInViewport(){return this.getVariation()}generateParentElementID(){let e=super.generateParentElementID();return this.engagementTrigger.isSubscriptionUpsell()&&(e+=`-${this.engagementTrigger.items[0].selectedOrFirstVariant.value.mID}`),e}checkAndSendEvent(){if(!et.get().isOpen()&&fe().pageName!=="cart"){w.log("Do not send display event as neither the cart drawer nor the cart page is open.");return}return super.checkAndSendEvent()}};var gT=t=>t,hv=t=>t.filter(e=>e.removedNodes&&e.removedNodes.length>0);function gv(t,e={childList:!0,subtree:!0},r=500,n=gT){return fl(o=>{let i=new MutationObserver(s=>o(s));return i.observe(t,e),i},(o,i)=>i.disconnect()).pipe(pn(o=>n(o)),Yp(o=>o.length>0),Xt(r))}var Ol=class t{constructor(e,r){this.engagementTrigger=e;this.element=r;this.cartItems=me.getCurrent().items}cartItems;static renderCartUpsell(e){let r=e.placement;if(!r?.selector){w.warn(`No placement available for ${e.objective}`,e.shortID);return}let n=Array.from(document.querySelectorAll(r.selector));if(!n?.length){w.warn(`No placement found for ${e.objective}`,e.shortID);return}for(let o of n)new t(e,o).render()}render(){let e=this.findCartItemFromHTMLElement();if(!e||this.engagementTrigger.skipSubscribedItems&&e.selling_plan_allocation)return;let r=this.engagementTrigger.items.find(d=>d.mID===e.product_id.toString());if(!r)return;let n=r.vars.find(d=>d.mID===e.id.toString());if(!n)return;let o=new Ur(n),i=e.selling_plan_allocation?.selling_plan;if(i)for(let d of o.sellingPlans??[])d.mID===i.id.toString()&&(d.isSelected=!0,o.changeSellingPlan(d));let s=new Rt(r);s.vars=[o],s.selectedOrFirstVariant.value=o;let a=`lc-cart-item-${this.engagementTrigger.shortID}-${r.mID}`;this.element.classList.add(a);let l=new Tt(this.engagementTrigger);l.placement.selector=`.${a}`,l.items=[s];let f=new dt(l);f.renderSilently(),this.watchForCartItemDeletion(f,a)}watchForCartItemDeletion(e,r){let n=new MutationObserver(o=>{o.forEach(i=>{i.removedNodes.forEach(s=>{s===this.element&&(w.verbose(`${r} has been removed`),e.destroy(),n.disconnect())})})});n.observe(this.element.parentElement,{childList:!0,subtree:!0})}findCartItemFromHTMLElement(){let e=this.element.innerHTML;return this.cartItems.find(r=>{if(!(e.includes(r.url)||e.includes(r.variant_id))&&(!e.includes(r.product_title)||r.variant_title&&!e.includes(r.variant_title)))return!1;let n=r.selling_plan_allocation?.selling_plan?.name;return!(n&&!e.includes(n))})}};var Nl=class extends dt{constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.progressBarConfig.update(e.progressBarConfig),await this.checkMilestoneTryCatch(),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.progressBarConfig}async startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-progressbar"),await this.checkMilestoneTryCatch()}async checkMilestoneTryCatch(){try{await this.checkMilestone()}catch(e){ae(e,"apply-milestones",{engagementTrigger:this.engagementTrigger})}}async checkMilestone(){let e=await me.getCurrent().getNormalisedCart(),r=this.engagementTrigger.progressBarConfig,n=[],o=[],i=[],s,a,l=[...r.milestones];for(let A of l){if(A.rewardType!==ou.FREE_AUTO_GIFT)continue;if(A.isUIOnly&&!A.allowATC){w.verbose(`Skipping milestone ${A.label} as it is UI only and does not allow ATC`);continue}let B=A.items[0],q=A.reached,P=e.items.find(Q=>(Q.vID===B.vID||Q.mID===B.mID)&&Q.properties._letscooee_campaign===this.engagementTrigger.shortID);q&&(s=A,a=P),P&&n.push(P),!q&&P&&r.removeIneligibleItem?(w.verbose(`Removing free gift ${P.vID} from cart`),i.push(P)):q&&!P&&(w.verbose(`Adding free gift ${B.vID} to cart`),o.push(B))}r.restrictToLatestFreebie&&s&&(a?(n=n.filter(A=>A.vID!==a.vID),o=[]):o=[s.items[0]],i.push(...n));let f={},d={};i.length&&i.forEach(A=>d[A.key??A.vID]=0),o.length&&o.forEach(A=>d[A.vID]=1);let m=r.coupons,_=[];if(m?.length){_=m.map(q=>q.couponCode);let A=me.getCurrent().discount_codes?.map(q=>q.code)??[];_.every(q=>A.some(P=>P===q))||(f.discount=_.join(","))}if(wt.hasKeys(d)&&(f.updates=d),!wt.hasKeys(f))return;let y=await cv(f,this.engagementTrigger);et.get().refreshUI(y,!1);let C=y?.items,N=[];for(let A of o){let B=C?.find(q=>_?.length?q.id+""===A.vID&&q.discounts?.some(P=>_.includes(P.title)):q.id+""===A.vID);B&&N.push(B)}N.length&&this.updatePrivateAttributesInItem(N).catch(A=>ae(A,"remove-free-gifts",{engagementTrigger:this.engagementTrigger,extra:{productAddedByCooee:N}}))}async updatePrivateAttributesInItem(e){await Promise.all(e.map(r=>lv(r,{properties:this.engagementTrigger.getPrivateAttributesForLineItem()})))}};var Ws=class extends dt{constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.content.update(e.content),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.content}async startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-savings-bar")}};var Pl=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!!this.engagementTrigger.content?.videoConfig}async startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}let e,r=this.engagementTrigger.content.videoConfig;r.template==="FLOATING_POPUP"?e="cooee-video-popup":r.template==="STORY"?e="cooee-video-stories":e="cooee-video-playlist",this.createAngularWidget(e)}};var Ll=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}async startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-sticky-atc")}};var Ml=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}async startRendering(){let e=this.getParentElement(`inner-letscooee-${this.engagementTrigger.shortID}`);this.rootContainer.appendChild(e),document.addEventListener("letscooee:inbound:cta:add-bundle",this.inboundCTAListener.bind(this),!1)}async inboundCTAListener(e){let r=this.engagementTrigger,n=`Engagement(id: ${r.engagementID}, shortID: ${r.shortID})`,o=e.detail;if(!wt.hasKeys(o)){w.error(`No detail received for ${n}`);return}w.log("Detail received for BYOB",o);let i=o.campaignID??o.campaignId??o.campaign_id;if(i!==r.shortID&&i!==r.engagementID){w.warn(`Current ${n} is not BYOB. Received: ${i}`);return}let s=o.items;if(!s?.length)return;let a=s.map(l=>new Nt({mID:l.product_id,vID:l.variant_id,quantity:l.quantity||1}));await new dn(this.triggerContext).execute({embeddedItems:a,clickAction:{at:we.ADD_BUNDLE,applyDiscount:!0}})}};var sm=!1,am=!1,Bl=null,Ul=null,yv=!1;function vv(){yv||(yv=!0,In(()=>{gv(document.body,{childList:!0,subtree:!0},500,hv).subscribe(()=>{vt.currentEngagements.forEach(t=>t.rerenderIfDeleted()),dt.currentEngagements.forEach(t=>t.rerenderIfDeleted())})}))}function cm(t){if(vv(),sm){w.verbose("Cart widget processing in progress, queuing latest triggers"),Bl=t;return}sm=!0;try{yT(t)}finally{if(sm=!1,Bl){let e=Bl;Bl=null,w.verbose("Processing queued cart triggers"),cm(e)}}}function lm(t){if(vv(),am){w.verbose("Page widget processing in progress, queuing latest triggers"),Ul=t;return}am=!0;try{vT(t)}finally{if(am=!1,Ul){let e=Ul;Ul=null,w.verbose("Processing queued page triggers"),lm(e)}}}function yT(t){_v(dt.currentEngagements,t);for(let e of t){w.info(`${e} received as cart embed`);let r=Ev(dt.currentEngagements,e);if(r&&!e.isSubscriptionUpsell()){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}w.verbose(`${e} is new`);let n;if(e.isProgressBar())n=new Nl(e);else if(e.isSubscriptionUpsell()){Ol.renderCartUpsell(e);continue}else e.isSavingsBar()?n=new Ws(e):n=new dt(e);dt.currentEngagements.add(n),n.renderSilently()}}function vT(t){_v(vt.currentEngagements,t);for(let e of t){w.info(`${e} received as page embed`);let r=Ev(vt.currentEngagements,e);if(r){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}w.verbose(`${e} is new`);let n;e.isShoppableVideo()?n=new Pl(e):e.isBYOB()?n=new Ml(e):e.isStickyATC()?n=new Ll(e):e.isSavingsBar()?n=new Ws(e):n=new vt(e),vt.currentEngagements.add(n),n.renderSilently()}}function Ev(t,e){for(let r of t)if(r.matches(e))return r}function _v(t,e){let r=new Set(e.map(n=>n.shortID));for(let n of t)r.has(n.engagementTrigger.shortID)||n.destroy()}var bv=new Kt,wv=0;bv.pipe(Xt(50),Kp(t=>qp(Promise.all([ET().catch(e=>{ae(e,"load-page-widgets",{extra:{firstLoad:t}})}),_T().catch(e=>{ae(e,"load-cart-widgets",{extra:{firstLoad:t}})})])))).subscribe();function Ii(t=!1){xr(mr).then(()=>{bv.next(t)})}function Sv(){dt.currentEngagements.forEach(t=>t.rerenderAfterCartOpened())}async function dv(t){let e=await mn();return Object.assign(t,e),Jt("/v1/engagement/get-variant",t)}async function ET(){wv++,wv===1?w.info("Fetch page widgets (after \u23F0",Io()+" of SDK load)"):w.info("Fetch page widgets");let t=await mn(),e=E({},t);Jt("/v1/engagement/page-widgets",e).then(r=>{w.info(`Page widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new Tt(o));lm(n)}).catch(r=>{w.error("Error sending widget getter",r)})}async function _T(){w.info("Fetch cart widgets");let t=await mn(),e=E({},t);Jt("/v1/engagement/cart-widgets",e).then(r=>{w.info(`Cart widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new Tt(o));cm(n)}).catch(r=>{w.error("Error sending widget getter",r)})}var kl=class{static processConfiguration(){let e=Ye.get();!e.gaMeasurementID||!e.gaEnabled||this.sendClientID()}static async sendClientID(){let e=await this.getClientID();e&&Fl({gaClientID:e})}static async getClientID(){let e=await qe.get("gacid"),r=await this.getClientIDViaGTag();if(e!==r)return await qe.set("gacid",r),r}static async getClientIDViaGTag(){let r=Ye.get().gaMeasurementID;if(!(!r||!window.gtag))return new Promise(n=>{window.gtag("get",r,"client_id",o=>{n(o)})})}};var Hl=class t{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}init(){Ds.get("conf",{}).then(e=>this.updateGlobalConfig(e)),window.CooeeSDK.cartChange$.subscribe(()=>{Ii()})}async processAppConfigurations(e){w.verbose("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);Ds.set("conf",r).catch(n=>w.error(n)),kl.processConfiguration(),r.website&&(Xg(r.website.commonJS),ao(r.website.commonCSS)),window.CooeeSDK.cartDrawerToggle$.pipe(Xt(10)).subscribe(async({open:n})=>{w.info("Cart drawer is now",n?"open":"closed"),n&&(Sv(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=Ce.globalRef.config.update(e);return et.forceUpdate(),w.verbose("App configurations",r),r}async trackViewCartEvent(){let e=await me.getCurrent().getNormalisedCart(),r={value:e.amount,currency:e.currency},n={items:e.items,amount:r,drawer:!0};xt(new xe("View Cart",n))}};var mr=new Ss(1),Tv="App ID or Shopify shop is not set",um,qr=class t{coreService=Hl.getInstance();userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return um||(um=new t),um}async populateAuthDataFromStorage(){await this.getOrSetDeviceIDSafe(),this.userID=await qe.get("id"),this.updateAPIClient()}async isAuthenticated(){return!this.deviceID||await this.isNewSessionRequired()?!1:!await this.notSynced()}authenticate(e){if(w.verbose("Initialising SDK",e),jy(navigator.userAgent)){w.info("This seems to be a bot. Disabling SDK");return}this.appID=e.appID,this.shopifyShop=e.shopifyShop,this.checkForNewSessionOnPageLoad().then(async()=>{mr.next(!0),mr.complete()}).catch(r=>{r?.message?.includes(Tv)&&ae(r,"initiate-session",{extra:e}),w.error("Unable to initiate session",r)})}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await qe.set("id",e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await qe.set("did",e.deviceID)),this.updateAPIClient())}async checkSessionAndGetContext(){return await this.checkForNewSessionUnsafe(!1),this.getContext()}async checkForNewSessionOnPageLoad(){await this.checkForNewSessionSafe(!0)}async getOrSetDeviceIDSafe(){await dl.request("gen_did",async()=>{let e=await qe.get("did");e||(e=new yt().toHexString(),await qe.set("did",e)),this.deviceID=e,w.info("Device ID:",this.deviceID)})}async getContext(){Ct.set("lastUsedTime",new Date().getTime());let[e,r,n]=await Promise.all([Ct.get("id",""),qe.get("sessionNumber",1),Ct.get("landing",{})]);return Uo({"cooee_session.number":r}),Va("Visitor Session",{id:e,number:r,landing_page:n}),{sessionID:e,sessionNumber:r,landingPage:n}}async checkForNewSessionSafe(e){await this.checkForNewSessionUnsafe(e)}async checkForNewSessionUnsafe(e){let r=!1;if(await this.isNewSessionRequired()?(w.info("New session to be started"),await this.startNewSession(),e=!0,r=!0):await this.notSynced()&&(r=!0),e){let n=await this.getContext();w.info(`Session ID: ${n.sessionID} & number: ${n.sessionNumber}`),await this.validateSessionFromServer(Z(E({},n),{newSession:r})),await Ct.set("synced",!0)}}async startNewSession(){w.verbose("Starting new session"),await Ct.clear(),w.verbose("Cleared SessionStorage before starting new session");let e=new Date,r=new yt().toHexString();w.verbose("New session ID to be used",r);let n=await qe.get("sessionNumber",0)+1;await Promise.all([qe.set("sessionNumber",n),Ct.set("id",r),Ct.set("lastUsedTime",e.getTime()),Ct.set("landing",Ks())])}async isNewSessionRequired(){if(!await Ct.get("id"))return!0;let e=await Ct.get("lastUsedTime",0);return e?(new Date().getTime()-e)/1e3>1800:!0}async notSynced(){return!await Ct.get("synced",!1)}async getSessionValidateData(e){if(!this.appID&&!this.shopifyShop)throw new Error(Tv);let r=await zy(),n=jc();return Z(E(E({deviceID:this.deviceID,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),n),{sdk:Gs,ad:pl.getAdParams(),occurred:wT(fe().jsLoadTime),properties:{}})}async validateSessionFromServer(e){w.verbose("Validating session with server"),await this.populateFirstSeen();let r=await this.getSessionValidateData(e);try{let n=await Jt("/v1/event/validate-session",r),o=n.data;w.info(`Auth finished in \u23F0 ${Xr(n.timeTakenMs)}`),w.verbose("Validate session Response",o),await this.coreService.processAppConfigurations(o.appSettings),await this.storeAndPopulateAuthData(o)}catch(n){throw w.error(n),n}}async populateFirstSeen(){let e=await qe.get("firstSeen"),r=e?new Date(e):new Date;e||await qe.set("firstSeen",r.toISOString()),xv(r),Va("Visitor Info",{first_seen:r.toISOString()})}updateAPIClient(){this.userID&&w.info("User ID:",this.userID),bi.trackDeviceID(this.deviceID),Iv(this.deviceID),Va("Visitor Info",{device_id:this.deviceID,user_id:this.userID}),Dh({id:this.deviceID})}};function wT(t){return(new Date().getTime()-t.getTime())/1e3>1800?new Date:t}var bT="keepalive"in new Request(""),zr=new Headers;xT();async function mn(){let[t]=await Promise.all([qr.getInstance().checkSessionAndGetContext()]);return E(E({},jc()),t)}function Si(t){xr(mr).then(()=>ST(t??{}))}function ST(t){Cv("/v1/user/update",t).then(async e=>{w.verbose("Updated user profile"),await qr.getInstance().storeAndPopulateAuthData(e.data)}).catch(e=>{w.error("Error saving user profile",e)})}function pv(t){return Jt("/v1/event/generate-discount",t)}function Fl(t){xr(mr).then(()=>TT({props:t}))}function TT(t){Cv("/v1/device/update",t).then(()=>{w.verbose("Updated device properties")}).catch(async e=>{w.error("Error saving device property",e)})}function Iv(t){t&&zr.set("cooee-device-id",t)}function xv(t){t&&zr.set("cooee-first-seen",t.toUTCString())}function Jt(t,e){return Rv("POST",t,e)}function Cv(t,e){return Rv("PUT",t,e)}function Rv(t,e,r){if(!os()&&!fe().flags?.allowEvents)return w.log(`Rejecting ${t} ${e} as this is not e-commerce app`),Promise.reject();if(e.startsWith("http")||(e=yr.apiURL+e),r&&!bT&&e.includes(nm))try{return IT(e,zr,r)}catch(o){throw ae(o,"http-request",{extra:{body:JSON.stringify(r)}}),o}let n={method:t,headers:zr,keepalive:!1};return r&&(n.body=JSON.stringify(r)),en(e,n)}function IT(t,e,r){return new Promise((n,o)=>{let i=new XMLHttpRequest;i.open("POST",t,!0),e.forEach((s,a)=>{i.setRequestHeader(a,s)}),i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(i.status>=200&&i.status<300)try{if(i.getResponseHeader("Content-Type")?.includes("application/json")){let a=JSON.parse(i.responseText);n({data:a,headers:e,request:i,status:i.status,statusText:i.statusText})}else o(new Error("Content-Type of response header is not json"))}catch(s){o(s)}else o(new Error(`Received status - ${i.status}(${i.statusText})`))},i.onerror=()=>{o(new Error("Network error occurred during the request."))},i.send(JSON.stringify(r))})}function xT(){zr.set("Content-Type","application/json; charset=utf-8"),zr.set("cooee-sdk",Gs),zr.set("cooee-sdk-code",Sm.toString()),zr.set("cooee-sdk-version",qs),zr.set("cooee-shop-name",ic()??""),yr.debug&&zr.set("cooee-sdk-debug",String(1))}var $l=class{modifications=[];constructor(){}execute(e){for(let r of e){if(!r.experimentConfig)continue;this.executeExperiment(r)&&this.trackExperimentRan(r)}if(document.querySelector("#lc-hide-body")?.remove(),!document.body){Sa("No body element found","error");return}this.setupMutationObserver()}executeExperiment(e){let r=e.experimentConfig?.modifications;if(!r?.length)return w.log("Nothing to experiment",e.toString()),!0;let n=!1;for(let o of r){if(!o.cssSelector){w.verbose("No CSS Selector available",e?.toString());continue}this.modifications.push(o);let i=Array.from(document.querySelectorAll(o.cssSelector));i?.length&&(this.executeSingleModification(o,i),n=!0)}return n}executeSingleModification(e,r){if(r?.length)for(let n of r)Object.assign(n.style,e.style),e.type==="TEXT"&&e.text?n.innerHTML=e.text:e.type==="IMAGE"&&this.updateImage(e,n),e.moveTo?.selector&&this.changePlacement(e,n).catch(console.error)}async changePlacement(e,r){let n=await xn(e.moveTo.selector);if(n)switch(e.moveTo.position){case Ot.BEFORE1:{r.nextElementSibling!==n&&n.parentElement?.insertBefore(r,n);break}case Ot.INSIDE_FIRST1:{n.firstChild!==r&&n.insertBefore(r,n.firstChild);break}case Ot.INSIDE_LAST1:{n.lastChild!==r&&n.appendChild(r);break}case Ot.AFTER1:default:r.previousElementSibling!==n&&n.parentElement?.insertBefore(r,n.nextSibling)}}trackExperimentRan(e){if(e.id==="preview"){w.warn("Skipping experiment attribution as its preview",e.toString());return}Av({name:"CE Experiment Start",experiment:new Pn(e)}).catch(r=>{w.error("Fail to track experiment",r)})}setupMutationObserver(){new MutationObserver(r=>{r.forEach(n=>{n.addedNodes.forEach(o=>{o instanceof HTMLElement&&this.modifications.forEach(i=>{o.matches&&o.matches(i.cssSelector)?(w.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,[o])):o.querySelectorAll&&(w.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,Array.from(o.querySelectorAll(i.cssSelector))))})})})}).observe(document.body,{childList:!0,subtree:!0})}updateImage(e,r){let n=e.image?.lg?.src,o=e.image?.sm?.src;!n&&!o||(r instanceof HTMLPictureElement?this.updatePictureElement({desktop:n,mobile:o},r):this.updateImageElement({desktop:n,mobile:o},r))}updateImageElement(e,r){jr()&&e.mobile?(r.setAttribute("src",e.mobile),r.removeAttribute("srcset")):e.desktop&&(r.setAttribute("src",e.desktop),r.removeAttribute("srcset"))}updatePictureElement(e,r){if(r.innerHTML="",e.mobile){let o=document.createElement("source");o.srcset=e.mobile,o.media="(max-width: 767px)",r.append(o)}if(e.desktop){let o=document.createElement("source");o.srcset=e.desktop,o.media="(min-width: 768px)",r.append(o)}let n=document.createElement("img");n.src=e.desktop??e.mobile??"",r.append(n)}};async function Av(t){let e=await mn(),r=E(E({},t),e);await Jt("/v1/event/experiment",r)}function Vl(){CT().catch(t=>ae(t,"fetch-experiments"))}async function CT(){if(!fe().activeExperiments)return;await qr.getInstance().isAuthenticated()?await Dv():(await xr(mr),await Dv())}async function Dv(){w.info("Fetch experiments after \u23F0",Io()+" of SDK load");let t=await mn(),e=E({},t);Jt("/v1/engagement/experiments",e).then(async r=>{w.info(`Experiments fetched in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.experiments.map(o=>new Tt(o));new $l().execute(n)}).catch(r=>{w.error("Error sending experiment getter",r)})}var Wl=class{runtimeData=fe();meddle(){let e=Ce.globalRef;e.account=e.account??[],e.profile=e.profile??[],e.events=e.events??[],e.page=e.page??[],this.meddlePage(),this.meddleAccount(),this.meddleEvents(),this.meddleProfile(),this.exposeMethods()}exposeMethods(){let e=Ce.globalRef;e.loadWidgets=e.loadCartWidgets=e.loadPageWidgets=()=>{Ii()},e.loadExperiments=()=>{Vl()},e.testCartUpdate=this.testCartUpdate.bind(this),e.previewWidget=Ce.previewWidget.bind(Ce),e.previewPopup=Ce.previewPopup.bind(Ce),e.executeCTA=(r,n)=>{new dn(r).execute(n)},e.sendEvent=r=>{xt(r)}}overwritePush(e,r){Lr(e,"push",r)}meddleAccount(){this.overwritePush(Ce.globalRef.account,(...e)=>{this.processAccount(e[0])}),Ce.globalRef.account.forEach(this.processAccount.bind(this))}meddleEvents(){this.overwritePush(Ce.globalRef.events,(...e)=>{this.processEvent(e[0])}),Ce.globalRef.events.forEach(this.processEvent.bind(this))}meddleProfile(){this.overwritePush(Ce.globalRef.profile,(...e)=>{this.processProfile(e[0])}),Ce.globalRef.profile.forEach(this.processProfile.bind(this))}processAccount(e){e&&(e.appID&&Ce.authenticate(e),e.flags&&(this.runtimeData.flags=e.flags))}processEvent(e){e&&(xm.includes(e[0])?Ce.sendEvent(e[0],e[1],E({occurred:this.runtimeData.jsLoadTime},e[2])):Ce.sendEvent(e[0],e[1],e[2]))}processProfile(e){e&&Ce.updateProfile(e)}processPageName(e){e&&Ce.setPageName(e)}meddlePage(){this.overwritePush(Ce.globalRef.page,(...e)=>{this.processPage(e[0])}),Ce.globalRef.page.forEach(this.processPage.bind(this))}processPage(e){e.currentItem&&RT(e.currentItem),e.currency&&(fe().currencyCode=e.currency),e.shopCurrency&&(this.runtimeData.shopCurrencyCode=e.shopCurrency),e.moneyFormat&&(this.runtimeData.moneyFormat=e.moneyFormat),e.jsLoad&&(this.runtimeData.jsLoadTime=e.jsLoad),e.locale&&(this.runtimeData.locale=e.locale),e.pageName&&Ce.setPageName(e.pageName),e.activeExperiment&&(this.runtimeData.activeExperiments=e.activeExperiment),e.cart&&me.getCurrent().update(e.cart),e.customContext&&(this.runtimeData.customContext=E(E({},this.runtimeData.customContext),e.customContext))}async testCartUpdate(){if(fe().pageName!=="product"){window.alert("This feature is only available on a product page");return}let e=mv();if(e||(e=fe().currentItem?.vID),!e){window.alert("Could not find a variant to test. Please try a different product page");return}let r=new Tt({id:"preview",shortID:"1",redirectBehaviour:tr.CART_DRAWER});await new dn(new Cr(new Date,r)).execute({clickAction:{at:we.ADD_TO_CART},embeddedItem:new Nt({vID:e})})}};function RT(t){let e=fe();if(e.currentItem&&e.currentItem.vID!==t.vID){let r=new CustomEvent("letscooee:variant-change",{detail:{variantID:t.vID}});document.dispatchEvent(r)}e.currentItem=new Nt(t)}var xi=class{static SESSION_STORAGE=window.sessionStorage;static SESSION_STORAGE_KEY_PREFIX="cooee".concat("-");static getString(e,r){return this.getItem(e)||r}static setString(e,r){this.setItem(e,r)}static remove(e){this.removeItem(e)}static getItem(e){return this.SESSION_STORAGE.getItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}static setItem(e,r){this.SESSION_STORAGE.setItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e),r)}static removeItem(e){this.SESSION_STORAGE.removeItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}};var AT=1e3,DT=10,fm=0,pm=new Date;function mm(t){xi.remove("sleid"),pm=t??new Date}function Ov(){if(window.scrollY){let t=Lv();Nv(t)&&Pv(t)}In(()=>{OT()})}function OT(){ho(window,"scroll").pipe(Xt(AT),pn(()=>{let t=Lv();if(t>100){w.warn("Received scroll percent is more than 100",t);return}if(Nv(t))return t})).subscribe(t=>{Pv(t)})}function Nv(t){return Math.abs(fm-t)>=DT||fm!==t&&t===100}function Pv(t){if(t==null)return;let e={percent:t,timeMS:new Date().getTime()-pm.getTime()};fm=t;let r=xi.getString("sleid",""),n=new xe("CE Scroll",e,null,r);xt(n),xi.setString("sleid",n.id.toHexString()),pm=new Date(n.occurred)}function Lv(){let t=window.document.body.scrollHeight,e=window.innerHeight;return Math.ceil((window.scrollY+e)/t*100)}function Mv(){NT()}function NT(){let t=window.fetch;window.fetch=async function(e,r){try{await PT(e,r)}catch(n){ae(n,"modify-graphql-request",{extra:{body:JSON.stringify(r?.body)}})}return t(e,r)},w.verbose("Securely overwritten window.fetch method for graphql query")}async function PT(t,e){let r=typeof t=="string"?t:t instanceof Request?t.url:"";if(!(r.includes("graphql.json")&&e?.method==="POST")||!e.body)return;let n;if(typeof e.body=="string")try{n=JSON.parse(e.body)}catch{return}else n=e.body;n?.variables?.input&&(w.verbose("Intercepted fetch request of:",r),n?.query.includes("cartCreate")&&(e.body=await LT(n),MT()))}async function LT(t){let e=t.variables.input.attributes??[],r=await Ga("Buy Now");return t.variables.input.attributes=[...e,...r],JSON.stringify(t)}function MT(){let t=fe().currentItem;if(!t)return;let e=new xe("Buy Now Clicked",{items:[t]});xt(e)}var Ci=class{constructor(e,r){this.selectors=e;this.eventName=r;this.selectorString=e.join(",")}static INSTANCE;elements;selectorString;clickListenerCallback=e=>{let r=e.currentTarget,n=new xe(this.eventName,{class:r.className||void 0,tagName:r.tagName||void 0,id:r.id||void 0});xt(n),this.removeClickListener(this.clickListenerCallback)};listenSilently(){this.listen().catch(e=>w.error(e))}async listen(){this.elements=await Af(this.selectorString),this.elements.forEach(e=>{e.addEventListener("click",this.clickListenerCallback)})}removeClickListener(e){this.elements?.forEach(r=>{r.removeEventListener("click",e)})}};var jl=class t extends Ci{static selectors=[".product__thumbnail-list-inner > button","product-gallery-navigation > button",".product-media--thumb-container",".product-images-inner > img",".m-product-media",".swiper-button-control",".media__thumb",".slick-arrow",".productView-img-container.product-single__media",".product-gallery__thumbnail_item_inner"];constructor(){super(t.selectors,"Item Thumbnail Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var Gl=class t extends Ci{static selectors=[".jdgm-widget.jdgm-preview-badge.jdgm-preview-badge--with-link.jdgm--done-setup","reviewsio-product-ratings",".ruk_rating_snippet.tracked:not(.hidden)","a > .loox-rating",".yotpo-reviews-star-ratings-widget",".yotpo.lp-hero__reviews",".pr-rating > a",".rivyoReviewWidget"];constructor(){super(t.selectors,"Review Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var BT=[".gokwik-checkout button","button.cart__checkout-button","button.cart__checkout","button#checkout","button#checkout2",'button[id*="checkout" i]','button[name*="checkout" i]','button[class*="checkout" i]'].join(",");function Bv(){In(()=>{w.verbose("Execution order:","document ready"),UT()})}function UT(){let t=window.location.hash?.substring(1);if(t)if(t.includes("initiate-checkout")){document.dispatchEvent(new Event("letscooee:outbound:third-party-initiate-checkout"));let e=document.querySelector(BT);if(!e){w.verbose("No clickable cart checkout button found");return}w.verbose("Clickable cart checkout button found",e),e.click()}else t.includes("open-cart-drawer")&&et.get().open()}function kv(){window.addEventListener("kp-modal:opened",()=>{fe().isGoKwikPopupOpen=!0}),window.addEventListener("user-loggedin",t=>{let{token:e}=t.detail;e&&Si({goKwikToken:e})}),window.gokwikSdk?Uv():window.addEventListener("gokwikLoaded",Uv)}function Uv(){window.gokwikSdk&&window.gokwikSdk.on("checkout_initiated",async()=>{let t=await me.getCurrent().getNormalisedCart(),e={via:"GoKwik",items:t.items,cartToken:t.token,amount:{value:t.amount,currency:t.currency}},r=new xe("Checkout Started",e);xt(r)})}var ql=class{static watch(){let e=Dm();(e==="1"||e==="on")&&Fl({debugTill:this.getDebugMillis()}),e==="on"?sessionStorage.cooeeDebug="1":e==="off"&&sessionStorage.removeItem("cooeeDebug"),sessionStorage.cooeeDebug&&this.renderDebugBar()}static renderDebugBar(){let e=document.createElement("cooee-debugger");e.logs=this.logs,In(()=>{document.body.appendChild(e)})}static getDebugMillis(){return new Date().getTime()+360*60*1e3}};var Ce=class{static globalRef;static authenticated;static async initForMerchantWebsiteOnly(e){window.cooeeSDKPreview||(this.initGlobalReference(e),await qr.getInstance().populateAuthDataFromStorage(),this.autoAuthenticate(),new Wl().meddle(),Bm(),Ii(!0),Vl(),Xy(),nv(),Mv(),Bv(),Ov(),Gl.getInstance().listenSilently(),jl.getInstance().listenSilently(),kv(),kT(),ql.watch())}static async initForAll(){this.injectWidgetAssets()}static initGlobalReference(e){window.CooeeSDK||Lr(window,"CooeeSDK",{}),this.globalRef=window.CooeeSDK,Lr(this.globalRef,"config",new Ye),Lr(this.globalRef,"runtimeData",{sdkLoadTime:e,jsLoadTime:new Date,lastEnterActive:new Date}),Lr(this.globalRef,"uaParser",new Tr,!0),Lr(this.globalRef,"cart",me.getCurrent()),Lr(this.globalRef,"cartChange$",rv()),Lr(this.globalRef,"cartDrawerToggle$",et.cartDrawerToggle$.asObservable()),w.verbose("Global reference initialised"),new Pc(()=>{this.globalRef.uaParser=new Tr})}static injectWidgetAssets(){Yg(yr.widgetURL,"cooee-widget-sdk"),vp()}static autoAuthenticate(){let e=ic();e&&this.authenticate({shopifyShop:e})}static authenticate(e){if(this.authenticated)return;w.info("Begin auth after \u23F0",Io(),"of SDK load");let r=e.appID?.trim(),n=e.shopifyShop;if((Cf(r)||r.length!==24)&&Cf(n)){w.warn("Cooee App ID or Shop name is not configured");return}this.authenticated=!0,qr.getInstance().authenticate(e)}static sendEvent(e,r,n){let o=new xe(e,r,n?.triggerData);n?.occurred&&(o.occurred=n.occurred),xt(o)}static updateProfile(e){for(let r in e)if(r.toLowerCase().startsWith("ce "))throw new Error("User property name cannot start with 'CE '");Si(e)}static setPageName(e){if(!e)return;let r=fe(),n=r.pageName;if(e===n)return;if(r.pageName=e,Tm.some(s=>e.includes(s))){mm();return}let o={};n&&(o.ps=n);let i=new xe("CE Screen View",o);i.occurred=r.jsLoadTime,xt(i),mm(i.occurred)}static previewPopup(e,r){new Hn(r).render(e)}static previewWidget(e){new vt(new Tt(e)).renderSilently()}};function kT(){if(window.opener){try{window.opener.postMessage({action:"COOEE_READY_FOR_PREVIEW"},"*")}catch(t){w.error(t)}window.addEventListener("message",t=>{if(w.verbose("Received event",t),!t.origin.includes("letscooee.com")&&!t.origin.includes("localhost"))return;let e=t.data;typeof e=="object"&&(e.action==="POPUP_PREVIEW"?(Ce.previewPopup(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)):e.action==="WIDGET_PREVIEW"&&(Ce.previewWidget(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)))})}}var Fv=new Date;Rm();Om();w.verbose("Execution order:","top");window.cooeeShopifyScriptLoaded||(window.cooeeShopifyScriptLoaded=!0,(async()=>(w.verbose("Execution order:","IIFE start"),await Ce.initForMerchantWebsiteOnly(Fv),await Ce.initForAll(),FT(),w.verbose("Execution order:","IIFE end")))());w.verbose("Execution order:","bottom");function FT(){Am()&&import("./debug-logs-HMY65ZL7.js").then(({printAllDebugLogs:t})=>t(Fv))}
@@ -1 +1 @@
1
- import{a as C,b}from"./chunk-K5LH5HY4.js";import{e as g,f as h,i as u,l as f}from"./chunk-FSCNYBTK.js";import{Aa as l,Pa as c,X as m,oa as n,pa as i,qa as r,v as s}from"./chunk-I4NX4HQ6.js";import"./chunk-V7UGKYBN.js";var _=class d{dialogRef=s(u);eventData=s(h);triggerData=s(g)().triggerData;onShareAndClose(p,o){p.stopPropagation();let{url:t,text:a}=b(this.triggerData,this.eventData.video,o!=="Clipboard");switch(o){case"Whatsapp":window.open(`https://wa.me/?text=${a}%20${t}`,"_blank","noopener,noreferrer");break;case"X(Twitter)":window.open(`https://x.com/intent/post?text=${a}&url=${t}`,"_blank","noopener,noreferrer");break;case"Clipboard":navigator.clipboard.writeText(t).catch(()=>{let e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)});break;default:}o&&C(this.triggerData,this.eventData.video,this.eventData.index,o),this.dialogRef.close()}static \u0275fac=function(o){return new(o||d)};static \u0275cmp=m({type:d,selectors:[["cooee-share-dialog"]],decls:19,vars:0,consts:[[1,"share-dialog"],[1,"share-dialog-header"],["type","button","aria-label","Close",1,"close-button",3,"click"],["name","close","aria-hidden","true"],[1,"share-options"],["type","button","aria-label","Share on WhatsApp",1,"share-option",3,"click"],["name","whatsapp","aria-hidden","true"],["type","button","aria-label","Share on X",1,"share-option",3,"click"],["name","x-twitter","aria-hidden","true"],["type","button","aria-label","Copy link",1,"share-option",3,"click"],["name","copy","aria-hidden","true"]],template:function(o,t){o&1&&(n(0,"div",0)(1,"div",1)(2,"h3"),c(3,"Share"),i(),n(4,"button",2),l("click",function(e){return t.onShareAndClose(e)}),r(5,"cooee-icon",3),i()(),n(6,"div",4)(7,"button",5),l("click",function(e){return t.onShareAndClose(e,"Whatsapp")}),r(8,"cooee-icon",6),n(9,"span"),c(10,"Whatsapp"),i()(),n(11,"button",7),l("click",function(e){return t.onShareAndClose(e,"X(Twitter)")}),r(12,"cooee-icon",8),n(13,"span"),c(14,"X"),i()(),n(15,"button",9),l("click",function(e){return t.onShareAndClose(e,"Clipboard")}),r(16,"cooee-icon",10),n(17,"span"),c(18,"Copy link"),i()()()())},dependencies:[f],styles:["@keyframes _ngcontent-%COMP%_slideInScale{0%{opacity:0;transform:scale(.9) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.share-dialog[_ngcontent-%COMP%]{background:#fff;border-radius:12px;padding:20px;min-width:280px;box-shadow:0 8px 32px #00000026;color:#333;animation:_ngcontent-%COMP%_slideInScale .25s ease-out}.share-dialog-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.share-dialog-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-family:var(--lc-heading-family),serif;margin:0;font-size:18px;font-weight:600}.share-options[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;font-family:var(--lc-text-family),serif}.share-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#0002;border:1px solid #e9ecef;border-radius:8px;color:#333;font-size:16px;font-weight:500;cursor:pointer;transition:all .2s ease}.share-option[_ngcontent-%COMP%]:hover{background:#0004;border-color:#dee2e6;transform:translateY(-1px)}.share-option[_ngcontent-%COMP%]:active{transform:translateY(0)}.share-option[_ngcontent-%COMP%] cooee-icon[_ngcontent-%COMP%]{width:24px;height:24px}.share-option[_ngcontent-%COMP%] cooee-icon[name=whatsapp][_ngcontent-%COMP%]{color:#25d366}.share-option[_ngcontent-%COMP%] cooee-icon[name=x-twitter][_ngcontent-%COMP%], .share-option[_ngcontent-%COMP%] cooee-icon[name=copy][_ngcontent-%COMP%]{color:#000}.share-option[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1;text-align:left}button.close-button[_ngcontent-%COMP%]{background-color:transparent;border:none}button.close-button[_ngcontent-%COMP%] cooee-icon[name=close][_ngcontent-%COMP%]{border-radius:100%;color:#000}"]})};export{_ as ShareDialogComponent};
1
+ import{a as C,b}from"./chunk-B6ELTYSW.js";import{e as g,f as h,i as u,l as f}from"./chunk-FTB47KVW.js";import{Aa as l,Pa as c,X as m,oa as n,pa as i,qa as r,v as s}from"./chunk-I4NX4HQ6.js";import"./chunk-V7UGKYBN.js";var _=class d{dialogRef=s(u);eventData=s(h);triggerData=s(g)().triggerData;onShareAndClose(p,o){p.stopPropagation();let{url:t,text:a}=b(this.triggerData,this.eventData.video,o!=="Clipboard");switch(o){case"Whatsapp":window.open(`https://wa.me/?text=${a}%20${t}`,"_blank","noopener,noreferrer");break;case"X(Twitter)":window.open(`https://x.com/intent/post?text=${a}&url=${t}`,"_blank","noopener,noreferrer");break;case"Clipboard":navigator.clipboard.writeText(t).catch(()=>{let e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)});break;default:}o&&C(this.triggerData,this.eventData.video,this.eventData.index,o),this.dialogRef.close()}static \u0275fac=function(o){return new(o||d)};static \u0275cmp=m({type:d,selectors:[["cooee-share-dialog"]],decls:19,vars:0,consts:[[1,"share-dialog"],[1,"share-dialog-header"],["type","button","aria-label","Close",1,"close-button",3,"click"],["name","close","aria-hidden","true"],[1,"share-options"],["type","button","aria-label","Share on WhatsApp",1,"share-option",3,"click"],["name","whatsapp","aria-hidden","true"],["type","button","aria-label","Share on X",1,"share-option",3,"click"],["name","x-twitter","aria-hidden","true"],["type","button","aria-label","Copy link",1,"share-option",3,"click"],["name","copy","aria-hidden","true"]],template:function(o,t){o&1&&(n(0,"div",0)(1,"div",1)(2,"h3"),c(3,"Share"),i(),n(4,"button",2),l("click",function(e){return t.onShareAndClose(e)}),r(5,"cooee-icon",3),i()(),n(6,"div",4)(7,"button",5),l("click",function(e){return t.onShareAndClose(e,"Whatsapp")}),r(8,"cooee-icon",6),n(9,"span"),c(10,"Whatsapp"),i()(),n(11,"button",7),l("click",function(e){return t.onShareAndClose(e,"X(Twitter)")}),r(12,"cooee-icon",8),n(13,"span"),c(14,"X"),i()(),n(15,"button",9),l("click",function(e){return t.onShareAndClose(e,"Clipboard")}),r(16,"cooee-icon",10),n(17,"span"),c(18,"Copy link"),i()()()())},dependencies:[f],styles:["@keyframes _ngcontent-%COMP%_slideInScale{0%{opacity:0;transform:scale(.9) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.share-dialog[_ngcontent-%COMP%]{background:#fff;border-radius:12px;padding:20px;min-width:280px;box-shadow:0 8px 32px #00000026;color:#333;animation:_ngcontent-%COMP%_slideInScale .25s ease-out}.share-dialog-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.share-dialog-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-family:var(--lc-heading-family),serif;margin:0;font-size:18px;font-weight:600}.share-options[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;font-family:var(--lc-text-family),serif}.share-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#0002;border:1px solid #e9ecef;border-radius:8px;color:#333;font-size:16px;font-weight:500;cursor:pointer;transition:all .2s ease}.share-option[_ngcontent-%COMP%]:hover{background:#0004;border-color:#dee2e6;transform:translateY(-1px)}.share-option[_ngcontent-%COMP%]:active{transform:translateY(0)}.share-option[_ngcontent-%COMP%] cooee-icon[_ngcontent-%COMP%]{width:24px;height:24px}.share-option[_ngcontent-%COMP%] cooee-icon[name=whatsapp][_ngcontent-%COMP%]{color:#25d366}.share-option[_ngcontent-%COMP%] cooee-icon[name=x-twitter][_ngcontent-%COMP%], .share-option[_ngcontent-%COMP%] cooee-icon[name=copy][_ngcontent-%COMP%]{color:#000}.share-option[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1;text-align:left}button.close-button[_ngcontent-%COMP%]{background-color:transparent;border:none}button.close-button[_ngcontent-%COMP%] cooee-icon[name=close][_ngcontent-%COMP%]{border-radius:100%;color:#000}"]})};export{_ as ShareDialogComponent};
@@ -1,3 +1,3 @@
1
- import{A as Pe,B as Me,C as Re,a as _e,c as O,d as Ce,f as U,k as Q,r as R,s as De,t as be,u as Te,v as Ie,w as Ee,y as Se,z as ke}from"./chunk-A2HFXM7A.js";import{a as Oe,b as Ne}from"./chunk-K5LH5HY4.js";import{c as we,e as fe,f as N,g as H,i as xe,j as Ve,k as ye,l as F}from"./chunk-FSCNYBTK.js";import"./chunk-OG6WZFOM.js";import{Aa as g,Ca as a,D as Y,E as f,Fa as $,Ga as j,Ha as W,I as T,Ia as ae,Ja as de,Ka as b,L as J,La as S,M as X,O as s,Sa as se,Ta as le,Ua as ce,V as Z,X as w,Ya as pe,_a as me,ba as I,eb as ue,ha as E,hb as k,ia as x,ib as P,ja as V,jb as M,ka as ee,kb as ge,la as y,ma as D,na as u,oa as l,pa as d,qa as _,ra as te,rb as he,sa as ie,ta as oe,tb as ve,ua as ne,v as m,va as re,wa as B,x as c,y as p,ya as v}from"./chunk-I4NX4HQ6.js";import"./chunk-V7UGKYBN.js";var A=class n{dialogState=P();dialog=m(ye);triggerData=m(fe)().triggerData;eventData=m(N);containerRef=m(Z);async share(t){t.stopPropagation(),t.preventDefault(),R()&&De()?await this.shareNative():await this.shareWithDialog()}async shareNative(){let t=Ne(this.triggerData,this.eventData.video,!1);await navigator.share(t),Oe(this.triggerData,this.eventData.video,this.eventData.index,"Native")}async shareWithDialog(){let t=await import("./share-dialog.component-B5JSWWM2.js");this.dialogState.emit(!0),this.dialog.open(t.ShareDialogComponent,{viewContainerRef:this.containerRef}).closed.subscribe(()=>this.dialogState.emit(!1))}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-share-button"]],outputs:{dialogState:"dialogState"},decls:2,vars:0,consts:[["type","button","aria-label","Share video",3,"click"],["name","share"]],template:function(e,i){e&1&&(l(0,"button",0),g("click",function(r){return i.share(r)}),_(1,"cooee-icon",1),d())},dependencies:[F],styles:["button[_ngcontent-%COMP%]{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}button[_ngcontent-%COMP%] cooee-icon[name=share][_ngcontent-%COMP%]{color:#fff}"]})};var z=class n{video=M.required();progress=f(0);constructor(){k(t=>{let e=this.video(),i=()=>{this.progress.set(e.currentTime/e.duration*100)};e.addEventListener("timeupdate",i),t(()=>{e.removeEventListener("timeupdate",i)})})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-progress-bar"]],inputs:{video:[1,"video"]},decls:3,vars:3,consts:[[1,"video-untracked-path"],["role","progressbar",1,"video-tracked-path"]],template:function(e,i){e&1&&(te(0,"div",0)(1,"div",1),oe(2,"div"),ie()()),e&2&&(s(),S("width",i.progress(),"%"),E("aria-valuenow",i.progress()))},styles:["[_nghost-%COMP%]{display:block;width:100%;position:absolute;z-index:10;top:4px;padding-inline:8px;box-sizing:border-box}.video-untracked-path[_ngcontent-%COMP%], .video-tracked-path[_ngcontent-%COMP%]{height:4px;border-radius:var(--lc-video-progress-bar-radius)}.video-untracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-bg-color));width:100%;margin-bottom:2px}.video-tracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-color));transition:width .5s ease-in-out}@media (prefers-reduced-motion: reduce){.video-tracked-path[_ngcontent-%COMP%]{transition:none}}"]})};var Ae=["swiperContainer"],ze=(n,t)=>t.id;function Le(n,t){if(n&1){let e=v();l(0,"div",3)(1,"cooee-item-card",4),g("buttonClick",function(o){c(e);let r=a();return p(r.onButtonClick(o))})("click",function(){let o=c(e).$implicit,r=a();return p(r.cardClick.emit(o))}),d()()}if(n&2){let e=t.$implicit;s(),u("item",e)}}var L=class n{items=M.required();cardClick=P();destroyRef=m(Y);elementRef=m(T);engagementService=m(U);swiperContainerRef=ge.required("swiperContainer");swiperInstance;constructor(){k(()=>{this.initSwiper()}),this.destroyRef.onDestroy(()=>{this.swiperInstance?.destroy()})}ngOnInit(){O(this.elementRef.nativeElement.shadowRoot)}onButtonClick(t){let e=_e.get().website?.canChangeVariantInCart;if(this.items()?.length>1||t.hasVariants()&&!e){this.cardClick.emit(t);return}this.engagementService.executeCTA(Ce.ADD_TO_CART,{item:t})}initSwiper(){this.swiperInstance=new window.CooeeSDK.Swiper(this.swiperContainerRef().nativeElement,{direction:"horizontal",effect:"slide",slidesPerView:1.2,nested:!0,centeredSlides:!0,spaceBetween:12,mousewheel:{enabled:!0,thresholdDelta:10,thresholdTime:200}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-promoted-items"]],viewQuery:function(e,i){e&1&&ae(i.swiperContainerRef,Ae,5),e&2&&de()},hostAttrs:[1,"letscooee-widget"],inputs:{items:[1,"items"]},outputs:{cardClick:"cardClick"},features:[me([U])],decls:5,vars:0,consts:[["swiperContainer",""],[1,"swiper-container"],[1,"swiper-wrapper"],[1,"swiper-slide"],["tabindex","0",3,"buttonClick","click","item"]],template:function(e,i){e&1&&(l(0,"div",1,0)(2,"div",2),y(3,Le,2,1,"div",3,ze),d()()),e&2&&(s(3),D(i.items()))},dependencies:[Re],styles:[`:host{display:block;width:100%}cooee-item-card{-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);background-color:rgba(var(--lc-card-bg-color));cursor:pointer;border-radius:var(--lc-card-radius)}
1
+ import{A as Pe,B as Me,C as Re,a as _e,c as O,d as Ce,f as U,k as Q,r as R,s as De,t as be,u as Te,v as Ie,w as Ee,y as Se,z as ke}from"./chunk-KV43FZHN.js";import{a as Oe,b as Ne}from"./chunk-B6ELTYSW.js";import{c as we,e as fe,f as N,g as H,i as xe,j as Ve,k as ye,l as F}from"./chunk-FTB47KVW.js";import"./chunk-OG6WZFOM.js";import{Aa as g,Ca as a,D as Y,E as f,Fa as $,Ga as j,Ha as W,I as T,Ia as ae,Ja as de,Ka as b,L as J,La as S,M as X,O as s,Sa as se,Ta as le,Ua as ce,V as Z,X as w,Ya as pe,_a as me,ba as I,eb as ue,ha as E,hb as k,ia as x,ib as P,ja as V,jb as M,ka as ee,kb as ge,la as y,ma as D,na as u,oa as l,pa as d,qa as _,ra as te,rb as he,sa as ie,ta as oe,tb as ve,ua as ne,v as m,va as re,wa as B,x as c,y as p,ya as v}from"./chunk-I4NX4HQ6.js";import"./chunk-V7UGKYBN.js";var A=class n{dialogState=P();dialog=m(ye);triggerData=m(fe)().triggerData;eventData=m(N);containerRef=m(Z);async share(t){t.stopPropagation(),t.preventDefault(),R()&&De()?await this.shareNative():await this.shareWithDialog()}async shareNative(){let t=Ne(this.triggerData,this.eventData.video,!1);await navigator.share(t),Oe(this.triggerData,this.eventData.video,this.eventData.index,"Native")}async shareWithDialog(){let t=await import("./share-dialog.component-2JRPBKO3.js");this.dialogState.emit(!0),this.dialog.open(t.ShareDialogComponent,{viewContainerRef:this.containerRef}).closed.subscribe(()=>this.dialogState.emit(!1))}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-share-button"]],outputs:{dialogState:"dialogState"},decls:2,vars:0,consts:[["type","button","aria-label","Share video",3,"click"],["name","share"]],template:function(e,i){e&1&&(l(0,"button",0),g("click",function(r){return i.share(r)}),_(1,"cooee-icon",1),d())},dependencies:[F],styles:["button[_ngcontent-%COMP%]{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}button[_ngcontent-%COMP%] cooee-icon[name=share][_ngcontent-%COMP%]{color:#fff}"]})};var z=class n{video=M.required();progress=f(0);constructor(){k(t=>{let e=this.video(),i=()=>{this.progress.set(e.currentTime/e.duration*100)};e.addEventListener("timeupdate",i),t(()=>{e.removeEventListener("timeupdate",i)})})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-progress-bar"]],inputs:{video:[1,"video"]},decls:3,vars:3,consts:[[1,"video-untracked-path"],["role","progressbar",1,"video-tracked-path"]],template:function(e,i){e&1&&(te(0,"div",0)(1,"div",1),oe(2,"div"),ie()()),e&2&&(s(),S("width",i.progress(),"%"),E("aria-valuenow",i.progress()))},styles:["[_nghost-%COMP%]{display:block;width:100%;position:absolute;z-index:10;top:4px;padding-inline:8px;box-sizing:border-box}.video-untracked-path[_ngcontent-%COMP%], .video-tracked-path[_ngcontent-%COMP%]{height:4px;border-radius:var(--lc-video-progress-bar-radius)}.video-untracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-bg-color));width:100%;margin-bottom:2px}.video-tracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-color));transition:width .5s ease-in-out}@media (prefers-reduced-motion: reduce){.video-tracked-path[_ngcontent-%COMP%]{transition:none}}"]})};var Ae=["swiperContainer"],ze=(n,t)=>t.id;function Le(n,t){if(n&1){let e=v();l(0,"div",3)(1,"cooee-item-card",4),g("buttonClick",function(o){c(e);let r=a();return p(r.onButtonClick(o))})("click",function(){let o=c(e).$implicit,r=a();return p(r.cardClick.emit(o))}),d()()}if(n&2){let e=t.$implicit;s(),u("item",e)}}var L=class n{items=M.required();cardClick=P();destroyRef=m(Y);elementRef=m(T);engagementService=m(U);swiperContainerRef=ge.required("swiperContainer");swiperInstance;constructor(){k(()=>{this.initSwiper()}),this.destroyRef.onDestroy(()=>{this.swiperInstance?.destroy()})}ngOnInit(){O(this.elementRef.nativeElement.shadowRoot)}onButtonClick(t){let e=_e.get().website?.canChangeVariantInCart;if(this.items()?.length>1||t.hasVariants()&&!e){this.cardClick.emit(t);return}this.engagementService.executeCTA(Ce.ADD_TO_CART,{item:t})}initSwiper(){this.swiperInstance=new window.CooeeSDK.Swiper(this.swiperContainerRef().nativeElement,{direction:"horizontal",effect:"slide",slidesPerView:1.2,nested:!0,centeredSlides:!0,spaceBetween:12,mousewheel:{enabled:!0,thresholdDelta:10,thresholdTime:200}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-promoted-items"]],viewQuery:function(e,i){e&1&&ae(i.swiperContainerRef,Ae,5),e&2&&de()},hostAttrs:[1,"letscooee-widget"],inputs:{items:[1,"items"]},outputs:{cardClick:"cardClick"},features:[me([U])],decls:5,vars:0,consts:[["swiperContainer",""],[1,"swiper-container"],[1,"swiper-wrapper"],[1,"swiper-slide"],["tabindex","0",3,"buttonClick","click","item"]],template:function(e,i){e&1&&(l(0,"div",1,0)(2,"div",2),y(3,Le,2,1,"div",3,ze),d()()),e&2&&(s(3),D(i.items()))},dependencies:[Re],styles:[`:host{display:block;width:100%}cooee-item-card{-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);background-color:rgba(var(--lc-card-bg-color));cursor:pointer;border-radius:var(--lc-card-radius)}
2
2
  `],encapsulation:3})};var Be=["swiperComp"],$e=["videoEl"],je=(n,t)=>t.url;function We(n,t){n&1&&(l(0,"div",11),_(1,"div",15),d())}function He(n,t){if(n&1&&_(0,"source",13),n&2){let e=t.$implicit;u("type",pe(e.mimeType))("src",e.url,J)}}function Ue(n,t){n&1&&B(0)}function Qe(n,t){if(n&1){let e=v();l(0,"cooee-video-promoted-items",24),g("cardClick",function(o){c(e);let r=a(2).$implicit,C=a();return p(C.productCardClicked(o,r))}),d()}if(n&2){let e=a(2).$implicit;u("items",e.items)}}function Ke(n,t){if(n&1&&_(0,"cooee-video-card",23),n&2){let e=a(2).$implicit;u("card",e.card)}}function qe(n,t){if(n&1){let e=v();_(0,"cooee-video-progress-bar",16),l(1,"div",17)(2,"cooee-mute-toggle",18),ce("mutedChange",function(o){c(e);let r=a(2);return le(r.muted,o)||(r.muted=o),p(o)}),g("toggled",function(){c(e);let o=a(2);return p(o.muteToggled())}),d(),I(3,Ue,1,0,"ng-container",8),d(),l(4,"div",19)(5,"cooee-share-button",20),g("dialogState",function(o){c(e);let r=a(2);return p(r.shareDialogOpen.set(o))}),d()(),l(6,"div",21),x(7,Qe,1,1,"cooee-video-promoted-items",22)(8,Ke,1,1,"cooee-video-card",23),d()}if(n&2){let e=a().$implicit,i=b(5),o=a(),r=b(9);u("video",i),s(2),se("muted",o.muted),u("videoEl",i),s(),u("ngTemplateOutlet",r),s(4),V(e.items.length&&o.footerContent===o.VideoConfigFooterContent.FIRST_ITEM?7:e.card&&o.footerContent===o.VideoConfigFooterContent.CARD?8:-1)}}function Ge(n,t){if(n&1){let e=v();l(0,"cooee-item-detail",25),g("closeClick",function(){c(e);let o=a(2);return p(o.productModalClosed())}),d()}if(n&2){let e=a(2);u("item",e.selectedItem)("similarItems",e.selectedVideo.items)}}function Ye(n,t){if(n&1){let e=v();l(0,"div",6)(1,"div",9)(2,"div",10),x(3,We,2,0,"div",11),l(4,"video",12,2),g("click",function(){let o=c(e).$index,r=a();return p(r.currentIndex===o&&r.toggleMute())})("ended",function(){c(e);let o=b(5),r=a();return p(r.onVideoEnded(o))})("loadstart",function(){let o=c(e).$index,r=a();return p(r.onVideoLoadStart(o))})("canplay",function(){let o=c(e).$index,r=a();return p(r.onVideoCanPlay(o))}),y(6,He,1,3,"source",13,je),d(),x(8,qe,9,5),d(),x(9,Ge,1,2,"cooee-item-detail",14),d()()}if(n&2){let e=t.$implicit,i=t.$index,o=a();s(2),S("background-image",e.thumbnail?"url("+e.thumbnail+")":null),s(),V(o.shouldShowVideoSpinner(i)?3:-1),s(),u("ngClass",o.viewTemplateClassName)("muted",!0),E("preload",o.isVideoVisible(i)?"metadata":"none")("data-video-id",e.id)("autoplay",null),s(2),D(e.sources),s(2),V(o.currentIndex===i?8:-1),s(),V(o.selectedItem&&o.currentIndex===i?9:-1)}}function Je(n,t){n&1&&B(0)}function Xe(n,t){if(n&1){let e=v();l(0,"button",26),g("click",function(){c(e);let o=a();return p(o.close())}),_(1,"cooee-icon",27),d()}}var Fe=class n{swiperComponent;videoElements;VideoConfigFooterContent=Se;currentIndex=0;muted=f(!1);selectedItem=null;selectedVideo;detailPopupTemplate;footerContent;viewTemplateClassName="lc-video-only-view";shareDialogOpen=f(!1);data=m(Ve);elementRef=m(T);eventData=m(N);dialogRef=m(xe);swiperInitialized=f(!1);swiperOptions=f(null);videos=[];triggerContext;engagementTrigger;isMobile=R();navigationConfig;cssLoadedPromise;resizeDebouncer=new be(this.onResize.bind(this));videoLoadingStates=new Map;constructor(){this.videos=this.data.videos,this.currentIndex=this.data.currentIndex,this.selectedVideo=this.videos[this.currentIndex],this.triggerContext=this.data.triggerContext,this.engagementTrigger=this.triggerContext.triggerData,this.navigationConfig=new Ee({enabled:!0,size:50,color:new Ie({h:"#000000"})}),this.cssLoadedPromise=O(this.elementRef.nativeElement.shadowRoot)}onKeyDown(t){t.preventDefault(),t.stopPropagation(),this.close()}async ngOnInit(){this.muted.set(await Q.get("muted",!1));let t=this.engagementTrigger?.content?.videoConfig;switch(this.detailPopupTemplate=t?.detailPopup.template??"VIDEO_ONLY_VIEW",this.footerContent=t?.footerContent??"FIRST_ITEM",this.detailPopupTemplate){case"PRODUCT_DETAIL_VIEW":this.selectItemForDetailView(),this.viewTemplateClassName="lc-product-detail-view";break;case"VIDEO_ONLY_VIEW":this.viewTemplateClassName="lc-video-only-view";break}}ngAfterViewInit(){this.initializeSwiperWithVideoDimensions()}ngOnDestroy(){this.resizeDebouncer?.destroy()}initializeSwiperWithVideoDimensions(){this.applyOptimalVideoDimensions(),this.initSwiperOptions(),this.playActiveVideo(!1)}close(){let t=this.getCurrentVideoElement();this.dialogRef.close({lastVideo:this.videos[this.currentIndex],lastVideoIndex:this.currentIndex,lastVideoDuration:t?.currentTime})}getCurrentVideoElement(){return this.videoElements.get(this.currentIndex)?.nativeElement}moveToNextVideo(){this.swiperComponent.swiper.slideTo(this.currentIndex+1)}productModalClosed(){this.selectedItem=null}pauseAll(){this.videoElements.forEach(t=>t.nativeElement.pause())}toggleMute(){this.muted.update(t=>!t)}async muteToggled(){await Q.set("muted",this.muted());let e=[this.muted()?"CE Video Muted":"CE Video Unmuted",{current:this.currentVideoProps()},{triggerData:this.engagementTrigger}];window.CooeeSDK.events.push(e)}playActiveVideo(t=!0){t&&this.pauseAll();let e=this.getCurrentVideoElement();e&&this.playVideo(e)}playVideo(t){t.currentTime=0,t.play().catch(e=>we.error(e))}onVideoEnded(t){if(this.currentIndex<this.videos.length-1)this.selectedItem||this.shareDialogOpen()?this.playVideo(t):this.moveToNextVideo();else{let e=this.getPreviousVideoDataForEvent(),i=["CE Last Video Ended",{previous:e},{triggerData:this.engagementTrigger}];window.CooeeSDK.events.push(i),this.playVideo(t)}}onSlideChange(t){let e=this.getPreviousVideoDataForEvent();this.currentIndex=t.realIndex,this.selectedVideo=this.videos[this.currentIndex],this.eventData.video=this.selectedVideo,this.eventData.index=this.currentIndex,this.playActiveVideo(),this.detailPopupTemplate==="PRODUCT_DETAIL_VIEW"?this.selectItemForDetailView():this.selectedItem=null;let i=this.currentVideoProps(),o={previous:e,current:i},r=new H("CE Video Changed",o,this.engagementTrigger);r.setVideos(this.videos[this.currentIndex]),window.CooeeSDK.sendEvent(r)}productCardClicked(t,e){let i={videoID:e.id,videoIndex:this.currentIndex},o=new H("CE More Item Info Clicked",{current:i},this.engagementTrigger);o.setVideos(e),window.CooeeSDK.sendEvent(o),this.selectedItem=t}onVideoLoadStart(t){this.videoLoadingStates.set(t,!0)}onVideoCanPlay(t){this.videoLoadingStates.set(t,!1)}shouldShowVideoSpinner(t){return this.swiperInitialized()?this.videoLoadingStates.get(t)===!0&&this.isVideoVisible(t):this.isVideoVisible(t)}isVideoVisible(t){let e=this.currentIndex-1,i=this.currentIndex+1;return t===this.currentIndex||t===e||t===i}async initSwiperOptions(){await this.cssLoadedPromise;let t=this.isMobile?1:"auto",e=0;this.isProductDetailView()&&(t="auto",e=10),this.swiperOptions.set({direction:this.isMobile?"vertical":"horizontal",effect:this.isMobile?"slide":"coverflow",slidesPerView:t,initialSlide:this.currentIndex,centeredSlides:!0,spaceBetween:e,coverflowEffect:{rotate:0,stretch:0,depth:400,modifier:1,slideShadows:!1},on:{init:i=>{this.swiperInitialized.set(!0),setTimeout(()=>{i.update()},100)}},mousewheel:{enabled:!this.isMobile,invert:!1,thresholdDelta:20}})}isProductDetailView(){return this.detailPopupTemplate==="PRODUCT_DETAIL_VIEW"}currentVideoProps(){return{videoID:this.videos[this.currentIndex].id,videoIndex:this.currentIndex}}getPreviousVideoDataForEvent(){let t=this.currentVideoProps(),e=this.videoElements.find(o=>o.nativeElement.dataset.videoId===this.videos[this.currentIndex].id)?.nativeElement;t.playedTillMS=Math.ceil(e?.currentTime*1e3);let i=e?.duration*1e3;return t.playedTillPercent=+(t.playedTillMS/i).toFixed(4),t}selectItemForDetailView(){this.selectedItem=this.isMobile?null:this.selectedVideo?.items?.[0]??null}applyOptimalVideoDimensions(){if(this.isMobile||this.isProductDetailView())return;let t=this.calculateOptimalVideoDimensions();t&&this.setVideoContainerDimensions(t.width,t.height)}calculateOptimalVideoDimensions(){let t=this.videos.map(h=>h.sources?.[0]).filter(h=>h?.width&&h?.height).map(h=>({width:h.width,height:h.height,aspectRatio:h.width/h.height}));if(t.length===0)return null;let e=t[0],i=window.innerWidth*.9,o=window.innerHeight*.9,r=i/e.width,C=o/e.height,G=Math.min(r,C);return{width:Math.floor(e.width*G),height:Math.floor(e.height*G)}}setVideoContainerDimensions(t,e){let i=this.elementRef.nativeElement;i.style.setProperty("--video-container-width",`${t}px`),i.style.setProperty("--video-container-height",`${e}px`)}onResize(){this.applyOptimalVideoDimensions()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-detail-dialog"]],viewQuery:function(e,i){if(e&1&&($(Be,7),$($e,5)),e&2){let o;j(o=W())&&(i.swiperComponent=o.first),j(o=W())&&(i.videoElements=o)}},hostAttrs:[1,"letscooee-widget"],hostBindings:function(e,i){e&1&&g("keydown.escape",function(r){return i.onKeyDown(r)},X)},decls:10,vars:4,consts:[["swiperComp",""],["closeButtonTemplate",""],["videoEl",""],[1,"lc-shadow-inner",3,"ngClass"],[1,"video-swiper",3,"slideChange","options","navigationConfig"],["ngProjectAs","swiper-slides",5,["swiper-slides"]],[1,"swiper-slide","video-slide"],[1,"lc-desktop-controls"],[4,"ngTemplateOutlet"],[1,"lc-video-modal-row"],[1,"lc-video-container"],[1,"video-loading-overlay"],["playsinline","",1,"lc-video-el",3,"click","ended","loadstart","canplay","ngClass","muted"],[3,"src","type"],[1,"swiper-no-swiping","swiper-no-mousewheel",3,"item","similarItems"],[1,"loading-spinner"],[3,"video"],[1,"lc-video-controls"],[3,"mutedChange","toggled","muted","videoEl"],[1,"share-controls"],[3,"dialogState"],[1,"lc-card-container"],[3,"items"],[3,"card"],[3,"cardClick","items"],[1,"swiper-no-swiping","swiper-no-mousewheel",3,"closeClick","item","similarItems"],["type","button","aria-label","Close",1,"lc-close-button",3,"click"],["name","close","aria-hidden","true"]],template:function(e,i){if(e&1){let o=v();l(0,"div",3)(1,"cooee-swiper",4,0),g("slideChange",function(C){return c(o),p(i.onSlideChange(C))}),ne(3,5),y(4,Ye,10,10,"div",6,ee),re(),d(),l(6,"div",7),I(7,Je,1,0,"ng-container",8),d()(),I(8,Xe,2,0,"ng-template",null,1,ue)}if(e&2){let o=b(9);u("ngClass",i.viewTemplateClassName),s(),u("options",i.swiperOptions())("navigationConfig",i.navigationConfig),s(3),D(i.videos),s(3),u("ngTemplateOutlet",o)}},dependencies:[L,Te,Me,A,z,ve,he,Pe,ke,F],styles:[`:host{display:flex}.lc-shadow-inner{position:relative;width:100vw;height:100vh;display:flex}@media (min-width: 768px){.lc-shadow-inner{background-color:color-mix(in oklab,#000 70%,transparent);justify-content:center;align-items:center}}.video-swiper{--swiper-navigation-size: 50px;--swiper-navigation-color: white;width:100dvw;height:100dvh}.lc-product-detail-view .video-swiper{align-items:center}@media (min-width: 768px){.video-swiper{width:100%;height:100%;max-width:90vw;max-height:90vh}}.video-swiper>.swiper-wrapper{max-height:100%}.lc-product-detail-view .video-swiper>.swiper-wrapper{align-items:center}@media (max-width: 768px){.video-swiper>.swiper-button-prev,.video-swiper>.swiper-button-next{display:none!important}}.video-slide{position:relative;display:flex;align-items:center;visibility:hidden}.lc-product-detail-view .video-slide{width:40vw!important;height:70vh!important}@media (min-width: 768px){.lc-product-detail-view .video-slide{min-width:650px!important}}@media (max-width: 768px){.lc-product-detail-view .video-slide{width:100%!important;height:100%!important}}@media (min-width: 768px){.lc-video-only-view .video-slide{width:fit-content!important}}@media (min-width: 768px){.video-slide{border-radius:var(--lc-media-radius);overflow:hidden}}.video-slide.swiper-slide-active,.video-slide.swiper-slide-prev,.video-slide.swiper-slide-next{visibility:visible}video{width:100%;height:100%;object-fit:cover;position:relative;z-index:3}.lc-desktop-controls{position:absolute;top:2rem;right:4rem;z-index:10;display:flex;gap:.5rem}@media (max-width: 768px){.lc-desktop-controls{display:none}}.lc-video-controls{position:absolute;top:1rem;z-index:10;right:.5rem;display:flex;gap:.25rem}@media (min-width: 768px){.lc-video-controls .lc-close-button{display:none}}.share-controls{position:absolute;bottom:30%;right:.5rem;z-index:10;display:flex;gap:.25rem;flex-direction:column;justify-content:center;align-items:center}.lc-close-button{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}.lc-video-container{position:relative;height:100%;width:100%;background:#000000b3 no-repeat center;background-size:cover}@media (min-width: 768px){.lc-product-detail-view .lc-video-container{width:50%}}@media (min-width: 768px){.lc-video-only-view .lc-video-container{width:var(--video-container-width, 100%);height:var(--video-container-height, 100%)}}.lc-card-container{position:absolute;bottom:12px;z-index:10;width:100%;padding-inline:12px;box-sizing:border-box}.lc-product-detail-view .lc-card-container{display:none}@media (max-width: 768px){.lc-product-detail-view .lc-card-container{display:block}}.lc-product-detail-view .lc-video-modal-row{display:flex;justify-content:center;height:100%;width:100%}.lc-video-only-view .lc-video-modal-row{display:block;height:100%}.lc-product-detail-view cooee-item-detail{--header-display: none;width:50%;flex:1}@media (max-width: 768px){.lc-product-detail-view cooee-item-detail{--header-display: flex;width:100%;height:70dvh;position:absolute;bottom:0;z-index:2147483646}}.lc-video-only-view cooee-item-detail{width:100%;height:70dvh;z-index:2147483646;bottom:0;position:absolute;border-radius:var(--lc-card-radius) var(--lc-card-radius) 0 0}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.video-loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;background-color:#0000004d;z-index:2}.video-loading-overlay .loading-spinner{width:30px;height:30px;border:3px solid rgba(255,255,255,.3);border-top:3px solid #fff;border-radius:50%;animation:spin 1s linear infinite}
3
3
  `],encapsulation:3})};export{Fe as VideoDetailDialogComponent};