@letscooee/web-sdk 9.13.1 → 9.13.2

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
- "use strict";(()=>{var Jd=Object.create;var kc=Object.defineProperty;var Xd=Object.getOwnPropertyDescriptor;var Qd=Object.getOwnPropertyNames;var Zd=Object.getPrototypeOf,tf=Object.prototype.hasOwnProperty;var ef=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qd(e))!tf.call(t,i)&&i!==r&&kc(t,i,{get:()=>e[i],enumerable:!(n=Xd(e,i))||n.enumerable});return t};var rf=(t,e,r)=>(r=t!=null?Jd(Zd(t)):{},ef(e||!t||!t.__esModule?kc(r,"default",{value:t,enumerable:!0}):r,t));var nf=Object.create,ca=Object.defineProperty,sf=Object.defineProperties,of=Object.getOwnPropertyDescriptor,af=Object.getOwnPropertyDescriptors,cf=Object.getOwnPropertyNames,Ri=Object.getOwnPropertySymbols,lf=Object.getPrototypeOf,la=Object.prototype.hasOwnProperty,Pu=Object.prototype.propertyIsEnumerable,Pc=(t,e,r)=>e in t?ca(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x=(t,e)=>{for(var r in e||={})la.call(e,r)&&Pc(t,r,e[r]);if(Ri)for(var r of Ri(e))Pu.call(e,r)&&Pc(t,r,e[r]);return t},lt=(t,e)=>sf(t,af(e)),hi=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),uf=(t,e)=>{var r={};for(var n in t)la.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Ri)for(var n of Ri(t))e.indexOf(n)<0&&Pu.call(t,n)&&(r[n]=t[n]);return r},rs=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),hf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cf(e))!la.call(t,i)&&i!==r&&ca(t,i,{get:()=>e[i],enumerable:!(n=of(e,i))||n.enumerable});return t},ke=(t,e,r)=>(r=t!=null?nf(lf(t)):{},hf(e||!t||!t.__esModule?ca(r,"default",{value:t,enumerable:!0}):r,t)),rn=rs((t,e)=>{"use strict";(function(r){"use strict";var n={};n.VERSION="1.6.1";var i,s={},o=function(h,w){return function(){return w.apply(h,arguments)}},c=function(){var h=arguments,w=h[0],y,b;for(b=1;b<h.length;b++)for(y in h[b])!(y in w)&&h[b].hasOwnProperty(y)&&(w[y]=h[b][y]);return w},l=function(h,w){return{value:h,name:w}};n.TRACE=l(1,"TRACE"),n.DEBUG=l(2,"DEBUG"),n.INFO=l(3,"INFO"),n.TIME=l(4,"TIME"),n.WARN=l(5,"WARN"),n.ERROR=l(8,"ERROR"),n.OFF=l(99,"OFF");var p=function(h){this.context=h,this.setLevel(h.filterLevel),this.log=this.info};p.prototype={setLevel:function(h){h&&"value"in h&&(this.context.filterLevel=h)},getLevel:function(){return this.context.filterLevel},enabledFor:function(h){var w=this.context.filterLevel;return h.value>=w.value},trace:function(){this.invoke(n.TRACE,arguments)},debug:function(){this.invoke(n.DEBUG,arguments)},info:function(){this.invoke(n.INFO,arguments)},warn:function(){this.invoke(n.WARN,arguments)},error:function(){this.invoke(n.ERROR,arguments)},time:function(h){typeof h=="string"&&h.length>0&&this.invoke(n.TIME,[h,"start"])},timeEnd:function(h){typeof h=="string"&&h.length>0&&this.invoke(n.TIME,[h,"end"])},invoke:function(h,w){i&&this.enabledFor(h)&&i(w,c({level:h},this.context))}};var g=new p({filterLevel:n.OFF});(function(){var h=n;h.enabledFor=o(g,g.enabledFor),h.trace=o(g,g.trace),h.debug=o(g,g.debug),h.time=o(g,g.time),h.timeEnd=o(g,g.timeEnd),h.info=o(g,g.info),h.warn=o(g,g.warn),h.error=o(g,g.error),h.log=h.info})(),n.setHandler=function(h){i=h},n.setLevel=function(h){g.setLevel(h);for(var w in s)s.hasOwnProperty(w)&&s[w].setLevel(h)},n.getLevel=function(){return g.getLevel()},n.get=function(h){return s[h]||(s[h]=new p(c({name:h},g.context)))},n.createDefaultHandler=function(h){h=h||{},h.formatter=h.formatter||function(b,_){_.name&&b.unshift("["+_.name+"]")};var w={},y=function(b,_){Function.prototype.apply.call(b,console,_)};return typeof console>"u"?function(){}:function(b,_){b=Array.prototype.slice.call(b);var k=console.log,A;_.level===n.TIME?(A=(_.name?"["+_.name+"] ":"")+b[0],b[1]==="start"?console.time?console.time(A):w[A]=new Date().getTime():console.timeEnd?console.timeEnd(A):y(k,[A+": "+(new Date().getTime()-w[A])+"ms"])):(_.level===n.WARN&&console.warn?k=console.warn:_.level===n.ERROR&&console.error?k=console.error:_.level===n.INFO&&console.info?k=console.info:_.level===n.DEBUG&&console.debug?k=console.debug:_.level===n.TRACE&&console.trace&&(k=console.trace),h.formatter(b,_),y(k,b))}},n.useDefaults=function(h){n.setLevel(h&&h.defaultLevel||n.DEBUG),n.setHandler(n.createDefaultHandler(h))},n.setDefaults=n.useDefaults,typeof define=="function"&&define.amd?define(n):typeof e<"u"&&e.exports?e.exports=n:(n._prevLogger=r.Logger,n.noConflict=function(){return r.Logger=n._prevLogger,n},r.Logger=n)})(t)}),pf=rs((t,e)=>{"use strict";(function(r){if(typeof t=="object"&&typeof e<"u")e.exports=r();else if(typeof define=="function"&&define.amd)define([],r);else{var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n=this,n.localforage=r()}})(function(){var r,n,i;return function s(o,c,l){function p(w,y){if(!c[w]){if(!o[w]){var b=typeof hi=="function"&&hi;if(!y&&b)return b(w,!0);if(g)return g(w,!0);var _=new Error("Cannot find module '"+w+"'");throw _.code="MODULE_NOT_FOUND",_}var k=c[w]={exports:{}};o[w][0].call(k.exports,function(A){var M=o[w][1][A];return p(M||A)},k,k.exports,s,o,c,l)}return c[w].exports}for(var g=typeof hi=="function"&&hi,h=0;h<l.length;h++)p(l[h]);return p}({1:[function(s,o,c){(function(l){"use strict";var p=l.MutationObserver||l.WebKitMutationObserver,g;if(p){var h=0,w=new p(A),y=l.document.createTextNode("");w.observe(y,{characterData:!0}),g=function(){y.data=h=++h%2}}else if(!l.setImmediate&&typeof l.MessageChannel<"u"){var b=new l.MessageChannel;b.port1.onmessage=A,g=function(){b.port2.postMessage(0)}}else"document"in l&&"onreadystatechange"in l.document.createElement("script")?g=function(){var G=l.document.createElement("script");G.onreadystatechange=function(){A(),G.onreadystatechange=null,G.parentNode.removeChild(G),G=null},l.document.documentElement.appendChild(G)}:g=function(){setTimeout(A,0)};var _,k=[];function A(){_=!0;for(var G,j,Z=k.length;Z;){for(j=k,k=[],G=-1;++G<Z;)j[G]();Z=k.length}_=!1}o.exports=M;function M(G){k.push(G)===1&&!_&&g()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(s,o,c){"use strict";var l=s(1);function p(){}var g={},h=["REJECTED"],w=["FULFILLED"],y=["PENDING"];o.exports=b;function b(q){if(typeof q!="function")throw new TypeError("resolver must be a function");this.state=y,this.queue=[],this.outcome=void 0,q!==p&&M(this,q)}b.prototype.catch=function(q){return this.then(null,q)},b.prototype.then=function(q,it){if(typeof q!="function"&&this.state===w||typeof it!="function"&&this.state===h)return this;var tt=new this.constructor(p);if(this.state!==y){var rt=this.state===w?q:it;k(tt,rt,this.outcome)}else this.queue.push(new _(tt,q,it));return tt};function _(q,it,tt){this.promise=q,typeof it=="function"&&(this.onFulfilled=it,this.callFulfilled=this.otherCallFulfilled),typeof tt=="function"&&(this.onRejected=tt,this.callRejected=this.otherCallRejected)}_.prototype.callFulfilled=function(q){g.resolve(this.promise,q)},_.prototype.otherCallFulfilled=function(q){k(this.promise,this.onFulfilled,q)},_.prototype.callRejected=function(q){g.reject(this.promise,q)},_.prototype.otherCallRejected=function(q){k(this.promise,this.onRejected,q)};function k(q,it,tt){l(function(){var rt;try{rt=it(tt)}catch(pt){return g.reject(q,pt)}rt===q?g.reject(q,new TypeError("Cannot resolve promise with itself")):g.resolve(q,rt)})}g.resolve=function(q,it){var tt=G(A,it);if(tt.status==="error")return g.reject(q,tt.value);var rt=tt.value;if(rt)M(q,rt);else{q.state=w,q.outcome=it;for(var pt=-1,Pt=q.queue.length;++pt<Pt;)q.queue[pt].callFulfilled(it)}return q},g.reject=function(q,it){q.state=h,q.outcome=it;for(var tt=-1,rt=q.queue.length;++tt<rt;)q.queue[tt].callRejected(it);return q};function A(q){var it=q&&q.then;if(q&&(typeof q=="object"||typeof q=="function")&&typeof it=="function")return function(){it.apply(q,arguments)}}function M(q,it){var tt=!1;function rt($t){tt||(tt=!0,g.reject(q,$t))}function pt($t){tt||(tt=!0,g.resolve(q,$t))}function Pt(){it(pt,rt)}var Ot=G(Pt);Ot.status==="error"&&rt(Ot.value)}function G(q,it){var tt={};try{tt.value=q(it),tt.status="success"}catch(rt){tt.status="error",tt.value=rt}return tt}b.resolve=j;function j(q){return q instanceof this?q:g.resolve(new this(p),q)}b.reject=Z;function Z(q){var it=new this(p);return g.reject(it,q)}b.all=Et;function Et(q){var it=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var tt=q.length,rt=!1;if(!tt)return this.resolve([]);for(var pt=new Array(tt),Pt=0,Ot=-1,$t=new this(p);++Ot<tt;)Wt(q[Ot],Ot);return $t;function Wt(mt,Gt){it.resolve(mt).then(at,function(nt){rt||(rt=!0,g.reject($t,nt))});function at(nt){pt[Gt]=nt,++Pt===tt&&!rt&&(rt=!0,g.resolve($t,pt))}}}b.race=At;function At(q){var it=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var tt=q.length,rt=!1;if(!tt)return this.resolve([]);for(var pt=-1,Pt=new this(p);++pt<tt;)Ot(q[pt]);return Pt;function Ot($t){it.resolve($t).then(function(Wt){rt||(rt=!0,g.resolve(Pt,Wt))},function(Wt){rt||(rt=!0,g.reject(Pt,Wt))})}}},{1:1}],3:[function(s,o,c){(function(l){"use strict";typeof l.Promise!="function"&&(l.Promise=s(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(s,o,c){"use strict";var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f};function p(f,m){if(!(f instanceof m))throw new TypeError("Cannot call a class as a function")}function g(){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 h=g();function w(){try{if(!h||!h.open)return!1;var f=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),m=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!f||m)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function y(f,m){f=f||[],m=m||{};try{return new Blob(f,m)}catch(C){if(C.name!=="TypeError")throw C;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,I=new v,S=0;S<f.length;S+=1)I.append(f[S]);return I.getBlob(m.type)}}typeof Promise>"u"&&s(3);var b=Promise;function _(f,m){m&&f.then(function(v){m(null,v)},function(v){m(v)})}function k(f,m,v){typeof m=="function"&&f.then(m),typeof v=="function"&&f.catch(v)}function A(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}function M(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var G="local-forage-detect-blob-support",j=void 0,Z={},Et=Object.prototype.toString,At="readonly",q="readwrite";function it(f){for(var m=f.length,v=new ArrayBuffer(m),I=new Uint8Array(v),S=0;S<m;S++)I[S]=f.charCodeAt(S);return v}function tt(f){return new b(function(m){var v=f.transaction(G,q),I=y([""]);v.objectStore(G).put(I,"key"),v.onabort=function(S){S.preventDefault(),S.stopPropagation(),m(!1)},v.oncomplete=function(){var S=navigator.userAgent.match(/Chrome\/(\d+)/),C=navigator.userAgent.match(/Edge\//);m(C||!S||parseInt(S[1],10)>=43)}}).catch(function(){return!1})}function rt(f){return typeof j=="boolean"?b.resolve(j):tt(f).then(function(m){return j=m,j})}function pt(f){var m=Z[f.name],v={};v.promise=new b(function(I,S){v.resolve=I,v.reject=S}),m.deferredOperations.push(v),m.dbReady?m.dbReady=m.dbReady.then(function(){return v.promise}):m.dbReady=v.promise}function Pt(f){var m=Z[f.name],v=m.deferredOperations.pop();if(v)return v.resolve(),v.promise}function Ot(f,m){var v=Z[f.name],I=v.deferredOperations.pop();if(I)return I.reject(m),I.promise}function $t(f,m){return new b(function(v,I){if(Z[f.name]=Z[f.name]||ci(),f.db)if(m)pt(f),f.db.close();else return v(f.db);var S=[f.name];m&&S.push(f.version);var C=h.open.apply(h,S);m&&(C.onupgradeneeded=function(N){var $=C.result;try{$.createObjectStore(f.storeName),N.oldVersion<=1&&$.createObjectStore(G)}catch(W){if(W.name==="ConstraintError")console.warn('The database "'+f.name+'" has been upgraded from version '+N.oldVersion+" to version "+N.newVersion+', but the storage "'+f.storeName+'" already exists.');else throw W}}),C.onerror=function(N){N.preventDefault(),I(C.error)},C.onsuccess=function(){var N=C.result;N.onversionchange=function($){$.target.close()},v(N),Pt(f)}})}function Wt(f){return $t(f,!1)}function mt(f){return $t(f,!0)}function Gt(f,m){if(!f.db)return!0;var v=!f.db.objectStoreNames.contains(f.storeName),I=f.version<f.db.version,S=f.version>f.db.version;if(I&&(f.version!==m&&console.warn('The database "'+f.name+`" can't be downgraded from version `+f.db.version+" to version "+f.version+"."),f.version=f.db.version),S||v){if(v){var C=f.db.version+1;C>f.version&&(f.version=C)}return!0}return!1}function at(f){return new b(function(m,v){var I=new FileReader;I.onerror=v,I.onloadend=function(S){var C=btoa(S.target.result||"");m({__local_forage_encoded_blob:!0,data:C,type:f.type})},I.readAsBinaryString(f)})}function nt(f){var m=it(atob(f.data));return y([m],{type:f.type})}function Ft(f){return f&&f.__local_forage_encoded_blob}function oi(f){var m=this,v=m._initReady().then(function(){var I=Z[m._dbInfo.name];if(I&&I.dbReady)return I.dbReady});return k(v,f,f),v}function ai(f){pt(f);for(var m=Z[f.name],v=m.forages,I=0;I<v.length;I++){var S=v[I];S._dbInfo.db&&(S._dbInfo.db.close(),S._dbInfo.db=null)}return f.db=null,Wt(f).then(function(C){return f.db=C,Gt(f)?mt(f):C}).then(function(C){f.db=m.db=C;for(var N=0;N<v.length;N++)v[N]._dbInfo.db=C}).catch(function(C){throw Ot(f,C),C})}function ae(f,m,v,I){I===void 0&&(I=1);try{var S=f.db.transaction(f.storeName,m);v(null,S)}catch(C){if(I>0&&(!f.db||C.name==="InvalidStateError"||C.name==="NotFoundError"))return b.resolve().then(function(){if(!f.db||C.name==="NotFoundError"&&!f.db.objectStoreNames.contains(f.storeName)&&f.version<=f.db.version)return f.db&&(f.version=f.db.version+1),mt(f)}).then(function(){return ai(f).then(function(){ae(f,m,v,I-1)})}).catch(v);v(C)}}function ci(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Ts(f){var m=this,v={db:null};if(f)for(var I in f)v[I]=f[I];var S=Z[v.name];S||(S=ci(),Z[v.name]=S),S.forages.push(m),m._initReady||(m._initReady=m.ready,m.ready=oi);var C=[];function N(){return b.resolve()}for(var $=0;$<S.forages.length;$++){var W=S.forages[$];W!==m&&C.push(W._initReady().catch(N))}var V=S.forages.slice(0);return b.all(C).then(function(){return v.db=S.db,Wt(v)}).then(function(F){return v.db=F,Gt(v,m._defaultConfig.version)?mt(v):F}).then(function(F){v.db=S.db=F,m._dbInfo=v;for(var J=0;J<V.length;J++){var ot=V[J];ot!==m&&(ot._dbInfo.db=v.db,ot._dbInfo.version=v.version)}})}function hn(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){ae(v._dbInfo,At,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=W.get(f);V.onsuccess=function(){var F=V.result;F===void 0&&(F=null),Ft(F)&&(F=nt(F)),S(F)},V.onerror=function(){C(V.error)}}catch(F){C(F)}})}).catch(C)});return _(I,m),I}function xs(f,m){var v=this,I=new b(function(S,C){v.ready().then(function(){ae(v._dbInfo,At,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=W.openCursor(),F=1;V.onsuccess=function(){var J=V.result;if(J){var ot=J.value;Ft(ot)&&(ot=nt(ot));var bt=f(ot,J.key,F++);bt!==void 0?S(bt):J.continue()}else S()},V.onerror=function(){C(V.error)}}catch(J){C(J)}})}).catch(C)});return _(I,m),I}function Ds(f,m,v){var I=this;f=A(f);var S=new b(function(C,N){var $;I.ready().then(function(){return $=I._dbInfo,Et.call(m)==="[object Blob]"?rt($.db).then(function(W){return W?m:at(m)}):m}).then(function(W){ae(I._dbInfo,q,function(V,F){if(V)return N(V);try{var J=F.objectStore(I._dbInfo.storeName);W===null&&(W=void 0);var ot=J.put(W,f);F.oncomplete=function(){W===void 0&&(W=null),C(W)},F.onabort=F.onerror=function(){var bt=ot.error?ot.error:ot.transaction.error;N(bt)}}catch(bt){N(bt)}})}).catch(N)});return _(S,v),S}function li(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){ae(v._dbInfo,q,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=W.delete(f);$.oncomplete=function(){S()},$.onerror=function(){C(V.error)},$.onabort=function(){var F=V.error?V.error:V.transaction.error;C(F)}}catch(F){C(F)}})}).catch(C)});return _(I,m),I}function Rr(f){var m=this,v=new b(function(I,S){m.ready().then(function(){ae(m._dbInfo,q,function(C,N){if(C)return S(C);try{var $=N.objectStore(m._dbInfo.storeName),W=$.clear();N.oncomplete=function(){I()},N.onabort=N.onerror=function(){var V=W.error?W.error:W.transaction.error;S(V)}}catch(V){S(V)}})}).catch(S)});return _(v,f),v}function ce(f){var m=this,v=new b(function(I,S){m.ready().then(function(){ae(m._dbInfo,At,function(C,N){if(C)return S(C);try{var $=N.objectStore(m._dbInfo.storeName),W=$.count();W.onsuccess=function(){I(W.result)},W.onerror=function(){S(W.error)}}catch(V){S(V)}})}).catch(S)});return _(v,f),v}function pn(f,m){var v=this,I=new b(function(S,C){if(f<0){S(null);return}v.ready().then(function(){ae(v._dbInfo,At,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=!1,F=W.openKeyCursor();F.onsuccess=function(){var J=F.result;if(!J){S(null);return}f===0||V?S(J.key):(V=!0,J.advance(f))},F.onerror=function(){C(F.error)}}catch(J){C(J)}})}).catch(C)});return _(I,m),I}function As(f){var m=this,v=new b(function(I,S){m.ready().then(function(){ae(m._dbInfo,At,function(C,N){if(C)return S(C);try{var $=N.objectStore(m._dbInfo.storeName),W=$.openKeyCursor(),V=[];W.onsuccess=function(){var F=W.result;if(!F){I(V);return}V.push(F.key),F.continue()},W.onerror=function(){S(W.error)}}catch(F){S(F)}})}).catch(S)});return _(v,f),v}function a(f,m){m=M.apply(this,arguments);var v=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||v.name,f.storeName=f.storeName||v.storeName);var I=this,S;if(!f.name)S=b.reject("Invalid arguments");else{var C=f.name===v.name&&I._dbInfo.db,N=C?b.resolve(I._dbInfo.db):Wt(f).then(function($){var W=Z[f.name],V=W.forages;W.db=$;for(var F=0;F<V.length;F++)V[F]._dbInfo.db=$;return $});f.storeName?S=N.then(function($){if($.objectStoreNames.contains(f.storeName)){var W=$.version+1;pt(f);var V=Z[f.name],F=V.forages;$.close();for(var J=0;J<F.length;J++){var ot=F[J];ot._dbInfo.db=null,ot._dbInfo.version=W}var bt=new b(function(ft,Rt){var Ct=h.open(f.name,W);Ct.onerror=function(le){var Rs=Ct.result;Rs.close(),Rt(le)},Ct.onupgradeneeded=function(){var le=Ct.result;le.deleteObjectStore(f.storeName)},Ct.onsuccess=function(){var le=Ct.result;le.close(),ft(le)}});return bt.then(function(ft){V.db=ft;for(var Rt=0;Rt<F.length;Rt++){var Ct=F[Rt];Ct._dbInfo.db=ft,Pt(Ct._dbInfo)}}).catch(function(ft){throw(Ot(f,ft)||b.resolve()).catch(function(){}),ft})}}):S=N.then(function($){pt(f);var W=Z[f.name],V=W.forages;$.close();for(var F=0;F<V.length;F++){var J=V[F];J._dbInfo.db=null}var ot=new b(function(bt,ft){var Rt=h.deleteDatabase(f.name);Rt.onerror=function(){var Ct=Rt.result;Ct&&Ct.close(),ft(Rt.error)},Rt.onblocked=function(){console.warn('dropInstance blocked for database "'+f.name+'" until all open connections are closed')},Rt.onsuccess=function(){var Ct=Rt.result;Ct&&Ct.close(),bt(Ct)}});return ot.then(function(bt){W.db=bt;for(var ft=0;ft<V.length;ft++){var Rt=V[ft];Pt(Rt._dbInfo)}}).catch(function(bt){throw(Ot(f,bt)||b.resolve()).catch(function(){}),bt})})}return _(S,m),S}var u={_driver:"asyncStorage",_initStorage:Ts,_support:w(),iterate:xs,getItem:hn,setItem:Ds,removeItem:li,clear:Rr,length:ce,key:pn,keys:As,dropInstance:a};function d(){return typeof openDatabase=="function"}var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",D="~~local_forage_type~",U=/^~~local_forage_type~([^~]+)~/,K="__lfsc__:",dt=K.length,Nt="arbf",vt="blob",It="si08",Bt="ui08",lr="uic8",dn="si16",fn="si32",bc="ur16",wc="ui32",_c="fl32",Ec="fl64",Sc=dt+Nt.length,Ic=Object.prototype.toString;function Cc(f){var m=f.length*.75,v=f.length,I,S=0,C,N,$,W;f[f.length-1]==="="&&(m--,f[f.length-2]==="="&&m--);var V=new ArrayBuffer(m),F=new Uint8Array(V);for(I=0;I<v;I+=4)C=E.indexOf(f[I]),N=E.indexOf(f[I+1]),$=E.indexOf(f[I+2]),W=E.indexOf(f[I+3]),F[S++]=C<<2|N>>4,F[S++]=(N&15)<<4|$>>2,F[S++]=($&3)<<6|W&63;return V}function Os(f){var m=new Uint8Array(f),v="",I;for(I=0;I<m.length;I+=3)v+=E[m[I]>>2],v+=E[(m[I]&3)<<4|m[I+1]>>4],v+=E[(m[I+1]&15)<<2|m[I+2]>>6],v+=E[m[I+2]&63];return m.length%3===2?v=v.substring(0,v.length-1)+"=":m.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function dd(f,m){var v="";if(f&&(v=Ic.call(f)),f&&(v==="[object ArrayBuffer]"||f.buffer&&Ic.call(f.buffer)==="[object ArrayBuffer]")){var I,S=K;f instanceof ArrayBuffer?(I=f,S+=Nt):(I=f.buffer,v==="[object Int8Array]"?S+=It:v==="[object Uint8Array]"?S+=Bt:v==="[object Uint8ClampedArray]"?S+=lr:v==="[object Int16Array]"?S+=dn:v==="[object Uint16Array]"?S+=bc:v==="[object Int32Array]"?S+=fn:v==="[object Uint32Array]"?S+=wc:v==="[object Float32Array]"?S+=_c:v==="[object Float64Array]"?S+=Ec:m(new Error("Failed to get type for BinaryArray"))),m(S+Os(I))}else if(v==="[object Blob]"){var C=new FileReader;C.onload=function(){var N=D+f.type+"~"+Os(this.result);m(K+vt+N)},C.readAsArrayBuffer(f)}else try{m(JSON.stringify(f))}catch(N){console.error("Couldn't convert value into a JSON string: ",f),m(null,N)}}function fd(f){if(f.substring(0,dt)!==K)return JSON.parse(f);var m=f.substring(Sc),v=f.substring(dt,Sc),I;if(v===vt&&U.test(m)){var S=m.match(U);I=S[1],m=m.substring(S[0].length)}var C=Cc(m);switch(v){case Nt:return C;case vt:return y([C],{type:I});case It:return new Int8Array(C);case Bt:return new Uint8Array(C);case lr:return new Uint8ClampedArray(C);case dn:return new Int16Array(C);case bc:return new Uint16Array(C);case fn:return new Int32Array(C);case wc:return new Uint32Array(C);case _c:return new Float32Array(C);case Ec:return new Float64Array(C);default:throw new Error("Unkown type: "+v)}}var Ns={serialize:dd,deserialize:fd,stringToBuffer:Cc,bufferToString:Os};function Tc(f,m,v,I){f.executeSql("CREATE TABLE IF NOT EXISTS "+m.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],v,I)}function gd(f){var m=this,v={db:null};if(f)for(var I in f)v[I]=typeof f[I]!="string"?f[I].toString():f[I];var S=new b(function(C,N){try{v.db=openDatabase(v.name,String(v.version),v.description,v.size)}catch($){return N($)}v.db.transaction(function($){Tc($,v,function(){m._dbInfo=v,C()},function(W,V){N(V)})},N)});return v.serializer=Ns,S}function Xe(f,m,v,I,S,C){f.executeSql(v,I,S,function(N,$){$.code===$.SYNTAX_ERR?N.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[m.storeName],function(W,V){V.rows.length?C(W,$):Tc(W,m,function(){W.executeSql(v,I,S,C)},C)},C):C(N,$)},C)}function md(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"SELECT * FROM "+N.storeName+" WHERE key = ? LIMIT 1",[f],function(W,V){var F=V.rows.length?V.rows.item(0).value:null;F&&(F=N.serializer.deserialize(F)),S(F)},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function vd(f,m){var v=this,I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"SELECT * FROM "+N.storeName,[],function(W,V){for(var F=V.rows,J=F.length,ot=0;ot<J;ot++){var bt=F.item(ot),ft=bt.value;if(ft&&(ft=N.serializer.deserialize(ft)),ft=f(ft,bt.key,ot+1),ft!==void 0){S(ft);return}}S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function xc(f,m,v,I){var S=this;f=A(f);var C=new b(function(N,$){S.ready().then(function(){m===void 0&&(m=null);var W=m,V=S._dbInfo;V.serializer.serialize(m,function(F,J){J?$(J):V.db.transaction(function(ot){Xe(ot,V,"INSERT OR REPLACE INTO "+V.storeName+" (key, value) VALUES (?, ?)",[f,F],function(){N(W)},function(bt,ft){$(ft)})},function(ot){if(ot.code===ot.QUOTA_ERR){if(I>0){N(xc.apply(S,[f,W,v,I-1]));return}$(ot)}})})}).catch($)});return _(C,v),C}function yd(f,m,v){return xc.apply(this,[f,m,v,1])}function bd(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"DELETE FROM "+N.storeName+" WHERE key = ?",[f],function(){S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function wd(f){var m=this,v=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(N){Xe(N,C,"DELETE FROM "+C.storeName,[],function(){I()},function($,W){S(W)})})}).catch(S)});return _(v,f),v}function _d(f){var m=this,v=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(N){Xe(N,C,"SELECT COUNT(key) as c FROM "+C.storeName,[],function($,W){var V=W.rows.item(0).c;I(V)},function($,W){S(W)})})}).catch(S)});return _(v,f),v}function Ed(f,m){var v=this,I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"SELECT key FROM "+N.storeName+" WHERE id = ? LIMIT 1",[f+1],function(W,V){var F=V.rows.length?V.rows.item(0).key:null;S(F)},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function Sd(f){var m=this,v=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(N){Xe(N,C,"SELECT key FROM "+C.storeName,[],function($,W){for(var V=[],F=0;F<W.rows.length;F++)V.push(W.rows.item(F).key);I(V)},function($,W){S(W)})})}).catch(S)});return _(v,f),v}function Id(f){return new b(function(m,v){f.transaction(function(I){I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(S,C){for(var N=[],$=0;$<C.rows.length;$++)N.push(C.rows.item($).name);m({db:f,storeNames:N})},function(S,C){v(C)})},function(I){v(I)})})}function Cd(f,m){m=M.apply(this,arguments);var v=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||v.name,f.storeName=f.storeName||v.storeName);var I=this,S;return f.name?S=new b(function(C){var N;f.name===v.name?N=I._dbInfo.db:N=openDatabase(f.name,"","",0),f.storeName?C({db:N,storeNames:[f.storeName]}):C(Id(N))}).then(function(C){return new b(function(N,$){C.db.transaction(function(W){function V(bt){return new b(function(ft,Rt){W.executeSql("DROP TABLE IF EXISTS "+bt,[],function(){ft()},function(Ct,le){Rt(le)})})}for(var F=[],J=0,ot=C.storeNames.length;J<ot;J++)F.push(V(C.storeNames[J]));b.all(F).then(function(){N()}).catch(function(bt){$(bt)})},function(W){$(W)})})}):S=b.reject("Invalid arguments"),_(S,m),S}var Td={_driver:"webSQLStorage",_initStorage:gd,_support:d(),iterate:vd,getItem:md,setItem:yd,removeItem:bd,clear:wd,length:_d,key:Ed,keys:Sd,dropInstance:Cd};function xd(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Dc(f,m){var v=f.name+"/";return f.storeName!==m.storeName&&(v+=f.storeName+"/"),v}function Dd(){var f="_localforage_support_test";try{return localStorage.setItem(f,!0),localStorage.removeItem(f),!1}catch{return!0}}function Ad(){return!Dd()||localStorage.length>0}function Od(f){var m=this,v={};if(f)for(var I in f)v[I]=f[I];return v.keyPrefix=Dc(f,m._defaultConfig),Ad()?(m._dbInfo=v,v.serializer=Ns,b.resolve()):b.reject()}function Nd(f){var m=this,v=m.ready().then(function(){for(var I=m._dbInfo.keyPrefix,S=localStorage.length-1;S>=0;S--){var C=localStorage.key(S);C.indexOf(I)===0&&localStorage.removeItem(C)}});return _(v,f),v}function kd(f,m){var v=this;f=A(f);var I=v.ready().then(function(){var S=v._dbInfo,C=localStorage.getItem(S.keyPrefix+f);return C&&(C=S.serializer.deserialize(C)),C});return _(I,m),I}function Pd(f,m){var v=this,I=v.ready().then(function(){for(var S=v._dbInfo,C=S.keyPrefix,N=C.length,$=localStorage.length,W=1,V=0;V<$;V++){var F=localStorage.key(V);if(F.indexOf(C)===0){var J=localStorage.getItem(F);if(J&&(J=S.serializer.deserialize(J)),J=f(J,F.substring(N),W++),J!==void 0)return J}}});return _(I,m),I}function Rd(f,m){var v=this,I=v.ready().then(function(){var S=v._dbInfo,C;try{C=localStorage.key(f)}catch{C=null}return C&&(C=C.substring(S.keyPrefix.length)),C});return _(I,m),I}function Ld(f){var m=this,v=m.ready().then(function(){for(var I=m._dbInfo,S=localStorage.length,C=[],N=0;N<S;N++){var $=localStorage.key(N);$.indexOf(I.keyPrefix)===0&&C.push($.substring(I.keyPrefix.length))}return C});return _(v,f),v}function Md(f){var m=this,v=m.keys().then(function(I){return I.length});return _(v,f),v}function Ud(f,m){var v=this;f=A(f);var I=v.ready().then(function(){var S=v._dbInfo;localStorage.removeItem(S.keyPrefix+f)});return _(I,m),I}function Bd(f,m,v){var I=this;f=A(f);var S=I.ready().then(function(){m===void 0&&(m=null);var C=m;return new b(function(N,$){var W=I._dbInfo;W.serializer.serialize(m,function(V,F){if(F)$(F);else try{localStorage.setItem(W.keyPrefix+f,V),N(C)}catch(J){(J.name==="QuotaExceededError"||J.name==="NS_ERROR_DOM_QUOTA_REACHED")&&$(J),$(J)}})})});return _(S,v),S}function jd(f,m){if(m=M.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var v=this.config();f.name=f.name||v.name,f.storeName=f.storeName||v.storeName}var I=this,S;return f.name?S=new b(function(C){f.storeName?C(Dc(f,I._defaultConfig)):C(f.name+"/")}).then(function(C){for(var N=localStorage.length-1;N>=0;N--){var $=localStorage.key(N);$.indexOf(C)===0&&localStorage.removeItem($)}}):S=b.reject("Invalid arguments"),_(S,m),S}var $d={_driver:"localStorageWrapper",_initStorage:Od,_support:xd(),iterate:Pd,getItem:kd,setItem:Bd,removeItem:Ud,clear:Nd,length:Md,key:Rd,keys:Ld,dropInstance:jd},Fd=function(f,m){return f===m||typeof f=="number"&&typeof m=="number"&&isNaN(f)&&isNaN(m)},Hd=function(f,m){for(var v=f.length,I=0;I<v;){if(Fd(f[I],m))return!0;I++}return!1},Ac=Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"},gn={},Oc={},Lr={INDEXEDDB:u,WEBSQL:Td,LOCALSTORAGE:$d},Vd=[Lr.INDEXEDDB._driver,Lr.WEBSQL._driver,Lr.LOCALSTORAGE._driver],ui=["dropInstance"],ks=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ui),qd={description:"",driver:Vd.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Wd(f,m){f[m]=function(){var v=arguments;return f.ready().then(function(){return f[m].apply(f,v)})}}function Ps(){for(var f=1;f<arguments.length;f++){var m=arguments[f];if(m)for(var v in m)m.hasOwnProperty(v)&&(Ac(m[v])?arguments[0][v]=m[v].slice():arguments[0][v]=m[v])}return arguments[0]}var Gd=function(){function f(m){p(this,f);for(var v in Lr)if(Lr.hasOwnProperty(v)){var I=Lr[v],S=I._driver;this[v]=S,gn[S]||this.defineDriver(I)}this._defaultConfig=Ps({},qd),this._config=Ps({},this._defaultConfig,m),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return f.prototype.config=function(m){if((typeof m>"u"?"undefined":l(m))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var v in m){if(v==="storeName"&&(m[v]=m[v].replace(/\W/g,"_")),v==="version"&&typeof m[v]!="number")return new Error("Database version must be a number.");this._config[v]=m[v]}return"driver"in m&&m.driver?this.setDriver(this._config.driver):!0}else return typeof m=="string"?this._config[m]:this._config},f.prototype.defineDriver=function(m,v,I){var S=new b(function(C,N){try{var $=m._driver,W=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){N(W);return}for(var V=ks.concat("_initStorage"),F=0,J=V.length;F<J;F++){var ot=V[F],bt=!Hd(ui,ot);if((bt||m[ot])&&typeof m[ot]!="function"){N(W);return}}var ft=function(){for(var Ct=function(Kd){return function(){var Yd=new Error("Method "+Kd+" is not implemented by the current driver"),Nc=b.reject(Yd);return _(Nc,arguments[arguments.length-1]),Nc}},le=0,Rs=ui.length;le<Rs;le++){var Ls=ui[le];m[Ls]||(m[Ls]=Ct(Ls))}};ft();var Rt=function(Ct){gn[$]&&console.info("Redefining LocalForage driver: "+$),gn[$]=m,Oc[$]=Ct,C()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(Rt,N):Rt(!!m._support):Rt(!0)}catch(Ct){N(Ct)}});return k(S,v,I),S},f.prototype.driver=function(){return this._driver||null},f.prototype.getDriver=function(m,v,I){var S=gn[m]?b.resolve(gn[m]):b.reject(new Error("Driver not found."));return k(S,v,I),S},f.prototype.getSerializer=function(m){var v=b.resolve(Ns);return k(v,m),v},f.prototype.ready=function(m){var v=this,I=v._driverSet.then(function(){return v._ready===null&&(v._ready=v._initDriver()),v._ready});return k(I,m,m),I},f.prototype.setDriver=function(m,v,I){var S=this;Ac(m)||(m=[m]);var C=this._getSupportedDrivers(m);function N(){S._config.driver=S.driver()}function $(F){return S._extend(F),N(),S._ready=S._initStorage(S._config),S._ready}function W(F){return function(){var J=0;function ot(){for(;J<F.length;){var bt=F[J];return J++,S._dbInfo=null,S._ready=null,S.getDriver(bt).then($).catch(ot)}N();var ft=new Error("No available storage method found.");return S._driverSet=b.reject(ft),S._driverSet}return ot()}}var V=this._driverSet!==null?this._driverSet.catch(function(){return b.resolve()}):b.resolve();return this._driverSet=V.then(function(){var F=C[0];return S._dbInfo=null,S._ready=null,S.getDriver(F).then(function(J){S._driver=J._driver,N(),S._wrapLibraryMethodsWithReady(),S._initDriver=W(C)})}).catch(function(){N();var F=new Error("No available storage method found.");return S._driverSet=b.reject(F),S._driverSet}),k(this._driverSet,v,I),this._driverSet},f.prototype.supports=function(m){return!!Oc[m]},f.prototype._extend=function(m){Ps(this,m)},f.prototype._getSupportedDrivers=function(m){for(var v=[],I=0,S=m.length;I<S;I++){var C=m[I];this.supports(C)&&v.push(C)}return v},f.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,v=ks.length;m<v;m++)Wd(this,ks[m])},f.prototype.createInstance=function(m){return new f(m)},f}(),zd=new Gd;o.exports=zd},{3:3}]},{},[4])(4)})}),Ru=rs(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.URLBuilder=void 0;var e=function(){function r(n){try{this.base=new URL(n),this.params=new URLSearchParams(this.base.search.slice(1))}catch(i){console.error("Un-parsable URL",i)}}return r.prototype.appendQueryParam=function(n,i){this.params.append(n,i?i.toString():"")},r.prototype.clearQueryParams=function(){return this.params=new URLSearchParams,this},r.prototype.deleteQueryParam=function(n){this.params.delete(n)},r.prototype.getBase=function(){return this.base},r.prototype.getPath=function(){return this.base.pathname},r.prototype.getHostname=function(){return this.base.hostname},r.prototype.getParams=function(){return this.params},r.prototype.getQueryParam=function(n){if(!this.params)return"";var i=this.params.get(n);return!i||i==="undefined"||i==="null"?void 0:i},r.prototype.getQueryString=function(){return this.params.toString()},r.prototype.setPath=function(n){return this.base.pathname=n,this},r.prototype.setQueryParam=function(n,i){return this.params.set(n,i?i.toString():""),this},r.prototype.setQueryString=function(n){if(n)return n[0]==="?"&&(n=n.slice(1)),this.params=new URLSearchParams(n),this},r.prototype.toString=function(){var n=this.params.toString();return n===""?this.base.search="":this.base.search="?"+n,this.base.toString()},r}();t.URLBuilder=e}),df=rs((t,e)=>{"use strict";(function(r,n){typeof t=="object"&&typeof e<"u"?e.exports=n():typeof define=="function"&&define.amd?define(n):(r=typeof globalThis<"u"?globalThis:r||self,r.fetchRetry=n())})(t,function(){"use strict";var r=function(s,o){if(o=o||{},typeof s!="function")throw new i("fetch must be a function");if(typeof o!="object")throw new i("defaults must be an object");if(o.retries!==void 0&&!n(o.retries))throw new i("retries must be a positive integer");if(o.retryDelay!==void 0&&!n(o.retryDelay)&&typeof o.retryDelay!="function")throw new i("retryDelay must be a positive integer or a function returning a positive integer");if(o.retryOn!==void 0&&!Array.isArray(o.retryOn)&&typeof o.retryOn!="function")throw new i("retryOn property expects an array or function");var c={retries:3,retryDelay:1e3,retryOn:[]};return o=Object.assign(c,o),function(l,p){var g=o.retries,h=o.retryDelay,w=o.retryOn;if(p&&p.retries!==void 0)if(n(p.retries))g=p.retries;else throw new i("retries must be a positive integer");if(p&&p.retryDelay!==void 0)if(n(p.retryDelay)||typeof p.retryDelay=="function")h=p.retryDelay;else throw new i("retryDelay must be a positive integer or a function returning a positive integer");if(p&&p.retryOn)if(Array.isArray(p.retryOn)||typeof p.retryOn=="function")w=p.retryOn;else throw new i("retryOn property expects an array or function");return new Promise(function(y,b){var _=function(A){var M=typeof Request<"u"&&l instanceof Request?l.clone():l;s(M,p).then(function(G){if(Array.isArray(w)&&w.indexOf(G.status)===-1)y(G);else if(typeof w=="function")try{return Promise.resolve(w(A,null,G)).then(function(j){j?k(A,null,G):y(G)}).catch(b)}catch(j){b(j)}else A<g?k(A,null,G):y(G)}).catch(function(G){if(typeof w=="function")try{Promise.resolve(w(A,G,null)).then(function(j){j?k(A,G,null):b(G)}).catch(function(j){b(j)})}catch(j){b(j)}else A<g?k(A,G,null):b(G)})};function k(A,M,G){var j=typeof h=="function"?h(A,M,G):h;setTimeout(function(){_(++A)},j)}_(0)})}};function n(s){return Number.isInteger(s)&&s>=0}function i(s){this.name="ArgumentError",this.message=s}return r})}),ff="9.13.1",H=class bo{static SDK_VERSION=ff;static SDK_VERSION_CODE;static SDK="WEB";static LOG_PREFIX="CooeeSDK";static COOEE="cooee";static SESSION_STORAGE_SCROLL_ID="sleid";static IDLE_TIME_IN_SECONDS=30*60;static IN_APP_WRAPPER_NAME="cooee-wrapper";static IN_APP_CONTAINER_NAME="cooee-container";static IN_APP_DEFAULT_PADDING=15;static EVENT_SCREEN_VIEW="CE Screen View";static EVENT_APP_BACKGROUND="CE App Background";static EVENT_TRIGGER_DISPLAYED="CE Trigger Displayed";static EVENT_CAMPAIGN_HOLDOUT="CE Campaign Holdout";static EVENT_CAMPAIGN_REJECTED="CE Campaign Rejected";static EVENT_CAMPAIGN_FAILED="CE Campaign Failed";static EVENT_TRIGGER_CLOSED="CE Trigger Closed";static EVENT_SCROLL="CE Scroll";static EVENT_TRIGGER_CLICKED="CE Trigger Clicked";static EVENT_FORM_SUBMITTED="CE Form Submitted";static EVENT_EXPERIMENT_START="CE Experiment Start";static EVENT_VIDEO_DIALOG_CLOSED="CE Video Dialog Closed";static EVENT_VIDEO_DIALOG_OPENED="CE Video Dialog Opened";static EVENT_VIDEO_CHANGE="CE Video Changed";static EVENT_LAST_VIDEO_ENDED="CE Last Video Ended";static EVENT_VIDEO_MUTED="CE Video Muted";static EVENT_VIDEO_UNMUTED="CE Video Unmuted";static EVENT_ADD_TO_CART_CLICKED="CE Add To Cart Clicked";static EVENT_VIEW_ITEM_CLICKED="CE View Item Clicked";static EVENT_MORE_ITEM_INFO_CLICKED="CE More Item Info Clicked";static EVENT_OPEN_CART_CLICKED="CE Open Cart Clicked";static EVENT_ADD_TO_CART="Add To Cart";static EVENT_REMOVE_FROM_CART="Remove From Cart";static EVENT_VIEW_ITEM="View Item";static EVENT_VIEW_CART="View Cart";static EVENT_OPEN_CART="Open Cart";static EVENT_VIEW_COLLECTION="View Collection";static EVENT_BUY_NOW_CLICKED="Buy Now Clicked";static EVENT_CHECKOUT_STARTED="Checkout Started";static EVENT_REVIEW_CLICKED="Review Clicked";static EVENT_ITEM_THUMBNAIL_CLICKED="Item Thumbnail Clicked";static JS_LOAD_WHITELIST_EVENTS=[this.EVENT_VIEW_ITEM,this.EVENT_VIEW_CART,this.EVENT_VIEW_COLLECTION];static HASH_INITIATE_CHECKOUT="initiate-checkout";static HASH_OPEN_CART_DRAWER="open-cart-drawer";static ADD_BUNDLE_CTA_INBOUND_EVENT="letscooee:inbound:cta:add-bundle";static CTA_OPEN_CART_EVENT="letscooee:outbound:open-cart";static CTA_AFTER_REFRESH_UI="letscooee:outbound:refresh-ui";static POPUP_ACTIVITY_EVENT="letscooee:outbound:popup-activities";static THIRD_PARTY_CHECKOUT_EVENT="letscooee:outbound:third-party-initiate-checkout";static CAMPAIGN_DISPLAYED_ACTIVITY="DISPLAYED";static CAMPAIGN_CLICKED_ACTIVITY="CLICKED";static CAMPAIGN_CLOSED_ACTIVITY="CLOSED";static BLACKLISTED_PAGE_NAMES=["collection","product","cart"];static API_CALL_MAX_ATTEMPTS=3;static API_CALL_RETRY_DELAY=1e3;static PLACEHOLDER_IMAGE="https://cdn.global.letscooee.com/images/placeholders/product.png";static CART_UPDATE_BROADCAST="CART_UPDATE";static GRAPHQL_VERSION="2024-10";static GRAPHQL_API_PATH=`/api/${this.GRAPHQL_VERSION}/graphql.json`;static SHADOW_SPLITTER=":shadow";static CAMPAIGN_ATTRIBUTE="_letscooee_campaign";static CONTENT_ATTRIBUTE="_letscooee_content";static VIA="_via";static PAYMENT_MODAL_DETAILS=[{identifier:"#flo-checkout-wrapper",gateway:"Shopflow"},{identifier:"#fastrr-main-container",gateway:"Shiprocket"},{identifier:"#gokwik-modal-wrapper",gateway:"Gokwik"},{identifier:"#zecpe",gateway:"Ecom 360"}];static{let e=bo.SDK_VERSION.split(".").map(r=>r.padStart(2,"0")).join("");bo.SDK_VERSION_CODE=parseInt(e,10)}},Ge={apiURL:"https://api.sdk.letscooee.com",debug:!1,mode:"production",styleURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${H.SDK_VERSION}/dist/widget.min.css`,widgetURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${H.SDK_VERSION}/dist/widget.min.js`},de=ke(rn()),T=class{static log(...t){de.default.info(...t)}static debug(...t){de.default.debug(...t)}static error(...t){de.default.error(...t)}static warn(...t){de.default.warn(...t)}static info(...t){de.default.info(...t)}static trace(...t){de.default.trace(...t)}};function gf(t=H.LOG_PREFIX){de.default.useDefaults({formatter:function(r){r.unshift(`${t} (v${H.SDK_VERSION}):`)}});let e=Lu();(e==="1"||e==="on")&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?de.default.setLevel(de.default[localStorage.cooeeLogLevel]):de.default.setLevel(Ge.debug?de.default.TRACE:de.default.OFF)}function Lu(){return new URL(location.href).searchParams?.get("cooee-debug")}function mf(){let t=`
1
+ "use strict";(()=>{var Jd=Object.create;var kc=Object.defineProperty;var Xd=Object.getOwnPropertyDescriptor;var Qd=Object.getOwnPropertyNames;var Zd=Object.getPrototypeOf,tf=Object.prototype.hasOwnProperty;var ef=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qd(e))!tf.call(t,i)&&i!==r&&kc(t,i,{get:()=>e[i],enumerable:!(n=Xd(e,i))||n.enumerable});return t};var rf=(t,e,r)=>(r=t!=null?Jd(Zd(t)):{},ef(e||!t||!t.__esModule?kc(r,"default",{value:t,enumerable:!0}):r,t));var nf=Object.create,ca=Object.defineProperty,sf=Object.defineProperties,of=Object.getOwnPropertyDescriptor,af=Object.getOwnPropertyDescriptors,cf=Object.getOwnPropertyNames,Ri=Object.getOwnPropertySymbols,lf=Object.getPrototypeOf,la=Object.prototype.hasOwnProperty,Pu=Object.prototype.propertyIsEnumerable,Pc=(t,e,r)=>e in t?ca(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x=(t,e)=>{for(var r in e||={})la.call(e,r)&&Pc(t,r,e[r]);if(Ri)for(var r of Ri(e))Pu.call(e,r)&&Pc(t,r,e[r]);return t},lt=(t,e)=>sf(t,af(e)),hi=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),uf=(t,e)=>{var r={};for(var n in t)la.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Ri)for(var n of Ri(t))e.indexOf(n)<0&&Pu.call(t,n)&&(r[n]=t[n]);return r},rs=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),hf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cf(e))!la.call(t,i)&&i!==r&&ca(t,i,{get:()=>e[i],enumerable:!(n=of(e,i))||n.enumerable});return t},ke=(t,e,r)=>(r=t!=null?nf(lf(t)):{},hf(e||!t||!t.__esModule?ca(r,"default",{value:t,enumerable:!0}):r,t)),rn=rs((t,e)=>{"use strict";(function(r){"use strict";var n={};n.VERSION="1.6.1";var i,s={},o=function(h,w){return function(){return w.apply(h,arguments)}},c=function(){var h=arguments,w=h[0],y,b;for(b=1;b<h.length;b++)for(y in h[b])!(y in w)&&h[b].hasOwnProperty(y)&&(w[y]=h[b][y]);return w},l=function(h,w){return{value:h,name:w}};n.TRACE=l(1,"TRACE"),n.DEBUG=l(2,"DEBUG"),n.INFO=l(3,"INFO"),n.TIME=l(4,"TIME"),n.WARN=l(5,"WARN"),n.ERROR=l(8,"ERROR"),n.OFF=l(99,"OFF");var p=function(h){this.context=h,this.setLevel(h.filterLevel),this.log=this.info};p.prototype={setLevel:function(h){h&&"value"in h&&(this.context.filterLevel=h)},getLevel:function(){return this.context.filterLevel},enabledFor:function(h){var w=this.context.filterLevel;return h.value>=w.value},trace:function(){this.invoke(n.TRACE,arguments)},debug:function(){this.invoke(n.DEBUG,arguments)},info:function(){this.invoke(n.INFO,arguments)},warn:function(){this.invoke(n.WARN,arguments)},error:function(){this.invoke(n.ERROR,arguments)},time:function(h){typeof h=="string"&&h.length>0&&this.invoke(n.TIME,[h,"start"])},timeEnd:function(h){typeof h=="string"&&h.length>0&&this.invoke(n.TIME,[h,"end"])},invoke:function(h,w){i&&this.enabledFor(h)&&i(w,c({level:h},this.context))}};var g=new p({filterLevel:n.OFF});(function(){var h=n;h.enabledFor=o(g,g.enabledFor),h.trace=o(g,g.trace),h.debug=o(g,g.debug),h.time=o(g,g.time),h.timeEnd=o(g,g.timeEnd),h.info=o(g,g.info),h.warn=o(g,g.warn),h.error=o(g,g.error),h.log=h.info})(),n.setHandler=function(h){i=h},n.setLevel=function(h){g.setLevel(h);for(var w in s)s.hasOwnProperty(w)&&s[w].setLevel(h)},n.getLevel=function(){return g.getLevel()},n.get=function(h){return s[h]||(s[h]=new p(c({name:h},g.context)))},n.createDefaultHandler=function(h){h=h||{},h.formatter=h.formatter||function(b,_){_.name&&b.unshift("["+_.name+"]")};var w={},y=function(b,_){Function.prototype.apply.call(b,console,_)};return typeof console>"u"?function(){}:function(b,_){b=Array.prototype.slice.call(b);var k=console.log,A;_.level===n.TIME?(A=(_.name?"["+_.name+"] ":"")+b[0],b[1]==="start"?console.time?console.time(A):w[A]=new Date().getTime():console.timeEnd?console.timeEnd(A):y(k,[A+": "+(new Date().getTime()-w[A])+"ms"])):(_.level===n.WARN&&console.warn?k=console.warn:_.level===n.ERROR&&console.error?k=console.error:_.level===n.INFO&&console.info?k=console.info:_.level===n.DEBUG&&console.debug?k=console.debug:_.level===n.TRACE&&console.trace&&(k=console.trace),h.formatter(b,_),y(k,b))}},n.useDefaults=function(h){n.setLevel(h&&h.defaultLevel||n.DEBUG),n.setHandler(n.createDefaultHandler(h))},n.setDefaults=n.useDefaults,typeof define=="function"&&define.amd?define(n):typeof e<"u"&&e.exports?e.exports=n:(n._prevLogger=r.Logger,n.noConflict=function(){return r.Logger=n._prevLogger,n},r.Logger=n)})(t)}),pf=rs((t,e)=>{"use strict";(function(r){if(typeof t=="object"&&typeof e<"u")e.exports=r();else if(typeof define=="function"&&define.amd)define([],r);else{var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n=this,n.localforage=r()}})(function(){var r,n,i;return function s(o,c,l){function p(w,y){if(!c[w]){if(!o[w]){var b=typeof hi=="function"&&hi;if(!y&&b)return b(w,!0);if(g)return g(w,!0);var _=new Error("Cannot find module '"+w+"'");throw _.code="MODULE_NOT_FOUND",_}var k=c[w]={exports:{}};o[w][0].call(k.exports,function(A){var M=o[w][1][A];return p(M||A)},k,k.exports,s,o,c,l)}return c[w].exports}for(var g=typeof hi=="function"&&hi,h=0;h<l.length;h++)p(l[h]);return p}({1:[function(s,o,c){(function(l){"use strict";var p=l.MutationObserver||l.WebKitMutationObserver,g;if(p){var h=0,w=new p(A),y=l.document.createTextNode("");w.observe(y,{characterData:!0}),g=function(){y.data=h=++h%2}}else if(!l.setImmediate&&typeof l.MessageChannel<"u"){var b=new l.MessageChannel;b.port1.onmessage=A,g=function(){b.port2.postMessage(0)}}else"document"in l&&"onreadystatechange"in l.document.createElement("script")?g=function(){var G=l.document.createElement("script");G.onreadystatechange=function(){A(),G.onreadystatechange=null,G.parentNode.removeChild(G),G=null},l.document.documentElement.appendChild(G)}:g=function(){setTimeout(A,0)};var _,k=[];function A(){_=!0;for(var G,j,Z=k.length;Z;){for(j=k,k=[],G=-1;++G<Z;)j[G]();Z=k.length}_=!1}o.exports=M;function M(G){k.push(G)===1&&!_&&g()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(s,o,c){"use strict";var l=s(1);function p(){}var g={},h=["REJECTED"],w=["FULFILLED"],y=["PENDING"];o.exports=b;function b(q){if(typeof q!="function")throw new TypeError("resolver must be a function");this.state=y,this.queue=[],this.outcome=void 0,q!==p&&M(this,q)}b.prototype.catch=function(q){return this.then(null,q)},b.prototype.then=function(q,it){if(typeof q!="function"&&this.state===w||typeof it!="function"&&this.state===h)return this;var tt=new this.constructor(p);if(this.state!==y){var rt=this.state===w?q:it;k(tt,rt,this.outcome)}else this.queue.push(new _(tt,q,it));return tt};function _(q,it,tt){this.promise=q,typeof it=="function"&&(this.onFulfilled=it,this.callFulfilled=this.otherCallFulfilled),typeof tt=="function"&&(this.onRejected=tt,this.callRejected=this.otherCallRejected)}_.prototype.callFulfilled=function(q){g.resolve(this.promise,q)},_.prototype.otherCallFulfilled=function(q){k(this.promise,this.onFulfilled,q)},_.prototype.callRejected=function(q){g.reject(this.promise,q)},_.prototype.otherCallRejected=function(q){k(this.promise,this.onRejected,q)};function k(q,it,tt){l(function(){var rt;try{rt=it(tt)}catch(pt){return g.reject(q,pt)}rt===q?g.reject(q,new TypeError("Cannot resolve promise with itself")):g.resolve(q,rt)})}g.resolve=function(q,it){var tt=G(A,it);if(tt.status==="error")return g.reject(q,tt.value);var rt=tt.value;if(rt)M(q,rt);else{q.state=w,q.outcome=it;for(var pt=-1,Pt=q.queue.length;++pt<Pt;)q.queue[pt].callFulfilled(it)}return q},g.reject=function(q,it){q.state=h,q.outcome=it;for(var tt=-1,rt=q.queue.length;++tt<rt;)q.queue[tt].callRejected(it);return q};function A(q){var it=q&&q.then;if(q&&(typeof q=="object"||typeof q=="function")&&typeof it=="function")return function(){it.apply(q,arguments)}}function M(q,it){var tt=!1;function rt($t){tt||(tt=!0,g.reject(q,$t))}function pt($t){tt||(tt=!0,g.resolve(q,$t))}function Pt(){it(pt,rt)}var Ot=G(Pt);Ot.status==="error"&&rt(Ot.value)}function G(q,it){var tt={};try{tt.value=q(it),tt.status="success"}catch(rt){tt.status="error",tt.value=rt}return tt}b.resolve=j;function j(q){return q instanceof this?q:g.resolve(new this(p),q)}b.reject=Z;function Z(q){var it=new this(p);return g.reject(it,q)}b.all=Et;function Et(q){var it=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var tt=q.length,rt=!1;if(!tt)return this.resolve([]);for(var pt=new Array(tt),Pt=0,Ot=-1,$t=new this(p);++Ot<tt;)Wt(q[Ot],Ot);return $t;function Wt(mt,Gt){it.resolve(mt).then(at,function(nt){rt||(rt=!0,g.reject($t,nt))});function at(nt){pt[Gt]=nt,++Pt===tt&&!rt&&(rt=!0,g.resolve($t,pt))}}}b.race=At;function At(q){var it=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var tt=q.length,rt=!1;if(!tt)return this.resolve([]);for(var pt=-1,Pt=new this(p);++pt<tt;)Ot(q[pt]);return Pt;function Ot($t){it.resolve($t).then(function(Wt){rt||(rt=!0,g.resolve(Pt,Wt))},function(Wt){rt||(rt=!0,g.reject(Pt,Wt))})}}},{1:1}],3:[function(s,o,c){(function(l){"use strict";typeof l.Promise!="function"&&(l.Promise=s(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(s,o,c){"use strict";var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f};function p(f,m){if(!(f instanceof m))throw new TypeError("Cannot call a class as a function")}function g(){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 h=g();function w(){try{if(!h||!h.open)return!1;var f=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),m=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!f||m)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function y(f,m){f=f||[],m=m||{};try{return new Blob(f,m)}catch(C){if(C.name!=="TypeError")throw C;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,I=new v,S=0;S<f.length;S+=1)I.append(f[S]);return I.getBlob(m.type)}}typeof Promise>"u"&&s(3);var b=Promise;function _(f,m){m&&f.then(function(v){m(null,v)},function(v){m(v)})}function k(f,m,v){typeof m=="function"&&f.then(m),typeof v=="function"&&f.catch(v)}function A(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}function M(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var G="local-forage-detect-blob-support",j=void 0,Z={},Et=Object.prototype.toString,At="readonly",q="readwrite";function it(f){for(var m=f.length,v=new ArrayBuffer(m),I=new Uint8Array(v),S=0;S<m;S++)I[S]=f.charCodeAt(S);return v}function tt(f){return new b(function(m){var v=f.transaction(G,q),I=y([""]);v.objectStore(G).put(I,"key"),v.onabort=function(S){S.preventDefault(),S.stopPropagation(),m(!1)},v.oncomplete=function(){var S=navigator.userAgent.match(/Chrome\/(\d+)/),C=navigator.userAgent.match(/Edge\//);m(C||!S||parseInt(S[1],10)>=43)}}).catch(function(){return!1})}function rt(f){return typeof j=="boolean"?b.resolve(j):tt(f).then(function(m){return j=m,j})}function pt(f){var m=Z[f.name],v={};v.promise=new b(function(I,S){v.resolve=I,v.reject=S}),m.deferredOperations.push(v),m.dbReady?m.dbReady=m.dbReady.then(function(){return v.promise}):m.dbReady=v.promise}function Pt(f){var m=Z[f.name],v=m.deferredOperations.pop();if(v)return v.resolve(),v.promise}function Ot(f,m){var v=Z[f.name],I=v.deferredOperations.pop();if(I)return I.reject(m),I.promise}function $t(f,m){return new b(function(v,I){if(Z[f.name]=Z[f.name]||ci(),f.db)if(m)pt(f),f.db.close();else return v(f.db);var S=[f.name];m&&S.push(f.version);var C=h.open.apply(h,S);m&&(C.onupgradeneeded=function(N){var $=C.result;try{$.createObjectStore(f.storeName),N.oldVersion<=1&&$.createObjectStore(G)}catch(W){if(W.name==="ConstraintError")console.warn('The database "'+f.name+'" has been upgraded from version '+N.oldVersion+" to version "+N.newVersion+', but the storage "'+f.storeName+'" already exists.');else throw W}}),C.onerror=function(N){N.preventDefault(),I(C.error)},C.onsuccess=function(){var N=C.result;N.onversionchange=function($){$.target.close()},v(N),Pt(f)}})}function Wt(f){return $t(f,!1)}function mt(f){return $t(f,!0)}function Gt(f,m){if(!f.db)return!0;var v=!f.db.objectStoreNames.contains(f.storeName),I=f.version<f.db.version,S=f.version>f.db.version;if(I&&(f.version!==m&&console.warn('The database "'+f.name+`" can't be downgraded from version `+f.db.version+" to version "+f.version+"."),f.version=f.db.version),S||v){if(v){var C=f.db.version+1;C>f.version&&(f.version=C)}return!0}return!1}function at(f){return new b(function(m,v){var I=new FileReader;I.onerror=v,I.onloadend=function(S){var C=btoa(S.target.result||"");m({__local_forage_encoded_blob:!0,data:C,type:f.type})},I.readAsBinaryString(f)})}function nt(f){var m=it(atob(f.data));return y([m],{type:f.type})}function Ft(f){return f&&f.__local_forage_encoded_blob}function oi(f){var m=this,v=m._initReady().then(function(){var I=Z[m._dbInfo.name];if(I&&I.dbReady)return I.dbReady});return k(v,f,f),v}function ai(f){pt(f);for(var m=Z[f.name],v=m.forages,I=0;I<v.length;I++){var S=v[I];S._dbInfo.db&&(S._dbInfo.db.close(),S._dbInfo.db=null)}return f.db=null,Wt(f).then(function(C){return f.db=C,Gt(f)?mt(f):C}).then(function(C){f.db=m.db=C;for(var N=0;N<v.length;N++)v[N]._dbInfo.db=C}).catch(function(C){throw Ot(f,C),C})}function ae(f,m,v,I){I===void 0&&(I=1);try{var S=f.db.transaction(f.storeName,m);v(null,S)}catch(C){if(I>0&&(!f.db||C.name==="InvalidStateError"||C.name==="NotFoundError"))return b.resolve().then(function(){if(!f.db||C.name==="NotFoundError"&&!f.db.objectStoreNames.contains(f.storeName)&&f.version<=f.db.version)return f.db&&(f.version=f.db.version+1),mt(f)}).then(function(){return ai(f).then(function(){ae(f,m,v,I-1)})}).catch(v);v(C)}}function ci(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Ts(f){var m=this,v={db:null};if(f)for(var I in f)v[I]=f[I];var S=Z[v.name];S||(S=ci(),Z[v.name]=S),S.forages.push(m),m._initReady||(m._initReady=m.ready,m.ready=oi);var C=[];function N(){return b.resolve()}for(var $=0;$<S.forages.length;$++){var W=S.forages[$];W!==m&&C.push(W._initReady().catch(N))}var V=S.forages.slice(0);return b.all(C).then(function(){return v.db=S.db,Wt(v)}).then(function(F){return v.db=F,Gt(v,m._defaultConfig.version)?mt(v):F}).then(function(F){v.db=S.db=F,m._dbInfo=v;for(var J=0;J<V.length;J++){var ot=V[J];ot!==m&&(ot._dbInfo.db=v.db,ot._dbInfo.version=v.version)}})}function hn(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){ae(v._dbInfo,At,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=W.get(f);V.onsuccess=function(){var F=V.result;F===void 0&&(F=null),Ft(F)&&(F=nt(F)),S(F)},V.onerror=function(){C(V.error)}}catch(F){C(F)}})}).catch(C)});return _(I,m),I}function xs(f,m){var v=this,I=new b(function(S,C){v.ready().then(function(){ae(v._dbInfo,At,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=W.openCursor(),F=1;V.onsuccess=function(){var J=V.result;if(J){var ot=J.value;Ft(ot)&&(ot=nt(ot));var bt=f(ot,J.key,F++);bt!==void 0?S(bt):J.continue()}else S()},V.onerror=function(){C(V.error)}}catch(J){C(J)}})}).catch(C)});return _(I,m),I}function Ds(f,m,v){var I=this;f=A(f);var S=new b(function(C,N){var $;I.ready().then(function(){return $=I._dbInfo,Et.call(m)==="[object Blob]"?rt($.db).then(function(W){return W?m:at(m)}):m}).then(function(W){ae(I._dbInfo,q,function(V,F){if(V)return N(V);try{var J=F.objectStore(I._dbInfo.storeName);W===null&&(W=void 0);var ot=J.put(W,f);F.oncomplete=function(){W===void 0&&(W=null),C(W)},F.onabort=F.onerror=function(){var bt=ot.error?ot.error:ot.transaction.error;N(bt)}}catch(bt){N(bt)}})}).catch(N)});return _(S,v),S}function li(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){ae(v._dbInfo,q,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=W.delete(f);$.oncomplete=function(){S()},$.onerror=function(){C(V.error)},$.onabort=function(){var F=V.error?V.error:V.transaction.error;C(F)}}catch(F){C(F)}})}).catch(C)});return _(I,m),I}function Rr(f){var m=this,v=new b(function(I,S){m.ready().then(function(){ae(m._dbInfo,q,function(C,N){if(C)return S(C);try{var $=N.objectStore(m._dbInfo.storeName),W=$.clear();N.oncomplete=function(){I()},N.onabort=N.onerror=function(){var V=W.error?W.error:W.transaction.error;S(V)}}catch(V){S(V)}})}).catch(S)});return _(v,f),v}function ce(f){var m=this,v=new b(function(I,S){m.ready().then(function(){ae(m._dbInfo,At,function(C,N){if(C)return S(C);try{var $=N.objectStore(m._dbInfo.storeName),W=$.count();W.onsuccess=function(){I(W.result)},W.onerror=function(){S(W.error)}}catch(V){S(V)}})}).catch(S)});return _(v,f),v}function pn(f,m){var v=this,I=new b(function(S,C){if(f<0){S(null);return}v.ready().then(function(){ae(v._dbInfo,At,function(N,$){if(N)return C(N);try{var W=$.objectStore(v._dbInfo.storeName),V=!1,F=W.openKeyCursor();F.onsuccess=function(){var J=F.result;if(!J){S(null);return}f===0||V?S(J.key):(V=!0,J.advance(f))},F.onerror=function(){C(F.error)}}catch(J){C(J)}})}).catch(C)});return _(I,m),I}function As(f){var m=this,v=new b(function(I,S){m.ready().then(function(){ae(m._dbInfo,At,function(C,N){if(C)return S(C);try{var $=N.objectStore(m._dbInfo.storeName),W=$.openKeyCursor(),V=[];W.onsuccess=function(){var F=W.result;if(!F){I(V);return}V.push(F.key),F.continue()},W.onerror=function(){S(W.error)}}catch(F){S(F)}})}).catch(S)});return _(v,f),v}function a(f,m){m=M.apply(this,arguments);var v=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||v.name,f.storeName=f.storeName||v.storeName);var I=this,S;if(!f.name)S=b.reject("Invalid arguments");else{var C=f.name===v.name&&I._dbInfo.db,N=C?b.resolve(I._dbInfo.db):Wt(f).then(function($){var W=Z[f.name],V=W.forages;W.db=$;for(var F=0;F<V.length;F++)V[F]._dbInfo.db=$;return $});f.storeName?S=N.then(function($){if($.objectStoreNames.contains(f.storeName)){var W=$.version+1;pt(f);var V=Z[f.name],F=V.forages;$.close();for(var J=0;J<F.length;J++){var ot=F[J];ot._dbInfo.db=null,ot._dbInfo.version=W}var bt=new b(function(ft,Rt){var Ct=h.open(f.name,W);Ct.onerror=function(le){var Rs=Ct.result;Rs.close(),Rt(le)},Ct.onupgradeneeded=function(){var le=Ct.result;le.deleteObjectStore(f.storeName)},Ct.onsuccess=function(){var le=Ct.result;le.close(),ft(le)}});return bt.then(function(ft){V.db=ft;for(var Rt=0;Rt<F.length;Rt++){var Ct=F[Rt];Ct._dbInfo.db=ft,Pt(Ct._dbInfo)}}).catch(function(ft){throw(Ot(f,ft)||b.resolve()).catch(function(){}),ft})}}):S=N.then(function($){pt(f);var W=Z[f.name],V=W.forages;$.close();for(var F=0;F<V.length;F++){var J=V[F];J._dbInfo.db=null}var ot=new b(function(bt,ft){var Rt=h.deleteDatabase(f.name);Rt.onerror=function(){var Ct=Rt.result;Ct&&Ct.close(),ft(Rt.error)},Rt.onblocked=function(){console.warn('dropInstance blocked for database "'+f.name+'" until all open connections are closed')},Rt.onsuccess=function(){var Ct=Rt.result;Ct&&Ct.close(),bt(Ct)}});return ot.then(function(bt){W.db=bt;for(var ft=0;ft<V.length;ft++){var Rt=V[ft];Pt(Rt._dbInfo)}}).catch(function(bt){throw(Ot(f,bt)||b.resolve()).catch(function(){}),bt})})}return _(S,m),S}var u={_driver:"asyncStorage",_initStorage:Ts,_support:w(),iterate:xs,getItem:hn,setItem:Ds,removeItem:li,clear:Rr,length:ce,key:pn,keys:As,dropInstance:a};function d(){return typeof openDatabase=="function"}var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",D="~~local_forage_type~",U=/^~~local_forage_type~([^~]+)~/,K="__lfsc__:",dt=K.length,Nt="arbf",vt="blob",It="si08",Bt="ui08",lr="uic8",dn="si16",fn="si32",bc="ur16",wc="ui32",_c="fl32",Ec="fl64",Sc=dt+Nt.length,Ic=Object.prototype.toString;function Cc(f){var m=f.length*.75,v=f.length,I,S=0,C,N,$,W;f[f.length-1]==="="&&(m--,f[f.length-2]==="="&&m--);var V=new ArrayBuffer(m),F=new Uint8Array(V);for(I=0;I<v;I+=4)C=E.indexOf(f[I]),N=E.indexOf(f[I+1]),$=E.indexOf(f[I+2]),W=E.indexOf(f[I+3]),F[S++]=C<<2|N>>4,F[S++]=(N&15)<<4|$>>2,F[S++]=($&3)<<6|W&63;return V}function Os(f){var m=new Uint8Array(f),v="",I;for(I=0;I<m.length;I+=3)v+=E[m[I]>>2],v+=E[(m[I]&3)<<4|m[I+1]>>4],v+=E[(m[I+1]&15)<<2|m[I+2]>>6],v+=E[m[I+2]&63];return m.length%3===2?v=v.substring(0,v.length-1)+"=":m.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function dd(f,m){var v="";if(f&&(v=Ic.call(f)),f&&(v==="[object ArrayBuffer]"||f.buffer&&Ic.call(f.buffer)==="[object ArrayBuffer]")){var I,S=K;f instanceof ArrayBuffer?(I=f,S+=Nt):(I=f.buffer,v==="[object Int8Array]"?S+=It:v==="[object Uint8Array]"?S+=Bt:v==="[object Uint8ClampedArray]"?S+=lr:v==="[object Int16Array]"?S+=dn:v==="[object Uint16Array]"?S+=bc:v==="[object Int32Array]"?S+=fn:v==="[object Uint32Array]"?S+=wc:v==="[object Float32Array]"?S+=_c:v==="[object Float64Array]"?S+=Ec:m(new Error("Failed to get type for BinaryArray"))),m(S+Os(I))}else if(v==="[object Blob]"){var C=new FileReader;C.onload=function(){var N=D+f.type+"~"+Os(this.result);m(K+vt+N)},C.readAsArrayBuffer(f)}else try{m(JSON.stringify(f))}catch(N){console.error("Couldn't convert value into a JSON string: ",f),m(null,N)}}function fd(f){if(f.substring(0,dt)!==K)return JSON.parse(f);var m=f.substring(Sc),v=f.substring(dt,Sc),I;if(v===vt&&U.test(m)){var S=m.match(U);I=S[1],m=m.substring(S[0].length)}var C=Cc(m);switch(v){case Nt:return C;case vt:return y([C],{type:I});case It:return new Int8Array(C);case Bt:return new Uint8Array(C);case lr:return new Uint8ClampedArray(C);case dn:return new Int16Array(C);case bc:return new Uint16Array(C);case fn:return new Int32Array(C);case wc:return new Uint32Array(C);case _c:return new Float32Array(C);case Ec:return new Float64Array(C);default:throw new Error("Unkown type: "+v)}}var Ns={serialize:dd,deserialize:fd,stringToBuffer:Cc,bufferToString:Os};function Tc(f,m,v,I){f.executeSql("CREATE TABLE IF NOT EXISTS "+m.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],v,I)}function gd(f){var m=this,v={db:null};if(f)for(var I in f)v[I]=typeof f[I]!="string"?f[I].toString():f[I];var S=new b(function(C,N){try{v.db=openDatabase(v.name,String(v.version),v.description,v.size)}catch($){return N($)}v.db.transaction(function($){Tc($,v,function(){m._dbInfo=v,C()},function(W,V){N(V)})},N)});return v.serializer=Ns,S}function Xe(f,m,v,I,S,C){f.executeSql(v,I,S,function(N,$){$.code===$.SYNTAX_ERR?N.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[m.storeName],function(W,V){V.rows.length?C(W,$):Tc(W,m,function(){W.executeSql(v,I,S,C)},C)},C):C(N,$)},C)}function md(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"SELECT * FROM "+N.storeName+" WHERE key = ? LIMIT 1",[f],function(W,V){var F=V.rows.length?V.rows.item(0).value:null;F&&(F=N.serializer.deserialize(F)),S(F)},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function vd(f,m){var v=this,I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"SELECT * FROM "+N.storeName,[],function(W,V){for(var F=V.rows,J=F.length,ot=0;ot<J;ot++){var bt=F.item(ot),ft=bt.value;if(ft&&(ft=N.serializer.deserialize(ft)),ft=f(ft,bt.key,ot+1),ft!==void 0){S(ft);return}}S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function xc(f,m,v,I){var S=this;f=A(f);var C=new b(function(N,$){S.ready().then(function(){m===void 0&&(m=null);var W=m,V=S._dbInfo;V.serializer.serialize(m,function(F,J){J?$(J):V.db.transaction(function(ot){Xe(ot,V,"INSERT OR REPLACE INTO "+V.storeName+" (key, value) VALUES (?, ?)",[f,F],function(){N(W)},function(bt,ft){$(ft)})},function(ot){if(ot.code===ot.QUOTA_ERR){if(I>0){N(xc.apply(S,[f,W,v,I-1]));return}$(ot)}})})}).catch($)});return _(C,v),C}function yd(f,m,v){return xc.apply(this,[f,m,v,1])}function bd(f,m){var v=this;f=A(f);var I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"DELETE FROM "+N.storeName+" WHERE key = ?",[f],function(){S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function wd(f){var m=this,v=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(N){Xe(N,C,"DELETE FROM "+C.storeName,[],function(){I()},function($,W){S(W)})})}).catch(S)});return _(v,f),v}function _d(f){var m=this,v=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(N){Xe(N,C,"SELECT COUNT(key) as c FROM "+C.storeName,[],function($,W){var V=W.rows.item(0).c;I(V)},function($,W){S(W)})})}).catch(S)});return _(v,f),v}function Ed(f,m){var v=this,I=new b(function(S,C){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function($){Xe($,N,"SELECT key FROM "+N.storeName+" WHERE id = ? LIMIT 1",[f+1],function(W,V){var F=V.rows.length?V.rows.item(0).key:null;S(F)},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function Sd(f){var m=this,v=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(N){Xe(N,C,"SELECT key FROM "+C.storeName,[],function($,W){for(var V=[],F=0;F<W.rows.length;F++)V.push(W.rows.item(F).key);I(V)},function($,W){S(W)})})}).catch(S)});return _(v,f),v}function Id(f){return new b(function(m,v){f.transaction(function(I){I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(S,C){for(var N=[],$=0;$<C.rows.length;$++)N.push(C.rows.item($).name);m({db:f,storeNames:N})},function(S,C){v(C)})},function(I){v(I)})})}function Cd(f,m){m=M.apply(this,arguments);var v=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||v.name,f.storeName=f.storeName||v.storeName);var I=this,S;return f.name?S=new b(function(C){var N;f.name===v.name?N=I._dbInfo.db:N=openDatabase(f.name,"","",0),f.storeName?C({db:N,storeNames:[f.storeName]}):C(Id(N))}).then(function(C){return new b(function(N,$){C.db.transaction(function(W){function V(bt){return new b(function(ft,Rt){W.executeSql("DROP TABLE IF EXISTS "+bt,[],function(){ft()},function(Ct,le){Rt(le)})})}for(var F=[],J=0,ot=C.storeNames.length;J<ot;J++)F.push(V(C.storeNames[J]));b.all(F).then(function(){N()}).catch(function(bt){$(bt)})},function(W){$(W)})})}):S=b.reject("Invalid arguments"),_(S,m),S}var Td={_driver:"webSQLStorage",_initStorage:gd,_support:d(),iterate:vd,getItem:md,setItem:yd,removeItem:bd,clear:wd,length:_d,key:Ed,keys:Sd,dropInstance:Cd};function xd(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Dc(f,m){var v=f.name+"/";return f.storeName!==m.storeName&&(v+=f.storeName+"/"),v}function Dd(){var f="_localforage_support_test";try{return localStorage.setItem(f,!0),localStorage.removeItem(f),!1}catch{return!0}}function Ad(){return!Dd()||localStorage.length>0}function Od(f){var m=this,v={};if(f)for(var I in f)v[I]=f[I];return v.keyPrefix=Dc(f,m._defaultConfig),Ad()?(m._dbInfo=v,v.serializer=Ns,b.resolve()):b.reject()}function Nd(f){var m=this,v=m.ready().then(function(){for(var I=m._dbInfo.keyPrefix,S=localStorage.length-1;S>=0;S--){var C=localStorage.key(S);C.indexOf(I)===0&&localStorage.removeItem(C)}});return _(v,f),v}function kd(f,m){var v=this;f=A(f);var I=v.ready().then(function(){var S=v._dbInfo,C=localStorage.getItem(S.keyPrefix+f);return C&&(C=S.serializer.deserialize(C)),C});return _(I,m),I}function Pd(f,m){var v=this,I=v.ready().then(function(){for(var S=v._dbInfo,C=S.keyPrefix,N=C.length,$=localStorage.length,W=1,V=0;V<$;V++){var F=localStorage.key(V);if(F.indexOf(C)===0){var J=localStorage.getItem(F);if(J&&(J=S.serializer.deserialize(J)),J=f(J,F.substring(N),W++),J!==void 0)return J}}});return _(I,m),I}function Rd(f,m){var v=this,I=v.ready().then(function(){var S=v._dbInfo,C;try{C=localStorage.key(f)}catch{C=null}return C&&(C=C.substring(S.keyPrefix.length)),C});return _(I,m),I}function Ld(f){var m=this,v=m.ready().then(function(){for(var I=m._dbInfo,S=localStorage.length,C=[],N=0;N<S;N++){var $=localStorage.key(N);$.indexOf(I.keyPrefix)===0&&C.push($.substring(I.keyPrefix.length))}return C});return _(v,f),v}function Md(f){var m=this,v=m.keys().then(function(I){return I.length});return _(v,f),v}function Ud(f,m){var v=this;f=A(f);var I=v.ready().then(function(){var S=v._dbInfo;localStorage.removeItem(S.keyPrefix+f)});return _(I,m),I}function Bd(f,m,v){var I=this;f=A(f);var S=I.ready().then(function(){m===void 0&&(m=null);var C=m;return new b(function(N,$){var W=I._dbInfo;W.serializer.serialize(m,function(V,F){if(F)$(F);else try{localStorage.setItem(W.keyPrefix+f,V),N(C)}catch(J){(J.name==="QuotaExceededError"||J.name==="NS_ERROR_DOM_QUOTA_REACHED")&&$(J),$(J)}})})});return _(S,v),S}function jd(f,m){if(m=M.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var v=this.config();f.name=f.name||v.name,f.storeName=f.storeName||v.storeName}var I=this,S;return f.name?S=new b(function(C){f.storeName?C(Dc(f,I._defaultConfig)):C(f.name+"/")}).then(function(C){for(var N=localStorage.length-1;N>=0;N--){var $=localStorage.key(N);$.indexOf(C)===0&&localStorage.removeItem($)}}):S=b.reject("Invalid arguments"),_(S,m),S}var $d={_driver:"localStorageWrapper",_initStorage:Od,_support:xd(),iterate:Pd,getItem:kd,setItem:Bd,removeItem:Ud,clear:Nd,length:Md,key:Rd,keys:Ld,dropInstance:jd},Fd=function(f,m){return f===m||typeof f=="number"&&typeof m=="number"&&isNaN(f)&&isNaN(m)},Hd=function(f,m){for(var v=f.length,I=0;I<v;){if(Fd(f[I],m))return!0;I++}return!1},Ac=Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"},gn={},Oc={},Lr={INDEXEDDB:u,WEBSQL:Td,LOCALSTORAGE:$d},Vd=[Lr.INDEXEDDB._driver,Lr.WEBSQL._driver,Lr.LOCALSTORAGE._driver],ui=["dropInstance"],ks=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ui),qd={description:"",driver:Vd.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Wd(f,m){f[m]=function(){var v=arguments;return f.ready().then(function(){return f[m].apply(f,v)})}}function Ps(){for(var f=1;f<arguments.length;f++){var m=arguments[f];if(m)for(var v in m)m.hasOwnProperty(v)&&(Ac(m[v])?arguments[0][v]=m[v].slice():arguments[0][v]=m[v])}return arguments[0]}var Gd=function(){function f(m){p(this,f);for(var v in Lr)if(Lr.hasOwnProperty(v)){var I=Lr[v],S=I._driver;this[v]=S,gn[S]||this.defineDriver(I)}this._defaultConfig=Ps({},qd),this._config=Ps({},this._defaultConfig,m),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return f.prototype.config=function(m){if((typeof m>"u"?"undefined":l(m))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var v in m){if(v==="storeName"&&(m[v]=m[v].replace(/\W/g,"_")),v==="version"&&typeof m[v]!="number")return new Error("Database version must be a number.");this._config[v]=m[v]}return"driver"in m&&m.driver?this.setDriver(this._config.driver):!0}else return typeof m=="string"?this._config[m]:this._config},f.prototype.defineDriver=function(m,v,I){var S=new b(function(C,N){try{var $=m._driver,W=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){N(W);return}for(var V=ks.concat("_initStorage"),F=0,J=V.length;F<J;F++){var ot=V[F],bt=!Hd(ui,ot);if((bt||m[ot])&&typeof m[ot]!="function"){N(W);return}}var ft=function(){for(var Ct=function(Kd){return function(){var Yd=new Error("Method "+Kd+" is not implemented by the current driver"),Nc=b.reject(Yd);return _(Nc,arguments[arguments.length-1]),Nc}},le=0,Rs=ui.length;le<Rs;le++){var Ls=ui[le];m[Ls]||(m[Ls]=Ct(Ls))}};ft();var Rt=function(Ct){gn[$]&&console.info("Redefining LocalForage driver: "+$),gn[$]=m,Oc[$]=Ct,C()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(Rt,N):Rt(!!m._support):Rt(!0)}catch(Ct){N(Ct)}});return k(S,v,I),S},f.prototype.driver=function(){return this._driver||null},f.prototype.getDriver=function(m,v,I){var S=gn[m]?b.resolve(gn[m]):b.reject(new Error("Driver not found."));return k(S,v,I),S},f.prototype.getSerializer=function(m){var v=b.resolve(Ns);return k(v,m),v},f.prototype.ready=function(m){var v=this,I=v._driverSet.then(function(){return v._ready===null&&(v._ready=v._initDriver()),v._ready});return k(I,m,m),I},f.prototype.setDriver=function(m,v,I){var S=this;Ac(m)||(m=[m]);var C=this._getSupportedDrivers(m);function N(){S._config.driver=S.driver()}function $(F){return S._extend(F),N(),S._ready=S._initStorage(S._config),S._ready}function W(F){return function(){var J=0;function ot(){for(;J<F.length;){var bt=F[J];return J++,S._dbInfo=null,S._ready=null,S.getDriver(bt).then($).catch(ot)}N();var ft=new Error("No available storage method found.");return S._driverSet=b.reject(ft),S._driverSet}return ot()}}var V=this._driverSet!==null?this._driverSet.catch(function(){return b.resolve()}):b.resolve();return this._driverSet=V.then(function(){var F=C[0];return S._dbInfo=null,S._ready=null,S.getDriver(F).then(function(J){S._driver=J._driver,N(),S._wrapLibraryMethodsWithReady(),S._initDriver=W(C)})}).catch(function(){N();var F=new Error("No available storage method found.");return S._driverSet=b.reject(F),S._driverSet}),k(this._driverSet,v,I),this._driverSet},f.prototype.supports=function(m){return!!Oc[m]},f.prototype._extend=function(m){Ps(this,m)},f.prototype._getSupportedDrivers=function(m){for(var v=[],I=0,S=m.length;I<S;I++){var C=m[I];this.supports(C)&&v.push(C)}return v},f.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,v=ks.length;m<v;m++)Wd(this,ks[m])},f.prototype.createInstance=function(m){return new f(m)},f}(),zd=new Gd;o.exports=zd},{3:3}]},{},[4])(4)})}),Ru=rs(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.URLBuilder=void 0;var e=function(){function r(n){try{this.base=new URL(n),this.params=new URLSearchParams(this.base.search.slice(1))}catch(i){console.error("Un-parsable URL",i)}}return r.prototype.appendQueryParam=function(n,i){this.params.append(n,i?i.toString():"")},r.prototype.clearQueryParams=function(){return this.params=new URLSearchParams,this},r.prototype.deleteQueryParam=function(n){this.params.delete(n)},r.prototype.getBase=function(){return this.base},r.prototype.getPath=function(){return this.base.pathname},r.prototype.getHostname=function(){return this.base.hostname},r.prototype.getParams=function(){return this.params},r.prototype.getQueryParam=function(n){if(!this.params)return"";var i=this.params.get(n);return!i||i==="undefined"||i==="null"?void 0:i},r.prototype.getQueryString=function(){return this.params.toString()},r.prototype.setPath=function(n){return this.base.pathname=n,this},r.prototype.setQueryParam=function(n,i){return this.params.set(n,i?i.toString():""),this},r.prototype.setQueryString=function(n){if(n)return n[0]==="?"&&(n=n.slice(1)),this.params=new URLSearchParams(n),this},r.prototype.toString=function(){var n=this.params.toString();return n===""?this.base.search="":this.base.search="?"+n,this.base.toString()},r}();t.URLBuilder=e}),df=rs((t,e)=>{"use strict";(function(r,n){typeof t=="object"&&typeof e<"u"?e.exports=n():typeof define=="function"&&define.amd?define(n):(r=typeof globalThis<"u"?globalThis:r||self,r.fetchRetry=n())})(t,function(){"use strict";var r=function(s,o){if(o=o||{},typeof s!="function")throw new i("fetch must be a function");if(typeof o!="object")throw new i("defaults must be an object");if(o.retries!==void 0&&!n(o.retries))throw new i("retries must be a positive integer");if(o.retryDelay!==void 0&&!n(o.retryDelay)&&typeof o.retryDelay!="function")throw new i("retryDelay must be a positive integer or a function returning a positive integer");if(o.retryOn!==void 0&&!Array.isArray(o.retryOn)&&typeof o.retryOn!="function")throw new i("retryOn property expects an array or function");var c={retries:3,retryDelay:1e3,retryOn:[]};return o=Object.assign(c,o),function(l,p){var g=o.retries,h=o.retryDelay,w=o.retryOn;if(p&&p.retries!==void 0)if(n(p.retries))g=p.retries;else throw new i("retries must be a positive integer");if(p&&p.retryDelay!==void 0)if(n(p.retryDelay)||typeof p.retryDelay=="function")h=p.retryDelay;else throw new i("retryDelay must be a positive integer or a function returning a positive integer");if(p&&p.retryOn)if(Array.isArray(p.retryOn)||typeof p.retryOn=="function")w=p.retryOn;else throw new i("retryOn property expects an array or function");return new Promise(function(y,b){var _=function(A){var M=typeof Request<"u"&&l instanceof Request?l.clone():l;s(M,p).then(function(G){if(Array.isArray(w)&&w.indexOf(G.status)===-1)y(G);else if(typeof w=="function")try{return Promise.resolve(w(A,null,G)).then(function(j){j?k(A,null,G):y(G)}).catch(b)}catch(j){b(j)}else A<g?k(A,null,G):y(G)}).catch(function(G){if(typeof w=="function")try{Promise.resolve(w(A,G,null)).then(function(j){j?k(A,G,null):b(G)}).catch(function(j){b(j)})}catch(j){b(j)}else A<g?k(A,G,null):b(G)})};function k(A,M,G){var j=typeof h=="function"?h(A,M,G):h;setTimeout(function(){_(++A)},j)}_(0)})}};function n(s){return Number.isInteger(s)&&s>=0}function i(s){this.name="ArgumentError",this.message=s}return r})}),ff="9.13.2",H=class bo{static SDK_VERSION=ff;static SDK_VERSION_CODE;static SDK="WEB";static LOG_PREFIX="CooeeSDK";static COOEE="cooee";static SESSION_STORAGE_SCROLL_ID="sleid";static IDLE_TIME_IN_SECONDS=30*60;static IN_APP_WRAPPER_NAME="cooee-wrapper";static IN_APP_CONTAINER_NAME="cooee-container";static IN_APP_DEFAULT_PADDING=15;static EVENT_SCREEN_VIEW="CE Screen View";static EVENT_APP_BACKGROUND="CE App Background";static EVENT_TRIGGER_DISPLAYED="CE Trigger Displayed";static EVENT_CAMPAIGN_HOLDOUT="CE Campaign Holdout";static EVENT_CAMPAIGN_REJECTED="CE Campaign Rejected";static EVENT_CAMPAIGN_FAILED="CE Campaign Failed";static EVENT_TRIGGER_CLOSED="CE Trigger Closed";static EVENT_SCROLL="CE Scroll";static EVENT_TRIGGER_CLICKED="CE Trigger Clicked";static EVENT_FORM_SUBMITTED="CE Form Submitted";static EVENT_EXPERIMENT_START="CE Experiment Start";static EVENT_VIDEO_DIALOG_CLOSED="CE Video Dialog Closed";static EVENT_VIDEO_DIALOG_OPENED="CE Video Dialog Opened";static EVENT_VIDEO_CHANGE="CE Video Changed";static EVENT_LAST_VIDEO_ENDED="CE Last Video Ended";static EVENT_VIDEO_MUTED="CE Video Muted";static EVENT_VIDEO_UNMUTED="CE Video Unmuted";static EVENT_ADD_TO_CART_CLICKED="CE Add To Cart Clicked";static EVENT_VIEW_ITEM_CLICKED="CE View Item Clicked";static EVENT_MORE_ITEM_INFO_CLICKED="CE More Item Info Clicked";static EVENT_OPEN_CART_CLICKED="CE Open Cart Clicked";static EVENT_ADD_TO_CART="Add To Cart";static EVENT_REMOVE_FROM_CART="Remove From Cart";static EVENT_VIEW_ITEM="View Item";static EVENT_VIEW_CART="View Cart";static EVENT_OPEN_CART="Open Cart";static EVENT_VIEW_COLLECTION="View Collection";static EVENT_BUY_NOW_CLICKED="Buy Now Clicked";static EVENT_CHECKOUT_STARTED="Checkout Started";static EVENT_REVIEW_CLICKED="Review Clicked";static EVENT_ITEM_THUMBNAIL_CLICKED="Item Thumbnail Clicked";static JS_LOAD_WHITELIST_EVENTS=[this.EVENT_VIEW_ITEM,this.EVENT_VIEW_CART,this.EVENT_VIEW_COLLECTION];static HASH_INITIATE_CHECKOUT="initiate-checkout";static HASH_OPEN_CART_DRAWER="open-cart-drawer";static ADD_BUNDLE_CTA_INBOUND_EVENT="letscooee:inbound:cta:add-bundle";static CTA_OPEN_CART_EVENT="letscooee:outbound:open-cart";static CTA_AFTER_REFRESH_UI="letscooee:outbound:refresh-ui";static POPUP_ACTIVITY_EVENT="letscooee:outbound:popup-activities";static THIRD_PARTY_CHECKOUT_EVENT="letscooee:outbound:third-party-initiate-checkout";static CAMPAIGN_DISPLAYED_ACTIVITY="DISPLAYED";static CAMPAIGN_CLICKED_ACTIVITY="CLICKED";static CAMPAIGN_CLOSED_ACTIVITY="CLOSED";static BLACKLISTED_PAGE_NAMES=["collection","product","cart"];static API_CALL_MAX_ATTEMPTS=3;static API_CALL_RETRY_DELAY=1e3;static PLACEHOLDER_IMAGE="https://cdn.global.letscooee.com/images/placeholders/product.png";static CART_UPDATE_BROADCAST="CART_UPDATE";static GRAPHQL_VERSION="2024-10";static GRAPHQL_API_PATH=`/api/${this.GRAPHQL_VERSION}/graphql.json`;static SHADOW_SPLITTER=":shadow";static CAMPAIGN_ATTRIBUTE="_letscooee_campaign";static CONTENT_ATTRIBUTE="_letscooee_content";static VIA="_via";static PAYMENT_MODAL_DETAILS=[{identifier:"#flo-checkout-wrapper",gateway:"Shopflow"},{identifier:"#fastrr-main-container",gateway:"Shiprocket"},{identifier:"#gokwik-modal-wrapper",gateway:"Gokwik"},{identifier:"#zecpe",gateway:"Ecom 360"}];static{let e=bo.SDK_VERSION.split(".").map(r=>r.padStart(2,"0")).join("");bo.SDK_VERSION_CODE=parseInt(e,10)}},Ge={apiURL:"https://api.sdk.letscooee.com",debug:!1,mode:"production",styleURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${H.SDK_VERSION}/dist/widget.min.css`,widgetURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${H.SDK_VERSION}/dist/widget.min.js`},de=ke(rn()),T=class{static log(...t){de.default.info(...t)}static debug(...t){de.default.debug(...t)}static error(...t){de.default.error(...t)}static warn(...t){de.default.warn(...t)}static info(...t){de.default.info(...t)}static trace(...t){de.default.trace(...t)}};function gf(t=H.LOG_PREFIX){de.default.useDefaults({formatter:function(r){r.unshift(`${t} (v${H.SDK_VERSION}):`)}});let e=Lu();(e==="1"||e==="on")&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?de.default.setLevel(de.default[localStorage.cooeeLogLevel]):de.default.setLevel(Ge.debug?de.default.TRACE:de.default.OFF)}function Lu(){return new URL(location.href).searchParams?.get("cooee-debug")}function mf(){let t=`
2
2
  display: inline-block;
3
3
  font-size: 14px;
4
4
  background: linear-gradient(90deg, #d52dc8 25%, #2179e2 82%);
@@ -66,4 +66,4 @@ mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
66
66
  }
67
67
  }
68
68
  }
69
- `,gc=class{sentryService=ut.get(zt);async addToCart(t,e){if(!t.length)return;let r=t.map(c=>{let{vID:l,quantity:p}=this.getVIDAndQuantity(c);return{id:l?+l:+c.mID,quantity:p,properties:e.getPrivateAttributesForLineItem()}}),n=Ln("cart/add.js"),i={items:r},s=Ee.get();s.isMiniCart()?i.sections=["mini-cart"]:s.isShopifyDefaultDrawer()&&(i.sections=s.element.getSectionsToRender?.().map(c=>c.section??c.id));let o=JSON.stringify(i);try{let c=await fetch(n,{body:o,method:"post",headers:{"Content-Type":"application/json"}});if(c&&!c.ok&&(await this.sentryService.captureFetchFailure(c,"cart-item-add"),c.status>400&&c.status<500)){let l=await c.json();Me(l.description||"Failed to add product in cart. Please try again")}if(c.status===200||c.status===302)return T.log(`Added ${t.length} items to Cart`),Me("Product added to your cart"),c.json()}catch(c){Me("Failed to add product in cart. Please try again"),this.sentryService.captureError(c,"cart-item-add",{extra:{body:o},engagementTrigger:e})}}async updateLineItem(t,e){if(!Gn.hasKeys(e)){T.warn("No update fields provided");return}let r=Ln("cart/change.js"),n=x({id:t.key},e),i=JSON.stringify(n);try{let s=await fetch(r,{body:i,method:"post",headers:{"Content-Type":"application/json"}});if(s&&!s.ok&&await this.sentryService.captureFetchFailure(s,"cart-item-update"),s.status===200||s.status===302){let o=await s.json();T.log(`Updated ${t}`),xt.getCurrent().update(o)}}catch(s){Me("Failed to update item in cart"),this.sentryService.captureError(s,"cart-item-update",{extra:{body:i}})}}async copyDiscountCode(t){if(t)try{await navigator.clipboard.writeText(t),T.log(`Code-${t} copied`),Me("Discount code copied")}catch(e){T.error("Failed to copy code",e)}}goToItem(t){if(!t?.link)return;let e=Wb(t.link);e&&(location.pathname=Wi()+"products/"+e)}async upgradeToSubscription(t,e){if(!t){T.warn("Trying to upgrade to subscription with no item");return}let r=await xt.getCurrent().getNormalisedCart(),n=t.selectedOrFirstVariant.value,i=r.items.findIndex(p=>p.vID===n.mID),s=n.selectedSellingPlan.value,o=Ln("cart/change.js"),c={line:i+1,selling_plan:s?.mID||null,properties:e.getPrivateAttributesForLineItem()},l=JSON.stringify(c);try{let p=await fetch(o,{body:l,method:"post",headers:{"Content-Type":"application/json"}});if(p&&!p.ok&&await this.sentryService.captureFetchFailure(p,"cart-switch-subscription"),p.status===200||p.status===302){T.log(`Upgraded ${t} selling plan`),Me("Line item updated");let g=await p.json();return xt.getCurrent().update(g),g}}catch(p){Me("Failed to update subscription"),this.sentryService.captureError(p,"cart-switch-subscription",{extra:{body:l},engagementTrigger:e})}}async createNewCart(t,e,r){let n=se.get().storefrontToken;if(!n)throw new Error("Storefront token not set for the store");if(!t?.vID){T.error("No variant ID found to perform Buy now",t);return}let i=e?[e]:[],s=[{merchandiseId:`gid://shopify/ProductVariant/${t.vID}`,quantity:1,attributes:r.getKVFormatPrivateAttributesForLineItem()}],o=await kh(),c=new Headers;c.append("Content-Type","application/json"),c.append("X-Shopify-Storefront-Access-Token",n);let l=JSON.stringify({query:V0,variables:{input:{lines:s,discountCodes:i,attributes:o}}});return(await Pr.getInstance().request(H.GRAPHQL_API_PATH,{method:"POST",headers:c,body:l})).data?.cartCreate?.cart?.checkoutUrl}async process(t){let e=t.clickAction,r=t.items,n=t.triggerData;if(e.at){let i=e;if(T.log(`Performing ${JSON.stringify(i)} action`),i.at===101)r?.length&&this.goToItem(r[0]);else if(i.at===102)r?.length&&await this.addToCart(r,n);else if(i.at===103)await this.copyDiscountCode(n.discount?.code);else if(i.at===105)Ee.get().open();else if(i.at===104){let s=t.collections;if(!s?.length)return;location.pathname=Wi()+"collections/"+s[0].handle}}e.applyDiscount&&n.discount?.code&&Mn.navigate(n.discount.code,n.redirectBehaviour)}getVIDAndQuantity(t){let e,r;if(t instanceof Ar)e=t.vID,r=t.quantity??1;else{if(!t.vars?.length)return{};e=t.selectedOrFirstVariant.value.mID,r=1}return{vID:e,quantity:r}}},q0=class extends Er{ctaExecutor=new gc;constructor(t){super(t)}update(t){super.update(t),this.engagementTrigger.progressBarConfig.update(t.progressBarConfig),this.checkMilestoneSilently(),this.widgetElement.update()}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-progressbar"),this.checkMilestoneSilently()}checkMilestoneSilently(){this.checkMilestone().catch(t=>{zt.getInstance().captureError(t,"apply-milestones",{engagementTrigger:this.engagementTrigger})})}async checkMilestone(){let t=await xt.getCurrent().getNormalisedCart(),e=this.engagementTrigger.progressBarConfig,r,n=[],i=[],s=[],o,c,l=[...e.milestones];for(let g of l){if(g.rewardType!==ju.FREE_AUTO_GIFT)continue;let h=g.items[0],w=g.reached,y=t.items.find(b=>(b.vID===h.vID||b.mID===h.mID)&&b.properties[H.CAMPAIGN_ATTRIBUTE]===this.engagementTrigger.shortID);w&&(o=g,c=y),y&&n.push(y),!w&&y&&e.removeIneligibleItem?(T.debug(`Removing free gift ${y.vID} from cart`),s.push(y)):w&&!y&&(T.debug(`Adding free gift ${h.vID} to cart`),i.push(h))}e.restrictToLatestFreebie&&o&&(c?(n=n.filter(g=>g.vID!==c.vID),i=[]):i=[o.items[0]],s.push(...n)),s.length&&await this.removeFreeGifts(s),i.length&&(r=await this.ctaExecutor.addToCart(i,this.engagementTrigger));let p=e.coupons;if(p?.length)try{await Mn.applyWithStorefront(p.map(g=>g.couponCode)),Ee.get().refreshUI(r,!1)}catch(g){this.sentryService.captureError(g,"cart-apply-discount",{extra:{coupons:p},engagementTrigger:this.engagementTrigger})}}async removeFreeGifts(t){await Promise.all(t.map(e=>this.ctaExecutor.updateLineItem(e,{quantity:0})))}},Nu=class extends Er{constructor(t){super(t)}update(t){super.update(t),this.engagementTrigger.content.update(t.content),this.widgetElement.update()}addToRendered(){this.engagementTrigger.isPageEmbed()?We.renderedEngagements.push(this):Er.renderedEngagements.push(this)}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-savings-bar")}},W0=class extends We{constructor(t){super(t)}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-shoppable-videos")}},G0=class extends We{constructor(t){super(t)}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-sticky-atc")}},z0=class extends We{constructor(t){super(t)}shouldStopRendering(){return!1}renderContainer(){let t=this.getParentElement(`inner-letscooee-${this.engagementTrigger.shortID}`);this.rootContainer.appendChild(t),document.addEventListener(H.ADD_BUNDLE_CTA_INBOUND_EVENT,this.inboundCTAListener.bind(this),!1)}async inboundCTAListener(t){let e=this.engagementTrigger,r=`Engagement(id: ${e.engagementID}, shortID: ${e.shortID})`,n=t.detail;if(!Gn.hasKeys(n)){T.error(`No detail received for ${r}`);return}T.log("Detail received for BYOB",n);let i=n.campaignID??n.campaignId??n.campaign_id;if(i!==e.shortID&&i!==e.engagementID){T.warn(`Current ${r} is not BYOB. Received: ${i}`);return}let s=n.items;if(!s?.length)return;let o=s.map(c=>new Ar({mID:c.product_id,vID:c.variant_id,quantity:c.quantity||1}));await new Cs(this.triggerContext).execute({embeddedItems:o,clickAction:{at:108,applyDiscount:!0}})}},mo=class{runtimeData=kt.get();processCartWidgetResponse(t){this.runtimeData.isCartDirty=!1,this.runtimeData.cartEngagements=t;let e=[...Er.renderedEngagements];Er.renderedEngagements.length=0;for(let r of t)T.log(`\u{1F4E3} ${r} received as cart embed`),!this.findAndUpdateCurrent(r,e)&&(T.log(`${r} is new`),r.isProgressBar()?new q0(r).renderSilently():r.isSubscriptionUpsell()?F0.renderCartUpsell(r):r.isSavingsBar()?new Nu(r).renderSilently():new Er(r).renderSilently());this.removeOldWidgets(e)}processPageWidgetResponse(t){let e=[...We.renderedEngagements];We.renderedEngagements.length=0;for(let r of t)T.log(`\u{1F4E3} ${r} received as page embed`),!this.findAndUpdateCurrent(r,e)&&(T.log(`${r} is new`),r.isShoppableVideo()?new W0(r).renderSilently():r.isBYOB()?new z0(r).renderSilently():r.isStickyATC()?new G0(r).renderSilently():r.isSavingsBar()?new Nu(r).renderSilently():new We(r).renderSilently());this.removeOldWidgets(e)}findAndUpdateCurrent(t,e){let r=e.findIndex(n=>n.isSameTrigger(t));return r<0||t.isSubscriptionUpsell()?!1:(e[r].update(t),e[r].renderSilently(),e.splice(r,1),!0)}removeOldWidgets(t){for(let e of t)e.destroy()}},td=class{runtimeData=kt.get();httpService=ut.get(Pr);sessionManager=ut.get(we);constructor(){}async getWidgetProps(){let t={};t.engagementIDs=this.addAvailableEngagementShortIDs(),t.locale=this.runtimeData.locale,await this.addSessionContext(t),t.currentItem=this.runtimeData.getCurrentItem();try{t.cart=await xt.getCurrent().getNormalisedCart()}catch(i){T.error("Error fetching Shopify cart before sending widget call",i)}let e=new URLSearchParams(location.search),r=e.get("cooee-preview");r?t.previewIDs=r.trim().split(",").filter(i=>Number.isInteger(+i)):this.runtimeData.previewIDs?.length&&(t.previewIDs=this.runtimeData.previewIDs);let n=e.get("cooee-variant");return n?t.previewVariant=n:this.runtimeData.previewVariant&&(t.previewVariant=this.runtimeData.previewVariant),t}async addSessionContext(t){let e=await this.sessionManager.checkSessionAndGetContext();t.sessionID=e[0],t.sessionNumber=e[1],t.landingPage=e[2],t.page=Ss.parseFromCurrent()}addAvailableEngagementShortIDs(){let t=document.querySelectorAll(".letscooee-engagement"),e=[];return t.forEach(r=>{let n=r.dataset.engagementId;n&&+n&&e.push(n)}),e}},Wn=class ed extends td{static INSTANCE;loadWidgetsSubject=new or;constructor(){super(),this.loadWidgetsSubject.pipe(ni(300)).subscribe(()=>{this.loadCartWidgets().catch(e=>T.error("Unable to initiate cart widgets",e)),this.loadPageWidgets().catch(e=>T.error("Unable to initiate page widgets",e))}),hc.get().subscriber(H.CART_UPDATE_BROADCAST).subscribe(()=>this.loadWidgetsSubject.next())}static getInstance(){return this.INSTANCE||(this.INSTANCE=new ed),this.INSTANCE}loadOrRenderWidgetsAfterCartChange(){this.runtimeData.isCartDirty?this.loadWidgetsSilently():this.renderCachedCartWidgets()}loadPageWidgetsSilently(){we.replaySubject.subscribe(async()=>{this.loadPageWidgets().catch(e=>T.error("Unable to initiate load page widgets",e))})}loadCartWidgetsSilently(){we.replaySubject.subscribe(async()=>{this.loadCartWidgets().catch(e=>T.error("Unable to initiate cart widgets",e))})}loadWidgetsSilently(){we.replaySubject.subscribe(async()=>{this.loadWidgetsSubject.next()})}async loadPageWidgets(){let e=await this.getWidgetProps();T.log("Load widgets",e),this.httpService.post("/v1/engagement/page-widgets",e).then(async r=>{let n=r.widgets.map(i=>new sr(i));new mo().processPageWidgetResponse(n)}).catch(r=>{T.error("Error sending widget getter",r)})}async loadCartWidgets(){let e=await this.getWidgetProps();T.log("Load cart widgets",e),this.httpService.post("/v1/engagement/cart-widgets",e).then(async r=>{let n=r.widgets.map(i=>new sr(i));new mo().processCartWidgetResponse(n)}).catch(r=>{T.error("Error sending widget getter",r)})}async getVariation(e){let r=await this.getWidgetProps();return this.httpService.post("/v1/engagement/get-variant",x(x({},e),r))}renderCachedCartWidgets(){new mo().processCartWidgetResponse(this.runtimeData.cartEngagements)}},K0=class rd{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new rd),this.INSTANCE}init(){Ou.get(ct.APP_CONFIG,{}).then(e=>this.updateGlobalConfig(e))}async processAppConfigurations(e){T.log("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);Ou.set(ct.APP_CONFIG,r).catch(n=>T.error(n)),D0.processConfiguration(),r.website&&(be.injectRawScript(r.website.commonJS),be.injectRawCSS(r.website.commonCSS)),Ee.get().onToggle().subscribe(async({open:n})=>{T.info("Cart drawer is now",n?"open":"closed"),n&&(ut.get(Wn).loadOrRenderWidgetsAfterCartChange(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=Tt.globalRef.config.update(e);return Ee.forceUpdate(),T.debug("App configurations",r),r}async trackViewCartEvent(){let e=await xt.getCurrent().getNormalisedCart(),r={value:e.amount,currency:e.currency},n={items:e.items,amount:r,drawer:!0};Vt.getInstance().sendEvent(new jt(H.EVENT_VIEW_CART,n))}},sa=class nd{static INSTANCE;httpAPIService=Pr.getInstance();coreService=K0.getInstance();sentryService=zt.getInstance();sdkToken="";userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new nd),this.INSTANCE}init(e){this.appID=e.appID,this.shopifyShop=e.shopifyShop}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await Mt.set(ct.ID,e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await Mt.set(ct.DEVICE_ID,e.deviceID)),e.sdkToken&&(this.sdkToken=e.sdkToken,await Mt.set(ct.SDK_TOKEN,e.sdkToken)),this.updateAPIClient())}async validateSession(e){await this.populateFirstSeen(),await this.populateUserDataFromStorage(),T.log("Validating session with server");let r=await this.getSessionValidateData(e);try{let n=await this.httpAPIService.validateSession(r);T.log("Validating session Response",n),await this.coreService.processAppConfigurations(n.appSettings),await this.storeAndPopulateAuthData(n)}catch(n){throw T.error(n),n}}async populateUserDataFromStorage(){if(this.sdkToken=await Mt.get(ct.SDK_TOKEN),!this.sdkToken){T.warn("No SDK token found in local storage");return}this.userID=await Mt.get(ct.ID),this.deviceID=await Mt.get(ct.DEVICE_ID),this.updateAPIClient()}updateAPIClient(){T.debug("SDK Token:",this.sdkToken),T.log("Device ID:",this.deviceID),T.log("User ID:",this.userID),Fp.trackDeviceID(this.deviceID),Ne.log(`Device ID: ${this.deviceID}`),this.userID&&Ne.log(`User ID: ${this.userID}`),this.httpAPIService.setAPIToken(this.sdkToken),this.httpAPIService.setDeviceId(this.deviceID),this.sentryService.setGlobalContext("Visitor Info",{device_id:this.deviceID,user_id:this.userID}),this.sentryService.setUser({id:this.deviceID})}async getSessionValidateData(e){let r=await new I0().safeGet(),n=await Mt.get(ct.DEVICE_ID);return n||(n=new Kt().toHexString(),await Mt.set(ct.DEVICE_ID,n)),lt(x({deviceID:n,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),{sdk:H.SDK,page:Ss.parseFromCurrent(),ad:w0.getAdParams(),occurred:this.getSessionStartTime(kt.get().jsLoadTime),currentItem:kt.get().getCurrentItem(),cart:await xt.getCurrent().getNormalisedCart(),properties:{}})}async populateFirstSeen(){let e=await Mt.get(ct.FIRST_SEEN),r=e?new Date(e):new Date;e||await Mt.set(ct.FIRST_SEEN,r.toISOString()),this.httpAPIService.setFirstSeen(r),this.sentryService.setGlobalContext("Visitor Info",{first_seen:r.toISOString()})}getSessionStartTime(e){return(new Date().getTime()-e.getTime())/1e3>H.IDLE_TIME_IN_SECONDS?new Date:e}},we=class Pn{static replaySubject=new j_(1);static INSTANCE;sentryService=ut.get(zt);constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Pn),this.INSTANCE}init(e){if(T.debug("Initialising SDK",e),E_(navigator.userAgent)){T.info("This seems to be a bot. Disabling SDK");return}sa.getInstance().init(e),Pn.INSTANCE.checkSessionOnPageLoad().then(async()=>{Pn.replaySubject.next(!0),Pn.replaySubject.complete()}).catch(r=>{T.error("Unable to initiate session",r)})}getCurrentSessionID(){return ee.set(ct.SESSION_LAST_USED_TIME,new Date().getTime()),ee.get(ct.ID,"")}async checkSessionOnPageLoad(){await zb.request("validate_session",async()=>{await this.checkForNewSession(!0)})}async checkSessionAndGetContext(){return await this.checkForNewSession(),this.getContext()}async getContext(){let e=await Promise.all([this.getCurrentSessionID(),this.getCurrentSessionNumber(),this.getLandingPage()]);return this.sentryService.setTags({"cooee_session.number":e[1]}),this.sentryService.setGlobalContext("Visitor Session",{id:e[0],number:e[1],landing_page:e[2]}),e}async checkForNewSession(e){let r=!1;if(await this.isNewSessionRequired()?(Ne.log("New session to be started"),await this.startNewSession(),e=!0,r=!0):await this.notSynced()&&(r=!0),e){let n=await this.getContext();Ne.log(`Session ID: ${n[0]} & number: ${n[1]}`),await sa.getInstance().validateSession({sessionID:n[0],sessionNumber:n[1],landingPage:n[2],newSession:r}),await ee.set(ct.SESSION_SYNCED,!0)}}async startNewSession(){T.debug("Starting new session"),await ee.clear(),T.debug("Cleared SessionStorage before starting new session");let e=new Date,r=new Kt().toHexString();T.debug("New session ID to be used",r);let n=await Mt.get(ct.SESSION_NUMBER,0)+1;await Promise.all([Mt.set(ct.SESSION_NUMBER,n),ee.set(ct.ID,r),ee.set(ct.SESSION_LAST_USED_TIME,e.getTime()),ee.set(ct.SESSION_LANDING_PAGE,Ss.parseFromCurrent())])}getLandingPage(){return ee.get(ct.SESSION_LANDING_PAGE,{})}getCurrentSessionNumber(){return Mt.get(ct.SESSION_NUMBER,1)}async isNewSessionRequired(){if(!await ee.get(ct.ID))return!0;let e=await ee.get(ct.SESSION_LAST_USED_TIME,0);return e?(new Date().getTime()-e)/1e3>H.IDLE_TIME_IN_SECONDS:!0}async notSynced(){return!await ee.get(ct.SESSION_SYNCED,!1)}},Y0=class{loadedFonts=[];async loadAllFonts(t){t.elems?.forEach(e=>{e instanceof ds&&this.loadFamily(e.typography?.fam)})}async loadFamily(t){if(!t?.fonts||this.loadedFonts.indexOf(t.name)>-1)return;let e=[];t.fonts.forEach(r=>{if(r.url){let n=new FontFace(H.COOEE+t.name,r.getURL(),r.getFontDescriptor());e.push(n.load())}}),this.loadedFonts.push(t.name),(await Promise.all(e)).forEach(r=>{document.fonts.add(r)})}},J0=class{static updateIdentity(t){if(!this.isInstalled())return;let e={};t.email&&(e.email=t.email),t.mobile&&(e.phone_number=t.mobile),T.debug("Sending email/mobile to Klaviyo"),window.klaviyo.push(["identify",e])}static isInstalled(){return window.klaviyo&&typeof window.klaviyo=="object"}},X0=class{apiService;action;triggerContext;constructor(t,e){this.action=t,this.apiService=Vt.getInstance(),this.triggerContext=e}async execute(){let t=this.containsCTA()?H.EVENT_TRIGGER_CLICKED:H.EVENT_TRIGGER_CLOSED;switch(this.action.at!==106&&await this.closeTriggerAndSendEvent(t),this.action.at){case 2:break;case 4:this.gotoURLAction();break;case 5:this.shareAction();break;case 106:await this.collectFormData();break;case void 0:case 105:break;default:T.error("Received an invalid ClickActionType: ",this.action.at);return}}externalAction(){this.action.ext?.u&&window.open(this.action.ext.u,"_blank")?.focus()}gotoURLAction(){if(this.action.gu?.u){let t=this.action.gu.u;Ah(t)||(t=`//${t}`),window.open(t,"_self")}}async closeTriggerAndSendEvent(t,e){this.triggerContext.closeInApp(t,e),await this.dispatchEvent()}shareAction(){if(this.action.share){if(!navigator.share){T.warn("Navigator.share is not compatible with this browser");return}navigator.share({text:this.action.share.text,title:"Share"}).then(t=>console.log(t)).catch(t=>console.error(t))}}containsCTA(){return this.action.at&&this.action.at!==1?!0:!(this.isEmpty(this.action.custKV)&&this.isEmpty(this.action.up))}isEmpty(t){return t?Object.keys(t).length===0:!0}async collectFormData(){let t={};for(let e of this.triggerContext.inputs){if(!e.isValid)return;let r=document.getElementById(e.id).value;e.type===51?t.email=r:e.type===52&&(t.mobile=r)}await this.closeTriggerAndSendEvent(H.EVENT_FORM_SUBMITTED,{form:t}),Me("Coupon applied on cart"),J0.updateIdentity(t)}async dispatchEvent(){let t=this.triggerContext.triggerData,e={clickAction:this.action,items:this.triggerContext.selectedEmbeddedItems??t.embeddedItems??t.items,collections:t.collections,triggerData:t};await new gc().process(e);let r={action:this.containsCTA()?H.CAMPAIGN_CLICKED_ACTIVITY:H.CAMPAIGN_CLOSED_ACTIVITY};document.dispatchEvent(new CustomEvent(H.POPUP_ACTIVITY_EVENT,{detail:r}))}},si=class{renderer=mc.get();parentHTMLEl;inappElement;inappHTMLEl;triggerContext;stylesConverter;scalingFactor;constructor(t,e,r){this.parentHTMLEl=t,this.inappElement=e,this.triggerContext=r,this.stylesConverter=new Gp(this.renderer.getScalingFactor())}getHTMLElement(){return this.inappHTMLEl}insertElement(){this.parentHTMLEl.appendChild(this.inappHTMLEl)}processCommonBlocks(){this.processWidthAndHeight(),this.processPositionBlock(),this.processTransformBlock(),this.processTransparency(),this.processShadow(),this.registerAction();let t=lt(x(x(x(x({},this.getDisplayStyles()),this.getSpaceStyles()),this.getBorderStyles()),this.getBackgroundStyles()),{boxSizing:"border-box",outline:"none"});es(this.inappHTMLEl,t)}getDisplayStyles(){return{display:"block"}}processWidthAndHeight(){this.inappElement.w&&X(this.inappHTMLEl,"width",this.stylesConverter.getSizePx(this.inappElement.w)),this.inappElement.h&&X(this.inappHTMLEl,"height",this.stylesConverter.getSizePx(this.inappElement.h))}processPositionBlock(){let t={position:"absolute",left:this.stylesConverter.getSizePx(this.inappElement.x),top:this.stylesConverter.getSizePx(this.inappElement.y)};es(this.inappHTMLEl,t)}getBorderStyles(){return this.stylesConverter.getBorderStyles(this.inappElement.br)}getSpaceStyles(){return this.stylesConverter.getSpaceStyles(this.inappElement.spc)}processTransparency(){let t=this.inappElement.alpha;if(!isNaN(t)){let e=(t/100).toFixed(2);X(this.inappHTMLEl,"opacity",e)}}processShadow(){let t=this.inappElement.shd;t?X(this.inappHTMLEl,"box-shadow",t.getStyle(this.scalingFactor)):X(this.inappHTMLEl,"box-shadow","unset")}processTransformBlock(){let t=new Vu(this.inappElement.trf);t&&t.rotate&&X(this.inappHTMLEl,"transform",`rotate(${t.rotate}deg)`)}registerAction(){let t=this.inappElement.clc;!t||Object.keys(t).length===0||(this.inappHTMLEl.addEventListener("click",e=>{e.stopPropagation(),new X0(t,this.triggerContext).execute()}),X(this.inappHTMLEl,"cursor","pointer"))}getBackgroundStyles(){return this.stylesConverter.getBackgroundStyles(this.inappElement.bg)}},Is=class extends si{constructor(t,e,r){super(t,e,r)}processCommonBlocks(){super.processCommonBlocks(),this.processFontBlock(),this.processAlignment()}processFontBlock(){let t={},e=this.inappElement.typography;return e&&(t.fontSize=this.stylesConverter.getSizePx(e.fs),t.fontFamily=H.COOEE+e.fam?.name,t.lineHeight=`${e.lh}`,t.letterSpacing=e.letterSpacing),this.stylesConverter.getColourStyles(this.inappElement.color,"color",t),es(this.inappHTMLEl,t),t}processPart(t,e){let r=[];e.u&&r.push("underline"),e.st&&r.push("line-through"),r.length||r.push("normal"),X(t,"font-weight",e.b?"bold":"normal"),X(t,"font-style",e.i?"italic":"normal"),X(t,"text-decoration",r.join(" ")),X(t,"color",e.c??"inherit"),X(t,"font-family","inherit")}processAlignment(){let t=this.inappElement.typography.ta,e=t?fa[t]?.toLowerCase():this.inappElement.typography.alignment;e||(e="start"),X(this.inappHTMLEl,"text-align",e)}},Q0=class extends Is{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.inappElement.parts?.forEach(t=>{let e=document.createElement("span");e.innerHTML=t.txt?.toString()?.replace(/\n/g,"<br />"),this.processPart(e,t),this.inappHTMLEl.appendChild(e)}),this.processCommonBlocks()}},Z0=class extends si{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.processCommonBlocks()}},id=class extends si{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("img"),this.insertElement()}render(){this.inappHTMLEl.setAttribute("src",this.inappElement.src),X(this.inappHTMLEl,"max-width","none"),X(this.inappHTMLEl,"max-height","none"),X(this.inappHTMLEl,"margin","0 auto"),this.processCommonBlocks()}},tE=class sd extends si{constructor(e,r,n){super(e,r,n),this.parent=e,this.inappHTMLEl=document.createElement("div")}static MAX_Z_INDEX="2147483647";render(){return this.parent||this.renderer.removeInApp(),this.insertElement(),this.processCommonBlocks(),this.inappHTMLEl.classList.add(H.IN_APP_WRAPPER_NAME),this.inappHTMLEl.classList.add(this.triggerContext.rootClassName),X(this.inappHTMLEl,"z-index",sd.MAX_Z_INDEX),this.inappHTMLEl}getBackgroundStyles(){return this.inappElement.cover?super.getBackgroundStyles():{}}processWidthAndHeight(){let e=this.inappElement.cont;if(this.inappElement.cover)this.renderer.isParentNotBody()?(X(this.inappHTMLEl,"width","100%"),X(this.inappHTMLEl,"height","100%")):(X(this.inappHTMLEl,"width","100vw"),X(this.inappHTMLEl,"height","100vh")),X(this.inappHTMLEl,"top","0"),X(this.inappHTMLEl,"left","0");else{let r=this.inappElement.spc,n=this.stylesConverter.getScaledSize(e.w)+r.getHorizontal(),i=this.stylesConverter.getScaledSize(e.h)+r.getVertical();X(this.inappHTMLEl,"width",n+"px"),X(this.inappHTMLEl,"height",i+"px")}}getSpaceStyles(){return{padding:this.inappElement.spc.getPaddingCSS()}}getDisplayStyles(){return x(x({display:"flex"},this.inappElement.getStylesForWrapper()),this.inappElement.getFlexStylesForContainer())}processPositionBlock(){if(this.renderer.isParentNotBody()){if(this.triggerContext.triggerData.ian?.isEmbedded()){X(this.inappHTMLEl,"position","block");return}X(this.inappHTMLEl,"position","absolute")}else X(this.inappHTMLEl,"position","fixed")}getBorderStyles(){return{}}processTransparency(){}processTransformBlock(){}processShadow(){}},eE=class extends si{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){return this.processCommonBlocks(),X(this.inappHTMLEl,"position","relative"),X(this.inappHTMLEl,"overflow","hidden"),this.inappHTMLEl.classList.add(H.IN_APP_CONTAINER_NAME),this}},rE=class Pe extends Is{static DAYS="Days";static HOURS="Hours";static MINUTES="Minutes";static SECONDS="Seconds";elements;spans=[];constructor(e,r,n){super(e,r,n),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.addTimerChildren(),this.processAndStartTimer(),this.processCommonBlocks();let e=lt(x(x(x({flex:"1 1 0"},this.stylesConverter.getBackgroundStyles(this.inappElement.bg)),this.stylesConverter.getBorderStyles(this.inappElement.br)),this.stylesConverter.getSpaceStyles(this.inappElement.spc)),{marginLeft:this.stylesConverter.getSizePx(this.inappElement.gap),marginRight:this.stylesConverter.getSizePx(this.inappElement.gap)});this.addStylesToTimer(e)}getBackgroundStyles(){return{}}processFontBlock(){let e=super.processFontBlock();return this.stylesConverter.getColourStyles(this.inappElement.color,"color",e),this.addStylesToTimer(e),e}getSpaceStyles(){return{}}getBorderStyles(){return{}}getDisplayStyles(){return{display:"flex",flexWrap:"nowrap",justifyContent:"center"}}addStylesToTimer(e){this.elements.forEach(r=>es(r,e))}addTimerChildren(){let e=this.inappElement.show;this.elements=[],e.day&&this.elements.push(this.getChild(Pe.DAYS)),e.hour&&this.elements.push(this.getChild(Pe.HOURS)),e.minute&&this.elements.push(this.getChild(Pe.MINUTES)),e.second&&this.elements.push(this.getChild(Pe.SECONDS)),this.elements.forEach(r=>this.inappHTMLEl.appendChild(r))}getChild(e){let r=document.createElement("div"),n=document.createElement("span"),i=document.createElement("span");return i.innerText=e,n.innerText="00",n.id=`lc-${e}`,X(i,"font-size","0.5em"),X(i,"text-align","center"),X(i,"font-family","inherit"),X(n,"text-align","center"),X(n,"font-family","inherit"),this.inappElement.lblPos==="start"?(r.appendChild(i),r.appendChild(n)):(r.appendChild(n),r.appendChild(i)),X(r,"display","flex"),X(r,"flex-direction",this.inappElement.horizontal?"":"column"),X(r,"justify-content","center"),X(r,"align-items","center"),X(r,"gap","5px"),this.spans.push(n),r}processAndStartTimer(){let e=this.inappElement.timer.start(this.inappElement.timerType,r=>{this.spans.forEach(n=>{n.id===`lc-${Pe.DAYS}`?n.innerText=String(r.days).padStart(2,"0"):n.id===`lc-${Pe.HOURS}`?n.innerText=String(r.hours).padStart(2,"0"):n.id===`lc-${Pe.MINUTES}`?n.innerText=String(r.minutes).padStart(2,"0"):n.id===`lc-${Pe.SECONDS}`&&(n.innerText=String(r.seconds).padStart(2,"0"))})});this.triggerContext.intervals.push(e)}},nE=class extends Is{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("select"),this.insertElement()}render(){X(this.inappHTMLEl,"background","#ffffff00"),X(this.inappHTMLEl,"outline","none"),this.processCommonBlocks(),this.addListener(this.inappHTMLEl),this.addOptions()}addListener(t){this.triggerContext.selectedEmbeddedItems?.length||this.updateItems(this.triggerContext.triggerData.items[0].vars[0]),t.addEventListener("click",e=>{e.stopPropagation()}),t.addEventListener("change",()=>{let e=new ps(JSON.parse(t.value));this.updateItems(e)})}updateItems(t){let e=this.triggerContext.triggerData.items[0];this.triggerContext.selectedEmbeddedItems=[e.toEmbed(t)];let r=this.parentHTMLEl.querySelector("#coo-13");if(!r)return;let n=t.imgs[0]??e.imgs?.at(0);n?.url&&r.setAttribute("src",n.url)}addOptions(){let t=this.triggerContext.triggerData.items,e=this.inappHTMLEl;if(!t?.length){e.add(this.createOption(this.inappElement.placeholderText));return}let r=this.triggerContext.selectedEmbeddedItems?.at(0);t[0].vars.forEach(n=>{e.add(this.createOption(n.name??"Default",n,n.mID===r?.vID))})}createOption(t,e,r){let n=document.createElement("option");return n.text=t,n.value=JSON.stringify(e),r&&(n.selected=!0),e||(n.disabled=!0),n}},od=class extends Is{borderColor="";constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("input"),this.insertElement()}render(){let t=this.setInputType();this.inappHTMLEl.setAttribute("placeholder",this.inappElement.placeholderText),X(this.inappHTMLEl,"background","#ffffff00"),X(this.inappHTMLEl,"outline","none"),this.inappHTMLEl.addEventListener("click",e=>{e.stopPropagation()}),this.processCommonBlocks(),this.addListener(this.inappHTMLEl,t),this.triggerContext.addInputField(t,this.inappElement.t)}},iE=class ad extends od{static EMAIL_REGEX=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;constructor(e,r,n){super(e,r,n)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.inappHTMLEl.setAttribute("type","email"),this.inappHTMLEl.setAttribute("id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(ad.EMAIL_REGEX)?(X(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(X(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},sE=class cd extends od{static MOBILE_REGEX=/^\d+$/;constructor(e,r,n){super(e,r,n)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.inappHTMLEl.setAttribute("type","tel"),this.inappHTMLEl.setAttribute("id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(cd.MOBILE_REGEX)?(X(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(X(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},oE=class extends id{constructor(t,e,r){super(t,e,r)}render(){super.render(),this.inappHTMLEl.setAttribute("id",`coo-${this.inappElement.type}`)}},mc=class Re{static DOCUMENT_STANDARD_MODE="CSS1Compat";static ACTIVE_TRIGGER_DATA;static _instance;safeHTTP;parent;rootContainer;containerHTMLElement;ian;scalingFactor=1;triggerContext;resizeListener;cartDrawerToggleSubscription;constructor(e){Re._instance=this,this.safeHTTP=Vt.getInstance(),this.resizeListener=()=>this.screenResized(),this.setParentContainer(e)}static get(){return Re._instance}render(e){this.renderEngagement(new sr(e))}getScalingFactor(){return this.scalingFactor}calculateScalingFactor(e){let r=e.max,n=e.cont.w,i=e.cont.h,s=e.spc,o=this.getWidth(),c=this.getHeight();r&&(o=o?Math.min(o,r):r,c=c?Math.min(c,r):r),c&&(o-=s.getHorizontal(),c-=s.getVertical(),o/c<n/i?this.scalingFactor=o/n:this.scalingFactor=c/i,this.scalingFactor=Math.min(this.scalingFactor,1))}setParentContainer(e){this.parent=e||document.body,this.parent&&this.isParentNotBody()&&X(this.parent,"position","relative")}isParentNotBody(){return this.parent!==document.body}getWidth(){return this.parent&&this.parent!==document.body?this.parent.clientWidth:document.compatMode===Re.DOCUMENT_STANDARD_MODE?document.documentElement.clientWidth:window.innerWidth}getHeight(){return this.isParentNotBody()?this.parent.clientHeight:document.compatMode===Re.DOCUMENT_STANDARD_MODE?document.documentElement.clientHeight:window.innerHeight}async renderEngagement(e){if(this.triggerContext=new ec(new Date,e),this.triggerContext.onClose(r=>{this.closeInApp(r)}),this.ian=e.ian,(_r()||e.previewType==="mobile")&&this.ian.overrideForMobileView(),this.ian.isEmbedded()){let r=document.querySelector(this.ian.getEmbeddedSelector());this.setParentContainer(r)}await this.preloadImages(e),e.shouldDelay()?window.setTimeout(()=>{this.withCartDrawerClosed()},e.getDelaySeconds()):this.withCartDrawerClosed()}withCartDrawerClosed(){if(!Ee.get().isOpen()||!_r()){this.startRenderingOnce();return}this.cartDrawerToggleSubscription=Ee.get().onToggle().subscribe(({open:e})=>{!e&&this.startRenderingOnce()})}startRenderingOnce(){if(!this.shouldSkipCampaign()){Re.ACTIVE_TRIGGER_DATA=this.triggerContext.triggerData;try{this.startRendering()}catch(e){zt.getInstance().captureError(e,"render-popup",{triggerContext:this.triggerContext});return}this.sendTriggerDisplayed(),_r()||window.addEventListener("resize",this.resizeListener),this.cartDrawerToggleSubscription?.unsubscribe()}}shouldSkipCampaign(){let e=this.triggerContext.triggerData;if(!e.previewType&&Re.ACTIVE_TRIGGER_DATA){let n={triggerShown:new Xa(Re.ACTIVE_TRIGGER_DATA??{})};return this.skipTrigger(e,n),!0}if(kt.get().isGoKwikPopupOpen)return this.skipTrigger(e,{reason:"GoKwik popup is open"}),!0;let r=H.PAYMENT_MODAL_DETAILS.find(n=>!!document.querySelector(n.identifier));return r?(this.skipTrigger(e,{reason:`${r.gateway} modal is open`}),!0):!1}startRendering(){this.calculateScalingFactor(this.ian),this.rootContainer=new tE(this.parent,this.ian,this.triggerContext).render();try{this.renderContainer(this.triggerContext)}catch(e){throw T.error(e),e}}sendTriggerDisplayed(){let e={};this.triggerContext.triggerData.items?.length&&(e.promotedMIDs=this.triggerContext.triggerData.items?.map(i=>i.mID));let r=new jt(H.EVENT_TRIGGER_DISPLAYED,e,this.triggerContext.triggerData);this.safeHTTP.sendEvent(r);let n={action:H.CAMPAIGN_DISPLAYED_ACTIVITY};document.dispatchEvent(new CustomEvent(H.POPUP_ACTIVITY_EVENT,{detail:n}))}sendTriggerClosed(e){let r=e.eventName;delete e.eventName;let n=new jt(r,e,this.triggerContext.triggerData);n.name===H.EVENT_TRIGGER_CLICKED&&(n.items=this.triggerContext.selectedEmbeddedItems??this.triggerContext.triggerData.items?.map(i=>i.toEmbed())),this.safeHTTP.sendEvent(n)}addEnterAnimation(e){this.containerHTMLElement.animate(e.getEnterAnimation(),{duration:500})}renderElement(e,r,n){r instanceof op?new iE(e,r,n).render():r instanceof ap?new sE(e,r,n).render():r instanceof Vo?new Q0(e,r,n).render():r instanceof cp?new oE(e,r,n).render():r instanceof Ha?new id(e,r,n).render():r instanceof rp?new Z0(e,r,n).render():r instanceof ip?new rE(e,r,n).render():r instanceof sp?new nE(e,r,n).render():T.error("Unsupported element type- "+r.type)}renderContainer(e){let r=this.ian?.cont;r&&(this.containerHTMLElement=new eE(this.rootContainer,r,e).render().getHTMLElement(),new Y0().loadAllFonts(this.ian),this.ian.elems?.forEach(async n=>{await this.renderElement(this.containerHTMLElement,n,e)}),this.addEnterAnimation(this.ian.anim))}closeInApp(e){let r=this.ian.anim.getExitAnimation();this.sendTriggerClosed(e),Re.ACTIVE_TRIGGER_DATA=void 0;let n=this.containerHTMLElement.animate(r,{duration:500,easing:"ease-in-out"});n.onfinish=()=>{this.removeInApp(),window.removeEventListener("resize",this.resizeListener)}}screenResized(){this.removeInApp(),this.startRendering()}removeInApp(){let e=document.querySelector(`.${this.triggerContext.rootClassName}`);e&&e.parentElement.removeChild(e)}skipTrigger(e,r){let n=new jt(H.EVENT_CAMPAIGN_REJECTED,r,e);this.safeHTTP.sendEvent(n)}async preloadImages(e){let r=e.ian;if(!r)return;let n=[];r.elems.forEach(i=>{let s=i.bg?.img?.src;if(s&&n.push(this.getPromise(s)),i.t===1){let o=i.src;if(!o)return;n.push(this.getPromise(o))}}),r.bg?.img?.src&&n.push(this.getPromise(r.bg.img.src)),r.cont.bg?.img?.src&&n.push(this.getPromise(r.cont.bg.img.src)),await Promise.all(n)}getPromise(e){return new Promise(r=>{let n=new Image;n.onload=r,n.src=e,n.style.display="none"})}},aE=class{triggerData;safeHttpService=Vt.getInstance();render(t){t.contentSource===ua.KLAVIYO&&(this.triggerData=t,window.addEventListener("klaviyoForms",this.handleKlaviyoEvents.bind(this)),window._klOnsite=window._klOnsite||[],window._klOnsite.push(["openForm",t.klaviyoFormID]))}handleKlaviyoEvents(t){if(t.type!=="klaviyoForms")return;let e=t.detail;if(e.formId!==this.triggerData.klaviyoFormID){T.warn("Received invalid trigger callback");return}switch(e.type){case"open":this.safeHttpService.sendEvent(new jt(H.EVENT_TRIGGER_DISPLAYED,{form:{id:e.formId}},this.triggerData));break;case"stepSubmit":{let r=this.getFormDetails(e);this.safeHttpService.sendEvent(new jt(H.EVENT_FORM_SUBMITTED,{form:r},this.triggerData)),this.safeHttpService.updateProfile(r);break}case"close":window.removeEventListener("klaviyoForms",this.handleKlaviyoEvents.bind(this)),this.safeHttpService.sendEvent(new jt(H.EVENT_TRIGGER_CLOSED,{form:{id:e.formId}},this.triggerData));break}}getFormDetails(t){let e={id:t.formId},r=t.metaData;if(Gn.hasKeys(r)){let n=["email","phone_number","first_name","last_name","$email","$phone_number","$first_name","$last_name"];Object.keys(r).forEach(o=>{n.includes(o)||(e[o]=r[o])}),e.email=r.$email??r.email,e.mobile=r.$phone_number??r.phone_number;let i=r.$first_name??r.first_name,s=r.$last_name??r.last_name;(i?.length||s?.length)&&(e.name=i+" "+s)}return e}},cE=class{static trackIntent(t){if(!this.isInstalled()){T.log("Facebook pixel not installed");return}if(!se.get().pixelPush){T.log("Facebook pixel push not enabled");return}let e=fs[t.intent]?.toLowerCase(),r=t.segmentName;!e&&!r||(T.debug(`Sending ${e} intent and ${r} segment to Facebook Pixel`),window.fbq("trackCustom","CooeeIntent",{intent_value:e,segment_value:t.segmentName}))}static isInstalled(){return window.fbq&&typeof window.fbq=="function"}},vc=class ld{static INSTANCE;httpService=ut.get(Pr);sentryService=ut.get(zt);sessionManager=ut.get(we);runtime=kt.get();constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new ld),this.INSTANCE}sendSilently(e){this.send(e).catch(r=>T.error(`Failed to send ${e.name}`,r))}async send(e){if(T.debug(`Sending event ${e.name}`),Ne.log(`Sending event ${e.name} with id ${e.id}`),this.shouldReject(e)){T.warn(`Rejecting event ${e.name}`);return}await Promise.all([this.addSessionContext(e),this.addShopifyContext(e)]),this.addShopifyAttributes(),e.name!==H.EVENT_APP_BACKGROUND&&this.runtime.setActive(),e.currentItem=this.runtime.getCurrentItem(),e.locale=this.runtime.locale,this.httpService.post("/v1/event/track",e).then(async r=>{T.log("\u2705 Event tracked:",e.name),Ne.log(`\u2705 Event <strong>${r.eventName}</strong> tracked`),this.processEventResponse(e,r)}).catch(r=>{T.error(`Error sending event ${e.name} to server`,r)})}shouldReject(e){return e.trigger?.triggerID==="test"||e.trigger?.triggerID==="preview"?(T.warn("Not sending event as this is a test trigger"),!0):!1}async addSessionContext(e){let r=await this.sessionManager.checkSessionAndGetContext();e.sessionID=r[0],e.sessionNumber=r[1],e.landingPage=r[2],e.page=Ss.parseFromCurrent()}async addShopifyContext(e){try{e.cart=await xt.getCurrent().getNormalisedCart()}catch(r){T.error("Error fetching Shopify cart before sending the event",r)}}processEventResponse(e,r){this.renderWidgetIfAny(e,r).catch(n=>{this.sentryService.captureError(n,"process-popup-response",{extra:{event:e,response:r}})}),this.utiliseIntentIfCalculated(r)}async renderWidgetIfAny(e,r){if(!r.triggerData){T.log(`Nothing to engage after ${e.name}`);return}T.log(`\u{1F4E3} Engagement(id=${r.triggerData.shortID}) will be shown`,r.triggerData),Ne.log(`\u{1F4E3} Campaign #${r.triggerData.shortID}) will be shown`);let n=new sr(r.triggerData);n.occurred=e.occurred;let i;try{i=await Wp.refreshItems(n)}catch(s){T.error("Failed to refresh the products",s);return}if(n.items=i,n.contentSource===ua.KLAVIYO){new aE().render(n);return}new mc().renderEngagement(n).catch(s=>{this.sentryService.captureError(s,"render-popup",{extra:{event:e},engagementTrigger:n})})}utiliseIntentIfCalculated(e){e.intent&&(Fp.trackIntent(e.intent),cE.trackIntent(e),Ne.log(`Intent is <strong>${fs[e.intent]}</strong>`))}addShopifyAttributes(){xt.getCurrent().addCooeeAttributes().catch(e=>{T.error("Fail to add attributes in cart",e)})}},Cs=class{constructor(t){this.triggerContext=t}safeHTTP=Vt.getInstance();eventAPIService=vc.getInstance();async execute(t){let e=kt.get().getCurrentItem(),r=t.clickAction;if(!r)return;let n=t.item,i=this.triggerContext,s=new gc,o=i.triggerData.redirectBehaviour,c=!!i.triggerData.discount?.type&&!!r?.applyDiscount,l={selectedVariants:i.triggerData.nonMutableItems.map(_=>({itemMID:_.mID,mID:_.selectedOrFirstVariant.value.mID,variantID:_.selectedOrFirstVariant.value.mID})),eID:i.triggerData.engagementID,cID:i.triggerData.contentID},p="",g=[],h=[];if(n?h=[n.toEmbed()]:t.embeddedItem&&(h=[t.embeddedItem]),r.at===108){let _=i.selectedItems;if(h=t.embeddedItems??_.map(k=>k.toEmbed()),i.shouldGiveFBTDiscount||t.embeddedItems?.length){let k;t.embeddedItems?k=t.embeddedItems.map(M=>({itemMID:M.mID,mID:M.vID,variantID:M.vID,quantity:M.quantity})):k=_.map(M=>({itemMID:M.mID,mID:M.selectedOrFirstVariant.value.mID,variantID:M.selectedOrFirstVariant.value.mID}));let A=i.triggerData.bundleFrom;i.triggerData.isBundleOnCartDrawer()&&A&&(k.push({itemMID:A.mID,mID:A.selectedOrFirstVariant.value.mID,isPrimary:!0}),h.unshift(A.toEmbed())),l.selectedVariants=k,i.triggerData.isBundleOnPDP()&&l.selectedVariants.forEach(M=>{M.mID===e.vID&&(M.isPrimary=!0)})}else l=void 0;g=t.embeddedItems??_}else if(r.at===107){let _=await xt.getCurrent().getNormalisedCart();h=_.items,l.selectedVariants=_.items.map(k=>({itemMID:k.mID,mID:k.vID}))}else if(r.at===102)g=n?[n]:[t.embeddedItem];else if(r.at===101)p=n?Wi()+"products/"+n.slug:t.embeddedItem?.link;else if(r.at===4){let _=Ah(r.gu?.u);_&&(p=_.href)}else if(r.at===109){let _=await s.upgradeToSubscription(n,i.triggerData);this.triggerContext.triggerData.skipSubscribedItems&&this.triggerContext.renderer.destroy(),Ee.get().refreshUI(_)}else if(r.at===104){let _=this.triggerContext.triggerData.collections?.[0];_&&(p="collections/"+_.handle)}if(this.sendTriggerClicked(h,{from:"button"},t.video),T.debug({redirectPath:p,redirectBehaviour:o,hasDiscount:c}),!c&&p){location.href=p;return}let w,y=!1;try{w=await this.getOrGenerateDiscountCode(l),T.debug("Discount code (if any) to apply",w)}catch(_){if(!this.triggerContext.triggerData.isBYOB()){v_.default.error("Unable to get a discount code",_);return}}if(w&&r.at===103)await s.copyDiscountCode(w);else if(r.at===110){let _=await s.createNewCart(e,w,i.triggerData);_&&(location.href=_);return}try{w&&await Mn.applyWithStorefront([w])}catch(_){T.error(_),y=!0}let b;if(g?.length&&(b=await s.addToCart(g,i.triggerData)),y&&w){Mn.navigate(w,o,p);return}if(p){location.href=p;return}Mn.navigateWithoutDiscount(o,b)}sendTriggerClicked(t,e,r){let n=new jt(H.EVENT_TRIGGER_CLICKED,e,this.triggerContext.triggerData);n.items=t,r?.id&&(n.videos=[r.id]),this.eventAPIService.sendSilently(n)}async getOrGenerateDiscountCode(t){let e=this.triggerContext.triggerData.discount;if(!e?.type)return;let r="";if(e.type===Ue.STATIC){if(!e.code)throw zt.getInstance().captureMessage("No discount code found","warning",{triggerContext:this.triggerContext}),new Error("No discount code found");return e.code}if(t){if(r=await this.generateDiscount(t),!r)throw T.error("No discount code found",t),new Error("Discount code not found or generated");return r}}async generateDiscount(t){try{return(await this.safeHTTP.generateDiscount(t))?.code}catch(e){throw Me("Failed to generate a discount code"),zt.getInstance().captureError(e,"backend-generate-discount",{extra:{discountData:JSON.stringify(t)},triggerContext:this.triggerContext}),e}}},lE=class{eventAPIService;modifications=[];constructor(){this.eventAPIService=ut.get(yc)}execute(t){for(let e of t)e.experimentConfig&&this.executeExperiment(e)&&this.trackExperimentRan(e);if(document.querySelector("#lc-hide-body")?.remove(),!document.body){ut.get(zt).captureMessage("No body element found","error");return}this.setupMutationObserver()}executeExperiment(t){let e=t.experimentConfig?.modifications;return e?.length?e.some(r=>{if(!r.cssSelector)return T.debug("No CSS Selector available",t?.toString()),!1;this.modifications.push(r);let n=Array.from(document.querySelectorAll(r.cssSelector));return n?.length?(this.executeSingleModification(r,n),!0):!1}):(T.log("Nothing to experiment",t.toString()),!1)}executeSingleModification(t,e){if(e?.length)for(let r of e)Object.assign(r.style,t.style),t.type==="TEXT"&&t.text?r.innerHTML=t.text:t.type==="IMAGE"&&this.updateImage(t,r)}trackExperimentRan(t){if(t.id==="preview"){T.warn("Skipping experiment attribution as its preview",t.toString());return}this.eventAPIService.trackExperiment({name:H.EVENT_EXPERIMENT_START,experiment:new Xa(t)}).catch(e=>{T.error("Fail to track experiment",e)})}setupMutationObserver(){new MutationObserver(t=>{t.forEach(e=>{e.addedNodes.forEach(r=>{r instanceof HTMLElement&&this.modifications.forEach(n=>{r.matches&&r.matches(n.cssSelector)?(T.debug("Re-applying experiment",n.toString()),this.executeSingleModification(n,[r])):r.querySelectorAll&&(T.debug("Re-applying experiment",n.toString()),this.executeSingleModification(n,Array.from(r.querySelectorAll(n.cssSelector))))})})})}).observe(document.body,{childList:!0,subtree:!0})}updateImage(t,e){let r=t.image?.lg?.src,n=t.image?.sm?.src;!r&&!n||(e instanceof HTMLPictureElement?this.updatePictureElement({desktop:r,mobile:n},e):this.updateImageElement({desktop:r,mobile:n},e))}updateImageElement(t,e){_r()&&t.mobile?(e.setAttribute("src",t.mobile),e.removeAttribute("srcset")):t.desktop&&(e.setAttribute("src",t.desktop),e.removeAttribute("srcset"))}updatePictureElement(t,e){if(e.innerHTML="",t.mobile){let n=document.createElement("source");n.srcset=t.mobile,n.media="(max-width: 767px)",e.append(n)}if(t.desktop){let n=document.createElement("source");n.srcset=t.desktop,n.media="(min-width: 768px)",e.append(n)}let r=document.createElement("img");r.src=t.desktop??t.mobile??"",e.append(r)}},yc=class ud extends td{static INSTANCE;constructor(){super()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new ud),this.INSTANCE}loadExperimentSilently(){Mt.get(ct.SDK_TOKEN).then(e=>{e?this.loadExperiments().catch(r=>T.error("Unable to initiate experiment",r)):we.replaySubject.subscribe(async()=>{this.loadExperiments().catch(r=>T.error("Unable to initiate experiment",r))})})}async loadExperiments(){if(!this.runtimeData.activeExperiment)return;let e=await this.getWidgetProps();T.log("Load experiments",e),this.httpService.post("/v1/engagement/experiments",e).then(async r=>{let n=r.experiments.map(i=>new sr(i));new lE().execute(n)}).catch(r=>{T.error("Error sending experiment getter",r)})}async trackExperiment(e){await this.addSessionContext(e),await this.httpService.post("/v1/event/experiment",e)}},uE=class{runtimeData=kt.get();widgetAPIService=ut.get(Wn);experimentAPIService=ut.get(yc);meddle(){let t=Tt.globalRef;t.account=t.account??[],t.profile=t.profile??[],t.events=t.events??[],t.page=t.page??[],this.meddlePage(),this.meddleAccount(),this.meddleEvents(),this.meddleProfile(),this.exposeMethods()}exposeMethods(){let t=Tt.globalRef;t.loadPageWidgets=()=>{this.widgetAPIService.loadPageWidgetsSilently()},t.loadCartWidgets=()=>{this.widgetAPIService.loadCartWidgetsSilently()},t.loadExperiments=()=>{this.experimentAPIService.loadExperimentSilently()},t.testCartUpdate=this.testCartUpdate.bind(this),t.previewWidget=Tt.previewWidget.bind(Tt),t.previewPopup=Tt.previewPopup.bind(Tt)}overwritePush(t,e){On(t,"push",e)}meddleAccount(){this.overwritePush(Tt.globalRef.account,(...t)=>{this.processAccount(t[0])}),Tt.globalRef.account.forEach(this.processAccount.bind(this))}meddleEvents(){this.overwritePush(Tt.globalRef.events,(...t)=>{this.processEvent(t[0])}),Tt.globalRef.events.forEach(this.processEvent.bind(this))}meddleProfile(){this.overwritePush(Tt.globalRef.profile,(...t)=>{this.processProfile(t[0])}),Tt.globalRef.profile.forEach(this.processProfile.bind(this))}processAccount(t){t&&(t.appID&&Tt.authenticate(t),t.flags&&ia.setFlags(t.flags))}processEvent(t){t&&(H.JS_LOAD_WHITELIST_EVENTS.includes(t[0])?Tt.sendEvent(t[0],t[1],x({occurred:this.runtimeData.jsLoadTime},t[2])):Tt.sendEvent(t[0],t[1],t[2]))}processProfile(t){t&&Tt.updateProfile(t)}processPageName(t){t&&Tt.setPageName(t)}meddlePage(){this.overwritePush(Tt.globalRef.page,(...t)=>{this.processPage(t[0])}),Tt.globalRef.page.forEach(this.processPage.bind(this))}processPage(t){t.currentItem&&this.runtimeData.setCurrentItem(t.currentItem),t.currency&&(this.runtimeData.currencyCode=t.currency),t.shopCurrency&&(this.runtimeData.shopCurrencyCode=t.shopCurrency),t.moneyFormat&&(this.runtimeData.moneyFormat=t.moneyFormat),t.jsLoad&&(this.runtimeData.jsLoadTime=t.jsLoad),t.locale&&(this.runtimeData.locale=t.locale),t.pageName&&Tt.setPageName(t.pageName),t.activeExperiment&&(this.runtimeData.activeExperiment=t.activeExperiment)}async testCartUpdate(){if(this.runtimeData.pageName!=="product"){window.alert("This feature is only available on a product page");return}let t=window.ShopifyAnalytics?.meta??{},e=t.selectedVariantId;if(e||(t.product?.variants?.length>0&&(e=t.product.variants[0].id),e||(e=this.runtimeData.getCurrentItem()?.vID)),!e){window.alert("Could not find a variant to test. Please try a different product page");return}let r=new sr({id:"preview",shortID:"1",redirectBehaviour:Te.CART_DRAWER});await new Cs(new ec(new Date,r)).execute({clickAction:{at:102},embeddedItem:new Ar({vID:e})})}},vo=class{static SESSION_STORAGE=window.sessionStorage;static SESSION_STORAGE_KEY_PREFIX=H.COOEE.concat("-");static getString(t,e){return this.getItem(t)||e}static setString(t,e){this.setItem(t,e)}static remove(t){this.removeItem(t)}static getItem(t){return this.SESSION_STORAGE.getItem(this.SESSION_STORAGE_KEY_PREFIX.concat(t))}static setItem(t,e){this.SESSION_STORAGE.setItem(this.SESSION_STORAGE_KEY_PREFIX.concat(t),e)}static removeItem(t){this.SESSION_STORAGE.removeItem(this.SESSION_STORAGE_KEY_PREFIX.concat(t))}},yo=class Pi{static INSTANCE;static DEBOUNCE_TIME=1e3;static THRESHOLD=10;safeHttpService=ut.get(Vt);lastPercent=0;_lastScreenOrScroll=new Date;constructor(){}set lastScreenOrScroll(e){this._lastScreenOrScroll=e}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Pi),this.INSTANCE}resetScrollID(e){vo.remove(H.SESSION_STORAGE_SCROLL_ID),this.lastScreenOrScroll=e??new Date}listen(){if(window.scrollY){let e=this.getPercentScrolledY();this.shouldSendScroll(e)&&this.sendScroll(e)}Na(()=>{this.observeWindowScroll()})}observeWindowScroll(){ts(window,"scroll").pipe(ni(Pi.DEBOUNCE_TIME),cc(()=>{let e=this.getPercentScrolledY();if(e>100){T.warn("Received scroll percent is more than 100",e);return}if(this.shouldSendScroll(e))return e})).subscribe(e=>{this.sendScroll(e)})}shouldSendScroll(e){return Math.abs(this.lastPercent-e)>=Pi.THRESHOLD||this.lastPercent!==e&&e===100}sendScroll(e){if(e==null)return;let r={percent:e,timeMS:new Date().getTime()-this._lastScreenOrScroll.getTime()};this.lastPercent=e;let n=vo.getString(H.SESSION_STORAGE_SCROLL_ID,""),i=new jt(H.EVENT_SCROLL,r,null,n);this.safeHttpService.sendEvent(i),vo.setString(H.SESSION_STORAGE_SCROLL_ID,i.id.toHexString()),this._lastScreenOrScroll=new Date(i.occurred)}getPercentScrolledY(){let e=window.document.body.scrollHeight,r=window.innerHeight;return Math.ceil((window.scrollY+r)/e*100)}},hE=class hd{static ACTIVE_DURATION="aDur";static INACTIVE_DURATION="iaDur";apiService=ut.get(Vt);runtimeData=kt.get();listen(){document.onvisibilitychange=()=>{document.visibilityState==="visible"?this.onVisible():document.visibilityState==="hidden"&&this.onHidden()}}async onVisible(){}async onHidden(){let e=await this.runtimeData.setInactive();if(e===0){T.info("Not sending background event as user was inactive on website");return}T.info(`Sending background event with ${e} seconds`);let r={};r[hd.ACTIVE_DURATION]=e,this.apiService.sendEvent(new jt(H.EVENT_APP_BACKGROUND,r))}},pE=class{compareCartItemSubject=new or;constructor(){this.compareCartItemSubject.pipe(ni(100)).subscribe(this.compareCartItems.bind(this))}listen(){this.compareCartItemSubject.next(),this.overwriteXMLHttpRequest(),this.overwriteFetchMethod()}overwriteXMLHttpRequest(){let t=this,e=window.XMLHttpRequest.prototype.send;window.XMLHttpRequest.prototype.send=function(){return this.addEventListener("load",function(){t.performEvent(this._url).catch(r=>T.error("Unable to process cart change in XMLHttpRequest",r))}),e.apply(this,arguments)},T.debug("Securely overwritten window.XMLHttpRequest.send method")}overwriteFetchMethod(){let t=this,e=window.fetch;window.fetch=function(r){return e.apply(window,arguments).then(n=>(t.performEvent(r.toString()).catch(i=>T.error("Unable to process cart change in fetch",i)),n))},T.debug("Securely overwritten window.fetch method")}async performEvent(t){this.isCartManipulationURL(t)&&(kt.get().isCartDirty=!0,this.compareCartItemSubject.next())}isCartManipulationURL(t){return/\/cart\/(add|change|update|clear)/.test(t)}sendChangesAsEvents(t,e){let r=t?.items,n=e.items,i=[],s=[];if(T.debug(`Comparing cart change with old count ${r?.length} to new count ${n.length}`),n?.forEach(o=>{let c=r?.find(l=>l.vID===o.vID);if(c){if(c.quantity!==o.quantity){let l=c.quantity<o.quantity,p=Math.abs(c.quantity-o.quantity),g=lt(x({},o),{quantity:p});l?i.push(g):s.push(g)}r&&tb(r,c)}else i.push(o)}),r)for(let o of r)s.push(o);T.debug(`Cart delta: added: ${i.length}, removed: ${s.length}`),i.length&&this.sendEvent(H.EVENT_ADD_TO_CART,{items:i}),s.length&&t.token===e.token&&this.sendEvent(H.EVENT_REMOVE_FROM_CART,{items:s}),(s.length||i.length)&&hc.get().broadcast(H.CART_UPDATE_BROADCAST,{itemsAdded:i,itemsRemoved:s})}sendEvent(t,e){let r=new jt(t,e);ut.get(Vt).sendEvent(r)}async compareCartItems(){let t=await Mt.get(ct.CURRENT_CART,{}),e=await xt.getCurrent().getNormalisedCart(!0);this.sendChangesAsEvents(t,e)}},dE=class{listen(){return this.overwriteFetchMethod(),this}overwriteFetchMethod(){let t=this,e=window.fetch;window.fetch=async function(r,n){try{await t.modifyRequest(r,n)}catch(i){zt.getInstance().captureError(i,"modify-graphql-request",{extra:{body:JSON.stringify(n?.body)}})}return e(r,n)},T.debug("Securely overwritten window.fetch method for graphql query")}async modifyRequest(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&&(T.debug("Intercepted fetch request of:",r),n?.query.includes("cartCreate")&&(e.body=await this.updatedBody(n),this.sendBuyNowEvent()))}async updatedBody(t){let e=t.variables.input.attributes??[],r=await kh();return t.variables.input.attributes=[...e,...r],JSON.stringify(t)}sendBuyNowEvent(){let t=kt.get().getCurrentItem();if(!t)return;let e=new jt(H.EVENT_BUY_NOW_CLICKED,{items:[t]});Vt.getInstance().sendEvent(e)}},pd=class{constructor(t,e){this.selectors=t,this.eventName=e,this.selectorString=t.join(",")}static INSTANCE;elements;selectorString;clickListenerCallback=t=>{let e=t.currentTarget,r=new jt(this.eventName,{class:e.className||void 0,tagName:e.tagName||void 0,id:e.id||void 0});Vt.getInstance().sendEvent(r),this.removeClickListener(this.clickListenerCallback)};listenSilently(){this.listen().catch(t=>T.error(t))}async listen(){this.elements=await Nh(this.selectorString),this.elements.forEach(t=>{t.addEventListener("click",this.clickListenerCallback)})}removeClickListener(t){this.elements?.forEach(e=>{e.removeEventListener("click",t)})}},fE=class oa extends pd{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(oa.selectors,H.EVENT_ITEM_THUMBNAIL_CLICKED)}static getInstance(){return this.INSTANCE||(this.INSTANCE=new oa),this.INSTANCE}},gE=class aa extends pd{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(aa.selectors,H.EVENT_REVIEW_CLICKED)}static getInstance(){return this.INSTANCE||(this.INSTANCE=new aa),this.INSTANCE}},mE=class{selector=[".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(",");listen(){Na(()=>{T.debug("Execution order:","document ready"),this.useLocationHash()})}useLocationHash(){let t=window.location.hash?.substring(1);if(t)if(t.includes(H.HASH_INITIATE_CHECKOUT)){document.dispatchEvent(new Event(H.THIRD_PARTY_CHECKOUT_EVENT));let e=document.querySelector(this.selector);if(!e){T.debug("No clickable cart checkout button found");return}T.debug("Clickable cart checkout button found",e),e.click()}else t.includes(H.HASH_OPEN_CART_DRAWER)&&Ee.get().open()}},ku=class{static attachCheckoutListener(){window.gokwikSdk&&window.gokwikSdk.on("checkout_initiated",async()=>{let t=await xt.getCurrent().getNormalisedCart(),e={via:"GoKwik",items:t.items,cartToken:t.token,amount:{value:t.amount,currency:t.currency}},r=new jt(H.EVENT_CHECKOUT_STARTED,e);Vt.getInstance().sendEvent(r)})}},vE=class{async migrate(){}},Tt=class{static globalRef;static authenticated;static async initForMerchantWebsiteOnly(){window.cooeeSDKPreview||(this.initGlobalReference(),await new vE().migrate(),this.autoAuthenticate(),new uE().meddle(),ut.get(yc).loadExperimentSilently(),new hE().listen(),new pE().listen(),new dE().listen(),new mE().listen(),ut.get(yo).listen(),ut.get(gE).listenSilently(),ut.get(fE).listenSilently(),ut.get(Wn).loadPageWidgetsSilently(),this.attachGoKwikListeners(),this.storePreviewParams(),this.setupPreviewListeners(),Ne.watch())}static async initForAll(){this.injectWidgetAssets()}static initGlobalReference(){window.CooeeSDK||On(window,"CooeeSDK",{}),this.globalRef=window.CooeeSDK,On(this.globalRef,"config",new se),On(this.globalRef,"runtimeData",new kt),On(this.globalRef,"uaParser",new Ke),T.debug("Global reference initialised")}static injectWidgetAssets(){be.injectScriptURL(Ge.widgetURL,"cooee-widget-sdk"),be.injectStylesheet(Ge.styleURL)}static autoAuthenticate(){let t=qb();t&&this.authenticate({shopifyShop:t})}static authenticate(t){if(this.authenticated)return;let e=t.appID?.trim(),r=t.shopifyShop;if((xl(e)||e.length!==24)&&xl(r)){T.warn("Cooee App ID or Shop name is not configured");return}this.authenticated=!0,ut.get(we).init(t)}static sendEvent(t,e,r){let n=new jt(t,e,r?.triggerData);r?.occurred&&(n.occurred=r.occurred),ut.get(Vt).sendEvent(n)}static updateProfile(t){for(let e in t)if(e.toLowerCase().startsWith("ce "))throw new Error("User property name cannot start with 'CE '");ut.get(Vt).updateProfile(t)}static setPageName(t){if(!t)return;let e=kt.get(),r=e.pageName;if(t===r)return;if(e.pageName=t,t==="cart"&&ut.get(Wn).loadOrRenderWidgetsAfterCartChange(),H.BLACKLISTED_PAGE_NAMES.some(s=>t.includes(s))){ut.get(yo).resetScrollID();return}let n={};r&&(n.ps=r);let i=new jt(H.EVENT_SCREEN_VIEW,n);i.occurred=e.jsLoadTime,ut.get(Vt).sendEvent(i),ut.get(yo).resetScrollID(i.occurred)}static previewPopup(t,e){new mc(e).render(t)}static previewWidget(t){new We(new sr(t)).render()}static setupPreviewListeners(){if(window.opener){try{window.opener.postMessage({action:"COOEE_READY_FOR_PREVIEW"},"*")}catch(t){T.error(t)}window.addEventListener("message",t=>{if(T.debug("Received event",t),!t.origin.includes("letscooee.com")&&!t.origin.includes("localhost"))return;let e=t.data;typeof e=="object"&&(e.action==="POPUP_PREVIEW"?(this.previewPopup(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)):e.action==="WIDGET_PREVIEW"&&(this.previewWidget(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)))})}}static attachGoKwikListeners(){let t=kt.get();window.addEventListener("kp-modal:opened",()=>{t.isGoKwikPopupOpen=!0}),window.addEventListener("user-loggedin",e=>{let{token:r}=e.detail;r&&this.updateProfile({goKwikToken:r})}),window.gokwikSdk?ku.attachCheckoutListener():window.addEventListener("gokwikLoaded",ku.attachCheckoutListener)}static storePreviewParams(){let t=kt.get(),e=new URLSearchParams(location.search),r=e.get("cooee-preview");r&&(t.previewIDs=r.trim().split(",").filter(i=>Number.isInteger(+i)));let n=e.get("cooee-variant");n&&(t.previewVariant=n)}};gf();mf();T.debug("Execution order:","top");window.cooeeShopifyScriptLoaded||(window.cooeeShopifyScriptLoaded=!0,(async()=>(T.debug("Execution order:","IIFE start"),await Tt.initForMerchantWebsiteOnly(),await Tt.initForAll(),T.debug("Execution order:","IIFE end")))());T.debug("Execution order:","bottom");})();
69
+ `,gc=class{sentryService=ut.get(zt);async addToCart(t,e){if(!t.length)return;let r=t.map(c=>{let{vID:l,quantity:p}=this.getVIDAndQuantity(c);return{id:l?+l:+c.mID,quantity:p,properties:e.getPrivateAttributesForLineItem()}}),n=Ln("cart/add.js"),i={items:r},s=Ee.get();s.isMiniCart()?i.sections=["mini-cart"]:s.isShopifyDefaultDrawer()&&(i.sections=s.element.getSectionsToRender?.().map(c=>c.section??c.id));let o=JSON.stringify(i);try{let c=await fetch(n,{body:o,method:"post",headers:{"Content-Type":"application/json"}});if(c&&!c.ok&&(await this.sentryService.captureFetchFailure(c,"cart-item-add"),c.status>400&&c.status<500)){let l=await c.json();Me(l.description||"Failed to add product in cart. Please try again")}if(c.status===200||c.status===302)return T.log(`Added ${t.length} items to Cart`),Me("Product added to your cart"),c.json()}catch(c){Me("Failed to add product in cart. Please try again"),this.sentryService.captureError(c,"cart-item-add",{extra:{body:o},engagementTrigger:e})}}async updateLineItem(t,e){if(!Gn.hasKeys(e)){T.warn("No update fields provided");return}let r=Ln("cart/change.js"),n=x({id:t.key},e),i=JSON.stringify(n);try{let s=await fetch(r,{body:i,method:"post",headers:{"Content-Type":"application/json"}});if(s&&!s.ok&&await this.sentryService.captureFetchFailure(s,"cart-item-update"),s.status===200||s.status===302){let o=await s.json();T.log(`Updated ${t}`),xt.getCurrent().update(o)}}catch(s){Me("Failed to update item in cart"),this.sentryService.captureError(s,"cart-item-update",{extra:{body:i}})}}async copyDiscountCode(t){if(t)try{await navigator.clipboard.writeText(t),T.log(`Code-${t} copied`),Me("Discount code copied")}catch(e){T.error("Failed to copy code",e)}}getProductURL(t){if(!t?.link)return;let e=Wb(t.link);if(e)return Wi()+"products/"+e}async upgradeToSubscription(t,e){if(!t){T.warn("Trying to upgrade to subscription with no item");return}let r=await xt.getCurrent().getNormalisedCart(),n=t.selectedOrFirstVariant.value,i=r.items.findIndex(p=>p.vID===n.mID),s=n.selectedSellingPlan.value,o=Ln("cart/change.js"),c={line:i+1,selling_plan:s?.mID||null,properties:e.getPrivateAttributesForLineItem()},l=JSON.stringify(c);try{let p=await fetch(o,{body:l,method:"post",headers:{"Content-Type":"application/json"}});if(p&&!p.ok&&await this.sentryService.captureFetchFailure(p,"cart-switch-subscription"),p.status===200||p.status===302){T.log(`Upgraded ${t} selling plan`),Me("Line item updated");let g=await p.json();return xt.getCurrent().update(g),g}}catch(p){Me("Failed to update subscription"),this.sentryService.captureError(p,"cart-switch-subscription",{extra:{body:l},engagementTrigger:e})}}async createNewCart(t,e,r){let n=se.get().storefrontToken;if(!n)throw new Error("Storefront token not set for the store");if(!t?.vID){T.error("No variant ID found to perform Buy now",t);return}let i=e?[e]:[],s=[{merchandiseId:`gid://shopify/ProductVariant/${t.vID}`,quantity:1,attributes:r.getKVFormatPrivateAttributesForLineItem()}],o=await kh(),c=new Headers;c.append("Content-Type","application/json"),c.append("X-Shopify-Storefront-Access-Token",n);let l=JSON.stringify({query:V0,variables:{input:{lines:s,discountCodes:i,attributes:o}}});return(await Pr.getInstance().request(H.GRAPHQL_API_PATH,{method:"POST",headers:c,body:l})).data?.cartCreate?.cart?.checkoutUrl}async process(t){let e=t.clickAction,r=t.items,n=t.triggerData,i;if(e.at){let s=e;if(T.log(`Performing ${JSON.stringify(s)} action`),s.at===101)i=this.getProductURL(r[0]);else if(s.at===102)r?.length&&await this.addToCart(r,n);else if(s.at===103)await this.copyDiscountCode(n.discount?.code);else if(s.at===105)Ee.get().open();else if(s.at===104){let o=t.collections;if(!o?.length)return;i=Wi()+"collections/"+o[0].handle}}e.applyDiscount&&n.discount?.code?Mn.navigate(n.discount.code,n.redirectBehaviour,i):i&&(location.pathname=i)}getVIDAndQuantity(t){let e,r;if(t instanceof Ar)e=t.vID,r=t.quantity??1;else{if(!t.vars?.length)return{};e=t.selectedOrFirstVariant.value.mID,r=1}return{vID:e,quantity:r}}},q0=class extends Er{ctaExecutor=new gc;constructor(t){super(t)}update(t){super.update(t),this.engagementTrigger.progressBarConfig.update(t.progressBarConfig),this.checkMilestoneSilently(),this.widgetElement.update()}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-progressbar"),this.checkMilestoneSilently()}checkMilestoneSilently(){this.checkMilestone().catch(t=>{zt.getInstance().captureError(t,"apply-milestones",{engagementTrigger:this.engagementTrigger})})}async checkMilestone(){let t=await xt.getCurrent().getNormalisedCart(),e=this.engagementTrigger.progressBarConfig,r,n=[],i=[],s=[],o,c,l=[...e.milestones];for(let g of l){if(g.rewardType!==ju.FREE_AUTO_GIFT)continue;let h=g.items[0],w=g.reached,y=t.items.find(b=>(b.vID===h.vID||b.mID===h.mID)&&b.properties[H.CAMPAIGN_ATTRIBUTE]===this.engagementTrigger.shortID);w&&(o=g,c=y),y&&n.push(y),!w&&y&&e.removeIneligibleItem?(T.debug(`Removing free gift ${y.vID} from cart`),s.push(y)):w&&!y&&(T.debug(`Adding free gift ${h.vID} to cart`),i.push(h))}e.restrictToLatestFreebie&&o&&(c?(n=n.filter(g=>g.vID!==c.vID),i=[]):i=[o.items[0]],s.push(...n)),s.length&&await this.removeFreeGifts(s),i.length&&(r=await this.ctaExecutor.addToCart(i,this.engagementTrigger));let p=e.coupons;if(p?.length)try{await Mn.applyWithStorefront(p.map(g=>g.couponCode)),Ee.get().refreshUI(r,!1)}catch(g){this.sentryService.captureError(g,"cart-apply-discount",{extra:{coupons:p},engagementTrigger:this.engagementTrigger})}}async removeFreeGifts(t){await Promise.all(t.map(e=>this.ctaExecutor.updateLineItem(e,{quantity:0})))}},Nu=class extends Er{constructor(t){super(t)}update(t){super.update(t),this.engagementTrigger.content.update(t.content),this.widgetElement.update()}addToRendered(){this.engagementTrigger.isPageEmbed()?We.renderedEngagements.push(this):Er.renderedEngagements.push(this)}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-savings-bar")}},W0=class extends We{constructor(t){super(t)}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-shoppable-videos")}},G0=class extends We{constructor(t){super(t)}shouldStopRendering(){return!1}renderContainer(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-sticky-atc")}},z0=class extends We{constructor(t){super(t)}shouldStopRendering(){return!1}renderContainer(){let t=this.getParentElement(`inner-letscooee-${this.engagementTrigger.shortID}`);this.rootContainer.appendChild(t),document.addEventListener(H.ADD_BUNDLE_CTA_INBOUND_EVENT,this.inboundCTAListener.bind(this),!1)}async inboundCTAListener(t){let e=this.engagementTrigger,r=`Engagement(id: ${e.engagementID}, shortID: ${e.shortID})`,n=t.detail;if(!Gn.hasKeys(n)){T.error(`No detail received for ${r}`);return}T.log("Detail received for BYOB",n);let i=n.campaignID??n.campaignId??n.campaign_id;if(i!==e.shortID&&i!==e.engagementID){T.warn(`Current ${r} is not BYOB. Received: ${i}`);return}let s=n.items;if(!s?.length)return;let o=s.map(c=>new Ar({mID:c.product_id,vID:c.variant_id,quantity:c.quantity||1}));await new Cs(this.triggerContext).execute({embeddedItems:o,clickAction:{at:108,applyDiscount:!0}})}},mo=class{runtimeData=kt.get();processCartWidgetResponse(t){this.runtimeData.isCartDirty=!1,this.runtimeData.cartEngagements=t;let e=[...Er.renderedEngagements];Er.renderedEngagements.length=0;for(let r of t)T.log(`\u{1F4E3} ${r} received as cart embed`),!this.findAndUpdateCurrent(r,e)&&(T.log(`${r} is new`),r.isProgressBar()?new q0(r).renderSilently():r.isSubscriptionUpsell()?F0.renderCartUpsell(r):r.isSavingsBar()?new Nu(r).renderSilently():new Er(r).renderSilently());this.removeOldWidgets(e)}processPageWidgetResponse(t){let e=[...We.renderedEngagements];We.renderedEngagements.length=0;for(let r of t)T.log(`\u{1F4E3} ${r} received as page embed`),!this.findAndUpdateCurrent(r,e)&&(T.log(`${r} is new`),r.isShoppableVideo()?new W0(r).renderSilently():r.isBYOB()?new z0(r).renderSilently():r.isStickyATC()?new G0(r).renderSilently():r.isSavingsBar()?new Nu(r).renderSilently():new We(r).renderSilently());this.removeOldWidgets(e)}findAndUpdateCurrent(t,e){let r=e.findIndex(n=>n.isSameTrigger(t));return r<0||t.isSubscriptionUpsell()?!1:(e[r].update(t),e[r].renderSilently(),e.splice(r,1),!0)}removeOldWidgets(t){for(let e of t)e.destroy()}},td=class{runtimeData=kt.get();httpService=ut.get(Pr);sessionManager=ut.get(we);constructor(){}async getWidgetProps(){let t={};t.engagementIDs=this.addAvailableEngagementShortIDs(),t.locale=this.runtimeData.locale,await this.addSessionContext(t),t.currentItem=this.runtimeData.getCurrentItem();try{t.cart=await xt.getCurrent().getNormalisedCart()}catch(i){T.error("Error fetching Shopify cart before sending widget call",i)}let e=new URLSearchParams(location.search),r=e.get("cooee-preview");r?t.previewIDs=r.trim().split(",").filter(i=>Number.isInteger(+i)):this.runtimeData.previewIDs?.length&&(t.previewIDs=this.runtimeData.previewIDs);let n=e.get("cooee-variant");return n?t.previewVariant=n:this.runtimeData.previewVariant&&(t.previewVariant=this.runtimeData.previewVariant),t}async addSessionContext(t){let e=await this.sessionManager.checkSessionAndGetContext();t.sessionID=e[0],t.sessionNumber=e[1],t.landingPage=e[2],t.page=Ss.parseFromCurrent()}addAvailableEngagementShortIDs(){let t=document.querySelectorAll(".letscooee-engagement"),e=[];return t.forEach(r=>{let n=r.dataset.engagementId;n&&+n&&e.push(n)}),e}},Wn=class ed extends td{static INSTANCE;loadWidgetsSubject=new or;constructor(){super(),this.loadWidgetsSubject.pipe(ni(300)).subscribe(()=>{this.loadCartWidgets().catch(e=>T.error("Unable to initiate cart widgets",e)),this.loadPageWidgets().catch(e=>T.error("Unable to initiate page widgets",e))}),hc.get().subscriber(H.CART_UPDATE_BROADCAST).subscribe(()=>this.loadWidgetsSubject.next())}static getInstance(){return this.INSTANCE||(this.INSTANCE=new ed),this.INSTANCE}loadOrRenderWidgetsAfterCartChange(){this.runtimeData.isCartDirty?this.loadWidgetsSilently():this.renderCachedCartWidgets()}loadPageWidgetsSilently(){we.replaySubject.subscribe(async()=>{this.loadPageWidgets().catch(e=>T.error("Unable to initiate load page widgets",e))})}loadCartWidgetsSilently(){we.replaySubject.subscribe(async()=>{this.loadCartWidgets().catch(e=>T.error("Unable to initiate cart widgets",e))})}loadWidgetsSilently(){we.replaySubject.subscribe(async()=>{this.loadWidgetsSubject.next()})}async loadPageWidgets(){let e=await this.getWidgetProps();T.log("Load widgets",e),this.httpService.post("/v1/engagement/page-widgets",e).then(async r=>{let n=r.widgets.map(i=>new sr(i));new mo().processPageWidgetResponse(n)}).catch(r=>{T.error("Error sending widget getter",r)})}async loadCartWidgets(){let e=await this.getWidgetProps();T.log("Load cart widgets",e),this.httpService.post("/v1/engagement/cart-widgets",e).then(async r=>{let n=r.widgets.map(i=>new sr(i));new mo().processCartWidgetResponse(n)}).catch(r=>{T.error("Error sending widget getter",r)})}async getVariation(e){let r=await this.getWidgetProps();return this.httpService.post("/v1/engagement/get-variant",x(x({},e),r))}renderCachedCartWidgets(){new mo().processCartWidgetResponse(this.runtimeData.cartEngagements)}},K0=class rd{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new rd),this.INSTANCE}init(){Ou.get(ct.APP_CONFIG,{}).then(e=>this.updateGlobalConfig(e))}async processAppConfigurations(e){T.log("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);Ou.set(ct.APP_CONFIG,r).catch(n=>T.error(n)),D0.processConfiguration(),r.website&&(be.injectRawScript(r.website.commonJS),be.injectRawCSS(r.website.commonCSS)),Ee.get().onToggle().subscribe(async({open:n})=>{T.info("Cart drawer is now",n?"open":"closed"),n&&(ut.get(Wn).loadOrRenderWidgetsAfterCartChange(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=Tt.globalRef.config.update(e);return Ee.forceUpdate(),T.debug("App configurations",r),r}async trackViewCartEvent(){let e=await xt.getCurrent().getNormalisedCart(),r={value:e.amount,currency:e.currency},n={items:e.items,amount:r,drawer:!0};Vt.getInstance().sendEvent(new jt(H.EVENT_VIEW_CART,n))}},sa=class nd{static INSTANCE;httpAPIService=Pr.getInstance();coreService=K0.getInstance();sentryService=zt.getInstance();sdkToken="";userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new nd),this.INSTANCE}init(e){this.appID=e.appID,this.shopifyShop=e.shopifyShop}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await Mt.set(ct.ID,e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await Mt.set(ct.DEVICE_ID,e.deviceID)),e.sdkToken&&(this.sdkToken=e.sdkToken,await Mt.set(ct.SDK_TOKEN,e.sdkToken)),this.updateAPIClient())}async validateSession(e){await this.populateFirstSeen(),await this.populateUserDataFromStorage(),T.log("Validating session with server");let r=await this.getSessionValidateData(e);try{let n=await this.httpAPIService.validateSession(r);T.log("Validating session Response",n),await this.coreService.processAppConfigurations(n.appSettings),await this.storeAndPopulateAuthData(n)}catch(n){throw T.error(n),n}}async populateUserDataFromStorage(){if(this.sdkToken=await Mt.get(ct.SDK_TOKEN),!this.sdkToken){T.warn("No SDK token found in local storage");return}this.userID=await Mt.get(ct.ID),this.deviceID=await Mt.get(ct.DEVICE_ID),this.updateAPIClient()}updateAPIClient(){T.debug("SDK Token:",this.sdkToken),T.log("Device ID:",this.deviceID),T.log("User ID:",this.userID),Fp.trackDeviceID(this.deviceID),Ne.log(`Device ID: ${this.deviceID}`),this.userID&&Ne.log(`User ID: ${this.userID}`),this.httpAPIService.setAPIToken(this.sdkToken),this.httpAPIService.setDeviceId(this.deviceID),this.sentryService.setGlobalContext("Visitor Info",{device_id:this.deviceID,user_id:this.userID}),this.sentryService.setUser({id:this.deviceID})}async getSessionValidateData(e){let r=await new I0().safeGet(),n=await Mt.get(ct.DEVICE_ID);return n||(n=new Kt().toHexString(),await Mt.set(ct.DEVICE_ID,n)),lt(x({deviceID:n,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),{sdk:H.SDK,page:Ss.parseFromCurrent(),ad:w0.getAdParams(),occurred:this.getSessionStartTime(kt.get().jsLoadTime),currentItem:kt.get().getCurrentItem(),cart:await xt.getCurrent().getNormalisedCart(),properties:{}})}async populateFirstSeen(){let e=await Mt.get(ct.FIRST_SEEN),r=e?new Date(e):new Date;e||await Mt.set(ct.FIRST_SEEN,r.toISOString()),this.httpAPIService.setFirstSeen(r),this.sentryService.setGlobalContext("Visitor Info",{first_seen:r.toISOString()})}getSessionStartTime(e){return(new Date().getTime()-e.getTime())/1e3>H.IDLE_TIME_IN_SECONDS?new Date:e}},we=class Pn{static replaySubject=new j_(1);static INSTANCE;sentryService=ut.get(zt);constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Pn),this.INSTANCE}init(e){if(T.debug("Initialising SDK",e),E_(navigator.userAgent)){T.info("This seems to be a bot. Disabling SDK");return}sa.getInstance().init(e),Pn.INSTANCE.checkSessionOnPageLoad().then(async()=>{Pn.replaySubject.next(!0),Pn.replaySubject.complete()}).catch(r=>{T.error("Unable to initiate session",r)})}getCurrentSessionID(){return ee.set(ct.SESSION_LAST_USED_TIME,new Date().getTime()),ee.get(ct.ID,"")}async checkSessionOnPageLoad(){await zb.request("validate_session",async()=>{await this.checkForNewSession(!0)})}async checkSessionAndGetContext(){return await this.checkForNewSession(),this.getContext()}async getContext(){let e=await Promise.all([this.getCurrentSessionID(),this.getCurrentSessionNumber(),this.getLandingPage()]);return this.sentryService.setTags({"cooee_session.number":e[1]}),this.sentryService.setGlobalContext("Visitor Session",{id:e[0],number:e[1],landing_page:e[2]}),e}async checkForNewSession(e){let r=!1;if(await this.isNewSessionRequired()?(Ne.log("New session to be started"),await this.startNewSession(),e=!0,r=!0):await this.notSynced()&&(r=!0),e){let n=await this.getContext();Ne.log(`Session ID: ${n[0]} & number: ${n[1]}`),await sa.getInstance().validateSession({sessionID:n[0],sessionNumber:n[1],landingPage:n[2],newSession:r}),await ee.set(ct.SESSION_SYNCED,!0)}}async startNewSession(){T.debug("Starting new session"),await ee.clear(),T.debug("Cleared SessionStorage before starting new session");let e=new Date,r=new Kt().toHexString();T.debug("New session ID to be used",r);let n=await Mt.get(ct.SESSION_NUMBER,0)+1;await Promise.all([Mt.set(ct.SESSION_NUMBER,n),ee.set(ct.ID,r),ee.set(ct.SESSION_LAST_USED_TIME,e.getTime()),ee.set(ct.SESSION_LANDING_PAGE,Ss.parseFromCurrent())])}getLandingPage(){return ee.get(ct.SESSION_LANDING_PAGE,{})}getCurrentSessionNumber(){return Mt.get(ct.SESSION_NUMBER,1)}async isNewSessionRequired(){if(!await ee.get(ct.ID))return!0;let e=await ee.get(ct.SESSION_LAST_USED_TIME,0);return e?(new Date().getTime()-e)/1e3>H.IDLE_TIME_IN_SECONDS:!0}async notSynced(){return!await ee.get(ct.SESSION_SYNCED,!1)}},Y0=class{loadedFonts=[];async loadAllFonts(t){t.elems?.forEach(e=>{e instanceof ds&&this.loadFamily(e.typography?.fam)})}async loadFamily(t){if(!t?.fonts||this.loadedFonts.indexOf(t.name)>-1)return;let e=[];t.fonts.forEach(r=>{if(r.url){let n=new FontFace(H.COOEE+t.name,r.getURL(),r.getFontDescriptor());e.push(n.load())}}),this.loadedFonts.push(t.name),(await Promise.all(e)).forEach(r=>{document.fonts.add(r)})}},J0=class{static updateIdentity(t){if(!this.isInstalled())return;let e={};t.email&&(e.email=t.email),t.mobile&&(e.phone_number=t.mobile),T.debug("Sending email/mobile to Klaviyo"),window.klaviyo.push(["identify",e])}static isInstalled(){return window.klaviyo&&typeof window.klaviyo=="object"}},X0=class{apiService;action;triggerContext;constructor(t,e){this.action=t,this.apiService=Vt.getInstance(),this.triggerContext=e}async execute(){let t=this.containsCTA()?H.EVENT_TRIGGER_CLICKED:H.EVENT_TRIGGER_CLOSED;switch(this.action.at!==106&&await this.closeTriggerAndSendEvent(t),this.action.at){case 2:break;case 4:this.gotoURLAction();break;case 5:this.shareAction();break;case 106:await this.collectFormData();break;case void 0:case 105:break;default:T.error("Received an invalid ClickActionType: ",this.action.at);return}}externalAction(){this.action.ext?.u&&window.open(this.action.ext.u,"_blank")?.focus()}gotoURLAction(){if(this.action.gu?.u){let t=this.action.gu.u;Ah(t)||(t=`//${t}`),window.open(t,"_self")}}async closeTriggerAndSendEvent(t,e){this.triggerContext.closeInApp(t,e),await this.dispatchEvent()}shareAction(){if(this.action.share){if(!navigator.share){T.warn("Navigator.share is not compatible with this browser");return}navigator.share({text:this.action.share.text,title:"Share"}).then(t=>console.log(t)).catch(t=>console.error(t))}}containsCTA(){return this.action.at&&this.action.at!==1?!0:!(this.isEmpty(this.action.custKV)&&this.isEmpty(this.action.up))}isEmpty(t){return t?Object.keys(t).length===0:!0}async collectFormData(){let t={};for(let e of this.triggerContext.inputs){if(!e.isValid)return;let r=document.getElementById(e.id).value;e.type===51?t.email=r:e.type===52&&(t.mobile=r)}await this.closeTriggerAndSendEvent(H.EVENT_FORM_SUBMITTED,{form:t}),Me("Coupon applied on cart"),J0.updateIdentity(t)}async dispatchEvent(){let t=this.triggerContext.triggerData,e={clickAction:this.action,items:this.triggerContext.selectedEmbeddedItems??t.embeddedItems??t.items,collections:t.collections,triggerData:t};await new gc().process(e);let r={action:this.containsCTA()?H.CAMPAIGN_CLICKED_ACTIVITY:H.CAMPAIGN_CLOSED_ACTIVITY};document.dispatchEvent(new CustomEvent(H.POPUP_ACTIVITY_EVENT,{detail:r}))}},si=class{renderer=mc.get();parentHTMLEl;inappElement;inappHTMLEl;triggerContext;stylesConverter;scalingFactor;constructor(t,e,r){this.parentHTMLEl=t,this.inappElement=e,this.triggerContext=r,this.stylesConverter=new Gp(this.renderer.getScalingFactor())}getHTMLElement(){return this.inappHTMLEl}insertElement(){this.parentHTMLEl.appendChild(this.inappHTMLEl)}processCommonBlocks(){this.processWidthAndHeight(),this.processPositionBlock(),this.processTransformBlock(),this.processTransparency(),this.processShadow(),this.registerAction();let t=lt(x(x(x(x({},this.getDisplayStyles()),this.getSpaceStyles()),this.getBorderStyles()),this.getBackgroundStyles()),{boxSizing:"border-box",outline:"none"});es(this.inappHTMLEl,t)}getDisplayStyles(){return{display:"block"}}processWidthAndHeight(){this.inappElement.w&&X(this.inappHTMLEl,"width",this.stylesConverter.getSizePx(this.inappElement.w)),this.inappElement.h&&X(this.inappHTMLEl,"height",this.stylesConverter.getSizePx(this.inappElement.h))}processPositionBlock(){let t={position:"absolute",left:this.stylesConverter.getSizePx(this.inappElement.x),top:this.stylesConverter.getSizePx(this.inappElement.y)};es(this.inappHTMLEl,t)}getBorderStyles(){return this.stylesConverter.getBorderStyles(this.inappElement.br)}getSpaceStyles(){return this.stylesConverter.getSpaceStyles(this.inappElement.spc)}processTransparency(){let t=this.inappElement.alpha;if(!isNaN(t)){let e=(t/100).toFixed(2);X(this.inappHTMLEl,"opacity",e)}}processShadow(){let t=this.inappElement.shd;t?X(this.inappHTMLEl,"box-shadow",t.getStyle(this.scalingFactor)):X(this.inappHTMLEl,"box-shadow","unset")}processTransformBlock(){let t=new Vu(this.inappElement.trf);t&&t.rotate&&X(this.inappHTMLEl,"transform",`rotate(${t.rotate}deg)`)}registerAction(){let t=this.inappElement.clc;!t||Object.keys(t).length===0||(this.inappHTMLEl.addEventListener("click",e=>{e.stopPropagation(),new X0(t,this.triggerContext).execute()}),X(this.inappHTMLEl,"cursor","pointer"))}getBackgroundStyles(){return this.stylesConverter.getBackgroundStyles(this.inappElement.bg)}},Is=class extends si{constructor(t,e,r){super(t,e,r)}processCommonBlocks(){super.processCommonBlocks(),this.processFontBlock(),this.processAlignment()}processFontBlock(){let t={},e=this.inappElement.typography;return e&&(t.fontSize=this.stylesConverter.getSizePx(e.fs),t.fontFamily=H.COOEE+e.fam?.name,t.lineHeight=`${e.lh}`,t.letterSpacing=e.letterSpacing),this.stylesConverter.getColourStyles(this.inappElement.color,"color",t),es(this.inappHTMLEl,t),t}processPart(t,e){let r=[];e.u&&r.push("underline"),e.st&&r.push("line-through"),r.length||r.push("normal"),X(t,"font-weight",e.b?"bold":"normal"),X(t,"font-style",e.i?"italic":"normal"),X(t,"text-decoration",r.join(" ")),X(t,"color",e.c??"inherit"),X(t,"font-family","inherit")}processAlignment(){let t=this.inappElement.typography.ta,e=t?fa[t]?.toLowerCase():this.inappElement.typography.alignment;e||(e="start"),X(this.inappHTMLEl,"text-align",e)}},Q0=class extends Is{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.inappElement.parts?.forEach(t=>{let e=document.createElement("span");e.innerHTML=t.txt?.toString()?.replace(/\n/g,"<br />"),this.processPart(e,t),this.inappHTMLEl.appendChild(e)}),this.processCommonBlocks()}},Z0=class extends si{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.processCommonBlocks()}},id=class extends si{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("img"),this.insertElement()}render(){this.inappHTMLEl.setAttribute("src",this.inappElement.src),X(this.inappHTMLEl,"max-width","none"),X(this.inappHTMLEl,"max-height","none"),X(this.inappHTMLEl,"margin","0 auto"),this.processCommonBlocks()}},tE=class sd extends si{constructor(e,r,n){super(e,r,n),this.parent=e,this.inappHTMLEl=document.createElement("div")}static MAX_Z_INDEX="2147483647";render(){return this.parent||this.renderer.removeInApp(),this.insertElement(),this.processCommonBlocks(),this.inappHTMLEl.classList.add(H.IN_APP_WRAPPER_NAME),this.inappHTMLEl.classList.add(this.triggerContext.rootClassName),X(this.inappHTMLEl,"z-index",sd.MAX_Z_INDEX),this.inappHTMLEl}getBackgroundStyles(){return this.inappElement.cover?super.getBackgroundStyles():{}}processWidthAndHeight(){let e=this.inappElement.cont;if(this.inappElement.cover)this.renderer.isParentNotBody()?(X(this.inappHTMLEl,"width","100%"),X(this.inappHTMLEl,"height","100%")):(X(this.inappHTMLEl,"width","100vw"),X(this.inappHTMLEl,"height","100vh")),X(this.inappHTMLEl,"top","0"),X(this.inappHTMLEl,"left","0");else{let r=this.inappElement.spc,n=this.stylesConverter.getScaledSize(e.w)+r.getHorizontal(),i=this.stylesConverter.getScaledSize(e.h)+r.getVertical();X(this.inappHTMLEl,"width",n+"px"),X(this.inappHTMLEl,"height",i+"px")}}getSpaceStyles(){return{padding:this.inappElement.spc.getPaddingCSS()}}getDisplayStyles(){return x(x({display:"flex"},this.inappElement.getStylesForWrapper()),this.inappElement.getFlexStylesForContainer())}processPositionBlock(){if(this.renderer.isParentNotBody()){if(this.triggerContext.triggerData.ian?.isEmbedded()){X(this.inappHTMLEl,"position","block");return}X(this.inappHTMLEl,"position","absolute")}else X(this.inappHTMLEl,"position","fixed")}getBorderStyles(){return{}}processTransparency(){}processTransformBlock(){}processShadow(){}},eE=class extends si{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){return this.processCommonBlocks(),X(this.inappHTMLEl,"position","relative"),X(this.inappHTMLEl,"overflow","hidden"),this.inappHTMLEl.classList.add(H.IN_APP_CONTAINER_NAME),this}},rE=class Pe extends Is{static DAYS="Days";static HOURS="Hours";static MINUTES="Minutes";static SECONDS="Seconds";elements;spans=[];constructor(e,r,n){super(e,r,n),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.addTimerChildren(),this.processAndStartTimer(),this.processCommonBlocks();let e=lt(x(x(x({flex:"1 1 0"},this.stylesConverter.getBackgroundStyles(this.inappElement.bg)),this.stylesConverter.getBorderStyles(this.inappElement.br)),this.stylesConverter.getSpaceStyles(this.inappElement.spc)),{marginLeft:this.stylesConverter.getSizePx(this.inappElement.gap),marginRight:this.stylesConverter.getSizePx(this.inappElement.gap)});this.addStylesToTimer(e)}getBackgroundStyles(){return{}}processFontBlock(){let e=super.processFontBlock();return this.stylesConverter.getColourStyles(this.inappElement.color,"color",e),this.addStylesToTimer(e),e}getSpaceStyles(){return{}}getBorderStyles(){return{}}getDisplayStyles(){return{display:"flex",flexWrap:"nowrap",justifyContent:"center"}}addStylesToTimer(e){this.elements.forEach(r=>es(r,e))}addTimerChildren(){let e=this.inappElement.show;this.elements=[],e.day&&this.elements.push(this.getChild(Pe.DAYS)),e.hour&&this.elements.push(this.getChild(Pe.HOURS)),e.minute&&this.elements.push(this.getChild(Pe.MINUTES)),e.second&&this.elements.push(this.getChild(Pe.SECONDS)),this.elements.forEach(r=>this.inappHTMLEl.appendChild(r))}getChild(e){let r=document.createElement("div"),n=document.createElement("span"),i=document.createElement("span");return i.innerText=e,n.innerText="00",n.id=`lc-${e}`,X(i,"font-size","0.5em"),X(i,"text-align","center"),X(i,"font-family","inherit"),X(n,"text-align","center"),X(n,"font-family","inherit"),this.inappElement.lblPos==="start"?(r.appendChild(i),r.appendChild(n)):(r.appendChild(n),r.appendChild(i)),X(r,"display","flex"),X(r,"flex-direction",this.inappElement.horizontal?"":"column"),X(r,"justify-content","center"),X(r,"align-items","center"),X(r,"gap","5px"),this.spans.push(n),r}processAndStartTimer(){let e=this.inappElement.timer.start(this.inappElement.timerType,r=>{this.spans.forEach(n=>{n.id===`lc-${Pe.DAYS}`?n.innerText=String(r.days).padStart(2,"0"):n.id===`lc-${Pe.HOURS}`?n.innerText=String(r.hours).padStart(2,"0"):n.id===`lc-${Pe.MINUTES}`?n.innerText=String(r.minutes).padStart(2,"0"):n.id===`lc-${Pe.SECONDS}`&&(n.innerText=String(r.seconds).padStart(2,"0"))})});this.triggerContext.intervals.push(e)}},nE=class extends Is{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("select"),this.insertElement()}render(){X(this.inappHTMLEl,"background","#ffffff00"),X(this.inappHTMLEl,"outline","none"),this.processCommonBlocks(),this.addListener(this.inappHTMLEl),this.addOptions()}addListener(t){this.triggerContext.selectedEmbeddedItems?.length||this.updateItems(this.triggerContext.triggerData.items[0].vars[0]),t.addEventListener("click",e=>{e.stopPropagation()}),t.addEventListener("change",()=>{let e=new ps(JSON.parse(t.value));this.updateItems(e)})}updateItems(t){let e=this.triggerContext.triggerData.items[0];this.triggerContext.selectedEmbeddedItems=[e.toEmbed(t)];let r=this.parentHTMLEl.querySelector("#coo-13");if(!r)return;let n=t.imgs[0]??e.imgs?.at(0);n?.url&&r.setAttribute("src",n.url)}addOptions(){let t=this.triggerContext.triggerData.items,e=this.inappHTMLEl;if(!t?.length){e.add(this.createOption(this.inappElement.placeholderText));return}let r=this.triggerContext.selectedEmbeddedItems?.at(0);t[0].vars.forEach(n=>{e.add(this.createOption(n.name??"Default",n,n.mID===r?.vID))})}createOption(t,e,r){let n=document.createElement("option");return n.text=t,n.value=JSON.stringify(e),r&&(n.selected=!0),e||(n.disabled=!0),n}},od=class extends Is{borderColor="";constructor(t,e,r){super(t,e,r),this.inappHTMLEl=document.createElement("input"),this.insertElement()}render(){let t=this.setInputType();this.inappHTMLEl.setAttribute("placeholder",this.inappElement.placeholderText),X(this.inappHTMLEl,"background","#ffffff00"),X(this.inappHTMLEl,"outline","none"),this.inappHTMLEl.addEventListener("click",e=>{e.stopPropagation()}),this.processCommonBlocks(),this.addListener(this.inappHTMLEl,t),this.triggerContext.addInputField(t,this.inappElement.t)}},iE=class ad extends od{static EMAIL_REGEX=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;constructor(e,r,n){super(e,r,n)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.inappHTMLEl.setAttribute("type","email"),this.inappHTMLEl.setAttribute("id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(ad.EMAIL_REGEX)?(X(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(X(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},sE=class cd extends od{static MOBILE_REGEX=/^\d+$/;constructor(e,r,n){super(e,r,n)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.inappHTMLEl.setAttribute("type","tel"),this.inappHTMLEl.setAttribute("id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(cd.MOBILE_REGEX)?(X(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(X(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},oE=class extends id{constructor(t,e,r){super(t,e,r)}render(){super.render(),this.inappHTMLEl.setAttribute("id",`coo-${this.inappElement.type}`)}},mc=class Re{static DOCUMENT_STANDARD_MODE="CSS1Compat";static ACTIVE_TRIGGER_DATA;static _instance;safeHTTP;parent;rootContainer;containerHTMLElement;ian;scalingFactor=1;triggerContext;resizeListener;cartDrawerToggleSubscription;constructor(e){Re._instance=this,this.safeHTTP=Vt.getInstance(),this.resizeListener=()=>this.screenResized(),this.setParentContainer(e)}static get(){return Re._instance}render(e){this.renderEngagement(new sr(e))}getScalingFactor(){return this.scalingFactor}calculateScalingFactor(e){let r=e.max,n=e.cont.w,i=e.cont.h,s=e.spc,o=this.getWidth(),c=this.getHeight();r&&(o=o?Math.min(o,r):r,c=c?Math.min(c,r):r),c&&(o-=s.getHorizontal(),c-=s.getVertical(),o/c<n/i?this.scalingFactor=o/n:this.scalingFactor=c/i,this.scalingFactor=Math.min(this.scalingFactor,1))}setParentContainer(e){this.parent=e||document.body,this.parent&&this.isParentNotBody()&&X(this.parent,"position","relative")}isParentNotBody(){return this.parent!==document.body}getWidth(){return this.parent&&this.parent!==document.body?this.parent.clientWidth:document.compatMode===Re.DOCUMENT_STANDARD_MODE?document.documentElement.clientWidth:window.innerWidth}getHeight(){return this.isParentNotBody()?this.parent.clientHeight:document.compatMode===Re.DOCUMENT_STANDARD_MODE?document.documentElement.clientHeight:window.innerHeight}async renderEngagement(e){if(this.triggerContext=new ec(new Date,e),this.triggerContext.onClose(r=>{this.closeInApp(r)}),this.ian=e.ian,(_r()||e.previewType==="mobile")&&this.ian.overrideForMobileView(),this.ian.isEmbedded()){let r=document.querySelector(this.ian.getEmbeddedSelector());this.setParentContainer(r)}await this.preloadImages(e),e.shouldDelay()?window.setTimeout(()=>{this.withCartDrawerClosed()},e.getDelaySeconds()):this.withCartDrawerClosed()}withCartDrawerClosed(){if(!Ee.get().isOpen()||!_r()){this.startRenderingOnce();return}this.cartDrawerToggleSubscription=Ee.get().onToggle().subscribe(({open:e})=>{!e&&this.startRenderingOnce()})}startRenderingOnce(){if(!this.shouldSkipCampaign()){Re.ACTIVE_TRIGGER_DATA=this.triggerContext.triggerData;try{this.startRendering()}catch(e){zt.getInstance().captureError(e,"render-popup",{triggerContext:this.triggerContext});return}this.sendTriggerDisplayed(),_r()||window.addEventListener("resize",this.resizeListener),this.cartDrawerToggleSubscription?.unsubscribe()}}shouldSkipCampaign(){let e=this.triggerContext.triggerData;if(!e.previewType&&Re.ACTIVE_TRIGGER_DATA){let n={triggerShown:new Xa(Re.ACTIVE_TRIGGER_DATA??{})};return this.skipTrigger(e,n),!0}if(kt.get().isGoKwikPopupOpen)return this.skipTrigger(e,{reason:"GoKwik popup is open"}),!0;let r=H.PAYMENT_MODAL_DETAILS.find(n=>!!document.querySelector(n.identifier));return r?(this.skipTrigger(e,{reason:`${r.gateway} modal is open`}),!0):!1}startRendering(){this.calculateScalingFactor(this.ian),this.rootContainer=new tE(this.parent,this.ian,this.triggerContext).render();try{this.renderContainer(this.triggerContext)}catch(e){throw T.error(e),e}}sendTriggerDisplayed(){let e={};this.triggerContext.triggerData.items?.length&&(e.promotedMIDs=this.triggerContext.triggerData.items?.map(i=>i.mID));let r=new jt(H.EVENT_TRIGGER_DISPLAYED,e,this.triggerContext.triggerData);this.safeHTTP.sendEvent(r);let n={action:H.CAMPAIGN_DISPLAYED_ACTIVITY};document.dispatchEvent(new CustomEvent(H.POPUP_ACTIVITY_EVENT,{detail:n}))}sendTriggerClosed(e){let r=e.eventName;delete e.eventName;let n=new jt(r,e,this.triggerContext.triggerData);n.name===H.EVENT_TRIGGER_CLICKED&&(n.items=this.triggerContext.selectedEmbeddedItems??this.triggerContext.triggerData.items?.map(i=>i.toEmbed())),this.safeHTTP.sendEvent(n)}addEnterAnimation(e){this.containerHTMLElement.animate(e.getEnterAnimation(),{duration:500})}renderElement(e,r,n){r instanceof op?new iE(e,r,n).render():r instanceof ap?new sE(e,r,n).render():r instanceof Vo?new Q0(e,r,n).render():r instanceof cp?new oE(e,r,n).render():r instanceof Ha?new id(e,r,n).render():r instanceof rp?new Z0(e,r,n).render():r instanceof ip?new rE(e,r,n).render():r instanceof sp?new nE(e,r,n).render():T.error("Unsupported element type- "+r.type)}renderContainer(e){let r=this.ian?.cont;r&&(this.containerHTMLElement=new eE(this.rootContainer,r,e).render().getHTMLElement(),new Y0().loadAllFonts(this.ian),this.ian.elems?.forEach(async n=>{await this.renderElement(this.containerHTMLElement,n,e)}),this.addEnterAnimation(this.ian.anim))}closeInApp(e){let r=this.ian.anim.getExitAnimation();this.sendTriggerClosed(e),Re.ACTIVE_TRIGGER_DATA=void 0;let n=this.containerHTMLElement.animate(r,{duration:500,easing:"ease-in-out"});n.onfinish=()=>{this.removeInApp(),window.removeEventListener("resize",this.resizeListener)}}screenResized(){this.removeInApp(),this.startRendering()}removeInApp(){let e=document.querySelector(`.${this.triggerContext.rootClassName}`);e&&e.parentElement.removeChild(e)}skipTrigger(e,r){let n=new jt(H.EVENT_CAMPAIGN_REJECTED,r,e);this.safeHTTP.sendEvent(n)}async preloadImages(e){let r=e.ian;if(!r)return;let n=[];r.elems.forEach(i=>{let s=i.bg?.img?.src;if(s&&n.push(this.getPromise(s)),i.t===1){let o=i.src;if(!o)return;n.push(this.getPromise(o))}}),r.bg?.img?.src&&n.push(this.getPromise(r.bg.img.src)),r.cont.bg?.img?.src&&n.push(this.getPromise(r.cont.bg.img.src)),await Promise.all(n)}getPromise(e){return new Promise(r=>{let n=new Image;n.onload=r,n.src=e,n.style.display="none"})}},aE=class{triggerData;safeHttpService=Vt.getInstance();render(t){t.contentSource===ua.KLAVIYO&&(this.triggerData=t,window.addEventListener("klaviyoForms",this.handleKlaviyoEvents.bind(this)),window._klOnsite=window._klOnsite||[],window._klOnsite.push(["openForm",t.klaviyoFormID]))}handleKlaviyoEvents(t){if(t.type!=="klaviyoForms")return;let e=t.detail;if(e.formId!==this.triggerData.klaviyoFormID){T.warn("Received invalid trigger callback");return}switch(e.type){case"open":this.safeHttpService.sendEvent(new jt(H.EVENT_TRIGGER_DISPLAYED,{form:{id:e.formId}},this.triggerData));break;case"stepSubmit":{let r=this.getFormDetails(e);this.safeHttpService.sendEvent(new jt(H.EVENT_FORM_SUBMITTED,{form:r},this.triggerData)),this.safeHttpService.updateProfile(r);break}case"close":window.removeEventListener("klaviyoForms",this.handleKlaviyoEvents.bind(this)),this.safeHttpService.sendEvent(new jt(H.EVENT_TRIGGER_CLOSED,{form:{id:e.formId}},this.triggerData));break}}getFormDetails(t){let e={id:t.formId},r=t.metaData;if(Gn.hasKeys(r)){let n=["email","phone_number","first_name","last_name","$email","$phone_number","$first_name","$last_name"];Object.keys(r).forEach(o=>{n.includes(o)||(e[o]=r[o])}),e.email=r.$email??r.email,e.mobile=r.$phone_number??r.phone_number;let i=r.$first_name??r.first_name,s=r.$last_name??r.last_name;(i?.length||s?.length)&&(e.name=i+" "+s)}return e}},cE=class{static trackIntent(t){if(!this.isInstalled()){T.log("Facebook pixel not installed");return}if(!se.get().pixelPush){T.log("Facebook pixel push not enabled");return}let e=fs[t.intent]?.toLowerCase(),r=t.segmentName;!e&&!r||(T.debug(`Sending ${e} intent and ${r} segment to Facebook Pixel`),window.fbq("trackCustom","CooeeIntent",{intent_value:e,segment_value:t.segmentName}))}static isInstalled(){return window.fbq&&typeof window.fbq=="function"}},vc=class ld{static INSTANCE;httpService=ut.get(Pr);sentryService=ut.get(zt);sessionManager=ut.get(we);runtime=kt.get();constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new ld),this.INSTANCE}sendSilently(e){this.send(e).catch(r=>T.error(`Failed to send ${e.name}`,r))}async send(e){if(T.debug(`Sending event ${e.name}`),Ne.log(`Sending event ${e.name} with id ${e.id}`),this.shouldReject(e)){T.warn(`Rejecting event ${e.name}`);return}await Promise.all([this.addSessionContext(e),this.addShopifyContext(e)]),this.addShopifyAttributes(),e.name!==H.EVENT_APP_BACKGROUND&&this.runtime.setActive(),e.currentItem=this.runtime.getCurrentItem(),e.locale=this.runtime.locale,this.httpService.post("/v1/event/track",e).then(async r=>{T.log("\u2705 Event tracked:",e.name),Ne.log(`\u2705 Event <strong>${r.eventName}</strong> tracked`),this.processEventResponse(e,r)}).catch(r=>{T.error(`Error sending event ${e.name} to server`,r)})}shouldReject(e){return e.trigger?.triggerID==="test"||e.trigger?.triggerID==="preview"?(T.warn("Not sending event as this is a test trigger"),!0):!1}async addSessionContext(e){let r=await this.sessionManager.checkSessionAndGetContext();e.sessionID=r[0],e.sessionNumber=r[1],e.landingPage=r[2],e.page=Ss.parseFromCurrent()}async addShopifyContext(e){try{e.cart=await xt.getCurrent().getNormalisedCart()}catch(r){T.error("Error fetching Shopify cart before sending the event",r)}}processEventResponse(e,r){this.renderWidgetIfAny(e,r).catch(n=>{this.sentryService.captureError(n,"process-popup-response",{extra:{event:e,response:r}})}),this.utiliseIntentIfCalculated(r)}async renderWidgetIfAny(e,r){if(!r.triggerData){T.log(`Nothing to engage after ${e.name}`);return}T.log(`\u{1F4E3} Engagement(id=${r.triggerData.shortID}) will be shown`,r.triggerData),Ne.log(`\u{1F4E3} Campaign #${r.triggerData.shortID}) will be shown`);let n=new sr(r.triggerData);n.occurred=e.occurred;let i;try{i=await Wp.refreshItems(n)}catch(s){T.error("Failed to refresh the products",s);return}if(n.items=i,n.contentSource===ua.KLAVIYO){new aE().render(n);return}new mc().renderEngagement(n).catch(s=>{this.sentryService.captureError(s,"render-popup",{extra:{event:e},engagementTrigger:n})})}utiliseIntentIfCalculated(e){e.intent&&(Fp.trackIntent(e.intent),cE.trackIntent(e),Ne.log(`Intent is <strong>${fs[e.intent]}</strong>`))}addShopifyAttributes(){xt.getCurrent().addCooeeAttributes().catch(e=>{T.error("Fail to add attributes in cart",e)})}},Cs=class{constructor(t){this.triggerContext=t}safeHTTP=Vt.getInstance();eventAPIService=vc.getInstance();async execute(t){let e=kt.get().getCurrentItem(),r=t.clickAction;if(!r)return;let n=t.item,i=this.triggerContext,s=new gc,o=i.triggerData.redirectBehaviour,c=!!i.triggerData.discount?.type&&!!r?.applyDiscount,l={selectedVariants:i.triggerData.nonMutableItems.map(_=>({itemMID:_.mID,mID:_.selectedOrFirstVariant.value.mID,variantID:_.selectedOrFirstVariant.value.mID})),eID:i.triggerData.engagementID,cID:i.triggerData.contentID},p="",g=[],h=[];if(n?h=[n.toEmbed()]:t.embeddedItem&&(h=[t.embeddedItem]),r.at===108){let _=i.selectedItems;if(h=t.embeddedItems??_.map(k=>k.toEmbed()),i.shouldGiveFBTDiscount||t.embeddedItems?.length){let k;t.embeddedItems?k=t.embeddedItems.map(M=>({itemMID:M.mID,mID:M.vID,variantID:M.vID,quantity:M.quantity})):k=_.map(M=>({itemMID:M.mID,mID:M.selectedOrFirstVariant.value.mID,variantID:M.selectedOrFirstVariant.value.mID}));let A=i.triggerData.bundleFrom;i.triggerData.isBundleOnCartDrawer()&&A&&(k.push({itemMID:A.mID,mID:A.selectedOrFirstVariant.value.mID,isPrimary:!0}),h.unshift(A.toEmbed())),l.selectedVariants=k,i.triggerData.isBundleOnPDP()&&l.selectedVariants.forEach(M=>{M.mID===e.vID&&(M.isPrimary=!0)})}else l=void 0;g=t.embeddedItems??_}else if(r.at===107){let _=await xt.getCurrent().getNormalisedCart();h=_.items,l.selectedVariants=_.items.map(k=>({itemMID:k.mID,mID:k.vID}))}else if(r.at===102)g=n?[n]:[t.embeddedItem];else if(r.at===101)p=n?Wi()+"products/"+n.slug:t.embeddedItem?.link;else if(r.at===4){let _=Ah(r.gu?.u);_&&(p=_.href)}else if(r.at===109){let _=await s.upgradeToSubscription(n,i.triggerData);this.triggerContext.triggerData.skipSubscribedItems&&this.triggerContext.renderer.destroy(),Ee.get().refreshUI(_)}else if(r.at===104){let _=this.triggerContext.triggerData.collections?.[0];_&&(p="collections/"+_.handle)}if(this.sendTriggerClicked(h,{from:"button"},t.video),T.debug({redirectPath:p,redirectBehaviour:o,hasDiscount:c}),!c&&p){location.href=p;return}let w,y=!1;try{w=await this.getOrGenerateDiscountCode(l),T.debug("Discount code (if any) to apply",w)}catch(_){if(!this.triggerContext.triggerData.isBYOB()){v_.default.error("Unable to get a discount code",_);return}}if(w&&r.at===103)await s.copyDiscountCode(w);else if(r.at===110){let _=await s.createNewCart(e,w,i.triggerData);_&&(location.href=_);return}try{w&&await Mn.applyWithStorefront([w])}catch(_){T.error(_),y=!0}let b;if(g?.length&&(b=await s.addToCart(g,i.triggerData)),y&&w){Mn.navigate(w,o,p);return}if(p){location.href=p;return}Mn.navigateWithoutDiscount(o,b)}sendTriggerClicked(t,e,r){let n=new jt(H.EVENT_TRIGGER_CLICKED,e,this.triggerContext.triggerData);n.items=t,r?.id&&(n.videos=[r.id]),this.eventAPIService.sendSilently(n)}async getOrGenerateDiscountCode(t){let e=this.triggerContext.triggerData.discount;if(!e?.type)return;let r="";if(e.type===Ue.STATIC){if(!e.code)throw zt.getInstance().captureMessage("No discount code found","warning",{triggerContext:this.triggerContext}),new Error("No discount code found");return e.code}if(t){if(r=await this.generateDiscount(t),!r)throw T.error("No discount code found",t),new Error("Discount code not found or generated");return r}}async generateDiscount(t){try{return(await this.safeHTTP.generateDiscount(t))?.code}catch(e){throw Me("Failed to generate a discount code"),zt.getInstance().captureError(e,"backend-generate-discount",{extra:{discountData:JSON.stringify(t)},triggerContext:this.triggerContext}),e}}},lE=class{eventAPIService;modifications=[];constructor(){this.eventAPIService=ut.get(yc)}execute(t){for(let e of t)e.experimentConfig&&this.executeExperiment(e)&&this.trackExperimentRan(e);if(document.querySelector("#lc-hide-body")?.remove(),!document.body){ut.get(zt).captureMessage("No body element found","error");return}this.setupMutationObserver()}executeExperiment(t){let e=t.experimentConfig?.modifications;return e?.length?e.some(r=>{if(!r.cssSelector)return T.debug("No CSS Selector available",t?.toString()),!1;this.modifications.push(r);let n=Array.from(document.querySelectorAll(r.cssSelector));return n?.length?(this.executeSingleModification(r,n),!0):!1}):(T.log("Nothing to experiment",t.toString()),!1)}executeSingleModification(t,e){if(e?.length)for(let r of e)Object.assign(r.style,t.style),t.type==="TEXT"&&t.text?r.innerHTML=t.text:t.type==="IMAGE"&&this.updateImage(t,r)}trackExperimentRan(t){if(t.id==="preview"){T.warn("Skipping experiment attribution as its preview",t.toString());return}this.eventAPIService.trackExperiment({name:H.EVENT_EXPERIMENT_START,experiment:new Xa(t)}).catch(e=>{T.error("Fail to track experiment",e)})}setupMutationObserver(){new MutationObserver(t=>{t.forEach(e=>{e.addedNodes.forEach(r=>{r instanceof HTMLElement&&this.modifications.forEach(n=>{r.matches&&r.matches(n.cssSelector)?(T.debug("Re-applying experiment",n.toString()),this.executeSingleModification(n,[r])):r.querySelectorAll&&(T.debug("Re-applying experiment",n.toString()),this.executeSingleModification(n,Array.from(r.querySelectorAll(n.cssSelector))))})})})}).observe(document.body,{childList:!0,subtree:!0})}updateImage(t,e){let r=t.image?.lg?.src,n=t.image?.sm?.src;!r&&!n||(e instanceof HTMLPictureElement?this.updatePictureElement({desktop:r,mobile:n},e):this.updateImageElement({desktop:r,mobile:n},e))}updateImageElement(t,e){_r()&&t.mobile?(e.setAttribute("src",t.mobile),e.removeAttribute("srcset")):t.desktop&&(e.setAttribute("src",t.desktop),e.removeAttribute("srcset"))}updatePictureElement(t,e){if(e.innerHTML="",t.mobile){let n=document.createElement("source");n.srcset=t.mobile,n.media="(max-width: 767px)",e.append(n)}if(t.desktop){let n=document.createElement("source");n.srcset=t.desktop,n.media="(min-width: 768px)",e.append(n)}let r=document.createElement("img");r.src=t.desktop??t.mobile??"",e.append(r)}},yc=class ud extends td{static INSTANCE;constructor(){super()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new ud),this.INSTANCE}loadExperimentSilently(){Mt.get(ct.SDK_TOKEN).then(e=>{e?this.loadExperiments().catch(r=>T.error("Unable to initiate experiment",r)):we.replaySubject.subscribe(async()=>{this.loadExperiments().catch(r=>T.error("Unable to initiate experiment",r))})})}async loadExperiments(){if(!this.runtimeData.activeExperiment)return;let e=await this.getWidgetProps();T.log("Load experiments",e),this.httpService.post("/v1/engagement/experiments",e).then(async r=>{let n=r.experiments.map(i=>new sr(i));new lE().execute(n)}).catch(r=>{T.error("Error sending experiment getter",r)})}async trackExperiment(e){await this.addSessionContext(e),await this.httpService.post("/v1/event/experiment",e)}},uE=class{runtimeData=kt.get();widgetAPIService=ut.get(Wn);experimentAPIService=ut.get(yc);meddle(){let t=Tt.globalRef;t.account=t.account??[],t.profile=t.profile??[],t.events=t.events??[],t.page=t.page??[],this.meddlePage(),this.meddleAccount(),this.meddleEvents(),this.meddleProfile(),this.exposeMethods()}exposeMethods(){let t=Tt.globalRef;t.loadPageWidgets=()=>{this.widgetAPIService.loadPageWidgetsSilently()},t.loadCartWidgets=()=>{this.widgetAPIService.loadCartWidgetsSilently()},t.loadExperiments=()=>{this.experimentAPIService.loadExperimentSilently()},t.testCartUpdate=this.testCartUpdate.bind(this),t.previewWidget=Tt.previewWidget.bind(Tt),t.previewPopup=Tt.previewPopup.bind(Tt)}overwritePush(t,e){On(t,"push",e)}meddleAccount(){this.overwritePush(Tt.globalRef.account,(...t)=>{this.processAccount(t[0])}),Tt.globalRef.account.forEach(this.processAccount.bind(this))}meddleEvents(){this.overwritePush(Tt.globalRef.events,(...t)=>{this.processEvent(t[0])}),Tt.globalRef.events.forEach(this.processEvent.bind(this))}meddleProfile(){this.overwritePush(Tt.globalRef.profile,(...t)=>{this.processProfile(t[0])}),Tt.globalRef.profile.forEach(this.processProfile.bind(this))}processAccount(t){t&&(t.appID&&Tt.authenticate(t),t.flags&&ia.setFlags(t.flags))}processEvent(t){t&&(H.JS_LOAD_WHITELIST_EVENTS.includes(t[0])?Tt.sendEvent(t[0],t[1],x({occurred:this.runtimeData.jsLoadTime},t[2])):Tt.sendEvent(t[0],t[1],t[2]))}processProfile(t){t&&Tt.updateProfile(t)}processPageName(t){t&&Tt.setPageName(t)}meddlePage(){this.overwritePush(Tt.globalRef.page,(...t)=>{this.processPage(t[0])}),Tt.globalRef.page.forEach(this.processPage.bind(this))}processPage(t){t.currentItem&&this.runtimeData.setCurrentItem(t.currentItem),t.currency&&(this.runtimeData.currencyCode=t.currency),t.shopCurrency&&(this.runtimeData.shopCurrencyCode=t.shopCurrency),t.moneyFormat&&(this.runtimeData.moneyFormat=t.moneyFormat),t.jsLoad&&(this.runtimeData.jsLoadTime=t.jsLoad),t.locale&&(this.runtimeData.locale=t.locale),t.pageName&&Tt.setPageName(t.pageName),t.activeExperiment&&(this.runtimeData.activeExperiment=t.activeExperiment)}async testCartUpdate(){if(this.runtimeData.pageName!=="product"){window.alert("This feature is only available on a product page");return}let t=window.ShopifyAnalytics?.meta??{},e=t.selectedVariantId;if(e||(t.product?.variants?.length>0&&(e=t.product.variants[0].id),e||(e=this.runtimeData.getCurrentItem()?.vID)),!e){window.alert("Could not find a variant to test. Please try a different product page");return}let r=new sr({id:"preview",shortID:"1",redirectBehaviour:Te.CART_DRAWER});await new Cs(new ec(new Date,r)).execute({clickAction:{at:102},embeddedItem:new Ar({vID:e})})}},vo=class{static SESSION_STORAGE=window.sessionStorage;static SESSION_STORAGE_KEY_PREFIX=H.COOEE.concat("-");static getString(t,e){return this.getItem(t)||e}static setString(t,e){this.setItem(t,e)}static remove(t){this.removeItem(t)}static getItem(t){return this.SESSION_STORAGE.getItem(this.SESSION_STORAGE_KEY_PREFIX.concat(t))}static setItem(t,e){this.SESSION_STORAGE.setItem(this.SESSION_STORAGE_KEY_PREFIX.concat(t),e)}static removeItem(t){this.SESSION_STORAGE.removeItem(this.SESSION_STORAGE_KEY_PREFIX.concat(t))}},yo=class Pi{static INSTANCE;static DEBOUNCE_TIME=1e3;static THRESHOLD=10;safeHttpService=ut.get(Vt);lastPercent=0;_lastScreenOrScroll=new Date;constructor(){}set lastScreenOrScroll(e){this._lastScreenOrScroll=e}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Pi),this.INSTANCE}resetScrollID(e){vo.remove(H.SESSION_STORAGE_SCROLL_ID),this.lastScreenOrScroll=e??new Date}listen(){if(window.scrollY){let e=this.getPercentScrolledY();this.shouldSendScroll(e)&&this.sendScroll(e)}Na(()=>{this.observeWindowScroll()})}observeWindowScroll(){ts(window,"scroll").pipe(ni(Pi.DEBOUNCE_TIME),cc(()=>{let e=this.getPercentScrolledY();if(e>100){T.warn("Received scroll percent is more than 100",e);return}if(this.shouldSendScroll(e))return e})).subscribe(e=>{this.sendScroll(e)})}shouldSendScroll(e){return Math.abs(this.lastPercent-e)>=Pi.THRESHOLD||this.lastPercent!==e&&e===100}sendScroll(e){if(e==null)return;let r={percent:e,timeMS:new Date().getTime()-this._lastScreenOrScroll.getTime()};this.lastPercent=e;let n=vo.getString(H.SESSION_STORAGE_SCROLL_ID,""),i=new jt(H.EVENT_SCROLL,r,null,n);this.safeHttpService.sendEvent(i),vo.setString(H.SESSION_STORAGE_SCROLL_ID,i.id.toHexString()),this._lastScreenOrScroll=new Date(i.occurred)}getPercentScrolledY(){let e=window.document.body.scrollHeight,r=window.innerHeight;return Math.ceil((window.scrollY+r)/e*100)}},hE=class hd{static ACTIVE_DURATION="aDur";static INACTIVE_DURATION="iaDur";apiService=ut.get(Vt);runtimeData=kt.get();listen(){document.onvisibilitychange=()=>{document.visibilityState==="visible"?this.onVisible():document.visibilityState==="hidden"&&this.onHidden()}}async onVisible(){}async onHidden(){let e=await this.runtimeData.setInactive();if(e===0){T.info("Not sending background event as user was inactive on website");return}T.info(`Sending background event with ${e} seconds`);let r={};r[hd.ACTIVE_DURATION]=e,this.apiService.sendEvent(new jt(H.EVENT_APP_BACKGROUND,r))}},pE=class{compareCartItemSubject=new or;constructor(){this.compareCartItemSubject.pipe(ni(100)).subscribe(this.compareCartItems.bind(this))}listen(){this.compareCartItemSubject.next(),this.overwriteXMLHttpRequest(),this.overwriteFetchMethod()}overwriteXMLHttpRequest(){let t=this,e=window.XMLHttpRequest.prototype.send;window.XMLHttpRequest.prototype.send=function(){return this.addEventListener("load",function(){t.performEvent(this._url).catch(r=>T.error("Unable to process cart change in XMLHttpRequest",r))}),e.apply(this,arguments)},T.debug("Securely overwritten window.XMLHttpRequest.send method")}overwriteFetchMethod(){let t=this,e=window.fetch;window.fetch=function(r){return e.apply(window,arguments).then(n=>(t.performEvent(r.toString()).catch(i=>T.error("Unable to process cart change in fetch",i)),n))},T.debug("Securely overwritten window.fetch method")}async performEvent(t){this.isCartManipulationURL(t)&&(kt.get().isCartDirty=!0,this.compareCartItemSubject.next())}isCartManipulationURL(t){return/\/cart\/(add|change|update|clear)/.test(t)}sendChangesAsEvents(t,e){let r=t?.items,n=e.items,i=[],s=[];if(T.debug(`Comparing cart change with old count ${r?.length} to new count ${n.length}`),n?.forEach(o=>{let c=r?.find(l=>l.vID===o.vID);if(c){if(c.quantity!==o.quantity){let l=c.quantity<o.quantity,p=Math.abs(c.quantity-o.quantity),g=lt(x({},o),{quantity:p});l?i.push(g):s.push(g)}r&&tb(r,c)}else i.push(o)}),r)for(let o of r)s.push(o);T.debug(`Cart delta: added: ${i.length}, removed: ${s.length}`),i.length&&this.sendEvent(H.EVENT_ADD_TO_CART,{items:i}),s.length&&t.token===e.token&&this.sendEvent(H.EVENT_REMOVE_FROM_CART,{items:s}),(s.length||i.length)&&hc.get().broadcast(H.CART_UPDATE_BROADCAST,{itemsAdded:i,itemsRemoved:s})}sendEvent(t,e){let r=new jt(t,e);ut.get(Vt).sendEvent(r)}async compareCartItems(){let t=await Mt.get(ct.CURRENT_CART,{}),e=await xt.getCurrent().getNormalisedCart(!0);this.sendChangesAsEvents(t,e)}},dE=class{listen(){return this.overwriteFetchMethod(),this}overwriteFetchMethod(){let t=this,e=window.fetch;window.fetch=async function(r,n){try{await t.modifyRequest(r,n)}catch(i){zt.getInstance().captureError(i,"modify-graphql-request",{extra:{body:JSON.stringify(n?.body)}})}return e(r,n)},T.debug("Securely overwritten window.fetch method for graphql query")}async modifyRequest(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&&(T.debug("Intercepted fetch request of:",r),n?.query.includes("cartCreate")&&(e.body=await this.updatedBody(n),this.sendBuyNowEvent()))}async updatedBody(t){let e=t.variables.input.attributes??[],r=await kh();return t.variables.input.attributes=[...e,...r],JSON.stringify(t)}sendBuyNowEvent(){let t=kt.get().getCurrentItem();if(!t)return;let e=new jt(H.EVENT_BUY_NOW_CLICKED,{items:[t]});Vt.getInstance().sendEvent(e)}},pd=class{constructor(t,e){this.selectors=t,this.eventName=e,this.selectorString=t.join(",")}static INSTANCE;elements;selectorString;clickListenerCallback=t=>{let e=t.currentTarget,r=new jt(this.eventName,{class:e.className||void 0,tagName:e.tagName||void 0,id:e.id||void 0});Vt.getInstance().sendEvent(r),this.removeClickListener(this.clickListenerCallback)};listenSilently(){this.listen().catch(t=>T.error(t))}async listen(){this.elements=await Nh(this.selectorString),this.elements.forEach(t=>{t.addEventListener("click",this.clickListenerCallback)})}removeClickListener(t){this.elements?.forEach(e=>{e.removeEventListener("click",t)})}},fE=class oa extends pd{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(oa.selectors,H.EVENT_ITEM_THUMBNAIL_CLICKED)}static getInstance(){return this.INSTANCE||(this.INSTANCE=new oa),this.INSTANCE}},gE=class aa extends pd{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(aa.selectors,H.EVENT_REVIEW_CLICKED)}static getInstance(){return this.INSTANCE||(this.INSTANCE=new aa),this.INSTANCE}},mE=class{selector=[".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(",");listen(){Na(()=>{T.debug("Execution order:","document ready"),this.useLocationHash()})}useLocationHash(){let t=window.location.hash?.substring(1);if(t)if(t.includes(H.HASH_INITIATE_CHECKOUT)){document.dispatchEvent(new Event(H.THIRD_PARTY_CHECKOUT_EVENT));let e=document.querySelector(this.selector);if(!e){T.debug("No clickable cart checkout button found");return}T.debug("Clickable cart checkout button found",e),e.click()}else t.includes(H.HASH_OPEN_CART_DRAWER)&&Ee.get().open()}},ku=class{static attachCheckoutListener(){window.gokwikSdk&&window.gokwikSdk.on("checkout_initiated",async()=>{let t=await xt.getCurrent().getNormalisedCart(),e={via:"GoKwik",items:t.items,cartToken:t.token,amount:{value:t.amount,currency:t.currency}},r=new jt(H.EVENT_CHECKOUT_STARTED,e);Vt.getInstance().sendEvent(r)})}},vE=class{async migrate(){}},Tt=class{static globalRef;static authenticated;static async initForMerchantWebsiteOnly(){window.cooeeSDKPreview||(this.initGlobalReference(),await new vE().migrate(),this.autoAuthenticate(),new uE().meddle(),ut.get(yc).loadExperimentSilently(),new hE().listen(),new pE().listen(),new dE().listen(),new mE().listen(),ut.get(yo).listen(),ut.get(gE).listenSilently(),ut.get(fE).listenSilently(),ut.get(Wn).loadPageWidgetsSilently(),this.attachGoKwikListeners(),this.storePreviewParams(),this.setupPreviewListeners(),Ne.watch())}static async initForAll(){this.injectWidgetAssets()}static initGlobalReference(){window.CooeeSDK||On(window,"CooeeSDK",{}),this.globalRef=window.CooeeSDK,On(this.globalRef,"config",new se),On(this.globalRef,"runtimeData",new kt),On(this.globalRef,"uaParser",new Ke),T.debug("Global reference initialised")}static injectWidgetAssets(){be.injectScriptURL(Ge.widgetURL,"cooee-widget-sdk"),be.injectStylesheet(Ge.styleURL)}static autoAuthenticate(){let t=qb();t&&this.authenticate({shopifyShop:t})}static authenticate(t){if(this.authenticated)return;let e=t.appID?.trim(),r=t.shopifyShop;if((xl(e)||e.length!==24)&&xl(r)){T.warn("Cooee App ID or Shop name is not configured");return}this.authenticated=!0,ut.get(we).init(t)}static sendEvent(t,e,r){let n=new jt(t,e,r?.triggerData);r?.occurred&&(n.occurred=r.occurred),ut.get(Vt).sendEvent(n)}static updateProfile(t){for(let e in t)if(e.toLowerCase().startsWith("ce "))throw new Error("User property name cannot start with 'CE '");ut.get(Vt).updateProfile(t)}static setPageName(t){if(!t)return;let e=kt.get(),r=e.pageName;if(t===r)return;if(e.pageName=t,t==="cart"&&ut.get(Wn).loadOrRenderWidgetsAfterCartChange(),H.BLACKLISTED_PAGE_NAMES.some(s=>t.includes(s))){ut.get(yo).resetScrollID();return}let n={};r&&(n.ps=r);let i=new jt(H.EVENT_SCREEN_VIEW,n);i.occurred=e.jsLoadTime,ut.get(Vt).sendEvent(i),ut.get(yo).resetScrollID(i.occurred)}static previewPopup(t,e){new mc(e).render(t)}static previewWidget(t){new We(new sr(t)).render()}static setupPreviewListeners(){if(window.opener){try{window.opener.postMessage({action:"COOEE_READY_FOR_PREVIEW"},"*")}catch(t){T.error(t)}window.addEventListener("message",t=>{if(T.debug("Received event",t),!t.origin.includes("letscooee.com")&&!t.origin.includes("localhost"))return;let e=t.data;typeof e=="object"&&(e.action==="POPUP_PREVIEW"?(this.previewPopup(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)):e.action==="WIDGET_PREVIEW"&&(this.previewWidget(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)))})}}static attachGoKwikListeners(){let t=kt.get();window.addEventListener("kp-modal:opened",()=>{t.isGoKwikPopupOpen=!0}),window.addEventListener("user-loggedin",e=>{let{token:r}=e.detail;r&&this.updateProfile({goKwikToken:r})}),window.gokwikSdk?ku.attachCheckoutListener():window.addEventListener("gokwikLoaded",ku.attachCheckoutListener)}static storePreviewParams(){let t=kt.get(),e=new URLSearchParams(location.search),r=e.get("cooee-preview");r&&(t.previewIDs=r.trim().split(",").filter(i=>Number.isInteger(+i)));let n=e.get("cooee-variant");n&&(t.previewVariant=n)}};gf();mf();T.debug("Execution order:","top");window.cooeeShopifyScriptLoaded||(window.cooeeShopifyScriptLoaded=!0,(async()=>(T.debug("Execution order:","IIFE start"),await Tt.initForMerchantWebsiteOnly(),await Tt.initForAll(),T.debug("Execution order:","IIFE end")))());T.debug("Execution order:","bottom");})();
@@ -7,7 +7,7 @@ import{$ as $i,$a as ks,A as Rl,Aa as Y,B as Et,Ba as Ee,C as zn,Ca as Ls,D as n
7
7
 
8
8
  `+y.message+`
9
9
  `+Array(y.message.length+1).join("=")+`
10
- `+N(A,P)):y}}function gt(A,x){var F;return x.cache&&x.name&&x.storage.templates.get(x.name)?x.storage.templates.get(x.name):(F=typeof A=="function"?A:Ye(A,x),x.cache&&x.name&&x.storage.templates.define(x.name,F),F)}Le.l.bind(Le),t.compile=Ye,t.compileScope=se,t.compileScopeIntoFunction=K,t.compileToString=N,t.defaultConfig=Le,t.filters=De,t.getConfig=Ge,t.helpers=ye,t.nativeHelpers=ke,t.parse=w,t.render=function(A,x,F,P){var v=Ge(F||{});if(!v.async)return gt(A,v)(x,v);if(!P){if(typeof r=="function")return new r(function(y,H){try{y(gt(A,v)(x,v))}catch(J){H(J)}});throw e("Please provide a callback function, this env doesn't support Promises")}try{gt(A,v)(x,v,P)}catch(y){return P(y)}},t.templates=te,Object.defineProperty(t,"__esModule",{value:!0})})});var of=Is((rf,ac)=>{"use strict";(function(t){if(typeof rf=="object"&&typeof ac<"u")ac.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,n;return function r(i,o,s){function a(g,p){if(!o[g]){if(!i[g]){var E=typeof ei=="function"&&ei;if(!p&&E)return E(g,!0);if(u)return u(g,!0);var w=new Error("Cannot find module '"+g+"'");throw w.code="MODULE_NOT_FOUND",w}var N=o[g]={exports:{}};i[g][0].call(N.exports,function(M){var L=i[g][1][M];return a(L||M)},N,N.exports,r,i,o,s)}return o[g].exports}for(var u=typeof ei=="function"&&ei,d=0;d<s.length;d++)a(s[d]);return a}({1:[function(r,i,o){(function(s){"use strict";var a=s.MutationObserver||s.WebKitMutationObserver,u;if(a){var d=0,g=new a(M),p=s.document.createTextNode("");g.observe(p,{characterData:!0}),u=function(){p.data=d=++d%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var E=new s.MessageChannel;E.port1.onmessage=M,u=function(){E.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?u=function(){var j=s.document.createElement("script");j.onreadystatechange=function(){M(),j.onreadystatechange=null,j.parentNode.removeChild(j),j=null},s.document.documentElement.appendChild(j)}:u=function(){setTimeout(M,0)};var w,N=[];function M(){w=!0;for(var j,K,se=N.length;se;){for(K=N,N=[],j=-1;++j<se;)K[j]();se=N.length}w=!1}i.exports=L;function L(j){N.push(j)===1&&!w&&u()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(r,i,o){"use strict";var s=r(1);function a(){}var u={},d=["REJECTED"],g=["FULFILLED"],p=["PENDING"];i.exports=E;function E(U){if(typeof U!="function")throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,U!==a&&L(this,U)}E.prototype.catch=function(U){return this.then(null,U)},E.prototype.then=function(U,he){if(typeof U!="function"&&this.state===g||typeof he!="function"&&this.state===d)return this;var te=new this.constructor(a);if(this.state!==p){var ye=this.state===g?U:he;N(te,ye,this.outcome)}else this.queue.push(new w(te,U,he));return te};function w(U,he,te){this.promise=U,typeof he=="function"&&(this.onFulfilled=he,this.callFulfilled=this.otherCallFulfilled),typeof te=="function"&&(this.onRejected=te,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(U){u.resolve(this.promise,U)},w.prototype.otherCallFulfilled=function(U){N(this.promise,this.onFulfilled,U)},w.prototype.callRejected=function(U){u.reject(this.promise,U)},w.prototype.otherCallRejected=function(U){N(this.promise,this.onRejected,U)};function N(U,he,te){s(function(){var ye;try{ye=he(te)}catch(ke){return u.reject(U,ke)}ye===U?u.reject(U,new TypeError("Cannot resolve promise with itself")):u.resolve(U,ye)})}u.resolve=function(U,he){var te=j(M,he);if(te.status==="error")return u.reject(U,te.value);var ye=te.value;if(ye)L(U,ye);else{U.state=g,U.outcome=he;for(var ke=-1,De=U.queue.length;++ke<De;)U.queue[ke].callFulfilled(he)}return U},u.reject=function(U,he){U.state=d,U.outcome=he;for(var te=-1,ye=U.queue.length;++te<ye;)U.queue[te].callRejected(he);return U};function M(U){var he=U&&U.then;if(U&&(typeof U=="object"||typeof U=="function")&&typeof he=="function")return function(){he.apply(U,arguments)}}function L(U,he){var te=!1;function ye(Ge){te||(te=!0,u.reject(U,Ge))}function ke(Ge){te||(te=!0,u.resolve(U,Ge))}function De(){he(ke,ye)}var Le=j(De);Le.status==="error"&&ye(Le.value)}function j(U,he){var te={};try{te.value=U(he),te.status="success"}catch(ye){te.status="error",te.value=ye}return te}E.resolve=K;function K(U){return U instanceof this?U:u.resolve(new this(a),U)}E.reject=se;function se(U){var he=new this(a);return u.reject(he,U)}E.all=X;function X(U){var he=this;if(Object.prototype.toString.call(U)!=="[object Array]")return this.reject(new TypeError("must be an array"));var te=U.length,ye=!1;if(!te)return this.resolve([]);for(var ke=new Array(te),De=0,Le=-1,Ge=new this(a);++Le<te;)Ye(U[Le],Le);return Ge;function Ye(gt,A){he.resolve(gt).then(x,function(F){ye||(ye=!0,u.reject(Ge,F))});function x(F){ke[A]=F,++De===te&&!ye&&(ye=!0,u.resolve(Ge,ke))}}}E.race=be;function be(U){var he=this;if(Object.prototype.toString.call(U)!=="[object Array]")return this.reject(new TypeError("must be an array"));var te=U.length,ye=!1;if(!te)return this.resolve([]);for(var ke=-1,De=new this(a);++ke<te;)Le(U[ke]);return De;function Le(Ge){he.resolve(Ge).then(function(Ye){ye||(ye=!0,u.resolve(De,Ye))},function(Ye){ye||(ye=!0,u.reject(De,Ye))})}}},{1:1}],3:[function(r,i,o){(function(s){"use strict";typeof s.Promise!="function"&&(s.Promise=r(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(r,i,o){"use strict";var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f};function a(f,b){if(!(f instanceof b))throw new TypeError("Cannot call a class as a function")}function u(){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 d=u();function g(){try{if(!d||!d.open)return!1;var f=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(!f||b)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function p(f,b){f=f||[],b=b||{};try{return new Blob(f,b)}catch(C){if(C.name!=="TypeError")throw C;for(var m=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,S=new m,I=0;I<f.length;I+=1)S.append(f[I]);return S.getBlob(b.type)}}typeof Promise>"u"&&r(3);var E=Promise;function w(f,b){b&&f.then(function(m){b(null,m)},function(m){b(m)})}function N(f,b,m){typeof b=="function"&&f.then(b),typeof m=="function"&&f.catch(m)}function M(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}function L(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var j="local-forage-detect-blob-support",K=void 0,se={},X=Object.prototype.toString,be="readonly",U="readwrite";function he(f){for(var b=f.length,m=new ArrayBuffer(b),S=new Uint8Array(m),I=0;I<b;I++)S[I]=f.charCodeAt(I);return m}function te(f){return new E(function(b){var m=f.transaction(j,U),S=p([""]);m.objectStore(j).put(S,"key"),m.onabort=function(I){I.preventDefault(),I.stopPropagation(),b(!1)},m.oncomplete=function(){var I=navigator.userAgent.match(/Chrome\/(\d+)/),C=navigator.userAgent.match(/Edge\//);b(C||!I||parseInt(I[1],10)>=43)}}).catch(function(){return!1})}function ye(f){return typeof K=="boolean"?E.resolve(K):te(f).then(function(b){return K=b,K})}function ke(f){var b=se[f.name],m={};m.promise=new E(function(S,I){m.resolve=S,m.reject=I}),b.deferredOperations.push(m),b.dbReady?b.dbReady=b.dbReady.then(function(){return m.promise}):b.dbReady=m.promise}function De(f){var b=se[f.name],m=b.deferredOperations.pop();if(m)return m.resolve(),m.promise}function Le(f,b){var m=se[f.name],S=m.deferredOperations.pop();if(S)return S.reject(b),S.promise}function Ge(f,b){return new E(function(m,S){if(se[f.name]=se[f.name]||J(),f.db)if(b)ke(f),f.db.close();else return m(f.db);var I=[f.name];b&&I.push(f.version);var C=d.open.apply(d,I);b&&(C.onupgradeneeded=function(R){var B=C.result;try{B.createObjectStore(f.storeName),R.oldVersion<=1&&B.createObjectStore(j)}catch($){if($.name==="ConstraintError")console.warn('The database "'+f.name+'" has been upgraded from version '+R.oldVersion+" to version "+R.newVersion+', but the storage "'+f.storeName+'" already exists.');else throw $}}),C.onerror=function(R){R.preventDefault(),S(C.error)},C.onsuccess=function(){var R=C.result;R.onversionchange=function(B){B.target.close()},m(R),De(f)}})}function Ye(f){return Ge(f,!1)}function gt(f){return Ge(f,!0)}function A(f,b){if(!f.db)return!0;var m=!f.db.objectStoreNames.contains(f.storeName),S=f.version<f.db.version,I=f.version>f.db.version;if(S&&(f.version!==b&&console.warn('The database "'+f.name+`" can't be downgraded from version `+f.db.version+" to version "+f.version+"."),f.version=f.db.version),I||m){if(m){var C=f.db.version+1;C>f.version&&(f.version=C)}return!0}return!1}function x(f){return new E(function(b,m){var S=new FileReader;S.onerror=m,S.onloadend=function(I){var C=btoa(I.target.result||"");b({__local_forage_encoded_blob:!0,data:C,type:f.type})},S.readAsBinaryString(f)})}function F(f){var b=he(atob(f.data));return p([b],{type:f.type})}function P(f){return f&&f.__local_forage_encoded_blob}function v(f){var b=this,m=b._initReady().then(function(){var S=se[b._dbInfo.name];if(S&&S.dbReady)return S.dbReady});return N(m,f,f),m}function y(f){ke(f);for(var b=se[f.name],m=b.forages,S=0;S<m.length;S++){var I=m[S];I._dbInfo.db&&(I._dbInfo.db.close(),I._dbInfo.db=null)}return f.db=null,Ye(f).then(function(C){return f.db=C,A(f)?gt(f):C}).then(function(C){f.db=b.db=C;for(var R=0;R<m.length;R++)m[R]._dbInfo.db=C}).catch(function(C){throw Le(f,C),C})}function H(f,b,m,S){S===void 0&&(S=1);try{var I=f.db.transaction(f.storeName,b);m(null,I)}catch(C){if(S>0&&(!f.db||C.name==="InvalidStateError"||C.name==="NotFoundError"))return E.resolve().then(function(){if(!f.db||C.name==="NotFoundError"&&!f.db.objectStoreNames.contains(f.storeName)&&f.version<=f.db.version)return f.db&&(f.version=f.db.version+1),gt(f)}).then(function(){return y(f).then(function(){H(f,b,m,S-1)})}).catch(m);m(C)}}function J(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function re(f){var b=this,m={db:null};if(f)for(var S in f)m[S]=f[S];var I=se[m.name];I||(I=J(),se[m.name]=I),I.forages.push(b),b._initReady||(b._initReady=b.ready,b.ready=v);var C=[];function R(){return E.resolve()}for(var B=0;B<I.forages.length;B++){var $=I.forages[B];$!==b&&C.push($._initReady().catch(R))}var G=I.forages.slice(0);return E.all(C).then(function(){return m.db=I.db,Ye(m)}).then(function(z){return m.db=z,A(m,b._defaultConfig.version)?gt(m):z}).then(function(z){m.db=I.db=z,b._dbInfo=m;for(var ie=0;ie<G.length;ie++){var xe=G[ie];xe!==b&&(xe._dbInfo.db=m.db,xe._dbInfo.version=m.version)}})}function oe(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){H(m._dbInfo,be,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=$.get(f);G.onsuccess=function(){var z=G.result;z===void 0&&(z=null),P(z)&&(z=F(z)),I(z)},G.onerror=function(){C(G.error)}}catch(z){C(z)}})}).catch(C)});return w(S,b),S}function ue(f,b){var m=this,S=new E(function(I,C){m.ready().then(function(){H(m._dbInfo,be,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=$.openCursor(),z=1;G.onsuccess=function(){var ie=G.result;if(ie){var xe=ie.value;P(xe)&&(xe=F(xe));var Ue=f(xe,ie.key,z++);Ue!==void 0?I(Ue):ie.continue()}else I()},G.onerror=function(){C(G.error)}}catch(ie){C(ie)}})}).catch(C)});return w(S,b),S}function Q(f,b,m){var S=this;f=M(f);var I=new E(function(C,R){var B;S.ready().then(function(){return B=S._dbInfo,X.call(b)==="[object Blob]"?ye(B.db).then(function($){return $?b:x(b)}):b}).then(function($){H(S._dbInfo,U,function(G,z){if(G)return R(G);try{var ie=z.objectStore(S._dbInfo.storeName);$===null&&($=void 0);var xe=ie.put($,f);z.oncomplete=function(){$===void 0&&($=null),C($)},z.onabort=z.onerror=function(){var Ue=xe.error?xe.error:xe.transaction.error;R(Ue)}}catch(Ue){R(Ue)}})}).catch(R)});return w(I,m),I}function ae(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){H(m._dbInfo,U,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=$.delete(f);B.oncomplete=function(){I()},B.onerror=function(){C(G.error)},B.onabort=function(){var z=G.error?G.error:G.transaction.error;C(z)}}catch(z){C(z)}})}).catch(C)});return w(S,b),S}function ee(f){var b=this,m=new E(function(S,I){b.ready().then(function(){H(b._dbInfo,U,function(C,R){if(C)return I(C);try{var B=R.objectStore(b._dbInfo.storeName),$=B.clear();R.oncomplete=function(){S()},R.onabort=R.onerror=function(){var G=$.error?$.error:$.transaction.error;I(G)}}catch(G){I(G)}})}).catch(I)});return w(m,f),m}function pe(f){var b=this,m=new E(function(S,I){b.ready().then(function(){H(b._dbInfo,be,function(C,R){if(C)return I(C);try{var B=R.objectStore(b._dbInfo.storeName),$=B.count();$.onsuccess=function(){S($.result)},$.onerror=function(){I($.error)}}catch(G){I(G)}})}).catch(I)});return w(m,f),m}function ce(f,b){var m=this,S=new E(function(I,C){if(f<0){I(null);return}m.ready().then(function(){H(m._dbInfo,be,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=!1,z=$.openKeyCursor();z.onsuccess=function(){var ie=z.result;if(!ie){I(null);return}f===0||G?I(ie.key):(G=!0,ie.advance(f))},z.onerror=function(){C(z.error)}}catch(ie){C(ie)}})}).catch(C)});return w(S,b),S}function me(f){var b=this,m=new E(function(S,I){b.ready().then(function(){H(b._dbInfo,be,function(C,R){if(C)return I(C);try{var B=R.objectStore(b._dbInfo.storeName),$=B.openKeyCursor(),G=[];$.onsuccess=function(){var z=$.result;if(!z){S(G);return}G.push(z.key),z.continue()},$.onerror=function(){I($.error)}}catch(z){I(z)}})}).catch(I)});return w(m,f),m}function ge(f,b){b=L.apply(this,arguments);var m=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||m.name,f.storeName=f.storeName||m.storeName);var S=this,I;if(!f.name)I=E.reject("Invalid arguments");else{var C=f.name===m.name&&S._dbInfo.db,R=C?E.resolve(S._dbInfo.db):Ye(f).then(function(B){var $=se[f.name],G=$.forages;$.db=B;for(var z=0;z<G.length;z++)G[z]._dbInfo.db=B;return B});f.storeName?I=R.then(function(B){if(B.objectStoreNames.contains(f.storeName)){var $=B.version+1;ke(f);var G=se[f.name],z=G.forages;B.close();for(var ie=0;ie<z.length;ie++){var xe=z[ie];xe._dbInfo.db=null,xe._dbInfo.version=$}var Ue=new E(function(He,st){var tt=d.open(f.name,$);tt.onerror=function(Wt){var Qr=tt.result;Qr.close(),st(Wt)},tt.onupgradeneeded=function(){var Wt=tt.result;Wt.deleteObjectStore(f.storeName)},tt.onsuccess=function(){var Wt=tt.result;Wt.close(),He(Wt)}});return Ue.then(function(He){G.db=He;for(var st=0;st<z.length;st++){var tt=z[st];tt._dbInfo.db=He,De(tt._dbInfo)}}).catch(function(He){throw(Le(f,He)||E.resolve()).catch(function(){}),He})}}):I=R.then(function(B){ke(f);var $=se[f.name],G=$.forages;B.close();for(var z=0;z<G.length;z++){var ie=G[z];ie._dbInfo.db=null}var xe=new E(function(Ue,He){var st=d.deleteDatabase(f.name);st.onerror=function(){var tt=st.result;tt&&tt.close(),He(st.error)},st.onblocked=function(){console.warn('dropInstance blocked for database "'+f.name+'" until all open connections are closed')},st.onsuccess=function(){var tt=st.result;tt&&tt.close(),Ue(tt)}});return xe.then(function(Ue){$.db=Ue;for(var He=0;He<G.length;He++){var st=G[He];De(st._dbInfo)}}).catch(function(Ue){throw(Le(f,Ue)||E.resolve()).catch(function(){}),Ue})})}return w(I,b),I}var _e={_driver:"asyncStorage",_initStorage:re,_support:g(),iterate:ue,getItem:oe,setItem:Q,removeItem:ae,clear:ee,length:pe,key:ce,keys:me,dropInstance:ge};function h(){return typeof openDatabase=="function"}var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l="~~local_forage_type~",_=/^~~local_forage_type~([^~]+)~/,T="__lfsc__:",D=T.length,V="arbf",ve="blob",Ie="si08",we="ui08",Ve="uic8",Be="si16",qe="si32",kt="ur16",Gt="ui32",bn="fl32",St="fl64",Vt=D+V.length,Vi=Object.prototype.toString;function dl(f){var b=f.length*.75,m=f.length,S,I=0,C,R,B,$;f[f.length-1]==="="&&(b--,f[f.length-2]==="="&&b--);var G=new ArrayBuffer(b),z=new Uint8Array(G);for(S=0;S<m;S+=4)C=c.indexOf(f[S]),R=c.indexOf(f[S+1]),B=c.indexOf(f[S+2]),$=c.indexOf(f[S+3]),z[I++]=C<<2|R>>4,z[I++]=(R&15)<<4|B>>2,z[I++]=(B&3)<<6|$&63;return G}function Es(f){var b=new Uint8Array(f),m="",S;for(S=0;S<b.length;S+=3)m+=c[b[S]>>2],m+=c[(b[S]&3)<<4|b[S+1]>>4],m+=c[(b[S+1]&15)<<2|b[S+2]>>6],m+=c[b[S+2]&63];return b.length%3===2?m=m.substring(0,m.length-1)+"=":b.length%3===1&&(m=m.substring(0,m.length-2)+"=="),m}function qp(f,b){var m="";if(f&&(m=Vi.call(f)),f&&(m==="[object ArrayBuffer]"||f.buffer&&Vi.call(f.buffer)==="[object ArrayBuffer]")){var S,I=T;f instanceof ArrayBuffer?(S=f,I+=V):(S=f.buffer,m==="[object Int8Array]"?I+=Ie:m==="[object Uint8Array]"?I+=we:m==="[object Uint8ClampedArray]"?I+=Ve:m==="[object Int16Array]"?I+=Be:m==="[object Uint16Array]"?I+=kt:m==="[object Int32Array]"?I+=qe:m==="[object Uint32Array]"?I+=Gt:m==="[object Float32Array]"?I+=bn:m==="[object Float64Array]"?I+=St:b(new Error("Failed to get type for BinaryArray"))),b(I+Es(S))}else if(m==="[object Blob]"){var C=new FileReader;C.onload=function(){var R=l+f.type+"~"+Es(this.result);b(T+ve+R)},C.readAsArrayBuffer(f)}else try{b(JSON.stringify(f))}catch(R){console.error("Couldn't convert value into a JSON string: ",f),b(null,R)}}function Zp(f){if(f.substring(0,D)!==T)return JSON.parse(f);var b=f.substring(Vt),m=f.substring(D,Vt),S;if(m===ve&&_.test(b)){var I=b.match(_);S=I[1],b=b.substring(I[0].length)}var C=dl(b);switch(m){case V:return C;case ve:return p([C],{type:S});case Ie:return new Int8Array(C);case we:return new Uint8Array(C);case Ve:return new Uint8ClampedArray(C);case Be:return new Int16Array(C);case kt:return new Uint16Array(C);case qe:return new Int32Array(C);case Gt:return new Uint32Array(C);case bn:return new Float32Array(C);case St:return new Float64Array(C);default:throw new Error("Unkown type: "+m)}}var bs={serialize:qp,deserialize:Zp,stringToBuffer:dl,bufferToString:Es};function fl(f,b,m,S){f.executeSql("CREATE TABLE IF NOT EXISTS "+b.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],m,S)}function Jp(f){var b=this,m={db:null};if(f)for(var S in f)m[S]=typeof f[S]!="string"?f[S].toString():f[S];var I=new E(function(C,R){try{m.db=openDatabase(m.name,String(m.version),m.description,m.size)}catch(B){return R(B)}m.db.transaction(function(B){fl(B,m,function(){b._dbInfo=m,C()},function($,G){R(G)})},R)});return m.serializer=bs,I}function Vn(f,b,m,S,I,C){f.executeSql(m,S,I,function(R,B){B.code===B.SYNTAX_ERR?R.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function($,G){G.rows.length?C($,B):fl($,b,function(){$.executeSql(m,S,I,C)},C)},C):C(R,B)},C)}function Qp(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"SELECT * FROM "+R.storeName+" WHERE key = ? LIMIT 1",[f],function($,G){var z=G.rows.length?G.rows.item(0).value:null;z&&(z=R.serializer.deserialize(z)),I(z)},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function eh(f,b){var m=this,S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"SELECT * FROM "+R.storeName,[],function($,G){for(var z=G.rows,ie=z.length,xe=0;xe<ie;xe++){var Ue=z.item(xe),He=Ue.value;if(He&&(He=R.serializer.deserialize(He)),He=f(He,Ue.key,xe+1),He!==void 0){I(He);return}}I()},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function pl(f,b,m,S){var I=this;f=M(f);var C=new E(function(R,B){I.ready().then(function(){b===void 0&&(b=null);var $=b,G=I._dbInfo;G.serializer.serialize(b,function(z,ie){ie?B(ie):G.db.transaction(function(xe){Vn(xe,G,"INSERT OR REPLACE INTO "+G.storeName+" (key, value) VALUES (?, ?)",[f,z],function(){R($)},function(Ue,He){B(He)})},function(xe){if(xe.code===xe.QUOTA_ERR){if(S>0){R(pl.apply(I,[f,$,m,S-1]));return}B(xe)}})})}).catch(B)});return w(C,m),C}function th(f,b,m){return pl.apply(this,[f,b,m,1])}function nh(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"DELETE FROM "+R.storeName+" WHERE key = ?",[f],function(){I()},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function rh(f){var b=this,m=new E(function(S,I){b.ready().then(function(){var C=b._dbInfo;C.db.transaction(function(R){Vn(R,C,"DELETE FROM "+C.storeName,[],function(){S()},function(B,$){I($)})})}).catch(I)});return w(m,f),m}function ih(f){var b=this,m=new E(function(S,I){b.ready().then(function(){var C=b._dbInfo;C.db.transaction(function(R){Vn(R,C,"SELECT COUNT(key) as c FROM "+C.storeName,[],function(B,$){var G=$.rows.item(0).c;S(G)},function(B,$){I($)})})}).catch(I)});return w(m,f),m}function oh(f,b){var m=this,S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"SELECT key FROM "+R.storeName+" WHERE id = ? LIMIT 1",[f+1],function($,G){var z=G.rows.length?G.rows.item(0).key:null;I(z)},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function sh(f){var b=this,m=new E(function(S,I){b.ready().then(function(){var C=b._dbInfo;C.db.transaction(function(R){Vn(R,C,"SELECT key FROM "+C.storeName,[],function(B,$){for(var G=[],z=0;z<$.rows.length;z++)G.push($.rows.item(z).key);S(G)},function(B,$){I($)})})}).catch(I)});return w(m,f),m}function ah(f){return new E(function(b,m){f.transaction(function(S){S.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(I,C){for(var R=[],B=0;B<C.rows.length;B++)R.push(C.rows.item(B).name);b({db:f,storeNames:R})},function(I,C){m(C)})},function(S){m(S)})})}function ch(f,b){b=L.apply(this,arguments);var m=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||m.name,f.storeName=f.storeName||m.storeName);var S=this,I;return f.name?I=new E(function(C){var R;f.name===m.name?R=S._dbInfo.db:R=openDatabase(f.name,"","",0),f.storeName?C({db:R,storeNames:[f.storeName]}):C(ah(R))}).then(function(C){return new E(function(R,B){C.db.transaction(function($){function G(Ue){return new E(function(He,st){$.executeSql("DROP TABLE IF EXISTS "+Ue,[],function(){He()},function(tt,Wt){st(Wt)})})}for(var z=[],ie=0,xe=C.storeNames.length;ie<xe;ie++)z.push(G(C.storeNames[ie]));E.all(z).then(function(){R()}).catch(function(Ue){B(Ue)})},function($){B($)})})}):I=E.reject("Invalid arguments"),w(I,b),I}var lh={_driver:"webSQLStorage",_initStorage:Jp,_support:h(),iterate:eh,getItem:Qp,setItem:th,removeItem:nh,clear:rh,length:ih,key:oh,keys:sh,dropInstance:ch};function uh(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function hl(f,b){var m=f.name+"/";return f.storeName!==b.storeName&&(m+=f.storeName+"/"),m}function dh(){var f="_localforage_support_test";try{return localStorage.setItem(f,!0),localStorage.removeItem(f),!1}catch{return!0}}function fh(){return!dh()||localStorage.length>0}function ph(f){var b=this,m={};if(f)for(var S in f)m[S]=f[S];return m.keyPrefix=hl(f,b._defaultConfig),fh()?(b._dbInfo=m,m.serializer=bs,E.resolve()):E.reject()}function hh(f){var b=this,m=b.ready().then(function(){for(var S=b._dbInfo.keyPrefix,I=localStorage.length-1;I>=0;I--){var C=localStorage.key(I);C.indexOf(S)===0&&localStorage.removeItem(C)}});return w(m,f),m}function mh(f,b){var m=this;f=M(f);var S=m.ready().then(function(){var I=m._dbInfo,C=localStorage.getItem(I.keyPrefix+f);return C&&(C=I.serializer.deserialize(C)),C});return w(S,b),S}function gh(f,b){var m=this,S=m.ready().then(function(){for(var I=m._dbInfo,C=I.keyPrefix,R=C.length,B=localStorage.length,$=1,G=0;G<B;G++){var z=localStorage.key(G);if(z.indexOf(C)===0){var ie=localStorage.getItem(z);if(ie&&(ie=I.serializer.deserialize(ie)),ie=f(ie,z.substring(R),$++),ie!==void 0)return ie}}});return w(S,b),S}function _h(f,b){var m=this,S=m.ready().then(function(){var I=m._dbInfo,C;try{C=localStorage.key(f)}catch{C=null}return C&&(C=C.substring(I.keyPrefix.length)),C});return w(S,b),S}function vh(f){var b=this,m=b.ready().then(function(){for(var S=b._dbInfo,I=localStorage.length,C=[],R=0;R<I;R++){var B=localStorage.key(R);B.indexOf(S.keyPrefix)===0&&C.push(B.substring(S.keyPrefix.length))}return C});return w(m,f),m}function yh(f){var b=this,m=b.keys().then(function(S){return S.length});return w(m,f),m}function Eh(f,b){var m=this;f=M(f);var S=m.ready().then(function(){var I=m._dbInfo;localStorage.removeItem(I.keyPrefix+f)});return w(S,b),S}function bh(f,b,m){var S=this;f=M(f);var I=S.ready().then(function(){b===void 0&&(b=null);var C=b;return new E(function(R,B){var $=S._dbInfo;$.serializer.serialize(b,function(G,z){if(z)B(z);else try{localStorage.setItem($.keyPrefix+f,G),R(C)}catch(ie){(ie.name==="QuotaExceededError"||ie.name==="NS_ERROR_DOM_QUOTA_REACHED")&&B(ie),B(ie)}})})});return w(I,m),I}function wh(f,b){if(b=L.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var m=this.config();f.name=f.name||m.name,f.storeName=f.storeName||m.storeName}var S=this,I;return f.name?I=new E(function(C){f.storeName?C(hl(f,S._defaultConfig)):C(f.name+"/")}).then(function(C){for(var R=localStorage.length-1;R>=0;R--){var B=localStorage.key(R);B.indexOf(C)===0&&localStorage.removeItem(B)}}):I=E.reject("Invalid arguments"),w(I,b),I}var Ch={_driver:"localStorageWrapper",_initStorage:ph,_support:uh(),iterate:gh,getItem:mh,setItem:bh,removeItem:Eh,clear:hh,length:yh,key:_h,keys:vh,dropInstance:wh},Sh=function(b,m){return b===m||typeof b=="number"&&typeof m=="number"&&isNaN(b)&&isNaN(m)},Th=function(b,m){for(var S=b.length,I=0;I<S;){if(Sh(b[I],m))return!0;I++}return!1},ml=Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"},Jr={},gl={},fr={INDEXEDDB:_e,WEBSQL:lh,LOCALSTORAGE:Ch},Ih=[fr.INDEXEDDB._driver,fr.WEBSQL._driver,fr.LOCALSTORAGE._driver],Bi=["dropInstance"],ws=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Bi),xh={description:"",driver:Ih.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Oh(f,b){f[b]=function(){var m=arguments;return f.ready().then(function(){return f[b].apply(f,m)})}}function Cs(){for(var f=1;f<arguments.length;f++){var b=arguments[f];if(b)for(var m in b)b.hasOwnProperty(m)&&(ml(b[m])?arguments[0][m]=b[m].slice():arguments[0][m]=b[m])}return arguments[0]}var Ah=function(){function f(b){a(this,f);for(var m in fr)if(fr.hasOwnProperty(m)){var S=fr[m],I=S._driver;this[m]=I,Jr[I]||this.defineDriver(S)}this._defaultConfig=Cs({},xh),this._config=Cs({},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 f.prototype.config=function(m){if((typeof m>"u"?"undefined":s(m))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var S in m){if(S==="storeName"&&(m[S]=m[S].replace(/\W/g,"_")),S==="version"&&typeof m[S]!="number")return new Error("Database version must be a number.");this._config[S]=m[S]}return"driver"in m&&m.driver?this.setDriver(this._config.driver):!0}else return typeof m=="string"?this._config[m]:this._config},f.prototype.defineDriver=function(m,S,I){var C=new E(function(R,B){try{var $=m._driver,G=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){B(G);return}for(var z=ws.concat("_initStorage"),ie=0,xe=z.length;ie<xe;ie++){var Ue=z[ie],He=!Th(Bi,Ue);if((He||m[Ue])&&typeof m[Ue]!="function"){B(G);return}}var st=function(){for(var Qr=function(Rh){return function(){var Mh=new Error("Method "+Rh+" is not implemented by the current driver"),_l=E.reject(Mh);return w(_l,arguments[arguments.length-1]),_l}},Ss=0,Nh=Bi.length;Ss<Nh;Ss++){var Ts=Bi[Ss];m[Ts]||(m[Ts]=Qr(Ts))}};st();var tt=function(Qr){Jr[$]&&console.info("Redefining LocalForage driver: "+$),Jr[$]=m,gl[$]=Qr,R()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(tt,B):tt(!!m._support):tt(!0)}catch(Wt){B(Wt)}});return N(C,S,I),C},f.prototype.driver=function(){return this._driver||null},f.prototype.getDriver=function(m,S,I){var C=Jr[m]?E.resolve(Jr[m]):E.reject(new Error("Driver not found."));return N(C,S,I),C},f.prototype.getSerializer=function(m){var S=E.resolve(bs);return N(S,m),S},f.prototype.ready=function(m){var S=this,I=S._driverSet.then(function(){return S._ready===null&&(S._ready=S._initDriver()),S._ready});return N(I,m,m),I},f.prototype.setDriver=function(m,S,I){var C=this;ml(m)||(m=[m]);var R=this._getSupportedDrivers(m);function B(){C._config.driver=C.driver()}function $(ie){return C._extend(ie),B(),C._ready=C._initStorage(C._config),C._ready}function G(ie){return function(){var xe=0;function Ue(){for(;xe<ie.length;){var He=ie[xe];return xe++,C._dbInfo=null,C._ready=null,C.getDriver(He).then($).catch(Ue)}B();var st=new Error("No available storage method found.");return C._driverSet=E.reject(st),C._driverSet}return Ue()}}var z=this._driverSet!==null?this._driverSet.catch(function(){return E.resolve()}):E.resolve();return this._driverSet=z.then(function(){var ie=R[0];return C._dbInfo=null,C._ready=null,C.getDriver(ie).then(function(xe){C._driver=xe._driver,B(),C._wrapLibraryMethodsWithReady(),C._initDriver=G(R)})}).catch(function(){B();var ie=new Error("No available storage method found.");return C._driverSet=E.reject(ie),C._driverSet}),N(this._driverSet,S,I),this._driverSet},f.prototype.supports=function(m){return!!gl[m]},f.prototype._extend=function(m){Cs(this,m)},f.prototype._getSupportedDrivers=function(m){for(var S=[],I=0,C=m.length;I<C;I++){var R=m[I];this.supports(R)&&S.push(R)}return S},f.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,S=ws.length;m<S;m++)Oh(this,ws[m])},f.prototype.createInstance=function(m){return new f(m)},f}(),Dh=new Ah;i.exports=Dh},{3:3}]},{},[4])(4)})});var Lh={schedule(t,e){let n=setTimeout(t,e);return()=>clearTimeout(n)}};function Fh(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function kh(t){return!!t&&t.nodeType===Node.ELEMENT_NODE}var Us;function Vh(t,e){if(!Us){let n=Element.prototype;Us=n.matches||n.matchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector||n.webkitMatchesSelector}return t.nodeType===Node.ELEMENT_NODE?Us.call(t,e):!1}function Bh(t){let e={};return t.forEach(({propName:n,templateName:r,transform:i})=>{e[Fh(r)]=[n,i]}),e}function Uh(t,e){return e.get(As).resolveComponentFactory(t).inputs}function Hh(t,e){let n=t.childNodes,r=e.map(()=>[]),i=-1;e.some((o,s)=>o==="*"?(i=s,!0):!1);for(let o=0,s=n.length;o<s;++o){let a=n[o],u=jh(a,e,i);u!==-1&&r[u].push(a)}return r}function jh(t,e,n){let r=n;return kh(t)&&e.some((i,o)=>i!=="*"&&Vh(t,i)?(r=o,!0):!1),r}var $h=10,Hs=class{componentFactory;inputMap=new Map;constructor(e,n){this.componentFactory=n.get(As).resolveComponentFactory(e);for(let r of this.componentFactory.inputs)this.inputMap.set(r.propName,r.templateName)}create(e){return new js(this.componentFactory,e,this.inputMap)}},js=class{componentFactory;injector;inputMap;eventEmitters=new wl(1);events=this.eventEmitters.pipe(Nl(e=>Hi(...e)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(e,n,r){this.componentFactory=e,this.injector=n,this.inputMap=r,this.ngZone=this.injector.get(Pt),this.appRef=this.injector.get(Wi),this.cdScheduler=n.get(Pl),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(e){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(e)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=Lh.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},$h))})}getInputValue(e){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(e):this.componentRef.instance[e])}setInputValue(e,n){if(this.componentRef===null){this.initialInputValues.set(e,n);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(e)??e,n),this.componentRef.hostView.dirty&&(this.componentRef.changeDetectorRef.markForRefresh(),this.cdScheduler.notify(6))})}initializeComponent(e){let n=Mt.create({providers:[],parent:this.injector}),r=Hh(e,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(n,r,e),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[e,n]of this.initialInputValues)this.setInputValue(e,n);this.initialInputValues.clear()}initializeOutputs(e){let n=this.componentFactory.outputs.map(({propName:r,templateName:i})=>{let o=e.instance[r];return new El(s=>{let a=o.subscribe(u=>s.next({name:i,value:u}));return()=>a.unsubscribe()})});this.eventEmitters.next(n)}runInZone(e){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(e):e()}},$s=class extends HTMLElement{ngElementEventsSubscription=null};function nu(t,e){let n=Uh(t,e.injector),r=e.strategyFactory||new Hs(t,e.injector),i=Bh(n);class o extends $s{injector;static observedAttributes=Object.keys(i);get ngElementStrategy(){if(!this._ngElementStrategy){let a=this._ngElementStrategy=r.create(this.injector||e.injector);n.forEach(({propName:u,transform:d})=>{if(!this.hasOwnProperty(u))return;let g=this[u];delete this[u],a.setInputValue(u,g,d)})}return this._ngElementStrategy}_ngElementStrategy;constructor(a){super(),this.injector=a}attributeChangedCallback(a,u,d,g){let[p,E]=i[a];this.ngElementStrategy.setInputValue(p,d,E)}connectedCallback(){let a=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),a=!0),this.ngElementStrategy.connect(this),a||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(a=>{let u=new CustomEvent(a.name,{detail:a.value});this.dispatchEvent(u)})}}return n.forEach(({propName:s,transform:a})=>{Object.defineProperty(o.prototype,s,{get(){return this.ngElementStrategy.getInputValue(s)},set(u){this.ngElementStrategy.setInputValue(s,u,a)},configurable:!0,enumerable:!0})}),o}var ru="9.13.1";var Xe=class t{static SDK_VERSION=ru;static SDK_VERSION_CODE;static SDK="WEB";static LOG_PREFIX="CooeeSDK";static COOEE="cooee";static SESSION_STORAGE_SCROLL_ID="sleid";static IDLE_TIME_IN_SECONDS=30*60;static IN_APP_WRAPPER_NAME="cooee-wrapper";static IN_APP_CONTAINER_NAME="cooee-container";static IN_APP_DEFAULT_PADDING=15;static EVENT_SCREEN_VIEW="CE Screen View";static EVENT_APP_BACKGROUND="CE App Background";static EVENT_TRIGGER_DISPLAYED="CE Trigger Displayed";static EVENT_CAMPAIGN_HOLDOUT="CE Campaign Holdout";static EVENT_CAMPAIGN_REJECTED="CE Campaign Rejected";static EVENT_CAMPAIGN_FAILED="CE Campaign Failed";static EVENT_TRIGGER_CLOSED="CE Trigger Closed";static EVENT_SCROLL="CE Scroll";static EVENT_TRIGGER_CLICKED="CE Trigger Clicked";static EVENT_FORM_SUBMITTED="CE Form Submitted";static EVENT_EXPERIMENT_START="CE Experiment Start";static EVENT_VIDEO_DIALOG_CLOSED="CE Video Dialog Closed";static EVENT_VIDEO_DIALOG_OPENED="CE Video Dialog Opened";static EVENT_VIDEO_CHANGE="CE Video Changed";static EVENT_LAST_VIDEO_ENDED="CE Last Video Ended";static EVENT_VIDEO_MUTED="CE Video Muted";static EVENT_VIDEO_UNMUTED="CE Video Unmuted";static EVENT_ADD_TO_CART_CLICKED="CE Add To Cart Clicked";static EVENT_VIEW_ITEM_CLICKED="CE View Item Clicked";static EVENT_MORE_ITEM_INFO_CLICKED="CE More Item Info Clicked";static EVENT_OPEN_CART_CLICKED="CE Open Cart Clicked";static EVENT_ADD_TO_CART="Add To Cart";static EVENT_REMOVE_FROM_CART="Remove From Cart";static EVENT_VIEW_ITEM="View Item";static EVENT_VIEW_CART="View Cart";static EVENT_OPEN_CART="Open Cart";static EVENT_VIEW_COLLECTION="View Collection";static EVENT_BUY_NOW_CLICKED="Buy Now Clicked";static EVENT_CHECKOUT_STARTED="Checkout Started";static EVENT_REVIEW_CLICKED="Review Clicked";static EVENT_ITEM_THUMBNAIL_CLICKED="Item Thumbnail Clicked";static JS_LOAD_WHITELIST_EVENTS=[this.EVENT_VIEW_ITEM,this.EVENT_VIEW_CART,this.EVENT_VIEW_COLLECTION];static HASH_INITIATE_CHECKOUT="initiate-checkout";static HASH_OPEN_CART_DRAWER="open-cart-drawer";static ADD_BUNDLE_CTA_INBOUND_EVENT="letscooee:inbound:cta:add-bundle";static CTA_OPEN_CART_EVENT="letscooee:outbound:open-cart";static CTA_AFTER_REFRESH_UI="letscooee:outbound:refresh-ui";static POPUP_ACTIVITY_EVENT="letscooee:outbound:popup-activities";static THIRD_PARTY_CHECKOUT_EVENT="letscooee:outbound:third-party-initiate-checkout";static CAMPAIGN_DISPLAYED_ACTIVITY="DISPLAYED";static CAMPAIGN_CLICKED_ACTIVITY="CLICKED";static CAMPAIGN_CLOSED_ACTIVITY="CLOSED";static BLACKLISTED_PAGE_NAMES=["collection","product","cart"];static API_CALL_MAX_ATTEMPTS=3;static API_CALL_RETRY_DELAY=1e3;static PLACEHOLDER_IMAGE="https://cdn.global.letscooee.com/images/placeholders/product.png";static CART_UPDATE_BROADCAST="CART_UPDATE";static GRAPHQL_VERSION="2024-10";static GRAPHQL_API_PATH=`/api/${this.GRAPHQL_VERSION}/graphql.json`;static SHADOW_SPLITTER=":shadow";static CAMPAIGN_ATTRIBUTE="_letscooee_campaign";static CONTENT_ATTRIBUTE="_letscooee_content";static VIA="_via";static PAYMENT_MODAL_DETAILS=[{identifier:"#flo-checkout-wrapper",gateway:"Shopflow"},{identifier:"#fastrr-main-container",gateway:"Shiprocket"},{identifier:"#gokwik-modal-wrapper",gateway:"Gokwik"},{identifier:"#zecpe",gateway:"Ecom 360"}];static{let e=t.SDK_VERSION.split(".").map(n=>n.padStart(2,"0")).join("");t.SDK_VERSION_CODE=parseInt(e,10)}};var Dn={apiURL:"https://api.sdk.letscooee.com",debug:!1,mode:"production",styleURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${Xe.SDK_VERSION}/dist/widget.min.css`,widgetURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${Xe.SDK_VERSION}/dist/widget.min.js`};var Ut=ti(ou());var ut=class{static log(...e){Ut.default.info(...e)}static debug(...e){Ut.default.debug(...e)}static error(...e){Ut.default.error(...e)}static warn(...e){Ut.default.warn(...e)}static info(...e){Ut.default.info(...e)}static trace(...e){Ut.default.trace(...e)}};function su(t=Xe.LOG_PREFIX){Ut.default.useDefaults({formatter:function(n){n.unshift(`${t} (v${Xe.SDK_VERSION}):`)}});let e=Wh();(e==="1"||e==="on")&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?Ut.default.setLevel(Ut.default[localStorage.cooeeLogLevel]):Ut.default.setLevel(Dn.debug?Ut.default.TRACE:Ut.default.OFF)}function Wh(){return new URL(location.href).searchParams?.get("cooee-debug")}var ki=ti(Qi());var cu={providers:[$l()]};var zh={"[class.ng-untouched]":"isUntouched","[class.ng-touched]":"isTouched","[class.ng-pristine]":"isPristine","[class.ng-dirty]":"isDirty","[class.ng-valid]":"isValid","[class.ng-invalid]":"isInvalid","[class.ng-pending]":"isPending"},KE=Ce(O({},zh),{"[class.ng-submitted]":"isSubmitted"});var Kh=new nn("",{providedIn:"root",factory:()=>du}),du="always";var Xh=(()=>{class t{static \u0275fac=function(r){return new(r||t)};static \u0275mod=Xn({type:t});static \u0275inj=zn({})}return t})();var fu=(()=>{class t{static withConfig(n){return{ngModule:t,providers:[{provide:Kh,useValue:n.callSetDisabledState??du}]}}static \u0275fac=function(r){return new(r||t)};static \u0275mod=Xn({type:t});static \u0275inj=zn({imports:[Xh]})}return t})();var zt=class{static SWIPER_CSS="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css";static injectScriptURL(e,n){if(!e)return;let r=document.createElement("script");r.id=n??"",r.src=e,r.type="module",document.head.appendChild(r)}static injectRawScript(e){if(!e)return;let n=document.createElement("script");n.id="cooee-app-script",n.innerHTML=e,document.head.appendChild(n)}static injectRawCSS(e,n=document.head){if(!e)return;let r=document.createElement("style");r.textContent=e,n.appendChild(r)}static injectSwiperCSS(e=document.head){this.injectStylesheet(this.SWIPER_CSS,e)}static injectStylesheet(e,n=document.head){if(!e)return;let r=document.createElement("link");r.rel="stylesheet",r.href=e,e===this.SWIPER_CSS&&(r.crossOrigin="anonymous",r.onload=i=>{let s=i.currentTarget?.sheet?.cssRules;if(s){for(let a of s)if(a.type==CSSRule.FONT_FACE_RULE){let u=e.split("/"),d=u.slice(0,u.length-1).join("/"),g=a.cssText;g=g.replace(/url\s*\(\s*['"]?(?!((\/)|((?:https?:)?\/\/)|(?:data:?:)))([^'")]+)['"]?\s*\)/g,`url("${d}/$4")`);let p=document.createElement("style");p.appendChild(document.createTextNode(g)),document.head.appendChild(p)}}}),n.appendChild(r)}static async loadSwiperScript(){window.CooeeSDK.Swiper||(window.CooeeSDK.Swiper=(await import("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.mjs")).Swiper)}};var Kt=class t{cooeeEvent=new at;cooeeCTA=new at;elementRef=q(Tt);_engagementTrigger=Lt(null);_triggerContext=Lt(null);constructor(){this.elementRef.nativeElement.update=this.update.bind(this)}get classes(){let e=["letscooee-widget"],n=this._engagementTrigger();return e.push(`widget-${n?.shortID}`),e}get triggerContext(){return this._triggerContext()}set triggerContext(e){this._triggerContext.set(e),this._engagementTrigger.set(e.triggerData),this.engagementTriggerReceived(e.triggerData)}get engagementTrigger(){return this._engagementTrigger()}ngOnInit(){ut.debug("Init",this.constructor.name);let e=this.elementRef.nativeElement.shadowRoot;e&&(zt.injectStylesheet(Dn.styleURL,e),zt.injectRawCSS(window.CooeeSDK.config.website.commonCSS,e))}ngOnDestroy(){ut.debug("Destroying",this.constructor.name)}sendEventToRenderer(e){this.cooeeEvent.emit(e)}executeCTAViaRenderer(e){this.cooeeCTA.emit(e)}static \u0275fac=function(n){return new(n||t)};static \u0275cmp=Me({type:t,selectors:[["ng-component"]],hostVars:2,hostBindings:function(n,r){n&2&&Bl(r.classes)},inputs:{triggerContext:"triggerContext"},outputs:{cooeeEvent:"cooeeEvent",cooeeCTA:"cooeeCTA"},decls:0,vars:0,template:function(n,r){},encapsulation:2})};var qh=(t,e)=>({"--option-color":t,"background-color":e}),pu=(t,e)=>e.id;function Zh(t,e){if(t&1&&(W(0,"span",6),Ae(1),Y()),t&2){Z();let n=Ke(1);k(),ln(n)}}function Jh(t,e){if(t&1){let n=ze();ct(0)(1)(2),W(3,"button",5),Pe("click",function(){let i=Ne(n).$implicit,o=Z().$implicit,s=Z();return Re(s.onOptionChange(o,i))}),Oe(4,Zh,2,1,"span",6),Y()}if(t&2){let n,r=e.$implicit,i=Z().$implicit,o=Ke(1),s=Z(),a=r.name;k();let u=vt(r.displayName||r.name),d=o?(n=r.hexColor)!==null&&n!==void 0?n:a:"";k(2),Ps("color-type",o)("selected",s.selectedOptions()[i.name]===a),de("disabled",r.disabled)("title",u)("ngStyle",zi(10,qh,d,d)),wn("data-value",a),k(),Te(o?-1:4)}}function Qh(t,e){if(t&1&&(W(0,"div"),ct(1),W(2,"div",1),Ae(3),Y(),W(4,"div",2),Ae(5),Y(),W(6,"div",3),nt(7,Jh,5,13,"button",4,pu),Y()()),t&2){let n=e.$implicit,r=Z();Ul("option-group ",n.name.toLowerCase(),""),k(),vt(r.hasHexColors(n)),k(2),It("",n.name,":"),k(2),ln(r.selectedOptions()[n.name]),k(2),rt(n.optionValues)}}var yr=class t extends Kt{selectedVariant=new at;item=hr.required();selectedOptions=Lt({});options=vr(()=>{let e=this.item();if(!e.options||e.vars.length===1)return[];if(window.cooeeManipulateProduct)try{window.cooeeManipulateProduct(e,this.engagementTrigger)}catch(n){ut.error(n)}return e.options});matchedVariant=vr(()=>{let e=this.item(),n=this.selectedOptions();return e.vars.find(r=>e.options.every(i=>n[i.name]===r.selectedOptions.find(o=>o.name===i.name)?.value))});constructor(){super(),ks(()=>{let n=this.matchedVariant();n&&(this.item().setSelectedVariant(n),this.selectedVariant.emit(n))});let e=ks(()=>{let n=this.item();if(!n?.options)return;let r=O({},this.selectedOptions());n.options.forEach(i=>{let o=n.vars[0]?.selectedOptions.find(s=>s.name===i.name)?.value;o&&(r[i.name]=o)}),this.selectedOptions.set(r),e.destroy()})}onOptionChange(e,n){let r=O({},this.selectedOptions());r[e.name]=n.name,this.selectedOptions.set(r)}engagementTriggerReceived(){}update(){}hasHexColors(e){return!!e.optionValues[0]?.name.match(/#[a-f0-9]{6}\b/i)}static \u0275fac=function(n){return new(n||t)};static \u0275cmp=Me({type:t,selectors:[["cooee-item-options-picker"]],inputs:{item:[1,"item"]},outputs:{selectedVariant:"selectedVariant"},features:[wt],decls:2,vars:0,consts:[[3,"class"],[1,"name"],[1,"selected-value"],[1,"option-values"],[1,"option-value",3,"disabled","color-type","selected","title","ngStyle"],[1,"option-value",3,"click","disabled","title","ngStyle"],[1,"title"]],template:function(n,r){n&1&&nt(0,Qh,9,6,"div",0,pu),n&2&&rt(r.options())},dependencies:[Kl,Yl,fu],styles:[`.option-group{display:flex;gap:4px;align-items:center}.option-group+.option-group{margin-top:8px}.option-values{display:flex;flex-wrap:nowrap;overflow-x:auto;padding:6px;gap:4px}.selected-value{display:none}.option-value{padding:5px 10px;border:1px solid #ccc;cursor:pointer;border-radius:4px;min-width:32px;min-height:32px;text-align:center;position:relative;--selected-color: var(--option-color, rgb(var(--lc-color-button, 0 0 0)))}.option-value.selected{box-shadow:#fff 0 0 0 2px,var(--selected-color) 0 0 0 4px}
10
+ `+N(A,P)):y}}function gt(A,x){var F;return x.cache&&x.name&&x.storage.templates.get(x.name)?x.storage.templates.get(x.name):(F=typeof A=="function"?A:Ye(A,x),x.cache&&x.name&&x.storage.templates.define(x.name,F),F)}Le.l.bind(Le),t.compile=Ye,t.compileScope=se,t.compileScopeIntoFunction=K,t.compileToString=N,t.defaultConfig=Le,t.filters=De,t.getConfig=Ge,t.helpers=ye,t.nativeHelpers=ke,t.parse=w,t.render=function(A,x,F,P){var v=Ge(F||{});if(!v.async)return gt(A,v)(x,v);if(!P){if(typeof r=="function")return new r(function(y,H){try{y(gt(A,v)(x,v))}catch(J){H(J)}});throw e("Please provide a callback function, this env doesn't support Promises")}try{gt(A,v)(x,v,P)}catch(y){return P(y)}},t.templates=te,Object.defineProperty(t,"__esModule",{value:!0})})});var of=Is((rf,ac)=>{"use strict";(function(t){if(typeof rf=="object"&&typeof ac<"u")ac.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,n;return function r(i,o,s){function a(g,p){if(!o[g]){if(!i[g]){var E=typeof ei=="function"&&ei;if(!p&&E)return E(g,!0);if(u)return u(g,!0);var w=new Error("Cannot find module '"+g+"'");throw w.code="MODULE_NOT_FOUND",w}var N=o[g]={exports:{}};i[g][0].call(N.exports,function(M){var L=i[g][1][M];return a(L||M)},N,N.exports,r,i,o,s)}return o[g].exports}for(var u=typeof ei=="function"&&ei,d=0;d<s.length;d++)a(s[d]);return a}({1:[function(r,i,o){(function(s){"use strict";var a=s.MutationObserver||s.WebKitMutationObserver,u;if(a){var d=0,g=new a(M),p=s.document.createTextNode("");g.observe(p,{characterData:!0}),u=function(){p.data=d=++d%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var E=new s.MessageChannel;E.port1.onmessage=M,u=function(){E.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?u=function(){var j=s.document.createElement("script");j.onreadystatechange=function(){M(),j.onreadystatechange=null,j.parentNode.removeChild(j),j=null},s.document.documentElement.appendChild(j)}:u=function(){setTimeout(M,0)};var w,N=[];function M(){w=!0;for(var j,K,se=N.length;se;){for(K=N,N=[],j=-1;++j<se;)K[j]();se=N.length}w=!1}i.exports=L;function L(j){N.push(j)===1&&!w&&u()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(r,i,o){"use strict";var s=r(1);function a(){}var u={},d=["REJECTED"],g=["FULFILLED"],p=["PENDING"];i.exports=E;function E(U){if(typeof U!="function")throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,U!==a&&L(this,U)}E.prototype.catch=function(U){return this.then(null,U)},E.prototype.then=function(U,he){if(typeof U!="function"&&this.state===g||typeof he!="function"&&this.state===d)return this;var te=new this.constructor(a);if(this.state!==p){var ye=this.state===g?U:he;N(te,ye,this.outcome)}else this.queue.push(new w(te,U,he));return te};function w(U,he,te){this.promise=U,typeof he=="function"&&(this.onFulfilled=he,this.callFulfilled=this.otherCallFulfilled),typeof te=="function"&&(this.onRejected=te,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(U){u.resolve(this.promise,U)},w.prototype.otherCallFulfilled=function(U){N(this.promise,this.onFulfilled,U)},w.prototype.callRejected=function(U){u.reject(this.promise,U)},w.prototype.otherCallRejected=function(U){N(this.promise,this.onRejected,U)};function N(U,he,te){s(function(){var ye;try{ye=he(te)}catch(ke){return u.reject(U,ke)}ye===U?u.reject(U,new TypeError("Cannot resolve promise with itself")):u.resolve(U,ye)})}u.resolve=function(U,he){var te=j(M,he);if(te.status==="error")return u.reject(U,te.value);var ye=te.value;if(ye)L(U,ye);else{U.state=g,U.outcome=he;for(var ke=-1,De=U.queue.length;++ke<De;)U.queue[ke].callFulfilled(he)}return U},u.reject=function(U,he){U.state=d,U.outcome=he;for(var te=-1,ye=U.queue.length;++te<ye;)U.queue[te].callRejected(he);return U};function M(U){var he=U&&U.then;if(U&&(typeof U=="object"||typeof U=="function")&&typeof he=="function")return function(){he.apply(U,arguments)}}function L(U,he){var te=!1;function ye(Ge){te||(te=!0,u.reject(U,Ge))}function ke(Ge){te||(te=!0,u.resolve(U,Ge))}function De(){he(ke,ye)}var Le=j(De);Le.status==="error"&&ye(Le.value)}function j(U,he){var te={};try{te.value=U(he),te.status="success"}catch(ye){te.status="error",te.value=ye}return te}E.resolve=K;function K(U){return U instanceof this?U:u.resolve(new this(a),U)}E.reject=se;function se(U){var he=new this(a);return u.reject(he,U)}E.all=X;function X(U){var he=this;if(Object.prototype.toString.call(U)!=="[object Array]")return this.reject(new TypeError("must be an array"));var te=U.length,ye=!1;if(!te)return this.resolve([]);for(var ke=new Array(te),De=0,Le=-1,Ge=new this(a);++Le<te;)Ye(U[Le],Le);return Ge;function Ye(gt,A){he.resolve(gt).then(x,function(F){ye||(ye=!0,u.reject(Ge,F))});function x(F){ke[A]=F,++De===te&&!ye&&(ye=!0,u.resolve(Ge,ke))}}}E.race=be;function be(U){var he=this;if(Object.prototype.toString.call(U)!=="[object Array]")return this.reject(new TypeError("must be an array"));var te=U.length,ye=!1;if(!te)return this.resolve([]);for(var ke=-1,De=new this(a);++ke<te;)Le(U[ke]);return De;function Le(Ge){he.resolve(Ge).then(function(Ye){ye||(ye=!0,u.resolve(De,Ye))},function(Ye){ye||(ye=!0,u.reject(De,Ye))})}}},{1:1}],3:[function(r,i,o){(function(s){"use strict";typeof s.Promise!="function"&&(s.Promise=r(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(r,i,o){"use strict";var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f};function a(f,b){if(!(f instanceof b))throw new TypeError("Cannot call a class as a function")}function u(){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 d=u();function g(){try{if(!d||!d.open)return!1;var f=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(!f||b)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function p(f,b){f=f||[],b=b||{};try{return new Blob(f,b)}catch(C){if(C.name!=="TypeError")throw C;for(var m=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,S=new m,I=0;I<f.length;I+=1)S.append(f[I]);return S.getBlob(b.type)}}typeof Promise>"u"&&r(3);var E=Promise;function w(f,b){b&&f.then(function(m){b(null,m)},function(m){b(m)})}function N(f,b,m){typeof b=="function"&&f.then(b),typeof m=="function"&&f.catch(m)}function M(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}function L(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var j="local-forage-detect-blob-support",K=void 0,se={},X=Object.prototype.toString,be="readonly",U="readwrite";function he(f){for(var b=f.length,m=new ArrayBuffer(b),S=new Uint8Array(m),I=0;I<b;I++)S[I]=f.charCodeAt(I);return m}function te(f){return new E(function(b){var m=f.transaction(j,U),S=p([""]);m.objectStore(j).put(S,"key"),m.onabort=function(I){I.preventDefault(),I.stopPropagation(),b(!1)},m.oncomplete=function(){var I=navigator.userAgent.match(/Chrome\/(\d+)/),C=navigator.userAgent.match(/Edge\//);b(C||!I||parseInt(I[1],10)>=43)}}).catch(function(){return!1})}function ye(f){return typeof K=="boolean"?E.resolve(K):te(f).then(function(b){return K=b,K})}function ke(f){var b=se[f.name],m={};m.promise=new E(function(S,I){m.resolve=S,m.reject=I}),b.deferredOperations.push(m),b.dbReady?b.dbReady=b.dbReady.then(function(){return m.promise}):b.dbReady=m.promise}function De(f){var b=se[f.name],m=b.deferredOperations.pop();if(m)return m.resolve(),m.promise}function Le(f,b){var m=se[f.name],S=m.deferredOperations.pop();if(S)return S.reject(b),S.promise}function Ge(f,b){return new E(function(m,S){if(se[f.name]=se[f.name]||J(),f.db)if(b)ke(f),f.db.close();else return m(f.db);var I=[f.name];b&&I.push(f.version);var C=d.open.apply(d,I);b&&(C.onupgradeneeded=function(R){var B=C.result;try{B.createObjectStore(f.storeName),R.oldVersion<=1&&B.createObjectStore(j)}catch($){if($.name==="ConstraintError")console.warn('The database "'+f.name+'" has been upgraded from version '+R.oldVersion+" to version "+R.newVersion+', but the storage "'+f.storeName+'" already exists.');else throw $}}),C.onerror=function(R){R.preventDefault(),S(C.error)},C.onsuccess=function(){var R=C.result;R.onversionchange=function(B){B.target.close()},m(R),De(f)}})}function Ye(f){return Ge(f,!1)}function gt(f){return Ge(f,!0)}function A(f,b){if(!f.db)return!0;var m=!f.db.objectStoreNames.contains(f.storeName),S=f.version<f.db.version,I=f.version>f.db.version;if(S&&(f.version!==b&&console.warn('The database "'+f.name+`" can't be downgraded from version `+f.db.version+" to version "+f.version+"."),f.version=f.db.version),I||m){if(m){var C=f.db.version+1;C>f.version&&(f.version=C)}return!0}return!1}function x(f){return new E(function(b,m){var S=new FileReader;S.onerror=m,S.onloadend=function(I){var C=btoa(I.target.result||"");b({__local_forage_encoded_blob:!0,data:C,type:f.type})},S.readAsBinaryString(f)})}function F(f){var b=he(atob(f.data));return p([b],{type:f.type})}function P(f){return f&&f.__local_forage_encoded_blob}function v(f){var b=this,m=b._initReady().then(function(){var S=se[b._dbInfo.name];if(S&&S.dbReady)return S.dbReady});return N(m,f,f),m}function y(f){ke(f);for(var b=se[f.name],m=b.forages,S=0;S<m.length;S++){var I=m[S];I._dbInfo.db&&(I._dbInfo.db.close(),I._dbInfo.db=null)}return f.db=null,Ye(f).then(function(C){return f.db=C,A(f)?gt(f):C}).then(function(C){f.db=b.db=C;for(var R=0;R<m.length;R++)m[R]._dbInfo.db=C}).catch(function(C){throw Le(f,C),C})}function H(f,b,m,S){S===void 0&&(S=1);try{var I=f.db.transaction(f.storeName,b);m(null,I)}catch(C){if(S>0&&(!f.db||C.name==="InvalidStateError"||C.name==="NotFoundError"))return E.resolve().then(function(){if(!f.db||C.name==="NotFoundError"&&!f.db.objectStoreNames.contains(f.storeName)&&f.version<=f.db.version)return f.db&&(f.version=f.db.version+1),gt(f)}).then(function(){return y(f).then(function(){H(f,b,m,S-1)})}).catch(m);m(C)}}function J(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function re(f){var b=this,m={db:null};if(f)for(var S in f)m[S]=f[S];var I=se[m.name];I||(I=J(),se[m.name]=I),I.forages.push(b),b._initReady||(b._initReady=b.ready,b.ready=v);var C=[];function R(){return E.resolve()}for(var B=0;B<I.forages.length;B++){var $=I.forages[B];$!==b&&C.push($._initReady().catch(R))}var G=I.forages.slice(0);return E.all(C).then(function(){return m.db=I.db,Ye(m)}).then(function(z){return m.db=z,A(m,b._defaultConfig.version)?gt(m):z}).then(function(z){m.db=I.db=z,b._dbInfo=m;for(var ie=0;ie<G.length;ie++){var xe=G[ie];xe!==b&&(xe._dbInfo.db=m.db,xe._dbInfo.version=m.version)}})}function oe(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){H(m._dbInfo,be,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=$.get(f);G.onsuccess=function(){var z=G.result;z===void 0&&(z=null),P(z)&&(z=F(z)),I(z)},G.onerror=function(){C(G.error)}}catch(z){C(z)}})}).catch(C)});return w(S,b),S}function ue(f,b){var m=this,S=new E(function(I,C){m.ready().then(function(){H(m._dbInfo,be,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=$.openCursor(),z=1;G.onsuccess=function(){var ie=G.result;if(ie){var xe=ie.value;P(xe)&&(xe=F(xe));var Ue=f(xe,ie.key,z++);Ue!==void 0?I(Ue):ie.continue()}else I()},G.onerror=function(){C(G.error)}}catch(ie){C(ie)}})}).catch(C)});return w(S,b),S}function Q(f,b,m){var S=this;f=M(f);var I=new E(function(C,R){var B;S.ready().then(function(){return B=S._dbInfo,X.call(b)==="[object Blob]"?ye(B.db).then(function($){return $?b:x(b)}):b}).then(function($){H(S._dbInfo,U,function(G,z){if(G)return R(G);try{var ie=z.objectStore(S._dbInfo.storeName);$===null&&($=void 0);var xe=ie.put($,f);z.oncomplete=function(){$===void 0&&($=null),C($)},z.onabort=z.onerror=function(){var Ue=xe.error?xe.error:xe.transaction.error;R(Ue)}}catch(Ue){R(Ue)}})}).catch(R)});return w(I,m),I}function ae(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){H(m._dbInfo,U,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=$.delete(f);B.oncomplete=function(){I()},B.onerror=function(){C(G.error)},B.onabort=function(){var z=G.error?G.error:G.transaction.error;C(z)}}catch(z){C(z)}})}).catch(C)});return w(S,b),S}function ee(f){var b=this,m=new E(function(S,I){b.ready().then(function(){H(b._dbInfo,U,function(C,R){if(C)return I(C);try{var B=R.objectStore(b._dbInfo.storeName),$=B.clear();R.oncomplete=function(){S()},R.onabort=R.onerror=function(){var G=$.error?$.error:$.transaction.error;I(G)}}catch(G){I(G)}})}).catch(I)});return w(m,f),m}function pe(f){var b=this,m=new E(function(S,I){b.ready().then(function(){H(b._dbInfo,be,function(C,R){if(C)return I(C);try{var B=R.objectStore(b._dbInfo.storeName),$=B.count();$.onsuccess=function(){S($.result)},$.onerror=function(){I($.error)}}catch(G){I(G)}})}).catch(I)});return w(m,f),m}function ce(f,b){var m=this,S=new E(function(I,C){if(f<0){I(null);return}m.ready().then(function(){H(m._dbInfo,be,function(R,B){if(R)return C(R);try{var $=B.objectStore(m._dbInfo.storeName),G=!1,z=$.openKeyCursor();z.onsuccess=function(){var ie=z.result;if(!ie){I(null);return}f===0||G?I(ie.key):(G=!0,ie.advance(f))},z.onerror=function(){C(z.error)}}catch(ie){C(ie)}})}).catch(C)});return w(S,b),S}function me(f){var b=this,m=new E(function(S,I){b.ready().then(function(){H(b._dbInfo,be,function(C,R){if(C)return I(C);try{var B=R.objectStore(b._dbInfo.storeName),$=B.openKeyCursor(),G=[];$.onsuccess=function(){var z=$.result;if(!z){S(G);return}G.push(z.key),z.continue()},$.onerror=function(){I($.error)}}catch(z){I(z)}})}).catch(I)});return w(m,f),m}function ge(f,b){b=L.apply(this,arguments);var m=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||m.name,f.storeName=f.storeName||m.storeName);var S=this,I;if(!f.name)I=E.reject("Invalid arguments");else{var C=f.name===m.name&&S._dbInfo.db,R=C?E.resolve(S._dbInfo.db):Ye(f).then(function(B){var $=se[f.name],G=$.forages;$.db=B;for(var z=0;z<G.length;z++)G[z]._dbInfo.db=B;return B});f.storeName?I=R.then(function(B){if(B.objectStoreNames.contains(f.storeName)){var $=B.version+1;ke(f);var G=se[f.name],z=G.forages;B.close();for(var ie=0;ie<z.length;ie++){var xe=z[ie];xe._dbInfo.db=null,xe._dbInfo.version=$}var Ue=new E(function(He,st){var tt=d.open(f.name,$);tt.onerror=function(Wt){var Qr=tt.result;Qr.close(),st(Wt)},tt.onupgradeneeded=function(){var Wt=tt.result;Wt.deleteObjectStore(f.storeName)},tt.onsuccess=function(){var Wt=tt.result;Wt.close(),He(Wt)}});return Ue.then(function(He){G.db=He;for(var st=0;st<z.length;st++){var tt=z[st];tt._dbInfo.db=He,De(tt._dbInfo)}}).catch(function(He){throw(Le(f,He)||E.resolve()).catch(function(){}),He})}}):I=R.then(function(B){ke(f);var $=se[f.name],G=$.forages;B.close();for(var z=0;z<G.length;z++){var ie=G[z];ie._dbInfo.db=null}var xe=new E(function(Ue,He){var st=d.deleteDatabase(f.name);st.onerror=function(){var tt=st.result;tt&&tt.close(),He(st.error)},st.onblocked=function(){console.warn('dropInstance blocked for database "'+f.name+'" until all open connections are closed')},st.onsuccess=function(){var tt=st.result;tt&&tt.close(),Ue(tt)}});return xe.then(function(Ue){$.db=Ue;for(var He=0;He<G.length;He++){var st=G[He];De(st._dbInfo)}}).catch(function(Ue){throw(Le(f,Ue)||E.resolve()).catch(function(){}),Ue})})}return w(I,b),I}var _e={_driver:"asyncStorage",_initStorage:re,_support:g(),iterate:ue,getItem:oe,setItem:Q,removeItem:ae,clear:ee,length:pe,key:ce,keys:me,dropInstance:ge};function h(){return typeof openDatabase=="function"}var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l="~~local_forage_type~",_=/^~~local_forage_type~([^~]+)~/,T="__lfsc__:",D=T.length,V="arbf",ve="blob",Ie="si08",we="ui08",Ve="uic8",Be="si16",qe="si32",kt="ur16",Gt="ui32",bn="fl32",St="fl64",Vt=D+V.length,Vi=Object.prototype.toString;function dl(f){var b=f.length*.75,m=f.length,S,I=0,C,R,B,$;f[f.length-1]==="="&&(b--,f[f.length-2]==="="&&b--);var G=new ArrayBuffer(b),z=new Uint8Array(G);for(S=0;S<m;S+=4)C=c.indexOf(f[S]),R=c.indexOf(f[S+1]),B=c.indexOf(f[S+2]),$=c.indexOf(f[S+3]),z[I++]=C<<2|R>>4,z[I++]=(R&15)<<4|B>>2,z[I++]=(B&3)<<6|$&63;return G}function Es(f){var b=new Uint8Array(f),m="",S;for(S=0;S<b.length;S+=3)m+=c[b[S]>>2],m+=c[(b[S]&3)<<4|b[S+1]>>4],m+=c[(b[S+1]&15)<<2|b[S+2]>>6],m+=c[b[S+2]&63];return b.length%3===2?m=m.substring(0,m.length-1)+"=":b.length%3===1&&(m=m.substring(0,m.length-2)+"=="),m}function qp(f,b){var m="";if(f&&(m=Vi.call(f)),f&&(m==="[object ArrayBuffer]"||f.buffer&&Vi.call(f.buffer)==="[object ArrayBuffer]")){var S,I=T;f instanceof ArrayBuffer?(S=f,I+=V):(S=f.buffer,m==="[object Int8Array]"?I+=Ie:m==="[object Uint8Array]"?I+=we:m==="[object Uint8ClampedArray]"?I+=Ve:m==="[object Int16Array]"?I+=Be:m==="[object Uint16Array]"?I+=kt:m==="[object Int32Array]"?I+=qe:m==="[object Uint32Array]"?I+=Gt:m==="[object Float32Array]"?I+=bn:m==="[object Float64Array]"?I+=St:b(new Error("Failed to get type for BinaryArray"))),b(I+Es(S))}else if(m==="[object Blob]"){var C=new FileReader;C.onload=function(){var R=l+f.type+"~"+Es(this.result);b(T+ve+R)},C.readAsArrayBuffer(f)}else try{b(JSON.stringify(f))}catch(R){console.error("Couldn't convert value into a JSON string: ",f),b(null,R)}}function Zp(f){if(f.substring(0,D)!==T)return JSON.parse(f);var b=f.substring(Vt),m=f.substring(D,Vt),S;if(m===ve&&_.test(b)){var I=b.match(_);S=I[1],b=b.substring(I[0].length)}var C=dl(b);switch(m){case V:return C;case ve:return p([C],{type:S});case Ie:return new Int8Array(C);case we:return new Uint8Array(C);case Ve:return new Uint8ClampedArray(C);case Be:return new Int16Array(C);case kt:return new Uint16Array(C);case qe:return new Int32Array(C);case Gt:return new Uint32Array(C);case bn:return new Float32Array(C);case St:return new Float64Array(C);default:throw new Error("Unkown type: "+m)}}var bs={serialize:qp,deserialize:Zp,stringToBuffer:dl,bufferToString:Es};function fl(f,b,m,S){f.executeSql("CREATE TABLE IF NOT EXISTS "+b.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],m,S)}function Jp(f){var b=this,m={db:null};if(f)for(var S in f)m[S]=typeof f[S]!="string"?f[S].toString():f[S];var I=new E(function(C,R){try{m.db=openDatabase(m.name,String(m.version),m.description,m.size)}catch(B){return R(B)}m.db.transaction(function(B){fl(B,m,function(){b._dbInfo=m,C()},function($,G){R(G)})},R)});return m.serializer=bs,I}function Vn(f,b,m,S,I,C){f.executeSql(m,S,I,function(R,B){B.code===B.SYNTAX_ERR?R.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function($,G){G.rows.length?C($,B):fl($,b,function(){$.executeSql(m,S,I,C)},C)},C):C(R,B)},C)}function Qp(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"SELECT * FROM "+R.storeName+" WHERE key = ? LIMIT 1",[f],function($,G){var z=G.rows.length?G.rows.item(0).value:null;z&&(z=R.serializer.deserialize(z)),I(z)},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function eh(f,b){var m=this,S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"SELECT * FROM "+R.storeName,[],function($,G){for(var z=G.rows,ie=z.length,xe=0;xe<ie;xe++){var Ue=z.item(xe),He=Ue.value;if(He&&(He=R.serializer.deserialize(He)),He=f(He,Ue.key,xe+1),He!==void 0){I(He);return}}I()},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function pl(f,b,m,S){var I=this;f=M(f);var C=new E(function(R,B){I.ready().then(function(){b===void 0&&(b=null);var $=b,G=I._dbInfo;G.serializer.serialize(b,function(z,ie){ie?B(ie):G.db.transaction(function(xe){Vn(xe,G,"INSERT OR REPLACE INTO "+G.storeName+" (key, value) VALUES (?, ?)",[f,z],function(){R($)},function(Ue,He){B(He)})},function(xe){if(xe.code===xe.QUOTA_ERR){if(S>0){R(pl.apply(I,[f,$,m,S-1]));return}B(xe)}})})}).catch(B)});return w(C,m),C}function th(f,b,m){return pl.apply(this,[f,b,m,1])}function nh(f,b){var m=this;f=M(f);var S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"DELETE FROM "+R.storeName+" WHERE key = ?",[f],function(){I()},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function rh(f){var b=this,m=new E(function(S,I){b.ready().then(function(){var C=b._dbInfo;C.db.transaction(function(R){Vn(R,C,"DELETE FROM "+C.storeName,[],function(){S()},function(B,$){I($)})})}).catch(I)});return w(m,f),m}function ih(f){var b=this,m=new E(function(S,I){b.ready().then(function(){var C=b._dbInfo;C.db.transaction(function(R){Vn(R,C,"SELECT COUNT(key) as c FROM "+C.storeName,[],function(B,$){var G=$.rows.item(0).c;S(G)},function(B,$){I($)})})}).catch(I)});return w(m,f),m}function oh(f,b){var m=this,S=new E(function(I,C){m.ready().then(function(){var R=m._dbInfo;R.db.transaction(function(B){Vn(B,R,"SELECT key FROM "+R.storeName+" WHERE id = ? LIMIT 1",[f+1],function($,G){var z=G.rows.length?G.rows.item(0).key:null;I(z)},function($,G){C(G)})})}).catch(C)});return w(S,b),S}function sh(f){var b=this,m=new E(function(S,I){b.ready().then(function(){var C=b._dbInfo;C.db.transaction(function(R){Vn(R,C,"SELECT key FROM "+C.storeName,[],function(B,$){for(var G=[],z=0;z<$.rows.length;z++)G.push($.rows.item(z).key);S(G)},function(B,$){I($)})})}).catch(I)});return w(m,f),m}function ah(f){return new E(function(b,m){f.transaction(function(S){S.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(I,C){for(var R=[],B=0;B<C.rows.length;B++)R.push(C.rows.item(B).name);b({db:f,storeNames:R})},function(I,C){m(C)})},function(S){m(S)})})}function ch(f,b){b=L.apply(this,arguments);var m=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||m.name,f.storeName=f.storeName||m.storeName);var S=this,I;return f.name?I=new E(function(C){var R;f.name===m.name?R=S._dbInfo.db:R=openDatabase(f.name,"","",0),f.storeName?C({db:R,storeNames:[f.storeName]}):C(ah(R))}).then(function(C){return new E(function(R,B){C.db.transaction(function($){function G(Ue){return new E(function(He,st){$.executeSql("DROP TABLE IF EXISTS "+Ue,[],function(){He()},function(tt,Wt){st(Wt)})})}for(var z=[],ie=0,xe=C.storeNames.length;ie<xe;ie++)z.push(G(C.storeNames[ie]));E.all(z).then(function(){R()}).catch(function(Ue){B(Ue)})},function($){B($)})})}):I=E.reject("Invalid arguments"),w(I,b),I}var lh={_driver:"webSQLStorage",_initStorage:Jp,_support:h(),iterate:eh,getItem:Qp,setItem:th,removeItem:nh,clear:rh,length:ih,key:oh,keys:sh,dropInstance:ch};function uh(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function hl(f,b){var m=f.name+"/";return f.storeName!==b.storeName&&(m+=f.storeName+"/"),m}function dh(){var f="_localforage_support_test";try{return localStorage.setItem(f,!0),localStorage.removeItem(f),!1}catch{return!0}}function fh(){return!dh()||localStorage.length>0}function ph(f){var b=this,m={};if(f)for(var S in f)m[S]=f[S];return m.keyPrefix=hl(f,b._defaultConfig),fh()?(b._dbInfo=m,m.serializer=bs,E.resolve()):E.reject()}function hh(f){var b=this,m=b.ready().then(function(){for(var S=b._dbInfo.keyPrefix,I=localStorage.length-1;I>=0;I--){var C=localStorage.key(I);C.indexOf(S)===0&&localStorage.removeItem(C)}});return w(m,f),m}function mh(f,b){var m=this;f=M(f);var S=m.ready().then(function(){var I=m._dbInfo,C=localStorage.getItem(I.keyPrefix+f);return C&&(C=I.serializer.deserialize(C)),C});return w(S,b),S}function gh(f,b){var m=this,S=m.ready().then(function(){for(var I=m._dbInfo,C=I.keyPrefix,R=C.length,B=localStorage.length,$=1,G=0;G<B;G++){var z=localStorage.key(G);if(z.indexOf(C)===0){var ie=localStorage.getItem(z);if(ie&&(ie=I.serializer.deserialize(ie)),ie=f(ie,z.substring(R),$++),ie!==void 0)return ie}}});return w(S,b),S}function _h(f,b){var m=this,S=m.ready().then(function(){var I=m._dbInfo,C;try{C=localStorage.key(f)}catch{C=null}return C&&(C=C.substring(I.keyPrefix.length)),C});return w(S,b),S}function vh(f){var b=this,m=b.ready().then(function(){for(var S=b._dbInfo,I=localStorage.length,C=[],R=0;R<I;R++){var B=localStorage.key(R);B.indexOf(S.keyPrefix)===0&&C.push(B.substring(S.keyPrefix.length))}return C});return w(m,f),m}function yh(f){var b=this,m=b.keys().then(function(S){return S.length});return w(m,f),m}function Eh(f,b){var m=this;f=M(f);var S=m.ready().then(function(){var I=m._dbInfo;localStorage.removeItem(I.keyPrefix+f)});return w(S,b),S}function bh(f,b,m){var S=this;f=M(f);var I=S.ready().then(function(){b===void 0&&(b=null);var C=b;return new E(function(R,B){var $=S._dbInfo;$.serializer.serialize(b,function(G,z){if(z)B(z);else try{localStorage.setItem($.keyPrefix+f,G),R(C)}catch(ie){(ie.name==="QuotaExceededError"||ie.name==="NS_ERROR_DOM_QUOTA_REACHED")&&B(ie),B(ie)}})})});return w(I,m),I}function wh(f,b){if(b=L.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var m=this.config();f.name=f.name||m.name,f.storeName=f.storeName||m.storeName}var S=this,I;return f.name?I=new E(function(C){f.storeName?C(hl(f,S._defaultConfig)):C(f.name+"/")}).then(function(C){for(var R=localStorage.length-1;R>=0;R--){var B=localStorage.key(R);B.indexOf(C)===0&&localStorage.removeItem(B)}}):I=E.reject("Invalid arguments"),w(I,b),I}var Ch={_driver:"localStorageWrapper",_initStorage:ph,_support:uh(),iterate:gh,getItem:mh,setItem:bh,removeItem:Eh,clear:hh,length:yh,key:_h,keys:vh,dropInstance:wh},Sh=function(b,m){return b===m||typeof b=="number"&&typeof m=="number"&&isNaN(b)&&isNaN(m)},Th=function(b,m){for(var S=b.length,I=0;I<S;){if(Sh(b[I],m))return!0;I++}return!1},ml=Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"},Jr={},gl={},fr={INDEXEDDB:_e,WEBSQL:lh,LOCALSTORAGE:Ch},Ih=[fr.INDEXEDDB._driver,fr.WEBSQL._driver,fr.LOCALSTORAGE._driver],Bi=["dropInstance"],ws=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Bi),xh={description:"",driver:Ih.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Oh(f,b){f[b]=function(){var m=arguments;return f.ready().then(function(){return f[b].apply(f,m)})}}function Cs(){for(var f=1;f<arguments.length;f++){var b=arguments[f];if(b)for(var m in b)b.hasOwnProperty(m)&&(ml(b[m])?arguments[0][m]=b[m].slice():arguments[0][m]=b[m])}return arguments[0]}var Ah=function(){function f(b){a(this,f);for(var m in fr)if(fr.hasOwnProperty(m)){var S=fr[m],I=S._driver;this[m]=I,Jr[I]||this.defineDriver(S)}this._defaultConfig=Cs({},xh),this._config=Cs({},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 f.prototype.config=function(m){if((typeof m>"u"?"undefined":s(m))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var S in m){if(S==="storeName"&&(m[S]=m[S].replace(/\W/g,"_")),S==="version"&&typeof m[S]!="number")return new Error("Database version must be a number.");this._config[S]=m[S]}return"driver"in m&&m.driver?this.setDriver(this._config.driver):!0}else return typeof m=="string"?this._config[m]:this._config},f.prototype.defineDriver=function(m,S,I){var C=new E(function(R,B){try{var $=m._driver,G=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){B(G);return}for(var z=ws.concat("_initStorage"),ie=0,xe=z.length;ie<xe;ie++){var Ue=z[ie],He=!Th(Bi,Ue);if((He||m[Ue])&&typeof m[Ue]!="function"){B(G);return}}var st=function(){for(var Qr=function(Rh){return function(){var Mh=new Error("Method "+Rh+" is not implemented by the current driver"),_l=E.reject(Mh);return w(_l,arguments[arguments.length-1]),_l}},Ss=0,Nh=Bi.length;Ss<Nh;Ss++){var Ts=Bi[Ss];m[Ts]||(m[Ts]=Qr(Ts))}};st();var tt=function(Qr){Jr[$]&&console.info("Redefining LocalForage driver: "+$),Jr[$]=m,gl[$]=Qr,R()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(tt,B):tt(!!m._support):tt(!0)}catch(Wt){B(Wt)}});return N(C,S,I),C},f.prototype.driver=function(){return this._driver||null},f.prototype.getDriver=function(m,S,I){var C=Jr[m]?E.resolve(Jr[m]):E.reject(new Error("Driver not found."));return N(C,S,I),C},f.prototype.getSerializer=function(m){var S=E.resolve(bs);return N(S,m),S},f.prototype.ready=function(m){var S=this,I=S._driverSet.then(function(){return S._ready===null&&(S._ready=S._initDriver()),S._ready});return N(I,m,m),I},f.prototype.setDriver=function(m,S,I){var C=this;ml(m)||(m=[m]);var R=this._getSupportedDrivers(m);function B(){C._config.driver=C.driver()}function $(ie){return C._extend(ie),B(),C._ready=C._initStorage(C._config),C._ready}function G(ie){return function(){var xe=0;function Ue(){for(;xe<ie.length;){var He=ie[xe];return xe++,C._dbInfo=null,C._ready=null,C.getDriver(He).then($).catch(Ue)}B();var st=new Error("No available storage method found.");return C._driverSet=E.reject(st),C._driverSet}return Ue()}}var z=this._driverSet!==null?this._driverSet.catch(function(){return E.resolve()}):E.resolve();return this._driverSet=z.then(function(){var ie=R[0];return C._dbInfo=null,C._ready=null,C.getDriver(ie).then(function(xe){C._driver=xe._driver,B(),C._wrapLibraryMethodsWithReady(),C._initDriver=G(R)})}).catch(function(){B();var ie=new Error("No available storage method found.");return C._driverSet=E.reject(ie),C._driverSet}),N(this._driverSet,S,I),this._driverSet},f.prototype.supports=function(m){return!!gl[m]},f.prototype._extend=function(m){Cs(this,m)},f.prototype._getSupportedDrivers=function(m){for(var S=[],I=0,C=m.length;I<C;I++){var R=m[I];this.supports(R)&&S.push(R)}return S},f.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,S=ws.length;m<S;m++)Oh(this,ws[m])},f.prototype.createInstance=function(m){return new f(m)},f}(),Dh=new Ah;i.exports=Dh},{3:3}]},{},[4])(4)})});var Lh={schedule(t,e){let n=setTimeout(t,e);return()=>clearTimeout(n)}};function Fh(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function kh(t){return!!t&&t.nodeType===Node.ELEMENT_NODE}var Us;function Vh(t,e){if(!Us){let n=Element.prototype;Us=n.matches||n.matchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector||n.webkitMatchesSelector}return t.nodeType===Node.ELEMENT_NODE?Us.call(t,e):!1}function Bh(t){let e={};return t.forEach(({propName:n,templateName:r,transform:i})=>{e[Fh(r)]=[n,i]}),e}function Uh(t,e){return e.get(As).resolveComponentFactory(t).inputs}function Hh(t,e){let n=t.childNodes,r=e.map(()=>[]),i=-1;e.some((o,s)=>o==="*"?(i=s,!0):!1);for(let o=0,s=n.length;o<s;++o){let a=n[o],u=jh(a,e,i);u!==-1&&r[u].push(a)}return r}function jh(t,e,n){let r=n;return kh(t)&&e.some((i,o)=>i!=="*"&&Vh(t,i)?(r=o,!0):!1),r}var $h=10,Hs=class{componentFactory;inputMap=new Map;constructor(e,n){this.componentFactory=n.get(As).resolveComponentFactory(e);for(let r of this.componentFactory.inputs)this.inputMap.set(r.propName,r.templateName)}create(e){return new js(this.componentFactory,e,this.inputMap)}},js=class{componentFactory;injector;inputMap;eventEmitters=new wl(1);events=this.eventEmitters.pipe(Nl(e=>Hi(...e)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(e,n,r){this.componentFactory=e,this.injector=n,this.inputMap=r,this.ngZone=this.injector.get(Pt),this.appRef=this.injector.get(Wi),this.cdScheduler=n.get(Pl),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(e){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(e)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=Lh.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},$h))})}getInputValue(e){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(e):this.componentRef.instance[e])}setInputValue(e,n){if(this.componentRef===null){this.initialInputValues.set(e,n);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(e)??e,n),this.componentRef.hostView.dirty&&(this.componentRef.changeDetectorRef.markForRefresh(),this.cdScheduler.notify(6))})}initializeComponent(e){let n=Mt.create({providers:[],parent:this.injector}),r=Hh(e,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(n,r,e),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[e,n]of this.initialInputValues)this.setInputValue(e,n);this.initialInputValues.clear()}initializeOutputs(e){let n=this.componentFactory.outputs.map(({propName:r,templateName:i})=>{let o=e.instance[r];return new El(s=>{let a=o.subscribe(u=>s.next({name:i,value:u}));return()=>a.unsubscribe()})});this.eventEmitters.next(n)}runInZone(e){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(e):e()}},$s=class extends HTMLElement{ngElementEventsSubscription=null};function nu(t,e){let n=Uh(t,e.injector),r=e.strategyFactory||new Hs(t,e.injector),i=Bh(n);class o extends $s{injector;static observedAttributes=Object.keys(i);get ngElementStrategy(){if(!this._ngElementStrategy){let a=this._ngElementStrategy=r.create(this.injector||e.injector);n.forEach(({propName:u,transform:d})=>{if(!this.hasOwnProperty(u))return;let g=this[u];delete this[u],a.setInputValue(u,g,d)})}return this._ngElementStrategy}_ngElementStrategy;constructor(a){super(),this.injector=a}attributeChangedCallback(a,u,d,g){let[p,E]=i[a];this.ngElementStrategy.setInputValue(p,d,E)}connectedCallback(){let a=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),a=!0),this.ngElementStrategy.connect(this),a||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(a=>{let u=new CustomEvent(a.name,{detail:a.value});this.dispatchEvent(u)})}}return n.forEach(({propName:s,transform:a})=>{Object.defineProperty(o.prototype,s,{get(){return this.ngElementStrategy.getInputValue(s)},set(u){this.ngElementStrategy.setInputValue(s,u,a)},configurable:!0,enumerable:!0})}),o}var ru="9.13.2";var Xe=class t{static SDK_VERSION=ru;static SDK_VERSION_CODE;static SDK="WEB";static LOG_PREFIX="CooeeSDK";static COOEE="cooee";static SESSION_STORAGE_SCROLL_ID="sleid";static IDLE_TIME_IN_SECONDS=30*60;static IN_APP_WRAPPER_NAME="cooee-wrapper";static IN_APP_CONTAINER_NAME="cooee-container";static IN_APP_DEFAULT_PADDING=15;static EVENT_SCREEN_VIEW="CE Screen View";static EVENT_APP_BACKGROUND="CE App Background";static EVENT_TRIGGER_DISPLAYED="CE Trigger Displayed";static EVENT_CAMPAIGN_HOLDOUT="CE Campaign Holdout";static EVENT_CAMPAIGN_REJECTED="CE Campaign Rejected";static EVENT_CAMPAIGN_FAILED="CE Campaign Failed";static EVENT_TRIGGER_CLOSED="CE Trigger Closed";static EVENT_SCROLL="CE Scroll";static EVENT_TRIGGER_CLICKED="CE Trigger Clicked";static EVENT_FORM_SUBMITTED="CE Form Submitted";static EVENT_EXPERIMENT_START="CE Experiment Start";static EVENT_VIDEO_DIALOG_CLOSED="CE Video Dialog Closed";static EVENT_VIDEO_DIALOG_OPENED="CE Video Dialog Opened";static EVENT_VIDEO_CHANGE="CE Video Changed";static EVENT_LAST_VIDEO_ENDED="CE Last Video Ended";static EVENT_VIDEO_MUTED="CE Video Muted";static EVENT_VIDEO_UNMUTED="CE Video Unmuted";static EVENT_ADD_TO_CART_CLICKED="CE Add To Cart Clicked";static EVENT_VIEW_ITEM_CLICKED="CE View Item Clicked";static EVENT_MORE_ITEM_INFO_CLICKED="CE More Item Info Clicked";static EVENT_OPEN_CART_CLICKED="CE Open Cart Clicked";static EVENT_ADD_TO_CART="Add To Cart";static EVENT_REMOVE_FROM_CART="Remove From Cart";static EVENT_VIEW_ITEM="View Item";static EVENT_VIEW_CART="View Cart";static EVENT_OPEN_CART="Open Cart";static EVENT_VIEW_COLLECTION="View Collection";static EVENT_BUY_NOW_CLICKED="Buy Now Clicked";static EVENT_CHECKOUT_STARTED="Checkout Started";static EVENT_REVIEW_CLICKED="Review Clicked";static EVENT_ITEM_THUMBNAIL_CLICKED="Item Thumbnail Clicked";static JS_LOAD_WHITELIST_EVENTS=[this.EVENT_VIEW_ITEM,this.EVENT_VIEW_CART,this.EVENT_VIEW_COLLECTION];static HASH_INITIATE_CHECKOUT="initiate-checkout";static HASH_OPEN_CART_DRAWER="open-cart-drawer";static ADD_BUNDLE_CTA_INBOUND_EVENT="letscooee:inbound:cta:add-bundle";static CTA_OPEN_CART_EVENT="letscooee:outbound:open-cart";static CTA_AFTER_REFRESH_UI="letscooee:outbound:refresh-ui";static POPUP_ACTIVITY_EVENT="letscooee:outbound:popup-activities";static THIRD_PARTY_CHECKOUT_EVENT="letscooee:outbound:third-party-initiate-checkout";static CAMPAIGN_DISPLAYED_ACTIVITY="DISPLAYED";static CAMPAIGN_CLICKED_ACTIVITY="CLICKED";static CAMPAIGN_CLOSED_ACTIVITY="CLOSED";static BLACKLISTED_PAGE_NAMES=["collection","product","cart"];static API_CALL_MAX_ATTEMPTS=3;static API_CALL_RETRY_DELAY=1e3;static PLACEHOLDER_IMAGE="https://cdn.global.letscooee.com/images/placeholders/product.png";static CART_UPDATE_BROADCAST="CART_UPDATE";static GRAPHQL_VERSION="2024-10";static GRAPHQL_API_PATH=`/api/${this.GRAPHQL_VERSION}/graphql.json`;static SHADOW_SPLITTER=":shadow";static CAMPAIGN_ATTRIBUTE="_letscooee_campaign";static CONTENT_ATTRIBUTE="_letscooee_content";static VIA="_via";static PAYMENT_MODAL_DETAILS=[{identifier:"#flo-checkout-wrapper",gateway:"Shopflow"},{identifier:"#fastrr-main-container",gateway:"Shiprocket"},{identifier:"#gokwik-modal-wrapper",gateway:"Gokwik"},{identifier:"#zecpe",gateway:"Ecom 360"}];static{let e=t.SDK_VERSION.split(".").map(n=>n.padStart(2,"0")).join("");t.SDK_VERSION_CODE=parseInt(e,10)}};var Dn={apiURL:"https://api.sdk.letscooee.com",debug:!1,mode:"production",styleURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${Xe.SDK_VERSION}/dist/widget.min.css`,widgetURL:`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${Xe.SDK_VERSION}/dist/widget.min.js`};var Ut=ti(ou());var ut=class{static log(...e){Ut.default.info(...e)}static debug(...e){Ut.default.debug(...e)}static error(...e){Ut.default.error(...e)}static warn(...e){Ut.default.warn(...e)}static info(...e){Ut.default.info(...e)}static trace(...e){Ut.default.trace(...e)}};function su(t=Xe.LOG_PREFIX){Ut.default.useDefaults({formatter:function(n){n.unshift(`${t} (v${Xe.SDK_VERSION}):`)}});let e=Wh();(e==="1"||e==="on")&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?Ut.default.setLevel(Ut.default[localStorage.cooeeLogLevel]):Ut.default.setLevel(Dn.debug?Ut.default.TRACE:Ut.default.OFF)}function Wh(){return new URL(location.href).searchParams?.get("cooee-debug")}var ki=ti(Qi());var cu={providers:[$l()]};var zh={"[class.ng-untouched]":"isUntouched","[class.ng-touched]":"isTouched","[class.ng-pristine]":"isPristine","[class.ng-dirty]":"isDirty","[class.ng-valid]":"isValid","[class.ng-invalid]":"isInvalid","[class.ng-pending]":"isPending"},KE=Ce(O({},zh),{"[class.ng-submitted]":"isSubmitted"});var Kh=new nn("",{providedIn:"root",factory:()=>du}),du="always";var Xh=(()=>{class t{static \u0275fac=function(r){return new(r||t)};static \u0275mod=Xn({type:t});static \u0275inj=zn({})}return t})();var fu=(()=>{class t{static withConfig(n){return{ngModule:t,providers:[{provide:Kh,useValue:n.callSetDisabledState??du}]}}static \u0275fac=function(r){return new(r||t)};static \u0275mod=Xn({type:t});static \u0275inj=zn({imports:[Xh]})}return t})();var zt=class{static SWIPER_CSS="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css";static injectScriptURL(e,n){if(!e)return;let r=document.createElement("script");r.id=n??"",r.src=e,r.type="module",document.head.appendChild(r)}static injectRawScript(e){if(!e)return;let n=document.createElement("script");n.id="cooee-app-script",n.innerHTML=e,document.head.appendChild(n)}static injectRawCSS(e,n=document.head){if(!e)return;let r=document.createElement("style");r.textContent=e,n.appendChild(r)}static injectSwiperCSS(e=document.head){this.injectStylesheet(this.SWIPER_CSS,e)}static injectStylesheet(e,n=document.head){if(!e)return;let r=document.createElement("link");r.rel="stylesheet",r.href=e,e===this.SWIPER_CSS&&(r.crossOrigin="anonymous",r.onload=i=>{let s=i.currentTarget?.sheet?.cssRules;if(s){for(let a of s)if(a.type==CSSRule.FONT_FACE_RULE){let u=e.split("/"),d=u.slice(0,u.length-1).join("/"),g=a.cssText;g=g.replace(/url\s*\(\s*['"]?(?!((\/)|((?:https?:)?\/\/)|(?:data:?:)))([^'")]+)['"]?\s*\)/g,`url("${d}/$4")`);let p=document.createElement("style");p.appendChild(document.createTextNode(g)),document.head.appendChild(p)}}}),n.appendChild(r)}static async loadSwiperScript(){window.CooeeSDK.Swiper||(window.CooeeSDK.Swiper=(await import("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.mjs")).Swiper)}};var Kt=class t{cooeeEvent=new at;cooeeCTA=new at;elementRef=q(Tt);_engagementTrigger=Lt(null);_triggerContext=Lt(null);constructor(){this.elementRef.nativeElement.update=this.update.bind(this)}get classes(){let e=["letscooee-widget"],n=this._engagementTrigger();return e.push(`widget-${n?.shortID}`),e}get triggerContext(){return this._triggerContext()}set triggerContext(e){this._triggerContext.set(e),this._engagementTrigger.set(e.triggerData),this.engagementTriggerReceived(e.triggerData)}get engagementTrigger(){return this._engagementTrigger()}ngOnInit(){ut.debug("Init",this.constructor.name);let e=this.elementRef.nativeElement.shadowRoot;e&&(zt.injectStylesheet(Dn.styleURL,e),zt.injectRawCSS(window.CooeeSDK.config.website.commonCSS,e))}ngOnDestroy(){ut.debug("Destroying",this.constructor.name)}sendEventToRenderer(e){this.cooeeEvent.emit(e)}executeCTAViaRenderer(e){this.cooeeCTA.emit(e)}static \u0275fac=function(n){return new(n||t)};static \u0275cmp=Me({type:t,selectors:[["ng-component"]],hostVars:2,hostBindings:function(n,r){n&2&&Bl(r.classes)},inputs:{triggerContext:"triggerContext"},outputs:{cooeeEvent:"cooeeEvent",cooeeCTA:"cooeeCTA"},decls:0,vars:0,template:function(n,r){},encapsulation:2})};var qh=(t,e)=>({"--option-color":t,"background-color":e}),pu=(t,e)=>e.id;function Zh(t,e){if(t&1&&(W(0,"span",6),Ae(1),Y()),t&2){Z();let n=Ke(1);k(),ln(n)}}function Jh(t,e){if(t&1){let n=ze();ct(0)(1)(2),W(3,"button",5),Pe("click",function(){let i=Ne(n).$implicit,o=Z().$implicit,s=Z();return Re(s.onOptionChange(o,i))}),Oe(4,Zh,2,1,"span",6),Y()}if(t&2){let n,r=e.$implicit,i=Z().$implicit,o=Ke(1),s=Z(),a=r.name;k();let u=vt(r.displayName||r.name),d=o?(n=r.hexColor)!==null&&n!==void 0?n:a:"";k(2),Ps("color-type",o)("selected",s.selectedOptions()[i.name]===a),de("disabled",r.disabled)("title",u)("ngStyle",zi(10,qh,d,d)),wn("data-value",a),k(),Te(o?-1:4)}}function Qh(t,e){if(t&1&&(W(0,"div"),ct(1),W(2,"div",1),Ae(3),Y(),W(4,"div",2),Ae(5),Y(),W(6,"div",3),nt(7,Jh,5,13,"button",4,pu),Y()()),t&2){let n=e.$implicit,r=Z();Ul("option-group ",n.name.toLowerCase(),""),k(),vt(r.hasHexColors(n)),k(2),It("",n.name,":"),k(2),ln(r.selectedOptions()[n.name]),k(2),rt(n.optionValues)}}var yr=class t extends Kt{selectedVariant=new at;item=hr.required();selectedOptions=Lt({});options=vr(()=>{let e=this.item();if(!e.options||e.vars.length===1)return[];if(window.cooeeManipulateProduct)try{window.cooeeManipulateProduct(e,this.engagementTrigger)}catch(n){ut.error(n)}return e.options});matchedVariant=vr(()=>{let e=this.item(),n=this.selectedOptions();return e.vars.find(r=>e.options.every(i=>n[i.name]===r.selectedOptions.find(o=>o.name===i.name)?.value))});constructor(){super(),ks(()=>{let n=this.matchedVariant();n&&(this.item().setSelectedVariant(n),this.selectedVariant.emit(n))});let e=ks(()=>{let n=this.item();if(!n?.options)return;let r=O({},this.selectedOptions());n.options.forEach(i=>{let o=n.vars[0]?.selectedOptions.find(s=>s.name===i.name)?.value;o&&(r[i.name]=o)}),this.selectedOptions.set(r),e.destroy()})}onOptionChange(e,n){let r=O({},this.selectedOptions());r[e.name]=n.name,this.selectedOptions.set(r)}engagementTriggerReceived(){}update(){}hasHexColors(e){return!!e.optionValues[0]?.name.match(/#[a-f0-9]{6}\b/i)}static \u0275fac=function(n){return new(n||t)};static \u0275cmp=Me({type:t,selectors:[["cooee-item-options-picker"]],inputs:{item:[1,"item"]},outputs:{selectedVariant:"selectedVariant"},features:[wt],decls:2,vars:0,consts:[[3,"class"],[1,"name"],[1,"selected-value"],[1,"option-values"],[1,"option-value",3,"disabled","color-type","selected","title","ngStyle"],[1,"option-value",3,"click","disabled","title","ngStyle"],[1,"title"]],template:function(n,r){n&1&&nt(0,Qh,9,6,"div",0,pu),n&2&&rt(r.options())},dependencies:[Kl,Yl,fu],styles:[`.option-group{display:flex;gap:4px;align-items:center}.option-group+.option-group{margin-top:8px}.option-values{display:flex;flex-wrap:nowrap;overflow-x:auto;padding:6px;gap:4px}.selected-value{display:none}.option-value{padding:5px 10px;border:1px solid #ccc;cursor:pointer;border-radius:4px;min-width:32px;min-height:32px;text-align:center;position:relative;--selected-color: var(--option-color, rgb(var(--lc-color-button, 0 0 0)))}.option-value.selected{box-shadow:#fff 0 0 0 2px,var(--selected-color) 0 0 0 4px}
11
11
  `],encapsulation:3})};var Gs=function(t){return t.SHOPIFY_CHECKOUT="shopify_checkout",t.THIRD_PARTY_CHECKOUT="third_party_checkout",t.CART_PAGE="cart_page",t.CART_DRAWER="cart_drawer",t}(Gs||{});var Xt=function(t){return t[t.NONE=0]="NONE",t[t.REJECT_POPUP=1]="REJECT_POPUP",t[t.ACCEPT_POPUP=2]="ACCEPT_POPUP",t[t.GO_TO_URL=4]="GO_TO_URL",t[t.SHARE=5]="SHARE",t[t.KEY_VALUE=100]="KEY_VALUE",t[t.GO_TO_PRODUCT=101]="GO_TO_PRODUCT",t[t.ADD_TO_CART=102]="ADD_TO_CART",t[t.COPY_COUPON_CODE=103]="COPY_COUPON_CODE",t[t.GO_TO_COLLECTION=104]="GO_TO_COLLECTION",t[t.OPEN_CART=105]="OPEN_CART",t[t.SUBMIT_FORM=106]="SUBMIT_FORM",t[t.INITIATE_CHECKOUT=107]="INITIATE_CHECKOUT",t[t.ADD_BUNDLE=108]="ADD_BUNDLE",t[t.UPGRADE_TO_SUBSCRIPTION=109]="UPGRADE_TO_SUBSCRIPTION",t}(Xt||{});var ai=function(t){return t.FREE_SHIPPING="FREE_SHIPPING",t.DISCOUNT="DISCOUNT",t.FREE_AUTO_GIFT="FREE_AUTO_GIFT",t.FREE_GIFT_SELECT="FREE_GIFT_SELECT",t.UI_ONLY="UI_ONLY",t}(ai||{});var Er=class{id;mID;vID;vName;imageURL;name;link;quantity;price;finalPrice;constructor(e){this.id=e.id,this.mID=e.mID,this.vID=e.vID,this.vName=e.vName,this.imageURL=e.imageURL,this.name=e.name,this.link=e.link,this.quantity=e.quantity,this.price=e.price,this.finalPrice=e.finalPrice??e.price}};var Ws=(n=>(n.CART_AMOUNT="CART_AMOUNT",n.ITEM_COUNT="ITEM_COUNT",n))(Ws||{});var br=class{gaEnabled;gaMeasurementID;pixelPush;website;currencyCount;money;storefrontToken;skipItemAttribute;currency;static get(){return window.CooeeSDK.config}update(e){return e??={},this.gaEnabled=e.gaEnabled,this.gaMeasurementID=e.gaMeasurementID,this.pixelPush=e.pixelPush,this.website=e.website??{},this.currencyCount=e.currencyCount??0,this.money=e.money,this.currency=e.currency,this.storefrontToken=e.storefrontToken,this.skipItemAttribute=e.skipItemAttribute,this}};var fe=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var Se=globalThis;var un="9.42.0";function Zn(){return Jn(Se),Se}function Jn(t){let e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||un,e[un]=e[un]||{}}function Nn(t,e,n=Se){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[un]=r[un]||{};return i[t]||(i[t]=e())}var Ys=["debug","info","warn","error","log","assert","trace"],em="Sentry Logger ",wr={};function Hn(t){if(!("console"in Se))return t();let e=Se.console,n={},r=Object.keys(wr);r.forEach(i=>{let o=wr[i];n[i]=e[i],e[i]=o});try{return t()}finally{r.forEach(i=>{e[i]=n[i]})}}function tm(){Ks().enabled=!0}function nm(){Ks().enabled=!1}function hu(){return Ks().enabled}function rm(...t){zs("log",...t)}function im(...t){zs("warn",...t)}function om(...t){zs("error",...t)}function zs(t,...e){fe&&hu()&&Hn(()=>{Se.console[t](`${em}[${t}]:`,...e)})}function Ks(){return fe?Nn("loggerSettings",()=>({enabled:!1})):{enabled:!1}}var ne={enable:tm,disable:nm,isEnabled:hu,log:rm,warn:im,error:om};var dn="?",mu=/\(error: (.*)\)/,gu=/captureMessage|captureException/;function qs(...t){let e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0,i=0)=>{let o=[],s=n.split(`
12
12
  `);for(let a=r;a<s.length;a++){let u=s[a];if(u.length>1024)continue;let d=mu.test(u)?u.replace(mu,"$1"):u;if(!d.match(/\S*Error: /)){for(let g of e){let p=g(d);if(p){o.push(p);break}}if(o.length>=50+i)break}}return _u(o.slice(i))}}function _u(t){if(!t.length)return[];let e=Array.from(t);return/sentryWrapped/.test(eo(e).function||"")&&e.pop(),e.reverse(),gu.test(eo(e).function||"")&&(e.pop(),gu.test(eo(e).function||"")&&e.pop()),e.slice(0,50).map(n=>Ce(O({},n),{filename:n.filename||eo(e).filename,function:n.function||dn}))}function eo(t){return t[t.length-1]||{}}var Xs="<anonymous>";function qt(t){try{return!t||typeof t!="function"?Xs:t.name||Xs}catch{return Xs}}function to(t){let e=t.exception;if(e){let n=[];try{return e.values.forEach(r=>{r.stacktrace.frames&&n.push(...r.stacktrace.frames)}),n}catch{return}}}var no={},vu={};function Ot(t,e){no[t]=no[t]||[],no[t].push(e)}function At(t,e){if(!vu[t]){vu[t]=!0;try{e()}catch(n){fe&&ne.error(`Error while instrumenting ${t}`,n)}}}function dt(t,e){let n=t&&no[t];if(n)for(let r of n)try{r(e)}catch(i){fe&&ne.error(`Error while triggering instrumentation handler.
13
13
  Type: ${t}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@letscooee/web-sdk",
3
3
  "description": "Engage uniquely and boost conversions with AI-powered customer journeys driven by real-time intent",
4
- "version": "9.13.1",
4
+ "version": "9.13.2",
5
5
  "scripts": {
6
6
  "lint": "ng lint",
7
7
  "integrity": "./scripts/validate-integrity.sh",