@letscooee/web-sdk 9.12.12 → 9.12.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{Aa as x,Da as h,Ka as a,La as y,R as l,Ta as p,Ua as v,Va as w,Y as d,_ as n,ga as c,gb as D,jb as k,la as g,pa as m,va as u,wa as f,xa as b,ya as r,za as o,zb as C}from"./chunk-EHNBTJQP.js";function M(i,t){if(i&1&&(r(0,"li")(1,"span",1),a(2),p(3,"date"),o(),a(4,"\xA0 "),x(5,"span",2),p(6,"safeHtml"),o()),i&2){let e=t.$implicit;n(2),y(w(3,2,e.time,"MM/dd/yy, hh:mm:ss a")),n(3),m("innerHTML",v(6,5,e.message),d)}}var _=class i{logs=l.required();constructor(){}shareLogs(){let t=JSON.stringify(this.logs());if(navigator.share){navigator.share({text:t});return}navigator.clipboard.writeText(t)}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=c({type:i,selectors:[["cooee-debugger"]],inputs:{logs:[1,"logs"]},features:[g([C])],decls:5,vars:0,consts:[[1,"btn-copy",3,"click"],[2,"color","rgb(100, 116, 139)"],[3,"innerHTML"]],template:function(e,s){e&1&&(r(0,"ol"),f(1,M,7,7,"li",null,u),o(),r(3,"button",0),h("click",function(){return s.shareLogs()}),a(4,"Share"),o()),e&2&&(n(),b(s.logs()))},dependencies:[k,D],styles:[`:host{display:block;position:fixed;top:calc(100vh - 90px);left:10px;right:10px;width:auto;max-width:100%;min-width:calc(100vw - 20px);height:80px;background:#fff;z-index:111111111111;overflow-y:auto;font-size:13px;line-height:1.5;padding:5px;font-family:Arial,"sans-serif";font-weight:500;border:2px solid rgb(245,28,143);border-radius:4px;resize:both;-webkit-user-select:auto;user-select:auto}@media (min-width: 768px){:host{width:600px;min-width:auto}}ol{margin:0;padding:0 0 0 28px}.btn-copy{position:absolute;top:5px;right:5px;background:#f51c8f;border:none;cursor:pointer;padding:6px 8px;font-size:12px;border-radius:6px;color:#fff}
1
+ import{Aa as x,Da as h,Ka as a,La as y,R as l,Sa as p,Ta as v,Ua as w,Y as d,_ as n,fb as D,ga as c,ib as k,la as g,pa as m,va as u,wa as f,xa as b,ya as r,yb as C,za as o}from"./chunk-5M6UNVYN.js";function M(i,t){if(i&1&&(r(0,"li")(1,"span",1),a(2),p(3,"date"),o(),a(4,"\xA0 "),x(5,"span",2),p(6,"safeHtml"),o()),i&2){let e=t.$implicit;n(2),y(w(3,2,e.time,"MM/dd/yy, hh:mm:ss a")),n(3),m("innerHTML",v(6,5,e.message),d)}}var _=class i{logs=l.required();constructor(){}shareLogs(){let t=JSON.stringify(this.logs());if(navigator.share){navigator.share({text:t});return}navigator.clipboard.writeText(t)}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=c({type:i,selectors:[["cooee-debugger"]],inputs:{logs:[1,"logs"]},features:[g([C])],decls:5,vars:0,consts:[[1,"btn-copy",3,"click"],[2,"color","rgb(100, 116, 139)"],[3,"innerHTML"]],template:function(e,s){e&1&&(r(0,"ol"),f(1,M,7,7,"li",null,u),o(),r(3,"button",0),h("click",function(){return s.shareLogs()}),a(4,"Share"),o()),e&2&&(n(),b(s.logs()))},dependencies:[k,D],styles:[`:host{display:block;position:fixed;top:calc(100vh - 90px);left:10px;right:10px;width:auto;max-width:100%;min-width:calc(100vw - 20px);height:80px;background:#fff;z-index:111111111111;overflow-y:auto;font-size:13px;line-height:1.5;padding:5px;font-family:Arial,"sans-serif";font-weight:500;border:2px solid rgb(245,28,143);border-radius:4px;resize:both;-webkit-user-select:auto;user-select:auto}@media (min-width: 768px){:host{width:600px;min-width:auto}}ol{margin:0;padding:0 0 0 28px}.btn-copy{position:absolute;top:5px;right:5px;background:#f51c8f;border:none;cursor:pointer;padding:6px 8px;font-size:12px;border-radius:6px;color:#fff}
2
2
  `],encapsulation:3})};export{_ as DebuggerComponent};
package/dist/main.min.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var Kd=Object.create;var xc=Object.defineProperty;var Yd=Object.getOwnPropertyDescriptor;var Jd=Object.getOwnPropertyNames;var Xd=Object.getPrototypeOf,Qd=Object.prototype.hasOwnProperty;var Zd=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Jd(e))!Qd.call(t,i)&&i!==r&&xc(t,i,{get:()=>e[i],enumerable:!(n=Yd(e,i))||n.enumerable});return t};var tf=(t,e,r)=>(r=t!=null?Kd(Xd(t)):{},Zd(e||!t||!t.__esModule?xc(r,"default",{value:t,enumerable:!0}):r,t));var ef=Object.create,ia=Object.defineProperty,rf=Object.defineProperties,nf=Object.getOwnPropertyDescriptor,sf=Object.getOwnPropertyDescriptors,of=Object.getOwnPropertyNames,Ri=Object.getOwnPropertySymbols,af=Object.getPrototypeOf,sa=Object.prototype.hasOwnProperty,Du=Object.prototype.propertyIsEnumerable,Dc=(t,e,r)=>e in t?ia(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,T=(t,e)=>{for(var r in e||={})sa.call(e,r)&&Dc(t,r,e[r]);if(Ri)for(var r of Ri(e))Du.call(e,r)&&Dc(t,r,e[r]);return t},ct=(t,e)=>rf(t,sf(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')}),cf=(t,e)=>{var r={};for(var n in t)sa.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&&Du.call(t,n)&&(r[n]=t[n]);return r},ts=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),lf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of of(e))!sa.call(t,i)&&i!==r&&ia(t,i,{get:()=>e[i],enumerable:!(n=nf(e,i))||n.enumerable});return t},Oe=(t,e,r)=>(r=t!=null?ef(af(t)):{},lf(e||!t||!t.__esModule?ia(r,"default",{value:t,enumerable:!0}):r,t)),tn=ts((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],v,b;for(b=1;b<h.length;b++)for(v in h[b])!(v in w)&&h[b].hasOwnProperty(v)&&(w[v]=h[b][v]);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={},v=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):v(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,_),v(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)}),uf=ts((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,v){if(!c[w]){if(!o[w]){var b=typeof hi=="function"&&hi;if(!v&&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 B=o[w][1][A];return p(B||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),v=l.document.createTextNode("");w.observe(v,{characterData:!0}),g=function(){v.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,Q=k.length;Q;){for(j=k,k=[],G=-1;++G<Q;)j[G]();Q=k.length}_=!1}o.exports=B;function B(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"],v=["PENDING"];o.exports=b;function b(q){if(typeof q!="function")throw new TypeError("resolver must be a function");this.state=v,this.queue=[],this.outcome=void 0,q!==p&&B(this,q)}b.prototype.catch=function(q){return this.then(null,q)},b.prototype.then=function(q,nt){if(typeof q!="function"&&this.state===w||typeof nt!="function"&&this.state===h)return this;var Z=new this.constructor(p);if(this.state!==v){var et=this.state===w?q:nt;k(Z,et,this.outcome)}else this.queue.push(new _(Z,q,nt));return Z};function _(q,nt,Z){this.promise=q,typeof nt=="function"&&(this.onFulfilled=nt,this.callFulfilled=this.otherCallFulfilled),typeof Z=="function"&&(this.onRejected=Z,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,nt,Z){l(function(){var et;try{et=nt(Z)}catch(ht){return g.reject(q,ht)}et===q?g.reject(q,new TypeError("Cannot resolve promise with itself")):g.resolve(q,et)})}g.resolve=function(q,nt){var Z=G(A,nt);if(Z.status==="error")return g.reject(q,Z.value);var et=Z.value;if(et)B(q,et);else{q.state=w,q.outcome=nt;for(var ht=-1,kt=q.queue.length;++ht<kt;)q.queue[ht].callFulfilled(nt)}return q},g.reject=function(q,nt){q.state=h,q.outcome=nt;for(var Z=-1,et=q.queue.length;++Z<et;)q.queue[Z].callRejected(nt);return q};function A(q){var nt=q&&q.then;if(q&&(typeof q=="object"||typeof q=="function")&&typeof nt=="function")return function(){nt.apply(q,arguments)}}function B(q,nt){var Z=!1;function et(jt){Z||(Z=!0,g.reject(q,jt))}function ht(jt){Z||(Z=!0,g.resolve(q,jt))}function kt(){nt(ht,et)}var At=G(kt);At.status==="error"&&et(At.value)}function G(q,nt){var Z={};try{Z.value=q(nt),Z.status="success"}catch(et){Z.status="error",Z.value=et}return Z}b.resolve=j;function j(q){return q instanceof this?q:g.resolve(new this(p),q)}b.reject=Q;function Q(q){var nt=new this(p);return g.reject(nt,q)}b.all=Et;function Et(q){var nt=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var Z=q.length,et=!1;if(!Z)return this.resolve([]);for(var ht=new Array(Z),kt=0,At=-1,jt=new this(p);++At<Z;)qt(q[At],At);return jt;function qt(gt,Wt){nt.resolve(gt).then(ot,function(rt){et||(et=!0,g.reject(jt,rt))});function ot(rt){ht[Wt]=rt,++kt===Z&&!et&&(et=!0,g.resolve(jt,ht))}}}b.race=Dt;function Dt(q){var nt=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var Z=q.length,et=!1;if(!Z)return this.resolve([]);for(var ht=-1,kt=new this(p);++ht<Z;)At(q[ht]);return kt;function At(jt){nt.resolve(jt).then(function(qt){et||(et=!0,g.resolve(kt,qt))},function(qt){et||(et=!0,g.reject(kt,qt))})}}},{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 v(f,m){f=f||[],m=m||{};try{return new Blob(f,m)}catch(C){if(C.name!=="TypeError")throw C;for(var y=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,I=new y,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(y){m(null,y)},function(y){m(y)})}function k(f,m,y){typeof m=="function"&&f.then(m),typeof y=="function"&&f.catch(y)}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 B(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var G="local-forage-detect-blob-support",j=void 0,Q={},Et=Object.prototype.toString,Dt="readonly",q="readwrite";function nt(f){for(var m=f.length,y=new ArrayBuffer(m),I=new Uint8Array(y),S=0;S<m;S++)I[S]=f.charCodeAt(S);return y}function Z(f){return new b(function(m){var y=f.transaction(G,q),I=v([""]);y.objectStore(G).put(I,"key"),y.onabort=function(S){S.preventDefault(),S.stopPropagation(),m(!1)},y.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 et(f){return typeof j=="boolean"?b.resolve(j):Z(f).then(function(m){return j=m,j})}function ht(f){var m=Q[f.name],y={};y.promise=new b(function(I,S){y.resolve=I,y.reject=S}),m.deferredOperations.push(y),m.dbReady?m.dbReady=m.dbReady.then(function(){return y.promise}):m.dbReady=y.promise}function kt(f){var m=Q[f.name],y=m.deferredOperations.pop();if(y)return y.resolve(),y.promise}function At(f,m){var y=Q[f.name],I=y.deferredOperations.pop();if(I)return I.reject(m),I.promise}function jt(f,m){return new b(function(y,I){if(Q[f.name]=Q[f.name]||ci(),f.db)if(m)ht(f),f.db.close();else return y(f.db);var S=[f.name];m&&S.push(f.version);var C=h.open.apply(h,S);m&&(C.onupgradeneeded=function(O){var $=C.result;try{$.createObjectStore(f.storeName),O.oldVersion<=1&&$.createObjectStore(G)}catch(W){if(W.name==="ConstraintError")console.warn('The database "'+f.name+'" has been upgraded from version '+O.oldVersion+" to version "+O.newVersion+', but the storage "'+f.storeName+'" already exists.');else throw W}}),C.onerror=function(O){O.preventDefault(),I(C.error)},C.onsuccess=function(){var O=C.result;O.onversionchange=function($){$.target.close()},y(O),kt(f)}})}function qt(f){return jt(f,!1)}function gt(f){return jt(f,!0)}function Wt(f,m){if(!f.db)return!0;var y=!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||y){if(y){var C=f.db.version+1;C>f.version&&(f.version=C)}return!0}return!1}function ot(f){return new b(function(m,y){var I=new FileReader;I.onerror=y,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 rt(f){var m=nt(atob(f.data));return v([m],{type:f.type})}function $t(f){return f&&f.__local_forage_encoded_blob}function oi(f){var m=this,y=m._initReady().then(function(){var I=Q[m._dbInfo.name];if(I&&I.dbReady)return I.dbReady});return k(y,f,f),y}function ai(f){ht(f);for(var m=Q[f.name],y=m.forages,I=0;I<y.length;I++){var S=y[I];S._dbInfo.db&&(S._dbInfo.db.close(),S._dbInfo.db=null)}return f.db=null,qt(f).then(function(C){return f.db=C,Wt(f)?gt(f):C}).then(function(C){f.db=m.db=C;for(var O=0;O<y.length;O++)y[O]._dbInfo.db=C}).catch(function(C){throw At(f,C),C})}function oe(f,m,y,I){I===void 0&&(I=1);try{var S=f.db.transaction(f.storeName,m);y(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),gt(f)}).then(function(){return ai(f).then(function(){oe(f,m,y,I-1)})}).catch(y);y(C)}}function ci(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Ss(f){var m=this,y={db:null};if(f)for(var I in f)y[I]=f[I];var S=Q[y.name];S||(S=ci(),Q[y.name]=S),S.forages.push(m),m._initReady||(m._initReady=m.ready,m.ready=oi);var C=[];function O(){return b.resolve()}for(var $=0;$<S.forages.length;$++){var W=S.forages[$];W!==m&&C.push(W._initReady().catch(O))}var V=S.forages.slice(0);return b.all(C).then(function(){return y.db=S.db,qt(y)}).then(function(F){return y.db=F,Wt(y,m._defaultConfig.version)?gt(y):F}).then(function(F){y.db=S.db=F,m._dbInfo=y;for(var J=0;J<V.length;J++){var st=V[J];st!==m&&(st._dbInfo.db=y.db,st._dbInfo.version=y.version)}})}function un(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){oe(y._dbInfo,Dt,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._dbInfo.storeName),V=W.get(f);V.onsuccess=function(){var F=V.result;F===void 0&&(F=null),$t(F)&&(F=rt(F)),S(F)},V.onerror=function(){C(V.error)}}catch(F){C(F)}})}).catch(C)});return _(I,m),I}function Is(f,m){var y=this,I=new b(function(S,C){y.ready().then(function(){oe(y._dbInfo,Dt,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._dbInfo.storeName),V=W.openCursor(),F=1;V.onsuccess=function(){var J=V.result;if(J){var st=J.value;$t(st)&&(st=rt(st));var vt=f(st,J.key,F++);vt!==void 0?S(vt):J.continue()}else S()},V.onerror=function(){C(V.error)}}catch(J){C(J)}})}).catch(C)});return _(I,m),I}function Cs(f,m,y){var I=this;f=A(f);var S=new b(function(C,O){var $;I.ready().then(function(){return $=I._dbInfo,Et.call(m)==="[object Blob]"?et($.db).then(function(W){return W?m:ot(m)}):m}).then(function(W){oe(I._dbInfo,q,function(V,F){if(V)return O(V);try{var J=F.objectStore(I._dbInfo.storeName);W===null&&(W=void 0);var st=J.put(W,f);F.oncomplete=function(){W===void 0&&(W=null),C(W)},F.onabort=F.onerror=function(){var vt=st.error?st.error:st.transaction.error;O(vt)}}catch(vt){O(vt)}})}).catch(O)});return _(S,y),S}function li(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){oe(y._dbInfo,q,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._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 kr(f){var m=this,y=new b(function(I,S){m.ready().then(function(){oe(m._dbInfo,q,function(C,O){if(C)return S(C);try{var $=O.objectStore(m._dbInfo.storeName),W=$.clear();O.oncomplete=function(){I()},O.onabort=O.onerror=function(){var V=W.error?W.error:W.transaction.error;S(V)}}catch(V){S(V)}})}).catch(S)});return _(y,f),y}function ae(f){var m=this,y=new b(function(I,S){m.ready().then(function(){oe(m._dbInfo,Dt,function(C,O){if(C)return S(C);try{var $=O.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 _(y,f),y}function hn(f,m){var y=this,I=new b(function(S,C){if(f<0){S(null);return}y.ready().then(function(){oe(y._dbInfo,Dt,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._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 Ts(f){var m=this,y=new b(function(I,S){m.ready().then(function(){oe(m._dbInfo,Dt,function(C,O){if(C)return S(C);try{var $=O.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 _(y,f),y}function a(f,m){m=B.apply(this,arguments);var y=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||y.name,f.storeName=f.storeName||y.storeName);var I=this,S;if(!f.name)S=b.reject("Invalid arguments");else{var C=f.name===y.name&&I._dbInfo.db,O=C?b.resolve(I._dbInfo.db):qt(f).then(function($){var W=Q[f.name],V=W.forages;W.db=$;for(var F=0;F<V.length;F++)V[F]._dbInfo.db=$;return $});f.storeName?S=O.then(function($){if($.objectStoreNames.contains(f.storeName)){var W=$.version+1;ht(f);var V=Q[f.name],F=V.forages;$.close();for(var J=0;J<F.length;J++){var st=F[J];st._dbInfo.db=null,st._dbInfo.version=W}var vt=new b(function(dt,Pt){var Ct=h.open(f.name,W);Ct.onerror=function(ce){var Os=Ct.result;Os.close(),Pt(ce)},Ct.onupgradeneeded=function(){var ce=Ct.result;ce.deleteObjectStore(f.storeName)},Ct.onsuccess=function(){var ce=Ct.result;ce.close(),dt(ce)}});return vt.then(function(dt){V.db=dt;for(var Pt=0;Pt<F.length;Pt++){var Ct=F[Pt];Ct._dbInfo.db=dt,kt(Ct._dbInfo)}}).catch(function(dt){throw(At(f,dt)||b.resolve()).catch(function(){}),dt})}}):S=O.then(function($){ht(f);var W=Q[f.name],V=W.forages;$.close();for(var F=0;F<V.length;F++){var J=V[F];J._dbInfo.db=null}var st=new b(function(vt,dt){var Pt=h.deleteDatabase(f.name);Pt.onerror=function(){var Ct=Pt.result;Ct&&Ct.close(),dt(Pt.error)},Pt.onblocked=function(){console.warn('dropInstance blocked for database "'+f.name+'" until all open connections are closed')},Pt.onsuccess=function(){var Ct=Pt.result;Ct&&Ct.close(),vt(Ct)}});return st.then(function(vt){W.db=vt;for(var dt=0;dt<V.length;dt++){var Pt=V[dt];kt(Pt._dbInfo)}}).catch(function(vt){throw(At(f,vt)||b.resolve()).catch(function(){}),vt})})}return _(S,m),S}var u={_driver:"asyncStorage",_initStorage:Ss,_support:w(),iterate:Is,getItem:un,setItem:Cs,removeItem:li,clear:kr,length:ae,key:hn,keys:Ts,dropInstance:a};function d(){return typeof openDatabase=="function"}var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",D="~~local_forage_type~",M=/^~~local_forage_type~([^~]+)~/,K="__lfsc__:",pt=K.length,Nt="arbf",mt="blob",It="si08",Ut="ui08",cr="uic8",pn="si16",dn="si32",fc="ur16",gc="ui32",mc="fl32",yc="fl64",vc=pt+Nt.length,bc=Object.prototype.toString;function wc(f){var m=f.length*.75,y=f.length,I,S=0,C,O,$,W;f[f.length-1]==="="&&(m--,f[f.length-2]==="="&&m--);var V=new ArrayBuffer(m),F=new Uint8Array(V);for(I=0;I<y;I+=4)C=E.indexOf(f[I]),O=E.indexOf(f[I+1]),$=E.indexOf(f[I+2]),W=E.indexOf(f[I+3]),F[S++]=C<<2|O>>4,F[S++]=(O&15)<<4|$>>2,F[S++]=($&3)<<6|W&63;return V}function xs(f){var m=new Uint8Array(f),y="",I;for(I=0;I<m.length;I+=3)y+=E[m[I]>>2],y+=E[(m[I]&3)<<4|m[I+1]>>4],y+=E[(m[I+1]&15)<<2|m[I+2]>>6],y+=E[m[I+2]&63];return m.length%3===2?y=y.substring(0,y.length-1)+"=":m.length%3===1&&(y=y.substring(0,y.length-2)+"=="),y}function hd(f,m){var y="";if(f&&(y=bc.call(f)),f&&(y==="[object ArrayBuffer]"||f.buffer&&bc.call(f.buffer)==="[object ArrayBuffer]")){var I,S=K;f instanceof ArrayBuffer?(I=f,S+=Nt):(I=f.buffer,y==="[object Int8Array]"?S+=It:y==="[object Uint8Array]"?S+=Ut:y==="[object Uint8ClampedArray]"?S+=cr:y==="[object Int16Array]"?S+=pn:y==="[object Uint16Array]"?S+=fc:y==="[object Int32Array]"?S+=dn:y==="[object Uint32Array]"?S+=gc:y==="[object Float32Array]"?S+=mc:y==="[object Float64Array]"?S+=yc:m(new Error("Failed to get type for BinaryArray"))),m(S+xs(I))}else if(y==="[object Blob]"){var C=new FileReader;C.onload=function(){var O=D+f.type+"~"+xs(this.result);m(K+mt+O)},C.readAsArrayBuffer(f)}else try{m(JSON.stringify(f))}catch(O){console.error("Couldn't convert value into a JSON string: ",f),m(null,O)}}function pd(f){if(f.substring(0,pt)!==K)return JSON.parse(f);var m=f.substring(vc),y=f.substring(pt,vc),I;if(y===mt&&M.test(m)){var S=m.match(M);I=S[1],m=m.substring(S[0].length)}var C=wc(m);switch(y){case Nt:return C;case mt:return v([C],{type:I});case It:return new Int8Array(C);case Ut:return new Uint8Array(C);case cr:return new Uint8ClampedArray(C);case pn:return new Int16Array(C);case fc:return new Uint16Array(C);case dn:return new Int32Array(C);case gc:return new Uint32Array(C);case mc:return new Float32Array(C);case yc:return new Float64Array(C);default:throw new Error("Unkown type: "+y)}}var Ds={serialize:hd,deserialize:pd,stringToBuffer:wc,bufferToString:xs};function _c(f,m,y,I){f.executeSql("CREATE TABLE IF NOT EXISTS "+m.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],y,I)}function dd(f){var m=this,y={db:null};if(f)for(var I in f)y[I]=typeof f[I]!="string"?f[I].toString():f[I];var S=new b(function(C,O){try{y.db=openDatabase(y.name,String(y.version),y.description,y.size)}catch($){return O($)}y.db.transaction(function($){_c($,y,function(){m._dbInfo=y,C()},function(W,V){O(V)})},O)});return y.serializer=Ds,S}function Je(f,m,y,I,S,C){f.executeSql(y,I,S,function(O,$){$.code===$.SYNTAX_ERR?O.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[m.storeName],function(W,V){V.rows.length?C(W,$):_c(W,m,function(){W.executeSql(y,I,S,C)},C)},C):C(O,$)},C)}function fd(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"SELECT * FROM "+O.storeName+" WHERE key = ? LIMIT 1",[f],function(W,V){var F=V.rows.length?V.rows.item(0).value:null;F&&(F=O.serializer.deserialize(F)),S(F)},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function gd(f,m){var y=this,I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"SELECT * FROM "+O.storeName,[],function(W,V){for(var F=V.rows,J=F.length,st=0;st<J;st++){var vt=F.item(st),dt=vt.value;if(dt&&(dt=O.serializer.deserialize(dt)),dt=f(dt,vt.key,st+1),dt!==void 0){S(dt);return}}S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function Ec(f,m,y,I){var S=this;f=A(f);var C=new b(function(O,$){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(st){Je(st,V,"INSERT OR REPLACE INTO "+V.storeName+" (key, value) VALUES (?, ?)",[f,F],function(){O(W)},function(vt,dt){$(dt)})},function(st){if(st.code===st.QUOTA_ERR){if(I>0){O(Ec.apply(S,[f,W,y,I-1]));return}$(st)}})})}).catch($)});return _(C,y),C}function md(f,m,y){return Ec.apply(this,[f,m,y,1])}function yd(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"DELETE FROM "+O.storeName+" WHERE key = ?",[f],function(){S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function vd(f){var m=this,y=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(O){Je(O,C,"DELETE FROM "+C.storeName,[],function(){I()},function($,W){S(W)})})}).catch(S)});return _(y,f),y}function bd(f){var m=this,y=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(O){Je(O,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 _(y,f),y}function wd(f,m){var y=this,I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"SELECT key FROM "+O.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 _d(f){var m=this,y=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(O){Je(O,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 _(y,f),y}function Ed(f){return new b(function(m,y){f.transaction(function(I){I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(S,C){for(var O=[],$=0;$<C.rows.length;$++)O.push(C.rows.item($).name);m({db:f,storeNames:O})},function(S,C){y(C)})},function(I){y(I)})})}function Sd(f,m){m=B.apply(this,arguments);var y=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||y.name,f.storeName=f.storeName||y.storeName);var I=this,S;return f.name?S=new b(function(C){var O;f.name===y.name?O=I._dbInfo.db:O=openDatabase(f.name,"","",0),f.storeName?C({db:O,storeNames:[f.storeName]}):C(Ed(O))}).then(function(C){return new b(function(O,$){C.db.transaction(function(W){function V(vt){return new b(function(dt,Pt){W.executeSql("DROP TABLE IF EXISTS "+vt,[],function(){dt()},function(Ct,ce){Pt(ce)})})}for(var F=[],J=0,st=C.storeNames.length;J<st;J++)F.push(V(C.storeNames[J]));b.all(F).then(function(){O()}).catch(function(vt){$(vt)})},function(W){$(W)})})}):S=b.reject("Invalid arguments"),_(S,m),S}var Id={_driver:"webSQLStorage",_initStorage:dd,_support:d(),iterate:gd,getItem:fd,setItem:md,removeItem:yd,clear:vd,length:bd,key:wd,keys:_d,dropInstance:Sd};function Cd(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Sc(f,m){var y=f.name+"/";return f.storeName!==m.storeName&&(y+=f.storeName+"/"),y}function Td(){var f="_localforage_support_test";try{return localStorage.setItem(f,!0),localStorage.removeItem(f),!1}catch{return!0}}function xd(){return!Td()||localStorage.length>0}function Dd(f){var m=this,y={};if(f)for(var I in f)y[I]=f[I];return y.keyPrefix=Sc(f,m._defaultConfig),xd()?(m._dbInfo=y,y.serializer=Ds,b.resolve()):b.reject()}function Ad(f){var m=this,y=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 _(y,f),y}function Nd(f,m){var y=this;f=A(f);var I=y.ready().then(function(){var S=y._dbInfo,C=localStorage.getItem(S.keyPrefix+f);return C&&(C=S.serializer.deserialize(C)),C});return _(I,m),I}function Od(f,m){var y=this,I=y.ready().then(function(){for(var S=y._dbInfo,C=S.keyPrefix,O=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(O),W++),J!==void 0)return J}}});return _(I,m),I}function kd(f,m){var y=this,I=y.ready().then(function(){var S=y._dbInfo,C;try{C=localStorage.key(f)}catch{C=null}return C&&(C=C.substring(S.keyPrefix.length)),C});return _(I,m),I}function Pd(f){var m=this,y=m.ready().then(function(){for(var I=m._dbInfo,S=localStorage.length,C=[],O=0;O<S;O++){var $=localStorage.key(O);$.indexOf(I.keyPrefix)===0&&C.push($.substring(I.keyPrefix.length))}return C});return _(y,f),y}function Rd(f){var m=this,y=m.keys().then(function(I){return I.length});return _(y,f),y}function Ld(f,m){var y=this;f=A(f);var I=y.ready().then(function(){var S=y._dbInfo;localStorage.removeItem(S.keyPrefix+f)});return _(I,m),I}function Md(f,m,y){var I=this;f=A(f);var S=I.ready().then(function(){m===void 0&&(m=null);var C=m;return new b(function(O,$){var W=I._dbInfo;W.serializer.serialize(m,function(V,F){if(F)$(F);else try{localStorage.setItem(W.keyPrefix+f,V),O(C)}catch(J){(J.name==="QuotaExceededError"||J.name==="NS_ERROR_DOM_QUOTA_REACHED")&&$(J),$(J)}})})});return _(S,y),S}function Ud(f,m){if(m=B.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var y=this.config();f.name=f.name||y.name,f.storeName=f.storeName||y.storeName}var I=this,S;return f.name?S=new b(function(C){f.storeName?C(Sc(f,I._defaultConfig)):C(f.name+"/")}).then(function(C){for(var O=localStorage.length-1;O>=0;O--){var $=localStorage.key(O);$.indexOf(C)===0&&localStorage.removeItem($)}}):S=b.reject("Invalid arguments"),_(S,m),S}var Bd={_driver:"localStorageWrapper",_initStorage:Dd,_support:Cd(),iterate:Od,getItem:Nd,setItem:Md,removeItem:Ld,clear:Ad,length:Rd,key:kd,keys:Pd,dropInstance:Ud},jd=function(f,m){return f===m||typeof f=="number"&&typeof m=="number"&&isNaN(f)&&isNaN(m)},$d=function(f,m){for(var y=f.length,I=0;I<y;){if(jd(f[I],m))return!0;I++}return!1},Ic=Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"},fn={},Cc={},Pr={INDEXEDDB:u,WEBSQL:Id,LOCALSTORAGE:Bd},Fd=[Pr.INDEXEDDB._driver,Pr.WEBSQL._driver,Pr.LOCALSTORAGE._driver],ui=["dropInstance"],As=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ui),Hd={description:"",driver:Fd.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Vd(f,m){f[m]=function(){var y=arguments;return f.ready().then(function(){return f[m].apply(f,y)})}}function Ns(){for(var f=1;f<arguments.length;f++){var m=arguments[f];if(m)for(var y in m)m.hasOwnProperty(y)&&(Ic(m[y])?arguments[0][y]=m[y].slice():arguments[0][y]=m[y])}return arguments[0]}var qd=function(){function f(m){p(this,f);for(var y in Pr)if(Pr.hasOwnProperty(y)){var I=Pr[y],S=I._driver;this[y]=S,fn[S]||this.defineDriver(I)}this._defaultConfig=Ns({},Hd),this._config=Ns({},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 y in m){if(y==="storeName"&&(m[y]=m[y].replace(/\W/g,"_")),y==="version"&&typeof m[y]!="number")return new Error("Database version must be a number.");this._config[y]=m[y]}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,y,I){var S=new b(function(C,O){try{var $=m._driver,W=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){O(W);return}for(var V=As.concat("_initStorage"),F=0,J=V.length;F<J;F++){var st=V[F],vt=!$d(ui,st);if((vt||m[st])&&typeof m[st]!="function"){O(W);return}}var dt=function(){for(var Ct=function(Gd){return function(){var zd=new Error("Method "+Gd+" is not implemented by the current driver"),Tc=b.reject(zd);return _(Tc,arguments[arguments.length-1]),Tc}},ce=0,Os=ui.length;ce<Os;ce++){var ks=ui[ce];m[ks]||(m[ks]=Ct(ks))}};dt();var Pt=function(Ct){fn[$]&&console.info("Redefining LocalForage driver: "+$),fn[$]=m,Cc[$]=Ct,C()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(Pt,O):Pt(!!m._support):Pt(!0)}catch(Ct){O(Ct)}});return k(S,y,I),S},f.prototype.driver=function(){return this._driver||null},f.prototype.getDriver=function(m,y,I){var S=fn[m]?b.resolve(fn[m]):b.reject(new Error("Driver not found."));return k(S,y,I),S},f.prototype.getSerializer=function(m){var y=b.resolve(Ds);return k(y,m),y},f.prototype.ready=function(m){var y=this,I=y._driverSet.then(function(){return y._ready===null&&(y._ready=y._initDriver()),y._ready});return k(I,m,m),I},f.prototype.setDriver=function(m,y,I){var S=this;Ic(m)||(m=[m]);var C=this._getSupportedDrivers(m);function O(){S._config.driver=S.driver()}function $(F){return S._extend(F),O(),S._ready=S._initStorage(S._config),S._ready}function W(F){return function(){var J=0;function st(){for(;J<F.length;){var vt=F[J];return J++,S._dbInfo=null,S._ready=null,S.getDriver(vt).then($).catch(st)}O();var dt=new Error("No available storage method found.");return S._driverSet=b.reject(dt),S._driverSet}return st()}}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,O(),S._wrapLibraryMethodsWithReady(),S._initDriver=W(C)})}).catch(function(){O();var F=new Error("No available storage method found.");return S._driverSet=b.reject(F),S._driverSet}),k(this._driverSet,y,I),this._driverSet},f.prototype.supports=function(m){return!!Cc[m]},f.prototype._extend=function(m){Ns(this,m)},f.prototype._getSupportedDrivers=function(m){for(var y=[],I=0,S=m.length;I<S;I++){var C=m[I];this.supports(C)&&y.push(C)}return y},f.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,y=As.length;m<y;m++)Vd(this,As[m])},f.prototype.createInstance=function(m){return new f(m)},f}(),Wd=new qd;o.exports=Wd},{3:3}]},{},[4])(4)})}),Au=ts(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}),hf=ts((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(v,b){var _=function(A){var B=typeof Request<"u"&&l instanceof Request?l.clone():l;s(B,p).then(function(G){if(Array.isArray(w)&&w.indexOf(G.status)===-1)v(G);else if(typeof w=="function")try{return Promise.resolve(w(A,null,G)).then(function(j){j?k(A,null,G):v(G)}).catch(b)}catch(j){b(j)}else A<g?k(A,null,G):v(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,B,G){var j=typeof h=="function"?h(A,B,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})}),pf="9.12.12",H=class mo{static SDK_VERSION=pf;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=mo.SDK_VERSION.split(".").map(r=>r.padStart(2,"0")).join("");mo.SDK_VERSION_CODE=parseInt(e,10)}},We={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`},pe=Oe(tn()),x=class{static log(...t){pe.default.info(...t)}static debug(...t){pe.default.debug(...t)}static error(...t){pe.default.error(...t)}static warn(...t){pe.default.warn(...t)}static info(...t){pe.default.info(...t)}static trace(...t){pe.default.trace(...t)}};function df(t=H.LOG_PREFIX){pe.default.useDefaults({formatter:function(r){r.unshift(`${t} (v${H.SDK_VERSION}):`)}});let e=Nu();(e==="1"||e==="on")&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?pe.default.setLevel(pe.default[localStorage.cooeeLogLevel]):pe.default.setLevel(We.debug?pe.default.TRACE:pe.default.OFF)}function Nu(){return new URL(location.href).searchParams?.get("cooee-debug")}function ff(){let t=`
1
+ "use strict";(()=>{var Kd=Object.create;var xc=Object.defineProperty;var Yd=Object.getOwnPropertyDescriptor;var Jd=Object.getOwnPropertyNames;var Xd=Object.getPrototypeOf,Qd=Object.prototype.hasOwnProperty;var Zd=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Jd(e))!Qd.call(t,i)&&i!==r&&xc(t,i,{get:()=>e[i],enumerable:!(n=Yd(e,i))||n.enumerable});return t};var tf=(t,e,r)=>(r=t!=null?Kd(Xd(t)):{},Zd(e||!t||!t.__esModule?xc(r,"default",{value:t,enumerable:!0}):r,t));var ef=Object.create,ia=Object.defineProperty,rf=Object.defineProperties,nf=Object.getOwnPropertyDescriptor,sf=Object.getOwnPropertyDescriptors,of=Object.getOwnPropertyNames,Ri=Object.getOwnPropertySymbols,af=Object.getPrototypeOf,sa=Object.prototype.hasOwnProperty,Du=Object.prototype.propertyIsEnumerable,Dc=(t,e,r)=>e in t?ia(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,T=(t,e)=>{for(var r in e||={})sa.call(e,r)&&Dc(t,r,e[r]);if(Ri)for(var r of Ri(e))Du.call(e,r)&&Dc(t,r,e[r]);return t},ct=(t,e)=>rf(t,sf(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')}),cf=(t,e)=>{var r={};for(var n in t)sa.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&&Du.call(t,n)&&(r[n]=t[n]);return r},ts=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),lf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of of(e))!sa.call(t,i)&&i!==r&&ia(t,i,{get:()=>e[i],enumerable:!(n=nf(e,i))||n.enumerable});return t},Oe=(t,e,r)=>(r=t!=null?ef(af(t)):{},lf(e||!t||!t.__esModule?ia(r,"default",{value:t,enumerable:!0}):r,t)),tn=ts((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],v,b;for(b=1;b<h.length;b++)for(v in h[b])!(v in w)&&h[b].hasOwnProperty(v)&&(w[v]=h[b][v]);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={},v=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):v(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,_),v(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)}),uf=ts((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,v){if(!c[w]){if(!o[w]){var b=typeof hi=="function"&&hi;if(!v&&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 B=o[w][1][A];return p(B||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),v=l.document.createTextNode("");w.observe(v,{characterData:!0}),g=function(){v.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,Q=k.length;Q;){for(j=k,k=[],G=-1;++G<Q;)j[G]();Q=k.length}_=!1}o.exports=B;function B(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"],v=["PENDING"];o.exports=b;function b(q){if(typeof q!="function")throw new TypeError("resolver must be a function");this.state=v,this.queue=[],this.outcome=void 0,q!==p&&B(this,q)}b.prototype.catch=function(q){return this.then(null,q)},b.prototype.then=function(q,nt){if(typeof q!="function"&&this.state===w||typeof nt!="function"&&this.state===h)return this;var Z=new this.constructor(p);if(this.state!==v){var et=this.state===w?q:nt;k(Z,et,this.outcome)}else this.queue.push(new _(Z,q,nt));return Z};function _(q,nt,Z){this.promise=q,typeof nt=="function"&&(this.onFulfilled=nt,this.callFulfilled=this.otherCallFulfilled),typeof Z=="function"&&(this.onRejected=Z,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,nt,Z){l(function(){var et;try{et=nt(Z)}catch(ht){return g.reject(q,ht)}et===q?g.reject(q,new TypeError("Cannot resolve promise with itself")):g.resolve(q,et)})}g.resolve=function(q,nt){var Z=G(A,nt);if(Z.status==="error")return g.reject(q,Z.value);var et=Z.value;if(et)B(q,et);else{q.state=w,q.outcome=nt;for(var ht=-1,kt=q.queue.length;++ht<kt;)q.queue[ht].callFulfilled(nt)}return q},g.reject=function(q,nt){q.state=h,q.outcome=nt;for(var Z=-1,et=q.queue.length;++Z<et;)q.queue[Z].callRejected(nt);return q};function A(q){var nt=q&&q.then;if(q&&(typeof q=="object"||typeof q=="function")&&typeof nt=="function")return function(){nt.apply(q,arguments)}}function B(q,nt){var Z=!1;function et(jt){Z||(Z=!0,g.reject(q,jt))}function ht(jt){Z||(Z=!0,g.resolve(q,jt))}function kt(){nt(ht,et)}var At=G(kt);At.status==="error"&&et(At.value)}function G(q,nt){var Z={};try{Z.value=q(nt),Z.status="success"}catch(et){Z.status="error",Z.value=et}return Z}b.resolve=j;function j(q){return q instanceof this?q:g.resolve(new this(p),q)}b.reject=Q;function Q(q){var nt=new this(p);return g.reject(nt,q)}b.all=Et;function Et(q){var nt=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var Z=q.length,et=!1;if(!Z)return this.resolve([]);for(var ht=new Array(Z),kt=0,At=-1,jt=new this(p);++At<Z;)qt(q[At],At);return jt;function qt(gt,Wt){nt.resolve(gt).then(ot,function(rt){et||(et=!0,g.reject(jt,rt))});function ot(rt){ht[Wt]=rt,++kt===Z&&!et&&(et=!0,g.resolve(jt,ht))}}}b.race=Dt;function Dt(q){var nt=this;if(Object.prototype.toString.call(q)!=="[object Array]")return this.reject(new TypeError("must be an array"));var Z=q.length,et=!1;if(!Z)return this.resolve([]);for(var ht=-1,kt=new this(p);++ht<Z;)At(q[ht]);return kt;function At(jt){nt.resolve(jt).then(function(qt){et||(et=!0,g.resolve(kt,qt))},function(qt){et||(et=!0,g.reject(kt,qt))})}}},{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 v(f,m){f=f||[],m=m||{};try{return new Blob(f,m)}catch(C){if(C.name!=="TypeError")throw C;for(var y=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,I=new y,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(y){m(null,y)},function(y){m(y)})}function k(f,m,y){typeof m=="function"&&f.then(m),typeof y=="function"&&f.catch(y)}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 B(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var G="local-forage-detect-blob-support",j=void 0,Q={},Et=Object.prototype.toString,Dt="readonly",q="readwrite";function nt(f){for(var m=f.length,y=new ArrayBuffer(m),I=new Uint8Array(y),S=0;S<m;S++)I[S]=f.charCodeAt(S);return y}function Z(f){return new b(function(m){var y=f.transaction(G,q),I=v([""]);y.objectStore(G).put(I,"key"),y.onabort=function(S){S.preventDefault(),S.stopPropagation(),m(!1)},y.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 et(f){return typeof j=="boolean"?b.resolve(j):Z(f).then(function(m){return j=m,j})}function ht(f){var m=Q[f.name],y={};y.promise=new b(function(I,S){y.resolve=I,y.reject=S}),m.deferredOperations.push(y),m.dbReady?m.dbReady=m.dbReady.then(function(){return y.promise}):m.dbReady=y.promise}function kt(f){var m=Q[f.name],y=m.deferredOperations.pop();if(y)return y.resolve(),y.promise}function At(f,m){var y=Q[f.name],I=y.deferredOperations.pop();if(I)return I.reject(m),I.promise}function jt(f,m){return new b(function(y,I){if(Q[f.name]=Q[f.name]||ci(),f.db)if(m)ht(f),f.db.close();else return y(f.db);var S=[f.name];m&&S.push(f.version);var C=h.open.apply(h,S);m&&(C.onupgradeneeded=function(O){var $=C.result;try{$.createObjectStore(f.storeName),O.oldVersion<=1&&$.createObjectStore(G)}catch(W){if(W.name==="ConstraintError")console.warn('The database "'+f.name+'" has been upgraded from version '+O.oldVersion+" to version "+O.newVersion+', but the storage "'+f.storeName+'" already exists.');else throw W}}),C.onerror=function(O){O.preventDefault(),I(C.error)},C.onsuccess=function(){var O=C.result;O.onversionchange=function($){$.target.close()},y(O),kt(f)}})}function qt(f){return jt(f,!1)}function gt(f){return jt(f,!0)}function Wt(f,m){if(!f.db)return!0;var y=!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||y){if(y){var C=f.db.version+1;C>f.version&&(f.version=C)}return!0}return!1}function ot(f){return new b(function(m,y){var I=new FileReader;I.onerror=y,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 rt(f){var m=nt(atob(f.data));return v([m],{type:f.type})}function $t(f){return f&&f.__local_forage_encoded_blob}function oi(f){var m=this,y=m._initReady().then(function(){var I=Q[m._dbInfo.name];if(I&&I.dbReady)return I.dbReady});return k(y,f,f),y}function ai(f){ht(f);for(var m=Q[f.name],y=m.forages,I=0;I<y.length;I++){var S=y[I];S._dbInfo.db&&(S._dbInfo.db.close(),S._dbInfo.db=null)}return f.db=null,qt(f).then(function(C){return f.db=C,Wt(f)?gt(f):C}).then(function(C){f.db=m.db=C;for(var O=0;O<y.length;O++)y[O]._dbInfo.db=C}).catch(function(C){throw At(f,C),C})}function oe(f,m,y,I){I===void 0&&(I=1);try{var S=f.db.transaction(f.storeName,m);y(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),gt(f)}).then(function(){return ai(f).then(function(){oe(f,m,y,I-1)})}).catch(y);y(C)}}function ci(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Ss(f){var m=this,y={db:null};if(f)for(var I in f)y[I]=f[I];var S=Q[y.name];S||(S=ci(),Q[y.name]=S),S.forages.push(m),m._initReady||(m._initReady=m.ready,m.ready=oi);var C=[];function O(){return b.resolve()}for(var $=0;$<S.forages.length;$++){var W=S.forages[$];W!==m&&C.push(W._initReady().catch(O))}var V=S.forages.slice(0);return b.all(C).then(function(){return y.db=S.db,qt(y)}).then(function(F){return y.db=F,Wt(y,m._defaultConfig.version)?gt(y):F}).then(function(F){y.db=S.db=F,m._dbInfo=y;for(var J=0;J<V.length;J++){var st=V[J];st!==m&&(st._dbInfo.db=y.db,st._dbInfo.version=y.version)}})}function un(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){oe(y._dbInfo,Dt,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._dbInfo.storeName),V=W.get(f);V.onsuccess=function(){var F=V.result;F===void 0&&(F=null),$t(F)&&(F=rt(F)),S(F)},V.onerror=function(){C(V.error)}}catch(F){C(F)}})}).catch(C)});return _(I,m),I}function Is(f,m){var y=this,I=new b(function(S,C){y.ready().then(function(){oe(y._dbInfo,Dt,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._dbInfo.storeName),V=W.openCursor(),F=1;V.onsuccess=function(){var J=V.result;if(J){var st=J.value;$t(st)&&(st=rt(st));var vt=f(st,J.key,F++);vt!==void 0?S(vt):J.continue()}else S()},V.onerror=function(){C(V.error)}}catch(J){C(J)}})}).catch(C)});return _(I,m),I}function Cs(f,m,y){var I=this;f=A(f);var S=new b(function(C,O){var $;I.ready().then(function(){return $=I._dbInfo,Et.call(m)==="[object Blob]"?et($.db).then(function(W){return W?m:ot(m)}):m}).then(function(W){oe(I._dbInfo,q,function(V,F){if(V)return O(V);try{var J=F.objectStore(I._dbInfo.storeName);W===null&&(W=void 0);var st=J.put(W,f);F.oncomplete=function(){W===void 0&&(W=null),C(W)},F.onabort=F.onerror=function(){var vt=st.error?st.error:st.transaction.error;O(vt)}}catch(vt){O(vt)}})}).catch(O)});return _(S,y),S}function li(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){oe(y._dbInfo,q,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._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 kr(f){var m=this,y=new b(function(I,S){m.ready().then(function(){oe(m._dbInfo,q,function(C,O){if(C)return S(C);try{var $=O.objectStore(m._dbInfo.storeName),W=$.clear();O.oncomplete=function(){I()},O.onabort=O.onerror=function(){var V=W.error?W.error:W.transaction.error;S(V)}}catch(V){S(V)}})}).catch(S)});return _(y,f),y}function ae(f){var m=this,y=new b(function(I,S){m.ready().then(function(){oe(m._dbInfo,Dt,function(C,O){if(C)return S(C);try{var $=O.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 _(y,f),y}function hn(f,m){var y=this,I=new b(function(S,C){if(f<0){S(null);return}y.ready().then(function(){oe(y._dbInfo,Dt,function(O,$){if(O)return C(O);try{var W=$.objectStore(y._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 Ts(f){var m=this,y=new b(function(I,S){m.ready().then(function(){oe(m._dbInfo,Dt,function(C,O){if(C)return S(C);try{var $=O.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 _(y,f),y}function a(f,m){m=B.apply(this,arguments);var y=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||y.name,f.storeName=f.storeName||y.storeName);var I=this,S;if(!f.name)S=b.reject("Invalid arguments");else{var C=f.name===y.name&&I._dbInfo.db,O=C?b.resolve(I._dbInfo.db):qt(f).then(function($){var W=Q[f.name],V=W.forages;W.db=$;for(var F=0;F<V.length;F++)V[F]._dbInfo.db=$;return $});f.storeName?S=O.then(function($){if($.objectStoreNames.contains(f.storeName)){var W=$.version+1;ht(f);var V=Q[f.name],F=V.forages;$.close();for(var J=0;J<F.length;J++){var st=F[J];st._dbInfo.db=null,st._dbInfo.version=W}var vt=new b(function(dt,Pt){var Ct=h.open(f.name,W);Ct.onerror=function(ce){var Os=Ct.result;Os.close(),Pt(ce)},Ct.onupgradeneeded=function(){var ce=Ct.result;ce.deleteObjectStore(f.storeName)},Ct.onsuccess=function(){var ce=Ct.result;ce.close(),dt(ce)}});return vt.then(function(dt){V.db=dt;for(var Pt=0;Pt<F.length;Pt++){var Ct=F[Pt];Ct._dbInfo.db=dt,kt(Ct._dbInfo)}}).catch(function(dt){throw(At(f,dt)||b.resolve()).catch(function(){}),dt})}}):S=O.then(function($){ht(f);var W=Q[f.name],V=W.forages;$.close();for(var F=0;F<V.length;F++){var J=V[F];J._dbInfo.db=null}var st=new b(function(vt,dt){var Pt=h.deleteDatabase(f.name);Pt.onerror=function(){var Ct=Pt.result;Ct&&Ct.close(),dt(Pt.error)},Pt.onblocked=function(){console.warn('dropInstance blocked for database "'+f.name+'" until all open connections are closed')},Pt.onsuccess=function(){var Ct=Pt.result;Ct&&Ct.close(),vt(Ct)}});return st.then(function(vt){W.db=vt;for(var dt=0;dt<V.length;dt++){var Pt=V[dt];kt(Pt._dbInfo)}}).catch(function(vt){throw(At(f,vt)||b.resolve()).catch(function(){}),vt})})}return _(S,m),S}var u={_driver:"asyncStorage",_initStorage:Ss,_support:w(),iterate:Is,getItem:un,setItem:Cs,removeItem:li,clear:kr,length:ae,key:hn,keys:Ts,dropInstance:a};function d(){return typeof openDatabase=="function"}var E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",D="~~local_forage_type~",M=/^~~local_forage_type~([^~]+)~/,K="__lfsc__:",pt=K.length,Nt="arbf",mt="blob",It="si08",Ut="ui08",cr="uic8",pn="si16",dn="si32",fc="ur16",gc="ui32",mc="fl32",yc="fl64",vc=pt+Nt.length,bc=Object.prototype.toString;function wc(f){var m=f.length*.75,y=f.length,I,S=0,C,O,$,W;f[f.length-1]==="="&&(m--,f[f.length-2]==="="&&m--);var V=new ArrayBuffer(m),F=new Uint8Array(V);for(I=0;I<y;I+=4)C=E.indexOf(f[I]),O=E.indexOf(f[I+1]),$=E.indexOf(f[I+2]),W=E.indexOf(f[I+3]),F[S++]=C<<2|O>>4,F[S++]=(O&15)<<4|$>>2,F[S++]=($&3)<<6|W&63;return V}function xs(f){var m=new Uint8Array(f),y="",I;for(I=0;I<m.length;I+=3)y+=E[m[I]>>2],y+=E[(m[I]&3)<<4|m[I+1]>>4],y+=E[(m[I+1]&15)<<2|m[I+2]>>6],y+=E[m[I+2]&63];return m.length%3===2?y=y.substring(0,y.length-1)+"=":m.length%3===1&&(y=y.substring(0,y.length-2)+"=="),y}function hd(f,m){var y="";if(f&&(y=bc.call(f)),f&&(y==="[object ArrayBuffer]"||f.buffer&&bc.call(f.buffer)==="[object ArrayBuffer]")){var I,S=K;f instanceof ArrayBuffer?(I=f,S+=Nt):(I=f.buffer,y==="[object Int8Array]"?S+=It:y==="[object Uint8Array]"?S+=Ut:y==="[object Uint8ClampedArray]"?S+=cr:y==="[object Int16Array]"?S+=pn:y==="[object Uint16Array]"?S+=fc:y==="[object Int32Array]"?S+=dn:y==="[object Uint32Array]"?S+=gc:y==="[object Float32Array]"?S+=mc:y==="[object Float64Array]"?S+=yc:m(new Error("Failed to get type for BinaryArray"))),m(S+xs(I))}else if(y==="[object Blob]"){var C=new FileReader;C.onload=function(){var O=D+f.type+"~"+xs(this.result);m(K+mt+O)},C.readAsArrayBuffer(f)}else try{m(JSON.stringify(f))}catch(O){console.error("Couldn't convert value into a JSON string: ",f),m(null,O)}}function pd(f){if(f.substring(0,pt)!==K)return JSON.parse(f);var m=f.substring(vc),y=f.substring(pt,vc),I;if(y===mt&&M.test(m)){var S=m.match(M);I=S[1],m=m.substring(S[0].length)}var C=wc(m);switch(y){case Nt:return C;case mt:return v([C],{type:I});case It:return new Int8Array(C);case Ut:return new Uint8Array(C);case cr:return new Uint8ClampedArray(C);case pn:return new Int16Array(C);case fc:return new Uint16Array(C);case dn:return new Int32Array(C);case gc:return new Uint32Array(C);case mc:return new Float32Array(C);case yc:return new Float64Array(C);default:throw new Error("Unkown type: "+y)}}var Ds={serialize:hd,deserialize:pd,stringToBuffer:wc,bufferToString:xs};function _c(f,m,y,I){f.executeSql("CREATE TABLE IF NOT EXISTS "+m.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],y,I)}function dd(f){var m=this,y={db:null};if(f)for(var I in f)y[I]=typeof f[I]!="string"?f[I].toString():f[I];var S=new b(function(C,O){try{y.db=openDatabase(y.name,String(y.version),y.description,y.size)}catch($){return O($)}y.db.transaction(function($){_c($,y,function(){m._dbInfo=y,C()},function(W,V){O(V)})},O)});return y.serializer=Ds,S}function Je(f,m,y,I,S,C){f.executeSql(y,I,S,function(O,$){$.code===$.SYNTAX_ERR?O.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[m.storeName],function(W,V){V.rows.length?C(W,$):_c(W,m,function(){W.executeSql(y,I,S,C)},C)},C):C(O,$)},C)}function fd(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"SELECT * FROM "+O.storeName+" WHERE key = ? LIMIT 1",[f],function(W,V){var F=V.rows.length?V.rows.item(0).value:null;F&&(F=O.serializer.deserialize(F)),S(F)},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function gd(f,m){var y=this,I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"SELECT * FROM "+O.storeName,[],function(W,V){for(var F=V.rows,J=F.length,st=0;st<J;st++){var vt=F.item(st),dt=vt.value;if(dt&&(dt=O.serializer.deserialize(dt)),dt=f(dt,vt.key,st+1),dt!==void 0){S(dt);return}}S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function Ec(f,m,y,I){var S=this;f=A(f);var C=new b(function(O,$){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(st){Je(st,V,"INSERT OR REPLACE INTO "+V.storeName+" (key, value) VALUES (?, ?)",[f,F],function(){O(W)},function(vt,dt){$(dt)})},function(st){if(st.code===st.QUOTA_ERR){if(I>0){O(Ec.apply(S,[f,W,y,I-1]));return}$(st)}})})}).catch($)});return _(C,y),C}function md(f,m,y){return Ec.apply(this,[f,m,y,1])}function yd(f,m){var y=this;f=A(f);var I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"DELETE FROM "+O.storeName+" WHERE key = ?",[f],function(){S()},function(W,V){C(V)})})}).catch(C)});return _(I,m),I}function vd(f){var m=this,y=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(O){Je(O,C,"DELETE FROM "+C.storeName,[],function(){I()},function($,W){S(W)})})}).catch(S)});return _(y,f),y}function bd(f){var m=this,y=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(O){Je(O,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 _(y,f),y}function wd(f,m){var y=this,I=new b(function(S,C){y.ready().then(function(){var O=y._dbInfo;O.db.transaction(function($){Je($,O,"SELECT key FROM "+O.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 _d(f){var m=this,y=new b(function(I,S){m.ready().then(function(){var C=m._dbInfo;C.db.transaction(function(O){Je(O,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 _(y,f),y}function Ed(f){return new b(function(m,y){f.transaction(function(I){I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(S,C){for(var O=[],$=0;$<C.rows.length;$++)O.push(C.rows.item($).name);m({db:f,storeNames:O})},function(S,C){y(C)})},function(I){y(I)})})}function Sd(f,m){m=B.apply(this,arguments);var y=this.config();f=typeof f!="function"&&f||{},f.name||(f.name=f.name||y.name,f.storeName=f.storeName||y.storeName);var I=this,S;return f.name?S=new b(function(C){var O;f.name===y.name?O=I._dbInfo.db:O=openDatabase(f.name,"","",0),f.storeName?C({db:O,storeNames:[f.storeName]}):C(Ed(O))}).then(function(C){return new b(function(O,$){C.db.transaction(function(W){function V(vt){return new b(function(dt,Pt){W.executeSql("DROP TABLE IF EXISTS "+vt,[],function(){dt()},function(Ct,ce){Pt(ce)})})}for(var F=[],J=0,st=C.storeNames.length;J<st;J++)F.push(V(C.storeNames[J]));b.all(F).then(function(){O()}).catch(function(vt){$(vt)})},function(W){$(W)})})}):S=b.reject("Invalid arguments"),_(S,m),S}var Id={_driver:"webSQLStorage",_initStorage:dd,_support:d(),iterate:gd,getItem:fd,setItem:md,removeItem:yd,clear:vd,length:bd,key:wd,keys:_d,dropInstance:Sd};function Cd(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Sc(f,m){var y=f.name+"/";return f.storeName!==m.storeName&&(y+=f.storeName+"/"),y}function Td(){var f="_localforage_support_test";try{return localStorage.setItem(f,!0),localStorage.removeItem(f),!1}catch{return!0}}function xd(){return!Td()||localStorage.length>0}function Dd(f){var m=this,y={};if(f)for(var I in f)y[I]=f[I];return y.keyPrefix=Sc(f,m._defaultConfig),xd()?(m._dbInfo=y,y.serializer=Ds,b.resolve()):b.reject()}function Ad(f){var m=this,y=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 _(y,f),y}function Nd(f,m){var y=this;f=A(f);var I=y.ready().then(function(){var S=y._dbInfo,C=localStorage.getItem(S.keyPrefix+f);return C&&(C=S.serializer.deserialize(C)),C});return _(I,m),I}function Od(f,m){var y=this,I=y.ready().then(function(){for(var S=y._dbInfo,C=S.keyPrefix,O=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(O),W++),J!==void 0)return J}}});return _(I,m),I}function kd(f,m){var y=this,I=y.ready().then(function(){var S=y._dbInfo,C;try{C=localStorage.key(f)}catch{C=null}return C&&(C=C.substring(S.keyPrefix.length)),C});return _(I,m),I}function Pd(f){var m=this,y=m.ready().then(function(){for(var I=m._dbInfo,S=localStorage.length,C=[],O=0;O<S;O++){var $=localStorage.key(O);$.indexOf(I.keyPrefix)===0&&C.push($.substring(I.keyPrefix.length))}return C});return _(y,f),y}function Rd(f){var m=this,y=m.keys().then(function(I){return I.length});return _(y,f),y}function Ld(f,m){var y=this;f=A(f);var I=y.ready().then(function(){var S=y._dbInfo;localStorage.removeItem(S.keyPrefix+f)});return _(I,m),I}function Md(f,m,y){var I=this;f=A(f);var S=I.ready().then(function(){m===void 0&&(m=null);var C=m;return new b(function(O,$){var W=I._dbInfo;W.serializer.serialize(m,function(V,F){if(F)$(F);else try{localStorage.setItem(W.keyPrefix+f,V),O(C)}catch(J){(J.name==="QuotaExceededError"||J.name==="NS_ERROR_DOM_QUOTA_REACHED")&&$(J),$(J)}})})});return _(S,y),S}function Ud(f,m){if(m=B.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var y=this.config();f.name=f.name||y.name,f.storeName=f.storeName||y.storeName}var I=this,S;return f.name?S=new b(function(C){f.storeName?C(Sc(f,I._defaultConfig)):C(f.name+"/")}).then(function(C){for(var O=localStorage.length-1;O>=0;O--){var $=localStorage.key(O);$.indexOf(C)===0&&localStorage.removeItem($)}}):S=b.reject("Invalid arguments"),_(S,m),S}var Bd={_driver:"localStorageWrapper",_initStorage:Dd,_support:Cd(),iterate:Od,getItem:Nd,setItem:Md,removeItem:Ld,clear:Ad,length:Rd,key:kd,keys:Pd,dropInstance:Ud},jd=function(f,m){return f===m||typeof f=="number"&&typeof m=="number"&&isNaN(f)&&isNaN(m)},$d=function(f,m){for(var y=f.length,I=0;I<y;){if(jd(f[I],m))return!0;I++}return!1},Ic=Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"},fn={},Cc={},Pr={INDEXEDDB:u,WEBSQL:Id,LOCALSTORAGE:Bd},Fd=[Pr.INDEXEDDB._driver,Pr.WEBSQL._driver,Pr.LOCALSTORAGE._driver],ui=["dropInstance"],As=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ui),Hd={description:"",driver:Fd.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Vd(f,m){f[m]=function(){var y=arguments;return f.ready().then(function(){return f[m].apply(f,y)})}}function Ns(){for(var f=1;f<arguments.length;f++){var m=arguments[f];if(m)for(var y in m)m.hasOwnProperty(y)&&(Ic(m[y])?arguments[0][y]=m[y].slice():arguments[0][y]=m[y])}return arguments[0]}var qd=function(){function f(m){p(this,f);for(var y in Pr)if(Pr.hasOwnProperty(y)){var I=Pr[y],S=I._driver;this[y]=S,fn[S]||this.defineDriver(I)}this._defaultConfig=Ns({},Hd),this._config=Ns({},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 y in m){if(y==="storeName"&&(m[y]=m[y].replace(/\W/g,"_")),y==="version"&&typeof m[y]!="number")return new Error("Database version must be a number.");this._config[y]=m[y]}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,y,I){var S=new b(function(C,O){try{var $=m._driver,W=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){O(W);return}for(var V=As.concat("_initStorage"),F=0,J=V.length;F<J;F++){var st=V[F],vt=!$d(ui,st);if((vt||m[st])&&typeof m[st]!="function"){O(W);return}}var dt=function(){for(var Ct=function(Gd){return function(){var zd=new Error("Method "+Gd+" is not implemented by the current driver"),Tc=b.reject(zd);return _(Tc,arguments[arguments.length-1]),Tc}},ce=0,Os=ui.length;ce<Os;ce++){var ks=ui[ce];m[ks]||(m[ks]=Ct(ks))}};dt();var Pt=function(Ct){fn[$]&&console.info("Redefining LocalForage driver: "+$),fn[$]=m,Cc[$]=Ct,C()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(Pt,O):Pt(!!m._support):Pt(!0)}catch(Ct){O(Ct)}});return k(S,y,I),S},f.prototype.driver=function(){return this._driver||null},f.prototype.getDriver=function(m,y,I){var S=fn[m]?b.resolve(fn[m]):b.reject(new Error("Driver not found."));return k(S,y,I),S},f.prototype.getSerializer=function(m){var y=b.resolve(Ds);return k(y,m),y},f.prototype.ready=function(m){var y=this,I=y._driverSet.then(function(){return y._ready===null&&(y._ready=y._initDriver()),y._ready});return k(I,m,m),I},f.prototype.setDriver=function(m,y,I){var S=this;Ic(m)||(m=[m]);var C=this._getSupportedDrivers(m);function O(){S._config.driver=S.driver()}function $(F){return S._extend(F),O(),S._ready=S._initStorage(S._config),S._ready}function W(F){return function(){var J=0;function st(){for(;J<F.length;){var vt=F[J];return J++,S._dbInfo=null,S._ready=null,S.getDriver(vt).then($).catch(st)}O();var dt=new Error("No available storage method found.");return S._driverSet=b.reject(dt),S._driverSet}return st()}}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,O(),S._wrapLibraryMethodsWithReady(),S._initDriver=W(C)})}).catch(function(){O();var F=new Error("No available storage method found.");return S._driverSet=b.reject(F),S._driverSet}),k(this._driverSet,y,I),this._driverSet},f.prototype.supports=function(m){return!!Cc[m]},f.prototype._extend=function(m){Ns(this,m)},f.prototype._getSupportedDrivers=function(m){for(var y=[],I=0,S=m.length;I<S;I++){var C=m[I];this.supports(C)&&y.push(C)}return y},f.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,y=As.length;m<y;m++)Vd(this,As[m])},f.prototype.createInstance=function(m){return new f(m)},f}(),Wd=new qd;o.exports=Wd},{3:3}]},{},[4])(4)})}),Au=ts(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}),hf=ts((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(v,b){var _=function(A){var B=typeof Request<"u"&&l instanceof Request?l.clone():l;s(B,p).then(function(G){if(Array.isArray(w)&&w.indexOf(G.status)===-1)v(G);else if(typeof w=="function")try{return Promise.resolve(w(A,null,G)).then(function(j){j?k(A,null,G):v(G)}).catch(b)}catch(j){b(j)}else A<g?k(A,null,G):v(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,B,G){var j=typeof h=="function"?h(A,B,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})}),pf="9.12.13",H=class mo{static SDK_VERSION=pf;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=mo.SDK_VERSION.split(".").map(r=>r.padStart(2,"0")).join("");mo.SDK_VERSION_CODE=parseInt(e,10)}},We={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`},pe=Oe(tn()),x=class{static log(...t){pe.default.info(...t)}static debug(...t){pe.default.debug(...t)}static error(...t){pe.default.error(...t)}static warn(...t){pe.default.warn(...t)}static info(...t){pe.default.info(...t)}static trace(...t){pe.default.trace(...t)}};function df(t=H.LOG_PREFIX){pe.default.useDefaults({formatter:function(r){r.unshift(`${t} (v${H.SDK_VERSION}):`)}});let e=Nu();(e==="1"||e==="on")&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?pe.default.setLevel(pe.default[localStorage.cooeeLogLevel]):pe.default.setLevel(We.debug?pe.default.TRACE:pe.default.OFF)}function Nu(){return new URL(location.href).searchParams?.get("cooee-debug")}function ff(){let t=`
2
2
  display: inline-block;
3
3
  font-size: 14px;
4
4
  background: linear-gradient(90deg, #d52dc8 25%, #2179e2 82%);
@@ -59,7 +59,7 @@ mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
59
59
  }
60
60
  }
61
61
  }
62
- `,ac=class{sentryService=lt.get(Gt);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.status===200||c.status===302)return x.log(`Added ${t.length} items to Cart`),Qe("Product added to your cart"),c.json()}catch(c){Qe("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)){x.warn("No update fields provided");return}let r=Ln("cart/change.js"),n=T({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.status===200||s.status===302){let o=await s.json();x.log(`Updated ${t}`),xt.getCurrent().update(o)}}catch(s){Qe("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),x.log(`Code-${t} copied`),Qe("Discount code copied")}catch(e){x.error("Failed to copy code",e)}}goToItem(t){if(!t?.link)return;let e=Fb(t.link);e&&(location.pathname=Vi()+"products/"+e)}async upgradeToSubscription(t,e){if(!t){x.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.status===200||p.status===302){x.log(`Upgraded ${t} selling plan`),Qe("Line item updated");let g=await p.json();return xt.getCurrent().update(g),g}}catch(p){Qe("Failed to update subscription"),this.sentryService.captureError(p,"cart-switch-subscription",{extra:{body:l},engagementTrigger:e})}}async createNewCart(t,e,r){let n=ie.get().storefrontToken;if(!n)throw new Error("Storefront token not set for the store");if(!t?.vID){x.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 Dh(),c=new Headers;c.append("Content-Type","application/json"),c.append("X-Shopify-Storefront-Access-Token",n);let l=JSON.stringify({query:I0,variables:{input:{lines:s,discountCodes:i,attributes:o}}});return(await Or.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(x.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=Vi()+"collections/"+s[0].handle}}e.applyDiscount&&n.discount?.code&&Mn.navigate(n.discount.code,n.redirectBehaviour)}getVIDAndQuantity(t){let e,r;if(t instanceof en)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}}},C0=class{static updateIdentity(t){if(!this.isInstalled())return;let e={};t.email&&(e.email=t.email),t.mobile&&(e.phone_number=t.mobile),x.debug("Sending email/mobile to Klaviyo"),window.klaviyo.push(["identify",e])}static isInstalled(){return window.klaviyo&&typeof window.klaviyo=="object"}},T0=class{apiService;action;triggerContext;constructor(t,e){this.action=t,this.apiService=Ht.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:x.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;Ch(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){x.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}),Qe("Coupon applied on cart"),C0.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 ac().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}))}},Zi=class Pe{static DOCUMENT_STANDARD_MODE="CSS1Compat";static _instance;parentContainer;scalingFactor=1;doc=document;constructor(){}static get(){return Pe._instance||(Pe._instance=new Pe),Pe._instance}getWidth(){return this.parentContainer&&this.parentContainer!==document.body?this.parentContainer.clientWidth:document.compatMode===Pe.DOCUMENT_STANDARD_MODE?document.documentElement.clientWidth:window.innerWidth}getHeight(){return this.isParentNotBody()?this.parentContainer.clientHeight:document.compatMode===Pe.DOCUMENT_STANDARD_MODE?document.documentElement.clientHeight:window.innerHeight}isMobile(){return window.CooeeSDK.uaParser.getDevice().type==="mobile"}calculateScalingFactor(e){let r=e.max,n=e.cont.w,i=e.cont.h,s=e.spc,o=Pe.get().getWidth(),c=Pe.get().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))}getScalingFactor(){return this.scalingFactor}createElement(e){return this.doc.createElement(e)}appendChild(e,r){e.appendChild(r)}setStyles(e,r){Object.assign(e.style,r)}setStyle(e,r,n){if(r){if(!n){e.style.removeProperty(r);return}e.style.setProperty(r,n,"important")}}setAttribute(e,r,n){e.setAttribute(r,n)}removeInApp(e){let r=document.querySelector(`.${e.rootClassName}`);r&&r.parentElement.removeChild(r)}setParentContainer(e){this.parentContainer=e,this.parentContainer&&this.isParentNotBody()&&this.setStyle(this.parentContainer,"position","relative")}isParentNotBody(){return this.parentContainer!==document.body}},Fp=class{constructor(t){this.scalingFactor=t}getLayoutStyles(t){if(!t)return{display:"block"};let e={display:t.disp};return t.of&&(e.objectFit=t.of),t.pos==="absolute"&&(e.width="auto !important",e.position="absolute",e.right=t.right+"px",e.left=t.left+"px",e.top=t.top+"px",e.bottom=t.bottom+"px"),e}getSizeStyles(t){let e={};return t?.w&&(e.width=t.w),t?.h&&(e.height=t.h),t?.maxW&&(e.maxWidth=t.maxW),t?.maxH&&(e.maxHeight=t.maxH),t?.minW&&(e.minWidth=t.minW),t?.minH&&(e.minHeight=t.minH),e}getBorderStyles(t){if(!t)return{};let e={};return t.radius&&t.radius>0&&(e.borderRadius=this.getSizePx(t.radius)),t.width&&t.width>0&&(e.borderWidth=this.getSizePx(t.width),e.borderStyle=t.style?.toLowerCase(),t.color?this.getColourStyles(t.color,"border-color",e):e.borderColor="black"),e}getFlexStyles(t){return t?{gap:t.gap+"px",flexWrap:t.wrap,flexDirection:t.dir,justifyContent:t.jc,alignItems:t.ai,width:"100%"}:{}}getSpaceStyles(t){let e={};return t?(e.paddingTop=this.getSizePx(t.pt),e.paddingBottom=this.getSizePx(t.pb),e.paddingLeft=this.getSizePx(t.pl),e.paddingRight=this.getSizePx(t.pr),e.marginTop=this.getSizePx(t.mt),e.marginBottom=this.getSizePx(t.mb),e.marginLeft=t.cent?"auto":this.getSizePx(t.ml),e.marginRight=t.cent?"auto":this.getSizePx(t.mr),e):(e.margin="0 !important",e.padding="unset",e)}getBackgroundStyles(t){if(!t)return{};let e={};if(t.glossy){let r="backdrop-filter",n="-webkit-"+r,i=`blur(${t.glossy.radius}px)`;if(!CSS.supports(n,i)&&!CSS.supports(r,i))return{background:t.glossy.fallback.rgba};if(e[n]=i,e[r]=i,t.glossy.color)return this.getColourStyles(t.glossy.color,"background",e)}else if(t.solid){if(t.solid.grad)return this.getGradientStyles(t.solid.grad,"background",e);if(t.solid.hex)return{backgroundColor:t.solid.rgba}}else if(t.img){if(!t.img.src)return{};let r=(t.img.a??0)/100;e.background=`linear-gradient(rgba(0, 0, 0, ${r}), rgba(0, 0, 0, ${r})),url("${t.img.src}") no-repeat center`,e.backgroundSize="cover",t.img.a&&(e["-webkit-backdrop-filter"]=`opacity(${t.img.a})`,e.backdropFilter=`opacity(${t.img.a})`)}return e}getGradientStyles(t,e,r){if(r??={},t.type==="LINEAR"){let n=`linear-gradient(${t.ang}deg, ${t.c1}, ${t.c2}`;t.c3&&(n+=`, ${t.c3}`),n+=")",r[e]=n}return r}getColourStyles(t,e="color",r){return r??={},t?t.grad?this.getGradientStyles(t.grad,e,r):(t.hex&&(r[e]=t.rgba),r):r}getSizePx(t){return this.getScaledSize(t)+"px"}getScaledSize(t){return(t??0)*this.scalingFactor}},ii=class{renderer=Zi.get();parentHTMLEl;inappElement;inappHTMLEl;triggerContext;stylesConverter;scalingFactor;constructor(t,e,r){this.parentHTMLEl=t,this.inappElement=e,this.triggerContext=r,this.stylesConverter=new Fp(this.renderer.getScalingFactor())}getHTMLElement(){return this.inappHTMLEl}insertElement(){this.renderer.appendChild(this.parentHTMLEl,this.inappHTMLEl)}processCommonBlocks(){this.processWidthAndHeight(),this.processPositionBlock(),this.processTransformBlock(),this.processTransparency(),this.processShadow(),this.registerAction();let t=ct(T(T(T(T({},this.getDisplayStyles()),this.getSpaceStyles()),this.getBorderStyles()),this.getBackgroundStyles()),{boxSizing:"border-box",outline:"none"});this.renderer.setStyles(this.inappHTMLEl,t)}getDisplayStyles(){return{display:"block"}}processWidthAndHeight(){this.inappElement.w&&this.renderer.setStyle(this.inappHTMLEl,"width",this.stylesConverter.getSizePx(this.inappElement.w)),this.inappElement.h&&this.renderer.setStyle(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)};this.renderer.setStyles(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);this.renderer.setStyle(this.inappHTMLEl,"opacity",e)}}processShadow(){let t=this.inappElement.shd;t?this.renderer.setStyle(this.inappHTMLEl,"box-shadow",t.getStyle(this.scalingFactor)):this.renderer.setStyle(this.inappHTMLEl,"box-shadow","unset")}processTransformBlock(){let t=new ju(this.inappElement.trf);t&&t.rotate&&this.renderer.setStyle(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 T0(t,this.triggerContext).execute()}),this.renderer.setStyle(this.inappHTMLEl,"cursor","pointer"))}getBackgroundStyles(){return this.stylesConverter.getBackgroundStyles(this.inappElement.bg)}},Es=class extends ii{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),this.renderer.setStyles(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"),this.renderer.setStyle(t,"font-weight",e.b?"bold":"normal"),this.renderer.setStyle(t,"font-style",e.i?"italic":"normal"),this.renderer.setStyle(t,"text-decoration",r.join(" ")),this.renderer.setStyle(t,"color",e.c??"inherit"),this.renderer.setStyle(t,"font-family","inherit")}processAlignment(){let t=this.inappElement.typography.ta,e=t?ua[t]?.toLowerCase():this.inappElement.typography.alignment;e||(e="start"),this.renderer.setStyle(this.inappHTMLEl,"text-align",e)}},x0=class extends Es{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){this.inappElement.parts?.forEach(t=>{let e=this.renderer.createElement("span");e.innerHTML=t.txt?.toString()?.replace(/\n/g,"<br />"),this.processPart(e,t),this.renderer.appendChild(this.inappHTMLEl,e)}),this.processCommonBlocks()}},D0=class extends ii{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){this.processCommonBlocks()}},Hp=class extends ii{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("img"),this.insertElement()}render(){this.renderer.setAttribute(this.inappHTMLEl,"src",this.inappElement.src),this.renderer.setStyle(this.inappHTMLEl,"max-width","none"),this.renderer.setStyle(this.inappHTMLEl,"max-height","none"),this.renderer.setStyle(this.inappHTMLEl,"margin","0 auto"),this.processCommonBlocks()}},A0=class Vp extends ii{constructor(e,r,n){super(e,r,n),this.parent=e,this.inappHTMLEl=this.renderer.createElement("div")}static MAX_Z_INDEX="2147483647";render(){return this.parent||this.renderer.removeInApp(this.triggerContext),this.insertElement(),this.processCommonBlocks(),this.inappHTMLEl.classList.add(H.IN_APP_WRAPPER_NAME),this.inappHTMLEl.classList.add(this.triggerContext.rootClassName),this.renderer.setStyle(this.inappHTMLEl,"z-index",Vp.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()?(this.renderer.setStyle(this.inappHTMLEl,"width","100%"),this.renderer.setStyle(this.inappHTMLEl,"height","100%")):(this.renderer.setStyle(this.inappHTMLEl,"width","100vw"),this.renderer.setStyle(this.inappHTMLEl,"height","100vh")),this.renderer.setStyle(this.inappHTMLEl,"top","0"),this.renderer.setStyle(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();this.renderer.setStyle(this.inappHTMLEl,"width",n+"px"),this.renderer.setStyle(this.inappHTMLEl,"height",i+"px")}}getSpaceStyles(){return{padding:this.inappElement.spc.getPaddingCSS()}}getDisplayStyles(){return T(T({display:"flex"},this.inappElement.getStylesForWrapper()),this.inappElement.getFlexStylesForContainer())}processPositionBlock(){if(this.renderer.isParentNotBody()){if(this.triggerContext.triggerData.ian?.isEmbedded()){this.renderer.setStyle(this.inappHTMLEl,"position","block");return}this.renderer.setStyle(this.inappHTMLEl,"position","absolute")}else this.renderer.setStyle(this.inappHTMLEl,"position","fixed")}getBorderStyles(){return{}}processTransparency(){}processTransformBlock(){}processShadow(){}},N0=class extends ii{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){return this.processCommonBlocks(),this.renderer.setStyle(this.inappHTMLEl,"position","relative"),this.renderer.setStyle(this.inappHTMLEl,"overflow","hidden"),this.inappHTMLEl.classList.add(H.IN_APP_CONTAINER_NAME),this}},O0=class Re extends Es{static DAYS="Days";static HOURS="Hours";static MINUTES="Minutes";static SECONDS="Seconds";elements;spans=[];constructor(e,r,n){super(e,r,n),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){this.addTimerChildren(),this.processAndStartTimer(),this.processCommonBlocks();let e=ct(T(T(T({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=>this.renderer.setStyles(r,e))}addTimerChildren(){let e=this.inappElement.show;this.elements=[],e.day&&this.elements.push(this.getChild(Re.DAYS)),e.hour&&this.elements.push(this.getChild(Re.HOURS)),e.minute&&this.elements.push(this.getChild(Re.MINUTES)),e.second&&this.elements.push(this.getChild(Re.SECONDS)),this.elements.forEach(r=>this.inappHTMLEl.appendChild(r))}getChild(e){let r=this.renderer.createElement("div"),n=this.renderer.createElement("span"),i=this.renderer.createElement("span");return i.innerText=e,n.innerText="00",n.id=`lc-${e}`,this.renderer.setStyle(i,"font-size","0.5em"),this.renderer.setStyle(i,"text-align","center"),this.renderer.setStyle(i,"font-family","inherit"),this.renderer.setStyle(n,"text-align","center"),this.renderer.setStyle(n,"font-family","inherit"),this.inappElement.lblPos==="start"?(r.appendChild(i),r.appendChild(n)):(r.appendChild(n),r.appendChild(i)),this.renderer.setStyle(r,"display","flex"),this.renderer.setStyle(r,"flex-direction",this.inappElement.horizontal?"":"column"),this.renderer.setStyle(r,"justify-content","center"),this.renderer.setStyle(r,"align-items","center"),this.renderer.setStyle(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-${Re.DAYS}`?n.innerText=String(r.days).padStart(2,"0"):n.id===`lc-${Re.HOURS}`?n.innerText=String(r.hours).padStart(2,"0"):n.id===`lc-${Re.MINUTES}`?n.innerText=String(r.minutes).padStart(2,"0"):n.id===`lc-${Re.SECONDS}`&&(n.innerText=String(r.seconds).padStart(2,"0"))})});this.triggerContext.intervals.push(e)}},k0=class extends Es{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("select"),this.insertElement()}render(){this.renderer.setStyle(this.inappHTMLEl,"background","#ffffff00"),this.renderer.setStyle(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 us(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=this.renderer.createElement("option");return n.text=t,n.value=JSON.stringify(e),r&&(n.selected=!0),e||(n.disabled=!0),n}},qp=class extends Es{borderColor="";constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("input"),this.insertElement()}render(){let t=this.setInputType();this.renderer.setAttribute(this.inappHTMLEl,"placeholder",this.inappElement.placeholderText),this.renderer.setStyle(this.inappHTMLEl,"background","#ffffff00"),this.renderer.setStyle(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)}},P0=class Wp extends qp{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.renderer.setAttribute(this.inappHTMLEl,"type","email"),this.renderer.setAttribute(this.inappHTMLEl,"id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(Wp.EMAIL_REGEX)?(this.renderer.setStyle(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(this.renderer.setStyle(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},R0=class Gp extends qp{static MOBILE_REGEX=/^\d+$/;constructor(e,r,n){super(e,r,n)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.renderer.setAttribute(this.inappHTMLEl,"type","tel"),this.renderer.setAttribute(this.inappHTMLEl,"id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(Gp.MOBILE_REGEX)?(this.renderer.setStyle(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(this.renderer.setStyle(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},L0=class extends Hp{constructor(t,e,r){super(t,e,r)}render(){super.render(),this.inappHTMLEl.setAttribute("id",`coo-${this.inappElement.type}`)}},zp=class kn{static ACTIVE_TRIGGER_DATA;renderer=Zi.get();safeHTTP;parent;rootContainer;containerHTMLElement;ian;triggerContext;resizeListener;cartDrawerToggleSubscription;constructor(e){this.safeHTTP=Ht.getInstance(),this.resizeListener=()=>this.screenResized(),this.setParentContainer(e)}setParentContainer(e){this.parent=e??document.body,this.renderer.setParentContainer(this.parent)}render(e){this.renderEngagement(new Tr(e))}async renderEngagement(e){if(this.triggerContext=new Bp(new Date,e),this.triggerContext.onClose(r=>{this.closeInApp(r)}),this.ian=e.ian,(this.renderer.isMobile()||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()||!this.renderer.isMobile()){this.startRenderingOnce();return}this.cartDrawerToggleSubscription=Ee.get().onToggle().subscribe(({open:e})=>{!e&&this.startRenderingOnce()})}startRenderingOnce(){if(!this.shouldSkipCampaign()){kn.ACTIVE_TRIGGER_DATA=this.triggerContext.triggerData;try{this.startRendering()}catch(e){Gt.getInstance().captureError(e,"render-popup",{triggerContext:this.triggerContext});return}this.sendTriggerDisplayed(),this.renderer.isMobile()||window.addEventListener("resize",this.resizeListener),this.cartDrawerToggleSubscription?.unsubscribe()}}shouldSkipCampaign(){let e=this.triggerContext.triggerData;if(!e.previewType&&kn.ACTIVE_TRIGGER_DATA){let n={triggerShown:new za(kn.ACTIVE_TRIGGER_DATA??{})};return this.skipTrigger(e,n),!0}if(Ot.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.renderer.calculateScalingFactor(this.ian),this.rootContainer=new A0(this.parent,this.ian,this.triggerContext).render();try{this.renderContainer(this.triggerContext)}catch(e){throw x.error(e),e}}sendTriggerDisplayed(){let e={};this.triggerContext.triggerData.items?.length&&(e.promotedMIDs=this.triggerContext.triggerData.items?.map(i=>i.mID));let r=new Bt(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 Bt(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 ep?new P0(e,r,n).render():r instanceof rp?new R0(e,r,n).render():r instanceof $o?new x0(e,r,n).render():r instanceof np?new L0(e,r,n).render():r instanceof Ba?new Hp(e,r,n).render():r instanceof Xh?new D0(e,r,n).render():r instanceof Zh?new O0(e,r,n).render():r instanceof tp?new k0(e,r,n).render():x.error("Unsupported element type- "+r.type)}renderContainer(e){let r=this.ian?.cont;r&&(this.containerHTMLElement=new N0(this.rootContainer,r,e).render().getHTMLElement(),new b0().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),kn.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(){Zi.get().removeInApp(this.triggerContext)}skipTrigger(e,r){let n=new Bt(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"})}},M0=class{triggerData;safeHttpService=Ht.getInstance();render(t){t.contentSource===oa.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){x.warn("Received invalid trigger callback");return}switch(e.type){case"open":this.safeHttpService.sendEvent(new Bt(H.EVENT_TRIGGER_DISPLAYED,{form:{id:e.formId}},this.triggerData));break;case"stepSubmit":{let r=this.getFormDetails(e);this.safeHttpService.sendEvent(new Bt(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 Bt(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}},U0=class{static trackIntent(t){if(!this.isInstalled()){x.log("Facebook pixel not installed");return}if(!ie.get().pixelPush){x.log("Facebook pixel push not enabled");return}let e=ps[t.intent]?.toLowerCase(),r=t.segmentName;!e&&!r||(x.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"}},Kp=class{static itemMap=new Map;static async refreshItems(t){if(t.isCartEmbed()&&!t.isSubscriptionUpsell()){let i=(await xt.getCurrent().getNormalisedCart()).items.map(s=>s.mID);t.items=t.items.filter(s=>!i.includes(s.mID))}if(ie.get().currencyCount<=1)return t.items;if(t.isShoppableVideo())return await this.refreshVideoItems(t.content.videoConfig,t),t.items;let e=t.items.length,r=t.items.map(i=>this.updatedItem(i,t)),n=(await Promise.all(r)).filter(i=>i!=null);if(e&&!n.length){let i="Failed to fetch any product from Ajax API",s=new Bt(H.EVENT_CAMPAIGN_FAILED,{reason:i,currency:t.currency},t);throw Ht.getInstance().sendEvent(s),new Error(i)}if(t.isCartRecovery()){let i=xt.getCurrent().items,s=[];for(let o of n)for(let c of o.vars){if(!c.isAvailable)continue;let l=i.find(h=>h.variant_id.toString()===c.mID);if(!l)continue;let p=new He(o);p.name=l.title;let g=new us(c);g.name=l.variant_title,g.price.d=l.discounted_price/100,p.variants=[g],s.push(p)}return s}return n}static async refreshVideoItems(t,e){await Promise.all(t.videos.map(async r=>{r.items=await Promise.all(r.items.map(async n=>await this.updatedItem(n,e)||n))}))}static async updatedItem(t,e){if(this.itemMap.has(t.mID))return this.itemMap.get(t.mID);let r=t,n=Gt.getInstance(),i=lt.get(Or),s,o=`/products/${r.slug}.js`;try{s=await i.request(o)}catch(l){return n.captureError(l,"fetch-shopify-product",{extra:{item:r,path:o},engagementTrigger:e}),null}if(!s)return x.error("Item not found after AJAX call for:",r),null;r.name=s.title,r.tags=s.tags;let c=r.selectedOrFirstVariant.value;return r.vars.map(l=>{let p=s.variants.find(g=>g.id===+l.mID);l.name=p.title,l.isAvailable=p.available,l.price.d=p.price?p.price/100:p.price,l.price.effective=l.price.d,l.price.cmp=p.compare_at_price?p.compare_at_price/100:p.compare_at_price,+c.mID===p.id&&(c.effectivePrice.value=l.price.d)}),this.itemMap.set(r.mID,r),r}},cc=class Yp{static INSTANCE;httpService=lt.get(Or);sentryService=lt.get(Gt);sessionManager=lt.get(we);runtime=Ot.get();constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Yp),this.INSTANCE}sendSilently(e){this.send(e).catch(r=>x.error(`Failed to send ${e.name}`,r))}async send(e){if(x.debug(`Sending event ${e.name}`),Ne.log(`Sending event ${e.name} with id ${e.id}`),this.shouldReject(e)){x.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=>{x.log("\u2705 Event tracked:",e.name),Ne.log(`\u2705 Event <strong>${r.eventName}</strong> tracked`),this.processEventResponse(e,r)}).catch(r=>{x.error(`Error sending event ${e.name} to server`,r)})}shouldReject(e){return e.trigger?.triggerID==="test"||e.trigger?.triggerID==="preview"?(x.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=_s.parseFromCurrent()}async addShopifyContext(e){try{e.cart=await xt.getCurrent().getNormalisedCart()}catch(r){x.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){x.log(`Nothing to engage after ${e.name}`);return}x.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 Tr(r.triggerData);n.occurred=e.occurred;let i;try{i=await Kp.refreshItems(n)}catch(s){x.error("Failed to refresh the products",s);return}if(n.items=i,n.contentSource===oa.KLAVIYO){new M0().render(n);return}new zp().renderEngagement(n).catch(s=>{this.sentryService.captureError(s,"render-popup",{extra:{event:e},engagementTrigger:n})})}utiliseIntentIfCalculated(e){e.intent&&(Up.trackIntent(e.intent),U0.trackIntent(e),Ne.log(`Intent is <strong>${ps[e.intent]}</strong>`))}addShopifyAttributes(){xt.getCurrent().addCooeeAttributes().catch(e=>{x.error("Fail to add attributes in cart",e)})}},Ht=class Jp{static INSTANCE;httpApiService=Or.getInstance();eventAPIService=cc.getInstance();constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Jp),this.INSTANCE}sendEvent(e){x.debug(`Waiting for auth to send event ${e.name}`),we.replaySubject.subscribe(async()=>{this.eventAPIService.sendSilently(e)})}updateProfile(e){we.replaySubject.subscribe(()=>{this.httpApiService.updateUserData(e??{})})}trackOrder(e){we.replaySubject.subscribe(()=>{this.httpApiService.trackOrder(e)})}updateDeviceProps(e){we.replaySubject.subscribe(()=>{this.httpApiService.updateDeviceProps({props:e})})}generateDiscount(e){return this.httpApiService.generateDiscount(e)}},Ne=class{static isOn=!1;static element;static logs=[];static watch(){let t=Nu();(t==="1"||t==="on")&&Ht.getInstance().updateDeviceProps({debugTill:this.getDebugMillis()}),t==="on"?sessionStorage.cooeeDebug="1":t==="off"&&sessionStorage.removeItem("cooeeDebug"),sessionStorage.cooeeDebug&&(this.isOn=!0,this.renderDebugBar(),this.log(`Cooee SDK v${H.SDK_VERSION} loaded`))}static log(t){this.isOn&&(this.logs.unshift({time:new Date,message:t}),this.element&&(this.element.logs=[...this.logs]))}static renderDebugBar(){this.element=document.createElement("cooee-debugger"),this.element.logs=this.logs,xa(()=>{document.body.appendChild(this.element)})}static getDebugMillis(){return new Date().getTime()+6*60*60*1e3}},Cu=class extends Ta{static storeName="app";static{this.storage=Ca(this.storeName)}},B0=class{static processConfiguration(){let t=ie.get();!t.gaMeasurementID||!t.gaEnabled||this.sendClientID()}static async sendClientID(){let t=await this.getClientID();t&&Ht.getInstance().updateDeviceProps({gaClientID:t})}static async getClientID(){let t=await Lt.get(at.GA_CLIENT_ID),e=await this.getClientIDViaGTag();if(t!==e)return await Lt.set(at.GA_CLIENT_ID,e),e}static async getClientIDViaGTag(){let t=ie.get().gaMeasurementID;if(!(!t||!window.gtag))return new Promise(e=>{window.gtag("get",t,"client_id",r=>{e(r)})})}},j0=class Xp{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Xp),this.INSTANCE}init(){Cu.get(at.APP_CONFIG,{}).then(e=>this.updateGlobalConfig(e))}async processAppConfigurations(e){x.log("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);Cu.set(at.APP_CONFIG,r).catch(n=>x.error(n)),B0.processConfiguration(),r.website&&(be.injectRawScript(r.website.commonJS),be.injectRawCSS(r.website.commonCSS)),Ee.get().onToggle().subscribe(async({open:n})=>{x.info("Cart drawer is now",n?"open":"closed"),n&&(lt.get(Wn).loadOrRenderWidgetsAfterCartChange(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=_t.globalRef.config.update(e);return Ee.forceUpdate(),x.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};Ht.getInstance().sendEvent(new Bt(H.EVENT_VIEW_CART,n))}},ea=class Qp{static INSTANCE;httpAPIService=Or.getInstance();coreService=j0.getInstance();sentryService=Gt.getInstance();sdkToken="";userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Qp),this.INSTANCE}init(e){this.appID=e.appID,this.shopifyShop=e.shopifyShop}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await Lt.set(at.ID,e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await Lt.set(at.DEVICE_ID,e.deviceID)),e.sdkToken&&(this.sdkToken=e.sdkToken,await Lt.set(at.SDK_TOKEN,e.sdkToken)),this.updateAPIClient())}async validateSession(e){await this.populateFirstSeen(),await this.populateUserDataFromStorage(),x.log("Validating session with server");let r=await this.getSessionValidateData(e);try{let n=await this.httpAPIService.validateSession(r);x.log("Validating session Response",n),await this.coreService.processAppConfigurations(n.appSettings),await this.storeAndPopulateAuthData(n)}catch(n){throw x.error(n),n}}async populateUserDataFromStorage(){if(this.sdkToken=await Lt.get(at.SDK_TOKEN),!this.sdkToken){x.warn("No SDK token found in local storage");return}this.userID=await Lt.get(at.ID),this.deviceID=await Lt.get(at.DEVICE_ID),this.updateAPIClient()}updateAPIClient(){x.debug("SDK Token:",this.sdkToken),x.log("Device ID:",this.deviceID),x.log("User ID:",this.userID),Up.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 v0().safeGet(),n=await Lt.get(at.DEVICE_ID);return n||(n=new zt().toHexString(),await Lt.set(at.DEVICE_ID,n)),ct(T({deviceID:n,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),{sdk:H.SDK,page:_s.parseFromCurrent(),ad:f0.getAdParams(),occurred:this.getSessionStartTime(Ot.get().jsLoadTime),currentItem:Ot.get().getCurrentItem(),cart:await xt.getCurrent().getNormalisedCart(),properties:{}})}async populateFirstSeen(){let e=await Lt.get(at.FIRST_SEEN),r=e?new Date(e):new Date;e||await Lt.set(at.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 D_(1);static INSTANCE;sentryService=lt.get(Gt);constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Pn),this.INSTANCE}init(e){if(x.debug("Initialising SDK",e),p0(navigator.userAgent)){x.info("This seems to be a bot. Disabling SDK");return}ea.getInstance().init(e),Pn.INSTANCE.checkSessionOnPageLoad().then(async()=>{Pn.replaySubject.next(!0),Pn.replaySubject.complete()}).catch(r=>{x.error("Unable to initiate session",r)})}getCurrentSessionID(){return te.set(at.SESSION_LAST_USED_TIME,new Date().getTime()),te.get(at.ID,"")}async checkSessionOnPageLoad(){await Vb.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 ea.getInstance().validateSession({sessionID:n[0],sessionNumber:n[1],landingPage:n[2],newSession:r}),await te.set(at.SESSION_SYNCED,!0)}}async startNewSession(){x.debug("Starting new session"),await te.clear(),x.debug("Cleared SessionStorage before starting new session");let e=new Date,r=new zt().toHexString();x.debug("New session ID to be used",r);let n=await Lt.get(at.SESSION_NUMBER,0)+1;await Promise.all([Lt.set(at.SESSION_NUMBER,n),te.set(at.ID,r),te.set(at.SESSION_LAST_USED_TIME,e.getTime()),te.set(at.SESSION_LANDING_PAGE,_s.parseFromCurrent())])}getLandingPage(){return te.get(at.SESSION_LANDING_PAGE,{})}getCurrentSessionNumber(){return Lt.get(at.SESSION_NUMBER,1)}async isNewSessionRequired(){if(!await te.get(at.ID))return!0;let e=await te.get(at.SESSION_LAST_USED_TIME,0);return e?(new Date().getTime()-e)/1e3>H.IDLE_TIME_IN_SECONDS:!0}async notSynced(){return!await te.get(at.SESSION_SYNCED,!1)}},$0=Oe(tn()),F0=Oe(tn()),lc=class{constructor(t){this.triggerContext=t}safeHTTP=Ht.getInstance();eventAPIService=cc.getInstance();async execute(t){let e=Ot.get().getCurrentItem(),r=t.clickAction;if(!r)return;let n=t.item,i=this.triggerContext,s=new ac,o=i.triggerData.redirectBehaviour,c=!!i.triggerData.discount.type&&!!r?.applyDiscount,l={selectedVariants:i.triggerData.nonMutableItems.map(_=>({itemMID:_.mID,mID:_.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(B=>({itemMID:B.mID,mID:B.vID,quantity:B.quantity})):k=_.map(B=>({itemMID:B.mID,mID:B.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(B=>{B.mID===e.vID&&(B.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?Vi()+"products/"+n.slug:t.embeddedItem?.link;else if(r.at===4){let _=Ch(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),x.debug({redirectPath:p,redirectBehaviour:o,hasDiscount:c}),!c&&p){location.href=p;return}let w,v=!1;try{w=await this.getOrGenerateDiscountCode(l),x.debug("Discount code (if any) to apply",w)}catch(_){if(!this.triggerContext.triggerData.isBYOB()){F0.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(_){x.error(_),v=!0}let b;if(g?.length&&(b=await s.addToCart(g,i.triggerData)),v&&w){Mn.navigate(w,o,p);return}if(p){location.href=p;return}Mn.navigateWithoutDiscount(o,b)}sendTriggerClicked(t,e,r){let n=new Bt(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===ye.STATIC){if(!e.code)throw Gt.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 x.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 Qe("Failed to generate a discount code"),Gt.getInstance().captureError(e,"backend-generate-discount",{extra:{discountData:JSON.stringify(t)},triggerContext:this.triggerContext}),e}}},se=class extends yr{stylesConverter=new Fp(1);renderer=Zi.get();mediaStyle={};deviceTypeKey;clickExecutor;componentWillMount(){this.deviceTypeKey=this.renderer.isMobile()?"sm":"lg",this.clickExecutor=new lc(this.props.triggerContext)}getCompiledStyles(){return this.putStyleAccordingToDevice(),T(T(ct(T(T(T(T(T(T({},this.stylesConverter.getFlexStyles(this.mediaStyle.flex)),this.stylesConverter.getBackgroundStyles(this.mediaStyle.bg)),this.stylesConverter.getBorderStyles(this.mediaStyle.br)),this.stylesConverter.getSizeStyles(this.mediaStyle.size)),this.stylesConverter.getSpaceStyles(this.mediaStyle.spc)),this.stylesConverter.getLayoutStyles(this.mediaStyle.lout)),{boxSizing:"border-box",outline:"none"}),this.getComponentStyles()),this.props.style)}matchWhenCondition(t){if(!t?.op)return!0;let{lhs:e,rhs:r}=t;switch(t.op){case"eq":return e===r;case"gt":return+e>+r;case"gte":return+e>=+r;case"lt":return+e<+r;case"lte":return+e<=+r;case"ne":return e!==r;case"null":return e==null;case"empty":return e.trim()==="";case"in":return new RegExp(`\\b${r}\\b`).test(e);case"nin":return!new RegExp(`\\b${r}\\b`).test(e);default:return x.error(`Invalid operator found for when condition - ${t.op}`),!1}}putStyleAccordingToDevice(){let t=this.props.element;this.mediaStyle=t.style.lg,this.renderer.isMobile()&&t.style.sm&&Object.keys(t.style.sm).length&&(this.mediaStyle=T(T({},this.mediaStyle),t.style.sm))}sendTriggerClicked(t,e){this.clickExecutor.sendTriggerClicked(t,e)}async onClick(t,e){t.stopPropagation(),!e.clickAction&&(e.clickAction=this.props.element.clc),await this.clickExecutor.execute(e)}},H0=0,_E=Array.isArray;function z(t,e,r,n,i,s){e||(e={});var o,c,l=e;if("ref"in l)for(c in l={},e)c=="ref"?o=e[c]:l[c]=e[c];var p={type:t,props:l,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--H0,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(o=t.defaultProps))for(c in o)l[c]===void 0&&(l[c]=o[c]);return ft.vnode&&ft.vnode(p),p}var si=class extends se{componentDidMount(){this.setState(()=>({text:this.props.element.text})),Ye(this.onChange.bind(this))}componentWillReceiveProps(t){this.props.element=t.element,this.onChange()}render(){let t=this.getCompiledStyles(),e=this.state.text;return e||(t.display="none",e=""),z("div",{style:t,onClick:this.customOnClick.bind(this),className:"lc-text",children:z("span",{style:this.getSpanStyle(),dangerouslySetInnerHTML:{__html:e}})})}customOnClick(){this.props.onClick&&this.props.onClick("title")}onChange(){if(this.props.element.text==null)return;let t=this.props.triggerContext.triggerData,e={bundle:t.discountData.value,customer:t.customerData,cart:t.getCartMagicVariables()},r=Ve.render(JSON.stringify(this.props.element),e),n=new Ae(JSON.parse(r));if(!this.matchWhenCondition(n.when)){this.setState(()=>({text:""}));return}this.setState(()=>({text:n.text}))}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.letterSpacing=e.letterSpacing,t.fontSize=e.fs+"px",t.lineHeight=e.lh,t.fontFamily=e.fam.name||"inherit",t.textAlign=e.alignment,t.fontWeight=e.fw,t.textDecoration=e.td??"none",this.stylesConverter.getColourStyles(e.tc,"color",t),t}getComponentStyles(){return T({},this.getTypoStyles())}getSpanStyle(){return{overflow:"hidden",display:"-webkit-box",webkitBoxOrient:"vertical",webkitLineClamp:2,color:"inherit",fontSize:"inherit",fontWeight:"inherit",fontFamily:"inherit"}}},Zp=class extends si{render(){return z("div",{style:this.getCompiledStyles(),className:"lc-button",onClick:t=>this.onClick(t,{item:this.props.item}),children:z("span",{style:this.getSpanStyle(),dangerouslySetInnerHTML:{__html:this.state.text}})})}getComponentStyles(){return ct(T({},super.getComponentStyles()),{cursor:"pointer"})}},V0=class extends yr{render(){if(this.props.element.show[this.props.label.toLowerCase()])return this.props.element.lblPos==="end"?z("div",{style:T(T({},this.getElementStyle()),this.props.styles),children:[z("span",{children:this.props.time}),z("span",{style:this.getTimeLabelStyle(),children:this.props.label})]}):z("div",{style:T(T({},this.getElementStyle()),this.props.styles),children:[z("span",{style:this.getTimeLabelStyle(),children:this.props.label}),z("span",{children:this.props.time})]})}getDesign(){}getTimeLabelStyle(){return{fontSize:"0.5em",alignContent:"center"}}getElementStyle(){let t={display:"flex",flexDirection:"column",placeContent:"center center",textAlign:"center"};return this.props.element.horizontal&&(t.gridTemplateColumns="repeat(2, minmax(0, 1fr))"),t}},q0=class extends si{labels={Days:"00",Hours:"00",Minutes:"00",Seconds:"00"};componentWillMount(){super.componentWillMount(),this.setState(()=>T({},this.labels)),this.processAndStartTimer()}render(){return z("div",{style:this.getLabelsParentStyle(),children:Object.keys(this.labels).map(t=>z(V0,{styles:this.getCompiledStyles(),label:t,time:this.state[t],element:this.props.element}))})}getLabelsParentStyle(){return{display:"grid",justifyContent:"center",gridTemplateColumns:"repeat(4, auto)",gap:this.stylesConverter.getSizePx(this.props.element.gap)}}getDisplayStyles(){return{display:"grid",placeContent:"center center"}}getComponentStyles(){return T(T({},super.getComponentStyles()),this.getDisplayStyles())}processAndStartTimer(){this.props.element.timer.start(this.props.element.timerType,t=>{this.labels.Days=String(t.days).padStart(2,"0"),this.labels.Hours=String(t.hours).padStart(2,"0"),this.labels.Minutes=String(t.minutes).padStart(2,"0"),this.labels.Seconds=String(t.seconds).padStart(2,"0"),this.setState(()=>T({},this.labels))})}},W0=class extends se{componentDidMount(){Ye(()=>{this.setState(()=>({checked:this.props.item.selected.value}))})}render(){return z("div",{style:this.getCompiledStyles(),className:"lc-checkbox",children:z("input",{type:"checkbox",checked:this.state.checked,onChange:this.onChange.bind(this),style:{appearance:"auto"}})})}onChange(t){let{checked:e}=t.target;this.props.item.selected.value=e}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.textAlign=e.alignment,t.justifyContent=e.alignment,t}getComponentStyles(){return ct(T({},this.getTypoStyles()),{display:"flex"})}},uc=class extends se{constructor(t,e){super(t,e)}render(){let t=this.props.element[this.deviceTypeKey],e=t?.src||this.props.element.src||this.props.element.lg?.src;return z("img",{onClick:this.customOnClick.bind(this),className:"lc-image",alt:t?.name||"Image",onMouseEnter:this.handleMouseEnter.bind(this),onMouseLeave:this.handleMouseLeave.bind(this),src:e,style:this.getCompiledStyles()})}customOnClick(t){this.props.element.clc?.at===Pu.ADD_TO_CART&&this.props.triggerContext.triggerData.items[0]&&this.onClick(t,{item:this.props.triggerContext.triggerData.items[0]}),this.props.onClick&&this.props.onClick("image")}getComponentStyles(){let t=this.mediaStyle.lout;if(!t||t.pos!=="absolute")return{};let e={zIndex:t.zIndex,cursor:this.props.element.clc?.at?"pointer":"auto"};return this.mediaStyle.size?.w&&(e.width=this.mediaStyle.size.w),this.mediaStyle.size?.h&&(e.height=this.mediaStyle.size.h),e}handleMouseEnter(t){let e=this.props.element[this.deviceTypeKey]?.secondarySrc;e&&(t.currentTarget.src=e)}handleMouseLeave(t){t.currentTarget.src=this.props.element[this.deviceTypeKey]?.src}},hc=class extends se{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return z("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:z(pc,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})})}getComponentStyles(){let t=this.mediaStyle.flex??new ip,e={display:"flex",gap:t.gap+"px",flexWrap:t.wrap,flexDirection:t.dir,justifyContent:t.jc,alignItems:t.ai};return t.wrap==="nowrap"&&t.scroll&&(t.dir==="column"?e["overflow-y"]="auto":e["overflow-x"]="auto"),e}},G0=class extends hc{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return z("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:z(td,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.props.noLinks})})}},z0=class extends se{render(){return z("select",{style:this.getCompiledStyles(),value:this.props.selectedVariant.selectedSellingPlan.value?.mID??"",onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){Ye(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.letterSpacing=e.letterSpacing,t.fontSize=e.fs+"px",t.lineHeight=e.lh,t.fontFamily="inherit",t.textAlign=e.alignment,t.fontWeight=e.fw,this.stylesConverter.getColourStyles(e.tc,"color",t),t.boxShadow="none",t}getComponentStyles(){let t={};return this.props.selectedVariant.sellingPlans?.length||(t.visibility="hidden"),T(T({},t),this.getTypoStyles())}createSelectItems(){let t=[],e=this.props.selectedVariant;if(!e.sellingPlans?.length)return[];this.props.triggerContext.triggerData.skipSubscribedItems?e.selectedSellingPlan.value||(e.sellingPlans[0].isSelected=!0,e.changeSellingPlan(e.sellingPlans[0])):t.push(z("option",{value:"",selected:!e.selectedSellingPlan,children:"One time purchase"}));for(let r of e.sellingPlans??[])t.push(z("option",{value:r.mID,selected:r.isSelected,children:r.name}));return t}onChange(t){let e=t.target.value;e?this.props.selectedVariant.selectedSellingPlan.value=this.props.selectedVariant.sellingPlans.find(r=>r.mID===e):this.props.selectedVariant.selectedSellingPlan.value=void 0}},K0=class extends se{colorRegex=new RegExp('fill="#[a-zA-Z0-9]+"');constructor(){super(),Ve.escape=Ou.escapeHtml}render(){let t=this.getCompiledStyles(),e=this.getRating();return e||(t.display="none",e=""),z("div",{style:t,className:"lc-star-rating",dangerouslySetInnerHTML:{__html:e}})}getRating(){let t=this.props.element.fullStar,e=this.props.element.halfStart,r={size:this.props.element.iconSize,color:this.props.element.c.hex};t=Ve.render(t,{svg:r}),e=Ve.render(e,{svg:r});let n=this.props.review;if(!n?.rating)return"";let i="";if(this.props.element.showSingleStar)i=t;else{let s=5,o=`${n.rating}`.split(".");for(let c=0;c<+o[0];c++)i+=t,s--;o[1]&&(i+=e,s--);for(let c=0;c<s;c++)i+=t.replace(this.colorRegex,'fill="#f1f1f1')}return i}getComponentStyles(){return{display:"flex",alignItems:"center"}}},Y0=class extends se{render(){return z("select",{style:this.getCompiledStyles(),value:this.props.item.selectedOrFirstVariant.value.mID,onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){Ye(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.letterSpacing=e.letterSpacing,t.fontSize=e.fs+"px",t.lineHeight=e.lh,t.fontFamily="inherit",t.textAlign=e.alignment,t.fontWeight=e.fw,this.stylesConverter.getColourStyles(e.tc,"color",t),t.boxShadow="none",t}getComponentStyles(){let t={};return this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"&&(t.visibility="hidden"),T(T({},t),this.getTypoStyles())}createSelectItems(){let t=[];for(let e of this.props.item.vars)t.push(z("option",{value:e.mID,disabled:!e.isAvailable,children:e.name}));return t}onChange(t){let e=t.target.value,r=this.props.item.vars.find(n=>n.mID===e);this.props.item.setSelectedVariant(r)}},td=class extends se{constructor(t,e){super(t,e),this.setState(()=>({decoration:"unset"}))}renderElement(t){if(!(t.hide||!this.matchWhenCondition(t.when))){if(t.t===4){let e=t;return z(G0,{element:e,triggerContext:this.props.triggerContext,elements:e.elems,item:this.props.item,noLinks:this.props.noLinks})}if(t.t===6)return this.props.triggerContext.triggerData.isBundle()?z(W0,{element:t,item:this.props.item,triggerContext:this.props.triggerContext}):void 0;if(t.t===13){let e=t,r=this.props.item,n=r.variantImage??r.imageURL,i=r.variantSecondaryImage??r.secondaryImageURL;e.lg=e.sm={src:n,name:r.name,secondarySrc:i};let s=z(uc,{element:e,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?s:z("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block"},children:s})}if(t.t===14)return this.renderProductTitle(t);if(t.t===15){let e=t;return this.props.triggerContext.triggerData.isCartEmbed()&&this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"?void 0:e.showChips?z("cooee-product-options-picker",{item:this.props.item,element:e}):z(Y0,{element:e,item:this.props.item,triggerContext:this.props.triggerContext})}return t.t===16?z(z0,{element:t,selectedVariant:this.props.item.selectedOrFirstVariant.value,item:this.props.item,triggerContext:this.props.triggerContext}):t.t===19?z(K0,{element:t,triggerContext:this.props.triggerContext,review:this.props.item.reviews}):t.t===18||t.t===3?z(Zp,{element:t,item:this.props.item,triggerContext:this.props.triggerContext}):z(pc,{elements:[t],element:this.props.element,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(t=>this.renderElement(t))}getComponentStyles(){return{}}renderProductTitle(t){let e=z(si,{element:t,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?e:z("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block",textDecoration:this.state.decoration},onMouseEnter:this.onMouseEnter.bind(this),onMouseLeave:this.onMouseLeave.bind(this),children:e})}customOnClick(t){this.sendTriggerClicked([this.props.item.toEmbed()],{from:t})}onMouseEnter(){this.setState(()=>({decoration:"underline"}))}onMouseLeave(){this.setState(()=>({decoration:"unset"}))}},ed=class extends se{productElement;constructor(t,e){super(t,e),this.setState(()=>({decoration:"unset"}))}render(){let t=JSON.stringify(this.props.element),e=Ve.render(t,this.getProductData());try{this.productElement=new Fa(JSON.parse(e))}catch(r){throw Gt.getInstance().captureError(r,"variable-replacement",{extra:{before:t,after:e},triggerContext:this.props.triggerContext}),r}if(!(this.productElement.hide||!this.matchWhenCondition(this.productElement.when)))return z("div",{style:T({},this.getCompiledStyles()),class:"lc-single-product",children:z(td,{element:this.productElement,elements:this.productElement.elems,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.productElement.noLinks})})}getComponentStyles(){return{flexShrink:0}}getProductData(){if(!this.props.item)return{};let t=this.props.item,e=t.selectedOrFirstVariant.value,r=t.getTemplateVariables();r.product.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(this.props.item.quantity):this.props.item.quantity;let n=this.props.triggerContext.triggerData.discount.type===ye.BXGY;return!e.hasEffectivePrice()&&n&&(r.product.effective_price=he(e.effectivePrice.value),r.product.price=""),r.variant.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(e.quantity):e.quantity,{product:r.product,variant:r.variant,svg:{color:()=>"{{svg.color}}",size:()=>"{{svg.size}}"}}}};function rd(t,e){if(!t)return;let r=new window.CooeeSDK.Swiper(t,{loop:!0,slidesPerView:e.maxInRow,spaceBetween:e.gap+"px",pagination:{type:e.pagination.type,el:t.querySelector(".swiper-pagination"),clickable:!0,renderBullet:(n,i)=>`
62
+ `,ac=class{sentryService=lt.get(Gt);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.status===200||c.status===302)return x.log(`Added ${t.length} items to Cart`),Qe("Product added to your cart"),c.json()}catch(c){Qe("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)){x.warn("No update fields provided");return}let r=Ln("cart/change.js"),n=T({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.status===200||s.status===302){let o=await s.json();x.log(`Updated ${t}`),xt.getCurrent().update(o)}}catch(s){Qe("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),x.log(`Code-${t} copied`),Qe("Discount code copied")}catch(e){x.error("Failed to copy code",e)}}goToItem(t){if(!t?.link)return;let e=Fb(t.link);e&&(location.pathname=Vi()+"products/"+e)}async upgradeToSubscription(t,e){if(!t){x.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.status===200||p.status===302){x.log(`Upgraded ${t} selling plan`),Qe("Line item updated");let g=await p.json();return xt.getCurrent().update(g),g}}catch(p){Qe("Failed to update subscription"),this.sentryService.captureError(p,"cart-switch-subscription",{extra:{body:l},engagementTrigger:e})}}async createNewCart(t,e,r){let n=ie.get().storefrontToken;if(!n)throw new Error("Storefront token not set for the store");if(!t?.vID){x.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 Dh(),c=new Headers;c.append("Content-Type","application/json"),c.append("X-Shopify-Storefront-Access-Token",n);let l=JSON.stringify({query:I0,variables:{input:{lines:s,discountCodes:i,attributes:o}}});return(await Or.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(x.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=Vi()+"collections/"+s[0].handle}}e.applyDiscount&&n.discount?.code&&Mn.navigate(n.discount.code,n.redirectBehaviour)}getVIDAndQuantity(t){let e,r;if(t instanceof en)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}}},C0=class{static updateIdentity(t){if(!this.isInstalled())return;let e={};t.email&&(e.email=t.email),t.mobile&&(e.phone_number=t.mobile),x.debug("Sending email/mobile to Klaviyo"),window.klaviyo.push(["identify",e])}static isInstalled(){return window.klaviyo&&typeof window.klaviyo=="object"}},T0=class{apiService;action;triggerContext;constructor(t,e){this.action=t,this.apiService=Ht.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:x.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;Ch(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){x.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}),Qe("Coupon applied on cart"),C0.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 ac().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}))}},Zi=class Pe{static DOCUMENT_STANDARD_MODE="CSS1Compat";static _instance;parentContainer;scalingFactor=1;doc=document;constructor(){}static get(){return Pe._instance||(Pe._instance=new Pe),Pe._instance}getWidth(){return this.parentContainer&&this.parentContainer!==document.body?this.parentContainer.clientWidth:document.compatMode===Pe.DOCUMENT_STANDARD_MODE?document.documentElement.clientWidth:window.innerWidth}getHeight(){return this.isParentNotBody()?this.parentContainer.clientHeight:document.compatMode===Pe.DOCUMENT_STANDARD_MODE?document.documentElement.clientHeight:window.innerHeight}isMobile(){return window.CooeeSDK.uaParser.getDevice().type==="mobile"}calculateScalingFactor(e){let r=e.max,n=e.cont.w,i=e.cont.h,s=e.spc,o=Pe.get().getWidth(),c=Pe.get().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))}getScalingFactor(){return this.scalingFactor}createElement(e){return this.doc.createElement(e)}appendChild(e,r){e.appendChild(r)}setStyles(e,r){Object.assign(e.style,r)}setStyle(e,r,n){if(r){if(!n){e.style.removeProperty(r);return}e.style.setProperty(r,n,"important")}}setAttribute(e,r,n){e.setAttribute(r,n)}removeInApp(e){let r=document.querySelector(`.${e.rootClassName}`);r&&r.parentElement.removeChild(r)}setParentContainer(e){this.parentContainer=e,this.parentContainer&&this.isParentNotBody()&&this.setStyle(this.parentContainer,"position","relative")}isParentNotBody(){return this.parentContainer!==document.body}},Fp=class{constructor(t){this.scalingFactor=t}getLayoutStyles(t){if(!t)return{display:"block"};let e={display:t.disp};return t.of&&(e.objectFit=t.of),t.pos==="absolute"&&(e.width="auto !important",e.position="absolute",e.right=t.right+"px",e.left=t.left+"px",e.top=t.top+"px",e.bottom=t.bottom+"px"),e}getSizeStyles(t){let e={};return t?.w&&(e.width=t.w),t?.h&&(e.height=t.h),t?.maxW&&(e.maxWidth=t.maxW),t?.maxH&&(e.maxHeight=t.maxH),t?.minW&&(e.minWidth=t.minW),t?.minH&&(e.minHeight=t.minH),e}getBorderStyles(t){if(!t)return{};let e={};return t.radius&&t.radius>0&&(e.borderRadius=this.getSizePx(t.radius)),t.width&&t.width>0&&(e.borderWidth=this.getSizePx(t.width),e.borderStyle=t.style?.toLowerCase(),t.color?this.getColourStyles(t.color,"border-color",e):e.borderColor="black"),e}getFlexStyles(t){return t?{gap:t.gap+"px",flexWrap:t.wrap,flexDirection:t.dir,justifyContent:t.jc,alignItems:t.ai,width:"100%"}:{}}getSpaceStyles(t){let e={};return t?(e.paddingTop=this.getSizePx(t.pt),e.paddingBottom=this.getSizePx(t.pb),e.paddingLeft=this.getSizePx(t.pl),e.paddingRight=this.getSizePx(t.pr),e.marginTop=this.getSizePx(t.mt),e.marginBottom=this.getSizePx(t.mb),e.marginLeft=t.cent?"auto":this.getSizePx(t.ml),e.marginRight=t.cent?"auto":this.getSizePx(t.mr),e):(e.margin="0 !important",e.padding="unset",e)}getBackgroundStyles(t){if(!t)return{};let e={};if(t.glossy){let r="backdrop-filter",n="-webkit-"+r,i=`blur(${t.glossy.radius}px)`;if(!CSS.supports(n,i)&&!CSS.supports(r,i))return{background:t.glossy.fallback.rgba};if(e[n]=i,e[r]=i,t.glossy.color)return this.getColourStyles(t.glossy.color,"background",e)}else if(t.solid){if(t.solid.grad)return this.getGradientStyles(t.solid.grad,"background",e);if(t.solid.hex)return{backgroundColor:t.solid.rgba}}else if(t.img){if(!t.img.src)return{};let r=(t.img.a??0)/100;e.background=`linear-gradient(rgba(0, 0, 0, ${r}), rgba(0, 0, 0, ${r})),url("${t.img.src}") no-repeat center`,e.backgroundSize="cover",t.img.a&&(e["-webkit-backdrop-filter"]=`opacity(${t.img.a})`,e.backdropFilter=`opacity(${t.img.a})`)}return e}getGradientStyles(t,e,r){if(r??={},t.type==="LINEAR"){let n=`linear-gradient(${t.ang}deg, ${t.c1}, ${t.c2}`;t.c3&&(n+=`, ${t.c3}`),n+=")",r[e]=n}return r}getColourStyles(t,e="color",r){return r??={},t?t.grad?this.getGradientStyles(t.grad,e,r):(t.hex&&(r[e]=t.rgba),r):r}getSizePx(t){return this.getScaledSize(t)+"px"}getScaledSize(t){return(t??0)*this.scalingFactor}},ii=class{renderer=Zi.get();parentHTMLEl;inappElement;inappHTMLEl;triggerContext;stylesConverter;scalingFactor;constructor(t,e,r){this.parentHTMLEl=t,this.inappElement=e,this.triggerContext=r,this.stylesConverter=new Fp(this.renderer.getScalingFactor())}getHTMLElement(){return this.inappHTMLEl}insertElement(){this.renderer.appendChild(this.parentHTMLEl,this.inappHTMLEl)}processCommonBlocks(){this.processWidthAndHeight(),this.processPositionBlock(),this.processTransformBlock(),this.processTransparency(),this.processShadow(),this.registerAction();let t=ct(T(T(T(T({},this.getDisplayStyles()),this.getSpaceStyles()),this.getBorderStyles()),this.getBackgroundStyles()),{boxSizing:"border-box",outline:"none"});this.renderer.setStyles(this.inappHTMLEl,t)}getDisplayStyles(){return{display:"block"}}processWidthAndHeight(){this.inappElement.w&&this.renderer.setStyle(this.inappHTMLEl,"width",this.stylesConverter.getSizePx(this.inappElement.w)),this.inappElement.h&&this.renderer.setStyle(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)};this.renderer.setStyles(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);this.renderer.setStyle(this.inappHTMLEl,"opacity",e)}}processShadow(){let t=this.inappElement.shd;t?this.renderer.setStyle(this.inappHTMLEl,"box-shadow",t.getStyle(this.scalingFactor)):this.renderer.setStyle(this.inappHTMLEl,"box-shadow","unset")}processTransformBlock(){let t=new ju(this.inappElement.trf);t&&t.rotate&&this.renderer.setStyle(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 T0(t,this.triggerContext).execute()}),this.renderer.setStyle(this.inappHTMLEl,"cursor","pointer"))}getBackgroundStyles(){return this.stylesConverter.getBackgroundStyles(this.inappElement.bg)}},Es=class extends ii{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),this.renderer.setStyles(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"),this.renderer.setStyle(t,"font-weight",e.b?"bold":"normal"),this.renderer.setStyle(t,"font-style",e.i?"italic":"normal"),this.renderer.setStyle(t,"text-decoration",r.join(" ")),this.renderer.setStyle(t,"color",e.c??"inherit"),this.renderer.setStyle(t,"font-family","inherit")}processAlignment(){let t=this.inappElement.typography.ta,e=t?ua[t]?.toLowerCase():this.inappElement.typography.alignment;e||(e="start"),this.renderer.setStyle(this.inappHTMLEl,"text-align",e)}},x0=class extends Es{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){this.inappElement.parts?.forEach(t=>{let e=this.renderer.createElement("span");e.innerHTML=t.txt?.toString()?.replace(/\n/g,"<br />"),this.processPart(e,t),this.renderer.appendChild(this.inappHTMLEl,e)}),this.processCommonBlocks()}},D0=class extends ii{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){this.processCommonBlocks()}},Hp=class extends ii{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("img"),this.insertElement()}render(){this.renderer.setAttribute(this.inappHTMLEl,"src",this.inappElement.src),this.renderer.setStyle(this.inappHTMLEl,"max-width","none"),this.renderer.setStyle(this.inappHTMLEl,"max-height","none"),this.renderer.setStyle(this.inappHTMLEl,"margin","0 auto"),this.processCommonBlocks()}},A0=class Vp extends ii{constructor(e,r,n){super(e,r,n),this.parent=e,this.inappHTMLEl=this.renderer.createElement("div")}static MAX_Z_INDEX="2147483647";render(){return this.parent||this.renderer.removeInApp(this.triggerContext),this.insertElement(),this.processCommonBlocks(),this.inappHTMLEl.classList.add(H.IN_APP_WRAPPER_NAME),this.inappHTMLEl.classList.add(this.triggerContext.rootClassName),this.renderer.setStyle(this.inappHTMLEl,"z-index",Vp.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()?(this.renderer.setStyle(this.inappHTMLEl,"width","100%"),this.renderer.setStyle(this.inappHTMLEl,"height","100%")):(this.renderer.setStyle(this.inappHTMLEl,"width","100vw"),this.renderer.setStyle(this.inappHTMLEl,"height","100vh")),this.renderer.setStyle(this.inappHTMLEl,"top","0"),this.renderer.setStyle(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();this.renderer.setStyle(this.inappHTMLEl,"width",n+"px"),this.renderer.setStyle(this.inappHTMLEl,"height",i+"px")}}getSpaceStyles(){return{padding:this.inappElement.spc.getPaddingCSS()}}getDisplayStyles(){return T(T({display:"flex"},this.inappElement.getStylesForWrapper()),this.inappElement.getFlexStylesForContainer())}processPositionBlock(){if(this.renderer.isParentNotBody()){if(this.triggerContext.triggerData.ian?.isEmbedded()){this.renderer.setStyle(this.inappHTMLEl,"position","block");return}this.renderer.setStyle(this.inappHTMLEl,"position","absolute")}else this.renderer.setStyle(this.inappHTMLEl,"position","fixed")}getBorderStyles(){return{}}processTransparency(){}processTransformBlock(){}processShadow(){}},N0=class extends ii{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){return this.processCommonBlocks(),this.renderer.setStyle(this.inappHTMLEl,"position","relative"),this.renderer.setStyle(this.inappHTMLEl,"overflow","hidden"),this.inappHTMLEl.classList.add(H.IN_APP_CONTAINER_NAME),this}},O0=class Re extends Es{static DAYS="Days";static HOURS="Hours";static MINUTES="Minutes";static SECONDS="Seconds";elements;spans=[];constructor(e,r,n){super(e,r,n),this.inappHTMLEl=this.renderer.createElement("div"),this.insertElement()}render(){this.addTimerChildren(),this.processAndStartTimer(),this.processCommonBlocks();let e=ct(T(T(T({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=>this.renderer.setStyles(r,e))}addTimerChildren(){let e=this.inappElement.show;this.elements=[],e.day&&this.elements.push(this.getChild(Re.DAYS)),e.hour&&this.elements.push(this.getChild(Re.HOURS)),e.minute&&this.elements.push(this.getChild(Re.MINUTES)),e.second&&this.elements.push(this.getChild(Re.SECONDS)),this.elements.forEach(r=>this.inappHTMLEl.appendChild(r))}getChild(e){let r=this.renderer.createElement("div"),n=this.renderer.createElement("span"),i=this.renderer.createElement("span");return i.innerText=e,n.innerText="00",n.id=`lc-${e}`,this.renderer.setStyle(i,"font-size","0.5em"),this.renderer.setStyle(i,"text-align","center"),this.renderer.setStyle(i,"font-family","inherit"),this.renderer.setStyle(n,"text-align","center"),this.renderer.setStyle(n,"font-family","inherit"),this.inappElement.lblPos==="start"?(r.appendChild(i),r.appendChild(n)):(r.appendChild(n),r.appendChild(i)),this.renderer.setStyle(r,"display","flex"),this.renderer.setStyle(r,"flex-direction",this.inappElement.horizontal?"":"column"),this.renderer.setStyle(r,"justify-content","center"),this.renderer.setStyle(r,"align-items","center"),this.renderer.setStyle(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-${Re.DAYS}`?n.innerText=String(r.days).padStart(2,"0"):n.id===`lc-${Re.HOURS}`?n.innerText=String(r.hours).padStart(2,"0"):n.id===`lc-${Re.MINUTES}`?n.innerText=String(r.minutes).padStart(2,"0"):n.id===`lc-${Re.SECONDS}`&&(n.innerText=String(r.seconds).padStart(2,"0"))})});this.triggerContext.intervals.push(e)}},k0=class extends Es{constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("select"),this.insertElement()}render(){this.renderer.setStyle(this.inappHTMLEl,"background","#ffffff00"),this.renderer.setStyle(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 us(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=this.renderer.createElement("option");return n.text=t,n.value=JSON.stringify(e),r&&(n.selected=!0),e||(n.disabled=!0),n}},qp=class extends Es{borderColor="";constructor(t,e,r){super(t,e,r),this.inappHTMLEl=this.renderer.createElement("input"),this.insertElement()}render(){let t=this.setInputType();this.renderer.setAttribute(this.inappHTMLEl,"placeholder",this.inappElement.placeholderText),this.renderer.setStyle(this.inappHTMLEl,"background","#ffffff00"),this.renderer.setStyle(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)}},P0=class Wp extends qp{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.renderer.setAttribute(this.inappHTMLEl,"type","email"),this.renderer.setAttribute(this.inappHTMLEl,"id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(Wp.EMAIL_REGEX)?(this.renderer.setStyle(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(this.renderer.setStyle(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},R0=class Gp extends qp{static MOBILE_REGEX=/^\d+$/;constructor(e,r,n){super(e,r,n)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.renderer.setAttribute(this.inappHTMLEl,"type","tel"),this.renderer.setAttribute(this.inappHTMLEl,"id",e),e}addListener(e,r){e.addEventListener("keydown",n=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(Gp.MOBILE_REGEX)?(this.renderer.setStyle(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(r,!0)):(this.renderer.setStyle(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(r,!1)),n.stopPropagation()})}},L0=class extends Hp{constructor(t,e,r){super(t,e,r)}render(){super.render(),this.inappHTMLEl.setAttribute("id",`coo-${this.inappElement.type}`)}},zp=class kn{static ACTIVE_TRIGGER_DATA;renderer=Zi.get();safeHTTP;parent;rootContainer;containerHTMLElement;ian;triggerContext;resizeListener;cartDrawerToggleSubscription;constructor(e){this.safeHTTP=Ht.getInstance(),this.resizeListener=()=>this.screenResized(),this.setParentContainer(e)}setParentContainer(e){this.parent=e??document.body,this.renderer.setParentContainer(this.parent)}render(e){this.renderEngagement(new Tr(e))}async renderEngagement(e){if(this.triggerContext=new Bp(new Date,e),this.triggerContext.onClose(r=>{this.closeInApp(r)}),this.ian=e.ian,(this.renderer.isMobile()||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()||!this.renderer.isMobile()){this.startRenderingOnce();return}this.cartDrawerToggleSubscription=Ee.get().onToggle().subscribe(({open:e})=>{!e&&this.startRenderingOnce()})}startRenderingOnce(){if(!this.shouldSkipCampaign()){kn.ACTIVE_TRIGGER_DATA=this.triggerContext.triggerData;try{this.startRendering()}catch(e){Gt.getInstance().captureError(e,"render-popup",{triggerContext:this.triggerContext});return}this.sendTriggerDisplayed(),this.renderer.isMobile()||window.addEventListener("resize",this.resizeListener),this.cartDrawerToggleSubscription?.unsubscribe()}}shouldSkipCampaign(){let e=this.triggerContext.triggerData;if(!e.previewType&&kn.ACTIVE_TRIGGER_DATA){let n={triggerShown:new za(kn.ACTIVE_TRIGGER_DATA??{})};return this.skipTrigger(e,n),!0}if(Ot.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.renderer.calculateScalingFactor(this.ian),this.rootContainer=new A0(this.parent,this.ian,this.triggerContext).render();try{this.renderContainer(this.triggerContext)}catch(e){throw x.error(e),e}}sendTriggerDisplayed(){let e={};this.triggerContext.triggerData.items?.length&&(e.promotedMIDs=this.triggerContext.triggerData.items?.map(i=>i.mID));let r=new Bt(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 Bt(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 ep?new P0(e,r,n).render():r instanceof rp?new R0(e,r,n).render():r instanceof $o?new x0(e,r,n).render():r instanceof np?new L0(e,r,n).render():r instanceof Ba?new Hp(e,r,n).render():r instanceof Xh?new D0(e,r,n).render():r instanceof Zh?new O0(e,r,n).render():r instanceof tp?new k0(e,r,n).render():x.error("Unsupported element type- "+r.type)}renderContainer(e){let r=this.ian?.cont;r&&(this.containerHTMLElement=new N0(this.rootContainer,r,e).render().getHTMLElement(),new b0().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),kn.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(){Zi.get().removeInApp(this.triggerContext)}skipTrigger(e,r){let n=new Bt(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"})}},M0=class{triggerData;safeHttpService=Ht.getInstance();render(t){t.contentSource===oa.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){x.warn("Received invalid trigger callback");return}switch(e.type){case"open":this.safeHttpService.sendEvent(new Bt(H.EVENT_TRIGGER_DISPLAYED,{form:{id:e.formId}},this.triggerData));break;case"stepSubmit":{let r=this.getFormDetails(e);this.safeHttpService.sendEvent(new Bt(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 Bt(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}},U0=class{static trackIntent(t){if(!this.isInstalled()){x.log("Facebook pixel not installed");return}if(!ie.get().pixelPush){x.log("Facebook pixel push not enabled");return}let e=ps[t.intent]?.toLowerCase(),r=t.segmentName;!e&&!r||(x.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"}},Kp=class{static itemMap=new Map;static async refreshItems(t){for(let i of t.items)if(window.cooeeManipulateProduct)try{window.cooeeManipulateProduct(i,t)}catch(s){x.error(s)}if(t.isCartEmbed()&&!t.isSubscriptionUpsell()){let i=(await xt.getCurrent().getNormalisedCart()).items.map(s=>s.mID);t.items=t.items.filter(s=>!i.includes(s.mID))}if(ie.get().currencyCount<=1)return t.items;if(t.isShoppableVideo())return await this.refreshVideoItems(t.content.videoConfig,t),t.items;let e=t.items.length,r=t.items.map(i=>this.updatedItem(i,t)),n=(await Promise.all(r)).filter(i=>i!=null);if(e&&!n.length){let i="Failed to fetch any product from Ajax API",s=new Bt(H.EVENT_CAMPAIGN_FAILED,{reason:i,currency:t.currency},t);throw Ht.getInstance().sendEvent(s),new Error(i)}if(t.isCartRecovery()){let i=xt.getCurrent().items,s=[];for(let o of n)for(let c of o.vars){if(!c.isAvailable)continue;let l=i.find(h=>h.variant_id.toString()===c.mID);if(!l)continue;let p=new He(o);p.name=l.title;let g=new us(c);g.name=l.variant_title,g.price.d=l.discounted_price/100,p.variants=[g],s.push(p)}return s}return n}static async refreshVideoItems(t,e){await Promise.all(t.videos.map(async r=>{r.items=await Promise.all(r.items.map(async n=>await this.updatedItem(n,e)||n))}))}static async updatedItem(t,e){if(this.itemMap.has(t.mID))return this.itemMap.get(t.mID);let r=t,n=Gt.getInstance(),i=lt.get(Or),s,o=`/products/${r.slug}.js`;try{s=await i.request(o)}catch(l){return n.captureError(l,"fetch-shopify-product",{extra:{item:r,path:o},engagementTrigger:e}),null}if(!s)return x.error("Item not found after AJAX call for:",r),null;r.name=s.title,r.tags=s.tags;let c=r.selectedOrFirstVariant.value;return r.vars.map(l=>{let p=s.variants.find(g=>g.id===+l.mID);l.name=p.title,l.isAvailable=p.available,l.price.d=p.price?p.price/100:p.price,l.price.effective=l.price.d,l.price.cmp=p.compare_at_price?p.compare_at_price/100:p.compare_at_price,+c.mID===p.id&&(c.effectivePrice.value=l.price.d)}),this.itemMap.set(r.mID,r),r}},cc=class Yp{static INSTANCE;httpService=lt.get(Or);sentryService=lt.get(Gt);sessionManager=lt.get(we);runtime=Ot.get();constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Yp),this.INSTANCE}sendSilently(e){this.send(e).catch(r=>x.error(`Failed to send ${e.name}`,r))}async send(e){if(x.debug(`Sending event ${e.name}`),Ne.log(`Sending event ${e.name} with id ${e.id}`),this.shouldReject(e)){x.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=>{x.log("\u2705 Event tracked:",e.name),Ne.log(`\u2705 Event <strong>${r.eventName}</strong> tracked`),this.processEventResponse(e,r)}).catch(r=>{x.error(`Error sending event ${e.name} to server`,r)})}shouldReject(e){return e.trigger?.triggerID==="test"||e.trigger?.triggerID==="preview"?(x.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=_s.parseFromCurrent()}async addShopifyContext(e){try{e.cart=await xt.getCurrent().getNormalisedCart()}catch(r){x.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){x.log(`Nothing to engage after ${e.name}`);return}x.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 Tr(r.triggerData);n.occurred=e.occurred;let i;try{i=await Kp.refreshItems(n)}catch(s){x.error("Failed to refresh the products",s);return}if(n.items=i,n.contentSource===oa.KLAVIYO){new M0().render(n);return}new zp().renderEngagement(n).catch(s=>{this.sentryService.captureError(s,"render-popup",{extra:{event:e},engagementTrigger:n})})}utiliseIntentIfCalculated(e){e.intent&&(Up.trackIntent(e.intent),U0.trackIntent(e),Ne.log(`Intent is <strong>${ps[e.intent]}</strong>`))}addShopifyAttributes(){xt.getCurrent().addCooeeAttributes().catch(e=>{x.error("Fail to add attributes in cart",e)})}},Ht=class Jp{static INSTANCE;httpApiService=Or.getInstance();eventAPIService=cc.getInstance();constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Jp),this.INSTANCE}sendEvent(e){x.debug(`Waiting for auth to send event ${e.name}`),we.replaySubject.subscribe(async()=>{this.eventAPIService.sendSilently(e)})}updateProfile(e){we.replaySubject.subscribe(()=>{this.httpApiService.updateUserData(e??{})})}trackOrder(e){we.replaySubject.subscribe(()=>{this.httpApiService.trackOrder(e)})}updateDeviceProps(e){we.replaySubject.subscribe(()=>{this.httpApiService.updateDeviceProps({props:e})})}generateDiscount(e){return this.httpApiService.generateDiscount(e)}},Ne=class{static isOn=!1;static element;static logs=[];static watch(){let t=Nu();(t==="1"||t==="on")&&Ht.getInstance().updateDeviceProps({debugTill:this.getDebugMillis()}),t==="on"?sessionStorage.cooeeDebug="1":t==="off"&&sessionStorage.removeItem("cooeeDebug"),sessionStorage.cooeeDebug&&(this.isOn=!0,this.renderDebugBar(),this.log(`Cooee SDK v${H.SDK_VERSION} loaded`))}static log(t){this.isOn&&(this.logs.unshift({time:new Date,message:t}),this.element&&(this.element.logs=[...this.logs]))}static renderDebugBar(){this.element=document.createElement("cooee-debugger"),this.element.logs=this.logs,xa(()=>{document.body.appendChild(this.element)})}static getDebugMillis(){return new Date().getTime()+6*60*60*1e3}},Cu=class extends Ta{static storeName="app";static{this.storage=Ca(this.storeName)}},B0=class{static processConfiguration(){let t=ie.get();!t.gaMeasurementID||!t.gaEnabled||this.sendClientID()}static async sendClientID(){let t=await this.getClientID();t&&Ht.getInstance().updateDeviceProps({gaClientID:t})}static async getClientID(){let t=await Lt.get(at.GA_CLIENT_ID),e=await this.getClientIDViaGTag();if(t!==e)return await Lt.set(at.GA_CLIENT_ID,e),e}static async getClientIDViaGTag(){let t=ie.get().gaMeasurementID;if(!(!t||!window.gtag))return new Promise(e=>{window.gtag("get",t,"client_id",r=>{e(r)})})}},j0=class Xp{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Xp),this.INSTANCE}init(){Cu.get(at.APP_CONFIG,{}).then(e=>this.updateGlobalConfig(e))}async processAppConfigurations(e){x.log("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);Cu.set(at.APP_CONFIG,r).catch(n=>x.error(n)),B0.processConfiguration(),r.website&&(be.injectRawScript(r.website.commonJS),be.injectRawCSS(r.website.commonCSS)),Ee.get().onToggle().subscribe(async({open:n})=>{x.info("Cart drawer is now",n?"open":"closed"),n&&(lt.get(Wn).loadOrRenderWidgetsAfterCartChange(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=_t.globalRef.config.update(e);return Ee.forceUpdate(),x.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};Ht.getInstance().sendEvent(new Bt(H.EVENT_VIEW_CART,n))}},ea=class Qp{static INSTANCE;httpAPIService=Or.getInstance();coreService=j0.getInstance();sentryService=Gt.getInstance();sdkToken="";userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Qp),this.INSTANCE}init(e){this.appID=e.appID,this.shopifyShop=e.shopifyShop}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await Lt.set(at.ID,e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await Lt.set(at.DEVICE_ID,e.deviceID)),e.sdkToken&&(this.sdkToken=e.sdkToken,await Lt.set(at.SDK_TOKEN,e.sdkToken)),this.updateAPIClient())}async validateSession(e){await this.populateFirstSeen(),await this.populateUserDataFromStorage(),x.log("Validating session with server");let r=await this.getSessionValidateData(e);try{let n=await this.httpAPIService.validateSession(r);x.log("Validating session Response",n),await this.coreService.processAppConfigurations(n.appSettings),await this.storeAndPopulateAuthData(n)}catch(n){throw x.error(n),n}}async populateUserDataFromStorage(){if(this.sdkToken=await Lt.get(at.SDK_TOKEN),!this.sdkToken){x.warn("No SDK token found in local storage");return}this.userID=await Lt.get(at.ID),this.deviceID=await Lt.get(at.DEVICE_ID),this.updateAPIClient()}updateAPIClient(){x.debug("SDK Token:",this.sdkToken),x.log("Device ID:",this.deviceID),x.log("User ID:",this.userID),Up.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 v0().safeGet(),n=await Lt.get(at.DEVICE_ID);return n||(n=new zt().toHexString(),await Lt.set(at.DEVICE_ID,n)),ct(T({deviceID:n,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),{sdk:H.SDK,page:_s.parseFromCurrent(),ad:f0.getAdParams(),occurred:this.getSessionStartTime(Ot.get().jsLoadTime),currentItem:Ot.get().getCurrentItem(),cart:await xt.getCurrent().getNormalisedCart(),properties:{}})}async populateFirstSeen(){let e=await Lt.get(at.FIRST_SEEN),r=e?new Date(e):new Date;e||await Lt.set(at.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 D_(1);static INSTANCE;sentryService=lt.get(Gt);constructor(){}static getInstance(){return this.INSTANCE||(this.INSTANCE=new Pn),this.INSTANCE}init(e){if(x.debug("Initialising SDK",e),p0(navigator.userAgent)){x.info("This seems to be a bot. Disabling SDK");return}ea.getInstance().init(e),Pn.INSTANCE.checkSessionOnPageLoad().then(async()=>{Pn.replaySubject.next(!0),Pn.replaySubject.complete()}).catch(r=>{x.error("Unable to initiate session",r)})}getCurrentSessionID(){return te.set(at.SESSION_LAST_USED_TIME,new Date().getTime()),te.get(at.ID,"")}async checkSessionOnPageLoad(){await Vb.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 ea.getInstance().validateSession({sessionID:n[0],sessionNumber:n[1],landingPage:n[2],newSession:r}),await te.set(at.SESSION_SYNCED,!0)}}async startNewSession(){x.debug("Starting new session"),await te.clear(),x.debug("Cleared SessionStorage before starting new session");let e=new Date,r=new zt().toHexString();x.debug("New session ID to be used",r);let n=await Lt.get(at.SESSION_NUMBER,0)+1;await Promise.all([Lt.set(at.SESSION_NUMBER,n),te.set(at.ID,r),te.set(at.SESSION_LAST_USED_TIME,e.getTime()),te.set(at.SESSION_LANDING_PAGE,_s.parseFromCurrent())])}getLandingPage(){return te.get(at.SESSION_LANDING_PAGE,{})}getCurrentSessionNumber(){return Lt.get(at.SESSION_NUMBER,1)}async isNewSessionRequired(){if(!await te.get(at.ID))return!0;let e=await te.get(at.SESSION_LAST_USED_TIME,0);return e?(new Date().getTime()-e)/1e3>H.IDLE_TIME_IN_SECONDS:!0}async notSynced(){return!await te.get(at.SESSION_SYNCED,!1)}},$0=Oe(tn()),F0=Oe(tn()),lc=class{constructor(t){this.triggerContext=t}safeHTTP=Ht.getInstance();eventAPIService=cc.getInstance();async execute(t){let e=Ot.get().getCurrentItem(),r=t.clickAction;if(!r)return;let n=t.item,i=this.triggerContext,s=new ac,o=i.triggerData.redirectBehaviour,c=!!i.triggerData.discount.type&&!!r?.applyDiscount,l={selectedVariants:i.triggerData.nonMutableItems.map(_=>({itemMID:_.mID,mID:_.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(B=>({itemMID:B.mID,mID:B.vID,quantity:B.quantity})):k=_.map(B=>({itemMID:B.mID,mID:B.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(B=>{B.mID===e.vID&&(B.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?Vi()+"products/"+n.slug:t.embeddedItem?.link;else if(r.at===4){let _=Ch(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),x.debug({redirectPath:p,redirectBehaviour:o,hasDiscount:c}),!c&&p){location.href=p;return}let w,v=!1;try{w=await this.getOrGenerateDiscountCode(l),x.debug("Discount code (if any) to apply",w)}catch(_){if(!this.triggerContext.triggerData.isBYOB()){F0.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(_){x.error(_),v=!0}let b;if(g?.length&&(b=await s.addToCart(g,i.triggerData)),v&&w){Mn.navigate(w,o,p);return}if(p){location.href=p;return}Mn.navigateWithoutDiscount(o,b)}sendTriggerClicked(t,e,r){let n=new Bt(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===ye.STATIC){if(!e.code)throw Gt.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 x.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 Qe("Failed to generate a discount code"),Gt.getInstance().captureError(e,"backend-generate-discount",{extra:{discountData:JSON.stringify(t)},triggerContext:this.triggerContext}),e}}},se=class extends yr{stylesConverter=new Fp(1);renderer=Zi.get();mediaStyle={};deviceTypeKey;clickExecutor;componentWillMount(){this.deviceTypeKey=this.renderer.isMobile()?"sm":"lg",this.clickExecutor=new lc(this.props.triggerContext)}getCompiledStyles(){return this.putStyleAccordingToDevice(),T(T(ct(T(T(T(T(T(T({},this.stylesConverter.getFlexStyles(this.mediaStyle.flex)),this.stylesConverter.getBackgroundStyles(this.mediaStyle.bg)),this.stylesConverter.getBorderStyles(this.mediaStyle.br)),this.stylesConverter.getSizeStyles(this.mediaStyle.size)),this.stylesConverter.getSpaceStyles(this.mediaStyle.spc)),this.stylesConverter.getLayoutStyles(this.mediaStyle.lout)),{boxSizing:"border-box",outline:"none"}),this.getComponentStyles()),this.props.style)}matchWhenCondition(t){if(!t?.op)return!0;let{lhs:e,rhs:r}=t;switch(t.op){case"eq":return e===r;case"gt":return+e>+r;case"gte":return+e>=+r;case"lt":return+e<+r;case"lte":return+e<=+r;case"ne":return e!==r;case"null":return e==null;case"empty":return e.trim()==="";case"in":return new RegExp(`\\b${r}\\b`).test(e);case"nin":return!new RegExp(`\\b${r}\\b`).test(e);default:return x.error(`Invalid operator found for when condition - ${t.op}`),!1}}putStyleAccordingToDevice(){let t=this.props.element;this.mediaStyle=t.style.lg,this.renderer.isMobile()&&t.style.sm&&Object.keys(t.style.sm).length&&(this.mediaStyle=T(T({},this.mediaStyle),t.style.sm))}sendTriggerClicked(t,e){this.clickExecutor.sendTriggerClicked(t,e)}async onClick(t,e){t.stopPropagation(),!e.clickAction&&(e.clickAction=this.props.element.clc),await this.clickExecutor.execute(e)}},H0=0,_E=Array.isArray;function z(t,e,r,n,i,s){e||(e={});var o,c,l=e;if("ref"in l)for(c in l={},e)c=="ref"?o=e[c]:l[c]=e[c];var p={type:t,props:l,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--H0,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(o=t.defaultProps))for(c in o)l[c]===void 0&&(l[c]=o[c]);return ft.vnode&&ft.vnode(p),p}var si=class extends se{componentDidMount(){this.setState(()=>({text:this.props.element.text})),Ye(this.onChange.bind(this))}componentWillReceiveProps(t){this.props.element=t.element,this.onChange()}render(){let t=this.getCompiledStyles(),e=this.state.text;return e||(t.display="none",e=""),z("div",{style:t,onClick:this.customOnClick.bind(this),className:"lc-text",children:z("span",{style:this.getSpanStyle(),dangerouslySetInnerHTML:{__html:e}})})}customOnClick(){this.props.onClick&&this.props.onClick("title")}onChange(){if(this.props.element.text==null)return;let t=this.props.triggerContext.triggerData,e={bundle:t.discountData.value,customer:t.customerData,cart:t.getCartMagicVariables()},r=Ve.render(JSON.stringify(this.props.element),e),n=new Ae(JSON.parse(r));if(!this.matchWhenCondition(n.when)){this.setState(()=>({text:""}));return}this.setState(()=>({text:n.text}))}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.letterSpacing=e.letterSpacing,t.fontSize=e.fs+"px",t.lineHeight=e.lh,t.fontFamily=e.fam.name||"inherit",t.textAlign=e.alignment,t.fontWeight=e.fw,t.textDecoration=e.td??"none",this.stylesConverter.getColourStyles(e.tc,"color",t),t}getComponentStyles(){return T({},this.getTypoStyles())}getSpanStyle(){return{overflow:"hidden",display:"-webkit-box",webkitBoxOrient:"vertical",webkitLineClamp:2,color:"inherit",fontSize:"inherit",fontWeight:"inherit",fontFamily:"inherit"}}},Zp=class extends si{render(){return z("div",{style:this.getCompiledStyles(),className:"lc-button",onClick:t=>this.onClick(t,{item:this.props.item}),children:z("span",{style:this.getSpanStyle(),dangerouslySetInnerHTML:{__html:this.state.text}})})}getComponentStyles(){return ct(T({},super.getComponentStyles()),{cursor:"pointer"})}},V0=class extends yr{render(){if(this.props.element.show[this.props.label.toLowerCase()])return this.props.element.lblPos==="end"?z("div",{style:T(T({},this.getElementStyle()),this.props.styles),children:[z("span",{children:this.props.time}),z("span",{style:this.getTimeLabelStyle(),children:this.props.label})]}):z("div",{style:T(T({},this.getElementStyle()),this.props.styles),children:[z("span",{style:this.getTimeLabelStyle(),children:this.props.label}),z("span",{children:this.props.time})]})}getDesign(){}getTimeLabelStyle(){return{fontSize:"0.5em",alignContent:"center"}}getElementStyle(){let t={display:"flex",flexDirection:"column",placeContent:"center center",textAlign:"center"};return this.props.element.horizontal&&(t.gridTemplateColumns="repeat(2, minmax(0, 1fr))"),t}},q0=class extends si{labels={Days:"00",Hours:"00",Minutes:"00",Seconds:"00"};componentWillMount(){super.componentWillMount(),this.setState(()=>T({},this.labels)),this.processAndStartTimer()}render(){return z("div",{style:this.getLabelsParentStyle(),children:Object.keys(this.labels).map(t=>z(V0,{styles:this.getCompiledStyles(),label:t,time:this.state[t],element:this.props.element}))})}getLabelsParentStyle(){return{display:"grid",justifyContent:"center",gridTemplateColumns:"repeat(4, auto)",gap:this.stylesConverter.getSizePx(this.props.element.gap)}}getDisplayStyles(){return{display:"grid",placeContent:"center center"}}getComponentStyles(){return T(T({},super.getComponentStyles()),this.getDisplayStyles())}processAndStartTimer(){this.props.element.timer.start(this.props.element.timerType,t=>{this.labels.Days=String(t.days).padStart(2,"0"),this.labels.Hours=String(t.hours).padStart(2,"0"),this.labels.Minutes=String(t.minutes).padStart(2,"0"),this.labels.Seconds=String(t.seconds).padStart(2,"0"),this.setState(()=>T({},this.labels))})}},W0=class extends se{componentDidMount(){Ye(()=>{this.setState(()=>({checked:this.props.item.selected.value}))})}render(){return z("div",{style:this.getCompiledStyles(),className:"lc-checkbox",children:z("input",{type:"checkbox",checked:this.state.checked,onChange:this.onChange.bind(this),style:{appearance:"auto"}})})}onChange(t){let{checked:e}=t.target;this.props.item.selected.value=e}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.textAlign=e.alignment,t.justifyContent=e.alignment,t}getComponentStyles(){return ct(T({},this.getTypoStyles()),{display:"flex"})}},uc=class extends se{constructor(t,e){super(t,e)}render(){let t=this.props.element[this.deviceTypeKey],e=t?.src||this.props.element.src||this.props.element.lg?.src;return z("img",{onClick:this.customOnClick.bind(this),className:"lc-image",alt:t?.name||"Image",onMouseEnter:this.handleMouseEnter.bind(this),onMouseLeave:this.handleMouseLeave.bind(this),src:e,style:this.getCompiledStyles()})}customOnClick(t){this.props.element.clc?.at===Pu.ADD_TO_CART&&this.props.triggerContext.triggerData.items[0]&&this.onClick(t,{item:this.props.triggerContext.triggerData.items[0]}),this.props.onClick&&this.props.onClick("image")}getComponentStyles(){let t=this.mediaStyle.lout;if(!t||t.pos!=="absolute")return{};let e={zIndex:t.zIndex,cursor:this.props.element.clc?.at?"pointer":"auto"};return this.mediaStyle.size?.w&&(e.width=this.mediaStyle.size.w),this.mediaStyle.size?.h&&(e.height=this.mediaStyle.size.h),e}handleMouseEnter(t){let e=this.props.element[this.deviceTypeKey]?.secondarySrc;e&&(t.currentTarget.src=e)}handleMouseLeave(t){t.currentTarget.src=this.props.element[this.deviceTypeKey]?.src}},hc=class extends se{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return z("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:z(pc,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})})}getComponentStyles(){let t=this.mediaStyle.flex??new ip,e={display:"flex",gap:t.gap+"px",flexWrap:t.wrap,flexDirection:t.dir,justifyContent:t.jc,alignItems:t.ai};return t.wrap==="nowrap"&&t.scroll&&(t.dir==="column"?e["overflow-y"]="auto":e["overflow-x"]="auto"),e}},G0=class extends hc{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return z("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:z(td,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.props.noLinks})})}},z0=class extends se{render(){return z("select",{style:this.getCompiledStyles(),value:this.props.selectedVariant.selectedSellingPlan.value?.mID??"",onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){Ye(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.letterSpacing=e.letterSpacing,t.fontSize=e.fs+"px",t.lineHeight=e.lh,t.fontFamily="inherit",t.textAlign=e.alignment,t.fontWeight=e.fw,this.stylesConverter.getColourStyles(e.tc,"color",t),t.boxShadow="none",t}getComponentStyles(){let t={};return this.props.selectedVariant.sellingPlans?.length||(t.visibility="hidden"),T(T({},t),this.getTypoStyles())}createSelectItems(){let t=[],e=this.props.selectedVariant;if(!e.sellingPlans?.length)return[];this.props.triggerContext.triggerData.skipSubscribedItems?e.selectedSellingPlan.value||(e.sellingPlans[0].isSelected=!0,e.changeSellingPlan(e.sellingPlans[0])):t.push(z("option",{value:"",selected:!e.selectedSellingPlan,children:"One time purchase"}));for(let r of e.sellingPlans??[])t.push(z("option",{value:r.mID,selected:r.isSelected,children:r.name}));return t}onChange(t){let e=t.target.value;e?this.props.selectedVariant.selectedSellingPlan.value=this.props.selectedVariant.sellingPlans.find(r=>r.mID===e):this.props.selectedVariant.selectedSellingPlan.value=void 0}},K0=class extends se{colorRegex=new RegExp('fill="#[a-zA-Z0-9]+"');constructor(){super(),Ve.escape=Ou.escapeHtml}render(){let t=this.getCompiledStyles(),e=this.getRating();return e||(t.display="none",e=""),z("div",{style:t,className:"lc-star-rating",dangerouslySetInnerHTML:{__html:e}})}getRating(){let t=this.props.element.fullStar,e=this.props.element.halfStart,r={size:this.props.element.iconSize,color:this.props.element.c.hex};t=Ve.render(t,{svg:r}),e=Ve.render(e,{svg:r});let n=this.props.review;if(!n?.rating)return"";let i="";if(this.props.element.showSingleStar)i=t;else{let s=5,o=`${n.rating}`.split(".");for(let c=0;c<+o[0];c++)i+=t,s--;o[1]&&(i+=e,s--);for(let c=0;c<s;c++)i+=t.replace(this.colorRegex,'fill="#f1f1f1')}return i}getComponentStyles(){return{display:"flex",alignItems:"center"}}},Y0=class extends se{render(){return z("select",{style:this.getCompiledStyles(),value:this.props.item.selectedOrFirstVariant.value.mID,onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){Ye(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let t={},e=this.mediaStyle.typo??new Ge;return t.letterSpacing=e.letterSpacing,t.fontSize=e.fs+"px",t.lineHeight=e.lh,t.fontFamily="inherit",t.textAlign=e.alignment,t.fontWeight=e.fw,this.stylesConverter.getColourStyles(e.tc,"color",t),t.boxShadow="none",t}getComponentStyles(){let t={};return this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"&&(t.visibility="hidden"),T(T({},t),this.getTypoStyles())}createSelectItems(){let t=[];for(let e of this.props.item.vars)t.push(z("option",{value:e.mID,disabled:!e.isAvailable,children:e.name}));return t}onChange(t){let e=t.target.value,r=this.props.item.vars.find(n=>n.mID===e);this.props.item.setSelectedVariant(r)}},td=class extends se{constructor(t,e){super(t,e),this.setState(()=>({decoration:"unset"}))}renderElement(t){if(!(t.hide||!this.matchWhenCondition(t.when))){if(t.t===4){let e=t;return z(G0,{element:e,triggerContext:this.props.triggerContext,elements:e.elems,item:this.props.item,noLinks:this.props.noLinks})}if(t.t===6)return this.props.triggerContext.triggerData.isBundle()?z(W0,{element:t,item:this.props.item,triggerContext:this.props.triggerContext}):void 0;if(t.t===13){let e=t,r=this.props.item,n=r.variantImage??r.imageURL,i=r.variantSecondaryImage??r.secondaryImageURL;e.lg=e.sm={src:n,name:r.name,secondarySrc:i};let s=z(uc,{element:e,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?s:z("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block"},children:s})}if(t.t===14)return this.renderProductTitle(t);if(t.t===15){let e=t;return this.props.triggerContext.triggerData.isCartEmbed()&&this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"?void 0:e.showChips?z("cooee-product-options-picker",{item:this.props.item,element:e}):z(Y0,{element:e,item:this.props.item,triggerContext:this.props.triggerContext})}return t.t===16?z(z0,{element:t,selectedVariant:this.props.item.selectedOrFirstVariant.value,item:this.props.item,triggerContext:this.props.triggerContext}):t.t===19?z(K0,{element:t,triggerContext:this.props.triggerContext,review:this.props.item.reviews}):t.t===18||t.t===3?z(Zp,{element:t,item:this.props.item,triggerContext:this.props.triggerContext}):z(pc,{elements:[t],element:this.props.element,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(t=>this.renderElement(t))}getComponentStyles(){return{}}renderProductTitle(t){let e=z(si,{element:t,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?e:z("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block",textDecoration:this.state.decoration},onMouseEnter:this.onMouseEnter.bind(this),onMouseLeave:this.onMouseLeave.bind(this),children:e})}customOnClick(t){this.sendTriggerClicked([this.props.item.toEmbed()],{from:t})}onMouseEnter(){this.setState(()=>({decoration:"underline"}))}onMouseLeave(){this.setState(()=>({decoration:"unset"}))}},ed=class extends se{productElement;constructor(t,e){super(t,e),this.setState(()=>({decoration:"unset"}))}render(){let t=JSON.stringify(this.props.element),e=Ve.render(t,this.getProductData());try{this.productElement=new Fa(JSON.parse(e))}catch(r){throw Gt.getInstance().captureError(r,"variable-replacement",{extra:{before:t,after:e},triggerContext:this.props.triggerContext}),r}if(!(this.productElement.hide||!this.matchWhenCondition(this.productElement.when)))return z("div",{style:T({},this.getCompiledStyles()),class:"lc-single-product",children:z(td,{element:this.productElement,elements:this.productElement.elems,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.productElement.noLinks})})}getComponentStyles(){return{flexShrink:0}}getProductData(){if(!this.props.item)return{};let t=this.props.item,e=t.selectedOrFirstVariant.value,r=t.getTemplateVariables();r.product.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(this.props.item.quantity):this.props.item.quantity;let n=this.props.triggerContext.triggerData.discount.type===ye.BXGY;return!e.hasEffectivePrice()&&n&&(r.product.effective_price=he(e.effectivePrice.value),r.product.price=""),r.variant.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(e.quantity):e.quantity,{product:r.product,variant:r.variant,svg:{color:()=>"{{svg.color}}",size:()=>"{{svg.size}}"}}}};function rd(t,e){if(!t)return;let r=new window.CooeeSDK.Swiper(t,{loop:!0,slidesPerView:e.maxInRow,spaceBetween:e.gap+"px",pagination:{type:e.pagination.type,el:t.querySelector(".swiper-pagination"),clickable:!0,renderBullet:(n,i)=>`
63
63
  <span class="${i}"
64
64
  style="background-color: ${e.pagination.color?.rgba};"></span>
65
65
  `,renderProgressbar:n=>`