@salla.sa/twilight 2.14.263 → 2.14.264
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@salla.sa/twilight.min.js +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}var t,r,n,i,o,a,s,l,c,u,d,h,f,p,g,m,v,y,b,w,_,S,E,k,x,P,A,I,O,T,j,C,R,F,L,U,N,q,z,D,$,M,B,H,J,G,W,V,Y,K,Q,X,Z,ee,te,re,ne,ie,oe,ae,se,le,ce,ue,de,he,fe,pe,ge,me,ve,ye,be,we,_e,Se,Ee,ke,xe,Pe,Ae,Ie,Oe,Te,je,Ce,Re,Fe,Le,Ue,Ne,qe,ze,De,$e,Me,Be,He,Je,Ge,We,Ve,Ye,Ke,Qe="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Xe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ze(){if(r)return t;r=1;var e=Array.isArray;return t=e}function et(){if(a)return o;a=1;var e=function(){if(i)return n;i=1;var e="object"==typeof Xe&&Xe&&Xe.Object===Object&&Xe;return n=e}(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return o=r}function tt(){if(l)return s;l=1;var e=et().Symbol;return s=e}function rt(){if(p)return f;p=1;var e=tt(),t=function(){if(u)return c;u=1;var e=tt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;return c=function(e){var t=r.call(e,i),o=e[i];try{e[i]=void 0;var a=!0}catch(e){}var s=n.call(e);return a&&(t?e[i]=o:delete e[i]),s}}(),r=function(){if(h)return d;h=1;var e=Object.prototype.toString;return d=function(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return f=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function nt(){if(y)return v;y=1;var e=rt(),t=m?g:(m=1,g=function(e){return null!=e&&"object"==typeof e});return v=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function it(){if(S)return _;return S=1,_=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function ot(){if(I)return A;I=1;var e,t=function(){if(P)return x;P=1;var e=et()["__core-js_shared__"];return x=e}(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return A=function(e){return!!r&&r in e}}function at(){if(C)return j;C=1;var e=function(){if(k)return E;k=1;var e=rt(),t=it();return E=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}(),t=ot(),r=it(),n=function(){if(T)return O;T=1;var e=Function.prototype.toString;return O=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,c=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return j=function(o){return!(!r(o)||t(o))&&(e(o)?c:i).test(n(o))}}function st(){if(U)return L;U=1;var e=at(),t=F?R:(F=1,R=function(e,t){return null==e?void 0:e[t]});return L=function(r,n){var i=t(r,n);return e(i)?i:void 0}}function lt(){if(q)return N;q=1;var e=st()(Object,"create");return N=e}function ct(){if(K)return Y;K=1;var e=function(){if(D)return z;D=1;var e=lt();return z=function(){this.__data__=e?e(null):{},this.size=0}}(),t=M?$:(M=1,$=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}),r=function(){if(H)return B;H=1;var e=lt(),t=Object.prototype.hasOwnProperty;return B=function(r){var n=this.__data__;if(e){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(n,r)?n[r]:void 0}}(),n=function(){if(G)return J;G=1;var e=lt(),t=Object.prototype.hasOwnProperty;return J=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}(),i=function(){if(V)return W;V=1;var e=lt();return W=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}();function o(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Y=o}function ut(){if(re)return te;re=1;var e=ee?Z:(ee=1,Z=function(e,t){return e===t||e!=e&&t!=t});return te=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function dt(){if(he)return de;he=1;var e=X?Q:(X=1,Q=function(){this.__data__=[],this.size=0}),t=function(){if(ie)return ne;ie=1;var e=ut(),t=Array.prototype.splice;return ne=function(r){var n=this.__data__,i=e(n,r);return!(i<0||(i==n.length-1?n.pop():t.call(n,i,1),--this.size,0))}}(),r=function(){if(ae)return oe;ae=1;var e=ut();return oe=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}(),n=function(){if(le)return se;le=1;var e=ut();return se=function(t){return e(this.__data__,t)>-1}}(),i=function(){if(ue)return ce;ue=1;var e=ut();return ce=function(t,r){var n=this.__data__,i=e(n,t);return i<0?(++this.size,n.push([t,r])):n[i][1]=r,this}}();function o(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,de=o}function ht(){if(me)return ge;me=1;var e=ct(),t=dt(),r=function(){if(pe)return fe;pe=1;var e=st()(et(),"Map");return fe=e}();return ge=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function ft(){if(we)return be;we=1;var e=ye?ve:(ye=1,ve=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return be=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function pt(){if(Te)return Oe;Te=1;var e=ht(),t=function(){if(Se)return _e;Se=1;var e=ft();return _e=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}(),r=function(){if(ke)return Ee;ke=1;var e=ft();return Ee=function(t){return e(this,t).get(t)}}(),n=function(){if(Pe)return xe;Pe=1;var e=ft();return xe=function(t){return e(this,t).has(t)}}(),i=function(){if(Ie)return Ae;Ie=1;var e=ft();return Ae=function(t,r){var n=e(this,t),i=n.size;return n.set(t,r),this.size+=n.size==i?0:1,this}}();function o(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Oe=o}function gt(){if(Fe)return Re;Fe=1;var e=function(){if(Ce)return je;Ce=1;var e=pt();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var e=arguments,t=n?n.apply(this,e):e[0],o=i.cache;if(o.has(t))return o.get(t);var a=r.apply(this,e);return i.cache=o.set(t,a)||o,a};return i.cache=new(t.Cache||e),i}return t.Cache=e,je=t}();return Re=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function mt(){if(De)return ze;De=1;var e=tt(),t=qe?Ne:(qe=1,Ne=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}),r=Ze(),n=nt(),i=e?e.prototype:void 0,o=i?i.toString:void 0;return ze=function e(i){if("string"==typeof i)return i;if(r(i))return t(i,e)+"";if(n(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},ze}function vt(){if(He)return Be;He=1;var e=Ze(),t=function(){if(w)return b;w=1;var e=Ze(),t=nt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return b=function(i,o){if(e(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!t(i))||n.test(i)||!r.test(i)||null!=o&&i in Object(o)}}(),r=function(){if(Ue)return Le;Ue=1;var e=gt(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e((function(e){var n=[];return 46===e.charCodeAt(0)&&n.push(""),e.replace(t,(function(e,t,i,o){n.push(i?o.replace(r,"$1"):t||e)})),n}));return Le=n}(),n=function(){if(Me)return $e;Me=1;var e=mt();return $e=function(t){return null==t?"":e(t)}}();return Be=function(i,o){return e(i)?i:t(i,o)?[i]:r(n(i))}}function yt(){if(Ve)return We;Ve=1;var e=vt(),t=function(){if(Ge)return Je;Ge=1;var e=nt();return Je=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}();return We=function(r,n){for(var i=0,o=(n=e(n,r)).length;null!=r&&i<o;)r=r[t(n[i++])];return i&&i==o?r:void 0}}var bt=function(){if(Ke)return Ye;Ke=1;var e=yt();return Ye=function(t,r,n){var i=null==t?void 0:e(t,r);return void 0===i?n:i}}();function wt(){throw new Error("setTimeout has not been defined")}function _t(){throw new Error("clearTimeout has not been defined")}var St=wt,Et=_t;function kt(e){if(St===setTimeout)return setTimeout(e,0);if((St===wt||!St)&&setTimeout)return St=setTimeout,setTimeout(e,0);try{return St(e,0)}catch(t){try{return St.call(null,e,0)}catch(t){return St.call(this,e,0)}}}"function"==typeof Qe.setTimeout&&(St=setTimeout),"function"==typeof Qe.clearTimeout&&(Et=clearTimeout);var xt,Pt=[],At=!1,It=-1;function Ot(){At&&xt&&(At=!1,xt.length?Pt=xt.concat(Pt):It=-1,Pt.length&&Tt())}function Tt(){if(!At){var e=kt(Ot);At=!0;for(var t=Pt.length;t;){for(xt=Pt,Pt=[];++It<t;)xt&&xt[It].run();It=-1,t=Pt.length}xt=null,At=!1,function(e){if(Et===clearTimeout)return clearTimeout(e);if((Et===_t||!Et)&&clearTimeout)return Et=clearTimeout,clearTimeout(e);try{return Et(e)}catch(t){try{return Et.call(null,e)}catch(t){return Et.call(this,e)}}}(e)}}function jt(e,t){this.fun=e,this.array=t}jt.prototype.run=function(){this.fun.apply(null,this.array)};function Ct(){}var Rt=Ct,Ft=Ct,Lt=Ct,Ut=Ct,Nt=Ct,qt=Ct,zt=Ct;var Dt=Qe.performance||{},$t=Dt.now||Dt.mozNow||Dt.msNow||Dt.oNow||Dt.webkitNow||function(){return(new Date).getTime()};var Mt=new Date;var Bt,Ht={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Pt.push(new jt(e,t)),1!==Pt.length||At||kt(Tt)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Rt,addListener:Ft,once:Lt,off:Ut,removeListener:Nt,removeAllListeners:qt,emit:zt,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*$t.call(Dt),r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r-=e[0],(n-=e[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Mt)/1e3}},Jt={exports:{}};var Gt,Wt,Vt,Yt,Kt=(Bt||(Bt=1,function(e,t){!function(t){var r=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},i="object"==typeof Ht&&"function"==typeof Ht.nextTick,o="function"==typeof Symbol,a="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,l=o?a&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&u.call(this,this._conf)}function u(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),void 0!==Ht&&Ht.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,Ht.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var h=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function f(e,r){for(var n={},i=e.length,o=0;o<i;o++)n[e[o]]=o<0?r[o]:t;return n}function p(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function g(e,n,i,o){var a=Object.assign({},n);if(!e)return a;if("object"!=typeof e)throw TypeError("options must be an object");var s,l,c,u=Object.keys(e),d=u.length;function h(e){throw Error('Invalid "'+s+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<d;f++){if(s=u[f],!r.call(n,s))throw Error('Unknown "'+s+'" option');(l=e[s])!==t&&(c=i[s],a[s]=c?c(l,h):l)}return a}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function v(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var o=typeof e;if(o===n||o===i)return e;r(t)}:function(n,i){for(var o=typeof n,a=r;a-- >0;)if(o===e[a])return n;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,o=this._emitter,a=this._listeners,s=function(){var n=h.apply(null,arguments),a={data:n,name:t,original:e};r?!1!==r.call(i,a)&&o.emit.apply(o,[a.name].concat(n)):o.emit.apply(o,[t].concat(n))};if(a[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===a[e]&&(a[e]=s,n._on.call(i,e,s))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!o.hasListeners(r)&&a[e]&&(a[e]=null,n._off.call(i,e,s))},a[e]=null,o.on("removeListener",this._onRemoveListener)):(a[e]=s,n._on.call(i,e,s))},unsubscribe:function(e){var t,r,n,i=this,o=this._listeners,a=this._emitter,s=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(a.off("newListener",i._onNewListener),a.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=_.call(a,i);a._observers.splice(e,1)}if(e){if(!(t=o[e]))return;s.call(c,e,t),delete o[e],--this._listenersCount||u()}else{for(n=(r=l(o)).length;n-- >0;)e=r[n],s.call(c,e,o[e]);this._listeners={},this._listenersCount=0,u()}}});var y=v(["function"]),b=v(["object","function"]);function w(e,t,r){var n,i,o,a=0,s=new e((function(l,c,u){function d(){i&&(i=null),a&&(clearTimeout(a),a=0)}r=g(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var h=function(e){d(),l(e)},f=function(e){d(),c(e)};n?t(h,f,u):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),r.timeout>0&&(a=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",a=0,s.cancel(e),c(e)}),r.timeout))}));return n||(s.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),s}function _(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function S(e,t,r,n,i){if(!r)return null;if(0===n){var o=typeof t;if("string"===o){var a,s,c=0,u=0,d=this.delimiter,h=d.length;if(-1!==(s=t.indexOf(d))){a=new Array(5);do{a[c++]=t.slice(u,s),u=s+h}while(-1!==(s=t.indexOf(d,u)));a[c++]=t.slice(u),t=a,i=c}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,p,g,m,v,y,b,w=null,_=t[n],E=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),w=[r]):(e&&e.push.apply(e,r._listeners),w=[r]));else{if("*"===_){for(s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&(b=S(e,t,r[f],n+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===_){for((v=n+1===i||n+2===i&&"*"===E)&&r._listeners&&(w=S(e,t,r,i,i)),s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&("*"===f||"**"===f?(r[f]._listeners&&!v&&(b=S(e,t,r[f],i,i))&&(w?w.push.apply(w,b):w=b),b=S(e,t,r[f],n,i)):b=S(e,t,r[f],f===E?n+2:n,i),b&&(w?w.push.apply(w,b):w=b));return w}r[_]&&(w=S(e,t,r[_],n+1,i))}if((p=r["*"])&&S(e,t,p,n+1,i),g=r["**"])if(n<i)for(g._listeners&&S(e,t,g,i,i),s=(y=l(g)).length;s-- >0;)"_listeners"!==(f=y[s])&&(f===E?S(e,t,g[f],n+2,i):f===_?S(e,t,g[f],n+1,i):((m={})[f]=g[f],S(e,t,{"**":m},n+1,i)));else g._listeners?S(e,t,g,i,i):g["*"]&&g["*"]._listeners&&S(e,t,g["*"],i,i);return w}function E(e,t,r){var n,i,o=0,a=0,s=this.delimiter,l=s.length;if("string"==typeof e)if(-1!==(n=e.indexOf(s))){i=new Array(5);do{i[o++]=e.slice(a,n),a=n+l}while(-1!==(n=e.indexOf(s,a)));i[o++]=e.slice(a)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,u=this.listenerTree;for(n=0;n<o;n++)if(u=u[c=i[n]]||(u[c]={}),n===o-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),r?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,d.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function k(e,t,r,n){for(var i,o,a,s,c=l(e),u=c.length,d=e._listeners;u-- >0;)i=e[o=c[u]],a="_listeners"===o?r:r?r.concat(o):[o],s=n||"symbol"==typeof o,d&&t.push(s?a:a.join(this.delimiter)),"object"==typeof i&&k.call(this,i,t,a,s);return t}function x(e){for(var t,r,n,i=l(e),o=i.length;o-- >0;)(t=e[r=i[o]])&&(n=!0,"_listeners"===r||x(t)||delete e[r]);return n}function P(e,t,r){this.emitter=e,this.event=t,this.listener=r}function A(e,r,n){if(!0===n)a=!0;else if(!1===n)o=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var o=n.async,a=n.promisify,l=n.nextTick,c=n.objectify}if(o||l||a){var u=r,d=r._origin||r;if(l&&!i)throw Error("process.nextTick is not supported");a===t&&(a="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return a?l?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=r,u.apply(t,e)})):(l?Ht.nextTick:s)((function(){t.event=r,u.apply(t,e)}))},r._async=!0,r._origin=d}return[r,c?new P(this,e,r):this]}function I(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,u.call(this,e)}P.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},I.EventEmitter2=I,I.prototype.listenTo=function(e,r,i){if("object"!=typeof e)throw TypeError("target musts be an object");var o=this;function a(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,n=i.reducers,a=_.call(o,e);r=-1===a?new p(o,e,i):o._observers[a];for(var s,c=l(t),u=c.length,d="function"==typeof n,h=0;h<u;h++)s=c[h],r.subscribe(s,t[s]||s,d?n:n&&n[s])}return i=g(i,{on:t,off:t,reducers:t},{on:y,off:y,reducers:b}),n(r)?a(f(r)):a("string"==typeof r?f(r.split(/\s+/)):r),this},I.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),o=!0);return o},I.prototype.delimiter=".",I.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},I.prototype.getMaxListeners=function(){return this._maxListeners},I.prototype.event="",I.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},I.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},I.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},I.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},I.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},I.prototype._many=function(e,t,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function a(){return 0==--t&&o.off(e,a),r.apply(this,arguments)}return a._origin=r,this._on(e,a,n,i)},I.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,a,s=arguments[0],l=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(r=s.length,o)for(n=0;n<r;n++)if("symbol"==typeof s[n]){a=!0;break}a||(s=s.join(this.delimiter))}var u,d=arguments.length;if(this._all&&this._all.length)for(n=0,r=(u=this._all.slice()).length;n<r;n++)switch(this.event=s,d){case 1:u[n].call(this,s);break;case 2:u[n].call(this,s,arguments[1]);break;case 3:u[n].call(this,s,arguments[1],arguments[2]);break;default:u[n].apply(this,arguments)}if(l)u=[],S.call(this,u,e,this.listenerTree,0,r);else{if("function"==typeof(u=this._events[s])){switch(this.event=s,d){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(d>3)for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];for(n=0,r=u.length;n<r;n++)switch(this.event=s,d){case 1:u[n].call(this);break;case 2:u[n].call(this,arguments[1]);break;case 3:u[n].call(this,arguments[1],arguments[2]);break;default:u[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===s)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},I.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,a,s=arguments[0],l=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(n=s.length,o)for(i=0;i<n;i++)if("symbol"==typeof s[i]){t=!0;break}t||(s=s.join(this.delimiter))}var u,d=[],h=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=s,h){case 1:d.push(this._all[i].call(this,s));break;case 2:d.push(this._all[i].call(this,s,arguments[1]));break;case 3:d.push(this._all[i].call(this,s,arguments[1],arguments[2]));break;default:d.push(this._all[i].apply(this,arguments))}if(l?(u=[],S.call(this,u,e,this.listenerTree,0)):u=this._events[s],"function"==typeof u)switch(this.event=s,h){case 1:d.push(u.call(this));break;case 2:d.push(u.call(this,arguments[1]));break;case 3:d.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];d.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),h>3)for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];for(i=0,n=u.length;i<n;i++)switch(this.event=s,h){case 1:d.push(u[i].call(this));break;case 2:d.push(u[i].call(this,arguments[1]));break;case 3:d.push(u[i].call(this,arguments[1],arguments[2]));break;default:d.push(u[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===s)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(d)},I.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},I.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},I.prototype.onAny=function(e){return this._onAny(e,!1)},I.prototype.prependAny=function(e){return this._onAny(e,!0)},I.prototype.addListener=I.prototype.on,I.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},I.prototype._on=function(e,r,n,i){if("function"==typeof e)return this._onAny(e,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||c.call(this);var o,a=this;return i!==t&&(r=(o=A.call(this,e,r,i))[0],a=o[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(E.call(this,e,r,n),a):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(r):this._events[e].push(r),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,d.call(this,this._events[e].length,e))):this._events[e]=r,a)},I.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=S.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var a=0;a<i.length;a++){var s=i[a];if(r=s._listeners,n(r)){for(var l=-1,c=0,u=r.length;c<u;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?s._listeners.splice(l,1):this._events[e].splice(l,1),0===r.length&&(this.wildcard?delete s._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete s._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&x(this.listenerTree),this},I.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},I.prototype.removeListener=I.prototype.off,I.prototype.removeAllListeners=function(e){if(e===t)return!this._events||c.call(this),this;if(this.wildcard){var r,n=S.call(this,null,e,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&x(this.listenerTree)}else this._events&&(this._events[e]=null);return this},I.prototype.listeners=function(e){var r,n,i,o,a,s=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!s)return[];for(o=(r=l(s)).length,i=[];o-- >0;)"function"==typeof(n=s[r[o]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(a=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,c,u,a,0),c}return s&&(n=s[e])?"function"==typeof n?[n]:n:[]},I.prototype.eventNames=function(e){var t=this._events;return this.wildcard?k.call(this,this.listenerTree,[],null,e):t?l(t):[]},I.prototype.listenerCount=function(e){return this.listeners(e).length},I.prototype.hasListeners=function(e){if(this.wildcard){var r=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(e===t?l(i).length:i[e]))},I.prototype.listenersAny=function(){return this._all?this._all:[]},I.prototype.waitFor=function(e,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),w((r=g(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:m})).Promise,(function(t,i,o){function a(){var o=r.filter;if(!o||o.apply(n,arguments))if(n.off(e,a),r.handleError){var s=arguments[0];s?i(s):t(h.apply(null,arguments).slice(1))}else t(h.apply(null,arguments))}o((function(){n.off(e,a)})),n._on(e,a,!1)}),{timeout:r.timeout,overload:r.overload})};var O=I.prototype;Object.defineProperties(I,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");O._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return w((r=g(r,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(r,n,i){var o;if("function"==typeof e.addEventListener)return o=function(){r(h.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var a,s=function(){a&&e.removeListener("error",a),r(h.apply(null,arguments))};"error"!==t&&(a=function(r){e.removeListener(t,s),n(r)},e.once("error",a)),i((function(){a&&e.removeListener("error",a),e.removeListener(t,s)})),e.once(t,s)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=I}()}(Jt)),Jt.exports);function Qt(){if(Wt)return Gt;Wt=1;var e=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)o(Object(arguments[i]),(function(t,r){e[r]=t}));return e},t=function(){if(Object.create)return function(t,r,n,o){var a=i(arguments,1);return e.apply(this,[Object.create(t)].concat(a))};{function t(){}return function(r,n,o,a){var s=i(arguments,1);return t.prototype=r,e.apply(this,[new t].concat(s))}}}(),r=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},n="undefined"!=typeof window?window:Xe;function i(e,t){return Array.prototype.slice.call(e,t||0)}function o(e,t){a(e,(function(e,r){return t(e,r),!1}))}function a(e,t){if(s(e)){for(var r=0;r<e.length;r++)if(t(e[r],r))return e[r]}else for(var n in e)if(e.hasOwnProperty(n)&&t(e[n],n))return e[n]}function s(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}return Gt={assign:e,create:t,trim:r,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:i,each:o,map:function(e,t){var r=s(e)?[]:{};return a(e,(function(e,n){return r[n]=t(e,n),!1})),r},pluck:a,isList:s,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:n},Gt}var Xt,Zt,er=function(){if(Yt)return Vt;Yt=1;var e=Qt(),t=e.slice,r=e.pluck,n=e.each,i=e.bind,o=e.create,a=e.isList,s=e.isFunction,l=e.isObject,c={version:"2.0.12",enabled:!1,get:function(e,t){var r=this.storage.read(this._namespacePrefix+e);return this._deserialize(r,t)},set:function(e,t){return void 0===t?this.remove(e):(this.storage.write(this._namespacePrefix+e,this._serialize(t)),t)},remove:function(e){this.storage.remove(this._namespacePrefix+e)},each:function(e){var t=this;this.storage.each((function(r,n){e.call(t,t._deserialize(r),(n||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return u.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return u(this.storage,this.plugins,e)}};function u(e,u,d){d||(d=""),e&&!a(e)&&(e=[e]),u&&!a(u)&&(u=[u]);var h=d?"__storejs_"+d+"_":"",f=d?new RegExp("^"+h):null;if(!/^[a-zA-Z0-9_\-]*$/.test(d))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var p={_namespacePrefix:h,_namespaceRegexp:f,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var r=e.read(t)===t;return e.remove(t),r}catch(e){return!1}},_assignPluginFnProp:function(e,r){var i=this[r];this[r]=function(){var r=t(arguments,0),o=this;var a=[function(){if(i)return n(arguments,(function(e,t){r[t]=e})),i.apply(o,r)}].concat(r);return e.apply(o,a)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var r="";try{r=JSON.parse(e)}catch(t){r=e}return void 0!==r?r:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(a(e))n(e,(function(e){t._addPlugin(e)}));else if(!r(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!s(e))throw new Error("Plugins must be function values that return objects");var i=e.call(this);if(!l(i))throw new Error("Plugins must return an object of function properties");n(i,(function(r,n){if(!s(r))throw new Error("Bad plugin property: "+n+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(r,n)}))}},addStorage:function(e){!function(){var e="undefined"==typeof console?null:console;e&&(e.warn?e.warn:e.log).apply(e,arguments)}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},g=o(p,c,{plugins:[]});return g.raw={},n(g,(function(e,t){s(e)&&(g.raw[t]=i(g,e))})),n(e,(function(e){g._addStorage(e)})),n(u,(function(e){g._addPlugin(e)})),g}return Vt={createStore:u}}();var tr,rr,nr=function(){if(Zt)return Xt;Zt=1;var e=Qt().Global;function t(){return e.localStorage}function r(e){return t().getItem(e)}return Xt={name:"localStorage",read:r,write:function(e,r){return t().setItem(e,r)},each:function(e){for(var n=t().length-1;n>=0;n--){var i=t().key(n);e(r(i),i)}},remove:function(e){return t().removeItem(e)},clearAll:function(){return t().clear()}},Xt}(),ir=e({__proto__:null,default:nr},[nr]);var or,ar,sr=function(){if(rr)return tr;rr=1;var e=Qt().Global;function t(){return e.sessionStorage}function r(e){return t().getItem(e)}return tr={name:"sessionStorage",read:r,write:function(e,r){return t().setItem(e,r)},each:function(e){for(var n=t().length-1;n>=0;n--){var i=t().key(n);e(r(i),i)}},remove:function(e){return t().removeItem(e)},clearAll:function(){return t().clear()}},tr}(),lr=e({__proto__:null,default:sr},[sr]);var cr,ur,dr=function(){if(ar)return or;ar=1;var e=Qt(),t=e.Global,r=e.trim;or={name:"cookieStorage",read:function(e){if(!e||!a(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(n.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;n.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:i,remove:o,clearAll:function(){i((function(e,t){o(t)}))}};var n=t.document;function i(e){for(var t=n.cookie.split(/; ?/g),i=t.length-1;i>=0;i--)if(r(t[i])){var o=t[i].split("="),a=unescape(o[0]);e(unescape(o[1]),a)}}function o(e){e&&a(e)&&(n.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function a(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(n.cookie)}return or}(),hr=e({__proto__:null,default:dr},[dr]);var fr=function(){if(ur)return cr;ur=1,cr={name:"memoryStorage",read:function(t){return e[t]},write:function(t,r){e[t]=r},each:function(t){for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)},remove:function(t){delete e[t]},clearAll:function(t){e={}}};var e={};return cr}(),pr=e({__proto__:null,default:fr},[fr]);function gr(e,t){void 0===t&&(t=!1),e+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],o=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,a=t?i:n,s=0;s<o.length;s++)r=new RegExp(o[s],"g"),e=e.replace(r,a[s]);return e.replace(t?"٫":".",t?".":"٫")}function mr(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?mr(e.replace(/\.(.+)\./g,".$1")):e}function vr(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function yr(e){if(vr(e))return e;var t=Salla.config.get("store.url");return t||(t=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",t)),t.rtrim("/")+"/"+(null==e?void 0:e.ltrim("/"))}function br(e,t,r){if(r=r||window.location.href,!t||!e)return r;var n=new RegExp("([?&])"+e+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}function wr(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function _r(e){return vr(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):wr("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}function Sr(e,t,r){var n,i=e[0];return r&&0==e.length?Array.isArray(r)?(r.push(t),r):[r,t]:Array.isArray(r)?(r.push(t),r):"string"==typeof r?[r,t]:r?(r[i]=Sr(e.slice(1),t,r[i]),r):i?((n={})[i]=Sr(e.slice(1),t),n):""===i?[t]:t}function Er(){return window.self!==window.top}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(e,t){for(var r,n=this,i=0;i<e.length;i++)r=new RegExp(e[i],"g"),n=n.replace(r,t[i]);return n},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)};var kr={digitsOnly:function(e){return gr(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,r){if(void 0===r&&(r=!1),"string"==typeof t)return document.querySelectorAll(t).forEach((function(t){return e(t,r)}));if(t){var n=Salla.helpers.digitsOnly(t.value);return t.min&&n<parseInt(t.min)?t.value=t.min:t.max&&n>parseInt(t.max)?t.value=t.max:t.maxLength>=1&&n.toString().length>t.maxLength?t.value=n.toString().substring(0,t.maxLength):t.value=r||t.dataset.hasOwnProperty("digitsWithDecimal")?mr(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:gr,money:function(e,t){void 0===t&&(t=!0);var r=Salla.config.currency(null==e?void 0:e.currency).symbol;return e=gr(e="object"==typeof e?e.amount:e)+" "+r,t&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(e=e.replace(r,"<i class=sicon-sar></i>")),e},isIframe:Er,isPreview:function(){return Er()},setNested:function(e,t,r){for(var n=e,i=t.split("."),o=i.length,a=0;a<o-1;a++){var s=i[a];n[s]||(n[s]={}),n=n[s]}return n[i[o-1]]=r,e},getNested:function(e,t,r){var n=bt.default?bt.default(e,t):bt(e,t);return void 0!==n?n:r},inputData:function(e,t,r){if(void 0===r&&(r={}),e.includes("[")){var n=e.split("]").join("").split("["),i=n[0],o=r&&"object"==typeof r?r[i]:void 0;return{name:i,value:Sr(n.slice(1),t,o)}}return{name:e,value:t}},url:Object.freeze({__proto__:null,addParamToUrl:br,api:function(e){var t;return(null===(t=Salla.config.get("store.api",yr("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},asset:_r,base:function(e){return vr(e)?e:"https://"+new URL(yr("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},baseUrl:wr,cdn:function(e,t,r){var n="https://cdn.salla.network/";return(t||r)&&(t=t?",width=".concat(t):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(t).concat(r,",onerror=redirect,format=auto/")),n+(null==e?void 0:e.ltrim("/"))},create:function(e,t){return"custom"===e?t:yr("offers"===e?e:"redirect/".concat(e,"/").concat(t))},domain:function(e){return vr(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},get:yr,is_full_url:vr,is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return _r(salla.config.get("theme.settings.placeholder"))===_r(e)}}),addParamToUrl:br,debounce:function(e,t){t=t||100;var r,n=[];return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return clearTimeout(r),r=setTimeout((function(){var t=e.apply(void 0,i);n.forEach((function(e){return e(t)})),n=[]}),t),new Promise((function(e){return n.push(e)}))}},hasApplePay:function(){var e;try{return!!(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments())}catch(e){return console.error(e),!1}}},xr=function(e,t){return xr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},xr(e,t)},Pr=function(){return Pr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Pr.apply(this,arguments)};function Ar(e,t,r){if(2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var Ir,Or,Tr,jr,Cr=(Ir=console,Or=[],Tr=[],jr={log:function(e,t){if(Ir&&salla.config.isDebug()){Or.push([t,e]),"trace"===salla.config.get("debug")&&(t="trace");var r=Ir.log,n=void 0===t?r:this.__dict__[t]||r,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];Tr.forEach((function(e){i[0]+=e[0],i.push(e[1])}));var o={event:"#CFF680",backend:"#7b68ee"}[t];o&&(i[0]+="%c"+t[0].toUpperCase()+t.substring(1),i.push("margin-left: 5px;color: ".concat(o,";font-weight:bold; border:1px solid ").concat(o,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,Ar([Ir],i.concat.apply(i,e),!1))}},__dict__:{trace:Ir.trace,debug:Ir.debug,info:Ir.info,warn:Ir.warn,error:Ir.error}},{event:function(){jr.log(arguments,"event")},trace:function(){jr.log(arguments,"trace")},debug:function(){jr.log(arguments,"debug")},info:function(){jr.log(arguments,"info")},warn:function(){jr.log(arguments,"warn")},error:function(){jr.log(arguments,"error")},log:function(){jr.log(arguments,void 0)},backend:function(){jr.log(arguments,"backend")},logs:function(e){[e].flat().forEach((function(e){return e&&jr.log([e].flat(),"backend")}))},history:function(){return Or.map((function(e){return Ir.log.apply(Ir,Ar([e[0]],e[1],!1))})),Or},addPrefix:function(e){return Array.isArray(e)?Tr.unshift(e):this.warn("addPrefix receives array only!"),this}}),Rr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=Pr(Pr({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=Pr(Pr({},this.properties_),e),this.properties_.store=Pr(Pr({},(null===(t=this.default_properties)||void 0===t?void 0:t.store)||{}),this.properties_.store),this},e.prototype.set=function(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)},e.prototype.currency=function(e){return void 0===e&&(e=void 0),e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]},e.prototype.get=function(e,t){return void 0===t&&(t=null),e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0},e.prototype.all=function(){return this.properties_},e.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},e}(),Fr=function(e){function t(){var t=this;return(t=e.call(this,{wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1})||this).delimiter="::","undefined"!=typeof document&&(t.body=document.querySelector("body")),t.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],t.ingoreLogEvents=["document::click","document::keyup","document::change"],t.noneFireableActions=["document.request"],t.emittedEvents=new Set,t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}xr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.createAndDispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.dispatch.apply(this,Ar([e],t,!1))},t.prototype.emit=function(t){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.emittedEvents.add(t);var o=t.replace("::",".");if(!this.noneFireableActions.includes(o)&&Salla.call&&"function"==typeof Salla.call(o))return Salla.log("'Salla.".concat(o,"(...)' triggered using event '").concat(t,"'")),o=o.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[o[0]])[o[1]].apply(r,n);e.prototype.emit.apply(this,Ar([t],n,!1)),this.trackEvents.apply(this,Ar([t],n,!1))},t.prototype.onlyWhen=function(e,t){var r=this;return t=t||function(){},new Promise((function(n){return r.emittedEvents.has(e)?n(t()):r.once(e,(function(){return n(t())}))}))},t.prototype.emitAsync=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(t);var i=e.prototype.emitAsync.apply(this,Ar([t],r,!1));try{this.trackEvents.apply(this,Ar([t],r,!1))}catch(e){Salla.logger.warn("error on tracking event (".concat(t,")"),r,e)}return i},t.prototype.trackEvents=function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var i={event:e};r.map((function(e){return"object"==typeof e&&(i=Pr(Pr({},i),e))})),window.dataLayer.push(i)}catch(e){salla.logger.error(e.message)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&(t=Salla.logger).event.apply(t,Ar([e],r,!1)),this.dispatchMobileEvent.apply(this,Ar([e],r,!1))},t.prototype.dispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this.emit.apply(this,Ar([e],t,!1))},t.prototype.dispatchEvents=function(e){if(e)if("object"!=typeof e||Array.isArray(e))Salla.log("Events object is wrong, it should be object of {event:payload}",e);else for(var t=0,r=Object.entries(e);t<r.length;t++){var n=r[t],i=n[0],o=n[1];this.dispatch(i,o)}else Salla.log("No Events To Dispatch!",e)},t.prototype.addListener=function(e,t,r){return this.on(e,t,r)},t.prototype.addEventListener=function(e,t,r){return this.on(e,t,r)},t.prototype.listen=function(e,t){return this.on(e,t)},t.prototype.registerGlobalListener=function(e,t){return this.onAny(t)},t.prototype.dispatchMobileEvent=function(e,t){var r;if(void 0===t&&(t={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:e,details:t})}catch(e){Salla.log(e,"The Flutter context does not exist yet")}}},t}(Kt.EventEmitter2),Lr=er.createStore([ir,lr,hr,pr],[]),Ur=er.createStore([lr],[]),Nr=er.createStore([hr],[]),qr=function(){function e(){var e=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(t){return e.remove(t)})),Salla.event.on("storage::item.set",(function(t,r){return e.set(t,r)})),this.store=Lr,this.session=Ur,this.cookie=Nr}return e.prototype.set=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0],i=((r={})[n]=this.store.get(n),r);return i=Salla.helpers.setNested(i,e,t),this.store.set(n,i[n])}return this.store.set(e,t)},e.prototype.remove=function(e){return this.store.remove(e)},e.prototype.clearAll=function(e){var t=this;if(void 0===e&&(e=!1),e)return this.store.clearAll();this.clearableItems.forEach((function(e){t.store.remove(e)}))},e.prototype.get=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),e)}return this.store.get(e,t)},e.prototype.prefixKey=function(e){return"".concat(e,"_").concat(Salla.config.get("store.id"))},e.prototype.setWithTTL=function(e,t,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var i=this.prefixKey(e),o=(new Date).getTime()+60*r*1e3;return this[n].set(i,{value:t,expiry:o})},e.prototype.getWithTTL=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r="store");var n=this.prefixKey(e),i=this[r].get(n);return i?(new Date).getTime()>i.expiry?(this[r].remove(n),t):i.value:t},e}(),zr=function(){function e(){var e=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(t){return e.remove(t)})),Salla.event.on("cookies::add",(function(t,r){return e.set(t,r)}))}return e.prototype.get=function(e){var t;return null===(t=document.cookie.split("; ").find((function(t){return t.startsWith(e+"=")})))||void 0===t?void 0:t.split("=")[1]},e.prototype.set=function(e,t,r){void 0===t&&(t=""),void 0===r&&(r=10);var n="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),n="; expires="+i.toUTCString()}var o=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=").concat(t).concat(n,"; path=/; SameSite=").concat(o,"; secure"),this},e.prototype.remove=function(e){var t=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=; Max-Age=0; path=/; SameSite=").concat(t,"; secure"),this},e.prototype.clearAll=function(e){return void 0===e&&(e=!1),this.clean(e)},e.prototype.clean=function(e){var t=this;return document.cookie.split(";").map((function(e){return e.split("=")[0].trim()})).filter((function(r){return e||t.keysToRemove.includes(r)||t.dynamicKeysToRemove.some((function(e){return r.startsWith(e)}))})).forEach((function(e){return t.remove(e)})),this},e.prototype.getCookieByPrefix=function(e){return document.cookie.split("; ").map((function(e){return e.split("=")[0]})).filter((function(t){return t.startsWith(e)}))},e.prototype.clearCookieByPrefix=function(e){var t=this;return this.getCookieByPrefix(e).forEach((function(e){return t.remove(e)}))},e}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),void 0!==Qe&&(Qe.salla=Qe.salla||Qe.Salla||{},Qe.Salla=Qe.salla),Salla.status="base",Salla.config=new Rr,Salla.logger=Cr,Salla.event=new Fr,Salla.helpers=kr,Salla.storage=new qr,Salla.cookie=new zr,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.262 - October 9, 2025 06:23:40"};var Dr=Salla;let $r=function(e,t,r){return alert(e)},Mr=function(e,t){return $r(e,Br.error,t)},Br={error:"error",success:"success",info:"info"};var Hr={fire:function(e,t,r){return $r(e,t,r)},setNotifier:function(e){$r=e,salla.event.emit("twilight::notifier.changed")},error:Mr,success:function(e,t){return $r(e,Br.success,t)},info:function(e,t){return $r(e,Br.info,t)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(()=>{e.forEach((e=>{e=decodeURI(e.replace("?danger=","").replace("&danger=",""));let t=document.createElement("div");t.innerText=e,Mr(t.innerHTML),salla.event.emit("twilight::error",e)}))})))},types:Br};class Jr{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,n){return"event"===n?t:"api"===n?e:e&&e[n]||r[n]}})}}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let r=this.getAttribute("data-function");if(r&&window[r])return"function"==typeof window[r]?this.getFilteredData(window[r].call(this,...t)):this.getFilteredData(window[r]);let n=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(n="FORM"===this.tagName?this:n||this.closest("form")||this.closest("[salla-form-data]")||this,n&&"FORM"===n.tagName)return this.getFilteredData(new FormData(n),null,n);let i=n.querySelectorAll("[name]");if(!i.length)return this.getFilteredData();let o=Object.assign({},this.dataset);return i.forEach((e=>{if(!["checkbox","radio"].includes(e.type)||e.checked)try{let t=Salla.helpers.inputData(e.name,e.value,o);o[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(o)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var r=0;r<this.attributes.length;r++){let n=this.attributes[r].name.toLowerCase();if(0===n.indexOf(e))return!t||n}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e=null,t=null,r=null){return e=e||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(e=function(e,t,r){e instanceof FormData?e.append(t,r):e[t]=r;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((n=>{let i=r?.dataset[n]||this.dataset[n];if(i){var o=window[i];if("function"==typeof o){if(!o(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return o(e,r||this,t)}Salla.log("window."+i+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};class Gr{constructor(){this.events={},this.namespace="";let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((e=>{this.createDynamicEventFuns(e),this.createDynamicListenerFuns(e)}))}createDynamicEventFuns(e){if(this[e])return;let t=this;this[e]=function(...r){return t.dispatch(e,...r)}}createDynamicListenerFuns(e){let t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;let r=this;this[t]=function(t){return r.on(e,(async(...e)=>t(...e)))}}getEventName(e){return e=this.events[e]||e||"unknown-event",!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e}dispatch(e,...t){return Salla.event.emitAsync(this.getEventName(e),...t)}on(e,t,r={}){return Salla.event.addListener(this.getEventName(e),t,r)}once(e,t){return Salla.event.once(this.getEventName(e),t)}}function Wr(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends Gr{constructor(){super(),this.namespace="auth",this.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}async loggedIn(e){return Salla.profile.info().finally((()=>this.dispatch("loggedIn",e)))}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends Gr{constructor(){super(),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed",submitting:"submitting"},this.after_init()}updated(e){return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,tax_amount:e.cart.tax_amount,total_discount:e.cart.total_discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:e.cart.free_shipping_bar?.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))}latestFetched(e){return this.updated(e.data),this.dispatch("latestFetched",e)}itemAdded(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)}itemDeleted(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)}itemUpdated(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)}couponAdded(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)}couponDeleted(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)}},Salla.event.order=new class extends Gr{constructor(){super(),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched"},this.after_init()}},Salla.event.scope=new class extends Gr{constructor(){super(),this.namespace="scope",this.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},this.after_init()}},Salla.event.rating=new class extends Gr{constructor(){super(),this.namespace="rating",this.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},this.after_init()}},Salla.event.booking=new class extends Gr{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends Gr{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.landing=new class extends Gr{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.loyalty=new class extends Gr{constructor(){super(),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},this.after_init()}exchangeSucceeded(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)}resetSucceeded(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)}},Salla.event.product=new class extends Gr{constructor(){super(),this.namespace="product",this.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},this.after_init()}},Salla.event.profile=new class extends Gr{constructor(){super(),this.namespace="profile",this.events={updated:"updated",updateFailed:"update.failed",verificationCodeSent:"verification.code.sent",updateContactsFailed:"update.contacts.failed",verified:"verified",unverified:"unverified",infoFetched:"info.fetched",infoNotFetched:"info.not.fetched",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},this.after_init()}},Salla.event.currency=new class extends Gr{constructor(){super(),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}},Salla.event.document=new class extends Gr{constructor(){super(),this.namespace="document",this.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},this.after_init()}onClick(e,t){this.fireCallableFuns("click",e,t)}onChange(e,t){this.fireCallableFuns("change",e,t)}onSubmit(e,t){this.fireCallableFuns("submit",e,t)}onKeyup(e,t){this.fireCallableFuns("keyup",e,t)}fireCallableFuns(e,t,r){this.on(e,(e=>{"function"!=typeof t?"function"==typeof r&&e.target.matches(t)&&r(e):t(e)}))}fireEvent(e,t,...r){return this.fireEventForElements(e,t,!1,...r)}fireEventForAll(e,t,...r){return this.fireEventForElements(e,t,!0,...r)}fireEventForElements(e,t,r,...n){if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...n)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const i=new CustomEvent(t,...n);return e.dispatchEvent(i)}},Salla.event.wishlist=new class extends Gr{constructor(){super(),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}},Salla.event.infiniteScroll=new class extends Gr{constructor(){super(),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}},Salla.event.notifications=new class extends Gr{constructor(){super(),this.namespace="notifications",this.events={fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.component=new class extends Gr{constructor(){super(),this.namespace="component",this.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},this.after_init()}},Salla.event.advertisement=new class extends Gr{constructor(){super(),this.namespace="advertisement",this.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},this.after_init()}},Salla.event.navigation=new class extends Gr{constructor(){super(),this.namespace="navigation",this.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.metadata=new class extends Gr{constructor(){super(),this.namespace="metadata",this.events={valueFetched:"value.fetched",valueNotFetch:"value.not.fetched"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(Wr(e),Object.keys(e).forEach((t=>{Wr(e[t])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:["group","test"].includes(window.location.hostname.split(".").pop())?window.location.origin+"/api/v1/":"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=!1,Salla.config.triedToGetLanguages_=!1,Salla.config.isUser=()=>"user"===Salla.config.get("user.type"),Salla.config.isGuest=()=>!Salla.config.isUser(),Salla.config.languages=async()=>{if(Salla.config.triedToGetLanguages_)return Salla.config.get("languages");Salla.config.triedToGetLanguages_=!0;let e=!0,t=[];return(await salla.document.api.request("languages",null,"get"))?.data?.map((r=>{e&&(t=[],e=!1),r.code=r.code||r.iso_code,r.url=salla.url.get(r.code),r.is_rtl=r.is_rtl||r.rtl,t.push(r)})),Salla.config.set("languages",t),t},Salla.config.currencies=async()=>{if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let e=!0,t={};return(await salla.currency.api.list())?.data?.map((r=>{e&&(t={},e=!1),r.country_code=r.code.substr(0,2).toLowerCase(),t[r.code]=r})),Salla.config.set("currencies",t),t},Salla.config.isMobileApp=()=>["ios","android"].includes(Salla.analytics?.jitsuAnalytics?.getContextProperty("app")?.platform?.toLowerCase());var Vr,Yr={exports:{}},Kr={exports:{}},Qr={exports:{}},Xr=Qr.exports;function Zr(){return Vr||(Vr=1,function(e){!function(t,r){e.exports?e.exports=r():t.EvEmitter=r()}("undefined"!=typeof window?window:Xr,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let r=this._events=this._events||{},n=r[e]=r[e]||[];return n.includes(t)||n.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let r=this._onceEvents=this._onceEvents||{};return(r[e]=r[e]||{})[t]=!0,this},t.off=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;let n=r.indexOf(t);return-1!=n&&r.splice(n,1),this},t.emitEvent=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;r=r.slice(0),t=t||[];let n=this._onceEvents&&this._onceEvents[e];for(let i of r){n&&n[i]&&(this.off(e,i),delete n[i]),i.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(Qr)),Qr.exports}var en,tn,rn={exports:{}},nn=rn.exports;function on(){return en||(en=1,function(e){!function(t,r){e.exports?e.exports=r(t):t.fizzyUIUtils=r(t)}(nn,(function(e){let t={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){if(Array.isArray(e))return e;if(null==e)return[];return"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){let r=e.indexOf(t);-1!=r&&e.splice(r,1)},getParent:function(e,t){for(;e.parentNode&&e!=document.body;)if((e=e.parentNode).matches(t))return e},getQueryElement:function(e){return"string"==typeof e?document.querySelector(e):e},handleEvent:function(e){let t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,r){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!r)return e.push(t),e;t.matches(r)&&e.push(t);let n=t.querySelectorAll(r);return e=e.concat(...n)}),[])},debounceMethod:function(e,t,r){r=r||100;let n=e.prototype[t],i=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[i]);let e=arguments;this[i]=setTimeout((()=>{n.apply(this,e),delete this[i]}),r)}},docReady:function(e){let t=document.readyState;"complete"==t||"interactive"==t?setTimeout(e):document.addEventListener("DOMContentLoaded",e)},toDashed:function(e){return e.replace(/(.)([A-Z])/g,(function(e,t,r){return t+"-"+r})).toLowerCase()}},r=e.console;return t.htmlInit=function(n,i){t.docReady((function(){let o="data-"+t.toDashed(i),a=document.querySelectorAll(`[${o}]`),s=e.jQuery;[...a].forEach((e=>{let t,a=e.getAttribute(o);try{t=a&&JSON.parse(a)}catch(t){return void(r&&r.error(`Error parsing ${o} on ${e.className}: ${t}`))}let l=new n(e,t);s&&s.data(e,i,l)}))}))},t}))}(rn)),rn.exports}function an(){return tn||(tn=1,function(e){!function(t,r){e.exports?e.exports=r(t,Zr(),on()):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let n=e.jQuery,i={};function o(e,t){let a=r.getQueryElement(e);if(a){if((e=a).infiniteScrollGUID){let r=i[e.infiniteScrollGUID];return r.option(t),r}this.element=e,this.options={...o.defaults},this.option(t),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(a||e))}o.defaults={},o.create={},o.destroy={};let a=o.prototype;Object.assign(a,t.prototype);let s=0;a.create=function(){let e=this.guid=++s;if(this.element.infiniteScrollGUID=e,i[e]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let e in o.create)o.create[e].call(this)}else console.error("Disabling InfiniteScroll")},a.option=function(e){Object.assign(this.options,e)},a.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},a.dispatchEvent=function(e,t,r){this.log(e,r);let i=t?[t].concat(r):r;if(this.emitEvent(e,i),!n||!this.$element)return;let o=e+=".infiniteScroll";if(t){let r=n.Event(t);r.type=e,o=r}this.$element.trigger(o,r)};let l={initialized:e=>`on ${e}`,request:e=>`URL: ${e}`,load:(e,t)=>`${e.title||""}. URL: ${t}`,error:(e,t)=>`${e}. URL: ${t}`,append:(e,t,r)=>`${r.length} items. URL: ${t}`,last:(e,t)=>`URL: ${t}`,history:(e,t)=>`URL: ${t}`,pageIndex:function(e,t){return`current page determined to be: ${e} from ${t}`}};a.log=function(e,t){if(!this.options.debug)return;let r=`[InfiniteScroll] ${e}`,n=l[e];n&&(r+=". "+n.apply(this,t)),console.log(r)},a.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},a.updateScroller=function(){let t=this.options.elementScroll;if(t){if(this.scroller=!0===t?this.element:r.getQueryElement(t),!this.scroller)throw new Error(`Unable to find elementScroll: ${t}`)}else this.scroller=e},a.updateGetPath=function(){let e=this.options.path;if(!e)return void console.error(`InfiniteScroll path option required. Set as: ${e}`);let t=typeof e;"function"!=t?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e},a.updateGetPathTemplate=function(e){this.getPath=()=>{let t=this.pageIndex+1;return e.replace("{{#}}",t)};let t=e.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),r=new RegExp(t),n=location.href.match(r);n&&(this.pageIndex=parseInt(n[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=o.getPathParts=function(e){if(e)for(let t of c){let r=e.match(t);if(r){let[,e,t,n]=r;return{begin:e,index:t,end:n}}}};a.updateGetPathSelector=function(e){let t=document.querySelector(e);if(!t)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${e}`);let r=t.getAttribute("href"),n=u(r);if(!n)return void console.error(`InfiniteScroll unable to parse next link href: ${r}`);let{begin:i,index:o,end:a}=n;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+a,this.pageIndex=parseInt(o,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},a.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,r=e.match(/^\?/),n=t.substring(0,t.lastIndexOf("/")),i=r?t:n+"/";this.getAbsolutePath=()=>i+this.getPath()},o.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},o.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},a.destroy=function(){this.allOff();for(let e in o.destroy)o.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},o.throttle=function(e,t){let r,n;return t=t||200,function(){let i=+new Date,o=arguments,a=()=>{r=i,e.apply(this,o)};r&&i<r+t?(clearTimeout(n),n=setTimeout(a,t)):a()}},o.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},o.setJQuery=function(e){n=e},r.htmlInit(o,"infinite-scroll"),a._init=function(){};let{jQueryBridget:d}=e;return n&&d&&d("infiniteScroll",o,n),o}))}(Kr)),Kr.exports}var sn,ln={exports:{}};function cn(){return sn||(sn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an()):r(t,t.InfiniteScroll)}(window,(function(e,t){let r=t.prototype;Object.assign(t.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),t.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},r.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let n=new DOMParser;function i(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return r.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:r}=this.options,i=this.getAbsolutePath();this.isLoading=!0,"function"==typeof r&&(r=r());let o=fetch(i,r).then((r=>{if(!r.ok){let e=new Error(r.statusText);return this.onPageError(e,i,r),{response:r}}return r[e]().then((o=>("text"==e&&t&&(o=n.parseFromString(o,"text/html")),204==r.status?(this.lastPageReached(o,i),{body:o,response:r}):this.onPageLoad(o,i,r))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,o]),o},r.onPageLoad=function(e,t,r){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,r]),this.appendNextPage(e,t,r)},r.appendNextPage=function(e,t,r){let{append:n,responseBody:o,domParseResponse:a}=this.options;if(!("text"==o&&a)||!n)return{body:e,response:r};let s=e.querySelectorAll(n),l={body:e,response:r,items:s};if(!s||!s.length)return this.lastPageReached(e,t),l;let c=i(s),u=()=>(this.appendItems(s,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,s,r]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},r.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),r=e.attributes;for(let e of r)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||i(e)),this.element.appendChild(t))},r.appendOutlayerItems=function(r,n){let i=t.imagesLoaded||e.imagesLoaded;return i?new Promise((function(e){i(r,(function(){let t=n();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},r.onAppendOutlayer=function(e,t,r){this.options.outlayer.appended(r)},r.checkLastPage=function(e,t){let r,{checkLastPage:n,path:i}=this.options;if(n){if("function"==typeof i){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof n?r=n:this.isPathSelector&&(r=i),r&&e.querySelector&&(e.querySelector(r)||this.lastPageReached(e,t))}},r.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},r.onPageError=function(e,t,r){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,r]),e},t.create.prefill=function(){if(!this.options.prefill)return;let e=this.options.append;e?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error(`append option required for prefill. Set as :${e}`)},r.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},r.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},r.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(ln)),ln.exports}var un,dn={exports:{}};function hn(){return un||(un=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;return Object.assign(t.defaults,{scrollThreshold:400}),t.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let e=this.options.scrollThreshold;(e||0===e)&&this.enableScrollWatch()},t.destroy.scrollWatch=function(){this.disableScrollWatch()},n.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},n.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},n.bindScrollWatchEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.pageScrollHandler),e[r]("resize",this.resizeHandler)},n.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),n.getBottomDistance=function(){let t,r;return this.options.elementScroll?(t=this.scroller.scrollHeight,r=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,r=e.scrollY+this.windowHeight),t-r},n.onResize=function(){this.updateMeasurements()},r.debounceMethod(t,"onResize",150),t}))}(dn)),dn.exports}var fn,pn={exports:{}};function gn(){return fn||(fn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;Object.assign(t.defaults,{history:"replace"});let i=document.createElement("a");return t.create.history=function(){if(!this.options.history)return;i.href=this.getAbsolutePath(),(i.origin||i.protocol+"//"+i.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${i.origin} on ${location.origin} . History behavior disabled.`)},n.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},n.bindHistoryAppendEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.scrollHistoryHandler),e[r]("unload",this.unloadHandler)},n.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=n.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},n.onAppendHistory=function(e,t,r){if(!r||!r.length)return;let n=r[0],o=this.getElementScrollY(n);i.href=t,this.scrollPages.push({top:o,path:i.href,title:e.title})},n.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},n.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},r.debounceMethod(t,"onScrollHistory",150),n.getClosestScrollPage=function(){let t,r;t=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:e.scrollY+this.windowHeight/2;for(let e of this.scrollPages){if(e.top>=t)break;r=e}return r},n.setHistory=function(e,t){let r=this.options.history;r&&history[r+"State"]&&(history[r+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},n.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},n.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(pn)),pn.exports}var mn,vn={exports:{}};function yn(){return mn||(mn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){class n{constructor(e,t){this.element=e,this.infScroll=t,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),t.on("request",this.disable.bind(this)),t.on("load",this.enable.bind(this)),t.on("error",this.hide.bind(this)),t.on("last",this.hide.bind(this))}onClick(e){e.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return t.create.button=function(){let e=r.getQueryElement(this.options.button);e&&(this.button=new n(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=n,t}))}(vn)),vn.exports}var bn,wn,_n={exports:{}};function Sn(){return bn||(bn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;function i(e){a(e,"none")}function o(e){a(e,"block")}function a(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=r.getQueryElement(this.options.status);e&&(this.statusElement=e,this.statusEventElements={request:e.querySelector(".infinite-scroll-request"),error:e.querySelector(".infinite-scroll-error"),last:e.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},n.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},n.showRequestStatus=function(){this.showStatus("request")},n.showErrorStatus=function(){this.showStatus("error")},n.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},n.showStatus=function(e){o(this.statusElement),this.hideStatusEventElements(),o(this.statusEventElements[e])},n.hideAllStatus=function(){i(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(let e in this.statusEventElements){i(this.statusEventElements[e])}},t}))}(_n)),_n.exports}
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}var t,r,n,i,o,a,s,l,c,u,d,h,f,p,g,m,v,y,b,w,_,S,E,k,x,P,A,I,O,T,j,C,R,F,L,U,N,q,z,D,$,M,B,H,J,G,W,V,Y,K,Q,X,Z,ee,te,re,ne,ie,oe,ae,se,le,ce,ue,de,he,fe,pe,ge,me,ve,ye,be,we,_e,Se,Ee,ke,xe,Pe,Ae,Ie,Oe,Te,je,Ce,Re,Fe,Le,Ue,Ne,qe,ze,De,$e,Me,Be,He,Je,Ge,We,Ve,Ye,Ke,Qe="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Xe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ze(){if(r)return t;r=1;var e=Array.isArray;return t=e}function et(){if(a)return o;a=1;var e=function(){if(i)return n;i=1;var e="object"==typeof Xe&&Xe&&Xe.Object===Object&&Xe;return n=e}(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return o=r}function tt(){if(l)return s;l=1;var e=et().Symbol;return s=e}function rt(){if(p)return f;p=1;var e=tt(),t=function(){if(u)return c;u=1;var e=tt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;return c=function(e){var t=r.call(e,i),o=e[i];try{e[i]=void 0;var a=!0}catch(e){}var s=n.call(e);return a&&(t?e[i]=o:delete e[i]),s}}(),r=function(){if(h)return d;h=1;var e=Object.prototype.toString;return d=function(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return f=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function nt(){if(y)return v;y=1;var e=rt(),t=m?g:(m=1,g=function(e){return null!=e&&"object"==typeof e});return v=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function it(){if(S)return _;return S=1,_=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function ot(){if(I)return A;I=1;var e,t=function(){if(P)return x;P=1;var e=et()["__core-js_shared__"];return x=e}(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return A=function(e){return!!r&&r in e}}function at(){if(C)return j;C=1;var e=function(){if(k)return E;k=1;var e=rt(),t=it();return E=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}(),t=ot(),r=it(),n=function(){if(T)return O;T=1;var e=Function.prototype.toString;return O=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,c=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return j=function(o){return!(!r(o)||t(o))&&(e(o)?c:i).test(n(o))}}function st(){if(U)return L;U=1;var e=at(),t=F?R:(F=1,R=function(e,t){return null==e?void 0:e[t]});return L=function(r,n){var i=t(r,n);return e(i)?i:void 0}}function lt(){if(q)return N;q=1;var e=st()(Object,"create");return N=e}function ct(){if(K)return Y;K=1;var e=function(){if(D)return z;D=1;var e=lt();return z=function(){this.__data__=e?e(null):{},this.size=0}}(),t=M?$:(M=1,$=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}),r=function(){if(H)return B;H=1;var e=lt(),t=Object.prototype.hasOwnProperty;return B=function(r){var n=this.__data__;if(e){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(n,r)?n[r]:void 0}}(),n=function(){if(G)return J;G=1;var e=lt(),t=Object.prototype.hasOwnProperty;return J=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}(),i=function(){if(V)return W;V=1;var e=lt();return W=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}();function o(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Y=o}function ut(){if(re)return te;re=1;var e=ee?Z:(ee=1,Z=function(e,t){return e===t||e!=e&&t!=t});return te=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function dt(){if(he)return de;he=1;var e=X?Q:(X=1,Q=function(){this.__data__=[],this.size=0}),t=function(){if(ie)return ne;ie=1;var e=ut(),t=Array.prototype.splice;return ne=function(r){var n=this.__data__,i=e(n,r);return!(i<0||(i==n.length-1?n.pop():t.call(n,i,1),--this.size,0))}}(),r=function(){if(ae)return oe;ae=1;var e=ut();return oe=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}(),n=function(){if(le)return se;le=1;var e=ut();return se=function(t){return e(this.__data__,t)>-1}}(),i=function(){if(ue)return ce;ue=1;var e=ut();return ce=function(t,r){var n=this.__data__,i=e(n,t);return i<0?(++this.size,n.push([t,r])):n[i][1]=r,this}}();function o(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,de=o}function ht(){if(me)return ge;me=1;var e=ct(),t=dt(),r=function(){if(pe)return fe;pe=1;var e=st()(et(),"Map");return fe=e}();return ge=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function ft(){if(we)return be;we=1;var e=ye?ve:(ye=1,ve=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return be=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function pt(){if(Te)return Oe;Te=1;var e=ht(),t=function(){if(Se)return _e;Se=1;var e=ft();return _e=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}(),r=function(){if(ke)return Ee;ke=1;var e=ft();return Ee=function(t){return e(this,t).get(t)}}(),n=function(){if(Pe)return xe;Pe=1;var e=ft();return xe=function(t){return e(this,t).has(t)}}(),i=function(){if(Ie)return Ae;Ie=1;var e=ft();return Ae=function(t,r){var n=e(this,t),i=n.size;return n.set(t,r),this.size+=n.size==i?0:1,this}}();function o(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Oe=o}function gt(){if(Fe)return Re;Fe=1;var e=function(){if(Ce)return je;Ce=1;var e=pt();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var e=arguments,t=n?n.apply(this,e):e[0],o=i.cache;if(o.has(t))return o.get(t);var a=r.apply(this,e);return i.cache=o.set(t,a)||o,a};return i.cache=new(t.Cache||e),i}return t.Cache=e,je=t}();return Re=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function mt(){if(De)return ze;De=1;var e=tt(),t=qe?Ne:(qe=1,Ne=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}),r=Ze(),n=nt(),i=e?e.prototype:void 0,o=i?i.toString:void 0;return ze=function e(i){if("string"==typeof i)return i;if(r(i))return t(i,e)+"";if(n(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},ze}function vt(){if(He)return Be;He=1;var e=Ze(),t=function(){if(w)return b;w=1;var e=Ze(),t=nt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return b=function(i,o){if(e(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!t(i))||n.test(i)||!r.test(i)||null!=o&&i in Object(o)}}(),r=function(){if(Ue)return Le;Ue=1;var e=gt(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e((function(e){var n=[];return 46===e.charCodeAt(0)&&n.push(""),e.replace(t,(function(e,t,i,o){n.push(i?o.replace(r,"$1"):t||e)})),n}));return Le=n}(),n=function(){if(Me)return $e;Me=1;var e=mt();return $e=function(t){return null==t?"":e(t)}}();return Be=function(i,o){return e(i)?i:t(i,o)?[i]:r(n(i))}}function yt(){if(Ve)return We;Ve=1;var e=vt(),t=function(){if(Ge)return Je;Ge=1;var e=nt();return Je=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}();return We=function(r,n){for(var i=0,o=(n=e(n,r)).length;null!=r&&i<o;)r=r[t(n[i++])];return i&&i==o?r:void 0}}var bt=function(){if(Ke)return Ye;Ke=1;var e=yt();return Ye=function(t,r,n){var i=null==t?void 0:e(t,r);return void 0===i?n:i}}();function wt(){throw new Error("setTimeout has not been defined")}function _t(){throw new Error("clearTimeout has not been defined")}var St=wt,Et=_t;function kt(e){if(St===setTimeout)return setTimeout(e,0);if((St===wt||!St)&&setTimeout)return St=setTimeout,setTimeout(e,0);try{return St(e,0)}catch(t){try{return St.call(null,e,0)}catch(t){return St.call(this,e,0)}}}"function"==typeof Qe.setTimeout&&(St=setTimeout),"function"==typeof Qe.clearTimeout&&(Et=clearTimeout);var xt,Pt=[],At=!1,It=-1;function Ot(){At&&xt&&(At=!1,xt.length?Pt=xt.concat(Pt):It=-1,Pt.length&&Tt())}function Tt(){if(!At){var e=kt(Ot);At=!0;for(var t=Pt.length;t;){for(xt=Pt,Pt=[];++It<t;)xt&&xt[It].run();It=-1,t=Pt.length}xt=null,At=!1,function(e){if(Et===clearTimeout)return clearTimeout(e);if((Et===_t||!Et)&&clearTimeout)return Et=clearTimeout,clearTimeout(e);try{return Et(e)}catch(t){try{return Et.call(null,e)}catch(t){return Et.call(this,e)}}}(e)}}function jt(e,t){this.fun=e,this.array=t}jt.prototype.run=function(){this.fun.apply(null,this.array)};function Ct(){}var Rt=Ct,Ft=Ct,Lt=Ct,Ut=Ct,Nt=Ct,qt=Ct,zt=Ct;var Dt=Qe.performance||{},$t=Dt.now||Dt.mozNow||Dt.msNow||Dt.oNow||Dt.webkitNow||function(){return(new Date).getTime()};var Mt=new Date;var Bt,Ht={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Pt.push(new jt(e,t)),1!==Pt.length||At||kt(Tt)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Rt,addListener:Ft,once:Lt,off:Ut,removeListener:Nt,removeAllListeners:qt,emit:zt,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*$t.call(Dt),r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r-=e[0],(n-=e[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Mt)/1e3}},Jt={exports:{}};var Gt,Wt,Vt,Yt,Kt=(Bt||(Bt=1,function(e,t){!function(t){var r=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},i="object"==typeof Ht&&"function"==typeof Ht.nextTick,o="function"==typeof Symbol,a="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,l=o?a&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&u.call(this,this._conf)}function u(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),void 0!==Ht&&Ht.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,Ht.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var h=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function f(e,r){for(var n={},i=e.length,o=0;o<i;o++)n[e[o]]=o<0?r[o]:t;return n}function p(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function g(e,n,i,o){var a=Object.assign({},n);if(!e)return a;if("object"!=typeof e)throw TypeError("options must be an object");var s,l,c,u=Object.keys(e),d=u.length;function h(e){throw Error('Invalid "'+s+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<d;f++){if(s=u[f],!r.call(n,s))throw Error('Unknown "'+s+'" option');(l=e[s])!==t&&(c=i[s],a[s]=c?c(l,h):l)}return a}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function v(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var o=typeof e;if(o===n||o===i)return e;r(t)}:function(n,i){for(var o=typeof n,a=r;a-- >0;)if(o===e[a])return n;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,o=this._emitter,a=this._listeners,s=function(){var n=h.apply(null,arguments),a={data:n,name:t,original:e};r?!1!==r.call(i,a)&&o.emit.apply(o,[a.name].concat(n)):o.emit.apply(o,[t].concat(n))};if(a[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===a[e]&&(a[e]=s,n._on.call(i,e,s))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!o.hasListeners(r)&&a[e]&&(a[e]=null,n._off.call(i,e,s))},a[e]=null,o.on("removeListener",this._onRemoveListener)):(a[e]=s,n._on.call(i,e,s))},unsubscribe:function(e){var t,r,n,i=this,o=this._listeners,a=this._emitter,s=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(a.off("newListener",i._onNewListener),a.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=_.call(a,i);a._observers.splice(e,1)}if(e){if(!(t=o[e]))return;s.call(c,e,t),delete o[e],--this._listenersCount||u()}else{for(n=(r=l(o)).length;n-- >0;)e=r[n],s.call(c,e,o[e]);this._listeners={},this._listenersCount=0,u()}}});var y=v(["function"]),b=v(["object","function"]);function w(e,t,r){var n,i,o,a=0,s=new e((function(l,c,u){function d(){i&&(i=null),a&&(clearTimeout(a),a=0)}r=g(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var h=function(e){d(),l(e)},f=function(e){d(),c(e)};n?t(h,f,u):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),r.timeout>0&&(a=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",a=0,s.cancel(e),c(e)}),r.timeout))}));return n||(s.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),s}function _(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function S(e,t,r,n,i){if(!r)return null;if(0===n){var o=typeof t;if("string"===o){var a,s,c=0,u=0,d=this.delimiter,h=d.length;if(-1!==(s=t.indexOf(d))){a=new Array(5);do{a[c++]=t.slice(u,s),u=s+h}while(-1!==(s=t.indexOf(d,u)));a[c++]=t.slice(u),t=a,i=c}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,p,g,m,v,y,b,w=null,_=t[n],E=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),w=[r]):(e&&e.push.apply(e,r._listeners),w=[r]));else{if("*"===_){for(s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&(b=S(e,t,r[f],n+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===_){for((v=n+1===i||n+2===i&&"*"===E)&&r._listeners&&(w=S(e,t,r,i,i)),s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&("*"===f||"**"===f?(r[f]._listeners&&!v&&(b=S(e,t,r[f],i,i))&&(w?w.push.apply(w,b):w=b),b=S(e,t,r[f],n,i)):b=S(e,t,r[f],f===E?n+2:n,i),b&&(w?w.push.apply(w,b):w=b));return w}r[_]&&(w=S(e,t,r[_],n+1,i))}if((p=r["*"])&&S(e,t,p,n+1,i),g=r["**"])if(n<i)for(g._listeners&&S(e,t,g,i,i),s=(y=l(g)).length;s-- >0;)"_listeners"!==(f=y[s])&&(f===E?S(e,t,g[f],n+2,i):f===_?S(e,t,g[f],n+1,i):((m={})[f]=g[f],S(e,t,{"**":m},n+1,i)));else g._listeners?S(e,t,g,i,i):g["*"]&&g["*"]._listeners&&S(e,t,g["*"],i,i);return w}function E(e,t,r){var n,i,o=0,a=0,s=this.delimiter,l=s.length;if("string"==typeof e)if(-1!==(n=e.indexOf(s))){i=new Array(5);do{i[o++]=e.slice(a,n),a=n+l}while(-1!==(n=e.indexOf(s,a)));i[o++]=e.slice(a)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,u=this.listenerTree;for(n=0;n<o;n++)if(u=u[c=i[n]]||(u[c]={}),n===o-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),r?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,d.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function k(e,t,r,n){for(var i,o,a,s,c=l(e),u=c.length,d=e._listeners;u-- >0;)i=e[o=c[u]],a="_listeners"===o?r:r?r.concat(o):[o],s=n||"symbol"==typeof o,d&&t.push(s?a:a.join(this.delimiter)),"object"==typeof i&&k.call(this,i,t,a,s);return t}function x(e){for(var t,r,n,i=l(e),o=i.length;o-- >0;)(t=e[r=i[o]])&&(n=!0,"_listeners"===r||x(t)||delete e[r]);return n}function P(e,t,r){this.emitter=e,this.event=t,this.listener=r}function A(e,r,n){if(!0===n)a=!0;else if(!1===n)o=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var o=n.async,a=n.promisify,l=n.nextTick,c=n.objectify}if(o||l||a){var u=r,d=r._origin||r;if(l&&!i)throw Error("process.nextTick is not supported");a===t&&(a="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return a?l?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=r,u.apply(t,e)})):(l?Ht.nextTick:s)((function(){t.event=r,u.apply(t,e)}))},r._async=!0,r._origin=d}return[r,c?new P(this,e,r):this]}function I(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,u.call(this,e)}P.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},I.EventEmitter2=I,I.prototype.listenTo=function(e,r,i){if("object"!=typeof e)throw TypeError("target musts be an object");var o=this;function a(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,n=i.reducers,a=_.call(o,e);r=-1===a?new p(o,e,i):o._observers[a];for(var s,c=l(t),u=c.length,d="function"==typeof n,h=0;h<u;h++)s=c[h],r.subscribe(s,t[s]||s,d?n:n&&n[s])}return i=g(i,{on:t,off:t,reducers:t},{on:y,off:y,reducers:b}),n(r)?a(f(r)):a("string"==typeof r?f(r.split(/\s+/)):r),this},I.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),o=!0);return o},I.prototype.delimiter=".",I.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},I.prototype.getMaxListeners=function(){return this._maxListeners},I.prototype.event="",I.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},I.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},I.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},I.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},I.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},I.prototype._many=function(e,t,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function a(){return 0==--t&&o.off(e,a),r.apply(this,arguments)}return a._origin=r,this._on(e,a,n,i)},I.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,a,s=arguments[0],l=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(r=s.length,o)for(n=0;n<r;n++)if("symbol"==typeof s[n]){a=!0;break}a||(s=s.join(this.delimiter))}var u,d=arguments.length;if(this._all&&this._all.length)for(n=0,r=(u=this._all.slice()).length;n<r;n++)switch(this.event=s,d){case 1:u[n].call(this,s);break;case 2:u[n].call(this,s,arguments[1]);break;case 3:u[n].call(this,s,arguments[1],arguments[2]);break;default:u[n].apply(this,arguments)}if(l)u=[],S.call(this,u,e,this.listenerTree,0,r);else{if("function"==typeof(u=this._events[s])){switch(this.event=s,d){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(d>3)for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];for(n=0,r=u.length;n<r;n++)switch(this.event=s,d){case 1:u[n].call(this);break;case 2:u[n].call(this,arguments[1]);break;case 3:u[n].call(this,arguments[1],arguments[2]);break;default:u[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===s)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},I.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,a,s=arguments[0],l=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(n=s.length,o)for(i=0;i<n;i++)if("symbol"==typeof s[i]){t=!0;break}t||(s=s.join(this.delimiter))}var u,d=[],h=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=s,h){case 1:d.push(this._all[i].call(this,s));break;case 2:d.push(this._all[i].call(this,s,arguments[1]));break;case 3:d.push(this._all[i].call(this,s,arguments[1],arguments[2]));break;default:d.push(this._all[i].apply(this,arguments))}if(l?(u=[],S.call(this,u,e,this.listenerTree,0)):u=this._events[s],"function"==typeof u)switch(this.event=s,h){case 1:d.push(u.call(this));break;case 2:d.push(u.call(this,arguments[1]));break;case 3:d.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];d.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),h>3)for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];for(i=0,n=u.length;i<n;i++)switch(this.event=s,h){case 1:d.push(u[i].call(this));break;case 2:d.push(u[i].call(this,arguments[1]));break;case 3:d.push(u[i].call(this,arguments[1],arguments[2]));break;default:d.push(u[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===s)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(d)},I.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},I.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},I.prototype.onAny=function(e){return this._onAny(e,!1)},I.prototype.prependAny=function(e){return this._onAny(e,!0)},I.prototype.addListener=I.prototype.on,I.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},I.prototype._on=function(e,r,n,i){if("function"==typeof e)return this._onAny(e,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||c.call(this);var o,a=this;return i!==t&&(r=(o=A.call(this,e,r,i))[0],a=o[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(E.call(this,e,r,n),a):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(r):this._events[e].push(r),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,d.call(this,this._events[e].length,e))):this._events[e]=r,a)},I.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=S.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var a=0;a<i.length;a++){var s=i[a];if(r=s._listeners,n(r)){for(var l=-1,c=0,u=r.length;c<u;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?s._listeners.splice(l,1):this._events[e].splice(l,1),0===r.length&&(this.wildcard?delete s._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete s._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&x(this.listenerTree),this},I.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},I.prototype.removeListener=I.prototype.off,I.prototype.removeAllListeners=function(e){if(e===t)return!this._events||c.call(this),this;if(this.wildcard){var r,n=S.call(this,null,e,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&x(this.listenerTree)}else this._events&&(this._events[e]=null);return this},I.prototype.listeners=function(e){var r,n,i,o,a,s=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!s)return[];for(o=(r=l(s)).length,i=[];o-- >0;)"function"==typeof(n=s[r[o]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(a=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,c,u,a,0),c}return s&&(n=s[e])?"function"==typeof n?[n]:n:[]},I.prototype.eventNames=function(e){var t=this._events;return this.wildcard?k.call(this,this.listenerTree,[],null,e):t?l(t):[]},I.prototype.listenerCount=function(e){return this.listeners(e).length},I.prototype.hasListeners=function(e){if(this.wildcard){var r=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(e===t?l(i).length:i[e]))},I.prototype.listenersAny=function(){return this._all?this._all:[]},I.prototype.waitFor=function(e,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),w((r=g(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:m})).Promise,(function(t,i,o){function a(){var o=r.filter;if(!o||o.apply(n,arguments))if(n.off(e,a),r.handleError){var s=arguments[0];s?i(s):t(h.apply(null,arguments).slice(1))}else t(h.apply(null,arguments))}o((function(){n.off(e,a)})),n._on(e,a,!1)}),{timeout:r.timeout,overload:r.overload})};var O=I.prototype;Object.defineProperties(I,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");O._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return w((r=g(r,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(r,n,i){var o;if("function"==typeof e.addEventListener)return o=function(){r(h.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var a,s=function(){a&&e.removeListener("error",a),r(h.apply(null,arguments))};"error"!==t&&(a=function(r){e.removeListener(t,s),n(r)},e.once("error",a)),i((function(){a&&e.removeListener("error",a),e.removeListener(t,s)})),e.once(t,s)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=I}()}(Jt)),Jt.exports);function Qt(){if(Wt)return Gt;Wt=1;var e=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)o(Object(arguments[i]),(function(t,r){e[r]=t}));return e},t=function(){if(Object.create)return function(t,r,n,o){var a=i(arguments,1);return e.apply(this,[Object.create(t)].concat(a))};{function t(){}return function(r,n,o,a){var s=i(arguments,1);return t.prototype=r,e.apply(this,[new t].concat(s))}}}(),r=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},n="undefined"!=typeof window?window:Xe;function i(e,t){return Array.prototype.slice.call(e,t||0)}function o(e,t){a(e,(function(e,r){return t(e,r),!1}))}function a(e,t){if(s(e)){for(var r=0;r<e.length;r++)if(t(e[r],r))return e[r]}else for(var n in e)if(e.hasOwnProperty(n)&&t(e[n],n))return e[n]}function s(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}return Gt={assign:e,create:t,trim:r,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:i,each:o,map:function(e,t){var r=s(e)?[]:{};return a(e,(function(e,n){return r[n]=t(e,n),!1})),r},pluck:a,isList:s,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:n},Gt}var Xt,Zt,er=function(){if(Yt)return Vt;Yt=1;var e=Qt(),t=e.slice,r=e.pluck,n=e.each,i=e.bind,o=e.create,a=e.isList,s=e.isFunction,l=e.isObject,c={version:"2.0.12",enabled:!1,get:function(e,t){var r=this.storage.read(this._namespacePrefix+e);return this._deserialize(r,t)},set:function(e,t){return void 0===t?this.remove(e):(this.storage.write(this._namespacePrefix+e,this._serialize(t)),t)},remove:function(e){this.storage.remove(this._namespacePrefix+e)},each:function(e){var t=this;this.storage.each((function(r,n){e.call(t,t._deserialize(r),(n||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return u.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return u(this.storage,this.plugins,e)}};function u(e,u,d){d||(d=""),e&&!a(e)&&(e=[e]),u&&!a(u)&&(u=[u]);var h=d?"__storejs_"+d+"_":"",f=d?new RegExp("^"+h):null;if(!/^[a-zA-Z0-9_\-]*$/.test(d))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var p={_namespacePrefix:h,_namespaceRegexp:f,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var r=e.read(t)===t;return e.remove(t),r}catch(e){return!1}},_assignPluginFnProp:function(e,r){var i=this[r];this[r]=function(){var r=t(arguments,0),o=this;var a=[function(){if(i)return n(arguments,(function(e,t){r[t]=e})),i.apply(o,r)}].concat(r);return e.apply(o,a)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var r="";try{r=JSON.parse(e)}catch(t){r=e}return void 0!==r?r:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(a(e))n(e,(function(e){t._addPlugin(e)}));else if(!r(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!s(e))throw new Error("Plugins must be function values that return objects");var i=e.call(this);if(!l(i))throw new Error("Plugins must return an object of function properties");n(i,(function(r,n){if(!s(r))throw new Error("Bad plugin property: "+n+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(r,n)}))}},addStorage:function(e){!function(){var e="undefined"==typeof console?null:console;e&&(e.warn?e.warn:e.log).apply(e,arguments)}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},g=o(p,c,{plugins:[]});return g.raw={},n(g,(function(e,t){s(e)&&(g.raw[t]=i(g,e))})),n(e,(function(e){g._addStorage(e)})),n(u,(function(e){g._addPlugin(e)})),g}return Vt={createStore:u}}();var tr,rr,nr=function(){if(Zt)return Xt;Zt=1;var e=Qt().Global;function t(){return e.localStorage}function r(e){return t().getItem(e)}return Xt={name:"localStorage",read:r,write:function(e,r){return t().setItem(e,r)},each:function(e){for(var n=t().length-1;n>=0;n--){var i=t().key(n);e(r(i),i)}},remove:function(e){return t().removeItem(e)},clearAll:function(){return t().clear()}},Xt}(),ir=e({__proto__:null,default:nr},[nr]);var or,ar,sr=function(){if(rr)return tr;rr=1;var e=Qt().Global;function t(){return e.sessionStorage}function r(e){return t().getItem(e)}return tr={name:"sessionStorage",read:r,write:function(e,r){return t().setItem(e,r)},each:function(e){for(var n=t().length-1;n>=0;n--){var i=t().key(n);e(r(i),i)}},remove:function(e){return t().removeItem(e)},clearAll:function(){return t().clear()}},tr}(),lr=e({__proto__:null,default:sr},[sr]);var cr,ur,dr=function(){if(ar)return or;ar=1;var e=Qt(),t=e.Global,r=e.trim;or={name:"cookieStorage",read:function(e){if(!e||!a(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(n.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;n.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:i,remove:o,clearAll:function(){i((function(e,t){o(t)}))}};var n=t.document;function i(e){for(var t=n.cookie.split(/; ?/g),i=t.length-1;i>=0;i--)if(r(t[i])){var o=t[i].split("="),a=unescape(o[0]);e(unescape(o[1]),a)}}function o(e){e&&a(e)&&(n.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function a(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(n.cookie)}return or}(),hr=e({__proto__:null,default:dr},[dr]);var fr=function(){if(ur)return cr;ur=1,cr={name:"memoryStorage",read:function(t){return e[t]},write:function(t,r){e[t]=r},each:function(t){for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)},remove:function(t){delete e[t]},clearAll:function(t){e={}}};var e={};return cr}(),pr=e({__proto__:null,default:fr},[fr]);function gr(e,t){void 0===t&&(t=!1),e+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],o=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,a=t?i:n,s=0;s<o.length;s++)r=new RegExp(o[s],"g"),e=e.replace(r,a[s]);return e.replace(t?"٫":".",t?".":"٫")}function mr(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?mr(e.replace(/\.(.+)\./g,".$1")):e}function vr(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function yr(e){if(vr(e))return e;var t=Salla.config.get("store.url");return t||(t=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",t)),t.rtrim("/")+"/"+(null==e?void 0:e.ltrim("/"))}function br(e,t,r){if(r=r||window.location.href,!t||!e)return r;var n=new RegExp("([?&])"+e+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}function wr(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function _r(e){return vr(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):wr("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}function Sr(e,t,r){var n,i=e[0];return r&&0==e.length?Array.isArray(r)?(r.push(t),r):[r,t]:Array.isArray(r)?(r.push(t),r):"string"==typeof r?[r,t]:r?(r[i]=Sr(e.slice(1),t,r[i]),r):i?((n={})[i]=Sr(e.slice(1),t),n):""===i?[t]:t}function Er(){return window.self!==window.top}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(e,t){for(var r,n=this,i=0;i<e.length;i++)r=new RegExp(e[i],"g"),n=n.replace(r,t[i]);return n},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)};var kr={digitsOnly:function(e){return gr(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,r){if(void 0===r&&(r=!1),"string"==typeof t)return document.querySelectorAll(t).forEach((function(t){return e(t,r)}));if(t){var n=Salla.helpers.digitsOnly(t.value);return t.min&&n<parseInt(t.min)?t.value=t.min:t.max&&n>parseInt(t.max)?t.value=t.max:t.maxLength>=1&&n.toString().length>t.maxLength?t.value=n.toString().substring(0,t.maxLength):t.value=r||t.dataset.hasOwnProperty("digitsWithDecimal")?mr(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:gr,money:function(e,t){void 0===t&&(t=!0);var r=Salla.config.currency(null==e?void 0:e.currency).symbol;return e=gr(e="object"==typeof e?e.amount:e)+" "+r,t&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(e=e.replace(r,"<i class=sicon-sar></i>")),e},isIframe:Er,isPreview:function(){return Er()},setNested:function(e,t,r){for(var n=e,i=t.split("."),o=i.length,a=0;a<o-1;a++){var s=i[a];n[s]||(n[s]={}),n=n[s]}return n[i[o-1]]=r,e},getNested:function(e,t,r){var n=bt.default?bt.default(e,t):bt(e,t);return void 0!==n?n:r},inputData:function(e,t,r){if(void 0===r&&(r={}),e.includes("[")){var n=e.split("]").join("").split("["),i=n[0],o=r&&"object"==typeof r?r[i]:void 0;return{name:i,value:Sr(n.slice(1),t,o)}}return{name:e,value:t}},url:Object.freeze({__proto__:null,addParamToUrl:br,api:function(e){var t;return(null===(t=Salla.config.get("store.api",yr("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},asset:_r,base:function(e){return vr(e)?e:"https://"+new URL(yr("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},baseUrl:wr,cdn:function(e,t,r){var n="https://cdn.salla.network/";return(t||r)&&(t=t?",width=".concat(t):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(t).concat(r,",onerror=redirect,format=auto/")),n+(null==e?void 0:e.ltrim("/"))},create:function(e,t){return"custom"===e?t:yr("offers"===e?e:"redirect/".concat(e,"/").concat(t))},domain:function(e){return vr(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},get:yr,is_full_url:vr,is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return _r(salla.config.get("theme.settings.placeholder"))===_r(e)}}),addParamToUrl:br,debounce:function(e,t){t=t||100;var r,n=[];return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return clearTimeout(r),r=setTimeout((function(){var t=e.apply(void 0,i);n.forEach((function(e){return e(t)})),n=[]}),t),new Promise((function(e){return n.push(e)}))}},hasApplePay:function(){var e;try{return!!(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments())}catch(e){return console.error(e),!1}}},xr=function(e,t){return xr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},xr(e,t)},Pr=function(){return Pr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Pr.apply(this,arguments)};function Ar(e,t,r){if(2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var Ir,Or,Tr,jr,Cr=(Ir=console,Or=[],Tr=[],jr={log:function(e,t){if(Ir&&salla.config.isDebug()){Or.push([t,e]),"trace"===salla.config.get("debug")&&(t="trace");var r=Ir.log,n=void 0===t?r:this.__dict__[t]||r,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];Tr.forEach((function(e){i[0]+=e[0],i.push(e[1])}));var o={event:"#CFF680",backend:"#7b68ee"}[t];o&&(i[0]+="%c"+t[0].toUpperCase()+t.substring(1),i.push("margin-left: 5px;color: ".concat(o,";font-weight:bold; border:1px solid ").concat(o,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,Ar([Ir],i.concat.apply(i,e),!1))}},__dict__:{trace:Ir.trace,debug:Ir.debug,info:Ir.info,warn:Ir.warn,error:Ir.error}},{event:function(){jr.log(arguments,"event")},trace:function(){jr.log(arguments,"trace")},debug:function(){jr.log(arguments,"debug")},info:function(){jr.log(arguments,"info")},warn:function(){jr.log(arguments,"warn")},error:function(){jr.log(arguments,"error")},log:function(){jr.log(arguments,void 0)},backend:function(){jr.log(arguments,"backend")},logs:function(e){[e].flat().forEach((function(e){return e&&jr.log([e].flat(),"backend")}))},history:function(){return Or.map((function(e){return Ir.log.apply(Ir,Ar([e[0]],e[1],!1))})),Or},addPrefix:function(e){return Array.isArray(e)?Tr.unshift(e):this.warn("addPrefix receives array only!"),this}}),Rr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=Pr(Pr({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=Pr(Pr({},this.properties_),e),this.properties_.store=Pr(Pr({},(null===(t=this.default_properties)||void 0===t?void 0:t.store)||{}),this.properties_.store),this},e.prototype.set=function(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)},e.prototype.currency=function(e){return void 0===e&&(e=void 0),e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]},e.prototype.get=function(e,t){return void 0===t&&(t=null),e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0},e.prototype.all=function(){return this.properties_},e.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},e}(),Fr=function(e){function t(){var t=this;return(t=e.call(this,{wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1})||this).delimiter="::","undefined"!=typeof document&&(t.body=document.querySelector("body")),t.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],t.ingoreLogEvents=["document::click","document::keyup","document::change"],t.noneFireableActions=["document.request"],t.emittedEvents=new Set,t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}xr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.createAndDispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.dispatch.apply(this,Ar([e],t,!1))},t.prototype.emit=function(t){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.emittedEvents.add(t);var o=t.replace("::",".");if(!this.noneFireableActions.includes(o)&&Salla.call&&"function"==typeof Salla.call(o))return Salla.log("'Salla.".concat(o,"(...)' triggered using event '").concat(t,"'")),o=o.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[o[0]])[o[1]].apply(r,n);e.prototype.emit.apply(this,Ar([t],n,!1)),this.trackEvents.apply(this,Ar([t],n,!1))},t.prototype.onlyWhen=function(e,t){var r=this;return t=t||function(){},new Promise((function(n){return r.emittedEvents.has(e)?n(t()):r.once(e,(function(){return n(t())}))}))},t.prototype.emitAsync=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(t);var i=e.prototype.emitAsync.apply(this,Ar([t],r,!1));try{this.trackEvents.apply(this,Ar([t],r,!1))}catch(e){Salla.logger.warn("error on tracking event (".concat(t,")"),r,e)}return i},t.prototype.trackEvents=function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var i={event:e};r.map((function(e){return"object"==typeof e&&(i=Pr(Pr({},i),e))})),window.dataLayer.push(i)}catch(e){salla.logger.error(e.message)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&(t=Salla.logger).event.apply(t,Ar([e],r,!1)),this.dispatchMobileEvent.apply(this,Ar([e],r,!1))},t.prototype.dispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this.emit.apply(this,Ar([e],t,!1))},t.prototype.dispatchEvents=function(e){if(e)if("object"!=typeof e||Array.isArray(e))Salla.log("Events object is wrong, it should be object of {event:payload}",e);else for(var t=0,r=Object.entries(e);t<r.length;t++){var n=r[t],i=n[0],o=n[1];this.dispatch(i,o)}else Salla.log("No Events To Dispatch!",e)},t.prototype.addListener=function(e,t,r){return this.on(e,t,r)},t.prototype.addEventListener=function(e,t,r){return this.on(e,t,r)},t.prototype.listen=function(e,t){return this.on(e,t)},t.prototype.registerGlobalListener=function(e,t){return this.onAny(t)},t.prototype.dispatchMobileEvent=function(e,t){var r;if(void 0===t&&(t={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:e,details:t})}catch(e){Salla.log(e,"The Flutter context does not exist yet")}}},t}(Kt.EventEmitter2),Lr=er.createStore([ir,lr,hr,pr],[]),Ur=er.createStore([lr],[]),Nr=er.createStore([hr],[]),qr=function(){function e(){var e=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(t){return e.remove(t)})),Salla.event.on("storage::item.set",(function(t,r){return e.set(t,r)})),this.store=Lr,this.session=Ur,this.cookie=Nr}return e.prototype.set=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0],i=((r={})[n]=this.store.get(n),r);return i=Salla.helpers.setNested(i,e,t),this.store.set(n,i[n])}return this.store.set(e,t)},e.prototype.remove=function(e){return this.store.remove(e)},e.prototype.clearAll=function(e){var t=this;if(void 0===e&&(e=!1),e)return this.store.clearAll();this.clearableItems.forEach((function(e){t.store.remove(e)}))},e.prototype.get=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),e)}return this.store.get(e,t)},e.prototype.prefixKey=function(e){return"".concat(e,"_").concat(Salla.config.get("store.id"))},e.prototype.setWithTTL=function(e,t,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var i=this.prefixKey(e),o=(new Date).getTime()+60*r*1e3;return this[n].set(i,{value:t,expiry:o})},e.prototype.getWithTTL=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r="store");var n=this.prefixKey(e),i=this[r].get(n);return i?(new Date).getTime()>i.expiry?(this[r].remove(n),t):i.value:t},e}(),zr=function(){function e(){var e=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(t){return e.remove(t)})),Salla.event.on("cookies::add",(function(t,r){return e.set(t,r)}))}return e.prototype.get=function(e){var t;return null===(t=document.cookie.split("; ").find((function(t){return t.startsWith(e+"=")})))||void 0===t?void 0:t.split("=")[1]},e.prototype.set=function(e,t,r){void 0===t&&(t=""),void 0===r&&(r=10);var n="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),n="; expires="+i.toUTCString()}var o=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=").concat(t).concat(n,"; path=/; SameSite=").concat(o,"; secure"),this},e.prototype.remove=function(e){var t=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=; Max-Age=0; path=/; SameSite=").concat(t,"; secure"),this},e.prototype.clearAll=function(e){return void 0===e&&(e=!1),this.clean(e)},e.prototype.clean=function(e){var t=this;return document.cookie.split(";").map((function(e){return e.split("=")[0].trim()})).filter((function(r){return e||t.keysToRemove.includes(r)||t.dynamicKeysToRemove.some((function(e){return r.startsWith(e)}))})).forEach((function(e){return t.remove(e)})),this},e.prototype.getCookieByPrefix=function(e){return document.cookie.split("; ").map((function(e){return e.split("=")[0]})).filter((function(t){return t.startsWith(e)}))},e.prototype.clearCookieByPrefix=function(e){var t=this;return this.getCookieByPrefix(e).forEach((function(e){return t.remove(e)}))},e}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),void 0!==Qe&&(Qe.salla=Qe.salla||Qe.Salla||{},Qe.Salla=Qe.salla),Salla.status="base",Salla.config=new Rr,Salla.logger=Cr,Salla.event=new Fr,Salla.helpers=kr,Salla.storage=new qr,Salla.cookie=new zr,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.263 - October 9, 2025 12:04:27"};var Dr=Salla;let $r=function(e,t,r){return alert(e)},Mr=function(e,t){return $r(e,Br.error,t)},Br={error:"error",success:"success",info:"info"};var Hr={fire:function(e,t,r){return $r(e,t,r)},setNotifier:function(e){$r=e,salla.event.emit("twilight::notifier.changed")},error:Mr,success:function(e,t){return $r(e,Br.success,t)},info:function(e,t){return $r(e,Br.info,t)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(()=>{e.forEach((e=>{e=decodeURI(e.replace("?danger=","").replace("&danger=",""));let t=document.createElement("div");t.innerText=e,Mr(t.innerHTML),salla.event.emit("twilight::error",e)}))})))},types:Br};class Jr{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,n){return"event"===n?t:"api"===n?e:e&&e[n]||r[n]}})}}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let r=this.getAttribute("data-function");if(r&&window[r])return"function"==typeof window[r]?this.getFilteredData(window[r].call(this,...t)):this.getFilteredData(window[r]);let n=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(n="FORM"===this.tagName?this:n||this.closest("form")||this.closest("[salla-form-data]")||this,n&&"FORM"===n.tagName)return this.getFilteredData(new FormData(n),null,n);let i=n.querySelectorAll("[name]");if(!i.length)return this.getFilteredData();let o=Object.assign({},this.dataset);return i.forEach((e=>{if(!["checkbox","radio"].includes(e.type)||e.checked)try{let t=Salla.helpers.inputData(e.name,e.value,o);o[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(o)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var r=0;r<this.attributes.length;r++){let n=this.attributes[r].name.toLowerCase();if(0===n.indexOf(e))return!t||n}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e=null,t=null,r=null){return e=e||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(e=function(e,t,r){e instanceof FormData?e.append(t,r):e[t]=r;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((n=>{let i=r?.dataset[n]||this.dataset[n];if(i){var o=window[i];if("function"==typeof o){if(!o(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return o(e,r||this,t)}Salla.log("window."+i+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};class Gr{constructor(){this.events={},this.namespace="";let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((e=>{this.createDynamicEventFuns(e),this.createDynamicListenerFuns(e)}))}createDynamicEventFuns(e){if(this[e])return;let t=this;this[e]=function(...r){return t.dispatch(e,...r)}}createDynamicListenerFuns(e){let t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;let r=this;this[t]=function(t){return r.on(e,(async(...e)=>t(...e)))}}getEventName(e){return e=this.events[e]||e||"unknown-event",!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e}dispatch(e,...t){return Salla.event.emitAsync(this.getEventName(e),...t)}on(e,t,r={}){return Salla.event.addListener(this.getEventName(e),t,r)}once(e,t){return Salla.event.once(this.getEventName(e),t)}}function Wr(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends Gr{constructor(){super(),this.namespace="auth",this.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}async loggedIn(e){return Salla.profile.info().finally((()=>this.dispatch("loggedIn",e)))}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends Gr{constructor(){super(),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed",submitting:"submitting"},this.after_init()}updated(e){return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,tax_amount:e.cart.tax_amount,total_discount:e.cart.total_discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:e.cart.free_shipping_bar?.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))}latestFetched(e){return this.updated(e.data),this.dispatch("latestFetched",e)}itemAdded(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)}itemDeleted(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)}itemUpdated(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)}couponAdded(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)}couponDeleted(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)}},Salla.event.order=new class extends Gr{constructor(){super(),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched"},this.after_init()}},Salla.event.scope=new class extends Gr{constructor(){super(),this.namespace="scope",this.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},this.after_init()}},Salla.event.rating=new class extends Gr{constructor(){super(),this.namespace="rating",this.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},this.after_init()}},Salla.event.booking=new class extends Gr{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends Gr{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.landing=new class extends Gr{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.loyalty=new class extends Gr{constructor(){super(),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},this.after_init()}exchangeSucceeded(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)}resetSucceeded(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)}},Salla.event.product=new class extends Gr{constructor(){super(),this.namespace="product",this.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},this.after_init()}},Salla.event.profile=new class extends Gr{constructor(){super(),this.namespace="profile",this.events={updated:"updated",updateFailed:"update.failed",verificationCodeSent:"verification.code.sent",updateContactsFailed:"update.contacts.failed",verified:"verified",unverified:"unverified",infoFetched:"info.fetched",infoNotFetched:"info.not.fetched",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},this.after_init()}},Salla.event.currency=new class extends Gr{constructor(){super(),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}},Salla.event.document=new class extends Gr{constructor(){super(),this.namespace="document",this.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},this.after_init()}onClick(e,t){this.fireCallableFuns("click",e,t)}onChange(e,t){this.fireCallableFuns("change",e,t)}onSubmit(e,t){this.fireCallableFuns("submit",e,t)}onKeyup(e,t){this.fireCallableFuns("keyup",e,t)}fireCallableFuns(e,t,r){this.on(e,(e=>{"function"!=typeof t?"function"==typeof r&&e.target.matches(t)&&r(e):t(e)}))}fireEvent(e,t,...r){return this.fireEventForElements(e,t,!1,...r)}fireEventForAll(e,t,...r){return this.fireEventForElements(e,t,!0,...r)}fireEventForElements(e,t,r,...n){if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...n)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const i=new CustomEvent(t,...n);return e.dispatchEvent(i)}},Salla.event.wishlist=new class extends Gr{constructor(){super(),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}},Salla.event.infiniteScroll=new class extends Gr{constructor(){super(),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}},Salla.event.notifications=new class extends Gr{constructor(){super(),this.namespace="notifications",this.events={fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.component=new class extends Gr{constructor(){super(),this.namespace="component",this.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},this.after_init()}},Salla.event.advertisement=new class extends Gr{constructor(){super(),this.namespace="advertisement",this.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},this.after_init()}},Salla.event.navigation=new class extends Gr{constructor(){super(),this.namespace="navigation",this.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.metadata=new class extends Gr{constructor(){super(),this.namespace="metadata",this.events={valueFetched:"value.fetched",valueNotFetch:"value.not.fetched"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(Wr(e),Object.keys(e).forEach((t=>{Wr(e[t])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:["group","test"].includes(window.location.hostname.split(".").pop())?window.location.origin+"/api/v1/":"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=!1,Salla.config.triedToGetLanguages_=!1,Salla.config.isUser=()=>"user"===Salla.config.get("user.type"),Salla.config.isGuest=()=>!Salla.config.isUser(),Salla.config.languages=async()=>{if(Salla.config.triedToGetLanguages_)return Salla.config.get("languages");Salla.config.triedToGetLanguages_=!0;let e=!0,t=[];return(await salla.document.api.request("languages",null,"get"))?.data?.map((r=>{e&&(t=[],e=!1),r.code=r.code||r.iso_code,r.url=salla.url.get(r.code),r.is_rtl=r.is_rtl||r.rtl,t.push(r)})),Salla.config.set("languages",t),t},Salla.config.currencies=async()=>{if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let e=!0,t={};return(await salla.currency.api.list())?.data?.map((r=>{e&&(t={},e=!1),r.country_code=r.code.substr(0,2).toLowerCase(),t[r.code]=r})),Salla.config.set("currencies",t),t},Salla.config.isMobileApp=()=>["ios","android"].includes(Salla.analytics?.jitsuAnalytics?.getContextProperty("app")?.platform?.toLowerCase());var Vr,Yr={exports:{}},Kr={exports:{}},Qr={exports:{}},Xr=Qr.exports;function Zr(){return Vr||(Vr=1,function(e){!function(t,r){e.exports?e.exports=r():t.EvEmitter=r()}("undefined"!=typeof window?window:Xr,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let r=this._events=this._events||{},n=r[e]=r[e]||[];return n.includes(t)||n.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let r=this._onceEvents=this._onceEvents||{};return(r[e]=r[e]||{})[t]=!0,this},t.off=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;let n=r.indexOf(t);return-1!=n&&r.splice(n,1),this},t.emitEvent=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;r=r.slice(0),t=t||[];let n=this._onceEvents&&this._onceEvents[e];for(let i of r){n&&n[i]&&(this.off(e,i),delete n[i]),i.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(Qr)),Qr.exports}var en,tn,rn={exports:{}},nn=rn.exports;function on(){return en||(en=1,function(e){!function(t,r){e.exports?e.exports=r(t):t.fizzyUIUtils=r(t)}(nn,(function(e){let t={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){if(Array.isArray(e))return e;if(null==e)return[];return"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){let r=e.indexOf(t);-1!=r&&e.splice(r,1)},getParent:function(e,t){for(;e.parentNode&&e!=document.body;)if((e=e.parentNode).matches(t))return e},getQueryElement:function(e){return"string"==typeof e?document.querySelector(e):e},handleEvent:function(e){let t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,r){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!r)return e.push(t),e;t.matches(r)&&e.push(t);let n=t.querySelectorAll(r);return e=e.concat(...n)}),[])},debounceMethod:function(e,t,r){r=r||100;let n=e.prototype[t],i=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[i]);let e=arguments;this[i]=setTimeout((()=>{n.apply(this,e),delete this[i]}),r)}},docReady:function(e){let t=document.readyState;"complete"==t||"interactive"==t?setTimeout(e):document.addEventListener("DOMContentLoaded",e)},toDashed:function(e){return e.replace(/(.)([A-Z])/g,(function(e,t,r){return t+"-"+r})).toLowerCase()}},r=e.console;return t.htmlInit=function(n,i){t.docReady((function(){let o="data-"+t.toDashed(i),a=document.querySelectorAll(`[${o}]`),s=e.jQuery;[...a].forEach((e=>{let t,a=e.getAttribute(o);try{t=a&&JSON.parse(a)}catch(t){return void(r&&r.error(`Error parsing ${o} on ${e.className}: ${t}`))}let l=new n(e,t);s&&s.data(e,i,l)}))}))},t}))}(rn)),rn.exports}function an(){return tn||(tn=1,function(e){!function(t,r){e.exports?e.exports=r(t,Zr(),on()):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let n=e.jQuery,i={};function o(e,t){let a=r.getQueryElement(e);if(a){if((e=a).infiniteScrollGUID){let r=i[e.infiniteScrollGUID];return r.option(t),r}this.element=e,this.options={...o.defaults},this.option(t),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(a||e))}o.defaults={},o.create={},o.destroy={};let a=o.prototype;Object.assign(a,t.prototype);let s=0;a.create=function(){let e=this.guid=++s;if(this.element.infiniteScrollGUID=e,i[e]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let e in o.create)o.create[e].call(this)}else console.error("Disabling InfiniteScroll")},a.option=function(e){Object.assign(this.options,e)},a.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},a.dispatchEvent=function(e,t,r){this.log(e,r);let i=t?[t].concat(r):r;if(this.emitEvent(e,i),!n||!this.$element)return;let o=e+=".infiniteScroll";if(t){let r=n.Event(t);r.type=e,o=r}this.$element.trigger(o,r)};let l={initialized:e=>`on ${e}`,request:e=>`URL: ${e}`,load:(e,t)=>`${e.title||""}. URL: ${t}`,error:(e,t)=>`${e}. URL: ${t}`,append:(e,t,r)=>`${r.length} items. URL: ${t}`,last:(e,t)=>`URL: ${t}`,history:(e,t)=>`URL: ${t}`,pageIndex:function(e,t){return`current page determined to be: ${e} from ${t}`}};a.log=function(e,t){if(!this.options.debug)return;let r=`[InfiniteScroll] ${e}`,n=l[e];n&&(r+=". "+n.apply(this,t)),console.log(r)},a.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},a.updateScroller=function(){let t=this.options.elementScroll;if(t){if(this.scroller=!0===t?this.element:r.getQueryElement(t),!this.scroller)throw new Error(`Unable to find elementScroll: ${t}`)}else this.scroller=e},a.updateGetPath=function(){let e=this.options.path;if(!e)return void console.error(`InfiniteScroll path option required. Set as: ${e}`);let t=typeof e;"function"!=t?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e},a.updateGetPathTemplate=function(e){this.getPath=()=>{let t=this.pageIndex+1;return e.replace("{{#}}",t)};let t=e.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),r=new RegExp(t),n=location.href.match(r);n&&(this.pageIndex=parseInt(n[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=o.getPathParts=function(e){if(e)for(let t of c){let r=e.match(t);if(r){let[,e,t,n]=r;return{begin:e,index:t,end:n}}}};a.updateGetPathSelector=function(e){let t=document.querySelector(e);if(!t)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${e}`);let r=t.getAttribute("href"),n=u(r);if(!n)return void console.error(`InfiniteScroll unable to parse next link href: ${r}`);let{begin:i,index:o,end:a}=n;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+a,this.pageIndex=parseInt(o,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},a.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,r=e.match(/^\?/),n=t.substring(0,t.lastIndexOf("/")),i=r?t:n+"/";this.getAbsolutePath=()=>i+this.getPath()},o.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},o.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},a.destroy=function(){this.allOff();for(let e in o.destroy)o.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},o.throttle=function(e,t){let r,n;return t=t||200,function(){let i=+new Date,o=arguments,a=()=>{r=i,e.apply(this,o)};r&&i<r+t?(clearTimeout(n),n=setTimeout(a,t)):a()}},o.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},o.setJQuery=function(e){n=e},r.htmlInit(o,"infinite-scroll"),a._init=function(){};let{jQueryBridget:d}=e;return n&&d&&d("infiniteScroll",o,n),o}))}(Kr)),Kr.exports}var sn,ln={exports:{}};function cn(){return sn||(sn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an()):r(t,t.InfiniteScroll)}(window,(function(e,t){let r=t.prototype;Object.assign(t.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),t.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},r.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let n=new DOMParser;function i(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return r.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:r}=this.options,i=this.getAbsolutePath();this.isLoading=!0,"function"==typeof r&&(r=r());let o=fetch(i,r).then((r=>{if(!r.ok){let e=new Error(r.statusText);return this.onPageError(e,i,r),{response:r}}return r[e]().then((o=>("text"==e&&t&&(o=n.parseFromString(o,"text/html")),204==r.status?(this.lastPageReached(o,i),{body:o,response:r}):this.onPageLoad(o,i,r))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,o]),o},r.onPageLoad=function(e,t,r){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,r]),this.appendNextPage(e,t,r)},r.appendNextPage=function(e,t,r){let{append:n,responseBody:o,domParseResponse:a}=this.options;if(!("text"==o&&a)||!n)return{body:e,response:r};let s=e.querySelectorAll(n),l={body:e,response:r,items:s};if(!s||!s.length)return this.lastPageReached(e,t),l;let c=i(s),u=()=>(this.appendItems(s,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,s,r]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},r.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),r=e.attributes;for(let e of r)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||i(e)),this.element.appendChild(t))},r.appendOutlayerItems=function(r,n){let i=t.imagesLoaded||e.imagesLoaded;return i?new Promise((function(e){i(r,(function(){let t=n();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},r.onAppendOutlayer=function(e,t,r){this.options.outlayer.appended(r)},r.checkLastPage=function(e,t){let r,{checkLastPage:n,path:i}=this.options;if(n){if("function"==typeof i){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof n?r=n:this.isPathSelector&&(r=i),r&&e.querySelector&&(e.querySelector(r)||this.lastPageReached(e,t))}},r.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},r.onPageError=function(e,t,r){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,r]),e},t.create.prefill=function(){if(!this.options.prefill)return;let e=this.options.append;e?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error(`append option required for prefill. Set as :${e}`)},r.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},r.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},r.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(ln)),ln.exports}var un,dn={exports:{}};function hn(){return un||(un=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;return Object.assign(t.defaults,{scrollThreshold:400}),t.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let e=this.options.scrollThreshold;(e||0===e)&&this.enableScrollWatch()},t.destroy.scrollWatch=function(){this.disableScrollWatch()},n.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},n.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},n.bindScrollWatchEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.pageScrollHandler),e[r]("resize",this.resizeHandler)},n.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),n.getBottomDistance=function(){let t,r;return this.options.elementScroll?(t=this.scroller.scrollHeight,r=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,r=e.scrollY+this.windowHeight),t-r},n.onResize=function(){this.updateMeasurements()},r.debounceMethod(t,"onResize",150),t}))}(dn)),dn.exports}var fn,pn={exports:{}};function gn(){return fn||(fn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;Object.assign(t.defaults,{history:"replace"});let i=document.createElement("a");return t.create.history=function(){if(!this.options.history)return;i.href=this.getAbsolutePath(),(i.origin||i.protocol+"//"+i.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${i.origin} on ${location.origin} . History behavior disabled.`)},n.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},n.bindHistoryAppendEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.scrollHistoryHandler),e[r]("unload",this.unloadHandler)},n.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=n.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},n.onAppendHistory=function(e,t,r){if(!r||!r.length)return;let n=r[0],o=this.getElementScrollY(n);i.href=t,this.scrollPages.push({top:o,path:i.href,title:e.title})},n.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},n.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},r.debounceMethod(t,"onScrollHistory",150),n.getClosestScrollPage=function(){let t,r;t=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:e.scrollY+this.windowHeight/2;for(let e of this.scrollPages){if(e.top>=t)break;r=e}return r},n.setHistory=function(e,t){let r=this.options.history;r&&history[r+"State"]&&(history[r+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},n.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},n.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(pn)),pn.exports}var mn,vn={exports:{}};function yn(){return mn||(mn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){class n{constructor(e,t){this.element=e,this.infScroll=t,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),t.on("request",this.disable.bind(this)),t.on("load",this.enable.bind(this)),t.on("error",this.hide.bind(this)),t.on("last",this.hide.bind(this))}onClick(e){e.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return t.create.button=function(){let e=r.getQueryElement(this.options.button);e&&(this.button=new n(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=n,t}))}(vn)),vn.exports}var bn,wn,_n={exports:{}};function Sn(){return bn||(bn=1,function(e){!function(t,r){e.exports?e.exports=r(t,an(),on()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;function i(e){a(e,"none")}function o(e){a(e,"block")}function a(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=r.getQueryElement(this.options.status);e&&(this.statusElement=e,this.statusEventElements={request:e.querySelector(".infinite-scroll-request"),error:e.querySelector(".infinite-scroll-error"),last:e.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},n.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},n.showRequestStatus=function(){this.showStatus("request")},n.showErrorStatus=function(){this.showStatus("error")},n.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},n.showStatus=function(e){o(this.statusElement),this.hideStatusEventElements(),o(this.statusEventElements[e])},n.hideAllStatus=function(){i(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(let e in this.statusEventElements){i(this.statusEventElements[e])}},t}))}(_n)),_n.exports}
|
|
2
2
|
/*!
|
|
3
3
|
* Infinite Scroll v4.0.1
|
|
4
4
|
* Automatically add next page
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
* @license MIT https://github.com/rmariuzzo/Lang.js/blob/master/LICENSE
|
|
17
17
|
* @site https://github.com/rmariuzzo/Lang.js
|
|
18
18
|
* @author Rubens Mariuzzo <rubens@mariuzzo.com>
|
|
19
|
-
*/var Pn=(kn||(kn=1,function(e,t){e.exports=function(){function e(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}function t(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}var r=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,n=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,i={locale:"en"},o=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return o.prototype.setMessages=function(e){this.messages=e},o.prototype.getLocale=function(){return this.locale||this.fallback},o.prototype.setLocale=function(e){this.locale=e},o.prototype.getFallback=function(){return this.fallback},o.prototype.setFallback=function(e){this.fallback=e},o.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},o.prototype.get=function(e,t,r){if(!this.has(e,r))return e;var n=this._getMessage(e,r);return null===n?e:(t&&(n=this._applyReplacements(n,t)),n)},o.prototype.trans=function(e,t){return this.get(e,t)},o.prototype.choice=function(e,t,r,i){(r=void 0!==r?r:{}).count=t;var o=this.get(e,r,i);if(null==o)return o;for(var a=o.split("|"),s=[],l=0;l<a.length;l++)if(a[l]=a[l].trim(),n.test(a[l])){var c=a[l].split(/\s/);s.push(c.shift()),a[l]=c.join(" ")}if(1===a.length)return o;for(var u=0;u<s.length;u++)if(this._testInterval(t,s[u]))return a[u];return i=i||this._getLocale(e),a[this._getPluralForm(t,i)]},o.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},o.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var r=e.split("."),n=r[0].replace(/\//g,".");return{source:t+"."+n,sourceFallback:this.getFallback()+"."+n,entries:r.slice(1)}},o.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var r=this.messages[e.source],n=e.entries.slice(),i=n.join(".");if("string"!=typeof(r=void 0!==r?this._getValueInKey(r,i):void 0)&&this.messages[e.sourceFallback])for(r=this.messages[e.sourceFallback],n=e.entries.slice(),i="";n.length&&void 0!==r;)r[i=i?i.concat(".",n.shift()):n.shift()]&&(r=r[i],i="");return"string"!=typeof r?null:r},o.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),n=0,i=r.length;n<i;++n){var o=r.slice(0,n+1).join("."),a=r.slice(n+1,r.length).join(".");if(e[o])return this._getValueInKey(e[o],a)}return e},o.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},o.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var r=e.join(".");if(t[r]){t=t[r];break}t=t[e.shift()]}return t},o.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},o.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(r){e=e.replace(new RegExp(":"+r,"gi"),(function(e){var n=t[r];return e===e.toUpperCase()?n.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?n.charAt(0).toUpperCase()+n.slice(1):n}))})),e},o.prototype._testInterval=function(e,n){if("string"!=typeof n)throw"Invalid interval: should be a string.";var i=(n=n.trim()).match(r);if(!i)throw"Invalid interval: "+n;if(!i[2]){var o=(i=i.filter((function(e){return!!e})))[1],a=t(i[2]);a===1/0&&(a=-1/0);var s=t(i[3]),l=i[4];return("["===o?e>=a:e>a)&&("]"===l?e<=s:e<s)}for(var c=i[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},o.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},o}()}(xn)),xn.exports);class An{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t=void 0,r=null){let n=Array.isArray(e),i=n?this.getUrl(...e):this.getUrl(e);e=n?e[0]:e,r=r||this.endpointsMethods[e]||"post";let o=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){let e={};Array.from(t.entries()).forEach((function(t){e[t[0]]=t[1]})),t={params:e}}return o&&"get"===r&&(t=t?Object.assign(t,o):o),this.webEndpoints.includes(e)?i=salla.url.get(i):"http"!==i.substring(0,4)&&(i=salla.url.api(i)),Salla.api.request(i,t,r,{headers:o})}request(e,t=void 0,r=null){return!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,r)):this.normalRequest(e,t,r)}getUrl(e){let t=this.endpoints[e]||e;const r=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(r,arguments[e]);return t}event(){return salla.event[this.className]}}class In extends An{constructor(){super(),this.addToCartTries=0,this.namespace="cart",this._pendingCartIdRequest=null,this.endpoints={latest:"cart/latest",latestApi:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}",giftCartDetails:"cart/{cartId}/buy-as-gift",cartGiftToCart:"cart/{cart_id}/buy-as-gift"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get",giftCartDetails:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",(()=>salla.api.cart.getCurrentCartId(!1,"api::initiated"))),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",(()=>salla.api.cart.getCurrentCartId(!0,"auth::verified")),{async:!0}),salla.event.on("twilight::initiated",(()=>salla.api.cart.syncGuestCart())),salla.event.on("profile::info.fetched",this._checkCurrentCart),salla.event.on("twilight::error",(e=>(e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()))}_checkCurrentCart(){let e=salla.storage.get("cart"),t=salla.config.get("user")?.id,r=salla.config.get("store")?.id;e&&e.id&&(e.user_id===t&&e.store_id===r||(salla.log("cart",{user_id:e.user_id,store_id:e.store_id}),salla.log("current",{user_id:t,store_id:r}),salla.log("Api:: case2 => The cart is not belong to current "+(e.user_id!==t?"user":"store")+"!"),salla.cart.api.reset()),salla.url.is_page("cart")&&e.id!==salla.config.get("page.id")&&(salla.log("cart",{user_id:e.user_id,store_id:e.store_id}),salla.log("current",{user_id:t,store_id:r}),salla.log(`Api:: case2 => The cart is different between storage:${e.id} & session:${salla.config.get("page.id")} !`),salla.cart.api.reset()))}async getCurrentCartId(e=!1,t="getCurrentCartId"){if(Salla.cart.api._pendingCartIdRequest)return Salla.cart.api._pendingCartIdRequest;Salla.cart.api._pendingCartIdRequest=(async()=>{try{if(!e){if(Salla.cart.api.latestCart)return Salla.cart.api.latestCart.cart.id;let e=Salla.storage.get("cart.id");if(e)return e}let r=await Salla.cart.api.latest(t);return Salla.cart.api.latestCart=r.data,Salla.cart.api.latestCart.cart.id}finally{Salla.cart.api._pendingCartIdRequest=null}})();let r=Salla.cart.api._pendingCartIdRequest;return Salla.cart.api._pendingCartIdRequest=null,r}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(e="direct"){return this.request(salla.auth.api.isSessionless()?"latestApi":"latest",{params:{source:"",callerName:e}}).then((e=>(salla.api.cart.set(e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.api.cart.reset(),salla.event.cart.latestFailed(e),e}))}async details(e,t=[]){return e=e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.details"),this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e,t,r){return this.addItem({id:e,quantity:t,offerType:r,endpoint:"quickAdd"})}async addItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no product "id"!';return salla.cart.event.itemAddedFailed(e),salla.api.errorPromise(e)}let r=salla.form.getPossibleValue(t.payload,["endpoint"]);r&&["addItem","quickAdd"].includes(r)||(r=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let n=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addItem");return this.request([r,n,t.id],t.payload).then((function(e){return salla.cart.api.addToCartTries=0,salla.cart.event.itemAdded(e,t.id),e})).catch((function(r){if(!salla.cart.api.addToCartTries)return salla.cart.api.addToCartTries++,salla.cart.reset(),salla.cart.api.addItem(e);throw salla.cart.event.itemAddedFailed(r,t.id),r}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),salla.api.errorPromise(e)}let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteItem");return this.request(["deleteItem",r,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))}async updateItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemUpdatedFailed(e),salla.api.errorPromise(e)}let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.updateItem");return"Object"===t.payload.constructor?.name?t.payload._method="PUT":t.payload.append("_method","PUT"),this.request(["updateItem",r,t.id],t.payload).then((function(e){return salla.cart.event.itemUpdated(e,t.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,t.id),e}))}async deleteImage(e){if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){let e='There is no "id"!';return salla.cart.event.imageNotDeleted(e),salla.api.errorPromise(e)}let t=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteImage");return this.request(["deleteImage",t,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))}async status(e,t=!1){e=e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.status");const r={has_apple_pay:salla.helpers.hasApplePay()};t&&(r.guest_checkout=1);try{await salla.cart.event.submitting()}catch(e){salla.log("Error on: salla.cart.event.submitting()")}return this.request(["status",e],{params:r})}async submit(e=!1){if(console.log("salla.cart.api.submit",{isGuestCheckout:e}),salla.config.isGuest()&&!e)return salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage();this.status(await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.submit"),e).then((e=>{let t=e.data.next_step?.to;if(t||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(e),e}return salla.cart.event.submitted(e),"login"===t?salla.cart.loginOnCartPage():"checkout"===t?window.location.href=e.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(e){salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();let t=404===e?.response?.data?.status;if(t&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit();throw t&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}}normalRequest(e,t=void 0,r=null){return super.normalRequest(e,t,r).catch((async e=>{throw 403===e?.response?.status&&(this.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cookie.clearCookieByPrefix(salla.api.cart.getCartCookiePrefix()),salla.cart.event.successReset()}async addCoupon(e){if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(e),salla.api.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.addCoupon");return this.request(["addCoupon",t],{coupon:e}).then((function(e){let r=salla.storage.get("cart");return r&&e.data?.cart?.coupon&&(r.coupon=e.data.cart.coupon,salla.storage.set("cart",r)),salla.event.cart.couponAdded(e,t),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,t),e}))}async deleteCoupon(){let e=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.deleteCoupon");return this.request(["deleteCoupon",e],{}).then((function(t){let r=salla.storage.get("cart");return r&&r.coupon&&(delete r.coupon,salla.storage.set("cart",r)),salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then((e=>(salla.event.cart.quickOrderSettingFetched(e),e))).catch((e=>{throw salla.event.cart.quickOrderSettingFailed(e),e}))}createQuickOrder(e){return this.request("createQuickOrder",e).then((e=>(salla.event.cart.quickOrderSucceeded(e),e))).catch((e=>{throw salla.event.cart.quickOrderFailed(e),e}))}async priceQuote(e){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open")):this.request(["priceQuote",e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.priceQuote")]).then((e=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((()=>(setTimeout((()=>window.location.href=salla.url.get("/")),1e3),e)))))).catch((e=>salla.event.cart.priceQuoteFailed(e).then((()=>{throw 404===e.error?.code&&window.location.reload(),e}))))}loginOnCartPage(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open",{withoutReload:!0,source:"cart-submit"}),salla.auth.event.onLoggedIn((()=>{salla.event.dispatch("login::close"),salla.cart.submit()}))}set(e){salla.storage.set("cart",e),salla.api.cart.syncGuestCart()}async offers(){const e=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.offers");return this.request(["offers",e]).then((e=>(salla.event.cart.offersFetched(e),e))).catch((e=>{throw salla.event.cart.offersFailed(e),e}))}async getGiftCartDetails(){let e=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.getGiftCartDetails");return this.request(["giftCartDetails",e]).then((t=>(salla.product.event.giftFetched(t,e),t))).catch((t=>{throw salla.product.event.giftFetchFailed(t,e),t}))}async addCartGiftToCart(e,t=!1){let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addCartGiftToCart");return this.request(["cartGiftToCart",r],e).then((e=>(salla.product.event.addGiftToCartSucceeded(e,r),t&&(window.location.href=e.redirect),e))).catch((e=>{throw salla.product.event.addGiftToCartFailed(e,r),e}))}async syncGuestCart(){if(!salla.config.isGuest())return;const e=salla.api.cart.getCartCookiePrefix(),t=salla.cookie.getCookieByPrefix(e),r=salla.storage.get("cart.id");if(!r&&t.length)try{const t=await salla.api.cart.latest(),r=t.data?.cart?.id;r&&salla.api.cart.setCartCookie(e,r)}catch(e){salla.log("Failed to fetch latest cart:",e)}salla.cookie.clearCookieByPrefix(e),r&&(salla.config.set("headers.s-cart-id",r),salla.api.cart.setCartCookie(e,r))}setCartCookie(e,t){salla.cookie.set(`${e}-${t}`,t,1)}getCartCookiePrefix(){return"cart-id-"+salla.config.get("store.id")}}class On extends An{constructor(){super(),this.namespace="loyalty",this.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},this.endpointsMethods={getProgram:"get",reset:"put"},this.after_init()}getProgram(){return this.request("getProgram").then((e=>(salla.loyalty.event.programFetched(e),e))).catch((e=>{throw salla.loyalty.event.programNotFetched(e),e}))}async exchange(e,t=null){if(!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}if(!(t=t||await salla.cart.getCurrentCartId(!1,"salla.api.loyalty.exchange"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}return this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))}async reset(e=null){if(!(e=e||await salla.cart.getCurrentCartId(!1,"salla.api.loyalty.reset"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(e),salla.api.errorPromise(e)}return this.request("reset",{cart_id:e}).then((e=>(salla.loyalty.event.resetSucceeded(e),e))).catch((e=>{throw salla.loyalty.event.resetFailed(e),e}))}}class Tn extends An{constructor(){super(),this.namespace="auth",this.canRedirect_=!0,this.afterLoginEvent={event:null,payload:null},this.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},this.webEndpoints=["logout","auth/jwt","refresh"],this.endpointsMethods={logout:"get"},this.inIframe=salla.helpers.isIframe(),Salla.event.on("twilight::init",(function(){if(Salla.config.isGuest()&&location.href.includes("force_logout"))return delete Salla.api.axios.defaults.headers.common.Authorization,Salla.api.auth.logout("twilight",!1)})),this.after_init()}setAfterLoginEvent(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}}setCanRedirect(e){salla.api.auth.canRedirect_=e}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(e){e?.data&&(e=e.data);let t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){let e="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(e),salla.api.errorPromise(e)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),salla.auth.api.trackBlockedError(e,"login"),e}))}async verify(e,t=!0){let r=salla.form.getPossibleValue(e,["type"]);if(!r){let e="Failed to know what's login type!";return salla.auth.event.verificationFailed(e),salla.api.errorPromise(e)}t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);let n=await salla.auth.api.request(["verify",r],e);return 200!==n?.status?(salla.auth.event.verificationFailed(n,r),salla.api.errorPromise(n)):salla.auth.api.handlAfterAuthenticatedResponse(n,t)}async handlAfterAuthenticatedResponse(e,t){e.data||(e={data:e});let r="authenticated"===e.data?.case;return r&&salla.auth.event.tokenFetched(e.data.token),t&&!this.inIframe&&!this.isSessionless()&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.api.handlAfterAuthenticatedResponse"}),r&&await salla.auth.event.loggedIn(e).then((()=>salla.auth.api.afterUserLogin())),await salla.auth.event.verified(e,e.data.verification.type),salla.api.successPromise(e)}resend(e){let t;return(e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),salla.auth.api.trackBlockedError(t,"resend"),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))}register(e){let t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((async e=>(salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),!this.inIframe&&!this.isSessionless()&&await salla.auth.request("auth/jwt",{callerName:"salla.auth.api.register"}),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e))).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),salla.auth.api.trackBlockedError(e,"register"),e}))}handleIframeReadyAction(e,t){e.contentWindow?.postMessage({source:"logout",type:"init",data:{id:salla.config.get("store.id"),lang:"ar",appUrl:t,apiUrl:salla.config.get("store.api").replace(/\/+$/,""),settings:salla.config.all(),storage:{}}},"*")}appendIframeAndLogout(){return new Promise((e=>{let t=salla.config.get("login.url","https://accounts.salla.com");const r=document.createElement("iframe");r.style.display="none",r.src=`${t}/logout`;const n=i=>{if("login"!==i.data.source)return;let o=i.data.type.replace("iframe::","");if(salla.log("iframe::logout-iframe message received",i.data),["logged-out","ready"].includes(o)){if("ready"===o)return this.handleIframeReadyAction(r,t);window.removeEventListener("message",n),r.remove(),e()}};window.addEventListener("message",n),document.body.appendChild(r)}))}logout(e="twilight",t=!0){return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((()=>this.appendIframeAndLogout())).then((()=>{if(!t)return;let r=salla.url.get(`logout?from=${e}`);console.log(`Going to ${r}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=r}catch(e){salla.log(e)}})).catch((e=>console.error("Error during logout:",e)))}refresh(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}isSessionless(){return"sessionless"===salla.config.get("auth.mode")}trackBlockedError(e,t){blockedByProxy=void 0===e?.response?.headers?.["s-ray"],blockedByProxy&&salla.analytics.track("BlockedByProxy",{class:"auth",function:t,reason:"non-server-request",message:e.message})}}class jn extends An{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},this.endpointsMethods={createCartFromOrder:"get",fetch:"get"},this.after_init()}show(e){let t=salla.form.getPossibleValue(e?.data||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue(e?.data||e,["url"])}cancel(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){let e="There is no id!";return salla.order.event.invoiceNotSent(e),salla.api.errorPromise(e)}return this.request(["sendInvoice",t],e).then((e=>(salla.event.order.invoiceSent(e,t),e))).catch((e=>{throw salla.event.order.invoiceNotSent(e,t),e}))}fetch(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.order.ordersFetched(e),e})).catch((function(e){throw salla.event.order.ordersNotFetched(e),e}))}}class Cn extends An{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftProductDetails:"products/{product_id}/buy-as-gift",productGiftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options"},this.endpointsMethods={details:"get",giftProductDetails:"get",fetch:"get",offers:"get",fetchOptions:"get"},this.after_init()}getPrice(e){let t=e.data||e,r=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",r],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,r),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,r),e}))}categories(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))}availabilitySubscribe(e){let t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}search(e){let t=e.data;if(t||(t={params:"string"==typeof e?{query:e}:e}),!(e=t instanceof FormData?t.get("query"):t.query||t.params?.query)){let e='There is no "query"!';return salla.product.event.searchFailed(e),salla.api.errorPromise(e)}if(e===salla.api.product.previousQuery){let e="Query is same as previous one!";return salla.product.event.searchFailed(e),salla.api.product.previousQuery=null,salla.api.errorPromise(e)}return salla.api.product.previousQuery=e,this.request("search",t,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))}offers(e){if(!(e=salla.form.getPossibleValue(e?.data|e,["product_id","id"]))){let e='There is no "product_id"!';return salla.product.event.fetchOffersFailed(e),salla.api.errorPromise(e)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))}getSizeGuides(e){return this.request(`products/${e}/size-guides`,null,"get").then((t=>(salla.product.event.sizeGuideFetched(t,e),t))).catch((t=>{throw salla.product.event.sizeGuideFetchFailed(t,e),t}))}getGiftProductDetails(e){return this.request(["giftProductDetails",e]).then((t=>(salla.product.event.giftFetched(t,e),t))).catch((t=>{throw salla.product.event.giftFetchFailed(t,e),t}))}getDetails(e,t=[]){if(!Array.isArray(t)){let e="withItems should be array.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}if(!e){let e="productId is not passed.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}addProductGiftToCart(e,t,r=!1){return this.request(["productGiftToCart",e],t).then((t=>(salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),t))).catch((t=>{throw salla.product.event.addGiftToCartFailed(t,e),t}))}uploadGiftImage(e){return this.request("giftImage",e).then((e=>(salla.product.event.giftImageUploadSucceeded(e),e))).catch((e=>{throw salla.product.event.giftImageUploadFailed(e),e}))}fetch(e){if(!e.source){const e="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}const t=!e.source_value,r="string"==typeof e.source_value&&"[]"===e.source_value,n=Array.isArray(e.source_value)&&!e.source_value.length;if((t||r||n)&&!["offers","latest","sales","wishlist","top-rated"].includes(e.source)){const e="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){const e="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("search"===e.source&&"string"!=typeof e.source_value){const e="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("related"===e.source&&isNaN(e.source_value)){const e="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}return this.request(this.endpoints.fetch,{params:e},"get").then((async e=>(salla.product.event.productListFetchSucceeded(e),e))).catch((e=>{throw salla.product.event.productListFetchFailed(e),e}))}fetchOptions(e,t={}){if(!e||0===e.length){const e="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(e),salla.api.errorPromise(e)}const{with:r=[]}=t,n={selected:e};return r.length>0&&(n.with=r),this.request(this.endpoints.fetchOptions,{params:n},"get").then((e=>(salla.product.event.productOptionsFetched(e),e))).catch((e=>{throw salla.product.event.productOptionsNotFetched(e),e}))}}class Rn extends An{constructor(){super(),this.namespace="profile",this.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},this.endpointsMethods={delete:"delete"},this.after_init()}syncUserData(e){let t={id:e.id,type:"user",email:e.email,mobile:e.phone.code+e.phone.number,country_code:e.phone.country,language_code:e.language,currency_code:e.currency,notifications:e.notifications,pending_orders:e.pending_orders,avatar:e.avatar,first_name:e.first_name,last_name:e.last_name,is_hidden_name:e.is_hidden_name,is_notifiable:e.is_notifiable,can_comment:salla.config.get("user.can_comment"),fetched_at:Date.now()};salla.config.set("user",t),salla.storage.set("user",t)}info(){return this.request("info",null,"get").then((e=>(this.syncUserData(e.data),salla.profile.event.infoFetched(e),e))).catch((e=>{throw salla.profile.event.infoNotFetched(e),e}))}update(e){if(Salla.config.get("store.features",[]).includes("sso-login")){const e="SSO login is enabled. You cannot update your profile.";return Salla.error(e),Promise.reject(new Error(e))}return this.request("update",e).then((e=>(this.syncUserData(e.data),salla.profile.event.updated(e),e))).catch((e=>{throw salla.event.profile.updateFailed(e),e}))}updateContacts(e){return this.request("updateContacts",e).then((e=>(salla.profile.event.verificationCodeSent(e),e))).catch((e=>{throw salla.event.profile.updateContactsFailed(e),e}))}verify(e){return this.request("verify",e).then((e=>(salla.profile.event.verified(e),e))).catch((e=>{throw salla.event.profile.unverified(e),e}))}updateSettings(e){return this.request("updateSettings",e).then((e=>(salla.event.profile.settingsUpdated(e),e))).catch((e=>{throw salla.event.profile.updateSettingsFailed(e),e}))}delete(){return this.request("delete").then((e=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.api.appendIframeAndLogout().then((()=>{salla.event.profile.deleted(e),window.location.href=salla.url.get("logout")})),e))).catch((e=>{throw salla.event.profile.notDeleted(e),e}))}}class Fn extends An{constructor(){super(),this.namespace="comment",this.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},this.after_init()}add(e){if(e?.data&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,!0)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){let e="can't find comment content!";return salla.event.comment.additionFailed(e),salla.api.errorPromise(e)}return this.request(["addComment","blog"==e.type?"blogs":e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))}getCommentPayload(e,t=!1){let r={};if(["id","type","comment","per_page","page","sort"].forEach((t=>{let n=salla.form.getPossibleValue(e,[t]);n&&(r[t]=n)})),!t){let t=e.ids;if(t&&(r.ids=Array.isArray(t)?t:[t]),!r.ids||!r.ids.length)return"Failed to get ids!"}return r.type&&["products","pages","product","page","blogs","blog"].includes(r.type)?(r.type+=["product","page"].includes(r.type)?"s":"",r):"Failed to get type one of:(products, product, page, pages, blog, blogs)!"}fetchComments(e){if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);const t={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(t.sort=e.sort),this.request(["comments"],{params:t},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))}getComments(e,t,r=1,n=5,i){const o=Array.isArray(t)?t:[t];return this.fetchComments({ids:o,type:`${e}s`,page:r,per_page:n,sort:i})}}class Ln extends An{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){let e="Can't find currency code!";return salla.currency.event.failed(e),salla.api.errorPromise(e)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))}list(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))}}class Un extends An{constructor(){super(),this.namespace="document"}reload(){window.location.reload()}}class Nn extends An{constructor(){super(),this.namespace="rating",this.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},this.endpointsMethods={order:"get"},this.after_init()}order(e){let t="object"==typeof e?e:{},r=salla.form.getPossibleValue(e?.data||e,["order_id","id"]);if(!r){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),salla.api.errorPromise(e)}return this.request(["order",r],t).then((function(e){return salla.event.rating.orderFetched(e,r),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,r),e}))}store(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.storeFailed(e),salla.api.errorPromise(e)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))}products(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.productsFailed(e),salla.api.errorPromise(e)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))}shipping(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.shippingFailed(e),salla.api.errorPromise(e)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))}}class qn extends An{constructor(){super(),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},Salla.onReady((()=>{"customer.wishlist"===Salla.config.get("page.slug")&&(Salla.storage.getWithTTL("s-utms")?.["s-utm-source"]||this.injectSourceIntoRequest())}))}injectSourceIntoRequest(){Salla.api.axios.interceptors.request.use((e=>(e.headers={...e.headers,"s-utm-source":"wishlist"},e)),(e=>Promise.reject(e)))}toggle(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)}add(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["add",e]).then((t=>(this.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t))).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(t="Failed to get product id!"),salla.api.errorPromise(t))}remove(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["remove",e]).then((t=>(this.updateWishlistStorage(e,!1),salla.wishlist.event.removed(t,e),t))).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(t="Failed to get id!"),salla.api.errorPromise(t))}updateWishlistStorage(e,t=!0){let r=salla.storage.get("salla::wishlist",[]);t?r.push(e):r.splice(r.indexOf(e),1),salla.storage.set("salla::wishlist",r)}}class zn extends An{constructor(){super(),this.namespace="scopes",this.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},this.after_init()}get(){return this.request("scopes",null,"get").then((e=>(salla.scope.event.fetched(e),e))).catch((e=>{throw salla.scope.event.notFetched(e),e}))}change(e){return this.request("scopes",e).then((e=>(salla.scope.event.changeSucceeded(e),e))).catch((e=>{throw salla.scope.event.changeFailed(e),e}))}getProductAvailability(e=null){return this.request(`scopes/availability?product_id=${e}`,null,"get").then((t=>(salla.scope.event.productAvailabilityFetched(t,e),t))).catch((e=>{throw salla.scope.event.productAvailabilityNotFetched(e),e}))}}class Dn extends An{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(e,t=!0){if(!e){let e="Please provide product id.";return salla.booking.event.additionFailed(e),salla.api.errorPromise(e)}return this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))}}class $n extends An{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},this.endpointsMethods={getDetails:"get",breadcrumbs:"get"},this.after_init()}getDetails(e){if(!e){let e="page landing id not passed";return salla.event.landing.getDetailsFailed(e),salla.api.errorPromise(e)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))}createCartFromPage(e){if(!e){let e="page landing id not passed";return salla.event.landing.orderCreationFailed(e),salla.api.errorPromise(e)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((()=>location.href=t.data.url)),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if("product.single"===e.page&&!e.id&&!e.parent_id){let e="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.landing.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e}))}}class Mn extends An{constructor(){super(),this.namespace="notifications",this.endpoints={fetch:"notifications"},this.endpointsMethods={fetch:"get"},this.after_init()}fetch(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.notifications.fetched(e),e})).catch((function(e){throw salla.event.notifications.fetchFailed(e),e}))}}function Bn(e,t){return function(){return e.apply(t,arguments)}}const{toString:Hn}=Object.prototype,{getPrototypeOf:Jn}=Object,{iterator:Gn,toStringTag:Wn}=Symbol,Vn=(Yn=Object.create(null),e=>{const t=Hn.call(e);return Yn[t]||(Yn[t]=t.slice(8,-1).toLowerCase())});var Yn;const Kn=e=>(e=e.toLowerCase(),t=>Vn(t)===e),Qn=e=>t=>typeof t===e,{isArray:Xn}=Array,Zn=Qn("undefined");const ei=Kn("ArrayBuffer");const ti=Qn("string"),ri=Qn("function"),ni=Qn("number"),ii=e=>null!==e&&"object"==typeof e,oi=e=>{if("object"!==Vn(e))return!1;const t=Jn(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Wn in e||Gn in e)},ai=Kn("Date"),si=Kn("File"),li=Kn("Blob"),ci=Kn("FileList"),ui=Kn("URLSearchParams"),[di,hi,fi,pi]=["ReadableStream","Request","Response","Headers"].map(Kn);function gi(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),Xn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let a;for(n=0;n<o;n++)a=i[n],t.call(null,e[a],a,e)}}function mi(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const vi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Qe,yi=e=>!Zn(e)&&e!==vi;const bi=(wi="undefined"!=typeof Uint8Array&&Jn(Uint8Array),e=>wi&&e instanceof wi);var wi;const _i=Kn("HTMLFormElement"),Si=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Ei=Kn("RegExp"),ki=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};gi(r,((r,i)=>{let o;!1!==(o=t(r,i,e))&&(n[i]=o||r)})),Object.defineProperties(e,n)};const xi=Kn("AsyncFunction"),Pi=(Ai="function"==typeof setImmediate,Ii=ri(vi.postMessage),Ai?setImmediate:Ii?(Oi=`axios@${Math.random()}`,Ti=[],vi.addEventListener("message",(({source:e,data:t})=>{e===vi&&t===Oi&&Ti.length&&Ti.shift()()}),!1),e=>{Ti.push(e),vi.postMessage(Oi,"*")}):e=>setTimeout(e));var Ai,Ii,Oi,Ti;const ji="undefined"!=typeof queueMicrotask?queueMicrotask.bind(vi):void 0!==Ht&&Ht.nextTick||Pi;var Ci={isArray:Xn,isArrayBuffer:ei,isBuffer:function(e){return null!==e&&!Zn(e)&&null!==e.constructor&&!Zn(e.constructor)&&ri(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||ri(e.append)&&("formdata"===(t=Vn(e))||"object"===t&&ri(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&ei(e.buffer),t},isString:ti,isNumber:ni,isBoolean:e=>!0===e||!1===e,isObject:ii,isPlainObject:oi,isReadableStream:di,isRequest:hi,isResponse:fi,isHeaders:pi,isUndefined:Zn,isDate:ai,isFile:si,isBlob:li,isRegExp:Ei,isFunction:ri,isStream:e=>ii(e)&&ri(e.pipe),isURLSearchParams:ui,isTypedArray:bi,isFileList:ci,forEach:gi,merge:function e(){const{caseless:t}=yi(this)&&this||{},r={},n=(n,i)=>{const o=t&&mi(r,i)||i;oi(r[o])&&oi(n)?r[o]=e(r[o],n):oi(n)?r[o]=e({},n):Xn(n)?r[o]=n.slice():r[o]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&gi(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(gi(t,((t,n)=>{r&&ri(t)?e[n]=Bn(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,o,a;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)a=i[o],n&&!n(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==r&&Jn(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:Vn,kindOfTest:Kn,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(Xn(e))return e;let t=e.length;if(!ni(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Gn]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:_i,hasOwnProperty:Si,hasOwnProp:Si,reduceDescriptors:ki,freezeMethods:e=>{ki(e,((t,r)=>{if(ri(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];ri(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return Xn(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:mi,global:vi,isContextDefined:yi,isSpecCompliantForm:function(e){return!!(e&&ri(e.append)&&"FormData"===e[Wn]&&e[Gn])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(ii(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=Xn(e)?[]:{};return gi(e,((e,t)=>{const o=r(e,n+1);!Zn(o)&&(i[t]=o)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:xi,isThenable:e=>e&&(ii(e)||ri(e))&&ri(e.then)&&ri(e.catch),setImmediate:Pi,asap:ji,isIterable:e=>null!=e&&ri(e[Gn])},Ri=[],Fi=[],Li="undefined"!=typeof Uint8Array?Uint8Array:Array,Ui=!1;function Ni(){Ui=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Ri[t]=e[t],Fi[e.charCodeAt(t)]=t;Fi["-".charCodeAt(0)]=62,Fi["_".charCodeAt(0)]=63}function qi(e,t,r){for(var n,i,o=[],a=t;a<r;a+=3)n=(e[a]<<16)+(e[a+1]<<8)+e[a+2],o.push(Ri[(i=n)>>18&63]+Ri[i>>12&63]+Ri[i>>6&63]+Ri[63&i]);return o.join("")}function zi(e){var t;Ui||Ni();for(var r=e.length,n=r%3,i="",o=[],a=16383,s=0,l=r-n;s<l;s+=a)o.push(qi(e,s,s+a>l?l:s+a));return 1===n?(t=e[r-1],i+=Ri[t>>2],i+=Ri[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Ri[t>>10],i+=Ri[t>>4&63],i+=Ri[t<<2&63],i+="="),o.push(i),o.join("")}function Di(e,t,r,n,i){var o,a,s=8*i-n-1,l=(1<<s)-1,c=l>>1,u=-7,d=r?i-1:0,h=r?-1:1,f=e[t+d];for(d+=h,o=f&(1<<-u)-1,f>>=-u,u+=s;u>0;o=256*o+e[t+d],d+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=n;u>0;a=256*a+e[t+d],d+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),o-=c}return(f?-1:1)*a*Math.pow(2,o-n)}function $i(e,t,r,n,i,o){var a,s,l,c=8*o-i-1,u=(1<<c)-1,d=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?h/l:h*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&s,f+=p,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;e[r+f]=255&a,f+=p,a/=256,c-=8);e[r+f-p]|=128*g}var Mi={}.toString,Bi=Array.isArray||function(e){return"[object Array]"==Mi.call(e)};function Hi(){return Gi.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ji(e,t){if(Hi()<t)throw new RangeError("Invalid typed array length");return Gi.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Gi.prototype:(null===e&&(e=new Gi(t)),e.length=t),e}function Gi(e,t,r){if(!(Gi.TYPED_ARRAY_SUPPORT||this instanceof Gi))return new Gi(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Yi(this,e)}return Wi(this,e,t,r)}function Wi(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);Gi.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Gi.prototype:e=Ki(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!Gi.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Zi(t,r);e=Ji(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(Xi(t)){var r=0|Qi(t.length);return 0===(e=Ji(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?Ji(e,0):Ki(e,t);if("Buffer"===t.type&&Bi(t.data))return Ki(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Vi(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Yi(e,t){if(Vi(t),e=Ji(e,t<0?0:0|Qi(t)),!Gi.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function Ki(e,t){var r=t.length<0?0:0|Qi(t.length);e=Ji(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function Qi(e){if(e>=Hi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Hi().toString(16)+" bytes");return 0|e}function Xi(e){return!(null==e||!e._isBuffer)}function Zi(e,t){if(Xi(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Ao(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Io(e).length;default:if(n)return Ao(e).length;t=(""+t).toLowerCase(),n=!0}}function eo(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return mo(this,t,r);case"utf8":case"utf-8":return ho(this,t,r);case"ascii":return po(this,t,r);case"latin1":case"binary":return go(this,t,r);case"base64":return uo(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vo(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function to(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function ro(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=Gi.from(t,n)),Xi(t))return 0===t.length?-1:no(e,t,r,n,i);if("number"==typeof t)return t&=255,Gi.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):no(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function no(e,t,r,n,i){var o,a=1,s=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var u=-1;for(o=r;o<s;o++)if(c(e,o)===c(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===l)return u*a}else-1!==u&&(o-=o-u),u=-1}else for(r+l>s&&(r=s-l),o=r;o>=0;o--){for(var d=!0,h=0;h<l;h++)if(c(e,o+h)!==c(t,h)){d=!1;break}if(d)return o}return-1}function io(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[r+a]=s}return a}function oo(e,t,r,n){return Oo(Ao(t,e.length-r),e,r,n)}function ao(e,t,r,n){return Oo(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function so(e,t,r,n){return ao(e,t,r,n)}function lo(e,t,r,n){return Oo(Io(t),e,r,n)}function co(e,t,r,n){return Oo(function(e,t){for(var r,n,i,o=[],a=0;a<e.length&&!((t-=2)<0);++a)n=(r=e.charCodeAt(a))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function uo(e,t,r){return 0===t&&r===e.length?zi(e):zi(e.slice(t,r))}function ho(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,a,s,l,c=e[i],u=null,d=c>239?4:c>223?3:c>191?2:1;if(i+d<=r)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(o=e[i+1]))&&(l=(31&c)<<6|63&o)>127&&(u=l);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(l=(15&c)<<12|(63&o)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=d}return function(e){var t=e.length;if(t<=fo)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=fo));return r}(n)}Gi.TYPED_ARRAY_SUPPORT=void 0===Qe.TYPED_ARRAY_SUPPORT||Qe.TYPED_ARRAY_SUPPORT,Hi(),Gi.poolSize=8192,Gi._augment=function(e){return e.__proto__=Gi.prototype,e},Gi.from=function(e,t,r){return Wi(null,e,t,r)},Gi.TYPED_ARRAY_SUPPORT&&(Gi.prototype.__proto__=Uint8Array.prototype,Gi.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Gi[Symbol.species]),Gi.alloc=function(e,t,r){return function(e,t,r,n){return Vi(t),t<=0?Ji(e,t):void 0!==r?"string"==typeof n?Ji(e,t).fill(r,n):Ji(e,t).fill(r):Ji(e,t)}(null,e,t,r)},Gi.allocUnsafe=function(e){return Yi(null,e)},Gi.allocUnsafeSlow=function(e){return Yi(null,e)},Gi.isBuffer=function(e){return null!=e&&(!!e._isBuffer||To(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&To(e.slice(0,0))}(e))},Gi.compare=function(e,t){if(!Xi(e)||!Xi(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},Gi.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Gi.concat=function(e,t){if(!Bi(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Gi.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=Gi.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!Xi(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},Gi.byteLength=Zi,Gi.prototype._isBuffer=!0,Gi.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)to(this,t,t+1);return this},Gi.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)to(this,t,t+3),to(this,t+1,t+2);return this},Gi.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)to(this,t,t+7),to(this,t+1,t+6),to(this,t+2,t+5),to(this,t+3,t+4);return this},Gi.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?ho(this,0,e):eo.apply(this,arguments)},Gi.prototype.equals=function(e){if(!Xi(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Gi.compare(this,e)},Gi.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Gi.prototype.compare=function(e,t,r,n,i){if(!Xi(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),l=this.slice(n,i),c=e.slice(t,r),u=0;u<s;++u)if(l[u]!==c[u]){o=l[u],a=c[u];break}return o<a?-1:a<o?1:0},Gi.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},Gi.prototype.indexOf=function(e,t,r){return ro(this,e,t,r,!0)},Gi.prototype.lastIndexOf=function(e,t,r){return ro(this,e,t,r,!1)},Gi.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return io(this,e,t,r);case"utf8":case"utf-8":return oo(this,e,t,r);case"ascii":return ao(this,e,t,r);case"latin1":case"binary":return so(this,e,t,r);case"base64":return lo(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return co(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Gi.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var fo=4096;function po(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function go(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function mo(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=Po(e[o]);return i}function vo(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function yo(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function bo(e,t,r,n,i,o){if(!Xi(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function wo(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function _o(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function So(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Eo(e,t,r,n,i){return i||So(e,0,r,4),$i(e,t,r,n,23,4),r+4}function ko(e,t,r,n,i){return i||So(e,0,r,8),$i(e,t,r,n,52,8),r+8}Gi.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),Gi.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=Gi.prototype;else{var i=t-e;r=new Gi(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},Gi.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},Gi.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},Gi.prototype.readUInt8=function(e,t){return t||yo(e,1,this.length),this[e]},Gi.prototype.readUInt16LE=function(e,t){return t||yo(e,2,this.length),this[e]|this[e+1]<<8},Gi.prototype.readUInt16BE=function(e,t){return t||yo(e,2,this.length),this[e]<<8|this[e+1]},Gi.prototype.readUInt32LE=function(e,t){return t||yo(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Gi.prototype.readUInt32BE=function(e,t){return t||yo(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Gi.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},Gi.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Gi.prototype.readInt8=function(e,t){return t||yo(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Gi.prototype.readInt16LE=function(e,t){t||yo(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Gi.prototype.readInt16BE=function(e,t){t||yo(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Gi.prototype.readInt32LE=function(e,t){return t||yo(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Gi.prototype.readInt32BE=function(e,t){return t||yo(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Gi.prototype.readFloatLE=function(e,t){return t||yo(e,4,this.length),Di(this,e,!0,23,4)},Gi.prototype.readFloatBE=function(e,t){return t||yo(e,4,this.length),Di(this,e,!1,23,4)},Gi.prototype.readDoubleLE=function(e,t){return t||yo(e,8,this.length),Di(this,e,!0,52,8)},Gi.prototype.readDoubleBE=function(e,t){return t||yo(e,8,this.length),Di(this,e,!1,52,8)},Gi.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||bo(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},Gi.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||bo(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},Gi.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,1,255,0),Gi.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Gi.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,65535,0),Gi.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):wo(this,e,t,!0),t+2},Gi.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,65535,0),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):wo(this,e,t,!1),t+2},Gi.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,4294967295,0),Gi.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):_o(this,e,t,!0),t+4},Gi.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,4294967295,0),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_o(this,e,t,!1),t+4},Gi.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);bo(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o<r&&(a*=256);)e<0&&0===s&&0!==this[t+o-1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},Gi.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);bo(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},Gi.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,1,127,-128),Gi.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Gi.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,32767,-32768),Gi.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):wo(this,e,t,!0),t+2},Gi.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,32767,-32768),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):wo(this,e,t,!1),t+2},Gi.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,2147483647,-2147483648),Gi.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):_o(this,e,t,!0),t+4},Gi.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_o(this,e,t,!1),t+4},Gi.prototype.writeFloatLE=function(e,t,r){return Eo(this,e,t,!0,r)},Gi.prototype.writeFloatBE=function(e,t,r){return Eo(this,e,t,!1,r)},Gi.prototype.writeDoubleLE=function(e,t,r){return ko(this,e,t,!0,r)},Gi.prototype.writeDoubleBE=function(e,t,r){return ko(this,e,t,!1,r)},Gi.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!Gi.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},Gi.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Gi.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var a=Xi(e)?e:Ao(new Gi(e,n).toString()),s=a.length;for(o=0;o<r-t;++o)this[o+t]=a[o%s]}return this};var xo=/[^+\/0-9A-Za-z-_]/g;function Po(e){return e<16?"0"+e.toString(16):e.toString(16)}function Ao(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Io(e){return function(e){var t,r,n,i,o,a;Ui||Ni();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[s-2]?2:"="===e[s-1]?1:0,a=new Li(3*s/4-o),n=o>0?s-4:s;var l=0;for(t=0,r=0;t<n;t+=4,r+=3)i=Fi[e.charCodeAt(t)]<<18|Fi[e.charCodeAt(t+1)]<<12|Fi[e.charCodeAt(t+2)]<<6|Fi[e.charCodeAt(t+3)],a[l++]=i>>16&255,a[l++]=i>>8&255,a[l++]=255&i;return 2===o?(i=Fi[e.charCodeAt(t)]<<2|Fi[e.charCodeAt(t+1)]>>4,a[l++]=255&i):1===o&&(i=Fi[e.charCodeAt(t)]<<10|Fi[e.charCodeAt(t+1)]<<4|Fi[e.charCodeAt(t+2)]>>2,a[l++]=i>>8&255,a[l++]=255&i),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(xo,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Oo(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function To(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function jo(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Ci.inherits(jo,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ci.toJSONObject(this.config),code:this.code,status:this.status}}});const Co=jo.prototype,Ro={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Ro[e]={value:e}})),Object.defineProperties(jo,Ro),Object.defineProperty(Co,"isAxiosError",{value:!0}),jo.from=(e,t,r,n,i,o)=>{const a=Object.create(Co);return Ci.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),jo.call(a,e.message,t,r,n,i),a.cause=e,a.name=e.name,o&&Object.assign(a,o),a};function Fo(e){return Ci.isPlainObject(e)||Ci.isArray(e)}function Lo(e){return Ci.endsWith(e,"[]")?e.slice(0,-2):e}function Uo(e,t,r){return e?e.concat(t).map((function(e,t){return e=Lo(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const No=Ci.toFlatObject(Ci,{},null,(function(e){return/^is[A-Z]/.test(e)}));function qo(e,t,r){if(!Ci.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=Ci.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Ci.isUndefined(t[e])}))).metaTokens,i=r.visitor||c,o=r.dots,a=r.indexes,s=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Ci.isSpecCompliantForm(t);if(!Ci.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ci.isDate(e))return e.toISOString();if(Ci.isBoolean(e))return e.toString();if(!s&&Ci.isBlob(e))throw new jo("Blob is not supported. Use a Buffer instead.");return Ci.isArrayBuffer(e)||Ci.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Gi.from(e):e}function c(e,r,i){let s=e;if(e&&!i&&"object"==typeof e)if(Ci.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(Ci.isArray(e)&&function(e){return Ci.isArray(e)&&!e.some(Fo)}(e)||(Ci.isFileList(e)||Ci.endsWith(r,"[]"))&&(s=Ci.toArray(e)))return r=Lo(r),s.forEach((function(e,n){!Ci.isUndefined(e)&&null!==e&&t.append(!0===a?Uo([r],n,o):null===a?r:r+"[]",l(e))})),!1;return!!Fo(e)||(t.append(Uo(i,r,o),l(e)),!1)}const u=[],d=Object.assign(No,{defaultVisitor:c,convertValue:l,isVisitable:Fo});if(!Ci.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!Ci.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),Ci.forEach(r,(function(r,o){!0===(!(Ci.isUndefined(r)||null===r)&&i.call(t,r,Ci.isString(o)?o.trim():o,n,d))&&e(r,n?n.concat(o):[o])})),u.pop()}}(e),t}function zo(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Do(e,t){this._pairs=[],e&&qo(e,this,t)}const $o=Do.prototype;function Mo(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Bo(e,t,r){if(!t)return e;const n=r&&r.encode||Mo;Ci.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let o;if(o=i?i(t,r):Ci.isURLSearchParams(t)?t.toString():new Do(t,r).toString(n),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}$o.append=function(e,t){this._pairs.push([e,t])},$o.toString=function(e){const t=e?function(t){return e.call(this,t,zo)}:zo;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class Ho{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ci.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var Jo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Go={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Do,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Wo="undefined"!=typeof window&&"undefined"!=typeof document,Vo="object"==typeof navigator&&navigator||void 0,Yo=Wo&&(!Vo||["ReactNative","NativeScript","NS"].indexOf(Vo.product)<0),Ko="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Qo=Wo&&window.location.href||"http://localhost";var Xo={...Object.freeze({__proto__:null,hasBrowserEnv:Wo,hasStandardBrowserEnv:Yo,hasStandardBrowserWebWorkerEnv:Ko,navigator:Vo,origin:Qo}),...Go};function Zo(e){function t(e,r,n,i){let o=e[i++];if("__proto__"===o)return!0;const a=Number.isFinite(+o),s=i>=e.length;if(o=!o&&Ci.isArray(n)?n.length:o,s)return Ci.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!a;n[o]&&Ci.isObject(n[o])||(n[o]=[]);return t(e,r,n[o],i)&&Ci.isArray(n[o])&&(n[o]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}(n[o])),!a}if(Ci.isFormData(e)&&Ci.isFunction(e.entries)){const r={};return Ci.forEachEntry(e,((e,n)=>{t(function(e){return Ci.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const ea={transitional:Jo,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=Ci.isObject(e);i&&Ci.isHTMLForm(e)&&(e=new FormData(e));if(Ci.isFormData(e))return n?JSON.stringify(Zo(e)):e;if(Ci.isArrayBuffer(e)||Ci.isBuffer(e)||Ci.isStream(e)||Ci.isFile(e)||Ci.isBlob(e)||Ci.isReadableStream(e))return e;if(Ci.isArrayBufferView(e))return e.buffer;if(Ci.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return qo(e,new Xo.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return Xo.isNode&&Ci.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=Ci.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return qo(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(Ci.isString(e))try{return(t||JSON.parse)(e),Ci.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ea.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Ci.isResponse(e)||Ci.isReadableStream(e))return e;if(e&&Ci.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw jo.from(e,jo.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Xo.classes.FormData,Blob:Xo.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ci.forEach(["delete","get","head","post","put","patch"],(e=>{ea.headers[e]={}}));const ta=Ci.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const ra=Symbol("internals");function na(e){return e&&String(e).trim().toLowerCase()}function ia(e){return!1===e||null==e?e:Ci.isArray(e)?e.map(ia):String(e)}function oa(e,t,r,n,i){return Ci.isFunction(n)?n.call(this,t,r):(i&&(t=r),Ci.isString(t)?Ci.isString(n)?-1!==t.indexOf(n):Ci.isRegExp(n)?n.test(t):void 0:void 0)}let aa=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=na(t);if(!i)throw new Error("header name must be a non-empty string");const o=Ci.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||t]=ia(e))}const o=(e,t)=>Ci.forEach(e,((e,r)=>i(e,r,t)));if(Ci.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Ci.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&ta[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t);else if(Ci.isObject(e)&&Ci.isIterable(e)){let r,n,i={};for(const t of e){if(!Ci.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[n=t[0]]=(r=i[n])?Ci.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=na(e)){const r=Ci.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(Ci.isFunction(t))return t.call(this,e,r);if(Ci.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=na(e)){const r=Ci.findKey(this,e);return!(!r||void 0===this[r]||t&&!oa(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=na(e)){const i=Ci.findKey(r,e);!i||t&&!oa(0,r[i],i,t)||(delete r[i],n=!0)}}return Ci.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!oa(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return Ci.forEach(this,((n,i)=>{const o=Ci.findKey(r,i);if(o)return t[o]=ia(n),void delete t[i];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();a!==i&&delete t[i],t[a]=ia(n),r[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ci.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&Ci.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[ra]=this[ra]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=na(e);t[n]||(!function(e,t){const r=Ci.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return Ci.isArray(e)?e.forEach(n):n(e),this}};function sa(e,t){const r=this||ea,n=t||r,i=aa.from(n.headers);let o=n.data;return Ci.forEach(e,(function(e){o=e.call(r,o,i.normalize(),t?t.status:void 0)})),i.normalize(),o}function la(e){return!(!e||!e.__CANCEL__)}function ca(e,t,r){jo.call(this,null==e?"canceled":e,jo.ERR_CANCELED,t,r),this.name="CanceledError"}function ua(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new jo("Request failed with status code "+r.status,[jo.ERR_BAD_REQUEST,jo.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}aa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ci.reduceDescriptors(aa.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),Ci.freezeMethods(aa),Ci.inherits(ca,jo,{__CANCEL__:!0});const da=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,o=0,a=0;return t=void 0!==t?t:1e3,function(s){const l=Date.now(),c=n[a];i||(i=l),r[o]=s,n[o]=l;let u=a,d=0;for(;u!==o;)d+=r[u++],u%=e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),l-i<t)return;const h=c&&l-c;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(e,t){let r,n,i=0,o=1e3/t;const a=(t,o=Date.now())=>{i=o,r=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),s=t-i;s>=o?a(e,t):(r=e,n||(n=setTimeout((()=>{n=null,a(r)}),o-s)))},()=>r&&a(r)]}((r=>{const o=r.loaded,a=r.lengthComputable?r.total:void 0,s=o-n,l=i(s);n=o;e({loaded:o,total:a,progress:a?o/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&o<=a?(a-o)/l:void 0,event:r,lengthComputable:null!=a,[t?"download":"upload"]:!0})}),r)},ha=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},fa=e=>(...t)=>Ci.asap((()=>e(...t)));var pa=Xo.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,Xo.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(Xo.origin),Xo.navigator&&/(msie|trident)/i.test(Xo.navigator.userAgent)):()=>!0,ga=Xo.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const a=[e+"="+encodeURIComponent(t)];Ci.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),Ci.isString(n)&&a.push("path="+n),Ci.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function ma(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const va=e=>e instanceof aa?{...e}:e;function ya(e,t){t=t||{};const r={};function n(e,t,r,n){return Ci.isPlainObject(e)&&Ci.isPlainObject(t)?Ci.merge.call({caseless:n},e,t):Ci.isPlainObject(t)?Ci.merge({},t):Ci.isArray(t)?t.slice():t}function i(e,t,r,i){return Ci.isUndefined(t)?Ci.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function o(e,t){if(!Ci.isUndefined(t))return n(void 0,t)}function a(e,t){return Ci.isUndefined(t)?Ci.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(r,i,o){return o in t?n(r,i):o in e?n(void 0,r):void 0}const l={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(e,t,r)=>i(va(e),va(t),0,!0)};return Ci.forEach(Object.keys(Object.assign({},e,t)),(function(n){const o=l[n]||i,a=o(e[n],t[n],n);Ci.isUndefined(a)&&o!==s||(r[n]=a)})),r}var ba=e=>{const t=ya({},e);let r,{data:n,withXSRFToken:i,xsrfHeaderName:o,xsrfCookieName:a,headers:s,auth:l}=t;if(t.headers=s=aa.from(s),t.url=Bo(ma(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),Ci.isFormData(n))if(Xo.hasStandardBrowserEnv||Xo.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(!1!==(r=s.getContentType())){const[e,...t]=r?r.split(";").map((e=>e.trim())).filter(Boolean):[];s.setContentType([e||"multipart/form-data",...t].join("; "))}if(Xo.hasStandardBrowserEnv&&(i&&Ci.isFunction(i)&&(i=i(t)),i||!1!==i&&pa(t.url))){const e=o&&a&&ga.read(a);e&&s.set(o,e)}return t};var wa="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){const n=ba(e);let i=n.data;const o=aa.from(n.headers).normalize();let a,s,l,c,u,{responseType:d,onUploadProgress:h,onDownloadProgress:f}=n;function p(){c&&c(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(a),n.signal&&n.signal.removeEventListener("abort",a)}let g=new XMLHttpRequest;function m(){if(!g)return;const n=aa.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());ua((function(e){t(e),p()}),(function(e){r(e),p()}),{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:n,config:e,request:g}),g=null}g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(r(new jo("Request aborted",jo.ECONNABORTED,e,g)),g=null)},g.onerror=function(){r(new jo("Network Error",jo.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||Jo;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new jo(t,i.clarifyTimeoutError?jo.ETIMEDOUT:jo.ECONNABORTED,e,g)),g=null},void 0===i&&o.setContentType(null),"setRequestHeader"in g&&Ci.forEach(o.toJSON(),(function(e,t){g.setRequestHeader(t,e)})),Ci.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),d&&"json"!==d&&(g.responseType=n.responseType),f&&([l,u]=da(f,!0),g.addEventListener("progress",l)),h&&g.upload&&([s,c]=da(h),g.upload.addEventListener("progress",s),g.upload.addEventListener("loadend",c)),(n.cancelToken||n.signal)&&(a=t=>{g&&(r(!t||t.type?new ca(null,e,g):t),g.abort(),g=null)},n.cancelToken&&n.cancelToken.subscribe(a),n.signal&&(n.signal.aborted?a():n.signal.addEventListener("abort",a)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);v&&-1===Xo.protocols.indexOf(v)?r(new jo("Unsupported protocol "+v+":",jo.ERR_BAD_REQUEST,e)):g.send(i||null)}))};const _a=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const i=function(e){if(!r){r=!0,a();const t=e instanceof Error?e:this.reason;n.abort(t instanceof jo?t:new ca(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{o=null,i(new jo(`timeout ${t} of ms exceeded`,jo.ETIMEDOUT))}),t);const a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)})),e=null)};e.forEach((e=>e.addEventListener("abort",i)));const{signal:s}=n;return s.unsubscribe=()=>Ci.asap(a),s}},Sa=function*(e,t){let r=e.byteLength;if(r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},Ea=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},ka=(e,t,r,n)=>{const i=async function*(e,t){for await(const r of Ea(e))yield*Sa(r,t)}(e,t);let o,a=0,s=e=>{o||(o=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return s(),void e.close();let o=n.byteLength;if(r){let e=a+=o;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})},xa="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Pa=xa&&"function"==typeof ReadableStream,Aa=xa&&("function"==typeof TextEncoder?(Ia=new TextEncoder,e=>Ia.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ia;const Oa=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ta=Pa&&Oa((()=>{let e=!1;const t=new Request(Xo.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),ja=Pa&&Oa((()=>Ci.isReadableStream(new Response("").body))),Ca={stream:ja&&(e=>e.body)};var Ra;xa&&(Ra=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Ca[e]&&(Ca[e]=Ci.isFunction(Ra[e])?t=>t[e]():(t,r)=>{throw new jo(`Response type '${e}' is not supported`,jo.ERR_NOT_SUPPORT,r)})})));const Fa=async(e,t)=>{const r=Ci.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Ci.isBlob(e))return e.size;if(Ci.isSpecCompliantForm(e)){const t=new Request(Xo.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ci.isArrayBufferView(e)||Ci.isArrayBuffer(e)?e.byteLength:(Ci.isURLSearchParams(e)&&(e+=""),Ci.isString(e)?(await Aa(e)).byteLength:void 0)})(t):r};var La=xa&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:a,onDownloadProgress:s,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:h}=ba(e);c=c?(c+"").toLowerCase():"text";let f,p=_a([i,o&&o.toAbortSignal()],a);const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let m;try{if(l&&Ta&&"get"!==r&&"head"!==r&&0!==(m=await Fa(u,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(Ci.isFormData(n)&&(e=r.headers.get("content-type"))&&u.setContentType(e),r.body){const[e,t]=ha(m,da(fa(l)));n=ka(r.body,65536,e,t)}}Ci.isString(d)||(d=d?"include":"omit");const i="credentials"in Request.prototype;f=new Request(t,{...h,signal:p,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:i?d:void 0});let o=await fetch(f,h);const a=ja&&("stream"===c||"response"===c);if(ja&&(s||a&&g)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=o[t]}));const t=Ci.toFiniteNumber(o.headers.get("content-length")),[r,n]=s&&ha(t,da(fa(s),!0))||[];o=new Response(ka(o.body,65536,r,(()=>{n&&n(),g&&g()})),e)}c=c||"text";let v=await Ca[Ci.findKey(Ca,c)||"text"](o,e);return!a&&g&&g(),await new Promise(((t,r)=>{ua(t,r,{data:v,headers:aa.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:f})}))}catch(t){if(g&&g(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new jo("Network Error",jo.ERR_NETWORK,e,f),{cause:t.cause||t});throw jo.from(t,t&&t.code,e,f)}});const Ua={http:null,xhr:wa,fetch:La};Ci.forEach(Ua,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Na=e=>`- ${e}`,qa=e=>Ci.isFunction(e)||null===e||!1===e;var za=e=>{e=Ci.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){let t;if(r=e[o],n=r,!qa(r)&&(n=Ua[(t=String(r)).toLowerCase()],void 0===n))throw new jo(`Unknown adapter '${t}'`);if(n)break;i[t||"#"+o]=n}if(!n){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new jo("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Na).join("\n"):" "+Na(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Da(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ca(null,e)}function $a(e){Da(e),e.headers=aa.from(e.headers),e.data=sa.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return za(e.adapter||ea.adapter)(e).then((function(t){return Da(e),t.data=sa.call(e,e.transformResponse,t),t.headers=aa.from(t.headers),t}),(function(t){return la(t)||(Da(e),t&&t.response&&(t.response.data=sa.call(e,e.transformResponse,t.response),t.response.headers=aa.from(t.response.headers))),Promise.reject(t)}))}const Ma="1.10.0",Ba={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Ba[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Ha={};Ba.transitional=function(e,t,r){function n(e,t){return"[Axios v"+Ma+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,o)=>{if(!1===e)throw new jo(n(i," has been removed"+(t?" in "+t:"")),jo.ERR_DEPRECATED);return t&&!Ha[i]&&(Ha[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,o)}},Ba.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var Ja={assertOptions:function(e,t,r){if("object"!=typeof e)throw new jo("options must be an object",jo.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],a=t[o];if(a){const t=e[o],r=void 0===t||a(t,o,e);if(!0!==r)throw new jo("option "+o+" must be "+r,jo.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new jo("Unknown option "+o,jo.ERR_BAD_OPTION)}},validators:Ba};const Ga=Ja.validators;let Wa=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ho,response:new Ho}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ya(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&Ja.assertOptions(r,{silentJSONParsing:Ga.transitional(Ga.boolean),forcedJSONParsing:Ga.transitional(Ga.boolean),clarifyTimeoutError:Ga.transitional(Ga.boolean)},!1),null!=n&&(Ci.isFunction(n)?t.paramsSerializer={serialize:n}:Ja.assertOptions(n,{encode:Ga.function,serialize:Ga.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Ja.assertOptions(t,{baseUrl:Ga.spelling("baseURL"),withXsrfToken:Ga.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&Ci.merge(i.common,i[t.method]);i&&Ci.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=aa.concat(o,i);const a=[];let s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));const l=[];let c;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let u,d=0;if(!s){const e=[$a.bind(this),void 0];for(e.unshift.apply(e,a),e.push.apply(e,l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=a.length;let h=t;for(d=0;d<u;){const e=a[d++],t=a[d++];try{h=e(h)}catch(e){t.call(this,e);break}}try{c=$a.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return Bo(ma((e=ya(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Ci.forEach(["delete","get","head","options"],(function(e){Wa.prototype[e]=function(t,r){return this.request(ya(r||{},{method:e,url:t,data:(r||{}).data}))}})),Ci.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(ya(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Wa.prototype[e]=t(),Wa.prototype[e+"Form"]=t(!0)}));const Va={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Va).forEach((([e,t])=>{Va[t]=e}));const Ya=function e(t){const r=new Wa(t),n=Bn(Wa.prototype.request,r);return Ci.extend(n,Wa.prototype,r,{allOwnKeys:!0}),Ci.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(ya(t,r))},n}(ea);Ya.Axios=Wa,Ya.CanceledError=ca,Ya.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new ca(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;const r=new e((function(e){t=e}));return{token:r,cancel:t}}},Ya.isCancel=la,Ya.VERSION=Ma,Ya.toFormData=qo,Ya.AxiosError=jo,Ya.Cancel=Ya.CanceledError,Ya.all=function(e){return Promise.all(e)},Ya.spread=function(e){return function(t){return e.apply(null,t)}},Ya.isAxiosError=function(e){return Ci.isObject(e)&&!0===e.isAxiosError},Ya.mergeConfig=ya,Ya.AxiosHeaders=aa,Ya.formToJSON=e=>Zo(Ci.isHTMLForm(e)?new FormData(e):e),Ya.getAdapter=za,Ya.HttpStatusCode=Va,Ya.default=Ya;const{Axios:Ka,AxiosError:Qa,CanceledError:Xa,isCancel:Za,CancelToken:es,VERSION:ts,all:rs,Cancel:ns,isAxiosError:is,spread:os,toFormData:as,AxiosHeaders:ss,HttpStatusCode:ls,formToJSON:cs,getAdapter:us,mergeConfig:ds}=Ya;class hs extends Error{}function fs(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return atob(t)}}hs.prototype.name="InvalidTokenError";class ps{constructor(){this.inIframe=salla.helpers.isIframe(),salla.event.on("twilight::before.ready",(async e=>await this.initiateRequest(e))),salla.event.on("profile::info.fetched",(e=>this.setCurrencyAndLanguage(e))),salla.event.on("auth::token.fetched",(e=>{salla.storage.set("token",e),this.inIframe&&salla.log("token fetched iframe"),this.inIframe&&salla.cookie.set("s-token",e,60),this.setToken(e)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=Ya.create({baseURL:Salla.config.get("store.api",Salla.config.get("store.url")),headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":Salla?.versions?.base?.toString()?.match(/^\d+\.\d+\.\d+/)[0]??"2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}}),this.axios.interceptors.request.use((e=>{"preview"===Salla.config.get("theme.mode")&&(e.url=Salla.url.addParamToUrl("use_username_url",1,e.url));try{const t=Salla.config.get("swoole",[]),r=new RegExp(t.join("|"),"i");t.length>0&&r.test(e.url)&&(e.headers["s-store-api-version"]="swoole")}catch(e){console.log(e)}return e}),(e=>Promise.reject(e)))}getHeaders(){let e={...this.axios.defaults.headers.common};return delete e["Content-Type"],e}getHeader(e){return Object.entries(this.getHeaders()).filter((([t])=>t.toLowerCase()===e.toLowerCase()))[0]?.[1]}setHeaders(e){return Object.entries(e).forEach((e=>this.setHeader(e[0],e[1]))),this}setHeader(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this}async withoutNotifier(e){return this.notifier_handler_disabled=!0,await e().finally((()=>{this.notifier_handler_disabled=!1}))}async initiateRequest(e){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:e.user?.currency_code||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":e.user?.id,"s-country":e.user?.country_code,...e.headers||{}});const t=Salla.config.get("store.scope",Salla.storage.get("scope")),r=new URLSearchParams(window.location.search).get("scope");r&&t&&!Salla.url.is_page("cart")&&(t.id=r,Salla.storage.set("scope",t),Salla.cart.reset()),t&&this.setHeaders({"s-scope-type":t.type,"s-scope-id":t.id});const n=Salla.storage.getWithTTL("s-utms");n&&this.setHeaders(n),await this.injectTokenToTheRequests(e),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))}async injectTokenToTheRequests(e){let t=salla.storage.get("token"),r="guest"===e.user?.type,n=parseInt(e.user?.id||0),i=parseInt(salla.storage.get("user.id")||0),o=salla.auth.api.isSessionless(),a=e=>{this.setToken(e),salla.event.emit("api::initiated")},s=async()=>{r||o||!n?salla.auth.event.tokenInvalid():(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async()=>{await salla.profile.info()})).catch((()=>salla.auth.event.tokenInvalid())))};if(!t)return salla.log("Api:: case 1 => current is is guest"),void await s();let l,c=function(e,t){if("string"!=typeof e)throw new hs("Invalid token specified: must be a string");t||(t={});const r=!0===t.header?0:1,n=e.split(".")[r];if("string"!=typeof n)throw new hs(`Invalid token specified: missing part #${r+1}`);let i;try{i=fs(n)}catch(e){throw new hs(`Invalid token specified: invalid base64 for part #${r+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new hs(`Invalid token specified: invalid json for part #${r+1} (${e.message})`)}}(t);return Date.now()/1e3>c.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await s()):(l=o?parseInt(c.sub)!==i:!i||!n||i!==n||parseInt(c.sub)!==n,l?(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log(`sub:${c.sub} userIdInWeb:${n} userIdInStorage:${i}, isSessionless:${o}`,c.sub,n,i),this.setHeader("Authorization","Bearer "+t),void await salla.profile.info().then((async e=>{!this.inIframe&&!o&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.request.injectTokenToTheRequests"}),a(t)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()}))):(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void a(t)))}setToken(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this}setCurrencyAndLanguage(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})}request(e,t=void 0,r="get",n={}){let i={endPoint:e,payload:t,method:r,options:n},o="undefined"!=typeof event?event.currentTarget:null,a=!1;return"SALLA-BUTTON"===o?.tagName&&(a=!0),a&&o?.load(),this.axios[i.method](i.endPoint,i.payload,i.options).then((e=>(a&&o?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw a&&o?.stop(),salla.event.document.requestFailed(i,e),this.handleErrorResponse(e),e}))}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:r=null}=e,n=t&&t.googleTags?t.googleTags:r;try{dataLayer&&n&&dataLayer.push(n)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)}fireEventsForResponse(e){let t=e?.events||e.data?.events||e.error?.events;"string"==typeof t&&(t=JSON.parse(t)),t&&Object.keys(t).forEach((e=>salla.event.dispatch(e,t[e])))}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&e.data?.message?salla.notify.fire(e.data?.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0}handleInvalidFields(e){let t=e.response.data.error.fields,r=[];Object.keys(t).forEach((e=>{let n=t[e];Array.isArray(n)?n.forEach((e=>r.push(e))):r.push(n)}));let n=(r.length>1?"* ":"")+r.join("\n* ");salla.error(n,e)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((r,n)=>t?r(e):n(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}}class gs extends An{constructor(){super(),this.namespace="component",this.endpoints={getMenus:"menus/{headOrFoot}?store_id={store}&lang={lang}",reviews:"reviews"},this.endpointsMethods={getMenus:"get",reviews:"get"}}async getMenus(e="header"){return this.request(["getMenus",e,salla.config.get("store.id"),salla.lang.getLocale()]).then((function(e){return salla.event.component.menuFetched(e),e})).catch((function(e){throw salla.event.component.menuFetchFailed(e),e}))}async getReviews({per_page:e=5,type:t="all",items:r}){if(!t){const e="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}const n=!r||"string"==typeof r&&"[]"===r||Array.isArray(r)&&!r.length;if(!new Set(["all","store","categories","products","json"]).has(t)){const e="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if("all"!==t&&"store"!==t&&n){const e="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if(new Set(["products","categories"]).has(t)&&!Array.isArray(r)){const e=`Items value must be an array of ${t} id for review type of ${t}.`;return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}return this.request(["reviews"],{params:{per_page:e,type:t,items:r}},"get").then((function(e){return salla.event.component.reviewsFetched(e),e})).catch((function(e){throw salla.event.component.reviewsFetchFailed(e),e}))}}class ms extends An{constructor(){super(),this.namespace="booking",this.endpoints={fetch:"advertisements"},this.endpointsMethods={fetch:"get"}}async fetch(e=null){const t=e?{page:e}:{};return this.request(["fetch"],{params:t}).then((function(e){return salla.event.advertisement.fetched(e),e})).catch((function(e){throw salla.event.advertisement.fetchFailed(e),e}))}}class vs extends An{constructor(){super(),this.namespace="navigation",this.endpoints={breadcrumbs:"breadcrumbs"},this.endpointsMethods={breadcrumbs:"get"},this.after_init()}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.navigation.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e}))}}class ys extends An{constructor(){super(),this.namespace="metadata",this.endpoints={fetchValues:"https://api.salla.dev/store/v1/metadata/values"},this.endpointsMethods={fetchValues:"get"}}async fetchValues(e,t){if(!e||!t){const e="Please provide entity type and entity ids.";return salla.metadata.event.valueNotFetch(e),salla.api.errorPromise(e)}const r={type:e,entities:Array.isArray(t)?t:[t]};return this.request(this.endpoints.fetchValues,{params:r},"get").then((e=>(salla.metadata.event.valueFetched(e),e))).catch((e=>{throw salla.metadata.event.valueNotFetch(e),e}))}}class bs{constructor(e){"ready"!==Dr.status?e?(Dr.config.merge(e),["salla.sa","salla.group"].includes(location.hostname)&&!Dr.config.get("store.url")?.includes(location.hostname)&&Dr.config.get("store.username")&&Dr.config.set("store.url",window.location.origin+"/"+Dr.config.get("store.username")),e?.events&&Dr.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),window.self===window.top&&(this.injectMaintenanceAlert(),this.injectThemePreviewAlert()),this.injectTemplateStoreAlert(),this.injectAppInstallAlert(),this.applyContentCopyright(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e),this.afterInit()):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}afterInit(){Dr.url.is_page("product.single")&&Dr.config.isGuest()&&window.addEventListener("mini-checkout::before-init",(e=>{e.preventDefault(),Dr.event.emit("login::open")}))}applyContentCopyright(){if(!Dr.config.get("store.settings.content_copyright"))return;["contextmenu","selectstart","copy"].forEach((e=>{document.addEventListener(e,(e=>e.preventDefault()))})),document.addEventListener("keydown",(e=>{const t=e.key.toLowerCase();("f12"===t||e.ctrlKey&&e.shiftKey&&["i","j","c"].includes(t)||e.ctrlKey&&"u"===t)&&(e.preventDefault(),e.stopPropagation())}));const e=document.createElement("style");e.textContent="\n body {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n img {\n pointer-events: none;\n -webkit-user-drag: none;\n }\n ",document.head.appendChild(e)}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.prepend(document.createElement("salla-maintenance-alert")))))}injectTemplateStoreAlert(){salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?salla.logger.warn("salla-bottom-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-bottom-alert")))))}injectAppInstallAlert(){salla.config.get("store.app_install_prompt")&&salla.config.get("store.apps")&&!salla.storage.get("app_install_prompt_disabled")&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?salla.logger.warn("salla-app-install-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-app-install-alert")))))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML=`\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(e)})))}injectEditAlert(){let e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let t=document.createElement("div");t.id="s-edit-alert",t.innerHTML=`\n <a href="${e}" style="display:block; background-color:${salla.config.get("theme.color.primary","#5cd5c4")}; color:${salla.config.get("theme.color.reverse","#fff")}; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n ${salla.lang.get("pages.products.quick_edit")}\n </a>\n `,document.body.prepend(t)})))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();let r=t.getAjaxFormData(e),n=r.method?r.method.toLowerCase():void 0;salla.api.request(r.url,r.formData,n).then((e=>(e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),this.callAjaxEvent(r.events.success,e,r.formData),e))).catch((e=>{throw salla.api.handleErrorResponse(e),this.callAjaxEvent(r.events.fail,e,r.formData),e}))}callAjaxEvent(e,t,r){if(e){if(r instanceof FormData){const e={};Array.from(r.entries()).forEach((function(t){e[t[0]]=t[1]})),r=e}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}}setSallaReady(e){this.storeUTMs(),Dr.event.emitAsync("twilight::before.ready",e),Dr.status="ready",Dr.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))}storeUTMs(){const e={fbclid:"facebook",gad_source:"google",ttclid:"tiktok",twclid:"twitter",scid:"snapchat"},t=["fbclid","gad_source","ttclid","twclid","scid"],r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content",...t],n={},i={};window.location.search.replace("?","").split("&").map((e=>e.split("="))).filter((([e])=>r.includes(e.toLowerCase()))).forEach((([e,t])=>n[e.toLowerCase()]=t));const o=t.find((e=>n[e]));!n.utm_source&&o&&(n.utm_source=e[o],n.utm_campaign=n.utm_campaign||`Using the CLICKID ${o} provided by ${n.utm_source}`,n.utm_term=n.utm_term||`${o}: ${n[o]}`),n.utm_source&&(Object.entries(n).filter((([e])=>!t.includes(e))).forEach((([e,t])=>i[`s-${e.replace("_","-")}`]=t)),i["s-utm-referrer"]=document.referrer,salla.storage.setWithTTL("s-utms",i,129600),this.logUTMVisitData(i))}async logUTMVisitData(e){const t=e["s-utm-source"],r=e["s-utm-medium"],n=e["s-utm-campaign"];e&&"affiliate"===t&&r&&n&&fetch(salla.config.get("affiliate.utm_url"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","s-utm-source":t,"s-utm-medium":r,"s-utm-campaign":n}}).then((e=>{if(e.ok){const e=new URL(window.location.href),t=window.history.state;e.searchParams.delete("utm_source"),e.searchParams.delete("utm_medium"),e.searchParams.delete("utm_campaign"),window.history.replaceState(t,"",e)}}))}}function ws(e,t,r,n,i){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:i;return e===i?r:e}var _s="undefined",Ss="object",Es="any",ks="*",xs=void 0!==Ht?Ht:{};xs.env&&xs.env.NODE_ENV;var Ps="undefined"!=typeof document;function As(e,t){return t.charAt(0)[e]()+t.slice(1)}null!=xs.versions&&xs.versions.node,"undefined"!=typeof Deno&&Deno.core,Ps&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));var Is=As.bind(null,"toUpperCase"),Os=As.bind(null,"toLowerCase");function Ts(e){return Ns(e)?Is("null"):"object"==typeof e?function(e){return Rs(e.constructor)?e.constructor.name:null}(e):Object.prototype.toString.call(e).slice(8,-1)}function js(e,t){void 0===t&&(t=!0);var r=Ts(e);return t?Os(r):r}function Cs(e,t){return typeof t===e}var Rs=Cs.bind(null,"function"),Fs=Cs.bind(null,"string"),Ls=Cs.bind(null,"undefined"),Us=Cs.bind(null,"boolean");function Ns(e){return null===e}function qs(e){if(!function(e){return e&&("object"==typeof e||null!==e)}(e))return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function zs(e){return e instanceof Error||Fs(e.message)&&e.constructor&&function(e){return"number"===js(e)&&!isNaN(e)}(e.constructor.stackTraceLimit)}function Ds(e,t){if("object"!=typeof t||Ns(t))return!1;if(t instanceof e)return!0;var r=js(new e(""));if(zs(t))for(;t;){if(js(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}function $s(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?function(e,t){return void 0===t&&(t=""),e&&e.nodeName===t.toUpperCase()}(e,t):r}function Ms(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}function Bs(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Hs(e){return function(e){for(var t,r=Object.create(null),n=/([^&=]+)=?([^&]*)/g;t=n.exec(e);){var i=Bs(t[1]),o=Bs(t[2]);"[]"===i.substring(i.length-2)?(r[i=i.substring(0,i.length-2)]||(r[i]=[])).push(o):r[i]=""===o||o}for(var a in r){var s=a.split("[");s.length>1&&(Js(r,s.map((function(e){return e.replace(/[?[\]\\ ]/g,"")})),r[a]),delete r[a])}return r}(Ps&&window.location.search.substring(1))}function Js(e,t,r){for(var n=t.length-1,i=0;i<n;++i){var o=t[i];if("__proto__"===o||"constructor"===o)break;o in e||(e[o]={}),e=e[o]}e[t[n]]=r}function Gs(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],i=15&r;e+="-"==n||"4"==n?n:("x"==n?i:3&i|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}Cs.bind(null,"symbol"),Ds.bind(null,TypeError),Ds.bind(null,SyntaxError),Ms($s,"form"),Ms($s,"button"),Ms($s,"input"),Ms($s,"select");var Ws="global",Vs="__global__",Ys=typeof self===Ss&&self.self===self&&self||typeof Qe===Ss&&Qe.global===Qe&&Qe||void 0;function Ks(e){return Ys[Vs][e]}function Qs(e,t){return Ys[Vs][e]=t}function Xs(e){delete Ys[Vs][e]}function Zs(e,t,r){var n;try{if(tl(e)){var i=window[e];n=i[t].bind(i)}}catch(e){}return n||r}Ys[Vs]||(Ys[Vs]={});var el={};function tl(e){if(typeof el[e]!==_s)return el[e];try{var t=window[e];t.setItem(_s,_s),t.removeItem(_s)}catch(t){return el[e]=!1}return el[e]=!0}function rl(){return rl=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},rl.apply(this,arguments)}var nl="function",il="undefined",ol="@@redux/"+Math.random().toString(36),al=function(){return typeof Symbol===nl&&Symbol.observable||"@@observable"}(),sl=" != "+nl;function ll(e,t,r){var n;if(typeof t===nl&&typeof r===il&&(r=t,t=void 0),typeof r!==il){if(typeof r!==nl)throw new Error("enhancer"+sl);return r(ll)(e,t)}if(typeof e!==nl)throw new Error("reducer"+sl);var i=e,o=t,a=[],s=a,l=!1;function c(){s===a&&(s=a.slice())}function u(){return o}function d(e){if(typeof e!==nl)throw new Error("Listener"+sl);var t=!0;return c(),s.push(e),function(){if(t){t=!1,c();var r=s.indexOf(e);s.splice(r,1)}}}function h(e){if(!qs(e))throw new Error("Act != obj");if(typeof e.type===il)throw new Error("ActType "+il);if(l)throw new Error("Dispatch in reducer");try{l=!0,o=i(o,e)}finally{l=!1}for(var t=a=s,r=0;r<t.length;r++)(0,t[r])();return e}return h({type:"@@redux/INIT"}),(n={dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if(typeof e!==nl)throw new Error("next reducer"+sl);i=e,h({type:"@@redux/INIT"})}})[al]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function r(){e.next&&e.next(u())}return r(),{unsubscribe:t(r)}}})[al]=function(){return this},e},n}function cl(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+il}function ul(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce((function(e,t){return function(){return e(t.apply(void 0,[].slice.call(arguments)))}}))}function dl(){var e=arguments;return function(t){return function(r,n,i){var o,a=t(r,n,i),s=a.dispatch,l={getState:a.getState,dispatch:function(e){return s(e)}};return o=[].slice.call(e).map((function(e){return e(l)})),rl({},a,{dispatch:s=ul.apply(void 0,o)(a.dispatch)})}}}var hl="__anon_id",fl="__user_id",pl="__user_traits",gl="userId",ml="anonymousId",vl=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],yl=["name","EVENTS","config","loaded"],bl=vl.reduce((function(e,t){return e[t]=t,e}),{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),wl=/^utm_/,_l=/^an_prop_/,Sl=/^an_trait_/;function El(e){var t=e.storage.setItem;return function(r){return function(n){return function(i){if(i.type===bl.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,l=i.initialUser,c=s.userId===a.userId;s.anonymousId!==a.anonymousId&&t(hl,a.anonymousId),c||t(fl,a.userId),l.traits&&t(pl,rl({},c&&s.traits?s.traits:{},l.traits));var u=Object.keys(i.params);if(u.length){var d=o.an_uid,h=o.an_event,f=u.reduce((function(e,t){if(t.match(wl)||t.match(/^(d|g)clid/)){var r=t.replace(wl,"");e.campaign["campaign"===r?"name":r]=o[t]}return t.match(_l)&&(e.props[t.replace(_l,"")]=o[t]),t.match(Sl)&&(e.traits[t.replace(Sl,"")]=o[t]),e}),{campaign:{},props:{},traits:{}});r.dispatch(rl({type:bl.params,raw:o},f,d?{userId:d}:{})),d&&setTimeout((function(){return e.identify(d,f.traits)}),0),h&&setTimeout((function(){return e.track(h,f.props)}),0),Object.keys(f.campaign).length&&r.dispatch({type:bl.campaign,campaign:f.campaign})}}return n(i)}}}}function kl(e){return function(t,r){if(void 0===t&&(t={}),void 0===r&&(r={}),r.type===bl.setItemEnd){if(r.key===hl)return rl({},t,{anonymousId:r.value});if(r.key===fl)return rl({},t,{userId:r.value})}switch(r.type){case bl.identify:return Object.assign({},t,{userId:r.userId,traits:rl({},t.traits,r.traits)});case bl.reset:return[fl,hl,pl].forEach((function(t){e.removeItem(t)})),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function xl(e){return{userId:e.getItem(fl),anonymousId:e.getItem(hl),traits:e.getItem(pl)}}var Pl=function(e){return"__TEMP__"+e};function Al(e){var t=e.storage,r=t.setItem,n=t.removeItem,i=t.getItem;return function(e){return function(t){return function(o){var a=o.userId,s=o.traits,l=o.options;if(o.type===bl.reset&&([fl,pl,hl].forEach((function(e){n(e)})),[gl,ml,"traits"].forEach((function(e){Xs(Pl(e))}))),o.type===bl.identify){i(hl)||r(hl,Gs());var c=i(fl),u=i(pl)||{};c&&c!==a&&e.dispatch({type:bl.userIdChanged,old:{userId:c,traits:u},new:{userId:a,traits:s},options:l}),a&&r(fl,a),s&&r(pl,rl({},u,s))}return t(o)}}}}var Il={};function Ol(e,t){Il[e]&&Rs(Il[e])&&(Il[e](t),delete Il[e])}function Tl(e,t,r){return new Promise((function(n,i){return t()?n(e):r<1?i(rl({},e,{queue:!0})):new Promise((function(e){return setTimeout(e,10)})).then((function(o){return Tl(e,t,r-10).then(n,i)}))}))}function jl(e){return{abort:e}}var Cl=function(e){var t=e.data,r=e.action,n=e.instance,i=e.state,o=e.allPlugins,a=e.allMatches,s=e.store,l=e.EVENTS;try{var c=i.plugins,u=i.context,d=r.type,h=d.match(Rl),f=t.exact.map((function(e){return e.pluginName}));h&&(f=a.during.map((function(e){return e.pluginName})));var p=function(e,t){return function(r,n,i){var o=n.config,a=n.name,s=a+"."+r.type;i&&(s=i.event);var l=r.type.match(Rl)?function(e,t,r,n,i){return function(o,a){var s=n?n.name:e,l=a&&Ml(a)?a:r;if(n&&(!(l=a&&Ml(a)?a:[e]).includes(e)||1!==l.length))throw new Error("Method "+t+" can only abort "+e+" plugin. "+JSON.stringify(l)+" input valid");return rl({},i,{abort:{reason:o,plugins:l,caller:t,_:s}})}}(a,s,t,i,r):function(e,t){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+t)}}(r,s);return{payload:Jl(r),instance:e,config:o||{},abort:l}}}(n,f),g=t.exact.reduce((function(e,t){var r=t.pluginName,n=t.methodName,i=!1;return n.match(/^initialize/)||n.match(/^reset/)||(i=!c[r].loaded),u.offline&&n.match(/^(page|track|identify)/)&&(i=!0),e[""+r]=i,e}),{});return Promise.resolve(t.exact.reduce((function(e,i,a){try{var s=i.pluginName;return Promise.resolve(e).then((function(e){function i(){return Promise.resolve(e)}var a=function(){if(t.namespaced&&t.namespaced[s])return Promise.resolve(t.namespaced[s].reduce((function(e,t,r){try{return Promise.resolve(e).then((function(e){return t.method&&Rs(t.method)?(function(e,t){var r=Hl(e);if(r&&r.name===t){var n=Hl(r.method);throw new Error([t+" plugin is calling method "+e,"Plugins cant call self","Use "+r.method+" "+(n?"or "+n.method:"")+" in "+t+" plugin insteadof "+e].join("\n"))}}(t.methodName,t.pluginName),Promise.resolve(t.method({payload:e,instance:n,abort:(r=e,i=s,a=t.pluginName,function(e,t){return rl({},r,{abort:{reason:e,plugins:t||[i],caller:d,from:a||i}})}),config:Nl(t.pluginName,c,o),plugins:c})).then((function(t){var r=qs(t)?t:{};return Promise.resolve(rl({},e,r))}))):e;var r,i,a}))}catch(e){return Promise.reject(e)}}),Promise.resolve(r))).then((function(t){e[s]=t}));e[s]=r}();return a&&a.then?a.then(i):i()}))}catch(e){return Promise.reject(e)}}),Promise.resolve({}))).then((function(e){return Promise.resolve(t.exact.reduce((function(r,i,a){try{var l=t.exact.length===a+1,u=i.pluginName,f=o[u];return Promise.resolve(r).then((function(t){var r=e[u]?e[u]:{};if(h&&(r=t),Dl(r,u))return Ul({data:r,method:d,instance:n,pluginName:u,store:s}),Promise.resolve(t);if(Dl(t,u))return l&&Ul({data:t,method:d,instance:n,store:s}),Promise.resolve(t);if(g.hasOwnProperty(u)&&!0===g[u])return s.dispatch({type:"queue",plugin:u,payload:r,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(t);var i=p(e[u],o[u]);return Promise.resolve(f[d]({abort:i.abort,payload:r,instance:n,config:Nl(u,c,o),plugins:c})).then((function(i){var o=qs(i)?i:{},a=rl({},t,o),l=e[u];if(Dl(l,u))Ul({data:l,method:d,instance:n,pluginName:u,store:s});else{var c=d+":"+u;(c.match(/:/g)||[]).length<2&&!d.match(Fl)&&!d.match(Ll)&&n.dispatch(rl({},h?a:r,{type:c,_:{called:c,from:"submethod"}}))}return Promise.resolve(a)}))}))}catch(e){return Promise.reject(e)}}),Promise.resolve(r))).then((function(e){if(!(d.match(Rl)||d.match(/^registerPlugin/)||d.match(Ll)||d.match(Fl)||d.match(/^params/)||d.match(/^userIdChanged/))){if(l.plugins.includes(d),e._&&e._.originalAction===d)return e;var r=rl({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});$l(e,t.exact.length)&&!d.match(/End$/)&&(r=rl({},r,{type:e.type+"Aborted"})),s.dispatch(r)}return e}))}))}catch(e){return Promise.reject(e)}},Rl=/Start$/,Fl=/^bootstrap/,Ll=/^ready/;function Ul(e){var t=e.pluginName,r=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(rl({},e.data,{type:r,_:{called:r,from:"abort"}}))}function Nl(e,t,r){var n=t[e]||r[e];return n&&n.config?n.config:{}}function ql(e,t){return t.reduce((function(t,r){return r[e]?t.concat({methodName:e,pluginName:r.name,method:r[e]}):t}),[])}function zl(e,t){var r=e.replace(Rl,""),n=t?":"+t:"";return[""+e+n,""+r+n,r+"End"+n]}function Dl(e,t){var r=e.abort;return!!r&&(!0===r||Bl(r,t)||r&&Bl(r.plugins,t))}function $l(e,t){var r=e.abort;if(!r)return!1;if(!0===r||Fs(r))return!0;var n=r.plugins;return Ml(r)&&r.length===t||Ml(n)&&n.length===t}function Ml(e){return Array.isArray(e)}function Bl(e,t){return!(!e||!Ml(e))&&e.includes(t)}function Hl(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function Jl(e){return Object.keys(e).reduce((function(t,r){return"type"===r||(t[r]=qs(e[r])?Object.assign({},e[r]):e[r]),t}),{})}function Gl(e,t,r){var n={};return function(i){return function(o){return function(a){try{var s,l=function(e){return s?e:o(d)},c=a.type,u=a.plugins,d=a;if(a.abort)return Promise.resolve(o(a));if(c===bl.enablePlugin&&i.dispatch({type:bl.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),c===bl.disablePlugin&&setTimeout((function(){return Ol(a.meta.rid,{payload:a})}),0),c===bl.initializeEnd){var h=t(),f=Object.keys(h),p=f.filter((function(e){return u.includes(e)})).map((function(e){return h[e]})),g=[],m=[],v=a.disabled,y=p.map((function(e){var t=e.loaded,r=e.name,o=e.config;return Tl(e,(function(){return t({config:o})}),1e4).then((function(t){return n[r]||(i.dispatch({type:bl.pluginReadyType(r),name:r,events:Object.keys(e).filter((function(e){return!yl.includes(e)}))}),n[r]=!0),g=g.concat(r),e})).catch((function(e){if(e instanceof Error)throw new Error(e);return m=m.concat(e.name),e}))}));Promise.all(y).then((function(e){var t={plugins:g,failed:m,disabled:v};setTimeout((function(){f.length===y.length+v.length&&i.dispatch(rl({},{type:bl.ready},t))}),0)}))}var b=function(){if(c!==bl.bootstrap)return/^ready:([^:]*)$/.test(c)&&setTimeout((function(){return function(e,t,r){var n={},i=t(),o=e.getState(),a=o.plugins,s=o.queue,l=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var c=s.actions.reduce((function(e,t,r){return a[t.plugin].loaded?(e.process.push(t),e.processIndex.push(r)):(e.requeue.push(t),e.requeueIndex.push(r)),e}),{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(c.processIndex&&c.processIndex.length){c.processIndex.forEach((function(t){var o=s.actions[t],c=o.plugin,u=o.payload.type,d=i[c][u];if(d&&Rs(d)){var h,f=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),[gl,ml].reduce((function(r,n){return e.hasOwnProperty(n)&&t[n]&&t[n]!==e[n]&&(r[n]=t[n]),r}),e)}(o.payload,l),p=n[f.meta.rid];if(!p&&(h=d({payload:f,config:a[c].config,instance:r,abort:jl}))&&qs(h)&&h.abort)return void(n[f.meta.rid]=!0);if(!p){var g=u+":"+c;e.dispatch(rl({},f,{type:g,_:{called:g,from:"queueDrain"}}))}}}));var u=s.actions.filter((function(e,t){return!~c.processIndex.indexOf(t)}));s.actions=u}}}(i,t,e)}),0),Promise.resolve(function(e,t,r,n,i){try{var o=Rs(t)?t():t,a=e.type,s=a.replace(Rl,"");if(e._&&e._.called)return Promise.resolve(e);var l=r.getState(),c=(h=o,void 0===(f=l.plugins)&&(f={}),void 0===(p=e.options)&&(p={}),Object.keys(h).filter((function(e){var t=p.plugins||{};return Us(t[e])?t[e]:!1!==t.all&&(!f[e]||!1!==f[e].enabled)})).map((function(e){return h[e]})));a===bl.initializeStart&&e.fromEnable&&(c=Object.keys(l.plugins).filter((function(t){var r=l.plugins[t];return e.plugins.includes(t)&&!r.initialized})).map((function(e){return o[e]})));var u=c.map((function(e){return e.name})),d=function(e,t,r){var n=zl(e).map((function(e){return ql(e,t)}));return t.reduce((function(r,n){var i=n.name,o=zl(e,i).map((function(e){return ql(e,t)})),a=o[0],s=o[1],l=o[2];return a.length&&(r.beforeNS[i]=a),s.length&&(r.duringNS[i]=s),l.length&&(r.afterNS[i]=l),r}),{before:n[0],beforeNS:{},during:n[1],duringNS:{},after:n[2],afterNS:{}})}(a,c);return Promise.resolve(Cl({action:e,data:{exact:d.before,namespaced:d.beforeNS},state:l,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then((function(e){function t(){var t=function(){if(a.match(Rl))return Promise.resolve(Cl({action:rl({},c,{type:s+"End"}),data:{exact:d.after,namespaced:d.afterNS},state:l,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then((function(e){e.meta&&e.meta.hasCallback&&Ol(e.meta.rid,{payload:e})}))}();return t&&t.then?t.then((function(){return e})):e}if($l(e,u.length))return e;var c,h=function(){if(a!==s)return Promise.resolve(Cl({action:rl({},e,{type:s}),data:{exact:d.during,namespaced:d.duringNS},state:l,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then((function(e){c=e}));c=e}();return h&&h.then?h.then(t):t()}))}catch(e){return Promise.reject(e)}var h,f,p}(a,t,e,i,r)).then((function(e){return s=1,o(e)}))}();return Promise.resolve(b&&b.then?b.then(l):l(b))}catch(e){return Promise.reject(e)}}}}}function Wl(e){return function(t){return function(t){return function(r){var n=r.type,i=r.key,o=r.value,a=r.options;if(n===bl.setItem||n===bl.removeItem){if(r.abort)return t(r);n===bl.setItem?e.setItem(i,o,a):e.removeItem(i,a)}return t(r)}}}}var Vl=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,r){e[r]=e[r].concat(t)},this.removeMiddleware=function(t,r){var n=e[r].findIndex((function(e){return e===t}));-1!==n&&(e[r]=[].concat(e[r].slice(0,n),e[r].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(r){return function(n){return function(i){var o={getState:r.getState,dispatch:function(e){return r.dispatch(e)}},a=e[t].map((function(e){return e(o)}));return ul.apply(void 0,a)(n)(i)}}}}};function Yl(e){return function(t,r){void 0===t&&(t={});var n={};if("initialize:aborted"===r.type)return t;if(/^registerPlugin:([^:]*)$/.test(r.type)){var i=Kl(r.type,"registerPlugin"),o=e()[i];if(!o||!i)return t;var a=r.enabled,s=o.config;return n[i]={enabled:a,initialized:!!a&&Boolean(!o.initialize),loaded:!!a&&Boolean(o.loaded({config:s})),config:s},rl({},t,n)}if(/^initialize:([^:]*)$/.test(r.type)){var l=Kl(r.type,bl.initialize),c=e()[l];return c&&l?(n[l]=rl({},t[l],{initialized:!0,loaded:Boolean(c.loaded({config:c.config}))}),rl({},t,n)):t}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=rl({},t[r.name],{loaded:!0}),rl({},t,n);switch(r.type){case bl.disablePlugin:return rl({},t,Ql(r.plugins,!1,t));case bl.enablePlugin:return rl({},t,Ql(r.plugins,!0,t));default:return t}}}function Kl(e,t){return e.substring(t.length+1,e.length)}function Ql(e,t,r){return e.reduce((function(e,n){return e[n]=rl({},r[n],{enabled:t}),e}),r)}function Xl(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var Zl={last:{},history:[]};function ec(e,t){void 0===e&&(e=Zl);var r=t.options,n=t.meta;if(t.type===bl.track){var i=Xl(rl({event:t.event,properties:t.properties},Object.keys(r).length&&{options:r},{meta:n}));return rl({},e,{last:i,history:e.history.concat(i)})}return e}var tc={actions:[]};function rc(e,t){void 0===e&&(e=tc);var r=t.payload;switch(t.type){case"queue":var n;return n=r&&r.type&&r.type===bl.identify?[t].concat(e.actions):e.actions.concat(t),rl({},e,{actions:n});case"dequeue":return[];default:return e}}var nc=/#.*$/;function ic(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(nc,""):"")}var oc,ac=function(e){if(void 0===e&&(e={}),!Ps)return e;var t=document,r=t.title,n=t.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,l=o.hash,c=o.search,u=function(e){var t=function(){if(Ps)for(var e,t=document.getElementsByTagName("link"),r=0;e=t[r];r++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}();return t?t.match(/\?/)?t:t+e:window.location.href.replace(nc,"")}(c),d={title:r,url:u,path:ic(u),hash:l,search:c,width:a,height:s};return n&&""!==n&&(d.referrer=n),rl({},d,e)},sc={last:{},history:[]};function lc(e,t){void 0===e&&(e=sc);var r=t.options;if(t.type===bl.page){var n=Xl(rl({properties:t.properties,meta:t.meta},Object.keys(r).length&&{options:r}));return rl({},e,{last:n,history:e.history.concat(n)})}return e}oc={};var cc={initialized:!1,sessionId:Gs(),app:null,version:null,debug:!1,offline:!!Ps&&!navigator.onLine,os:{name:"na"},userAgent:Ps?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.14"},timezone:void 0,locale:void 0,campaign:{},referrer:oc};function uc(e,t){void 0===e&&(e=cc);var r=e.initialized,n=t.campaign;switch(t.type){case bl.campaign:return rl({},e,{campaign:n});case bl.offline:return rl({},e,{offline:!0});case bl.online:return rl({},e,{offline:!1});default:return r?e:rl({},cc,e,{initialized:!0})}}var dc=["plugins","reducers","storage"];function hc(){return Qs("analytics",[]),function(e){return function(t,r,n){var i=e(t,r,n),o=i.dispatch;return Object.assign(i,{dispatch:function(e){return Ys[Vs].analytics.push(e.action||e),o(e)}})}}}function fc(e){return function(){return ul(ul.apply(null,arguments),hc())}}function pc(e){return e?function(e){return"array"===js(e)}(e)?e:[e]:[]}function gc(e,t,r){void 0===e&&(e={});var n,i,o=Gs();return t&&(Il[o]=(n=t,i=function(e){for(var t,r=e||Array.prototype.slice.call(arguments),n=0;n<r.length;n++)if(Rs(r[n])){t=r[n];break}return t}(r),function(e){i&&i(e),n(e)})),rl({},e,{rid:o,ts:(new Date).getTime()},t?{hasCallback:!0}:{})}function mc(e){void 0===e&&(e={});var t=e.reducers||{},r=e.initialUser||{},n=(e.plugins||[]).reduce((function(e,t){if(Rs(t))return e.middlewares=e.middlewares.concat(t),e;if(t.NAMESPACE&&(t.name=t.NAMESPACE),!t.name)throw new Error("https://lytics.dev/errors/1");t.config||(t.config={});var r=t.EVENTS?Object.keys(t.EVENTS).map((function(e){return t.EVENTS[e]})):[];e.pluginEnabled[t.name]=!(!1===t.enabled||!1===t.config.enabled),delete t.enabled,t.methods&&(e.methods[t.name]=Object.keys(t.methods).reduce((function(e,r){var n;return e[r]=(n=t.methods[r],function(){for(var e=Array.prototype.slice.call(arguments),t=new Array(n.length),r=0;r<e.length;r++)t[r]=e[r];return t[t.length]=_,n.apply({instance:_},t)}),e}),{}),delete t.methods);var n=Object.keys(t).concat(r),i=new Set(e.events.concat(n));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(t),e.plugins[t.name])throw new Error(t.name+"AlreadyLoaded");return e.plugins[t.name]=t,e.plugins[t.name].loaded||(e.plugins[t.name].loaded=function(){return!0}),e}),{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=e.storage?e.storage:{getItem:Ks,setItem:Qs,removeItem:Xs},o=function(e){return function(t,r,n){return r.getState("user")[t]||(n&&qs(n)&&n[t]?n[t]:xl(e)[t]||Ks(Pl(t))||null)}}(i),a=n.plugins,s=n.events.filter((function(e){return!yl.includes(e)})).sort(),l=new Set(s.concat(vl).filter((function(e){return!yl.includes(e)}))),c=Array.from(l).sort(),u=function(){return a},d=new Vl,h=d.addMiddleware,f=d.removeMiddleware,p=d.dynamicMiddlewares,g=function(){throw new Error("Abort disabled inListener")},m=Hs(),v=xl(i),y=rl({},v,r,m.an_uid?{userId:m.an_uid}:{},m.an_aid?{anonymousId:m.an_aid}:{});y.anonymousId||(y.anonymousId=Gs());var b=rl({enable:function(e,t){return new Promise((function(r){j.dispatch({type:bl.enablePlugin,plugins:pc(e),_:{originalAction:bl.enablePlugin}},r,[t])}))},disable:function(e,t){return new Promise((function(r){j.dispatch({type:bl.disablePlugin,plugins:pc(e),_:{originalAction:bl.disablePlugin}},r,[t])}))}},n.methods),w=!1,_={identify:function(e,t,r,n){try{var i=Fs(e)?e:null,a=qs(e)?e:t,s=r||{},l=_.user();Qs(Pl(gl),i);var c=i||a.userId||o(gl,_,a);return Promise.resolve(new Promise((function(e){j.dispatch(rl({type:bl.identifyStart,userId:c,traits:a||{},options:s,anonymousId:l.anonymousId},l.id&&l.id!==i&&{previousId:l.id}),e,[t,r,n])})))}catch(e){return Promise.reject(e)}},track:function(e,t,r,n){try{var i=qs(e)?e.event:e;if(!i||!Fs(i))throw new Error("EventMissing");var a=qs(e)?e:t||{},s=qs(r)?r:{};return Promise.resolve(new Promise((function(e){j.dispatch({type:bl.trackStart,event:i,properties:a,options:s,userId:o(gl,_,t),anonymousId:o(ml,_,t)},e,[t,r,n])})))}catch(e){return Promise.reject(e)}},page:function(e,t,r){try{var n=qs(e)?e:{},i=qs(t)?t:{};return Promise.resolve(new Promise((function(a){j.dispatch({type:bl.pageStart,properties:ac(n),options:i,userId:o(gl,_,n),anonymousId:o(ml,_,n)},a,[e,t,r])})))}catch(e){return Promise.reject(e)}},user:function(e){if(e===gl||"id"===e)return o(gl,_);if(e===ml||"anonId"===e)return o(ml,_);var t=_.getState("user");return e?ws(t,e):t},reset:function(e){return new Promise((function(t){j.dispatch({type:bl.resetStart},t,e)}))},ready:function(e){return w&&e({plugins:b,instance:_}),_.on(bl.ready,(function(t){e(t),w=!0}))},on:function(e,t){if(!e||!Rs(t))return!1;if(e===bl.bootstrap)throw new Error(".on disabled for "+e);var r=/Start$|Start:/;if("*"===e){var n=function(e){return function(e){return function(n){return n.type.match(r)&&t({payload:n,instance:_,plugins:a}),e(n)}}},i=function(e){return function(e){return function(n){return n.type.match(r)||t({payload:n,instance:_,plugins:a}),e(n)}}};return h(n,vc),h(i,yc),function(){f(n,vc),f(i,yc)}}var o=e.match(r)?vc:yc,s=function(r){return function(r){return function(n){return n.type===e&&t({payload:n,instance:_,plugins:a,abort:g}),r(n)}}};return h(s,o),function(){return f(s,o)}},once:function(e,t){if(!e||!Rs(t))return!1;if(e===bl.bootstrap)throw new Error(".once disabled for "+e);var r=_.on(e,(function(e){t({payload:e.payload,instance:_,plugins:a,abort:g}),r()}));return r},getState:function(e){var t=j.getState();return e?ws(t,e):Object.assign({},t)},dispatch:function(e){var t=Fs(e)?{type:e}:e;if(vl.includes(t.type))throw new Error("reserved action "+t.type);var r=rl({},t,{_:rl({originalAction:t.type},e._||{})});j.dispatch(r)},enablePlugin:b.enable,disablePlugin:b.disable,plugins:b,storage:{getItem:i.getItem,setItem:function(e,t,r){j.dispatch({type:bl.setItemStart,key:e,value:t,options:r})},removeItem:function(e,t){j.dispatch({type:bl.removeItemStart,key:e,options:t})}},setAnonymousId:function(e,t){_.storage.setItem(hl,e,t)},events:{core:vl,plugins:s}},S=n.middlewares.concat([function(e){return function(e){return function(t){return t.meta||(t.meta=gc()),e(t)}}},p(vc),Gl(_,u,{all:c,plugins:s}),Wl(i),El(_),Al(_),p(yc)]),E={context:uc,user:kl(i),page:lc,track:ec,plugins:Yl(u),queue:rc},k=ul,x=ul;if(Ps&&e.debug){var P=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;P&&(k=P({trace:!0,traceLimit:25})),x=function(){return 0===arguments.length?hc():qs(typeof arguments[0])?fc():fc().apply(null,arguments)}}var A,I=function(e){return Object.keys(e).reduce((function(t,r){return dc.includes(r)||(t[r]=e[r]),t}),{})}(e),O=n.pluginsArray.reduce((function(e,t){var r=t.name,i=t.config,o=t.loaded,a=n.pluginEnabled[r];return e[r]={enabled:a,initialized:!!a&&Boolean(!t.initialize),loaded:Boolean(o({config:i})),config:i},e}),{}),T={context:I,user:y,plugins:O},j=ll(function(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var i=t[n];typeof e[i]===nl&&(r[i]=e[i])}var o,a=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(typeof r(void 0,{type:"@@redux/INIT"})===il||typeof r(void 0,{type:ol})===il)throw new Error("reducer "+t+" "+il)}))}(r)}catch(e){o=e}return function(e,t){if(void 0===e&&(e={}),o)throw o;for(var n=!1,i={},s=0;s<a.length;s++){var l=a[s],c=e[l],u=(0,r[l])(c,t);if(typeof u===il){var d=cl(l,t);throw new Error(d)}i[l]=u,n=n||u!==c}return n?i:e}}(rl({},E,t)),T,x(k(dl.apply(void 0,S))));j.dispatch=(A=j.dispatch,function(e,t,r){var n=rl({},e,{meta:gc(e.meta,t,pc(r))});return A.apply(null,[n])});var C=Object.keys(a);j.dispatch({type:bl.bootstrap,plugins:C,config:I,params:m,user:y,initialUser:r,persistedUser:v});var R=C.filter((function(e){return n.pluginEnabled[e]})),F=C.filter((function(e){return!n.pluginEnabled[e]}));return j.dispatch({type:bl.registerPlugins,plugins:C,enabled:n.pluginEnabled}),n.pluginsArray.map((function(e,t){var r=e.bootstrap,i=e.config,o=e.name;r&&Rs(r)&&r({instance:_,config:i,payload:e}),j.dispatch({type:bl.registerPluginType(o),name:o,enabled:n.pluginEnabled[o],plugin:e}),n.pluginsArray.length===t+1&&j.dispatch({type:bl.initializeStart,plugins:R,disabled:F})})),_}var vc="before",yc="after",bc="cookie",wc=kc(),_c=xc,Sc=xc;function Ec(e){return wc?xc(e,"",-1):Xs(e)}function kc(){if(void 0!==wc)return wc;var e="cookiecookie";try{xc(e,e),wc=-1!==document.cookie.indexOf(e),Ec(e)}catch(e){wc=!1}return wc}function xc(e,t,r,n,i,o){if("undefined"!=typeof window){var a=arguments.length>1;return!1===wc&&(a?Qs(e,t):Ks(e)),a?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Pc="localStorage",Ac=tl.bind(null,"localStorage");Zs("localStorage","getItem",Ks),Zs("localStorage","setItem",Qs),Zs("localStorage","removeItem",Xs);var Ic="sessionStorage",Oc=tl.bind(null,"sessionStorage");function Tc(e){var t=e;try{if("true"===(t=JSON.parse(e)))return!0;if("false"===t)return!1;if(qs(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch(e){}if(null!==t&&""!==t)return t}Zs("sessionStorage","getItem",Ks),Zs("sessionStorage","setItem",Qs),Zs("sessionStorage","removeItem",Xs);var jc=Ac(),Cc=Oc(),Rc=kc();function Fc(e,t){if(e){var r=Lc(t),n=!zc(r),i=Uc(r)?Tc(localStorage.getItem(e)):void 0;if(n&&!Ls(i))return i;var o=Nc(r)?Tc(_c(e)):void 0;if(n&&o)return o;var a=qc(r)?Tc(sessionStorage.getItem(e)):void 0;if(n&&a)return a;var s=Ks(e);return n?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function Lc(e){return e?Fs(e)?e:e.storage:Es}function Uc(e){return jc&&Dc(e,Pc)}function Nc(e){return Rc&&Dc(e,bc)}function qc(e){return Cc&&Dc(e,Ic)}function zc(e){return e===ks||"all"===e}function Dc(e,t){return e===Es||e===t||zc(e)}function $c(e,t,r){return{location:e,current:t,previous:r}}var Mc={setItem:function(e,t,r){if(e&&!Ls(t)){var n={},i=Lc(r),o=JSON.stringify(t),a=!zc(i);return Uc(i)&&(n[Pc]=$c(Pc,t,Tc(localStorage.getItem(e))),localStorage.setItem(e,o),a)?n[Pc]:Nc(i)&&(n[bc]=$c(bc,t,Tc(_c(e))),Sc(e,o),a)?n[bc]:qc(i)&&(n[Ic]=$c(Ic,t,Tc(sessionStorage.getItem(e))),sessionStorage.setItem(e,o),a)?n[Ic]:(n[Ws]=$c(Ws,t,Ks(e)),Qs(e,t),a?n[Ws]:n)}},getItem:Fc,removeItem:function(e,t){if(e){var r=Lc(t),n=Fc(e,ks),i={};return!Ls(n.localStorage)&&Uc(r)&&(localStorage.removeItem(e),i[Pc]=n.localStorage),!Ls(n.cookie)&&Nc(r)&&(Ec(e),i[bc]=n.cookie),!Ls(n.sessionStorage)&&qc(r)&&(sessionStorage.removeItem(e),i[Ic]=n.sessionStorage),!Ls(n.global)&&Dc(r,Ws)&&(Xs(e),i[Ws]=n.global),i}}};function Bc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Jc(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Hc(Object(r),!0).forEach((function(t){Bc(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hc(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Gc(e,t){const r=function(e){return Array.prototype.slice.call(window.document.querySelectorAll("script")).find((t=>t.src===e))}(e);if(void 0!==r){const e=null==r?void 0:r.getAttribute("status");if("loaded"===e)return Promise.resolve(r);if("loading"===e)return new Promise(((e,t)=>{r.addEventListener("load",(()=>e(r))),r.addEventListener("error",(e=>t(e)))}))}return new Promise(((r,n)=>{var i,o;const a=window.document.createElement("script");a.type="text/javascript",a.src=function(e,t){let r=e;return r.startsWith("http")||(r=`https://${(null==t?void 0:t.www)?"www.":""}${r}`),(null==t?void 0:t.min)?r+=".min.js":(null==t?void 0:t.js)&&(r+=".js"),(null==t?void 0:t.query)&&(r+="?"+t.query),r}(e,t),a.async=!0,a.setAttribute("status","loading");for(const[e,r]of Object.entries(null!==(i=null==t?void 0:t.attributes)&&void 0!==i?i:{}))a.setAttribute(e,r);a.onload=()=>{a.onerror=a.onload=null,a.setAttribute("status","loaded"),r(a)},a.onerror=()=>{a.onerror=a.onload=null,a.setAttribute("status","error"),n(new Error(`Failed to load ${e}`))};const s=window.document.getElementsByTagName("script")[0];null===(o=s.parentElement)||void 0===o||o.insertBefore(a,s)}))}var Wc=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const Vc={id:"tag",handle(e,t){return Wc(this,void 0,void 0,(function*(){fu(t,e)&&function(e,t,r={}){let n;try{n=JSON.parse(e)}catch(t){n={code:e,lang:"javascript"}}const i=r.debug||!1;if(Zu())if("javascript"===n.lang)!function(e,t){const r=`jitsu_event_${dd()}`;window[r]=t;const n=`(function(){\n const event = ${r};\n ${e}\n })()`;try{Kc(n)}catch(e){console.error(`[JITSU] Error executing JS code: ${e.message}. Code: `,n)}finally{delete window[r]}}(n.code,t);else{const e=document.createElement("span");e.innerHTML=function(e,t){return e.replace(/{{\s*event\s*}}/g,JSON.stringify(t))}(n.code,t),document.body.insertAdjacentElement("beforeend",e);e.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");t.type=t.type||"text/javascript",e.hasAttribute("src")&&(t.src=e.src),t.text=e.text,i&&console.log("[JITSU] Executing script"+(e.hasAttribute("src")?` ${e.src}`:""),t.text),document.head.appendChild(t),document.head.removeChild(t)}))}else i&&console.log("[JITSU] insertTags(): cannot insert tags in non-browser environment")}(e.code,t)}))}};let Yc="ve".split("").reverse().join("");const Kc=globalThis[Yc+"al"];var Qc=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const Xc="cdn.lr-ingest.io/",Zc={id:"logrocket",handle(e,t){return Qc(this,void 0,void 0,(function*(){if(!fu(t,e))return;!function(e){Qc(this,void 0,void 0,(function*(){"fresh"===eu()&&(tu("loading"),Gc(`${Xc}LogRocket`,{min:!0,attributes:{crossOrigin:"anonymous"}}).then((()=>{if(window.LogRocket){try{window.LogRocket.init(e)}catch(t){console.warn(`LogRocket (id=${e}) init failed: ${t.message}`,t),tu("failed")}tu("loaded"),nu(window.LogRocket)}})).catch((t=>{console.warn(`LogRocket (id=${e}) init failed: ${t.message}`,t),tu("failed")})))}))}(e.appId);ru().push((e=>{"identify"===t.type&&t.userId&&e.identify(t.userId,t.traits||{})})),"loaded"===eu()&&nu(window.LogRocket)}))}};function eu(){return window.__jitsuLrState||"fresh"}function tu(e){window.__jitsuLrState=e}function ru(){return window.__jitsuLrQueue||(window.__jitsuLrQueue=[])}function nu(e){const t=ru();for(;t.length>0;){const r=t.shift();try{const t=r(e);t&&t.catch((e=>console.warn(`Async LogRocket method failed: ${e.message}`,e)))}catch(e){console.warn(`LogRocket method failed: ${e.message}`,e)}}}var iu=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const ou={id:"gtm",handle(e,t){return iu(this,void 0,void 0,(function*(){var r,n,i,o,a,s,l,c,u,d,h,f,p,g;const m=!!e.debug;if(!fu(t,e))return;yield function(e,t){return iu(this,void 0,void 0,(function*(){if("fresh"!==(window.__jitsuGtmState||"fresh"))return;au("loading");const r=e.dataLayerName||"dataLayer",n=e.containerId;!function(e,r,i){e[r]=e[r]||[],e[r].push({user_id:t.userId}),e[r].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});Gc("googletagmanager.com/gtm",{www:!0,js:!0,query:"id="+i+("dataLayer"!=r?"&l="+r:"")}).then((()=>{au("loaded")})).catch((e=>{console.warn(`GTM (containerId=${n}) init failed: ${e.message}`,e),au("failed")}))}(window,r,n)}))}(e,t);const v=window[e.dataLayerName||"dataLayer"],y=Object.assign(Object.assign({},(null==t?void 0:t.traits)||{}),(null===(r=null==t?void 0:t.context)||void 0===r?void 0:r.traits)||{}),b=function(e,...t){return Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e))))}(y,"id","userId","user_id","anonymousId","userId");m&&console.debug("GTM plugin will be applied to following payload",t);const w={email_address:y.email},_=Object.assign(Object.assign(Object.assign(Object.assign({},t.userId?{user_id:t.userId,userId:t.userId}:{}),t.anonymousId?{anonymousId:t.anonymousId}:{}),b),{user_data:Object.keys(w).length>0?w:void 0});m&&console.debug("GTM plugin will set following user-related data layer vars",_);const S=t.properties||{},E={page_location:S.url||(null===(i=null===(n=t.context)||void 0===n?void 0:n.page)||void 0===i?void 0:i.url),page_title:S.title||(null===(a=null===(o=t.context)||void 0===o?void 0:o.page)||void 0===a?void 0:a.title),page_path:S.path||(null===(l=null===(s=t.context)||void 0===s?void 0:s.page)||void 0===l?void 0:l.path),page_hash:S.hash||(null===(u=null===(c=t.context)||void 0===c?void 0:c.page)||void 0===u?void 0:u.hash),page_search:S.search||(null===(h=null===(d=t.context)||void 0===d?void 0:d.page)||void 0===h?void 0:h.search),page_referrer:null!==(g=null===(p=null===(f=null==t?void 0:t.context)||void 0===f?void 0:f.page)||void 0===p?void 0:p.referrer)&&void 0!==g?g:""};m&&console.debug("GTM plugin will set following context (page) related data layer vars",_);const k=e=>{v.push(e),m&&console.debug("GTM plugin will push following data to dataLayer",e)};switch(t.type){case"page":k(Object.assign(Object.assign({event:"page_view"},E),_));break;case"track":const{properties:e}=t;k(Object.assign(Object.assign(Object.assign({event:t.event},E),e),_));break;case"identify":const{traits:r}=t;k(Object.assign(Object.assign(Object.assign({event:"identify"},E),r),_))}v.push((function(){this.reset()}))}))}};function au(e){window.__jitsuGtmState=e}var su=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const lu=[new Uint8Array([109,111,99,46,114,101,103,97,110,97,109,103,97,116,101,108,103,111,111,103]),new Uint8Array([103,97,116,103]),new Uint8Array([115,106])];function cu(e){return(new TextDecoder).decode(e)}const uu={id:"ga4-tag",handle(e,t){return su(this,void 0,void 0,(function*(){var r,n;if(!fu(t,e))return;yield function(e,t){return su(this,void 0,void 0,(function*(){if("fresh"!==(window.__jitsuGa4State||"fresh"))return;du("loading");const r=e.dataLayerName||"dataLayer",n="dataLayer"!==r?"&l="+r:"",i=e.measurementIds;window[r]=window[r]||[];const o=function(){window[r].push(arguments)};o("js",new Date),o("config",i,Object.assign(Object.assign({},t.userId?{user_id:t.userId}:{}),e.autoPageView?{}:{send_page_view:!1})),Gc(lu.map((e=>e.reverse())).map(cu).join("/"),{query:`id=${i}${n}`,www:!0}).then((()=>{du("loaded")})).catch((t=>{console.warn(`GA4 (containerId=${e.measurementIds}) init failed: ${t.message}`,t),du("failed")}))}))}(e,t);const i=window[e.dataLayerName||"dataLayer"],o=function(){i.push(arguments)},a=Object.assign(Object.assign({},t.userId?{user_id:t.userId,userId:t.userId}:{}),t.anonymousId?{anonymousId:t.anonymousId}:{});switch(t.userId&&o("set",{user_id:t.userId}),t.type){case"page":if(e.autoPageView){console.log("autoPageView");break}const{properties:i,context:s}=t;o("event","page_view",Object.assign({page_location:i.url,page_title:i.title,page_path:i.path,page_hash:i.hash,page_search:i.search,page_referrer:null!==(n=null===(r=null==s?void 0:s.page)||void 0===r?void 0:r.referrer)&&void 0!==n?n:""},a));break;case"track":const{properties:l}=t,c=Object.assign(Object.assign({},l),a);o("event",t.event,c);break;case"identify":const{traits:u}=t;o("event","identify",Object.assign(Object.assign({},u),a))}}))}};function du(e){window.__jitsuGa4State=e}function hu(e,t){return"*"===e||e.toLowerCase().trim()===(t||"").trim().toLowerCase()}function fu(e,t){const{hosts:r="*",events:n="*"}=t;try{const t=Array.isArray(n)?n:n.split("\n");return!(!(Array.isArray(r)?r:r.split("\n")).find((t=>{var r,n,i,o;return i=t,o=null===(n=null===(r=e.context)||void 0===r?void 0:r.page)||void 0===n?void 0:n.host,"*"===i||(o=o||"",i.startsWith("*.")?o.endsWith(i.substring(1)):i===o)}))||!t.find((t=>hu(t,e.type)))&&!t.find((t=>hu(t,e.event))))}catch(e){throw console.warn(`Failed to apply filters: ${e.message}. Typeof events: ${typeof n}, typeof hosts: ${typeof r}. Values`,n,r),new Error(`Failed to apply filters: ${e.message}. Typeof events: ${typeof n}, typeof hosts: ${typeof r}`)}}const pu={[Vc.id]:Vc,[ou.id]:ou,[uu.id]:uu,[Zc.id]:Zc},gu="2.0.0",mu="@jitsu/js",vu="myshopify.com,ac,com.ac,edu.ac,gov.ac,net.ac,mil.ac,org.ac,ad,nom.ad,ae,co.ae,net.ae,org.ae,sch.ae,ac.ae,gov.ae,mil.ae,aero,af,gov.af,com.af,org.af,net.af,edu.af,ag,com.ag,org.ag,net.ag,co.ag,nom.ag,ai,off.ai,com.ai,net.ai,org.ai,al,com.al,edu.al,gov.al,mil.al,net.al,org.al,am,co.am,com.am,commune.am,net.am,org.am,ao,ed.ao,gv.ao,og.ao,co.ao,pb.ao,it.ao,aq,ar,bet.ar,com.ar,coop.ar,edu.ar,gob.ar,gov.ar,int.ar,mil.ar,musica.ar,mutual.ar,net.ar,org.ar,senasa.ar,tur.ar,arpa,e164.arpa,in-addr.arpa,ip6.arpa,iris.arpa,uri.arpa,urn.arpa,as,gov.as,asia,at,ac.at,co.at,gv.at,or.at,sth.ac.at,au,com.au,net.au,org.au,edu.au,gov.au,asn.au,id.au,act.au,nsw.au,nt.au,qld.au,sa.au,tas.au,vic.au,wa.au,aw,com.aw,ax,az,com.az,net.az,int.az,gov.az,org.az,edu.az,info.az,pp.az,mil.az,name.az,pro.az,biz.az,ba,com.ba,edu.ba,gov.ba,mil.ba,net.ba,org.ba,bb,biz.bb,co.bb,com.bb,edu.bb,gov.bb,info.bb,net.bb,org.bb,store.bb,tv.bb,bd,be,ac.be,bf,gov.bf,bg,a.bg,b.bg,c.bg,d.bg,e.bg,f.bg,g.bg,h.bg,i.bg,j.bg,k.bg,l.bg,m.bg,n.bg,o.bg,p.bg,q.bg,r.bg,s.bg,t.bg,u.bg,v.bg,w.bg,x.bg,y.bg,z.bg,0.bg,1.bg,2.bg,3.bg,4.bg,5.bg,6.bg,7.bg,8.bg,9.bg,bh,com.bh,edu.bh,net.bh,org.bh,gov.bh,bi,co.bi,com.bi,edu.bi,or.bi,org.bi,biz,bj,africa.bj,agro.bj,architectes.bj,assur.bj,avocats.bj,co.bj,com.bj,eco.bj,econo.bj,edu.bj,info.bj,loisirs.bj,money.bj,net.bj,org.bj,ote.bj,resto.bj,restaurant.bj,tourism.bj,univ.bj,bm,com.bm,edu.bm,gov.bm,net.bm,org.bm,bn,com.bn,edu.bn,gov.bn,net.bn,org.bn,bo,com.bo,edu.bo,gob.bo,int.bo,org.bo,net.bo,mil.bo,tv.bo,web.bo,br,9guacu.br,abc.br,adm.br,adv.br,agr.br,aju.br,am.br,anani.br,aparecida.br,app.br,arq.br,art.br,ato.br,b.br,barueri.br,belem.br,bhz.br,bib.br,bio.br,blog.br,bmd.br,boavista.br,bsb.br,campinagrande.br,campinas.br,caxias.br,cim.br,cng.br,cnt.br,com.br,contagem.br,coop.br,coz.br,cri.br,cuiaba.br,curitiba.br,def.br,des.br,det.br,dev.br,ecn.br,eco.br,edu.br,emp.br,enf.br,eng.br,esp.br,etc.br,eti.br,far.br,feira.br,flog.br,floripa.br,fm.br,fnd.br,fortal.br,fot.br,foz.br,fst.br,g12.br,geo.br,ggf.br,goiania.br,gov.br,gru.br,imb.br,ind.br,inf.br,jab.br,jampa.br,jdf.br,joinville.br,jor.br,jus.br,leg.br,lel.br,log.br,londrina.br,macapa.br,maceio.br,manaus.br,maringa.br,mat.br,med.br,mil.br,morena.br,mp.br,mus.br,natal.br,net.br,niteroi.br,nom.br,not.br,ntr.br,odo.br,ong.br,org.br,osasco.br,palmas.br,poa.br,ppg.br,pro.br,psc.br,psi.br,pvh.br,qsl.br,radio.br,rec.br,recife.br,rep.br,ribeirao.br,rio.br,riobranco.br,riopreto.br,salvador.br,sampa.br,santamaria.br,santoandre.br,saobernardo.br,saogonca.br,seg.br,sjc.br,slg.br,slz.br,sorocaba.br,srv.br,taxi.br,tc.br,tec.br,teo.br,the.br,tmp.br,trd.br,tur.br,tv.br,udi.br,vet.br,vix.br,vlog.br,wiki.br,zlg.br,bs,com.bs,net.bs,org.bs,edu.bs,gov.bs,bt,com.bt,edu.bt,gov.bt,net.bt,org.bt,bv,bw,co.bw,org.bw,by,gov.by,mil.by,com.by,of.by,bz,com.bz,net.bz,org.bz,edu.bz,gov.bz,ca,ab.ca,bc.ca,mb.ca,nb.ca,nf.ca,nl.ca,ns.ca,nt.ca,nu.ca,on.ca,pe.ca,qc.ca,sk.ca,yk.ca,gc.ca,cat,cc,cd,gov.cd,cf,cg,ch,ci,org.ci,or.ci,com.ci,co.ci,edu.ci,ed.ci,ac.ci,net.ci,go.ci,asso.ci,aéroport.ci,int.ci,presse.ci,md.ci,gouv.ci,ck,cl,co.cl,gob.cl,gov.cl,mil.cl,cm,co.cm,com.cm,gov.cm,net.cm,cn,ac.cn,com.cn,edu.cn,gov.cn,net.cn,org.cn,mil.cn,co,arts.co,com.co,edu.co,firm.co,gov.co,info.co,int.co,mil.co,net.co,nom.co,org.co,rec.co,web.co,com,coop,cr,ac.cr,co.cr,ed.cr,fi.cr,go.cr,or.cr,sa.cr,cu,com.cu,edu.cu,org.cu,net.cu,gov.cu,inf.cu,cv,com.cv,edu.cv,int.cv,nome.cv,org.cv,cw,com.cw,edu.cw,net.cw,org.cw,cx,gov.cx,cy,ac.cy,biz.cy,com.cy,ekloges.cy,gov.cy,ltd.cy,mil.cy,net.cy,org.cy,press.cy,pro.cy,tm.cy,cz,de,dj,dk,dm,com.dm,net.dm,org.dm,edu.dm,gov.dm,do,art.do,com.do,edu.do,gob.do,gov.do,mil.do,net.do,org.do,sld.do,web.do,dz,art.dz,asso.dz,com.dz,edu.dz,gov.dz,org.dz,net.dz,pol.dz,soc.dz,tm.dz,ec,com.ec,info.ec,net.ec,fin.ec,k12.ec,med.ec,pro.ec,org.ec,edu.ec,gov.ec,gob.ec,mil.ec,edu,ee,edu.ee,gov.ee,riik.ee,lib.ee,med.ee,com.ee,pri.ee,aip.ee,org.ee,fie.ee,eg,com.eg,edu.eg,eun.eg,gov.eg,mil.eg,name.eg,net.eg,org.eg,sci.eg,er,es,com.es,nom.es,org.es,gob.es,edu.es,et,com.et,gov.et,org.et,edu.et,biz.et,name.et,info.et,net.et,eu,fi,aland.fi,fj,ac.fj,biz.fj,com.fj,gov.fj,info.fj,mil.fj,name.fj,net.fj,org.fj,pro.fj,fk,com.fm,edu.fm,net.fm,org.fm,fm,fo,fr,asso.fr,com.fr,gouv.fr,nom.fr,prd.fr,tm.fr,aeroport.fr,avocat.fr,avoues.fr,cci.fr,chambagri.fr,chirurgiens-dentistes.fr,experts-comptables.fr,geometre-expert.fr,greta.fr,huissier-justice.fr,medecin.fr,notaires.fr,pharmacien.fr,port.fr,veterinaire.fr,ga,gb,edu.gd,gov.gd,gd,ge,com.ge,edu.ge,gov.ge,org.ge,mil.ge,net.ge,pvt.ge,gf,gg,co.gg,net.gg,org.gg,gh,com.gh,edu.gh,gov.gh,org.gh,mil.gh,gi,com.gi,ltd.gi,gov.gi,mod.gi,edu.gi,org.gi,gl,co.gl,com.gl,edu.gl,net.gl,org.gl,gm,gn,ac.gn,com.gn,edu.gn,gov.gn,org.gn,net.gn,gov,gp,com.gp,net.gp,mobi.gp,edu.gp,org.gp,asso.gp,gq,gr,com.gr,edu.gr,net.gr,org.gr,gov.gr,gs,gt,com.gt,edu.gt,gob.gt,ind.gt,mil.gt,net.gt,org.gt,gu,com.gu,edu.gu,gov.gu,guam.gu,info.gu,net.gu,org.gu,web.gu,gw,gy,co.gy,com.gy,edu.gy,gov.gy,net.gy,org.gy,hk,com.hk,edu.hk,gov.hk,idv.hk,net.hk,org.hk,hm,hn,com.hn,edu.hn,org.hn,net.hn,mil.hn,gob.hn,hr,iz.hr,from.hr,name.hr,com.hr,ht,com.ht,shop.ht,firm.ht,info.ht,adult.ht,net.ht,pro.ht,org.ht,med.ht,art.ht,coop.ht,pol.ht,asso.ht,edu.ht,rel.ht,gouv.ht,perso.ht,hu,co.hu,info.hu,org.hu,priv.hu,sport.hu,tm.hu,2000.hu,agrar.hu,bolt.hu,casino.hu,city.hu,erotica.hu,erotika.hu,film.hu,forum.hu,games.hu,hotel.hu,ingatlan.hu,jogasz.hu,konyvelo.hu,lakas.hu,media.hu,news.hu,reklam.hu,sex.hu,shop.hu,suli.hu,szex.hu,tozsde.hu,utazas.hu,video.hu,id,ac.id,biz.id,co.id,desa.id,go.id,mil.id,my.id,net.id,or.id,ponpes.id,sch.id,web.id,ie,gov.ie,il,ac.il,co.il,gov.il,idf.il,k12.il,muni.il,net.il,org.il,im,ac.im,co.im,com.im,ltd.co.im,net.im,org.im,plc.co.im,tt.im,tv.im,in,5g.in,6g.in,ac.in,ai.in,am.in,bihar.in,biz.in,business.in,ca.in,cn.in,co.in,com.in,coop.in,cs.in,delhi.in,dr.in,edu.in,er.in,firm.in,gen.in,gov.in,gujarat.in,ind.in,info.in,int.in,internet.in,io.in,me.in,mil.in,net.in,nic.in,org.in,pg.in,post.in,pro.in,res.in,travel.in,tv.in,uk.in,up.in,us.in,info,int,eu.int,io,com.io,iq,gov.iq,edu.iq,mil.iq,com.iq,org.iq,net.iq,ir,ac.ir,co.ir,gov.ir,id.ir,net.ir,org.ir,sch.ir,is,net.is,com.is,edu.is,gov.is,org.is,int.is,it,gov.it,edu.it,je,co.je,net.je,org.je,jm,jo,com.jo,org.jo,net.jo,edu.jo,sch.jo,gov.jo,mil.jo,name.jo,jobs,jp,ac.jp,ad.jp,co.jp,ed.jp,go.jp,gr.jp,lg.jp,ne.jp,or.jp,ke,ac.ke,co.ke,go.ke,info.ke,me.ke,mobi.ke,ne.ke,or.ke,sc.ke,kg,org.kg,net.kg,com.kg,edu.kg,gov.kg,mil.kg,kh,ki,edu.ki,biz.ki,net.ki,org.ki,gov.ki,info.ki,com.ki,km,org.km,nom.km,gov.km,prd.km,tm.km,edu.km,mil.km,ass.km,com.km,kn,net.kn,org.kn,edu.kn,gov.kn,kp,com.kp,edu.kp,gov.kp,org.kp,rep.kp,tra.kp,kr,ac.kr,co.kr,es.kr,go.kr,hs.kr,kg.kr,mil.kr,ms.kr,ne.kr,or.kr,pe.kr,re.kr,sc.kr,kw,com.kw,edu.kw,emb.kw,gov.kw,ind.kw,net.kw,org.kw,ky,com.ky,edu.ky,net.ky,org.ky,kz,org.kz,edu.kz,net.kz,gov.kz,mil.kz,com.kz,la,int.la,net.la,info.la,edu.la,gov.la,per.la,com.la,org.la,lb,com.lb,edu.lb,gov.lb,net.lb,org.lb,lc,com.lc,net.lc,co.lc,org.lc,edu.lc,gov.lc,li,lk,gov.lk,sch.lk,net.lk,int.lk,com.lk,org.lk,edu.lk,ngo.lk,soc.lk,web.lk,ltd.lk,assn.lk,grp.lk,hotel.lk,ac.lk,lr,com.lr,edu.lr,gov.lr,org.lr,net.lr,ls,ac.ls,biz.ls,co.ls,edu.ls,gov.ls,info.ls,net.ls,org.ls,sc.ls,lt,gov.lt,lu,lv,com.lv,edu.lv,gov.lv,org.lv,mil.lv,id.lv,net.lv,asn.lv,conf.lv,ly,com.ly,net.ly,gov.ly,plc.ly,edu.ly,sch.ly,med.ly,org.ly,id.ly,ma,co.ma,net.ma,gov.ma,org.ma,ac.ma,press.ma,mc,tm.mc,asso.mc,md,me,co.me,net.me,org.me,edu.me,ac.me,gov.me,its.me,priv.me,mg,org.mg,nom.mg,gov.mg,prd.mg,tm.mg,edu.mg,mil.mg,com.mg,co.mg,mh,mil,mk,com.mk,org.mk,net.mk,edu.mk,gov.mk,inf.mk,name.mk,ml,com.ml,edu.ml,gouv.ml,gov.ml,net.ml,org.ml,presse.ml,mm,mn,gov.mn,edu.mn,org.mn,mo,com.mo,net.mo,org.mo,edu.mo,gov.mo,mobi,mp,mq,mr,gov.mr,ms,com.ms,edu.ms,gov.ms,net.ms,org.ms,mt,com.mt,edu.mt,net.mt,org.mt,mu,com.mu,net.mu,org.mu,gov.mu,ac.mu,co.mu,or.mu,museum,mv,aero.mv,biz.mv,com.mv,coop.mv,edu.mv,gov.mv,info.mv,int.mv,mil.mv,museum.mv,name.mv,net.mv,org.mv,pro.mv,mw,ac.mw,biz.mw,co.mw,com.mw,coop.mw,edu.mw,gov.mw,int.mw,museum.mw,net.mw,org.mw,mx,com.mx,org.mx,gob.mx,edu.mx,net.mx,my,biz.my,com.my,edu.my,gov.my,mil.my,name.my,net.my,org.my,mz,ac.mz,adv.mz,co.mz,edu.mz,gov.mz,mil.mz,net.mz,org.mz,na,info.na,pro.na,name.na,school.na,or.na,dr.na,us.na,mx.na,ca.na,in.na,cc.na,tv.na,ws.na,mobi.na,co.na,com.na,org.na,name,nc,asso.nc,nom.nc,ne,net,nf,com.nf,net.nf,per.nf,rec.nf,web.nf,arts.nf,firm.nf,info.nf,other.nf,store.nf,ng,com.ng,edu.ng,gov.ng,i.ng,mil.ng,mobi.ng,name.ng,net.ng,org.ng,sch.ng,ni,ac.ni,biz.ni,co.ni,com.ni,edu.ni,gob.ni,in.ni,info.ni,int.ni,mil.ni,net.ni,nom.ni,org.ni,web.ni,nl,no,fhs.no,vgs.no,fylkesbibl.no,folkebibl.no,museum.no,idrett.no,priv.no,mil.no,stat.no,dep.no,kommune.no,herad.no,np,nr,biz.nr,info.nr,gov.nr,edu.nr,org.nr,net.nr,com.nr,nu,nz,ac.nz,co.nz,cri.nz,geek.nz,gen.nz,govt.nz,health.nz,iwi.nz,kiwi.nz,maori.nz,mil.nz,māori.nz,net.nz,org.nz,parliament.nz,school.nz,om,co.om,com.om,edu.om,gov.om,med.om,museum.om,net.om,org.om,pro.om,onion,org,pa,ac.pa,gob.pa,com.pa,org.pa,sld.pa,edu.pa,net.pa,ing.pa,abo.pa,med.pa,nom.pa,pe,edu.pe,gob.pe,nom.pe,mil.pe,org.pe,com.pe,net.pe,pf,com.pf,org.pf,edu.pf,pg,ph,com.ph,net.ph,org.ph,gov.ph,edu.ph,ngo.ph,mil.ph,i.ph,pk,com.pk,net.pk,edu.pk,org.pk,fam.pk,biz.pk,web.pk,gov.pk,gob.pk,gok.pk,gon.pk,gop.pk,gos.pk,info.pk,pl,com.pl,net.pl,org.pl,aid.pl,agro.pl,atm.pl,auto.pl,biz.pl,edu.pl,gmina.pl,gsm.pl,info.pl,mail.pl,miasta.pl,media.pl,mil.pl,nieruchomosci.pl,nom.pl,pc.pl,powiat.pl,priv.pl,realestate.pl,rel.pl,sex.pl,shop.pl,sklep.pl,sos.pl,szkola.pl,targi.pl,tm.pl,tourism.pl,travel.pl,turystyka.pl,pm,pn,gov.pn,co.pn,org.pn,edu.pn,net.pn,post,pr,com.pr,net.pr,org.pr,gov.pr,edu.pr,isla.pr,pro.pr,biz.pr,info.pr,name.pr,est.pr,prof.pr,ac.pr,pro,aaa.pro,aca.pro,acct.pro,avocat.pro,bar.pro,cpa.pro,eng.pro,jur.pro,law.pro,med.pro,recht.pro,ps,edu.ps,gov.ps,sec.ps,plo.ps,com.ps,org.ps,net.ps,pt,net.pt,gov.pt,org.pt,edu.pt,int.pt,publ.pt,com.pt,nome.pt,pw,co.pw,ne.pw,or.pw,ed.pw,go.pw,belau.pw,py,com.py,coop.py,edu.py,gov.py,mil.py,net.py,org.py,qa,com.qa,edu.qa,gov.qa,mil.qa,name.qa,net.qa,org.qa,sch.qa,re,asso.re,com.re,nom.re,ro,arts.ro,com.ro,firm.ro,info.ro,nom.ro,nt.ro,org.ro,rec.ro,store.ro,tm.ro,www.ro,rs,ac.rs,co.rs,edu.rs,gov.rs,in.rs,org.rs,ru,rw,ac.rw,co.rw,coop.rw,gov.rw,mil.rw,net.rw,org.rw,sa,com.sa,net.sa,org.sa,gov.sa,med.sa,pub.sa,edu.sa,sch.sa,sb,com.sb,edu.sb,gov.sb,net.sb,org.sb,sc,com.sc,gov.sc,net.sc,org.sc,edu.sc,sd,com.sd,net.sd,org.sd,edu.sd,med.sd,tv.sd,gov.sd,info.sd,se,a.se,ac.se,b.se,bd.se,brand.se,c.se,d.se,e.se,f.se,fh.se,fhsk.se,fhv.se,g.se,h.se,i.se,k.se,komforb.se,kommunalforbund.se,komvux.se,l.se,lanbib.se,m.se,n.se,naturbruksgymn.se,o.se,org.se,p.se,parti.se,pp.se,press.se,r.se,s.se,t.se,tm.se,u.se,w.se,x.se,y.se,z.se,sg,com.sg,net.sg,org.sg,gov.sg,edu.sg,per.sg,sh,com.sh,net.sh,gov.sh,org.sh,mil.sh,si,sj,sk,sl,com.sl,net.sl,edu.sl,gov.sl,org.sl,sm,sn,art.sn,com.sn,edu.sn,gouv.sn,org.sn,perso.sn,univ.sn,so,com.so,edu.so,gov.so,me.so,net.so,org.so,sr,ss,biz.ss,com.ss,edu.ss,gov.ss,me.ss,net.ss,org.ss,sch.ss,st,co.st,com.st,consulado.st,edu.st,embaixada.st,mil.st,net.st,org.st,principe.st,saotome.st,store.st,su,sv,com.sv,edu.sv,gob.sv,org.sv,red.sv,sx,gov.sx,sy,edu.sy,gov.sy,net.sy,mil.sy,com.sy,org.sy,sz,co.sz,ac.sz,org.sz,tc,td,tel,tf,tg,th,ac.th,co.th,go.th,in.th,mi.th,net.th,or.th,tj,ac.tj,biz.tj,co.tj,com.tj,edu.tj,go.tj,gov.tj,int.tj,mil.tj,name.tj,net.tj,nic.tj,org.tj,test.tj,web.tj,tk,tl,gov.tl,tm,com.tm,co.tm,org.tm,net.tm,nom.tm,gov.tm,mil.tm,edu.tm,tn,com.tn,ens.tn,fin.tn,gov.tn,ind.tn,info.tn,intl.tn,mincom.tn,nat.tn,net.tn,org.tn,perso.tn,tourism.tn,to,com.to,gov.to,net.to,org.to,edu.to,mil.to,tr,av.tr,bbs.tr,bel.tr,biz.tr,com.tr,dr.tr,edu.tr,gen.tr,gov.tr,info.tr,mil.tr,k12.tr,kep.tr,name.tr,net.tr,org.tr,pol.tr,tel.tr,tsk.tr,tv.tr,web.tr,nc.tr,tt,co.tt,com.tt,org.tt,net.tt,biz.tt,info.tt,pro.tt,int.tt,coop.tt,jobs.tt,mobi.tt,travel.tt,museum.tt,aero.tt,name.tt,gov.tt,edu.tt,tv,tw,edu.tw,gov.tw,mil.tw,com.tw,net.tw,org.tw,idv.tw,game.tw,ebiz.tw,club.tw,tz,ac.tz,co.tz,go.tz,hotel.tz,info.tz,me.tz,mil.tz,mobi.tz,ne.tz,or.tz,sc.tz,tv.tz,ua,com.ua,edu.ua,gov.ua,in.ua,net.ua,org.ua,ug,co.ug,or.ug,ac.ug,sc.ug,go.ug,ne.ug,com.ug,org.ug,uk,ac.uk,co.uk,gov.uk,ltd.uk,me.uk,net.uk,nhs.uk,org.uk,plc.uk,police.uk,us,dni.us,fed.us,isa.us,kids.us,nsn.us,ak.us,al.us,ar.us,as.us,az.us,ca.us,co.us,ct.us,dc.us,de.us,fl.us,ga.us,gu.us,hi.us,ia.us,id.us,il.us,in.us,ks.us,ky.us,la.us,ma.us,md.us,me.us,mi.us,mn.us,mo.us,ms.us,mt.us,nc.us,nd.us,ne.us,nh.us,nj.us,nm.us,nv.us,ny.us,oh.us,ok.us,or.us,pa.us,pr.us,ri.us,sc.us,sd.us,tn.us,tx.us,ut.us,vi.us,vt.us,va.us,wa.us,wi.us,wv.us,wy.us,uy,com.uy,edu.uy,gub.uy,mil.uy,net.uy,org.uy,uz,co.uz,com.uz,net.uz,org.uz,va,vc,com.vc,net.vc,org.vc,gov.vc,mil.vc,edu.vc,ve,arts.ve,bib.ve,co.ve,com.ve,e12.ve,edu.ve,firm.ve,gob.ve,gov.ve,info.ve,int.ve,mil.ve,net.ve,nom.ve,org.ve,rar.ve,rec.ve,store.ve,tec.ve,web.ve,vg,vi,co.vi,com.vi,k12.vi,net.vi,org.vi,vn,ac.vn,ai.vn,biz.vn,com.vn,edu.vn,gov.vn,health.vn,id.vn,info.vn,int.vn,io.vn,name.vn,net.vn,org.vn,pro.vn,vu,com.vu,edu.vu,net.vu,org.vu,wf,ws,com.ws,net.ws,org.ws,gov.ws,edu.ws,yt,ye,com.ye,edu.ye,gov.ye,net.ye,mil.ye,org.ye,ac.za,agric.za,alt.za,co.za,edu.za,gov.za,grondar.za,law.za,mil.za,net.za,ngo.za,nic.za,nis.za,nom.za,org.za,school.za,tm.za,web.za,zm,ac.zm,biz.zm,co.zm,com.zm,edu.zm,gov.zm,info.zm,mil.zm,net.zm,org.zm,sch.zm,zw,ac.zw,co.zw,gov.zw,mil.zw,org.zw".split(","),yu={};vu.forEach((e=>{yu[e]=!0}));const bu=yu;function wu(e){const[t]=e.split(":"),r=t.split(".");if("localhost"===r[r.length-1]||r.length<2)return r[r.length-1];{const e=r[r.length-2]+"."+r[r.length-1];return r.length>2&&bu[e]?r[r.length-3]+"."+e:e}}class _u{constructor(e){this.selfOptions=e||{},this.pipes={}}options(e){return e&&(this.selfOptions=e),this.selfOptions}pipe(e,t){let r=t;if("string"==typeof e){if(void 0===r)return this.pipes[e];this.pipes[e]=r}if(e&&e.name){if(r=e,r.processor===this)return r;this.pipes[r.name]=r}return r.processor=this,r}process(e,t){let r=e;r.options=this.options();let n,i=t||e.pipe||"default";for(;i;)void 0!==r.nextAfterChildren&&(r.next=r.nextAfterChildren,r.nextAfterChildren=null),"string"==typeof i&&(i=this.pipe(i)),i.process(r),n=i,i=null,r&&r.next&&(r=r.next,i=r.pipe||n);return r.hasResult?r.result:void 0}}class Su{constructor(e){this.name=e,this.filters=[]}process(e){if(!this.processor)throw new Error("add this pipe to a processor before using it");const t=this.debug,r=this.filters.length,n=e;for(let e=0;e<r;e++){const r=this.filters[e];if(t&&this.log(`filter: ${r.filterName}`),r(n),"object"==typeof n&&n.exiting){n.exiting=!1;break}}!n.next&&this.resultCheck&&this.resultCheck(n)}log(e){console.log(`[jsondiffpatch] ${this.name} pipe, ${e}`)}append(...e){return this.filters.push(...e),this}prepend(...e){return this.filters.unshift(...e),this}indexOf(e){if(!e)throw new Error("a filter name is required");for(let t=0;t<this.filters.length;t++){if(this.filters[t].filterName===e)return t}throw new Error(`filter not found: ${e}`)}list(){return this.filters.map((e=>e.filterName))}after(e,...t){const r=this.indexOf(e);return this.filters.splice(r+1,0,...t),this}before(e,...t){const r=this.indexOf(e);return this.filters.splice(r,0,...t),this}replace(e,...t){const r=this.indexOf(e);return this.filters.splice(r,1,...t),this}remove(e){const t=this.indexOf(e);return this.filters.splice(t,1),this}clear(){return this.filters.length=0,this}shouldHaveResult(e){if(!1!==e){if(!this.resultCheck)return this.resultCheck=e=>{if(!e.hasResult){console.log(e);const t=new Error(`${this.name} failed`);throw t.noResult=!0,t}},this}else this.resultCheck=null}}class Eu{setResult(e){return this.result=e,this.hasResult=!0,this}exit(){return this.exiting=!0,this}push(e,t){return e.parent=this,void 0!==t&&(e.childName=t),e.root=this.root||this,e.options=e.options||this.options,this.children?(this.children[this.children.length-1].next=e,this.children.push(e)):(this.children=[e],this.nextAfterChildren=this.next||null,this.next=e),e.next=this,this}}class ku extends Eu{constructor(e,t){super(),this.left=e,this.right=t,this.pipe="diff"}setResult(e){return super.setResult(e)}}class xu extends Eu{constructor(e,t){super(),this.left=e,this.delta=t,this.pipe="patch"}}const Pu=function(e){if(e.left!==e.right)if(void 0!==e.left)if(void 0!==e.right){if("function"==typeof e.left||"function"==typeof e.right)throw new Error("functions are not supported");if(e.leftType=null===e.left?"null":typeof e.left,e.rightType=null===e.right?"null":typeof e.right,e.leftType===e.rightType)if("boolean"!==e.leftType&&"number"!==e.leftType&&"string"!==e.leftType){if("object"===e.leftType&&(e.leftIsArray=Array.isArray(e.left)),"object"===e.rightType&&(e.rightIsArray=Array.isArray(e.right)),e.leftIsArray===e.rightIsArray)return e.leftIsArray&&e.rightIsArray?function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(e.left,e.right)?void e.setResult(void 0).exit():void e.setResult([e.left,e.right]).exit():void(e.left instanceof RegExp&&(e.right instanceof RegExp?e.setResult([e.left.toString(),e.right.toString()]).exit():e.setResult([e.left,e.right]).exit()));e.setResult([e.left,e.right]).exit()}else e.setResult([e.left,e.right]).exit();else e.setResult([e.left,e.right]).exit()}else e.setResult([e.left,0,0]).exit();else{if("function"==typeof e.right)throw new Error("functions are not supported");e.setResult([e.right]).exit()}else e.setResult(void 0).exit()};Pu.filterName="trivial";const Au=function(e){if(void 0===e.delta)return void e.setResult(e.left).exit();if(e.nested=!Array.isArray(e.delta),e.nested)return;const t=e.delta;if(1!==t.length)if(2!==t.length)3===t.length&&0===t[2]&&e.setResult(void 0).exit();else{if(e.left instanceof RegExp){const r=/^\/(.*)\/([gimyu]+)$/.exec(t[1]);if(r)return void e.setResult(new RegExp(r[1],r[2])).exit()}e.setResult(t[1]).exit()}else e.setResult(t[0]).exit()};Au.filterName="trivial";const Iu=e=>{if(!e||!e.children)return;const t=e.children.length;let r,n=e.result;for(let i=0;i<t;i++)r=e.children[i],void 0!==r.result&&(n=n||{},n[r.childName]=r.result);n&&e.leftIsArray&&(n._t="a"),e.setResult(n).exit()};Iu.filterName="collectChildren";const Ou=e=>{if(e.leftIsArray||"object"!==e.leftType)return;const t=e.left,r=e.right;let n,i;const o=e.options.propertyFilter;for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o&&!o(n,e)||(i=new ku(t[n],r[n]),e.push(i,n)));for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o&&!o(n,e)||void 0===t[n]&&(i=new ku(void 0,r[n]),e.push(i,n)));e.children&&0!==e.children.length?e.exit():e.setResult(void 0).exit()};Ou.filterName="objects";const Tu=function(e){if(!e.nested)return;const t=e.delta;if(t._t)return;const r=t;let n,i;for(n in r)i=new xu(e.left[n],r[n]),e.push(i,n);e.exit()};Tu.filterName="objects";const ju=function(e){if(!e||!e.children)return;if(e.delta._t)return;const t=e.left,r=e.children.length;let n;for(let i=0;i<r;i++){n=e.children[i];const r=n.childName;Object.prototype.hasOwnProperty.call(e.left,r)&&void 0===n.result?delete t[r]:t[r]!==n.result&&(t[r]=n.result)}e.setResult(t).exit()};ju.filterName="collectChildren";const Cu=function(e){e.left instanceof Date?(e.right instanceof Date?e.left.getTime()!==e.right.getTime()?e.setResult([e.left,e.right]):e.setResult(void 0):e.setResult([e.left,e.right]),e.exit()):e.right instanceof Date&&e.setResult([e.left,e.right]).exit()};Cu.filterName="dates";class Ru{constructor(e){this.processor=new _u(e),this.processor.pipe(new Su("diff").append(Iu,Pu,Cu,Ou).shouldHaveResult()),this.processor.pipe(new Su("patch").append(ju,Au,Tu).shouldHaveResult())}options(e){return this.processor.options(e)}diff(e,t){return this.processor.process(new ku(e,t))}patch(e,t){return this.processor.process(new xu(e,t))}}var Fu=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const Lu=new Ru(Uu);var Uu;const Nu={writeKey:null,host:null,debug:!1,fetch:null,echoEvents:!1,cookieDomain:void 0,cookieNames:{},cookieCapture:{},runtime:void 0,fetchTimeoutMs:void 0,s2s:void 0,idEndpoint:void 0,errorPolicy:"log",defaultPayloadContext:{},privacy:{dontSend:!1,disableUserIds:!1,ipPolicy:"keep",consentCategories:void 0}},qu=(e,t)=>{for(const r of Object.keys(Nu)){const n=t[r];"privacy"===r?"object"==typeof n?e.privacy=Object.assign(Object.assign(Object.assign({},Nu.privacy),e.privacy),n):t.hasOwnProperty("privacy")&&void 0===n&&(e.privacy=Object.assign({},Nu.privacy)):void 0===n?!t.hasOwnProperty(r)&&e.hasOwnProperty(r)||(e[r]=Nu[r]):e[r]=n}},zu=e=>{if(!e)return{};let t=e.length>0&&"?"===e.charAt(0)?e.substring(1):e,r={},n=("?"===t[0]?t.substr(1):t).split("&");for(let e=0;e<n.length;e++){let t=n[e].split("=");r[decodeURIComponent(t[0])]=decodeURIComponent(t[1]||"")}return r};function Du(e){const t=e.substring(4);return"campaign"===t?"name":t}function $u(e){return Object.entries(e).filter((([e])=>0===e.indexOf("utm_"))).reduce(((e,[t,r])=>Object.assign(Object.assign({},e),{[Du(t)]:r})),{})}function Mu(e,t){try{return e()}catch(e){return t}}function Bu(e){let t=e.getItem("__user_traits");"string"==typeof t&&(t=Mu((()=>JSON.parse(t)),{})),("object"!=typeof t||null===t||Array.isArray(t))&&(t={});let r=e.getItem("__group_traits");return"string"==typeof r&&(r=Mu((()=>JSON.parse(r)),{})),("object"!=typeof r||null===r||Array.isArray(r))&&(r={}),Object.assign(Object.assign({},r||{}),t||{})}function Hu(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift():void 0}function Ju(e,t){const r=Object.assign({fbc:"_fbc",fbp:"_fbp"},t),n=Object.entries(r).reduce(((t,[r,n])=>(t[r]=e.getCookie(n),t)),{});return Object.assign(Object.assign({},n),function(e){var t;const r=e.getCookies(),n=null===(t=r._ga)||void 0===t?void 0:t.split(".").slice(-2).join("."),i=Object.entries(r).filter((([e])=>e.startsWith("_ga_"))),o=i.length>0?Object.fromEntries(i.map((([e,t])=>{if("string"!=typeof t)return null;const r=t.split(".");return r.length<3?null:[e.substring(4),r[2]]})).filter((e=>null!==e))):void 0;return n||o?{ga4:{clientId:n,sessionIds:o}}:void 0}(e))}function Gu(e,{domain:t,secure:r}){document.cookie=e+"=;domain="+t+";path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;SameSite="+(r?"None":"Lax")+(r?";secure":"")}const Wu={__anon_id:"__eventn_id",__user_id:"__eventn_uid",__user_traits:"__eventn_id_usr",__group_id:"__group_id",__group_traits:"__group_traits"},Vu=(e,t)=>({setItem(r,n){const i=t(r)||r;if(void 0===n)return void Gu(i,{domain:e,secure:"https:"===window.location.protocol});!function(e,t,{domain:r,secure:n}){document.cookie=e+"="+t+";domain="+r+";path=/;expires="+new Date((new Date).getTime()+15768e7).toUTCString()+";SameSite="+(n?"None":"Lax")+(n?";secure":"")}(i,"object"==typeof n&&null!==n?encodeURIComponent(JSON.stringify(n)):n,{domain:e,secure:"https:"===window.location.protocol})},getItem(e){const r=Hu(t(e)||e);if("__anon_id"===e)return r;if(void 0===r&&"__user_id"===e){const e=gd(Hu(t("__user_traits")||"__eventn_id_usr"))||{};return e.internal_id||e.user_id||e.id||e.userId}return gd(r)},removeItem(r){Gu(t(r)||r,{domain:e,secure:"https:"===window.location.protocol})},reset(){for(const r of Object.keys(Wu))Gu(t(r)||r,{domain:e,secure:"https:"===window.location.protocol})}});function Yu(e){const t=t=>{var r,n,i,o,a;switch(t){case"__anon_id":return(null===(r=e.cookieNames)||void 0===r?void 0:r.anonymousId)||Wu.__anon_id;case"__user_id":return(null===(n=e.cookieNames)||void 0===n?void 0:n.userId)||Wu.__user_id;case"__user_traits":return(null===(i=e.cookieNames)||void 0===i?void 0:i.userTraits)||Wu.__user_traits;case"__group_id":return(null===(o=e.cookieNames)||void 0===o?void 0:o.groupId)||Wu.__group_id;case"__group_traits":return(null===(a=e.cookieNames)||void 0===a?void 0:a.groupTraits)||Wu.__group_traits;default:return t}};return{getCookie(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift():void 0},getCookies(){const e={},t=`; ${document.cookie}`.matchAll(/(\w+)=([^;]+)/g);for(const r of t)e[r[1]]=r[2];return e},documentEncoding:()=>window.document.characterSet,timezoneOffset:()=>(new Date).getTimezoneOffset(),store:()=>Vu(e.cookieDomain||wu(window.location.hostname),t),language:()=>window.navigator.language,pageTitle:()=>window.document.title,pageUrl:()=>window.location.href,referrer:()=>window.document.referrer,screen:()=>({width:window.screen.width,height:window.screen.height,innerWidth:window.innerWidth,innerHeight:window.innerHeight,density:Math.floor(window.devicePixelRatio)}),userAgent:()=>window.navigator.userAgent}}function Ku(e){const t={};return{reset(){Object.keys(t).forEach((e=>delete t[e]))},setItem(r,n){e&&console.log(`[JITSU EMPTY RUNTIME] Set storage item ${r}=${JSON.stringify(n)}`),void 0===n?delete t[r]:t[r]=n},getItem(r){const n=t[r];return e&&console.log(`[JITSU EMPTY RUNTIME] Get storage item ${r}=${JSON.stringify(n)}`),n},removeItem(r){e&&console.log(`[JITSU EMPTY RUNTIME] Get storage item ${r}=${t[r]}`),delete t[r]}}}const Qu=e=>({documentEncoding(){},timezoneOffset(){},getCookie(e){},getCookies:()=>({}),store:()=>Ku(e.debug),language(){},pageTitle(){},pageUrl(){},referrer(){},screen(){},userAgent(){}});function Xu(e,t){return"object"!=typeof t||null===t||"object"!=typeof e||null===e?t:Object.entries(t).reduce(((t,[r,n])=>(t[r]=Xu(e[r],n),t)),e)}function Zu(){return"undefined"!=typeof document&&"undefined"!=typeof window}const ed=/#.*$/;function td(e,t,r,n){var i,o,a,s,l,c,u,d,h,f,p,g,m,v;const y=t.runtime||(Zu()?Yu(t):Qu(t)),b=y.pageUrl(),w=Mu((()=>new URL(b)),void 0),_=w?zu(w.search):{},S=e.properties||{};if("page"===e.type&&(S.url||b)){const e=S.url||b;S.url=e.replace(ed,""),S.path=(E=function(e){const t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(ed,""):"")}(e),0===E.indexOf("//")&&1===E.lastIndexOf("/")?"/":E)}var E;const k=Xu(t.defaultPayloadContext,(null===(i=e.properties)||void 0===i?void 0:i.context)||(null===(o=e.options)||void 0===o?void 0:o.context)||{});null===(a=e.properties)||void 0===a||delete a.context;const x=y.referrer(),P={library:{name:mu,version:gu,env:Zu()?"browser":"node"},consent:(null===(s=t.privacy)||void 0===s?void 0:s.consentCategories)?{categoryPreferences:t.privacy.consentCategories}:void 0,userAgent:null===(l=y.userAgent)||void 0===l?void 0:l.call(y),locale:null===(c=y.language)||void 0===c?void 0:c.call(y),screen:null===(u=y.screen)||void 0===u?void 0:u.call(y),ip:null===(d=null==y?void 0:y.ip)||void 0===d?void 0:d.call(y),traits:"identify"!=e.type&&"group"!=e.type?Object.assign(Object.assign({},Bu(r)||{}),(null===(h=null==e?void 0:e.options)||void 0===h?void 0:h.traits)||{}):void 0,page:{path:S.path||w&&w.pathname,referrer:x,referring_domain:Mu((()=>x&&new URL(x).hostname)),host:w&&w.host,search:S.search||w&&w.search,title:S.title||y.pageTitle(),url:S.url||b,encoding:S.encoding||y.documentEncoding()},clientIds:(null===(f=t.privacy)||void 0===f?void 0:f.disableUserIds)?void 0:Ju(y,t.cookieCapture),campaign:$u(_)},A=Object.assign(Object.assign({},e),{userId:(null===(p=null==e?void 0:e.options)||void 0===p?void 0:p.userId)||(null==e?void 0:e.userId),anonymousId:(null===(g=null==e?void 0:e.options)||void 0===g?void 0:g.anonymousId)||(null==e?void 0:e.anonymousId),groupId:(null===(m=null==e?void 0:e.options)||void 0===m?void 0:m.groupId)||r.getItem("__group_id"),timestamp:(new Date).toISOString(),sentAt:(new Date).toISOString(),messageId:dd(S.path||w&&w.pathname),writeKey:nd(t.writeKey),context:Xu(P,k)});return delete A.meta,delete A.options,(null===(v=t.privacy)||void 0===v?void 0:v.disableUserIds)&&(delete A.userId,delete A.anonymousId,delete A.context.traits,delete A.groupId),A}function rd(e){const t=Object.keys(e);return 1===t.length&&"__diff"===t[0]}function nd(e){if(e){const[t,r]=e.split(":",2);return r?`${t}:***`:"***"}return e}function id(e){const t=e.errorPolicy||"log";return"function"==typeof t?t:"rethrow"===t?(e,...t)=>{throw new Error(e)}:(e,...t)=>{console.error(e,...t)}}function od(e,t,r,n,i){return Fu(this,void 0,void 0,(function*(){var o,a;const s=!!r.s2s,l=r.debug?{"X-Enable-Debug":"true"}:{},c=td(t,r,i);if(r.echoEvents)return void console.log(`[JITSU DEBUG] sending '${e}' event:`,c);const u=s?`${r.host}/api/s/s2s/${e}`:`${r.host}/api/s/${e}`,d=r.fetch||globalThis.fetch;if(!d)throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");const h=r.fetchTimeoutMs?new AbortController:void 0,f=r.fetchTimeoutMs?setTimeout((()=>{h.abort()}),r.fetchTimeoutMs):void 0,p=r.writeKey?{"X-Write-Key":r.writeKey}:{},g=void 0===(null===(o=r.privacy)||void 0===o?void 0:o.ipPolicy)||"keep"===(null===(a=r.privacy)||void 0===a?void 0:a.ipPolicy)?{}:{"X-IP-Policy":r.privacy.ipPolicy};let m,v,y;try{m=yield d(u,{method:"POST",headers:Object.assign(Object.assign(Object.assign({"Content-Type":"application/json"},p),l),g),body:JSON.stringify(c),signal:null==h?void 0:h.signal}),f&&clearTimeout(f)}catch(e){return id(r)(`Call to ${u} failed with error ${e.message}`),Promise.resolve()}try{v=yield m.text()}catch(e){console.warn(`Can't read response text from ${u} (status - ${m.status} ${m.statusText}): ${null==e?void 0:e.message}`)}if(r.debug&&console.log(`[JITSU DEBUG] ${u} replied ${m.status}: ${v}. Original payload:\n${JSON.stringify(c,null,2)}`),!m.ok)return id(r)(`Call to ${u} failed with error: ${m.status} - ${m.statusText}: ${v}`),Promise.resolve();try{y=JSON.parse(v)}catch(e){return id(r)(`Can't parse JSON: ${v}: ${null==e?void 0:e.message}`),Promise.resolve()}if(y.destinations&&y.destinations.length>0)if(r.s2s)console.warn(`[JITSU] ${t.type} responded with list of ${y.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`,r.debug?JSON.stringify(y.destinations,null,2):void 0);else if(Zu())return r.debug&&console.log("[JITSU] Processing device destinations: ",JSON.stringify(y.destinations,null,2)),function(e,t,r,n,i){return Fu(this,void 0,void 0,(function*(){const o=[];for(const a of e){let e=[r];if(a.newEvents)try{e=a.newEvents.map((e=>"same"===e?r:rd(e)?Lu.patch(r,e.__diff):e))}catch(e){console.error(`[JITSU] Error applying '${a.id}' changes to event: ${null==e?void 0:e.message}`,e)}const s=Object.assign(Object.assign({},a.credentials),a.options);if("internal-plugin"===a.deviceOptions.type){const t=pu[a.deviceOptions.name];if(t)for(const r of e)try{o.push(t.handle(Object.assign(Object.assign({},s),{debug:n}),r))}catch(e){console.warn(`[JITSU] Error processing event with internal plugin '${a.deviceOptions.name}': ${null==e?void 0:e.message}`,e)}else console.warn(`[JITSU] Unknown internal plugin '${a.deviceOptions.name}' for destination '${a.id}'`)}else if("analytics-plugin"===a.deviceOptions.type){yield Gc(a.deviceOptions.packageCdn);const r=window[a.deviceOptions.moduleVarName];if(r){let o;try{o=("function"==typeof r?r:r.init)(s)}catch(e){console.warn(`[JITSU] Error creating plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}`,e)}try{n&&console.log(`[JITSU] Plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}' initialized with config:`,o.config),o.initialize({config:o.config,instance:i})}catch(e){console.warn(`[JITSU] Error initializing plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}. Config: ${JSON.stringify(o.config)}`,e);continue}if(o[t])for(const r of e)try{o[t]({payload:r,config:o.config,instance:i})}catch(e){console.warn(`[JITSU] Error processing ${t}() with plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}`,e)}}else console.warn(`[JITSU] Broken plugin '${a.deviceOptions.packageCdn}' for destination '${a.id}' - it doesn't export '${a.deviceOptions.moduleVarName}' variable`)}}}))}(y.destinations,e,c,!!r.debug,n);return c}))}const ad=["$doNotSend"];function sd(e){const t=Object.assign({},e);for(const e of ad)delete t[e];return t}const ld=(e={},t)=>(qu(e,e),{name:"jitsu",config:e,initialize:e=>Fu(void 0,void 0,void 0,(function*(){const{config:t}=e;if(t.debug&&console.debug("[JITSU DEBUG] Initializing Jitsu plugin with config: ",JSON.stringify(t,null,2)),!t.host&&!t.echoEvents)throw new Error("Please specify host variable in jitsu plugin initialization, or set echoEvents to true");if(function(e){if(e){const[,r]=e.split(":",2);if(!r&&(25!==(t=e).length||"c"!==t.charAt(0)))throw new Error(`Legacy write key detected - ${e}! This format doesn't work anymore, it should be 'key:secret'. Please download a new key from Jitsu UI`)}var t}(t.writeKey),t.idEndpoint){if(!Zu())return void console.error("[JITSU] 'idEndpoint' option can be used only in browser environment");try{const e=t.fetch||globalThis.fetch,r=new AbortController;setTimeout((()=>r.abort()),1e3);const n=t.cookieDomain||wu(window.location.hostname),i=yield e(t.idEndpoint+"?domain="+encodeURIComponent(n),{credentials:"include",signal:r.signal});i.ok?t.debug&&console.log(`[JITSU DEBUG] Fetch idEndpoint: ${i.status}`):console.error(`[JITSU] Can't fetch idEndpoint: ${i.status} - ${i.statusText}`)}catch(e){console.error(`[JITSU] Can't fetch idEndpoint: ${e.message}`)}}})),page:e=>{var r;const{payload:n,config:i,instance:o}=e;if(!(null===(r=i.privacy)||void 0===r?void 0:r.dontSend))return od("page",n,i,o,t)},track:e=>{var r;const{payload:n,config:i,instance:o}=e;if(!(null===(r=i.privacy)||void 0===r?void 0:r.dontSend))return od("track",n,i,o,t)},identify:e=>{var r,n,i;const{payload:o,config:a,instance:s}=e;if((null===(r=a.privacy)||void 0===r?void 0:r.dontSend)||(null===(n=a.privacy)||void 0===n?void 0:n.disableUserIds))return;t.setItem("__user_id",o.userId);const l=null===(i=o.traits)||void 0===i?void 0:i.$doNotSend;return o.traits&&"object"==typeof o.traits&&(o.traits=sd(o.traits),t.setItem("__user_traits",o.traits)),l?Promise.resolve():od("identify",o,a,s,t)},reset:e=>{const{config:r,instance:n}=e;t.reset(),r.debug&&console.log("[JITSU DEBUG] Resetting Jitsu plugin storage")},methods:{configure(r){var n,i,o,a;const s=(null===(n=e.privacy)||void 0===n?void 0:n.disableUserIds)||(null===(i=e.privacy)||void 0===i?void 0:i.dontSend);qu(e,r);if(!((null===(o=e.privacy)||void 0===o?void 0:o.disableUserIds)||(null===(a=e.privacy)||void 0===a?void 0:a.dontSend))&&s){e.debug&&console.log("[JITSU] Enabling Anonymous ID. Generating new Id.");const r=this.instance,n=hd(),i=r.user();i&&(i.anonymousId=n),t.setItem("__anon_id",n),r.setAnonymousId(n)}},group(r,n,i,o){var a,s;if((null===(a=e.privacy)||void 0===a?void 0:a.dontSend)||(null===(s=e.privacy)||void 0===s?void 0:s.disableUserIds))return;"number"==typeof r&&(r+="");const l=this.instance,c=l.user(),u=(null==i?void 0:i.userId)||(null==c?void 0:c.userId),d=(null==i?void 0:i.anonymousId)||(null==c?void 0:c.anonymousId)||t.getItem("__anon_id");t.setItem("__group_id",r);const h=null==n?void 0:n.$doNotSend;return n&&"object"==typeof n&&(n=sd(n),t.setItem("__group_traits",n)),h?Promise.resolve():od("group",Object.assign(Object.assign({type:"group",groupId:r,traits:n},d?{anonymousId:d}:{}),u?{userId:u}:{}),e,l,t)}}});let cd=0;function ud(){var e;cd=(cd+1)%Number.MAX_SAFE_INTEGER;const t=Date.now()%2147483647;return(Zu()&&(null===(e=null===window||void 0===window?void 0:window.performance)||void 0===e?void 0:e.now())||t)+cd}function dd(e=""){const t=Date.now();return(Math.random()*t*fd(null!=e?e:"",ud())%Number.MAX_SAFE_INTEGER).toString(36)+(Math.random()*t*fd(null!=e?e:"",ud())%Number.MAX_SAFE_INTEGER).toString(36)}function hd(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],i=15&r;e+="-"==n||"4"==n?n:("x"==n?i:3&i|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}function fd(e,t=0){let r=3735928559^t,n=1103547991^t;for(let t,i=0;i<e.length;i++)t=e.charCodeAt(i),r=Math.imul(r^t,2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&n)+(r>>>0)}var pd=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};function gd(e){let t=e;0===(null==e?void 0:e.indexOf("%7B%22"))&&(t=decodeURIComponent(e));try{if(t=JSON.parse(t),"true"===t)return!0;if("false"===t)return!1;if("object"==typeof t)return t;parseFloat(t)===t&&(t=parseFloat(t))}catch(e){}if(null!==t&&""!==t)return t}function md(e,t,r=[]){var n,i,o;const a={},s=t=>({setItem(r,n){var i,o;(null===(i=e.privacy)||void 0===i?void 0:i.dontSend)||(null===(o=e.privacy)||void 0===o?void 0:o.disableUserIds)||(e.debug&&console.log(`[JITSU DEBUG] Caching storage setItem: ${r}=${n}`),a[r]=n,t.setItem(r,n))},getItem(r){var n,i;if((null===(n=e.privacy)||void 0===n?void 0:n.dontSend)||(null===(i=e.privacy)||void 0===i?void 0:i.disableUserIds))return;const o=a[r]||t.getItem(r);return e.debug&&console.log(`[JITSU DEBUG] Caching storage getItem: ${r}=${o}. Evicted from cache: ${!a[r]}`),o},reset(){for(const e of[...Object.keys(a)])delete a[e];t.reset()},removeItem(r){e.debug&&console.log(`[JITSU DEBUG] Caching storage removeItem: ${r}`),delete a[r],t.removeItem(r)}}),l=s((null===(n=t.store)||void 0===n?void 0:n.call(t))||Ku(e.debug)),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return mc(Jc(Jc({},{storage:Mc}),e))}({debug:!!e.debug,storage:l,plugins:[ld(e,l),...r]}),u=Object.assign(Object.assign({},c),{page:(...e)=>2===e.length&&"string"==typeof e[0]&&"object"==typeof e[1]?c.page(Object.assign({name:e[0]},e[1])):c.page(...e),identify:(...e)=>{e[0]&&"object"!=typeof e[0]&&"string"!=typeof e[0]&&(e[0]=e[0]+"");const t=c.storage,r=s(t);return"string"==typeof e[0]?r.setItem("__user_id",e[0]):"object"==typeof e[0]&&r.setItem("__user_traits",e[0]),2===e.length&&"object"==typeof e[1]&&r.setItem("__user_traits",e[1]),c.identify(...e)},setContextProperty(t,r){e.debug&&console.log(`[JITSU DEBUG] Setting context property '${t}':${JSON.stringify(r)}`),e.defaultPayloadContext?e.defaultPayloadContext[t]=r:e.defaultPayloadContext={[t]:r}},getContextProperty(t){var r;return e.debug&&console.log(`[JITSU DEBUG] Getting context property '${t}'`),null===(r=e.defaultPayloadContext)||void 0===r?void 0:r[t]},setAnonymousId:t=>{e.debug&&console.log("[JITSU DEBUG] Setting anonymous id to "+t),l.setItem("__anon_id",t);const r=c.user();r&&(r.anonymousId=t),c.setAnonymousId(t)},reset(){return pd(this,void 0,void 0,(function*(){e.debug&&console.log("[JITSU DEBUG] Called reset(). Storage state",JSON.stringify(c.user())),l.reset(),yield c.reset(),this.setAnonymousId(hd()),e.debug&&console.log("[JITSU DEBUG] User state after reset",JSON.stringify(c.user()))}))},configure(t){return pd(this,void 0,void 0,(function*(){var r,n;e.debug&&console.log("[JITSU DEBUG] Update Jitsu config with",JSON.stringify(t)),((null===(r=t.privacy)||void 0===r?void 0:r.disableUserIds)||(null===(n=t.privacy)||void 0===n?void 0:n.dontSend))&&l.reset();for(const e of Object.values(c.plugins))"function"==typeof e.configure&&e.configure(t)}))},group(e,t,r,n){return pd(this,void 0,void 0,(function*(){const i=[];for(const o of Object.values(c.plugins))o.group&&i.push(yield o.group(e,t,r,n));return i[0]}))}});return((null===(i=e.privacy)||void 0===i?void 0:i.disableUserIds)||(null===(o=e.privacy)||void 0===o?void 0:o.dontSend))&&l.reset(),u}function vd(e){const t=function(e){var t,r;return Object.assign(Object.assign({},e),{host:0!==(null!==(t=e.host)&&void 0!==t?t:"").indexOf("https://")&&0!==(null!==(r=e.host)&&void 0!==r?r:"").indexOf("http://")?`https://${e.host}`:e.host})}(e),r=Zu();return md(t,t.runtime||(r?Yu(t):Qu(t)))}class yd{constructor(e){this.item=e[0]}toSegment(){return{event:"Product Added",properties:{cart_id:this.item.cart_id?.toString(),product_id:this.item.id?.toString(),category:this.item.category,currency:Salla.config.currency()?.code,name:this.item.name,brand:this.item.brand,variant:this.item.variant?.toString(),price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}}static shouldSend(){return"customer.wishlist"!==salla.config.get("page.slug")}}class bd{constructor(e){this.product=e[0]}toSegment(){return{event:"Product Viewed",properties:{product_id:this.product.id?.toString(),category:this.product.category,name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:this.product.quantity,currency:this.product.currency,coupon:this.product.coupon,position:this.product.position,value:this.product.value,sku:this.product.sku,url:this.product.url,image_url:this.product.image_url}}}}class wd{constructor(e){this.cart=e[0]}toSegment(){return{event:"Cart Viewed",properties:{cart_id:this.cart.cart_id?.toString(),products:this.cart.products.map((e=>({product_id:e.id?.toString(),name:e.name,price:e.price,category:e.category,sku:e.sku,position:e.position,url:e.url,image_url:e.image_url,brand:e.brand,currency:Salla.config.currency()?.code,variant:e.variant,coupon:e.coupon,quantity:e.quantity})))}}}}class _d{constructor(e){const t=e?.nextPage;this.listId=salla.config.get("page.slug"),Salla.config.get("page.id")&&(this.listId+=`_${salla.config.get("page.id")}`),this.sorts=null;try{if(t){const e=new URL(t).searchParams.get("sort");e&&(this.sorts=[{type:"sort",value:e}])}e.source&&(this.listId=`${this.listId}_${e.source}`),e.sourceValue&&(this.listId=`${this.listId}_${Array.isArray(e.sourceValue)?e.sourceValue.join("_"):e.sourceValue}`)}catch(e){salla.logger.error(e)}this.products=e?.data}toSegment(){return{event:"Product List Viewed",properties:{list_id:this.listId,category:salla.config.get("page.title"),sorts:this.sorts,products:this.products.map((e=>({product_id:e.id,category:e.category?.name,currency:Salla.config.currency()?.code,name:e.name,brand:e.brand?.name,variant:e.variant?.toString(),coupon:e.coupon?.toString(),price:e.price,quantity:Number(e.quantity),sku:e.sku,position:0,url:e.url,image_url:e.image?.url})))}}}static shouldSend(e){return!(e?.nextPage||"").includes("filters")&&!["index","customer.wishlist"].includes(salla.config.get("page.slug"))}}class Sd{constructor(e){this.query=e}toSegment(){return{event:"Products Searched",properties:{query:this.query}}}}class Ed{constructor(){this.user=JSON.parse(localStorage.getItem("user"))}toSegment(){return{event:"Signed In",properties:{first_name:this.user?.first_name,last_name:this.user?.last_name,type:this.user?.type,mobile:this.user?.mobile,email:this.user?.email}}}static shouldSend(){return"user"===Salla.config.get("user.type")?!Salla.analytics.history.find((({eventName:e})=>"Signed In"===e)):(Salla.profile.event.onInfoFetched((()=>Salla.event.emit("Signed In"))),!1)}}class kd extends Ed{toSegment(){const e=super.toSegment();return{event:"Signed Up",properties:e?.properties}}static shouldSend(){return"user"===Salla.config.get("user.type")||(Salla.profile.event.onInfoFetched((()=>Salla.event.emit("Signed Up"))),!1)}}class xd{toSegment(){return{event:"Signed Out",properties:{}}}}class Pd{constructor(e){this.item=e[0]}toSegment(){return{event:"Product Removed",properties:{cart_id:this.item?.cart_id?.toString(),product_id:this.item?.id?.toString(),category:this.item?.category,currency:Salla.config.currency()?.code,name:this.item?.name,brand:this.item?.brand,variant:this.item?.variant,price:this.item?.price,quantity:this.item?.quantity,sku:this.item?.sku,coupon:this.item?.coupon,position:this.item?.position,url:this.item?.url,image_url:this.item?.image_url}}}}class Ad{constructor(e){this.product=e.data.product}toSegment(){return{event:"Product Added to Wishlist",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:this.product.id?.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,position:Number(this.product.position||0),url:this.product.url,image_url:this.product?.image||null,category:this.product.category,currency:Salla.config.currency()?.code,brand:this.product.brand}}}}class Id{constructor(e){this.product=e.data.product}toSegment(){return{event:"Product Removed from Wishlist",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:this.product.id?.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,coupon:this.product.coupon||null,position:Number(this.product.position||0),currency:Salla.config.currency()?.code,url:this.product.url,image_url:this.product?.image||null,category:this.product.category,brand:this.product.brand}}}}class Od{constructor(e){this.details=e[0]}toSegment(){return{event:"Order Completed",properties:this.details}}}class Td{constructor(e){this.item=e[0]}toSegment(){return{event:"Wishlist Product Added to Cart",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),cart_id:this.item.cart_id?.toString(),product_id:this.item.id?.toString(),category:this.item.category,name:this.item.name,brand:this.item.brand,variant:this.item.variant,price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}}static shouldSend(){return"customer.wishlist"===salla.config.get("page.slug")}}class jd{constructor(e){this.data=e}toSegment(){const e=Salla.analytics.history.find((({eventName:e})=>"Product Viewed"===e))?.payload||{};return e.share_via=this.data.share_via,{event:"Product Shared",properties:e}}static shouldSend(){return"product.single"===salla.config.get("page.slug")}}class Cd{constructor(e){this.details=e}toSegment(){return{event:"Product Reviewed",properties:this.details}}static registerEvent(){salla.event.rating.onProductsRated((function(e,t){const{products:r,order_id:n}=t;Object.values(r).forEach((e=>{Salla.event.emit("Product Reviewed",{product_id:e.product_id?.toString(),review_id:n?.toString(),review_body:e.comment,rating:e.rating})}))}))}}class Rd{constructor(e){this.promotion=e[0]}toSegment(){return{event:"Promotion Viewed",properties:{promotion_id:this.promotion.id?.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}}}class Fd{constructor(e){this.promotion=e[0]}toSegment(){return{event:"Promotion Clicked",properties:{promotion_id:this.promotion.id?.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}}}class Ld{constructor(e){this.transaction=e}getCartId(){return"cart"===salla.config.get("page.slug")?salla.config.get("page.id")?.toString():this.transaction?.data?.cart?.id?.toString()||""}toSegment(){return{event:"Coupon Applied",properties:{cart_id:this.getCartId(),coupon_name:this.transaction?.data?.cart?.coupon||"",discount:this.transaction?.data?.cart?.discount||0,currency:salla.config.get("user.currency")||""}}}}class Ud{constructor(e){this.transaction=e}getCartId(){return"cart"===salla.config.get("page.slug")?salla.config.get("page.id")?.toString():""}getCouponCode(){try{const e=this.transaction.response?.config?.data;return e?JSON.parse(e)?.coupon:""}catch{return""}}toSegment(){return{event:"Coupon Denied",properties:{cart_id:this.getCartId(),coupon_name:this.getCouponCode(),reason:this.transaction.response?.data?.error?.message||"Unknown error"}}}}class Nd{constructor(e){this.transaction=e}getCartId(){return"cart"===salla.config.get("page.slug")?salla.config.get("page.id")?.toString():this.transaction?.data?.cart?.id?.toString()||""}toSegment(){return{event:"Coupon Removed",properties:{cart_id:this.getCartId(),coupon_name:this.transaction?.coupon||"",discount:this.transaction?.data?.cart?.discount||0,currency:salla.config.get("user.currency")||""}}}}class qd{static user={};constructor(e){this.details=e?.data}toSegment(){const e=["first_name","last_name","birthday","gender"].filter((e=>qd.user[e]!==this.details?.[e]&&(void 0!==qd.user[e]||void 0!==this.details?.[e])));return qd.setUser(this.details),{event:"User Profile Updated",properties:{updated_fields:e}}}static registerEvent(){Salla.onReady((()=>{salla.url.is_page("customer.profile")&&qd.setUser(Salla.config.get("user"))}))}static setUser(e){qd.user={first_name:e?.first_name,last_name:e?.last_name,gender:e?.gender,birthday:e?.birthday,avatar:e?.avatar}}static shouldSend(){return"user"===Salla.config.get("user.type")}}class zd extends _d{constructor(e){super(e);const t=e?.nextPage||"";this.filters=this.extractFilters(t)}extractFilters(e){if(!e)return null;try{const t=new URL(e),r=[];return Array.from(t.searchParams.entries()).forEach((([e,t])=>{if(e.startsWith("filters[")){const n=e.match(/^filters\[(.*?)\]/),i=n?n[1]:e;r.push({type:i,value:t})}})),r.length>0?r:null}catch(e){return console.warn("Error extracting filters from URL:",e),null}}toSegment(){const e=super.toSegment();return{event:"Product List Filtered",properties:{...e?.properties,filters:this.filters}}}static shouldSend(e){return(e?.nextPage||"").includes("filters")}}class Dd{constructor(e){this.cart=e}toSegment(){return{event:"Cart Updated",properties:{cart_id:this.cart.id?.toString(),value:this.cart.total,revenue:this.cart.sub_total,tax:this.cart.tax_amount,discount:this.cart.total_discount,shipping:this.cart.real_shipping_cost,currency:Salla.config.currency()?.code,affiliation:Salla.storage.getWithTTL("s-utms")?.["s-utm-source"],products:this.cart.items?.map((e=>({product_id:e.product_id?.toString(),name:e.product_name,price:e.product_price,category:e.category?.toString(),sku:e.product_sku?.toString(),position:e.position,url:e.url,image_url:e.product_image,brand:e.brand?.toString(),currency:Salla.config.currency()?.code,variant:e.variant?.toString(),coupon:this.cart.coupon,quantity:e.quantity})))}}}static shouldSend(){return"cart"===salla.config.get("page.slug")}}class $d{constructor(e){this.scope=e.data}toSegment(){return{event:"Market Selected",properties:{...this.getScope(this.scope),prev:this.getScope(Salla.config.get("store.scope"))}}}getScope(e){return e=e||{},{id:e.id?.toString(),country:this.getScopeAttribute(e,"countries"),currency:this.getScopeAttribute(e,"currencies"),locale:this.getScopeAttribute(e,"languages")}}getScopeAttribute(e,t){return e=e[t],Array.isArray(e)?e[0]:e}}class Md{static events={"Order Completed":[Od],"Product Added":[yd,Td],"Product Removed":[Pd],"Product Viewed":[bd],"Product Added to Wishlist":[Ad],"Product Removed from Wishlist":[Id],"Cart Viewed":[wd],"Products Searched":[Sd],"Product List Viewed":[_d],"Product List Filtered":[zd],"Signed Up":[kd],"Signed In":[Ed],"Signed Out":[xd],"Product Reviewed":[Cd],"Product Shared":[jd],"Promotion Viewed":[Rd],"Promotion Clicked":[Fd],"Coupon Applied":[Ld],"Coupon Removed":[Nd],"Coupon Denied":[Ud],"User Profile Updated":[qd],"Cart Updated":[Dd],"Market Selected":[$d]};static registerEvents(){Object.values(this.events).forEach((e=>{e.forEach((e=>{"function"==typeof e.registerEvent&&e.registerEvent()}))}))}static transform(e,t){try{const r=this.events[e]||[];for(const e of r){if(!e||"function"==typeof e.shouldSend&&!e.shouldSend(t))continue;const r=new e(t).toSegment();return{event:r.event,properties:r.properties}}return null}catch(e){return console.error("Failed to transform event:",e),null}}}return Dr.onInitiated=e=>salla.event.once("twilight::initiated",e),Dr.onReady=Dr.onReady||function(e){return new Promise((function(t){return"ready"===salla.status?t(e?e(salla.config.all()):salla.config.all()):Dr.onInitiated((r=>t(e?e(r):r)))}))},Dr.status="loading",Dr.notify=Hr,Dr.lang=new class extends Pn{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){return new Promise((t=>{if(this.translationsLoaded)return t(e?e():null);Salla.event.once("languages::translations.loaded",(()=>t(e?e():null)))}))}loadStoreTranslations(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get(`s_translations.${this.hash}`),this.messages&&(this.translationsLoaded=!0)&&super.setMessages(this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get(`languages/assets/${this.hash}.js`)):this.loadScript("https://cdn.salla.network/js/translations.js",!1)}setMessages(e){super.setMessages(e),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(e,t=!0){let r=document.createElement("script");r.src=e,r.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);r.onerror()},r.onerror=()=>{if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),this.loadScript("https://cdn.salla.network/js/translations.js",!1);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.")},document.head.appendChild(r)}getWithDefault(e,t,r,n){let i=this.get(e,r,n);return i!==e?i:t}get(e,t,r){let n=e;(window.translations||this.translationsLoaded)&&(n="trans."+e);let i=super.get(n,t,r);return i!==n?i:super.get(n,t,"en").replace(n,e)}set(e,t){return salla.helpers.setNested(this.messages[`${this.getLocale()}.trans`],e,t),this}add(e,t){return Object.entries(t).forEach((t=>salla.helpers.setNested(this.messages[t[0]+".trans"],e,t[1]))),this}addBulk(e){return Object.entries(e).forEach((([e,t])=>{this.add(e,t)})),this}},Dr.form=new class{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name||"submit"===t?.type){if(t.preventDefault(),"FORM"!==t.target?.tagName)return Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((()=>{throw"Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===t?.submitter?.parentElement?.tagName&&t.submitter.parentElement.load(),r=t.target.getElementSallaData(),salla.log("Data from element",r)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.api.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let n=e.split("."),i=n.splice(-1);return await salla.call(n.join("."))[i](r).finally((()=>t?.submitter?.parentElement?.stop())).catch((e=>{throw salla.logger.warn(e),e}))}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){return t?.currentTarget?"FORM"!==t?.currentTarget?.tagName||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${e}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${e}' without event!`),!1)}getPossibleValue(e,t,r=!1){if(!e)return;if("object"!=typeof e)return e;let n;for(let r=0;r<t.length&&!(n=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[r])));r++);return n=n||e,"object"!=typeof n||r?n:void 0}},Dr.infiniteScroll=new class extends Jr{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},this.instances=[]}initiate(e,t,r,n=!1){n?((r=r||{}).fetchOptions={...this.fetchOptions,...r.fetchOptions||{}},r.responseBody="json"):r=this.getCustomOptions(t,r);let i="string"!=typeof e?e:document.querySelector(e),o=r.path;if(!i||!o||"string"==typeof o&&!document.querySelector(o))return void Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let a=new En(i,r);return a.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),a.on("request",Salla.infiniteScroll.event.request),a.on("load",Salla.infiniteScroll.event.load),a.on("append",Salla.infiniteScroll.event.append),a.on("error",Salla.infiniteScroll.event.error),a.on("last",Salla.infiniteScroll.event.last),a.on("history",Salla.infiniteScroll.event.history),this.instances.push(a),a}getCustomOptions(e,t){return(t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t}loadNextPage(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage()}destroy(e){("string"!=typeof e?e:document.querySelector(e)).destroy()}}(void 0,salla.event.infiniteScroll),Dr.api=new class extends ps{constructor(){super(),this.auth=new Tn,this.cart=new In,this.loyalty=new On,this.order=new jn,this.rating=new Nn,this.product=new Cn,this.profile=new Rn,this.comment=new Fn,this.currency=new Ln,this.document=new Un,this.wishlist=new qn,this.scope=new zn,this.booking=new Dn,this.landing=new $n,this.notifications=new Mn,this.component=new gs,this.advertisement=new ms,this.navigation=new vs,this.metadata=new ys}beaconRequest(e,t={}){if(!window.navigator?.sendBeacon)return fetch(e,t);const r="string"==typeof t?.body?t?.body:JSON.stringify(t?.body||{}),n=new Blob([r],{type:"application/json"});return Salla.log(`Beacon payload size: ${n.size} bytes (~${(n.size/1024).toFixed(2)} KB)`),navigator.sendBeacon(e,n),Promise.resolve(new Response('{"status":"sent_via_beacon"}',{status:200,headers:{"Content-Type":"application/json"}}))}},Dr.sso=new class{constructor(){Salla.onReady((()=>this.init()))}init(){if(salla.config.get("store.features",[]).includes("sso-login")){if(window.location.hostname.includes("salla"))return salla.log("SSO is not supported yet for stores without custom domain.");salla.auth.event.onLoggedOut((()=>new Promise((e=>{const t=document.createElement("iframe");t.style.display="none",t.src=salla.url.get("sso/logout"),document.body.appendChild(t),t.onload=()=>{document.body.removeChild(t),e()}})))),document.querySelector("salla-login-modal")?.remove(),Salla.event.removeAllListeners("login::open"),Salla.event.prependListener("login::open",(()=>this.redirect())),window.addEventListener("mini-checkout::before-init",(e=>{Salla.config.isUser()||(e.preventDefault(),this.redirect())}))}}redirect(){const e=window.location.pathname+window.location.search,t=`${window.location.origin}/sso/login?intended_to=${encodeURIComponent(e)}`;return console.log("Redirecting to:",t),window.location.href=t,!0}},Dr.intend=new class{constructor(){Salla.onReady((()=>this.init()))}init(){if(Salla.config.isUser())return;const e=new URLSearchParams(window.location.search);if(e.has("intended_to"))try{const t=new URL(e.get("intended_to"));if(t.hostname!==window.location.hostname)return;return this.handleAfterLoginEvent(t)}catch(e){return void console.warn("Invalid URL provided in intended_to parameter")}}handleAfterLoginEvent(e){let t="intend::user.logged.in";Salla.event.on(t,(()=>window.location=e)),Salla.api.auth.setAfterLoginEvent(t),Salla.api.auth.setCanRedirect(!1),Salla.event.on("salla-login::ready",(()=>Salla.event.emit("login::open",{withoutReload:!0})))}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing","metadata"].forEach((e=>Dr[e]=new Jr(Dr.api[e],Dr.event[e]))),Dr.call=e=>{let t=Dr,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},Dr.analytics=new class{constructor(){this.history=[],this.customTrackers=[],this.mappedEvents={"wishlist::added":"Product Added to Wishlist","wishlist::removed":"Product Removed from Wishlist","salla-products-list::products.fetched":["Product List Viewed","Product List Filtered"],"auth::registered":"Signed Up","auth::logged.in":"Signed In","auth::logged.out":"Signed Out","share-element":"Product Shared","promotion::viewed":"Promotion Viewed","promotion::clicked":"Promotion Clicked","cart::coupon.added":"Coupon Applied","cart::coupon.deleted":"Coupon Removed","cart::coupon.addition.failed":"Coupon Denied","profile::updated":"User Profile Updated","cart::updated":"Cart Updated","scope::changed":"Market Selected"},Salla.event.onAny(((e,t)=>{try{if(Object.keys(this.mappedEvents).includes(e)){const r=this.mappedEvents[e];return void(Array.isArray(r)?r:[r]).forEach((e=>Salla.event.emit(e,t)))}if(!Salla.config.get("jitsu.events",[]).includes(e))return;const r=Md.transform(e,t);r&&this.track(r.event,r.properties)}catch(e){Salla.log("Error in analytics event handling:",e)}})),this.debugAnalytics=vd({host:"https://st.salla.dev",writeKey:"bbLD6Xqr1OKsDJfxZBCy7SJN1RIsrkBp:WEa99iY220v9qX7KiuAlML9ldSFJKW2p",fetch:this.customFetch}),this.debugAnalytics.setContextProperty("library",{twilight:Salla.versions}),Salla.event.on("twilight::init",(e=>{const{host:t,key:r}=e?.jitsu||{};this.jitsuAnalytics=null,t&&r?(Md.registerEvents(),this.jitsuAnalytics=vd({host:t,writeKey:r}),this.setContext("store_id",e.store?.id),this.setContext("version",e.jitsu?.version),this.setContext("library",{twilight:Salla.versions}),e.jitsu?.context?.extra&&this.setExtraContext(e.jitsu.context.extra),e.store?.scope?.id&&this.setContext("scope",e.store?.scope),"user"===e?.user?.type&&this.setContext("traits",this.getFormattedUser(e.user)),this.registerTracker({name:"DefaultSallaTracker",track:(e,t)=>this.jitsuAnalytics.track(e,t),page:e=>this.jitsuAnalytics.page(e)})):salla.log("Jitsu configuration is missing. Analytics will not be tracked.")})),Salla.onReady((()=>{const e={name:Salla.config.get("page.slug",""),id:Salla.config.get("page.id","")?.toString()};this.setContext("page",e),this.page(e)}))}setExtraContext(e){e?.headers?.["s-app-os"]&&(this.setContext("app",{version:e.headers["s-app-os-version"],app_release_tag:e.headers["s-app-version"],platform:e.headers["s-app-os"].toLowerCase()}),delete e.headers["s-app-os"],delete e.headers["s-app-os-version"],delete e.headers["s-app-version"],delete e.headers["s-source"]),this.setContext("system",e)}setContext(e,t){this.jitsuAnalytics?.setContextProperty(e,t),this.debugAnalytics.setContextProperty(e,t)}customFetch(e,t){return Salla.api.beaconRequest(`${e}?writekey=${t?.headers?.["X-Write-Key"]}`,t)}track(e,t={}){t=this.finalPayload(t),this.history.push({action:"track",eventName:e,payload:t}),this.pushEventToCustomTrackers("track",e,t)}log(e,t={}){return this.debugAnalytics?.track(e,t).catch((e=>(salla.log("Error tracking event:",e),Promise.reject(e))))}page(e={}){(e=this.finalPayload(e)).id=(e.id||Salla.config.get("page.id",""))?.toString(),e.name=e.name||Salla.config.get("page.slug"),e.keywords=e.keywords||document.querySelector("meta[name=keywords]")?.content,e.referrer=e.referrer||document.referrer,this.history.push({action:"page",payload:e}),this.pushEventToCustomTrackers("page",e)}finalPayload(e={}){const t=Salla.storage.getWithTTL("s-utms");if(t){const{"s-utm-campaign":e,"s-utm-source":r,"s-utm-medium":n,"s-utm-term":i,"s-utm-content":o,"s-utm-referrer":a}=t;Salla.analytics?.analytics?.setContextProperty("campaign",{name:e,source:r,medium:n,term:i,content:o,referrer:a})}return{...e}}registerTracker(e){"object"==typeof e?"string"==typeof e.name&&e.name?"function"==typeof e.track?"function"==typeof e.page?this.customTrackers.find((t=>t.name===e.name))?Salla.log("tracker with the same name already exists!"):(this.customTrackers.push(e),this.history.forEach((t=>"track"===t.action?e.track(t.eventName,t.payload):"page"===t.action?e.page(t.payload):void 0))):Salla.log("tracker.page most be a function!"):Salla.log("tracker.track most be a function!"):Salla.log("tracker.name most be a string!"):Salla.log('tracker most be an object {name:"tracker name", track: callback, page: callback}!')}pushEventToCustomTrackers(e,t,r={}){const n="page"===e?[t]:[t,r];return Promise.allSettled(this.customTrackers.map((t=>this.pushEventToCustomTracker(t[e],n)))).then((t=>t.filter((e=>"rejected"===e.status)).map((t=>Salla.log("Error on customTracker to send "+e,t)))))}pushEventToCustomTracker(e,t){try{const r=e(...t);return Promise.resolve(r).catch((e=>Promise.reject(e)))}catch(e){return Promise.reject(e)}}getFormattedUser(e){return e.phone=e.mobile,e.country=e.country_code,e.language=e.language_code,e.currency=e.currency_code,e}},Dr.init=e=>new bs(e),new class{constructor(e={}){this.config={WHITELIST:[location.hostname,"salla.com","salla.sa","salla.dev","salla.network","salla.group","mtjr.at"],POLL_INTERVAL_MS:500,WHITELIST_PAGES:["customer.orders.single","page-single","blog.single","blog.index"],...e},this.originalMethods={},this.isInitialized=!1,Salla.onReady((()=>this.init()))}normalizeUrl(e){try{return new URL(e,location.href)}catch{return null}}shouldIgnoreUrl(e){if(!e)return!1;const t="string"==typeof e?e:e.href||String(e),r=t.toLowerCase();if(["tel:","mailto:","javascript:"].some((e=>r.startsWith(e))))return!0;try{const e=new URL(t,location.href).hostname.toLowerCase();return["facebook.com","fb.com","twitter.com","x.com","instagram.com","linkedin.com","youtube.com","youtu.be","tiktok.com","snapchat.com","pinterest.com","whatsapp.com","wa.me","iwtsp.com","telegram.org","t.me","discord.com","discord.gg","reddit.com","tumblr.com","google.com","forms.gle","maps.app.goo.gl","goo.gl","apple.com","smsaexpress.com","aramex.com","aj-ex.com","redboxsa.com","fastcoo-tech.com","express.dhl","najizxpress.net","jtexpress.me","jtexpress-sa.com","tamex.com.sa","aymakan.com.sa","fastlo.com","sls-express.com","logestechs.com","massuul.com","tamara.co","gov.sa","org.sa","stc.com.sa","sa","addtoany.com","wchat.freshchat.com","getbutton.io","heyzine.com","linktr.ee"].some((t=>e===t||e.endsWith("."+t)))}catch{return!1}}isWhitelisted(e){if(!e)return!1;const t=e.hostname.toLowerCase();for(const e of this.config.WHITELIST){const r=String(e||"").toLowerCase().trim();if(r&&(t===r||t.endsWith("."+r)))return!0}return!1}emit(e){try{window.__redirectLogs||(window.__redirectLogs=[]),window.__redirectLogs.push(e);try{Salla.analytics.log("redirect",e)}catch{}}catch{}}logRedirect(e,t,r){if(this.shouldIgnoreUrl(t))return;const n=this.normalizeUrl(t),i=this.normalizeUrl(location.href),o=this.isWhitelisted(n),a={redirect_source:e,redirect_from:i?i.href:String(location.href),redirect_to:n?n.href:String(t),redirect_host:n?n.hostname:null,redirect_referrer:document.referrer||null,page_slug:Salla.config.get("page.slug"),whitelisted:o,stack:r&&r.stack?String(r.stack):void 0,meta:r||void 0};o||this.emit(a)}hookHistoryAPIs(){["pushState","replaceState"].forEach((e=>{try{const t=history[e];"function"==typeof t&&(this.originalMethods[`history.${e}`]=t,history[e]=(...r)=>{try{this.logRedirect(e,r[2]??location.href)}catch{}return t.apply(history,r)})}catch{}})),window.addEventListener("popstate",(()=>{this.logRedirect("popstate",location.href)})),window.addEventListener("hashchange",(()=>{this.logRedirect("hashchange",location.href)}))}hookLocationMethods(){try{const e=location.assign.bind(location);this.originalMethods["location.assign"]=e,location.assign=t=>(this.logRedirect("location.assign",t,{stack:(new Error).stack}),e(t))}catch{}try{const e=location.replace.bind(location);this.originalMethods["location.replace"]=e,location.replace=t=>(this.logRedirect("location.replace",t,{stack:(new Error).stack}),e(t))}catch{}}hookWindowOpen(){try{const e=window.open;this.originalMethods["window.open"]=e,window.open=(t,...r)=>(t&&this.logRedirect("window.open",t,{stack:(new Error).stack}),e.apply(window,[t,...r]))}catch{}}setupEventListeners(){this.handleLinkClick=e=>{const t=e.target&&e.target.closest?e.target.closest("a[href]"):null;if(!t)return;const r=t.getAttribute("href");if(!r||r.startsWith("#"))return;if(this.shouldIgnoreUrl(r))return;const n=t.getAttribute("target")||"_self";setTimeout((()=>{this.logRedirect("link-click",r,{target:n})}),0)},document.addEventListener("click",this.handleLinkClick,!0),this.handleFormSubmit=e=>{const t=e.target,r=t&&t.getAttribute&&t.getAttribute("action")||location.href,n=(t&&t.method?String(t.method):"GET").toUpperCase();this.logRedirect("form-submit",r,{method:n})},document.addEventListener("submit",this.handleFormSubmit,!0)}setupPerformanceObserver(){try{this.performanceObserver=new PerformanceObserver((e=>{for(const t of e.getEntries())"navigation"===t.entryType&&this.logRedirect("performance-navigation",location.href,{type:t.type,redirectCount:t.redirectCount})})),this.performanceObserver.observe({type:"navigation",buffered:!0})}catch{}}init(){if(this.config.WHITELIST_PAGES.includes(Salla.config.get("page.slug")))return;if(this.isInitialized)return;const e=new URL(Salla.config.get("store.url")).hostname.split(".").slice(-2).join(".");this.config.WHITELIST.includes(e)||this.config.WHITELIST.push(e),this.hookHistoryAPIs(),this.hookLocationMethods(),this.hookWindowOpen(),this.setupEventListeners(),this.setupPerformanceObserver(),this.isInitialized=!0}destroy(){this.isInitialized&&(Object.keys(this.originalMethods).forEach((e=>{const[t,r]=e.split(".");"history"===t&&this.originalMethods[e]?history[r]=this.originalMethods[e]:"location"===t&&this.originalMethods[e]?location[r]=this.originalMethods[e]:"window"===t&&"open"===r&&this.originalMethods[e]&&(window.open=this.originalMethods[e])})),this.handleLinkClick&&document.removeEventListener("click",this.handleLinkClick,!0),this.handleFormSubmit&&document.removeEventListener("submit",this.handleFormSubmit,!0),this.performanceObserver&&this.performanceObserver.disconnect(),this.isInitialized=!1)}},salla.event.once("twilight::init",salla.init),salla.event.on("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),Dr.success=Dr.notify.success,Dr.error=Dr.notify.error,Dr.versions.twilight="2.14.262 - October 9, 2025 06:23:45",window.dispatchEvent(new CustomEvent("salla::created")),Dr}));
|
|
19
|
+
*/var Pn=(kn||(kn=1,function(e,t){e.exports=function(){function e(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}function t(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}var r=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,n=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,i={locale:"en"},o=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return o.prototype.setMessages=function(e){this.messages=e},o.prototype.getLocale=function(){return this.locale||this.fallback},o.prototype.setLocale=function(e){this.locale=e},o.prototype.getFallback=function(){return this.fallback},o.prototype.setFallback=function(e){this.fallback=e},o.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},o.prototype.get=function(e,t,r){if(!this.has(e,r))return e;var n=this._getMessage(e,r);return null===n?e:(t&&(n=this._applyReplacements(n,t)),n)},o.prototype.trans=function(e,t){return this.get(e,t)},o.prototype.choice=function(e,t,r,i){(r=void 0!==r?r:{}).count=t;var o=this.get(e,r,i);if(null==o)return o;for(var a=o.split("|"),s=[],l=0;l<a.length;l++)if(a[l]=a[l].trim(),n.test(a[l])){var c=a[l].split(/\s/);s.push(c.shift()),a[l]=c.join(" ")}if(1===a.length)return o;for(var u=0;u<s.length;u++)if(this._testInterval(t,s[u]))return a[u];return i=i||this._getLocale(e),a[this._getPluralForm(t,i)]},o.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},o.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var r=e.split("."),n=r[0].replace(/\//g,".");return{source:t+"."+n,sourceFallback:this.getFallback()+"."+n,entries:r.slice(1)}},o.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var r=this.messages[e.source],n=e.entries.slice(),i=n.join(".");if("string"!=typeof(r=void 0!==r?this._getValueInKey(r,i):void 0)&&this.messages[e.sourceFallback])for(r=this.messages[e.sourceFallback],n=e.entries.slice(),i="";n.length&&void 0!==r;)r[i=i?i.concat(".",n.shift()):n.shift()]&&(r=r[i],i="");return"string"!=typeof r?null:r},o.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),n=0,i=r.length;n<i;++n){var o=r.slice(0,n+1).join("."),a=r.slice(n+1,r.length).join(".");if(e[o])return this._getValueInKey(e[o],a)}return e},o.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},o.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var r=e.join(".");if(t[r]){t=t[r];break}t=t[e.shift()]}return t},o.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},o.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(r){e=e.replace(new RegExp(":"+r,"gi"),(function(e){var n=t[r];return e===e.toUpperCase()?n.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?n.charAt(0).toUpperCase()+n.slice(1):n}))})),e},o.prototype._testInterval=function(e,n){if("string"!=typeof n)throw"Invalid interval: should be a string.";var i=(n=n.trim()).match(r);if(!i)throw"Invalid interval: "+n;if(!i[2]){var o=(i=i.filter((function(e){return!!e})))[1],a=t(i[2]);a===1/0&&(a=-1/0);var s=t(i[3]),l=i[4];return("["===o?e>=a:e>a)&&("]"===l?e<=s:e<s)}for(var c=i[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},o.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},o}()}(xn)),xn.exports);class An{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t=void 0,r=null){let n=Array.isArray(e),i=n?this.getUrl(...e):this.getUrl(e);e=n?e[0]:e,r=r||this.endpointsMethods[e]||"post";let o=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){let e={};Array.from(t.entries()).forEach((function(t){e[t[0]]=t[1]})),t={params:e}}return o&&"get"===r&&(t=t?Object.assign(t,o):o),this.webEndpoints.includes(e)?i=salla.url.get(i):"http"!==i.substring(0,4)&&(i=salla.url.api(i)),Salla.api.request(i,t,r,{headers:o})}request(e,t=void 0,r=null){return!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,r)):this.normalRequest(e,t,r)}getUrl(e){let t=this.endpoints[e]||e;const r=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(r,arguments[e]);return t}event(){return salla.event[this.className]}}class In extends An{constructor(){super(),this.addToCartTries=0,this.namespace="cart",this._pendingCartIdRequest=null,this.endpoints={latest:"cart/latest",latestApi:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}",giftCartDetails:"cart/{cartId}/buy-as-gift",cartGiftToCart:"cart/{cart_id}/buy-as-gift"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get",giftCartDetails:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",(()=>salla.api.cart.getCurrentCartId(!1,"api::initiated"))),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",(()=>salla.api.cart.getCurrentCartId(!0,"auth::verified")),{async:!0}),salla.event.on("twilight::initiated",(()=>salla.api.cart.syncGuestCart())),salla.event.on("profile::info.fetched",this._checkCurrentCart),salla.event.on("twilight::error",(e=>(e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()))}_checkCurrentCart(){let e=salla.storage.get("cart"),t=salla.config.get("user")?.id,r=salla.config.get("store")?.id;e&&e.id&&(e.user_id===t&&e.store_id===r||(salla.log("cart",{user_id:e.user_id,store_id:e.store_id}),salla.log("current",{user_id:t,store_id:r}),salla.log("Api:: case2 => The cart is not belong to current "+(e.user_id!==t?"user":"store")+"!"),salla.cart.api.reset()),salla.url.is_page("cart")&&e.id!==salla.config.get("page.id")&&(salla.log("cart",{user_id:e.user_id,store_id:e.store_id}),salla.log("current",{user_id:t,store_id:r}),salla.log(`Api:: case2 => The cart is different between storage:${e.id} & session:${salla.config.get("page.id")} !`),salla.cart.api.reset()))}async getCurrentCartId(e=!1,t="getCurrentCartId"){if(Salla.cart.api._pendingCartIdRequest)return Salla.cart.api._pendingCartIdRequest;Salla.cart.api._pendingCartIdRequest=(async()=>{try{if(!e){if(Salla.cart.api.latestCart)return Salla.cart.api.latestCart.cart.id;let e=Salla.storage.get("cart.id");if(e)return e}let r=await Salla.cart.api.latest(t);return Salla.cart.api.latestCart=r.data,Salla.cart.api.latestCart.cart.id}finally{Salla.cart.api._pendingCartIdRequest=null}})();let r=Salla.cart.api._pendingCartIdRequest;return Salla.cart.api._pendingCartIdRequest=null,r}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(e="direct"){return this.request(salla.auth.api.isSessionless()?"latestApi":"latest",{params:{source:"",callerName:e}}).then((e=>(salla.api.cart.set(e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.api.cart.reset(),salla.event.cart.latestFailed(e),e}))}async details(e,t=[]){return e=e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.details"),this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e,t,r){return this.addItem({id:e,quantity:t,offerType:r,endpoint:"quickAdd"})}async addItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no product "id"!';return salla.cart.event.itemAddedFailed(e),salla.api.errorPromise(e)}let r=salla.form.getPossibleValue(t.payload,["endpoint"]);r&&["addItem","quickAdd"].includes(r)||(r=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let n=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addItem");return this.request([r,n,t.id],t.payload).then((function(e){return salla.cart.api.addToCartTries=0,salla.cart.event.itemAdded(e,t.id),e})).catch((function(r){if(!salla.cart.api.addToCartTries)return salla.cart.api.addToCartTries++,salla.cart.reset(),salla.cart.api.addItem(e);throw salla.cart.event.itemAddedFailed(r,t.id),r}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),salla.api.errorPromise(e)}let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteItem");return this.request(["deleteItem",r,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))}async updateItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemUpdatedFailed(e),salla.api.errorPromise(e)}let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.updateItem");return"Object"===t.payload.constructor?.name?t.payload._method="PUT":t.payload.append("_method","PUT"),this.request(["updateItem",r,t.id],t.payload).then((function(e){return salla.cart.event.itemUpdated(e,t.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,t.id),e}))}async deleteImage(e){if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){let e='There is no "id"!';return salla.cart.event.imageNotDeleted(e),salla.api.errorPromise(e)}let t=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteImage");return this.request(["deleteImage",t,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))}async status(e,t=!1){e=e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.status");const r={has_apple_pay:salla.helpers.hasApplePay()};t&&(r.guest_checkout=1);try{await salla.cart.event.submitting()}catch(e){salla.log("Error on: salla.cart.event.submitting()")}return this.request(["status",e],{params:r})}async submit(e=!1){if(console.log("salla.cart.api.submit",{isGuestCheckout:e}),salla.config.isGuest()&&!e)return salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage();this.status(await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.submit"),e).then((e=>{let t=e.data.next_step?.to;if(t||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(e),e}return salla.cart.event.submitted(e),"login"===t?salla.cart.loginOnCartPage():"checkout"===t?window.location.href=e.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(e){salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();let t=404===e?.response?.data?.status;if(t&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit();throw t&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}}normalRequest(e,t=void 0,r=null){return super.normalRequest(e,t,r).catch((async e=>{throw 403===e?.response?.status&&(this.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cookie.clearCookieByPrefix(salla.api.cart.getCartCookiePrefix()),salla.cart.event.successReset()}async addCoupon(e){if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(e),salla.api.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.addCoupon");return this.request(["addCoupon",t],{coupon:e}).then((function(e){let r=salla.storage.get("cart");return r&&e.data?.cart?.coupon&&(r.coupon=e.data.cart.coupon,salla.storage.set("cart",r)),salla.event.cart.couponAdded(e,t),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,t),e}))}async deleteCoupon(){let e=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.deleteCoupon");return this.request(["deleteCoupon",e],{}).then((function(t){let r=salla.storage.get("cart");return r&&r.coupon&&(delete r.coupon,salla.storage.set("cart",r)),salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then((e=>(salla.event.cart.quickOrderSettingFetched(e),e))).catch((e=>{throw salla.event.cart.quickOrderSettingFailed(e),e}))}createQuickOrder(e){return this.request("createQuickOrder",e).then((e=>(salla.event.cart.quickOrderSucceeded(e),e))).catch((e=>{throw salla.event.cart.quickOrderFailed(e),e}))}async priceQuote(e){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open")):this.request(["priceQuote",e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.priceQuote")]).then((e=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((()=>(setTimeout((()=>window.location.href=salla.url.get("/")),1e3),e)))))).catch((e=>salla.event.cart.priceQuoteFailed(e).then((()=>{throw 404===e.error?.code&&window.location.reload(),e}))))}loginOnCartPage(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open",{withoutReload:!0,source:"cart-submit"}),salla.auth.event.onLoggedIn((()=>{salla.event.dispatch("login::close"),salla.cart.submit()}))}set(e){salla.storage.set("cart",e),salla.api.cart.syncGuestCart()}async offers(){const e=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.offers");return this.request(["offers",e]).then((e=>(salla.event.cart.offersFetched(e),e))).catch((e=>{throw salla.event.cart.offersFailed(e),e}))}async getGiftCartDetails(){let e=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.getGiftCartDetails");return this.request(["giftCartDetails",e]).then((t=>(salla.product.event.giftFetched(t,e),t))).catch((t=>{throw salla.product.event.giftFetchFailed(t,e),t}))}async addCartGiftToCart(e,t=!1){let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addCartGiftToCart");return this.request(["cartGiftToCart",r],e).then((e=>(salla.product.event.addGiftToCartSucceeded(e,r),t&&(window.location.href=e.redirect),e))).catch((e=>{throw salla.product.event.addGiftToCartFailed(e,r),e}))}async syncGuestCart(){if(!salla.config.isGuest())return;const e=salla.api.cart.getCartCookiePrefix(),t=salla.cookie.getCookieByPrefix(e),r=salla.storage.get("cart.id");if(!r&&t.length)try{const t=await salla.api.cart.latest(),r=t.data?.cart?.id;r&&salla.api.cart.setCartCookie(e,r)}catch(e){salla.log("Failed to fetch latest cart:",e)}salla.cookie.clearCookieByPrefix(e),r&&(salla.config.set("headers.s-cart-id",r),salla.api.cart.setCartCookie(e,r))}setCartCookie(e,t){salla.cookie.set(`${e}-${t}`,t,1)}getCartCookiePrefix(){return"cart-id-"+salla.config.get("store.id")}}class On extends An{constructor(){super(),this.namespace="loyalty",this.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},this.endpointsMethods={getProgram:"get",reset:"put"},this.after_init()}getProgram(){return this.request("getProgram").then((e=>(salla.loyalty.event.programFetched(e),e))).catch((e=>{throw salla.loyalty.event.programNotFetched(e),e}))}async exchange(e,t=null){if(!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}if(!(t=t||await salla.cart.getCurrentCartId(!1,"salla.api.loyalty.exchange"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}return this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))}async reset(e=null){if(!(e=e||await salla.cart.getCurrentCartId(!1,"salla.api.loyalty.reset"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(e),salla.api.errorPromise(e)}return this.request("reset",{cart_id:e}).then((e=>(salla.loyalty.event.resetSucceeded(e),e))).catch((e=>{throw salla.loyalty.event.resetFailed(e),e}))}}class Tn extends An{constructor(){super(),this.namespace="auth",this.canRedirect_=!0,this.afterLoginEvent={event:null,payload:null},this.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},this.webEndpoints=["logout","auth/jwt","refresh"],this.endpointsMethods={logout:"get"},this.inIframe=salla.helpers.isIframe(),Salla.event.on("twilight::init",(function(){if(Salla.config.isGuest()&&location.href.includes("force_logout"))return delete Salla.api.axios.defaults.headers.common.Authorization,Salla.api.auth.logout("twilight",!1)})),this.after_init()}setAfterLoginEvent(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}}setCanRedirect(e){salla.api.auth.canRedirect_=e}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(e){e?.data&&(e=e.data);let t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){let e="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(e),salla.api.errorPromise(e)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),salla.auth.api.trackBlockedError(e,"login"),e}))}async verify(e,t=!0){let r=salla.form.getPossibleValue(e,["type"]);if(!r){let e="Failed to know what's login type!";return salla.auth.event.verificationFailed(e),salla.api.errorPromise(e)}t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);let n=await salla.auth.api.request(["verify",r],e);return 200!==n?.status?(salla.auth.event.verificationFailed(n,r),salla.api.errorPromise(n)):salla.auth.api.handlAfterAuthenticatedResponse(n,t)}async handlAfterAuthenticatedResponse(e,t){e.data||(e={data:e});let r="authenticated"===e.data?.case;return r&&salla.auth.event.tokenFetched(e.data.token),t&&!this.inIframe&&!this.isSessionless()&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.api.handlAfterAuthenticatedResponse"}),r&&await salla.auth.event.loggedIn(e).then((()=>salla.auth.api.afterUserLogin())),await salla.auth.event.verified(e,e.data.verification.type),salla.api.successPromise(e)}resend(e){let t;return(e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),salla.auth.api.trackBlockedError(t,"resend"),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))}register(e){let t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((async e=>(salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),!this.inIframe&&!this.isSessionless()&&await salla.auth.request("auth/jwt",{callerName:"salla.auth.api.register"}),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e))).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),salla.auth.api.trackBlockedError(e,"register"),e}))}handleIframeReadyAction(e,t){e.contentWindow?.postMessage({source:"logout",type:"init",data:{id:salla.config.get("store.id"),lang:"ar",appUrl:t,apiUrl:salla.config.get("store.api").replace(/\/+$/,""),settings:salla.config.all(),storage:{}}},"*")}appendIframeAndLogout(){return new Promise((e=>{let t=salla.config.get("login.url","https://accounts.salla.com");const r=document.createElement("iframe");r.style.display="none",r.src=`${t}/logout`;const n=i=>{if("login"!==i.data.source)return;let o=i.data.type.replace("iframe::","");if(salla.log("iframe::logout-iframe message received",i.data),["logged-out","ready"].includes(o)){if("ready"===o)return this.handleIframeReadyAction(r,t);window.removeEventListener("message",n),r.remove(),e()}};window.addEventListener("message",n),document.body.appendChild(r)}))}logout(e="twilight",t=!0){return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((()=>this.appendIframeAndLogout())).then((()=>{if(!t)return;let r=salla.url.get(`logout?from=${e}`);console.log(`Going to ${r}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=r}catch(e){salla.log(e)}})).catch((e=>console.error("Error during logout:",e)))}refresh(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}isSessionless(){return"sessionless"===salla.config.get("auth.mode")}trackBlockedError(e,t){blockedByProxy=void 0===e?.response?.headers?.["s-ray"],blockedByProxy&&salla.analytics.track("BlockedByProxy",{class:"auth",function:t,reason:"non-server-request",message:e.message})}}class jn extends An{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},this.endpointsMethods={createCartFromOrder:"get",fetch:"get"},this.after_init()}show(e){let t=salla.form.getPossibleValue(e?.data||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue(e?.data||e,["url"])}cancel(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){let e="There is no id!";return salla.order.event.invoiceNotSent(e),salla.api.errorPromise(e)}return this.request(["sendInvoice",t],e).then((e=>(salla.event.order.invoiceSent(e,t),e))).catch((e=>{throw salla.event.order.invoiceNotSent(e,t),e}))}fetch(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.order.ordersFetched(e),e})).catch((function(e){throw salla.event.order.ordersNotFetched(e),e}))}}class Cn extends An{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftProductDetails:"products/{product_id}/buy-as-gift",productGiftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options"},this.endpointsMethods={details:"get",giftProductDetails:"get",fetch:"get",offers:"get",fetchOptions:"get"},this.after_init()}getPrice(e){let t=e.data||e,r=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",r],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,r),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,r),e}))}categories(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))}availabilitySubscribe(e){let t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}search(e){let t=e.data;if(t||(t={params:"string"==typeof e?{query:e}:e}),!(e=t instanceof FormData?t.get("query"):t.query||t.params?.query)){let e='There is no "query"!';return salla.product.event.searchFailed(e),salla.api.errorPromise(e)}if(e===salla.api.product.previousQuery){let e="Query is same as previous one!";return salla.product.event.searchFailed(e),salla.api.product.previousQuery=null,salla.api.errorPromise(e)}return salla.api.product.previousQuery=e,this.request("search",t,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))}offers(e){if(!(e=salla.form.getPossibleValue(e?.data|e,["product_id","id"]))){let e='There is no "product_id"!';return salla.product.event.fetchOffersFailed(e),salla.api.errorPromise(e)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))}getSizeGuides(e){return this.request(`products/${e}/size-guides`,null,"get").then((t=>(salla.product.event.sizeGuideFetched(t,e),t))).catch((t=>{throw salla.product.event.sizeGuideFetchFailed(t,e),t}))}getGiftProductDetails(e){return this.request(["giftProductDetails",e]).then((t=>(salla.product.event.giftFetched(t,e),t))).catch((t=>{throw salla.product.event.giftFetchFailed(t,e),t}))}getDetails(e,t=[]){if(!Array.isArray(t)){let e="withItems should be array.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}if(!e){let e="productId is not passed.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}addProductGiftToCart(e,t,r=!1){return this.request(["productGiftToCart",e],t).then((t=>(salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),t))).catch((t=>{throw salla.product.event.addGiftToCartFailed(t,e),t}))}uploadGiftImage(e){return this.request("giftImage",e).then((e=>(salla.product.event.giftImageUploadSucceeded(e),e))).catch((e=>{throw salla.product.event.giftImageUploadFailed(e),e}))}fetch(e){if(!e.source){const e="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}const t=!e.source_value,r="string"==typeof e.source_value&&"[]"===e.source_value,n=Array.isArray(e.source_value)&&!e.source_value.length;if((t||r||n)&&!["offers","latest","sales","wishlist","top-rated"].includes(e.source)){const e="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){const e="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("search"===e.source&&"string"!=typeof e.source_value){const e="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("related"===e.source&&isNaN(e.source_value)){const e="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}return this.request(this.endpoints.fetch,{params:e},"get").then((async e=>(salla.product.event.productListFetchSucceeded(e),e))).catch((e=>{throw salla.product.event.productListFetchFailed(e),e}))}fetchOptions(e,t={}){if(!e||0===e.length){const e="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(e),salla.api.errorPromise(e)}const{with:r=[]}=t,n={selected:e};return r.length>0&&(n.with=r),this.request(this.endpoints.fetchOptions,{params:n},"get").then((e=>(salla.product.event.productOptionsFetched(e),e))).catch((e=>{throw salla.product.event.productOptionsNotFetched(e),e}))}}class Rn extends An{constructor(){super(),this.namespace="profile",this.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},this.endpointsMethods={delete:"delete"},this.after_init()}syncUserData(e){let t={id:e.id,type:"user",email:e.email,mobile:e.phone.code+e.phone.number,country_code:e.phone.country,language_code:e.language,currency_code:e.currency,notifications:e.notifications,pending_orders:e.pending_orders,avatar:e.avatar,first_name:e.first_name,last_name:e.last_name,is_hidden_name:e.is_hidden_name,is_notifiable:e.is_notifiable,can_comment:salla.config.get("user.can_comment"),fetched_at:Date.now()};salla.config.set("user",t),salla.storage.set("user",t)}info(){return this.request("info",null,"get").then((e=>(this.syncUserData(e.data),salla.profile.event.infoFetched(e),e))).catch((e=>{throw salla.profile.event.infoNotFetched(e),e}))}update(e){if(Salla.config.get("store.features",[]).includes("sso-login")){const e="SSO login is enabled. You cannot update your profile.";return Salla.error(e),Promise.reject(new Error(e))}return this.request("update",e).then((e=>(this.syncUserData(e.data),salla.profile.event.updated(e),e))).catch((e=>{throw salla.event.profile.updateFailed(e),e}))}updateContacts(e){return this.request("updateContacts",e).then((e=>(salla.profile.event.verificationCodeSent(e),e))).catch((e=>{throw salla.event.profile.updateContactsFailed(e),e}))}verify(e){return this.request("verify",e).then((e=>(salla.profile.event.verified(e),e))).catch((e=>{throw salla.event.profile.unverified(e),e}))}updateSettings(e){return this.request("updateSettings",e).then((e=>(salla.event.profile.settingsUpdated(e),e))).catch((e=>{throw salla.event.profile.updateSettingsFailed(e),e}))}delete(){return this.request("delete").then((e=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.api.appendIframeAndLogout().then((()=>{salla.event.profile.deleted(e),window.location.href=salla.url.get("logout")})),e))).catch((e=>{throw salla.event.profile.notDeleted(e),e}))}}class Fn extends An{constructor(){super(),this.namespace="comment",this.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},this.after_init()}add(e){if(e?.data&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,!0)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){let e="can't find comment content!";return salla.event.comment.additionFailed(e),salla.api.errorPromise(e)}return this.request(["addComment","blog"==e.type?"blogs":e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))}getCommentPayload(e,t=!1){let r={};if(["id","type","comment","per_page","page","sort"].forEach((t=>{let n=salla.form.getPossibleValue(e,[t]);n&&(r[t]=n)})),!t){let t=e.ids;if(t&&(r.ids=Array.isArray(t)?t:[t]),!r.ids||!r.ids.length)return"Failed to get ids!"}return r.type&&["products","pages","product","page","blogs","blog"].includes(r.type)?(r.type+=["product","page"].includes(r.type)?"s":"",r):"Failed to get type one of:(products, product, page, pages, blog, blogs)!"}fetchComments(e){if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);const t={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(t.sort=e.sort),this.request(["comments"],{params:t},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))}getComments(e,t,r=1,n=5,i){const o=Array.isArray(t)?t:[t];return this.fetchComments({ids:o,type:`${e}s`,page:r,per_page:n,sort:i})}}class Ln extends An{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){let e="Can't find currency code!";return salla.currency.event.failed(e),salla.api.errorPromise(e)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))}list(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))}}class Un extends An{constructor(){super(),this.namespace="document"}reload(){window.location.reload()}}class Nn extends An{constructor(){super(),this.namespace="rating",this.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},this.endpointsMethods={order:"get"},this.after_init()}order(e){let t="object"==typeof e?e:{},r=salla.form.getPossibleValue(e?.data||e,["order_id","id"]);if(!r){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),salla.api.errorPromise(e)}return this.request(["order",r],t).then((function(e){return salla.event.rating.orderFetched(e,r),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,r),e}))}store(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.storeFailed(e),salla.api.errorPromise(e)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))}products(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.productsFailed(e),salla.api.errorPromise(e)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))}shipping(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.shippingFailed(e),salla.api.errorPromise(e)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))}}class qn extends An{constructor(){super(),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},Salla.onReady((()=>{"customer.wishlist"===Salla.config.get("page.slug")&&(Salla.storage.getWithTTL("s-utms")?.["s-utm-source"]||this.injectSourceIntoRequest())}))}injectSourceIntoRequest(){Salla.api.axios.interceptors.request.use((e=>(e.headers={...e.headers,"s-utm-source":"wishlist"},e)),(e=>Promise.reject(e)))}toggle(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)}add(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["add",e]).then((t=>(this.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t))).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(t="Failed to get product id!"),salla.api.errorPromise(t))}remove(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["remove",e]).then((t=>(this.updateWishlistStorage(e,!1),salla.wishlist.event.removed(t,e),t))).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(t="Failed to get id!"),salla.api.errorPromise(t))}updateWishlistStorage(e,t=!0){let r=salla.storage.get("salla::wishlist",[]);t?r.push(e):r.splice(r.indexOf(e),1),salla.storage.set("salla::wishlist",r)}}class zn extends An{constructor(){super(),this.namespace="scopes",this.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},this.after_init()}get(){return this.request("scopes",null,"get").then((e=>(salla.scope.event.fetched(e),e))).catch((e=>{throw salla.scope.event.notFetched(e),e}))}change(e){return this.request("scopes",e).then((e=>(salla.scope.event.changeSucceeded(e),e))).catch((e=>{throw salla.scope.event.changeFailed(e),e}))}getProductAvailability(e=null){return this.request(`scopes/availability?product_id=${e}`,null,"get").then((t=>(salla.scope.event.productAvailabilityFetched(t,e),t))).catch((e=>{throw salla.scope.event.productAvailabilityNotFetched(e),e}))}}class Dn extends An{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(e,t=!0){if(!e){let e="Please provide product id.";return salla.booking.event.additionFailed(e),salla.api.errorPromise(e)}return this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))}}class $n extends An{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},this.endpointsMethods={getDetails:"get",breadcrumbs:"get"},this.after_init()}getDetails(e){if(!e){let e="page landing id not passed";return salla.event.landing.getDetailsFailed(e),salla.api.errorPromise(e)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))}createCartFromPage(e){if(!e){let e="page landing id not passed";return salla.event.landing.orderCreationFailed(e),salla.api.errorPromise(e)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((()=>location.href=t.data.url)),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if("product.single"===e.page&&!e.id&&!e.parent_id){let e="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.landing.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e}))}}class Mn extends An{constructor(){super(),this.namespace="notifications",this.endpoints={fetch:"notifications"},this.endpointsMethods={fetch:"get"},this.after_init()}fetch(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.notifications.fetched(e),e})).catch((function(e){throw salla.event.notifications.fetchFailed(e),e}))}}function Bn(e,t){return function(){return e.apply(t,arguments)}}const{toString:Hn}=Object.prototype,{getPrototypeOf:Jn}=Object,{iterator:Gn,toStringTag:Wn}=Symbol,Vn=(Yn=Object.create(null),e=>{const t=Hn.call(e);return Yn[t]||(Yn[t]=t.slice(8,-1).toLowerCase())});var Yn;const Kn=e=>(e=e.toLowerCase(),t=>Vn(t)===e),Qn=e=>t=>typeof t===e,{isArray:Xn}=Array,Zn=Qn("undefined");const ei=Kn("ArrayBuffer");const ti=Qn("string"),ri=Qn("function"),ni=Qn("number"),ii=e=>null!==e&&"object"==typeof e,oi=e=>{if("object"!==Vn(e))return!1;const t=Jn(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Wn in e||Gn in e)},ai=Kn("Date"),si=Kn("File"),li=Kn("Blob"),ci=Kn("FileList"),ui=Kn("URLSearchParams"),[di,hi,fi,pi]=["ReadableStream","Request","Response","Headers"].map(Kn);function gi(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),Xn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let a;for(n=0;n<o;n++)a=i[n],t.call(null,e[a],a,e)}}function mi(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const vi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Qe,yi=e=>!Zn(e)&&e!==vi;const bi=(wi="undefined"!=typeof Uint8Array&&Jn(Uint8Array),e=>wi&&e instanceof wi);var wi;const _i=Kn("HTMLFormElement"),Si=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Ei=Kn("RegExp"),ki=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};gi(r,((r,i)=>{let o;!1!==(o=t(r,i,e))&&(n[i]=o||r)})),Object.defineProperties(e,n)};const xi=Kn("AsyncFunction"),Pi=(Ai="function"==typeof setImmediate,Ii=ri(vi.postMessage),Ai?setImmediate:Ii?(Oi=`axios@${Math.random()}`,Ti=[],vi.addEventListener("message",(({source:e,data:t})=>{e===vi&&t===Oi&&Ti.length&&Ti.shift()()}),!1),e=>{Ti.push(e),vi.postMessage(Oi,"*")}):e=>setTimeout(e));var Ai,Ii,Oi,Ti;const ji="undefined"!=typeof queueMicrotask?queueMicrotask.bind(vi):void 0!==Ht&&Ht.nextTick||Pi;var Ci={isArray:Xn,isArrayBuffer:ei,isBuffer:function(e){return null!==e&&!Zn(e)&&null!==e.constructor&&!Zn(e.constructor)&&ri(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||ri(e.append)&&("formdata"===(t=Vn(e))||"object"===t&&ri(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&ei(e.buffer),t},isString:ti,isNumber:ni,isBoolean:e=>!0===e||!1===e,isObject:ii,isPlainObject:oi,isReadableStream:di,isRequest:hi,isResponse:fi,isHeaders:pi,isUndefined:Zn,isDate:ai,isFile:si,isBlob:li,isRegExp:Ei,isFunction:ri,isStream:e=>ii(e)&&ri(e.pipe),isURLSearchParams:ui,isTypedArray:bi,isFileList:ci,forEach:gi,merge:function e(){const{caseless:t}=yi(this)&&this||{},r={},n=(n,i)=>{const o=t&&mi(r,i)||i;oi(r[o])&&oi(n)?r[o]=e(r[o],n):oi(n)?r[o]=e({},n):Xn(n)?r[o]=n.slice():r[o]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&gi(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(gi(t,((t,n)=>{r&&ri(t)?e[n]=Bn(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,o,a;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)a=i[o],n&&!n(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==r&&Jn(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:Vn,kindOfTest:Kn,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(Xn(e))return e;let t=e.length;if(!ni(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Gn]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:_i,hasOwnProperty:Si,hasOwnProp:Si,reduceDescriptors:ki,freezeMethods:e=>{ki(e,((t,r)=>{if(ri(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];ri(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return Xn(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:mi,global:vi,isContextDefined:yi,isSpecCompliantForm:function(e){return!!(e&&ri(e.append)&&"FormData"===e[Wn]&&e[Gn])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(ii(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=Xn(e)?[]:{};return gi(e,((e,t)=>{const o=r(e,n+1);!Zn(o)&&(i[t]=o)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:xi,isThenable:e=>e&&(ii(e)||ri(e))&&ri(e.then)&&ri(e.catch),setImmediate:Pi,asap:ji,isIterable:e=>null!=e&&ri(e[Gn])},Ri=[],Fi=[],Li="undefined"!=typeof Uint8Array?Uint8Array:Array,Ui=!1;function Ni(){Ui=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Ri[t]=e[t],Fi[e.charCodeAt(t)]=t;Fi["-".charCodeAt(0)]=62,Fi["_".charCodeAt(0)]=63}function qi(e,t,r){for(var n,i,o=[],a=t;a<r;a+=3)n=(e[a]<<16)+(e[a+1]<<8)+e[a+2],o.push(Ri[(i=n)>>18&63]+Ri[i>>12&63]+Ri[i>>6&63]+Ri[63&i]);return o.join("")}function zi(e){var t;Ui||Ni();for(var r=e.length,n=r%3,i="",o=[],a=16383,s=0,l=r-n;s<l;s+=a)o.push(qi(e,s,s+a>l?l:s+a));return 1===n?(t=e[r-1],i+=Ri[t>>2],i+=Ri[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=Ri[t>>10],i+=Ri[t>>4&63],i+=Ri[t<<2&63],i+="="),o.push(i),o.join("")}function Di(e,t,r,n,i){var o,a,s=8*i-n-1,l=(1<<s)-1,c=l>>1,u=-7,d=r?i-1:0,h=r?-1:1,f=e[t+d];for(d+=h,o=f&(1<<-u)-1,f>>=-u,u+=s;u>0;o=256*o+e[t+d],d+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=n;u>0;a=256*a+e[t+d],d+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),o-=c}return(f?-1:1)*a*Math.pow(2,o-n)}function $i(e,t,r,n,i,o){var a,s,l,c=8*o-i-1,u=(1<<c)-1,d=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?h/l:h*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&s,f+=p,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;e[r+f]=255&a,f+=p,a/=256,c-=8);e[r+f-p]|=128*g}var Mi={}.toString,Bi=Array.isArray||function(e){return"[object Array]"==Mi.call(e)};function Hi(){return Gi.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ji(e,t){if(Hi()<t)throw new RangeError("Invalid typed array length");return Gi.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Gi.prototype:(null===e&&(e=new Gi(t)),e.length=t),e}function Gi(e,t,r){if(!(Gi.TYPED_ARRAY_SUPPORT||this instanceof Gi))return new Gi(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Yi(this,e)}return Wi(this,e,t,r)}function Wi(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);Gi.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Gi.prototype:e=Ki(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!Gi.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Zi(t,r);e=Ji(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(Xi(t)){var r=0|Qi(t.length);return 0===(e=Ji(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?Ji(e,0):Ki(e,t);if("Buffer"===t.type&&Bi(t.data))return Ki(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Vi(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Yi(e,t){if(Vi(t),e=Ji(e,t<0?0:0|Qi(t)),!Gi.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function Ki(e,t){var r=t.length<0?0:0|Qi(t.length);e=Ji(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function Qi(e){if(e>=Hi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Hi().toString(16)+" bytes");return 0|e}function Xi(e){return!(null==e||!e._isBuffer)}function Zi(e,t){if(Xi(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Ao(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Io(e).length;default:if(n)return Ao(e).length;t=(""+t).toLowerCase(),n=!0}}function eo(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return mo(this,t,r);case"utf8":case"utf-8":return ho(this,t,r);case"ascii":return po(this,t,r);case"latin1":case"binary":return go(this,t,r);case"base64":return uo(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vo(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function to(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function ro(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=Gi.from(t,n)),Xi(t))return 0===t.length?-1:no(e,t,r,n,i);if("number"==typeof t)return t&=255,Gi.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):no(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function no(e,t,r,n,i){var o,a=1,s=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var u=-1;for(o=r;o<s;o++)if(c(e,o)===c(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===l)return u*a}else-1!==u&&(o-=o-u),u=-1}else for(r+l>s&&(r=s-l),o=r;o>=0;o--){for(var d=!0,h=0;h<l;h++)if(c(e,o+h)!==c(t,h)){d=!1;break}if(d)return o}return-1}function io(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[r+a]=s}return a}function oo(e,t,r,n){return Oo(Ao(t,e.length-r),e,r,n)}function ao(e,t,r,n){return Oo(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function so(e,t,r,n){return ao(e,t,r,n)}function lo(e,t,r,n){return Oo(Io(t),e,r,n)}function co(e,t,r,n){return Oo(function(e,t){for(var r,n,i,o=[],a=0;a<e.length&&!((t-=2)<0);++a)n=(r=e.charCodeAt(a))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function uo(e,t,r){return 0===t&&r===e.length?zi(e):zi(e.slice(t,r))}function ho(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,a,s,l,c=e[i],u=null,d=c>239?4:c>223?3:c>191?2:1;if(i+d<=r)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(o=e[i+1]))&&(l=(31&c)<<6|63&o)>127&&(u=l);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(l=(15&c)<<12|(63&o)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=d}return function(e){var t=e.length;if(t<=fo)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=fo));return r}(n)}Gi.TYPED_ARRAY_SUPPORT=void 0===Qe.TYPED_ARRAY_SUPPORT||Qe.TYPED_ARRAY_SUPPORT,Hi(),Gi.poolSize=8192,Gi._augment=function(e){return e.__proto__=Gi.prototype,e},Gi.from=function(e,t,r){return Wi(null,e,t,r)},Gi.TYPED_ARRAY_SUPPORT&&(Gi.prototype.__proto__=Uint8Array.prototype,Gi.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Gi[Symbol.species]),Gi.alloc=function(e,t,r){return function(e,t,r,n){return Vi(t),t<=0?Ji(e,t):void 0!==r?"string"==typeof n?Ji(e,t).fill(r,n):Ji(e,t).fill(r):Ji(e,t)}(null,e,t,r)},Gi.allocUnsafe=function(e){return Yi(null,e)},Gi.allocUnsafeSlow=function(e){return Yi(null,e)},Gi.isBuffer=function(e){return null!=e&&(!!e._isBuffer||To(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&To(e.slice(0,0))}(e))},Gi.compare=function(e,t){if(!Xi(e)||!Xi(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},Gi.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Gi.concat=function(e,t){if(!Bi(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Gi.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=Gi.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!Xi(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},Gi.byteLength=Zi,Gi.prototype._isBuffer=!0,Gi.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)to(this,t,t+1);return this},Gi.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)to(this,t,t+3),to(this,t+1,t+2);return this},Gi.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)to(this,t,t+7),to(this,t+1,t+6),to(this,t+2,t+5),to(this,t+3,t+4);return this},Gi.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?ho(this,0,e):eo.apply(this,arguments)},Gi.prototype.equals=function(e){if(!Xi(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Gi.compare(this,e)},Gi.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Gi.prototype.compare=function(e,t,r,n,i){if(!Xi(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),l=this.slice(n,i),c=e.slice(t,r),u=0;u<s;++u)if(l[u]!==c[u]){o=l[u],a=c[u];break}return o<a?-1:a<o?1:0},Gi.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},Gi.prototype.indexOf=function(e,t,r){return ro(this,e,t,r,!0)},Gi.prototype.lastIndexOf=function(e,t,r){return ro(this,e,t,r,!1)},Gi.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return io(this,e,t,r);case"utf8":case"utf-8":return oo(this,e,t,r);case"ascii":return ao(this,e,t,r);case"latin1":case"binary":return so(this,e,t,r);case"base64":return lo(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return co(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Gi.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var fo=4096;function po(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function go(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function mo(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=Po(e[o]);return i}function vo(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function yo(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function bo(e,t,r,n,i,o){if(!Xi(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function wo(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function _o(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function So(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Eo(e,t,r,n,i){return i||So(e,0,r,4),$i(e,t,r,n,23,4),r+4}function ko(e,t,r,n,i){return i||So(e,0,r,8),$i(e,t,r,n,52,8),r+8}Gi.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),Gi.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=Gi.prototype;else{var i=t-e;r=new Gi(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},Gi.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},Gi.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},Gi.prototype.readUInt8=function(e,t){return t||yo(e,1,this.length),this[e]},Gi.prototype.readUInt16LE=function(e,t){return t||yo(e,2,this.length),this[e]|this[e+1]<<8},Gi.prototype.readUInt16BE=function(e,t){return t||yo(e,2,this.length),this[e]<<8|this[e+1]},Gi.prototype.readUInt32LE=function(e,t){return t||yo(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Gi.prototype.readUInt32BE=function(e,t){return t||yo(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Gi.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},Gi.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||yo(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Gi.prototype.readInt8=function(e,t){return t||yo(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Gi.prototype.readInt16LE=function(e,t){t||yo(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Gi.prototype.readInt16BE=function(e,t){t||yo(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Gi.prototype.readInt32LE=function(e,t){return t||yo(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Gi.prototype.readInt32BE=function(e,t){return t||yo(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Gi.prototype.readFloatLE=function(e,t){return t||yo(e,4,this.length),Di(this,e,!0,23,4)},Gi.prototype.readFloatBE=function(e,t){return t||yo(e,4,this.length),Di(this,e,!1,23,4)},Gi.prototype.readDoubleLE=function(e,t){return t||yo(e,8,this.length),Di(this,e,!0,52,8)},Gi.prototype.readDoubleBE=function(e,t){return t||yo(e,8,this.length),Di(this,e,!1,52,8)},Gi.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||bo(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},Gi.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||bo(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},Gi.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,1,255,0),Gi.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Gi.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,65535,0),Gi.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):wo(this,e,t,!0),t+2},Gi.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,65535,0),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):wo(this,e,t,!1),t+2},Gi.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,4294967295,0),Gi.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):_o(this,e,t,!0),t+4},Gi.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,4294967295,0),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_o(this,e,t,!1),t+4},Gi.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);bo(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o<r&&(a*=256);)e<0&&0===s&&0!==this[t+o-1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},Gi.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);bo(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},Gi.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,1,127,-128),Gi.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Gi.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,32767,-32768),Gi.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):wo(this,e,t,!0),t+2},Gi.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,2,32767,-32768),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):wo(this,e,t,!1),t+2},Gi.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,2147483647,-2147483648),Gi.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):_o(this,e,t,!0),t+4},Gi.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||bo(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Gi.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_o(this,e,t,!1),t+4},Gi.prototype.writeFloatLE=function(e,t,r){return Eo(this,e,t,!0,r)},Gi.prototype.writeFloatBE=function(e,t,r){return Eo(this,e,t,!1,r)},Gi.prototype.writeDoubleLE=function(e,t,r){return ko(this,e,t,!0,r)},Gi.prototype.writeDoubleBE=function(e,t,r){return ko(this,e,t,!1,r)},Gi.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!Gi.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},Gi.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Gi.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var a=Xi(e)?e:Ao(new Gi(e,n).toString()),s=a.length;for(o=0;o<r-t;++o)this[o+t]=a[o%s]}return this};var xo=/[^+\/0-9A-Za-z-_]/g;function Po(e){return e<16?"0"+e.toString(16):e.toString(16)}function Ao(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Io(e){return function(e){var t,r,n,i,o,a;Ui||Ni();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[s-2]?2:"="===e[s-1]?1:0,a=new Li(3*s/4-o),n=o>0?s-4:s;var l=0;for(t=0,r=0;t<n;t+=4,r+=3)i=Fi[e.charCodeAt(t)]<<18|Fi[e.charCodeAt(t+1)]<<12|Fi[e.charCodeAt(t+2)]<<6|Fi[e.charCodeAt(t+3)],a[l++]=i>>16&255,a[l++]=i>>8&255,a[l++]=255&i;return 2===o?(i=Fi[e.charCodeAt(t)]<<2|Fi[e.charCodeAt(t+1)]>>4,a[l++]=255&i):1===o&&(i=Fi[e.charCodeAt(t)]<<10|Fi[e.charCodeAt(t+1)]<<4|Fi[e.charCodeAt(t+2)]>>2,a[l++]=i>>8&255,a[l++]=255&i),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(xo,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Oo(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function To(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function jo(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Ci.inherits(jo,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ci.toJSONObject(this.config),code:this.code,status:this.status}}});const Co=jo.prototype,Ro={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Ro[e]={value:e}})),Object.defineProperties(jo,Ro),Object.defineProperty(Co,"isAxiosError",{value:!0}),jo.from=(e,t,r,n,i,o)=>{const a=Object.create(Co);return Ci.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),jo.call(a,e.message,t,r,n,i),a.cause=e,a.name=e.name,o&&Object.assign(a,o),a};function Fo(e){return Ci.isPlainObject(e)||Ci.isArray(e)}function Lo(e){return Ci.endsWith(e,"[]")?e.slice(0,-2):e}function Uo(e,t,r){return e?e.concat(t).map((function(e,t){return e=Lo(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const No=Ci.toFlatObject(Ci,{},null,(function(e){return/^is[A-Z]/.test(e)}));function qo(e,t,r){if(!Ci.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=Ci.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Ci.isUndefined(t[e])}))).metaTokens,i=r.visitor||c,o=r.dots,a=r.indexes,s=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Ci.isSpecCompliantForm(t);if(!Ci.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ci.isDate(e))return e.toISOString();if(Ci.isBoolean(e))return e.toString();if(!s&&Ci.isBlob(e))throw new jo("Blob is not supported. Use a Buffer instead.");return Ci.isArrayBuffer(e)||Ci.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Gi.from(e):e}function c(e,r,i){let s=e;if(e&&!i&&"object"==typeof e)if(Ci.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(Ci.isArray(e)&&function(e){return Ci.isArray(e)&&!e.some(Fo)}(e)||(Ci.isFileList(e)||Ci.endsWith(r,"[]"))&&(s=Ci.toArray(e)))return r=Lo(r),s.forEach((function(e,n){!Ci.isUndefined(e)&&null!==e&&t.append(!0===a?Uo([r],n,o):null===a?r:r+"[]",l(e))})),!1;return!!Fo(e)||(t.append(Uo(i,r,o),l(e)),!1)}const u=[],d=Object.assign(No,{defaultVisitor:c,convertValue:l,isVisitable:Fo});if(!Ci.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!Ci.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),Ci.forEach(r,(function(r,o){!0===(!(Ci.isUndefined(r)||null===r)&&i.call(t,r,Ci.isString(o)?o.trim():o,n,d))&&e(r,n?n.concat(o):[o])})),u.pop()}}(e),t}function zo(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Do(e,t){this._pairs=[],e&&qo(e,this,t)}const $o=Do.prototype;function Mo(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Bo(e,t,r){if(!t)return e;const n=r&&r.encode||Mo;Ci.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let o;if(o=i?i(t,r):Ci.isURLSearchParams(t)?t.toString():new Do(t,r).toString(n),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}$o.append=function(e,t){this._pairs.push([e,t])},$o.toString=function(e){const t=e?function(t){return e.call(this,t,zo)}:zo;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class Ho{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ci.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var Jo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Go={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Do,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Wo="undefined"!=typeof window&&"undefined"!=typeof document,Vo="object"==typeof navigator&&navigator||void 0,Yo=Wo&&(!Vo||["ReactNative","NativeScript","NS"].indexOf(Vo.product)<0),Ko="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Qo=Wo&&window.location.href||"http://localhost";var Xo={...Object.freeze({__proto__:null,hasBrowserEnv:Wo,hasStandardBrowserEnv:Yo,hasStandardBrowserWebWorkerEnv:Ko,navigator:Vo,origin:Qo}),...Go};function Zo(e){function t(e,r,n,i){let o=e[i++];if("__proto__"===o)return!0;const a=Number.isFinite(+o),s=i>=e.length;if(o=!o&&Ci.isArray(n)?n.length:o,s)return Ci.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!a;n[o]&&Ci.isObject(n[o])||(n[o]=[]);return t(e,r,n[o],i)&&Ci.isArray(n[o])&&(n[o]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}(n[o])),!a}if(Ci.isFormData(e)&&Ci.isFunction(e.entries)){const r={};return Ci.forEachEntry(e,((e,n)=>{t(function(e){return Ci.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const ea={transitional:Jo,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=Ci.isObject(e);i&&Ci.isHTMLForm(e)&&(e=new FormData(e));if(Ci.isFormData(e))return n?JSON.stringify(Zo(e)):e;if(Ci.isArrayBuffer(e)||Ci.isBuffer(e)||Ci.isStream(e)||Ci.isFile(e)||Ci.isBlob(e)||Ci.isReadableStream(e))return e;if(Ci.isArrayBufferView(e))return e.buffer;if(Ci.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return qo(e,new Xo.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return Xo.isNode&&Ci.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=Ci.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return qo(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(Ci.isString(e))try{return(t||JSON.parse)(e),Ci.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ea.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Ci.isResponse(e)||Ci.isReadableStream(e))return e;if(e&&Ci.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw jo.from(e,jo.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Xo.classes.FormData,Blob:Xo.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ci.forEach(["delete","get","head","post","put","patch"],(e=>{ea.headers[e]={}}));const ta=Ci.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const ra=Symbol("internals");function na(e){return e&&String(e).trim().toLowerCase()}function ia(e){return!1===e||null==e?e:Ci.isArray(e)?e.map(ia):String(e)}function oa(e,t,r,n,i){return Ci.isFunction(n)?n.call(this,t,r):(i&&(t=r),Ci.isString(t)?Ci.isString(n)?-1!==t.indexOf(n):Ci.isRegExp(n)?n.test(t):void 0:void 0)}let aa=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=na(t);if(!i)throw new Error("header name must be a non-empty string");const o=Ci.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||t]=ia(e))}const o=(e,t)=>Ci.forEach(e,((e,r)=>i(e,r,t)));if(Ci.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Ci.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&ta[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t);else if(Ci.isObject(e)&&Ci.isIterable(e)){let r,n,i={};for(const t of e){if(!Ci.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[n=t[0]]=(r=i[n])?Ci.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=na(e)){const r=Ci.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(Ci.isFunction(t))return t.call(this,e,r);if(Ci.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=na(e)){const r=Ci.findKey(this,e);return!(!r||void 0===this[r]||t&&!oa(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=na(e)){const i=Ci.findKey(r,e);!i||t&&!oa(0,r[i],i,t)||(delete r[i],n=!0)}}return Ci.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!oa(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return Ci.forEach(this,((n,i)=>{const o=Ci.findKey(r,i);if(o)return t[o]=ia(n),void delete t[i];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();a!==i&&delete t[i],t[a]=ia(n),r[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ci.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&Ci.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[ra]=this[ra]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=na(e);t[n]||(!function(e,t){const r=Ci.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return Ci.isArray(e)?e.forEach(n):n(e),this}};function sa(e,t){const r=this||ea,n=t||r,i=aa.from(n.headers);let o=n.data;return Ci.forEach(e,(function(e){o=e.call(r,o,i.normalize(),t?t.status:void 0)})),i.normalize(),o}function la(e){return!(!e||!e.__CANCEL__)}function ca(e,t,r){jo.call(this,null==e?"canceled":e,jo.ERR_CANCELED,t,r),this.name="CanceledError"}function ua(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new jo("Request failed with status code "+r.status,[jo.ERR_BAD_REQUEST,jo.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}aa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ci.reduceDescriptors(aa.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),Ci.freezeMethods(aa),Ci.inherits(ca,jo,{__CANCEL__:!0});const da=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,o=0,a=0;return t=void 0!==t?t:1e3,function(s){const l=Date.now(),c=n[a];i||(i=l),r[o]=s,n[o]=l;let u=a,d=0;for(;u!==o;)d+=r[u++],u%=e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),l-i<t)return;const h=c&&l-c;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(e,t){let r,n,i=0,o=1e3/t;const a=(t,o=Date.now())=>{i=o,r=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),s=t-i;s>=o?a(e,t):(r=e,n||(n=setTimeout((()=>{n=null,a(r)}),o-s)))},()=>r&&a(r)]}((r=>{const o=r.loaded,a=r.lengthComputable?r.total:void 0,s=o-n,l=i(s);n=o;e({loaded:o,total:a,progress:a?o/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&o<=a?(a-o)/l:void 0,event:r,lengthComputable:null!=a,[t?"download":"upload"]:!0})}),r)},ha=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},fa=e=>(...t)=>Ci.asap((()=>e(...t)));var pa=Xo.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,Xo.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(Xo.origin),Xo.navigator&&/(msie|trident)/i.test(Xo.navigator.userAgent)):()=>!0,ga=Xo.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const a=[e+"="+encodeURIComponent(t)];Ci.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),Ci.isString(n)&&a.push("path="+n),Ci.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function ma(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const va=e=>e instanceof aa?{...e}:e;function ya(e,t){t=t||{};const r={};function n(e,t,r,n){return Ci.isPlainObject(e)&&Ci.isPlainObject(t)?Ci.merge.call({caseless:n},e,t):Ci.isPlainObject(t)?Ci.merge({},t):Ci.isArray(t)?t.slice():t}function i(e,t,r,i){return Ci.isUndefined(t)?Ci.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function o(e,t){if(!Ci.isUndefined(t))return n(void 0,t)}function a(e,t){return Ci.isUndefined(t)?Ci.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(r,i,o){return o in t?n(r,i):o in e?n(void 0,r):void 0}const l={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(e,t,r)=>i(va(e),va(t),0,!0)};return Ci.forEach(Object.keys(Object.assign({},e,t)),(function(n){const o=l[n]||i,a=o(e[n],t[n],n);Ci.isUndefined(a)&&o!==s||(r[n]=a)})),r}var ba=e=>{const t=ya({},e);let r,{data:n,withXSRFToken:i,xsrfHeaderName:o,xsrfCookieName:a,headers:s,auth:l}=t;if(t.headers=s=aa.from(s),t.url=Bo(ma(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),Ci.isFormData(n))if(Xo.hasStandardBrowserEnv||Xo.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(!1!==(r=s.getContentType())){const[e,...t]=r?r.split(";").map((e=>e.trim())).filter(Boolean):[];s.setContentType([e||"multipart/form-data",...t].join("; "))}if(Xo.hasStandardBrowserEnv&&(i&&Ci.isFunction(i)&&(i=i(t)),i||!1!==i&&pa(t.url))){const e=o&&a&&ga.read(a);e&&s.set(o,e)}return t};var wa="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){const n=ba(e);let i=n.data;const o=aa.from(n.headers).normalize();let a,s,l,c,u,{responseType:d,onUploadProgress:h,onDownloadProgress:f}=n;function p(){c&&c(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(a),n.signal&&n.signal.removeEventListener("abort",a)}let g=new XMLHttpRequest;function m(){if(!g)return;const n=aa.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());ua((function(e){t(e),p()}),(function(e){r(e),p()}),{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:n,config:e,request:g}),g=null}g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(r(new jo("Request aborted",jo.ECONNABORTED,e,g)),g=null)},g.onerror=function(){r(new jo("Network Error",jo.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||Jo;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new jo(t,i.clarifyTimeoutError?jo.ETIMEDOUT:jo.ECONNABORTED,e,g)),g=null},void 0===i&&o.setContentType(null),"setRequestHeader"in g&&Ci.forEach(o.toJSON(),(function(e,t){g.setRequestHeader(t,e)})),Ci.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),d&&"json"!==d&&(g.responseType=n.responseType),f&&([l,u]=da(f,!0),g.addEventListener("progress",l)),h&&g.upload&&([s,c]=da(h),g.upload.addEventListener("progress",s),g.upload.addEventListener("loadend",c)),(n.cancelToken||n.signal)&&(a=t=>{g&&(r(!t||t.type?new ca(null,e,g):t),g.abort(),g=null)},n.cancelToken&&n.cancelToken.subscribe(a),n.signal&&(n.signal.aborted?a():n.signal.addEventListener("abort",a)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);v&&-1===Xo.protocols.indexOf(v)?r(new jo("Unsupported protocol "+v+":",jo.ERR_BAD_REQUEST,e)):g.send(i||null)}))};const _a=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const i=function(e){if(!r){r=!0,a();const t=e instanceof Error?e:this.reason;n.abort(t instanceof jo?t:new ca(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{o=null,i(new jo(`timeout ${t} of ms exceeded`,jo.ETIMEDOUT))}),t);const a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)})),e=null)};e.forEach((e=>e.addEventListener("abort",i)));const{signal:s}=n;return s.unsubscribe=()=>Ci.asap(a),s}},Sa=function*(e,t){let r=e.byteLength;if(r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},Ea=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},ka=(e,t,r,n)=>{const i=async function*(e,t){for await(const r of Ea(e))yield*Sa(r,t)}(e,t);let o,a=0,s=e=>{o||(o=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return s(),void e.close();let o=n.byteLength;if(r){let e=a+=o;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})},xa="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Pa=xa&&"function"==typeof ReadableStream,Aa=xa&&("function"==typeof TextEncoder?(Ia=new TextEncoder,e=>Ia.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ia;const Oa=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ta=Pa&&Oa((()=>{let e=!1;const t=new Request(Xo.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),ja=Pa&&Oa((()=>Ci.isReadableStream(new Response("").body))),Ca={stream:ja&&(e=>e.body)};var Ra;xa&&(Ra=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Ca[e]&&(Ca[e]=Ci.isFunction(Ra[e])?t=>t[e]():(t,r)=>{throw new jo(`Response type '${e}' is not supported`,jo.ERR_NOT_SUPPORT,r)})})));const Fa=async(e,t)=>{const r=Ci.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Ci.isBlob(e))return e.size;if(Ci.isSpecCompliantForm(e)){const t=new Request(Xo.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ci.isArrayBufferView(e)||Ci.isArrayBuffer(e)?e.byteLength:(Ci.isURLSearchParams(e)&&(e+=""),Ci.isString(e)?(await Aa(e)).byteLength:void 0)})(t):r};var La=xa&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:a,onDownloadProgress:s,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:h}=ba(e);c=c?(c+"").toLowerCase():"text";let f,p=_a([i,o&&o.toAbortSignal()],a);const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let m;try{if(l&&Ta&&"get"!==r&&"head"!==r&&0!==(m=await Fa(u,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(Ci.isFormData(n)&&(e=r.headers.get("content-type"))&&u.setContentType(e),r.body){const[e,t]=ha(m,da(fa(l)));n=ka(r.body,65536,e,t)}}Ci.isString(d)||(d=d?"include":"omit");const i="credentials"in Request.prototype;f=new Request(t,{...h,signal:p,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:i?d:void 0});let o=await fetch(f,h);const a=ja&&("stream"===c||"response"===c);if(ja&&(s||a&&g)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=o[t]}));const t=Ci.toFiniteNumber(o.headers.get("content-length")),[r,n]=s&&ha(t,da(fa(s),!0))||[];o=new Response(ka(o.body,65536,r,(()=>{n&&n(),g&&g()})),e)}c=c||"text";let v=await Ca[Ci.findKey(Ca,c)||"text"](o,e);return!a&&g&&g(),await new Promise(((t,r)=>{ua(t,r,{data:v,headers:aa.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:f})}))}catch(t){if(g&&g(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new jo("Network Error",jo.ERR_NETWORK,e,f),{cause:t.cause||t});throw jo.from(t,t&&t.code,e,f)}});const Ua={http:null,xhr:wa,fetch:La};Ci.forEach(Ua,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Na=e=>`- ${e}`,qa=e=>Ci.isFunction(e)||null===e||!1===e;var za=e=>{e=Ci.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){let t;if(r=e[o],n=r,!qa(r)&&(n=Ua[(t=String(r)).toLowerCase()],void 0===n))throw new jo(`Unknown adapter '${t}'`);if(n)break;i[t||"#"+o]=n}if(!n){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new jo("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Na).join("\n"):" "+Na(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Da(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ca(null,e)}function $a(e){Da(e),e.headers=aa.from(e.headers),e.data=sa.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return za(e.adapter||ea.adapter)(e).then((function(t){return Da(e),t.data=sa.call(e,e.transformResponse,t),t.headers=aa.from(t.headers),t}),(function(t){return la(t)||(Da(e),t&&t.response&&(t.response.data=sa.call(e,e.transformResponse,t.response),t.response.headers=aa.from(t.response.headers))),Promise.reject(t)}))}const Ma="1.10.0",Ba={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Ba[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Ha={};Ba.transitional=function(e,t,r){function n(e,t){return"[Axios v"+Ma+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,o)=>{if(!1===e)throw new jo(n(i," has been removed"+(t?" in "+t:"")),jo.ERR_DEPRECATED);return t&&!Ha[i]&&(Ha[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,o)}},Ba.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var Ja={assertOptions:function(e,t,r){if("object"!=typeof e)throw new jo("options must be an object",jo.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],a=t[o];if(a){const t=e[o],r=void 0===t||a(t,o,e);if(!0!==r)throw new jo("option "+o+" must be "+r,jo.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new jo("Unknown option "+o,jo.ERR_BAD_OPTION)}},validators:Ba};const Ga=Ja.validators;let Wa=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ho,response:new Ho}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ya(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&Ja.assertOptions(r,{silentJSONParsing:Ga.transitional(Ga.boolean),forcedJSONParsing:Ga.transitional(Ga.boolean),clarifyTimeoutError:Ga.transitional(Ga.boolean)},!1),null!=n&&(Ci.isFunction(n)?t.paramsSerializer={serialize:n}:Ja.assertOptions(n,{encode:Ga.function,serialize:Ga.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Ja.assertOptions(t,{baseUrl:Ga.spelling("baseURL"),withXsrfToken:Ga.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&Ci.merge(i.common,i[t.method]);i&&Ci.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=aa.concat(o,i);const a=[];let s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));const l=[];let c;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let u,d=0;if(!s){const e=[$a.bind(this),void 0];for(e.unshift.apply(e,a),e.push.apply(e,l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=a.length;let h=t;for(d=0;d<u;){const e=a[d++],t=a[d++];try{h=e(h)}catch(e){t.call(this,e);break}}try{c=$a.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return Bo(ma((e=ya(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Ci.forEach(["delete","get","head","options"],(function(e){Wa.prototype[e]=function(t,r){return this.request(ya(r||{},{method:e,url:t,data:(r||{}).data}))}})),Ci.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(ya(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Wa.prototype[e]=t(),Wa.prototype[e+"Form"]=t(!0)}));const Va={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Va).forEach((([e,t])=>{Va[t]=e}));const Ya=function e(t){const r=new Wa(t),n=Bn(Wa.prototype.request,r);return Ci.extend(n,Wa.prototype,r,{allOwnKeys:!0}),Ci.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(ya(t,r))},n}(ea);Ya.Axios=Wa,Ya.CanceledError=ca,Ya.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new ca(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;const r=new e((function(e){t=e}));return{token:r,cancel:t}}},Ya.isCancel=la,Ya.VERSION=Ma,Ya.toFormData=qo,Ya.AxiosError=jo,Ya.Cancel=Ya.CanceledError,Ya.all=function(e){return Promise.all(e)},Ya.spread=function(e){return function(t){return e.apply(null,t)}},Ya.isAxiosError=function(e){return Ci.isObject(e)&&!0===e.isAxiosError},Ya.mergeConfig=ya,Ya.AxiosHeaders=aa,Ya.formToJSON=e=>Zo(Ci.isHTMLForm(e)?new FormData(e):e),Ya.getAdapter=za,Ya.HttpStatusCode=Va,Ya.default=Ya;const{Axios:Ka,AxiosError:Qa,CanceledError:Xa,isCancel:Za,CancelToken:es,VERSION:ts,all:rs,Cancel:ns,isAxiosError:is,spread:os,toFormData:as,AxiosHeaders:ss,HttpStatusCode:ls,formToJSON:cs,getAdapter:us,mergeConfig:ds}=Ya;class hs extends Error{}function fs(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return atob(t)}}hs.prototype.name="InvalidTokenError";class ps{constructor(){this.inIframe=salla.helpers.isIframe(),salla.event.on("twilight::before.ready",(async e=>await this.initiateRequest(e))),salla.event.on("profile::info.fetched",(e=>this.setCurrencyAndLanguage(e))),salla.event.on("auth::token.fetched",(e=>{salla.storage.set("token",e),this.inIframe&&salla.log("token fetched iframe"),this.inIframe&&salla.cookie.set("s-token",e,60),this.setToken(e)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=Ya.create({baseURL:Salla.config.get("store.api",Salla.config.get("store.url")),headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":Salla?.versions?.base?.toString()?.match(/^\d+\.\d+\.\d+/)[0]??"2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}}),this.axios.interceptors.request.use((e=>{"preview"===Salla.config.get("theme.mode")&&(e.url=Salla.url.addParamToUrl("use_username_url",1,e.url));try{const t=Salla.config.get("swoole",[]),r=new RegExp(t.join("|"),"i");t.length>0&&r.test(e.url)&&(e.headers["s-store-api-version"]="swoole")}catch(e){console.log(e)}return e}),(e=>Promise.reject(e)))}getHeaders(){let e={...this.axios.defaults.headers.common};return delete e["Content-Type"],e}getHeader(e){return Object.entries(this.getHeaders()).filter((([t])=>t.toLowerCase()===e.toLowerCase()))[0]?.[1]}setHeaders(e){return Object.entries(e).forEach((e=>this.setHeader(e[0],e[1]))),this}setHeader(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this}async withoutNotifier(e){return this.notifier_handler_disabled=!0,await e().finally((()=>{this.notifier_handler_disabled=!1}))}async initiateRequest(e){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:e.user?.currency_code||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":e.user?.id,"s-country":e.user?.country_code,...e.headers||{}});const t=Salla.config.get("store.scope",Salla.storage.get("scope")),r=new URLSearchParams(window.location.search).get("scope");r&&t&&!Salla.url.is_page("cart")&&(t.id=r,Salla.storage.set("scope",t),Salla.cart.reset()),t&&this.setHeaders({"s-scope-type":t.type,"s-scope-id":t.id});const n=Salla.storage.getWithTTL("s-utms");n&&this.setHeaders(n),await this.injectTokenToTheRequests(e),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))}async injectTokenToTheRequests(e){let t=salla.storage.get("token"),r="guest"===e.user?.type,n=parseInt(e.user?.id||0),i=parseInt(salla.storage.get("user.id")||0),o=salla.auth.api.isSessionless(),a=e=>{this.setToken(e),salla.event.emit("api::initiated")},s=async()=>{r||o||!n?salla.auth.event.tokenInvalid():(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async()=>{await salla.profile.info()})).catch((()=>salla.auth.event.tokenInvalid())))};if(!t)return salla.log("Api:: case 1 => current is is guest"),void await s();let l,c=function(e,t){if("string"!=typeof e)throw new hs("Invalid token specified: must be a string");t||(t={});const r=!0===t.header?0:1,n=e.split(".")[r];if("string"!=typeof n)throw new hs(`Invalid token specified: missing part #${r+1}`);let i;try{i=fs(n)}catch(e){throw new hs(`Invalid token specified: invalid base64 for part #${r+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new hs(`Invalid token specified: invalid json for part #${r+1} (${e.message})`)}}(t);return Date.now()/1e3>c.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await s()):(l=o?parseInt(c.sub)!==i:!i||!n||i!==n||parseInt(c.sub)!==n,l?(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log(`sub:${c.sub} userIdInWeb:${n} userIdInStorage:${i}, isSessionless:${o}`,c.sub,n,i),this.setHeader("Authorization","Bearer "+t),void await salla.profile.info().then((async e=>{!this.inIframe&&!o&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.request.injectTokenToTheRequests"}),a(t)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()}))):(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void a(t)))}setToken(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this}setCurrencyAndLanguage(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})}request(e,t=void 0,r="get",n={}){let i={endPoint:e,payload:t,method:r,options:n},o="undefined"!=typeof event?event.currentTarget:null,a=!1;return"SALLA-BUTTON"===o?.tagName&&(a=!0),a&&o?.load(),this.axios[i.method](i.endPoint,i.payload,i.options).then((e=>(a&&o?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw a&&o?.stop(),salla.event.document.requestFailed(i,e),this.handleErrorResponse(e),e}))}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:r=null}=e,n=t&&t.googleTags?t.googleTags:r;try{dataLayer&&n&&dataLayer.push(n)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)}fireEventsForResponse(e){let t=e?.events||e.data?.events||e.error?.events;"string"==typeof t&&(t=JSON.parse(t)),t&&Object.keys(t).forEach((e=>salla.event.dispatch(e,t[e])))}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&e.data?.message?salla.notify.fire(e.data?.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0}handleInvalidFields(e){let t=e.response.data.error.fields,r=[];Object.keys(t).forEach((e=>{let n=t[e];Array.isArray(n)?n.forEach((e=>r.push(e))):r.push(n)}));let n=(r.length>1?"* ":"")+r.join("\n* ");salla.error(n,e)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((r,n)=>t?r(e):n(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}}class gs extends An{constructor(){super(),this.namespace="component",this.endpoints={getMenus:"menus/{headOrFoot}?store_id={store}&lang={lang}",reviews:"reviews"},this.endpointsMethods={getMenus:"get",reviews:"get"}}async getMenus(e="header"){return this.request(["getMenus",e,salla.config.get("store.id"),salla.lang.getLocale()]).then((function(e){return salla.event.component.menuFetched(e),e})).catch((function(e){throw salla.event.component.menuFetchFailed(e),e}))}async getReviews({per_page:e=5,type:t="all",items:r}){if(!t){const e="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}const n=!r||"string"==typeof r&&"[]"===r||Array.isArray(r)&&!r.length;if(!new Set(["all","store","categories","products","json"]).has(t)){const e="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if("all"!==t&&"store"!==t&&n){const e="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if(new Set(["products","categories"]).has(t)&&!Array.isArray(r)){const e=`Items value must be an array of ${t} id for review type of ${t}.`;return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}return this.request(["reviews"],{params:{per_page:e,type:t,items:r}},"get").then((function(e){return salla.event.component.reviewsFetched(e),e})).catch((function(e){throw salla.event.component.reviewsFetchFailed(e),e}))}}class ms extends An{constructor(){super(),this.namespace="booking",this.endpoints={fetch:"advertisements"},this.endpointsMethods={fetch:"get"}}async fetch(e=null){const t=e?{page:e}:{};return this.request(["fetch"],{params:t}).then((function(e){return salla.event.advertisement.fetched(e),e})).catch((function(e){throw salla.event.advertisement.fetchFailed(e),e}))}}class vs extends An{constructor(){super(),this.namespace="navigation",this.endpoints={breadcrumbs:"breadcrumbs"},this.endpointsMethods={breadcrumbs:"get"},this.after_init()}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.navigation.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e}))}}class ys extends An{constructor(){super(),this.namespace="metadata",this.endpoints={fetchValues:"https://api.salla.dev/store/v1/metadata/values"},this.endpointsMethods={fetchValues:"get"}}async fetchValues(e,t){if(!e||!t){const e="Please provide entity type and entity ids.";return salla.metadata.event.valueNotFetch(e),salla.api.errorPromise(e)}const r={type:e,entities:Array.isArray(t)?t:[t]};return this.request(this.endpoints.fetchValues,{params:r},"get").then((e=>(salla.metadata.event.valueFetched(e),e))).catch((e=>{throw salla.metadata.event.valueNotFetch(e),e}))}}class bs{constructor(e){"ready"!==Dr.status?e?(Dr.config.merge(e),["salla.sa","salla.group"].includes(location.hostname)&&!Dr.config.get("store.url")?.includes(location.hostname)&&Dr.config.get("store.username")&&Dr.config.set("store.url",window.location.origin+"/"+Dr.config.get("store.username")),e?.events&&Dr.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),window.self===window.top&&(this.injectMaintenanceAlert(),this.injectThemePreviewAlert()),this.injectTemplateStoreAlert(),this.injectAppInstallAlert(),this.applyContentCopyright(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e),this.afterInit()):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}afterInit(){Dr.url.is_page("product.single")&&Dr.config.isGuest()&&window.addEventListener("mini-checkout::before-init",(e=>{e.preventDefault(),Dr.event.emit("login::open")}))}applyContentCopyright(){if(!Dr.config.get("store.settings.content_copyright"))return;["contextmenu","selectstart","copy"].forEach((e=>{document.addEventListener(e,(e=>e.preventDefault()))})),document.addEventListener("keydown",(e=>{const t=e.key.toLowerCase();("f12"===t||e.ctrlKey&&e.shiftKey&&["i","j","c"].includes(t)||e.ctrlKey&&"u"===t)&&(e.preventDefault(),e.stopPropagation())}));const e=document.createElement("style");e.textContent="\n body {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n img {\n pointer-events: none;\n -webkit-user-drag: none;\n }\n ",document.head.appendChild(e)}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.prepend(document.createElement("salla-maintenance-alert")))))}injectTemplateStoreAlert(){salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?salla.logger.warn("salla-bottom-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-bottom-alert")))))}injectAppInstallAlert(){salla.config.get("store.app_install_prompt")&&salla.config.get("store.apps")&&!salla.storage.get("app_install_prompt_disabled")&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?salla.logger.warn("salla-app-install-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-app-install-alert")))))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML=`\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(e)})))}injectEditAlert(){let e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let t=document.createElement("div");t.id="s-edit-alert",t.innerHTML=`\n <a href="${e}" style="display:block; background-color:${salla.config.get("theme.color.primary","#5cd5c4")}; color:${salla.config.get("theme.color.reverse","#fff")}; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n ${salla.lang.get("pages.products.quick_edit")}\n </a>\n `,document.body.prepend(t)})))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();let r=t.getAjaxFormData(e),n=r.method?r.method.toLowerCase():void 0;salla.api.request(r.url,r.formData,n).then((e=>(e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),this.callAjaxEvent(r.events.success,e,r.formData),e))).catch((e=>{throw salla.api.handleErrorResponse(e),this.callAjaxEvent(r.events.fail,e,r.formData),e}))}callAjaxEvent(e,t,r){if(e){if(r instanceof FormData){const e={};Array.from(r.entries()).forEach((function(t){e[t[0]]=t[1]})),r=e}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}}setSallaReady(e){this.storeUTMs(),Dr.event.emitAsync("twilight::before.ready",e),Dr.status="ready",Dr.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))}storeUTMs(){const e={fbclid:"facebook",gad_source:"google",ttclid:"tiktok",twclid:"twitter",scid:"snapchat"},t=["fbclid","gad_source","ttclid","twclid","scid"],r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content",...t],n={},i={};window.location.search.replace("?","").split("&").map((e=>e.split("="))).filter((([e])=>r.includes(e.toLowerCase()))).forEach((([e,t])=>n[e.toLowerCase()]=t));const o=t.find((e=>n[e]));!n.utm_source&&o&&(n.utm_source=e[o],n.utm_campaign=n.utm_campaign||`Using the CLICKID ${o} provided by ${n.utm_source}`,n.utm_term=n.utm_term||`${o}: ${n[o]}`),n.utm_source&&(Object.entries(n).filter((([e])=>!t.includes(e))).forEach((([e,t])=>i[`s-${e.replace("_","-")}`]=t)),i["s-utm-referrer"]=document.referrer,salla.storage.setWithTTL("s-utms",i,129600),this.logUTMVisitData(i))}async logUTMVisitData(e){const t=e["s-utm-source"],r=e["s-utm-medium"],n=e["s-utm-campaign"];e&&"affiliate"===t&&r&&n&&fetch(salla.config.get("affiliate.utm_url"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","s-utm-source":t,"s-utm-medium":r,"s-utm-campaign":n}}).then((e=>{if(e.ok){const e=new URL(window.location.href),t=window.history.state;e.searchParams.delete("utm_source"),e.searchParams.delete("utm_medium"),e.searchParams.delete("utm_campaign"),window.history.replaceState(t,"",e)}}))}}function ws(e,t,r,n,i){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:i;return e===i?r:e}var _s="undefined",Ss="object",Es="any",ks="*",xs=void 0!==Ht?Ht:{};xs.env&&xs.env.NODE_ENV;var Ps="undefined"!=typeof document;function As(e,t){return t.charAt(0)[e]()+t.slice(1)}null!=xs.versions&&xs.versions.node,"undefined"!=typeof Deno&&Deno.core,Ps&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));var Is=As.bind(null,"toUpperCase"),Os=As.bind(null,"toLowerCase");function Ts(e){return Ns(e)?Is("null"):"object"==typeof e?function(e){return Rs(e.constructor)?e.constructor.name:null}(e):Object.prototype.toString.call(e).slice(8,-1)}function js(e,t){void 0===t&&(t=!0);var r=Ts(e);return t?Os(r):r}function Cs(e,t){return typeof t===e}var Rs=Cs.bind(null,"function"),Fs=Cs.bind(null,"string"),Ls=Cs.bind(null,"undefined"),Us=Cs.bind(null,"boolean");function Ns(e){return null===e}function qs(e){if(!function(e){return e&&("object"==typeof e||null!==e)}(e))return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function zs(e){return e instanceof Error||Fs(e.message)&&e.constructor&&function(e){return"number"===js(e)&&!isNaN(e)}(e.constructor.stackTraceLimit)}function Ds(e,t){if("object"!=typeof t||Ns(t))return!1;if(t instanceof e)return!0;var r=js(new e(""));if(zs(t))for(;t;){if(js(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}function $s(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?function(e,t){return void 0===t&&(t=""),e&&e.nodeName===t.toUpperCase()}(e,t):r}function Ms(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}function Bs(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Hs(e){return function(e){for(var t,r=Object.create(null),n=/([^&=]+)=?([^&]*)/g;t=n.exec(e);){var i=Bs(t[1]),o=Bs(t[2]);"[]"===i.substring(i.length-2)?(r[i=i.substring(0,i.length-2)]||(r[i]=[])).push(o):r[i]=""===o||o}for(var a in r){var s=a.split("[");s.length>1&&(Js(r,s.map((function(e){return e.replace(/[?[\]\\ ]/g,"")})),r[a]),delete r[a])}return r}(Ps&&window.location.search.substring(1))}function Js(e,t,r){for(var n=t.length-1,i=0;i<n;++i){var o=t[i];if("__proto__"===o||"constructor"===o)break;o in e||(e[o]={}),e=e[o]}e[t[n]]=r}function Gs(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],i=15&r;e+="-"==n||"4"==n?n:("x"==n?i:3&i|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}Cs.bind(null,"symbol"),Ds.bind(null,TypeError),Ds.bind(null,SyntaxError),Ms($s,"form"),Ms($s,"button"),Ms($s,"input"),Ms($s,"select");var Ws="global",Vs="__global__",Ys=typeof self===Ss&&self.self===self&&self||typeof Qe===Ss&&Qe.global===Qe&&Qe||void 0;function Ks(e){return Ys[Vs][e]}function Qs(e,t){return Ys[Vs][e]=t}function Xs(e){delete Ys[Vs][e]}function Zs(e,t,r){var n;try{if(tl(e)){var i=window[e];n=i[t].bind(i)}}catch(e){}return n||r}Ys[Vs]||(Ys[Vs]={});var el={};function tl(e){if(typeof el[e]!==_s)return el[e];try{var t=window[e];t.setItem(_s,_s),t.removeItem(_s)}catch(t){return el[e]=!1}return el[e]=!0}function rl(){return rl=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},rl.apply(this,arguments)}var nl="function",il="undefined",ol="@@redux/"+Math.random().toString(36),al=function(){return typeof Symbol===nl&&Symbol.observable||"@@observable"}(),sl=" != "+nl;function ll(e,t,r){var n;if(typeof t===nl&&typeof r===il&&(r=t,t=void 0),typeof r!==il){if(typeof r!==nl)throw new Error("enhancer"+sl);return r(ll)(e,t)}if(typeof e!==nl)throw new Error("reducer"+sl);var i=e,o=t,a=[],s=a,l=!1;function c(){s===a&&(s=a.slice())}function u(){return o}function d(e){if(typeof e!==nl)throw new Error("Listener"+sl);var t=!0;return c(),s.push(e),function(){if(t){t=!1,c();var r=s.indexOf(e);s.splice(r,1)}}}function h(e){if(!qs(e))throw new Error("Act != obj");if(typeof e.type===il)throw new Error("ActType "+il);if(l)throw new Error("Dispatch in reducer");try{l=!0,o=i(o,e)}finally{l=!1}for(var t=a=s,r=0;r<t.length;r++)(0,t[r])();return e}return h({type:"@@redux/INIT"}),(n={dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if(typeof e!==nl)throw new Error("next reducer"+sl);i=e,h({type:"@@redux/INIT"})}})[al]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function r(){e.next&&e.next(u())}return r(),{unsubscribe:t(r)}}})[al]=function(){return this},e},n}function cl(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+il}function ul(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce((function(e,t){return function(){return e(t.apply(void 0,[].slice.call(arguments)))}}))}function dl(){var e=arguments;return function(t){return function(r,n,i){var o,a=t(r,n,i),s=a.dispatch,l={getState:a.getState,dispatch:function(e){return s(e)}};return o=[].slice.call(e).map((function(e){return e(l)})),rl({},a,{dispatch:s=ul.apply(void 0,o)(a.dispatch)})}}}var hl="__anon_id",fl="__user_id",pl="__user_traits",gl="userId",ml="anonymousId",vl=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],yl=["name","EVENTS","config","loaded"],bl=vl.reduce((function(e,t){return e[t]=t,e}),{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),wl=/^utm_/,_l=/^an_prop_/,Sl=/^an_trait_/;function El(e){var t=e.storage.setItem;return function(r){return function(n){return function(i){if(i.type===bl.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,l=i.initialUser,c=s.userId===a.userId;s.anonymousId!==a.anonymousId&&t(hl,a.anonymousId),c||t(fl,a.userId),l.traits&&t(pl,rl({},c&&s.traits?s.traits:{},l.traits));var u=Object.keys(i.params);if(u.length){var d=o.an_uid,h=o.an_event,f=u.reduce((function(e,t){if(t.match(wl)||t.match(/^(d|g)clid/)){var r=t.replace(wl,"");e.campaign["campaign"===r?"name":r]=o[t]}return t.match(_l)&&(e.props[t.replace(_l,"")]=o[t]),t.match(Sl)&&(e.traits[t.replace(Sl,"")]=o[t]),e}),{campaign:{},props:{},traits:{}});r.dispatch(rl({type:bl.params,raw:o},f,d?{userId:d}:{})),d&&setTimeout((function(){return e.identify(d,f.traits)}),0),h&&setTimeout((function(){return e.track(h,f.props)}),0),Object.keys(f.campaign).length&&r.dispatch({type:bl.campaign,campaign:f.campaign})}}return n(i)}}}}function kl(e){return function(t,r){if(void 0===t&&(t={}),void 0===r&&(r={}),r.type===bl.setItemEnd){if(r.key===hl)return rl({},t,{anonymousId:r.value});if(r.key===fl)return rl({},t,{userId:r.value})}switch(r.type){case bl.identify:return Object.assign({},t,{userId:r.userId,traits:rl({},t.traits,r.traits)});case bl.reset:return[fl,hl,pl].forEach((function(t){e.removeItem(t)})),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function xl(e){return{userId:e.getItem(fl),anonymousId:e.getItem(hl),traits:e.getItem(pl)}}var Pl=function(e){return"__TEMP__"+e};function Al(e){var t=e.storage,r=t.setItem,n=t.removeItem,i=t.getItem;return function(e){return function(t){return function(o){var a=o.userId,s=o.traits,l=o.options;if(o.type===bl.reset&&([fl,pl,hl].forEach((function(e){n(e)})),[gl,ml,"traits"].forEach((function(e){Xs(Pl(e))}))),o.type===bl.identify){i(hl)||r(hl,Gs());var c=i(fl),u=i(pl)||{};c&&c!==a&&e.dispatch({type:bl.userIdChanged,old:{userId:c,traits:u},new:{userId:a,traits:s},options:l}),a&&r(fl,a),s&&r(pl,rl({},u,s))}return t(o)}}}}var Il={};function Ol(e,t){Il[e]&&Rs(Il[e])&&(Il[e](t),delete Il[e])}function Tl(e,t,r){return new Promise((function(n,i){return t()?n(e):r<1?i(rl({},e,{queue:!0})):new Promise((function(e){return setTimeout(e,10)})).then((function(o){return Tl(e,t,r-10).then(n,i)}))}))}function jl(e){return{abort:e}}var Cl=function(e){var t=e.data,r=e.action,n=e.instance,i=e.state,o=e.allPlugins,a=e.allMatches,s=e.store,l=e.EVENTS;try{var c=i.plugins,u=i.context,d=r.type,h=d.match(Rl),f=t.exact.map((function(e){return e.pluginName}));h&&(f=a.during.map((function(e){return e.pluginName})));var p=function(e,t){return function(r,n,i){var o=n.config,a=n.name,s=a+"."+r.type;i&&(s=i.event);var l=r.type.match(Rl)?function(e,t,r,n,i){return function(o,a){var s=n?n.name:e,l=a&&Ml(a)?a:r;if(n&&(!(l=a&&Ml(a)?a:[e]).includes(e)||1!==l.length))throw new Error("Method "+t+" can only abort "+e+" plugin. "+JSON.stringify(l)+" input valid");return rl({},i,{abort:{reason:o,plugins:l,caller:t,_:s}})}}(a,s,t,i,r):function(e,t){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+t)}}(r,s);return{payload:Jl(r),instance:e,config:o||{},abort:l}}}(n,f),g=t.exact.reduce((function(e,t){var r=t.pluginName,n=t.methodName,i=!1;return n.match(/^initialize/)||n.match(/^reset/)||(i=!c[r].loaded),u.offline&&n.match(/^(page|track|identify)/)&&(i=!0),e[""+r]=i,e}),{});return Promise.resolve(t.exact.reduce((function(e,i,a){try{var s=i.pluginName;return Promise.resolve(e).then((function(e){function i(){return Promise.resolve(e)}var a=function(){if(t.namespaced&&t.namespaced[s])return Promise.resolve(t.namespaced[s].reduce((function(e,t,r){try{return Promise.resolve(e).then((function(e){return t.method&&Rs(t.method)?(function(e,t){var r=Hl(e);if(r&&r.name===t){var n=Hl(r.method);throw new Error([t+" plugin is calling method "+e,"Plugins cant call self","Use "+r.method+" "+(n?"or "+n.method:"")+" in "+t+" plugin insteadof "+e].join("\n"))}}(t.methodName,t.pluginName),Promise.resolve(t.method({payload:e,instance:n,abort:(r=e,i=s,a=t.pluginName,function(e,t){return rl({},r,{abort:{reason:e,plugins:t||[i],caller:d,from:a||i}})}),config:Nl(t.pluginName,c,o),plugins:c})).then((function(t){var r=qs(t)?t:{};return Promise.resolve(rl({},e,r))}))):e;var r,i,a}))}catch(e){return Promise.reject(e)}}),Promise.resolve(r))).then((function(t){e[s]=t}));e[s]=r}();return a&&a.then?a.then(i):i()}))}catch(e){return Promise.reject(e)}}),Promise.resolve({}))).then((function(e){return Promise.resolve(t.exact.reduce((function(r,i,a){try{var l=t.exact.length===a+1,u=i.pluginName,f=o[u];return Promise.resolve(r).then((function(t){var r=e[u]?e[u]:{};if(h&&(r=t),Dl(r,u))return Ul({data:r,method:d,instance:n,pluginName:u,store:s}),Promise.resolve(t);if(Dl(t,u))return l&&Ul({data:t,method:d,instance:n,store:s}),Promise.resolve(t);if(g.hasOwnProperty(u)&&!0===g[u])return s.dispatch({type:"queue",plugin:u,payload:r,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(t);var i=p(e[u],o[u]);return Promise.resolve(f[d]({abort:i.abort,payload:r,instance:n,config:Nl(u,c,o),plugins:c})).then((function(i){var o=qs(i)?i:{},a=rl({},t,o),l=e[u];if(Dl(l,u))Ul({data:l,method:d,instance:n,pluginName:u,store:s});else{var c=d+":"+u;(c.match(/:/g)||[]).length<2&&!d.match(Fl)&&!d.match(Ll)&&n.dispatch(rl({},h?a:r,{type:c,_:{called:c,from:"submethod"}}))}return Promise.resolve(a)}))}))}catch(e){return Promise.reject(e)}}),Promise.resolve(r))).then((function(e){if(!(d.match(Rl)||d.match(/^registerPlugin/)||d.match(Ll)||d.match(Fl)||d.match(/^params/)||d.match(/^userIdChanged/))){if(l.plugins.includes(d),e._&&e._.originalAction===d)return e;var r=rl({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});$l(e,t.exact.length)&&!d.match(/End$/)&&(r=rl({},r,{type:e.type+"Aborted"})),s.dispatch(r)}return e}))}))}catch(e){return Promise.reject(e)}},Rl=/Start$/,Fl=/^bootstrap/,Ll=/^ready/;function Ul(e){var t=e.pluginName,r=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(rl({},e.data,{type:r,_:{called:r,from:"abort"}}))}function Nl(e,t,r){var n=t[e]||r[e];return n&&n.config?n.config:{}}function ql(e,t){return t.reduce((function(t,r){return r[e]?t.concat({methodName:e,pluginName:r.name,method:r[e]}):t}),[])}function zl(e,t){var r=e.replace(Rl,""),n=t?":"+t:"";return[""+e+n,""+r+n,r+"End"+n]}function Dl(e,t){var r=e.abort;return!!r&&(!0===r||Bl(r,t)||r&&Bl(r.plugins,t))}function $l(e,t){var r=e.abort;if(!r)return!1;if(!0===r||Fs(r))return!0;var n=r.plugins;return Ml(r)&&r.length===t||Ml(n)&&n.length===t}function Ml(e){return Array.isArray(e)}function Bl(e,t){return!(!e||!Ml(e))&&e.includes(t)}function Hl(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function Jl(e){return Object.keys(e).reduce((function(t,r){return"type"===r||(t[r]=qs(e[r])?Object.assign({},e[r]):e[r]),t}),{})}function Gl(e,t,r){var n={};return function(i){return function(o){return function(a){try{var s,l=function(e){return s?e:o(d)},c=a.type,u=a.plugins,d=a;if(a.abort)return Promise.resolve(o(a));if(c===bl.enablePlugin&&i.dispatch({type:bl.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),c===bl.disablePlugin&&setTimeout((function(){return Ol(a.meta.rid,{payload:a})}),0),c===bl.initializeEnd){var h=t(),f=Object.keys(h),p=f.filter((function(e){return u.includes(e)})).map((function(e){return h[e]})),g=[],m=[],v=a.disabled,y=p.map((function(e){var t=e.loaded,r=e.name,o=e.config;return Tl(e,(function(){return t({config:o})}),1e4).then((function(t){return n[r]||(i.dispatch({type:bl.pluginReadyType(r),name:r,events:Object.keys(e).filter((function(e){return!yl.includes(e)}))}),n[r]=!0),g=g.concat(r),e})).catch((function(e){if(e instanceof Error)throw new Error(e);return m=m.concat(e.name),e}))}));Promise.all(y).then((function(e){var t={plugins:g,failed:m,disabled:v};setTimeout((function(){f.length===y.length+v.length&&i.dispatch(rl({},{type:bl.ready},t))}),0)}))}var b=function(){if(c!==bl.bootstrap)return/^ready:([^:]*)$/.test(c)&&setTimeout((function(){return function(e,t,r){var n={},i=t(),o=e.getState(),a=o.plugins,s=o.queue,l=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var c=s.actions.reduce((function(e,t,r){return a[t.plugin].loaded?(e.process.push(t),e.processIndex.push(r)):(e.requeue.push(t),e.requeueIndex.push(r)),e}),{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(c.processIndex&&c.processIndex.length){c.processIndex.forEach((function(t){var o=s.actions[t],c=o.plugin,u=o.payload.type,d=i[c][u];if(d&&Rs(d)){var h,f=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),[gl,ml].reduce((function(r,n){return e.hasOwnProperty(n)&&t[n]&&t[n]!==e[n]&&(r[n]=t[n]),r}),e)}(o.payload,l),p=n[f.meta.rid];if(!p&&(h=d({payload:f,config:a[c].config,instance:r,abort:jl}))&&qs(h)&&h.abort)return void(n[f.meta.rid]=!0);if(!p){var g=u+":"+c;e.dispatch(rl({},f,{type:g,_:{called:g,from:"queueDrain"}}))}}}));var u=s.actions.filter((function(e,t){return!~c.processIndex.indexOf(t)}));s.actions=u}}}(i,t,e)}),0),Promise.resolve(function(e,t,r,n,i){try{var o=Rs(t)?t():t,a=e.type,s=a.replace(Rl,"");if(e._&&e._.called)return Promise.resolve(e);var l=r.getState(),c=(h=o,void 0===(f=l.plugins)&&(f={}),void 0===(p=e.options)&&(p={}),Object.keys(h).filter((function(e){var t=p.plugins||{};return Us(t[e])?t[e]:!1!==t.all&&(!f[e]||!1!==f[e].enabled)})).map((function(e){return h[e]})));a===bl.initializeStart&&e.fromEnable&&(c=Object.keys(l.plugins).filter((function(t){var r=l.plugins[t];return e.plugins.includes(t)&&!r.initialized})).map((function(e){return o[e]})));var u=c.map((function(e){return e.name})),d=function(e,t,r){var n=zl(e).map((function(e){return ql(e,t)}));return t.reduce((function(r,n){var i=n.name,o=zl(e,i).map((function(e){return ql(e,t)})),a=o[0],s=o[1],l=o[2];return a.length&&(r.beforeNS[i]=a),s.length&&(r.duringNS[i]=s),l.length&&(r.afterNS[i]=l),r}),{before:n[0],beforeNS:{},during:n[1],duringNS:{},after:n[2],afterNS:{}})}(a,c);return Promise.resolve(Cl({action:e,data:{exact:d.before,namespaced:d.beforeNS},state:l,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then((function(e){function t(){var t=function(){if(a.match(Rl))return Promise.resolve(Cl({action:rl({},c,{type:s+"End"}),data:{exact:d.after,namespaced:d.afterNS},state:l,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then((function(e){e.meta&&e.meta.hasCallback&&Ol(e.meta.rid,{payload:e})}))}();return t&&t.then?t.then((function(){return e})):e}if($l(e,u.length))return e;var c,h=function(){if(a!==s)return Promise.resolve(Cl({action:rl({},e,{type:s}),data:{exact:d.during,namespaced:d.duringNS},state:l,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then((function(e){c=e}));c=e}();return h&&h.then?h.then(t):t()}))}catch(e){return Promise.reject(e)}var h,f,p}(a,t,e,i,r)).then((function(e){return s=1,o(e)}))}();return Promise.resolve(b&&b.then?b.then(l):l(b))}catch(e){return Promise.reject(e)}}}}}function Wl(e){return function(t){return function(t){return function(r){var n=r.type,i=r.key,o=r.value,a=r.options;if(n===bl.setItem||n===bl.removeItem){if(r.abort)return t(r);n===bl.setItem?e.setItem(i,o,a):e.removeItem(i,a)}return t(r)}}}}var Vl=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,r){e[r]=e[r].concat(t)},this.removeMiddleware=function(t,r){var n=e[r].findIndex((function(e){return e===t}));-1!==n&&(e[r]=[].concat(e[r].slice(0,n),e[r].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(r){return function(n){return function(i){var o={getState:r.getState,dispatch:function(e){return r.dispatch(e)}},a=e[t].map((function(e){return e(o)}));return ul.apply(void 0,a)(n)(i)}}}}};function Yl(e){return function(t,r){void 0===t&&(t={});var n={};if("initialize:aborted"===r.type)return t;if(/^registerPlugin:([^:]*)$/.test(r.type)){var i=Kl(r.type,"registerPlugin"),o=e()[i];if(!o||!i)return t;var a=r.enabled,s=o.config;return n[i]={enabled:a,initialized:!!a&&Boolean(!o.initialize),loaded:!!a&&Boolean(o.loaded({config:s})),config:s},rl({},t,n)}if(/^initialize:([^:]*)$/.test(r.type)){var l=Kl(r.type,bl.initialize),c=e()[l];return c&&l?(n[l]=rl({},t[l],{initialized:!0,loaded:Boolean(c.loaded({config:c.config}))}),rl({},t,n)):t}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=rl({},t[r.name],{loaded:!0}),rl({},t,n);switch(r.type){case bl.disablePlugin:return rl({},t,Ql(r.plugins,!1,t));case bl.enablePlugin:return rl({},t,Ql(r.plugins,!0,t));default:return t}}}function Kl(e,t){return e.substring(t.length+1,e.length)}function Ql(e,t,r){return e.reduce((function(e,n){return e[n]=rl({},r[n],{enabled:t}),e}),r)}function Xl(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var Zl={last:{},history:[]};function ec(e,t){void 0===e&&(e=Zl);var r=t.options,n=t.meta;if(t.type===bl.track){var i=Xl(rl({event:t.event,properties:t.properties},Object.keys(r).length&&{options:r},{meta:n}));return rl({},e,{last:i,history:e.history.concat(i)})}return e}var tc={actions:[]};function rc(e,t){void 0===e&&(e=tc);var r=t.payload;switch(t.type){case"queue":var n;return n=r&&r.type&&r.type===bl.identify?[t].concat(e.actions):e.actions.concat(t),rl({},e,{actions:n});case"dequeue":return[];default:return e}}var nc=/#.*$/;function ic(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(nc,""):"")}var oc,ac=function(e){if(void 0===e&&(e={}),!Ps)return e;var t=document,r=t.title,n=t.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,l=o.hash,c=o.search,u=function(e){var t=function(){if(Ps)for(var e,t=document.getElementsByTagName("link"),r=0;e=t[r];r++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}();return t?t.match(/\?/)?t:t+e:window.location.href.replace(nc,"")}(c),d={title:r,url:u,path:ic(u),hash:l,search:c,width:a,height:s};return n&&""!==n&&(d.referrer=n),rl({},d,e)},sc={last:{},history:[]};function lc(e,t){void 0===e&&(e=sc);var r=t.options;if(t.type===bl.page){var n=Xl(rl({properties:t.properties,meta:t.meta},Object.keys(r).length&&{options:r}));return rl({},e,{last:n,history:e.history.concat(n)})}return e}oc={};var cc={initialized:!1,sessionId:Gs(),app:null,version:null,debug:!1,offline:!!Ps&&!navigator.onLine,os:{name:"na"},userAgent:Ps?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.14"},timezone:void 0,locale:void 0,campaign:{},referrer:oc};function uc(e,t){void 0===e&&(e=cc);var r=e.initialized,n=t.campaign;switch(t.type){case bl.campaign:return rl({},e,{campaign:n});case bl.offline:return rl({},e,{offline:!0});case bl.online:return rl({},e,{offline:!1});default:return r?e:rl({},cc,e,{initialized:!0})}}var dc=["plugins","reducers","storage"];function hc(){return Qs("analytics",[]),function(e){return function(t,r,n){var i=e(t,r,n),o=i.dispatch;return Object.assign(i,{dispatch:function(e){return Ys[Vs].analytics.push(e.action||e),o(e)}})}}}function fc(e){return function(){return ul(ul.apply(null,arguments),hc())}}function pc(e){return e?function(e){return"array"===js(e)}(e)?e:[e]:[]}function gc(e,t,r){void 0===e&&(e={});var n,i,o=Gs();return t&&(Il[o]=(n=t,i=function(e){for(var t,r=e||Array.prototype.slice.call(arguments),n=0;n<r.length;n++)if(Rs(r[n])){t=r[n];break}return t}(r),function(e){i&&i(e),n(e)})),rl({},e,{rid:o,ts:(new Date).getTime()},t?{hasCallback:!0}:{})}function mc(e){void 0===e&&(e={});var t=e.reducers||{},r=e.initialUser||{},n=(e.plugins||[]).reduce((function(e,t){if(Rs(t))return e.middlewares=e.middlewares.concat(t),e;if(t.NAMESPACE&&(t.name=t.NAMESPACE),!t.name)throw new Error("https://lytics.dev/errors/1");t.config||(t.config={});var r=t.EVENTS?Object.keys(t.EVENTS).map((function(e){return t.EVENTS[e]})):[];e.pluginEnabled[t.name]=!(!1===t.enabled||!1===t.config.enabled),delete t.enabled,t.methods&&(e.methods[t.name]=Object.keys(t.methods).reduce((function(e,r){var n;return e[r]=(n=t.methods[r],function(){for(var e=Array.prototype.slice.call(arguments),t=new Array(n.length),r=0;r<e.length;r++)t[r]=e[r];return t[t.length]=_,n.apply({instance:_},t)}),e}),{}),delete t.methods);var n=Object.keys(t).concat(r),i=new Set(e.events.concat(n));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(t),e.plugins[t.name])throw new Error(t.name+"AlreadyLoaded");return e.plugins[t.name]=t,e.plugins[t.name].loaded||(e.plugins[t.name].loaded=function(){return!0}),e}),{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=e.storage?e.storage:{getItem:Ks,setItem:Qs,removeItem:Xs},o=function(e){return function(t,r,n){return r.getState("user")[t]||(n&&qs(n)&&n[t]?n[t]:xl(e)[t]||Ks(Pl(t))||null)}}(i),a=n.plugins,s=n.events.filter((function(e){return!yl.includes(e)})).sort(),l=new Set(s.concat(vl).filter((function(e){return!yl.includes(e)}))),c=Array.from(l).sort(),u=function(){return a},d=new Vl,h=d.addMiddleware,f=d.removeMiddleware,p=d.dynamicMiddlewares,g=function(){throw new Error("Abort disabled inListener")},m=Hs(),v=xl(i),y=rl({},v,r,m.an_uid?{userId:m.an_uid}:{},m.an_aid?{anonymousId:m.an_aid}:{});y.anonymousId||(y.anonymousId=Gs());var b=rl({enable:function(e,t){return new Promise((function(r){j.dispatch({type:bl.enablePlugin,plugins:pc(e),_:{originalAction:bl.enablePlugin}},r,[t])}))},disable:function(e,t){return new Promise((function(r){j.dispatch({type:bl.disablePlugin,plugins:pc(e),_:{originalAction:bl.disablePlugin}},r,[t])}))}},n.methods),w=!1,_={identify:function(e,t,r,n){try{var i=Fs(e)?e:null,a=qs(e)?e:t,s=r||{},l=_.user();Qs(Pl(gl),i);var c=i||a.userId||o(gl,_,a);return Promise.resolve(new Promise((function(e){j.dispatch(rl({type:bl.identifyStart,userId:c,traits:a||{},options:s,anonymousId:l.anonymousId},l.id&&l.id!==i&&{previousId:l.id}),e,[t,r,n])})))}catch(e){return Promise.reject(e)}},track:function(e,t,r,n){try{var i=qs(e)?e.event:e;if(!i||!Fs(i))throw new Error("EventMissing");var a=qs(e)?e:t||{},s=qs(r)?r:{};return Promise.resolve(new Promise((function(e){j.dispatch({type:bl.trackStart,event:i,properties:a,options:s,userId:o(gl,_,t),anonymousId:o(ml,_,t)},e,[t,r,n])})))}catch(e){return Promise.reject(e)}},page:function(e,t,r){try{var n=qs(e)?e:{},i=qs(t)?t:{};return Promise.resolve(new Promise((function(a){j.dispatch({type:bl.pageStart,properties:ac(n),options:i,userId:o(gl,_,n),anonymousId:o(ml,_,n)},a,[e,t,r])})))}catch(e){return Promise.reject(e)}},user:function(e){if(e===gl||"id"===e)return o(gl,_);if(e===ml||"anonId"===e)return o(ml,_);var t=_.getState("user");return e?ws(t,e):t},reset:function(e){return new Promise((function(t){j.dispatch({type:bl.resetStart},t,e)}))},ready:function(e){return w&&e({plugins:b,instance:_}),_.on(bl.ready,(function(t){e(t),w=!0}))},on:function(e,t){if(!e||!Rs(t))return!1;if(e===bl.bootstrap)throw new Error(".on disabled for "+e);var r=/Start$|Start:/;if("*"===e){var n=function(e){return function(e){return function(n){return n.type.match(r)&&t({payload:n,instance:_,plugins:a}),e(n)}}},i=function(e){return function(e){return function(n){return n.type.match(r)||t({payload:n,instance:_,plugins:a}),e(n)}}};return h(n,vc),h(i,yc),function(){f(n,vc),f(i,yc)}}var o=e.match(r)?vc:yc,s=function(r){return function(r){return function(n){return n.type===e&&t({payload:n,instance:_,plugins:a,abort:g}),r(n)}}};return h(s,o),function(){return f(s,o)}},once:function(e,t){if(!e||!Rs(t))return!1;if(e===bl.bootstrap)throw new Error(".once disabled for "+e);var r=_.on(e,(function(e){t({payload:e.payload,instance:_,plugins:a,abort:g}),r()}));return r},getState:function(e){var t=j.getState();return e?ws(t,e):Object.assign({},t)},dispatch:function(e){var t=Fs(e)?{type:e}:e;if(vl.includes(t.type))throw new Error("reserved action "+t.type);var r=rl({},t,{_:rl({originalAction:t.type},e._||{})});j.dispatch(r)},enablePlugin:b.enable,disablePlugin:b.disable,plugins:b,storage:{getItem:i.getItem,setItem:function(e,t,r){j.dispatch({type:bl.setItemStart,key:e,value:t,options:r})},removeItem:function(e,t){j.dispatch({type:bl.removeItemStart,key:e,options:t})}},setAnonymousId:function(e,t){_.storage.setItem(hl,e,t)},events:{core:vl,plugins:s}},S=n.middlewares.concat([function(e){return function(e){return function(t){return t.meta||(t.meta=gc()),e(t)}}},p(vc),Gl(_,u,{all:c,plugins:s}),Wl(i),El(_),Al(_),p(yc)]),E={context:uc,user:kl(i),page:lc,track:ec,plugins:Yl(u),queue:rc},k=ul,x=ul;if(Ps&&e.debug){var P=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;P&&(k=P({trace:!0,traceLimit:25})),x=function(){return 0===arguments.length?hc():qs(typeof arguments[0])?fc():fc().apply(null,arguments)}}var A,I=function(e){return Object.keys(e).reduce((function(t,r){return dc.includes(r)||(t[r]=e[r]),t}),{})}(e),O=n.pluginsArray.reduce((function(e,t){var r=t.name,i=t.config,o=t.loaded,a=n.pluginEnabled[r];return e[r]={enabled:a,initialized:!!a&&Boolean(!t.initialize),loaded:Boolean(o({config:i})),config:i},e}),{}),T={context:I,user:y,plugins:O},j=ll(function(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var i=t[n];typeof e[i]===nl&&(r[i]=e[i])}var o,a=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(typeof r(void 0,{type:"@@redux/INIT"})===il||typeof r(void 0,{type:ol})===il)throw new Error("reducer "+t+" "+il)}))}(r)}catch(e){o=e}return function(e,t){if(void 0===e&&(e={}),o)throw o;for(var n=!1,i={},s=0;s<a.length;s++){var l=a[s],c=e[l],u=(0,r[l])(c,t);if(typeof u===il){var d=cl(l,t);throw new Error(d)}i[l]=u,n=n||u!==c}return n?i:e}}(rl({},E,t)),T,x(k(dl.apply(void 0,S))));j.dispatch=(A=j.dispatch,function(e,t,r){var n=rl({},e,{meta:gc(e.meta,t,pc(r))});return A.apply(null,[n])});var C=Object.keys(a);j.dispatch({type:bl.bootstrap,plugins:C,config:I,params:m,user:y,initialUser:r,persistedUser:v});var R=C.filter((function(e){return n.pluginEnabled[e]})),F=C.filter((function(e){return!n.pluginEnabled[e]}));return j.dispatch({type:bl.registerPlugins,plugins:C,enabled:n.pluginEnabled}),n.pluginsArray.map((function(e,t){var r=e.bootstrap,i=e.config,o=e.name;r&&Rs(r)&&r({instance:_,config:i,payload:e}),j.dispatch({type:bl.registerPluginType(o),name:o,enabled:n.pluginEnabled[o],plugin:e}),n.pluginsArray.length===t+1&&j.dispatch({type:bl.initializeStart,plugins:R,disabled:F})})),_}var vc="before",yc="after",bc="cookie",wc=kc(),_c=xc,Sc=xc;function Ec(e){return wc?xc(e,"",-1):Xs(e)}function kc(){if(void 0!==wc)return wc;var e="cookiecookie";try{xc(e,e),wc=-1!==document.cookie.indexOf(e),Ec(e)}catch(e){wc=!1}return wc}function xc(e,t,r,n,i,o){if("undefined"!=typeof window){var a=arguments.length>1;return!1===wc&&(a?Qs(e,t):Ks(e)),a?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Pc="localStorage",Ac=tl.bind(null,"localStorage");Zs("localStorage","getItem",Ks),Zs("localStorage","setItem",Qs),Zs("localStorage","removeItem",Xs);var Ic="sessionStorage",Oc=tl.bind(null,"sessionStorage");function Tc(e){var t=e;try{if("true"===(t=JSON.parse(e)))return!0;if("false"===t)return!1;if(qs(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch(e){}if(null!==t&&""!==t)return t}Zs("sessionStorage","getItem",Ks),Zs("sessionStorage","setItem",Qs),Zs("sessionStorage","removeItem",Xs);var jc=Ac(),Cc=Oc(),Rc=kc();function Fc(e,t){if(e){var r=Lc(t),n=!zc(r),i=Uc(r)?Tc(localStorage.getItem(e)):void 0;if(n&&!Ls(i))return i;var o=Nc(r)?Tc(_c(e)):void 0;if(n&&o)return o;var a=qc(r)?Tc(sessionStorage.getItem(e)):void 0;if(n&&a)return a;var s=Ks(e);return n?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function Lc(e){return e?Fs(e)?e:e.storage:Es}function Uc(e){return jc&&Dc(e,Pc)}function Nc(e){return Rc&&Dc(e,bc)}function qc(e){return Cc&&Dc(e,Ic)}function zc(e){return e===ks||"all"===e}function Dc(e,t){return e===Es||e===t||zc(e)}function $c(e,t,r){return{location:e,current:t,previous:r}}var Mc={setItem:function(e,t,r){if(e&&!Ls(t)){var n={},i=Lc(r),o=JSON.stringify(t),a=!zc(i);return Uc(i)&&(n[Pc]=$c(Pc,t,Tc(localStorage.getItem(e))),localStorage.setItem(e,o),a)?n[Pc]:Nc(i)&&(n[bc]=$c(bc,t,Tc(_c(e))),Sc(e,o),a)?n[bc]:qc(i)&&(n[Ic]=$c(Ic,t,Tc(sessionStorage.getItem(e))),sessionStorage.setItem(e,o),a)?n[Ic]:(n[Ws]=$c(Ws,t,Ks(e)),Qs(e,t),a?n[Ws]:n)}},getItem:Fc,removeItem:function(e,t){if(e){var r=Lc(t),n=Fc(e,ks),i={};return!Ls(n.localStorage)&&Uc(r)&&(localStorage.removeItem(e),i[Pc]=n.localStorage),!Ls(n.cookie)&&Nc(r)&&(Ec(e),i[bc]=n.cookie),!Ls(n.sessionStorage)&&qc(r)&&(sessionStorage.removeItem(e),i[Ic]=n.sessionStorage),!Ls(n.global)&&Dc(r,Ws)&&(Xs(e),i[Ws]=n.global),i}}};function Bc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hc(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Jc(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Hc(Object(r),!0).forEach((function(t){Bc(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hc(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Gc(e,t){const r=function(e){return Array.prototype.slice.call(window.document.querySelectorAll("script")).find((t=>t.src===e))}(e);if(void 0!==r){const e=null==r?void 0:r.getAttribute("status");if("loaded"===e)return Promise.resolve(r);if("loading"===e)return new Promise(((e,t)=>{r.addEventListener("load",(()=>e(r))),r.addEventListener("error",(e=>t(e)))}))}return new Promise(((r,n)=>{var i,o;const a=window.document.createElement("script");a.type="text/javascript",a.src=function(e,t){let r=e;return r.startsWith("http")||(r=`https://${(null==t?void 0:t.www)?"www.":""}${r}`),(null==t?void 0:t.min)?r+=".min.js":(null==t?void 0:t.js)&&(r+=".js"),(null==t?void 0:t.query)&&(r+="?"+t.query),r}(e,t),a.async=!0,a.setAttribute("status","loading");for(const[e,r]of Object.entries(null!==(i=null==t?void 0:t.attributes)&&void 0!==i?i:{}))a.setAttribute(e,r);a.onload=()=>{a.onerror=a.onload=null,a.setAttribute("status","loaded"),r(a)},a.onerror=()=>{a.onerror=a.onload=null,a.setAttribute("status","error"),n(new Error(`Failed to load ${e}`))};const s=window.document.getElementsByTagName("script")[0];null===(o=s.parentElement)||void 0===o||o.insertBefore(a,s)}))}var Wc=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const Vc={id:"tag",handle(e,t){return Wc(this,void 0,void 0,(function*(){fu(t,e)&&function(e,t,r={}){let n;try{n=JSON.parse(e)}catch(t){n={code:e,lang:"javascript"}}const i=r.debug||!1;if(Zu())if("javascript"===n.lang)!function(e,t){const r=`jitsu_event_${dd()}`;window[r]=t;const n=`(function(){\n const event = ${r};\n ${e}\n })()`;try{Kc(n)}catch(e){console.error(`[JITSU] Error executing JS code: ${e.message}. Code: `,n)}finally{delete window[r]}}(n.code,t);else{const e=document.createElement("span");e.innerHTML=function(e,t){return e.replace(/{{\s*event\s*}}/g,JSON.stringify(t))}(n.code,t),document.body.insertAdjacentElement("beforeend",e);e.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");t.type=t.type||"text/javascript",e.hasAttribute("src")&&(t.src=e.src),t.text=e.text,i&&console.log("[JITSU] Executing script"+(e.hasAttribute("src")?` ${e.src}`:""),t.text),document.head.appendChild(t),document.head.removeChild(t)}))}else i&&console.log("[JITSU] insertTags(): cannot insert tags in non-browser environment")}(e.code,t)}))}};let Yc="ve".split("").reverse().join("");const Kc=globalThis[Yc+"al"];var Qc=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const Xc="cdn.lr-ingest.io/",Zc={id:"logrocket",handle(e,t){return Qc(this,void 0,void 0,(function*(){if(!fu(t,e))return;!function(e){Qc(this,void 0,void 0,(function*(){"fresh"===eu()&&(tu("loading"),Gc(`${Xc}LogRocket`,{min:!0,attributes:{crossOrigin:"anonymous"}}).then((()=>{if(window.LogRocket){try{window.LogRocket.init(e)}catch(t){console.warn(`LogRocket (id=${e}) init failed: ${t.message}`,t),tu("failed")}tu("loaded"),nu(window.LogRocket)}})).catch((t=>{console.warn(`LogRocket (id=${e}) init failed: ${t.message}`,t),tu("failed")})))}))}(e.appId);ru().push((e=>{"identify"===t.type&&t.userId&&e.identify(t.userId,t.traits||{})})),"loaded"===eu()&&nu(window.LogRocket)}))}};function eu(){return window.__jitsuLrState||"fresh"}function tu(e){window.__jitsuLrState=e}function ru(){return window.__jitsuLrQueue||(window.__jitsuLrQueue=[])}function nu(e){const t=ru();for(;t.length>0;){const r=t.shift();try{const t=r(e);t&&t.catch((e=>console.warn(`Async LogRocket method failed: ${e.message}`,e)))}catch(e){console.warn(`LogRocket method failed: ${e.message}`,e)}}}var iu=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const ou={id:"gtm",handle(e,t){return iu(this,void 0,void 0,(function*(){var r,n,i,o,a,s,l,c,u,d,h,f,p,g;const m=!!e.debug;if(!fu(t,e))return;yield function(e,t){return iu(this,void 0,void 0,(function*(){if("fresh"!==(window.__jitsuGtmState||"fresh"))return;au("loading");const r=e.dataLayerName||"dataLayer",n=e.containerId;!function(e,r,i){e[r]=e[r]||[],e[r].push({user_id:t.userId}),e[r].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});Gc("googletagmanager.com/gtm",{www:!0,js:!0,query:"id="+i+("dataLayer"!=r?"&l="+r:"")}).then((()=>{au("loaded")})).catch((e=>{console.warn(`GTM (containerId=${n}) init failed: ${e.message}`,e),au("failed")}))}(window,r,n)}))}(e,t);const v=window[e.dataLayerName||"dataLayer"],y=Object.assign(Object.assign({},(null==t?void 0:t.traits)||{}),(null===(r=null==t?void 0:t.context)||void 0===r?void 0:r.traits)||{}),b=function(e,...t){return Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e))))}(y,"id","userId","user_id","anonymousId","userId");m&&console.debug("GTM plugin will be applied to following payload",t);const w={email_address:y.email},_=Object.assign(Object.assign(Object.assign(Object.assign({},t.userId?{user_id:t.userId,userId:t.userId}:{}),t.anonymousId?{anonymousId:t.anonymousId}:{}),b),{user_data:Object.keys(w).length>0?w:void 0});m&&console.debug("GTM plugin will set following user-related data layer vars",_);const S=t.properties||{},E={page_location:S.url||(null===(i=null===(n=t.context)||void 0===n?void 0:n.page)||void 0===i?void 0:i.url),page_title:S.title||(null===(a=null===(o=t.context)||void 0===o?void 0:o.page)||void 0===a?void 0:a.title),page_path:S.path||(null===(l=null===(s=t.context)||void 0===s?void 0:s.page)||void 0===l?void 0:l.path),page_hash:S.hash||(null===(u=null===(c=t.context)||void 0===c?void 0:c.page)||void 0===u?void 0:u.hash),page_search:S.search||(null===(h=null===(d=t.context)||void 0===d?void 0:d.page)||void 0===h?void 0:h.search),page_referrer:null!==(g=null===(p=null===(f=null==t?void 0:t.context)||void 0===f?void 0:f.page)||void 0===p?void 0:p.referrer)&&void 0!==g?g:""};m&&console.debug("GTM plugin will set following context (page) related data layer vars",_);const k=e=>{v.push(e),m&&console.debug("GTM plugin will push following data to dataLayer",e)};switch(t.type){case"page":k(Object.assign(Object.assign({event:"page_view"},E),_));break;case"track":const{properties:e}=t;k(Object.assign(Object.assign(Object.assign({event:t.event},E),e),_));break;case"identify":const{traits:r}=t;k(Object.assign(Object.assign(Object.assign({event:"identify"},E),r),_))}v.push((function(){this.reset()}))}))}};function au(e){window.__jitsuGtmState=e}var su=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const lu=[new Uint8Array([109,111,99,46,114,101,103,97,110,97,109,103,97,116,101,108,103,111,111,103]),new Uint8Array([103,97,116,103]),new Uint8Array([115,106])];function cu(e){return(new TextDecoder).decode(e)}const uu={id:"ga4-tag",handle(e,t){return su(this,void 0,void 0,(function*(){var r,n;if(!fu(t,e))return;yield function(e,t){return su(this,void 0,void 0,(function*(){if("fresh"!==(window.__jitsuGa4State||"fresh"))return;du("loading");const r=e.dataLayerName||"dataLayer",n="dataLayer"!==r?"&l="+r:"",i=e.measurementIds;window[r]=window[r]||[];const o=function(){window[r].push(arguments)};o("js",new Date),o("config",i,Object.assign(Object.assign({},t.userId?{user_id:t.userId}:{}),e.autoPageView?{}:{send_page_view:!1})),Gc(lu.map((e=>e.reverse())).map(cu).join("/"),{query:`id=${i}${n}`,www:!0}).then((()=>{du("loaded")})).catch((t=>{console.warn(`GA4 (containerId=${e.measurementIds}) init failed: ${t.message}`,t),du("failed")}))}))}(e,t);const i=window[e.dataLayerName||"dataLayer"],o=function(){i.push(arguments)},a=Object.assign(Object.assign({},t.userId?{user_id:t.userId,userId:t.userId}:{}),t.anonymousId?{anonymousId:t.anonymousId}:{});switch(t.userId&&o("set",{user_id:t.userId}),t.type){case"page":if(e.autoPageView){console.log("autoPageView");break}const{properties:i,context:s}=t;o("event","page_view",Object.assign({page_location:i.url,page_title:i.title,page_path:i.path,page_hash:i.hash,page_search:i.search,page_referrer:null!==(n=null===(r=null==s?void 0:s.page)||void 0===r?void 0:r.referrer)&&void 0!==n?n:""},a));break;case"track":const{properties:l}=t,c=Object.assign(Object.assign({},l),a);o("event",t.event,c);break;case"identify":const{traits:u}=t;o("event","identify",Object.assign(Object.assign({},u),a))}}))}};function du(e){window.__jitsuGa4State=e}function hu(e,t){return"*"===e||e.toLowerCase().trim()===(t||"").trim().toLowerCase()}function fu(e,t){const{hosts:r="*",events:n="*"}=t;try{const t=Array.isArray(n)?n:n.split("\n");return!(!(Array.isArray(r)?r:r.split("\n")).find((t=>{var r,n,i,o;return i=t,o=null===(n=null===(r=e.context)||void 0===r?void 0:r.page)||void 0===n?void 0:n.host,"*"===i||(o=o||"",i.startsWith("*.")?o.endsWith(i.substring(1)):i===o)}))||!t.find((t=>hu(t,e.type)))&&!t.find((t=>hu(t,e.event))))}catch(e){throw console.warn(`Failed to apply filters: ${e.message}. Typeof events: ${typeof n}, typeof hosts: ${typeof r}. Values`,n,r),new Error(`Failed to apply filters: ${e.message}. Typeof events: ${typeof n}, typeof hosts: ${typeof r}`)}}const pu={[Vc.id]:Vc,[ou.id]:ou,[uu.id]:uu,[Zc.id]:Zc},gu="2.0.0",mu="@jitsu/js",vu="myshopify.com,ac,com.ac,edu.ac,gov.ac,net.ac,mil.ac,org.ac,ad,nom.ad,ae,co.ae,net.ae,org.ae,sch.ae,ac.ae,gov.ae,mil.ae,aero,af,gov.af,com.af,org.af,net.af,edu.af,ag,com.ag,org.ag,net.ag,co.ag,nom.ag,ai,off.ai,com.ai,net.ai,org.ai,al,com.al,edu.al,gov.al,mil.al,net.al,org.al,am,co.am,com.am,commune.am,net.am,org.am,ao,ed.ao,gv.ao,og.ao,co.ao,pb.ao,it.ao,aq,ar,bet.ar,com.ar,coop.ar,edu.ar,gob.ar,gov.ar,int.ar,mil.ar,musica.ar,mutual.ar,net.ar,org.ar,senasa.ar,tur.ar,arpa,e164.arpa,in-addr.arpa,ip6.arpa,iris.arpa,uri.arpa,urn.arpa,as,gov.as,asia,at,ac.at,co.at,gv.at,or.at,sth.ac.at,au,com.au,net.au,org.au,edu.au,gov.au,asn.au,id.au,act.au,nsw.au,nt.au,qld.au,sa.au,tas.au,vic.au,wa.au,aw,com.aw,ax,az,com.az,net.az,int.az,gov.az,org.az,edu.az,info.az,pp.az,mil.az,name.az,pro.az,biz.az,ba,com.ba,edu.ba,gov.ba,mil.ba,net.ba,org.ba,bb,biz.bb,co.bb,com.bb,edu.bb,gov.bb,info.bb,net.bb,org.bb,store.bb,tv.bb,bd,be,ac.be,bf,gov.bf,bg,a.bg,b.bg,c.bg,d.bg,e.bg,f.bg,g.bg,h.bg,i.bg,j.bg,k.bg,l.bg,m.bg,n.bg,o.bg,p.bg,q.bg,r.bg,s.bg,t.bg,u.bg,v.bg,w.bg,x.bg,y.bg,z.bg,0.bg,1.bg,2.bg,3.bg,4.bg,5.bg,6.bg,7.bg,8.bg,9.bg,bh,com.bh,edu.bh,net.bh,org.bh,gov.bh,bi,co.bi,com.bi,edu.bi,or.bi,org.bi,biz,bj,africa.bj,agro.bj,architectes.bj,assur.bj,avocats.bj,co.bj,com.bj,eco.bj,econo.bj,edu.bj,info.bj,loisirs.bj,money.bj,net.bj,org.bj,ote.bj,resto.bj,restaurant.bj,tourism.bj,univ.bj,bm,com.bm,edu.bm,gov.bm,net.bm,org.bm,bn,com.bn,edu.bn,gov.bn,net.bn,org.bn,bo,com.bo,edu.bo,gob.bo,int.bo,org.bo,net.bo,mil.bo,tv.bo,web.bo,br,9guacu.br,abc.br,adm.br,adv.br,agr.br,aju.br,am.br,anani.br,aparecida.br,app.br,arq.br,art.br,ato.br,b.br,barueri.br,belem.br,bhz.br,bib.br,bio.br,blog.br,bmd.br,boavista.br,bsb.br,campinagrande.br,campinas.br,caxias.br,cim.br,cng.br,cnt.br,com.br,contagem.br,coop.br,coz.br,cri.br,cuiaba.br,curitiba.br,def.br,des.br,det.br,dev.br,ecn.br,eco.br,edu.br,emp.br,enf.br,eng.br,esp.br,etc.br,eti.br,far.br,feira.br,flog.br,floripa.br,fm.br,fnd.br,fortal.br,fot.br,foz.br,fst.br,g12.br,geo.br,ggf.br,goiania.br,gov.br,gru.br,imb.br,ind.br,inf.br,jab.br,jampa.br,jdf.br,joinville.br,jor.br,jus.br,leg.br,lel.br,log.br,londrina.br,macapa.br,maceio.br,manaus.br,maringa.br,mat.br,med.br,mil.br,morena.br,mp.br,mus.br,natal.br,net.br,niteroi.br,nom.br,not.br,ntr.br,odo.br,ong.br,org.br,osasco.br,palmas.br,poa.br,ppg.br,pro.br,psc.br,psi.br,pvh.br,qsl.br,radio.br,rec.br,recife.br,rep.br,ribeirao.br,rio.br,riobranco.br,riopreto.br,salvador.br,sampa.br,santamaria.br,santoandre.br,saobernardo.br,saogonca.br,seg.br,sjc.br,slg.br,slz.br,sorocaba.br,srv.br,taxi.br,tc.br,tec.br,teo.br,the.br,tmp.br,trd.br,tur.br,tv.br,udi.br,vet.br,vix.br,vlog.br,wiki.br,zlg.br,bs,com.bs,net.bs,org.bs,edu.bs,gov.bs,bt,com.bt,edu.bt,gov.bt,net.bt,org.bt,bv,bw,co.bw,org.bw,by,gov.by,mil.by,com.by,of.by,bz,com.bz,net.bz,org.bz,edu.bz,gov.bz,ca,ab.ca,bc.ca,mb.ca,nb.ca,nf.ca,nl.ca,ns.ca,nt.ca,nu.ca,on.ca,pe.ca,qc.ca,sk.ca,yk.ca,gc.ca,cat,cc,cd,gov.cd,cf,cg,ch,ci,org.ci,or.ci,com.ci,co.ci,edu.ci,ed.ci,ac.ci,net.ci,go.ci,asso.ci,aéroport.ci,int.ci,presse.ci,md.ci,gouv.ci,ck,cl,co.cl,gob.cl,gov.cl,mil.cl,cm,co.cm,com.cm,gov.cm,net.cm,cn,ac.cn,com.cn,edu.cn,gov.cn,net.cn,org.cn,mil.cn,co,arts.co,com.co,edu.co,firm.co,gov.co,info.co,int.co,mil.co,net.co,nom.co,org.co,rec.co,web.co,com,coop,cr,ac.cr,co.cr,ed.cr,fi.cr,go.cr,or.cr,sa.cr,cu,com.cu,edu.cu,org.cu,net.cu,gov.cu,inf.cu,cv,com.cv,edu.cv,int.cv,nome.cv,org.cv,cw,com.cw,edu.cw,net.cw,org.cw,cx,gov.cx,cy,ac.cy,biz.cy,com.cy,ekloges.cy,gov.cy,ltd.cy,mil.cy,net.cy,org.cy,press.cy,pro.cy,tm.cy,cz,de,dj,dk,dm,com.dm,net.dm,org.dm,edu.dm,gov.dm,do,art.do,com.do,edu.do,gob.do,gov.do,mil.do,net.do,org.do,sld.do,web.do,dz,art.dz,asso.dz,com.dz,edu.dz,gov.dz,org.dz,net.dz,pol.dz,soc.dz,tm.dz,ec,com.ec,info.ec,net.ec,fin.ec,k12.ec,med.ec,pro.ec,org.ec,edu.ec,gov.ec,gob.ec,mil.ec,edu,ee,edu.ee,gov.ee,riik.ee,lib.ee,med.ee,com.ee,pri.ee,aip.ee,org.ee,fie.ee,eg,com.eg,edu.eg,eun.eg,gov.eg,mil.eg,name.eg,net.eg,org.eg,sci.eg,er,es,com.es,nom.es,org.es,gob.es,edu.es,et,com.et,gov.et,org.et,edu.et,biz.et,name.et,info.et,net.et,eu,fi,aland.fi,fj,ac.fj,biz.fj,com.fj,gov.fj,info.fj,mil.fj,name.fj,net.fj,org.fj,pro.fj,fk,com.fm,edu.fm,net.fm,org.fm,fm,fo,fr,asso.fr,com.fr,gouv.fr,nom.fr,prd.fr,tm.fr,aeroport.fr,avocat.fr,avoues.fr,cci.fr,chambagri.fr,chirurgiens-dentistes.fr,experts-comptables.fr,geometre-expert.fr,greta.fr,huissier-justice.fr,medecin.fr,notaires.fr,pharmacien.fr,port.fr,veterinaire.fr,ga,gb,edu.gd,gov.gd,gd,ge,com.ge,edu.ge,gov.ge,org.ge,mil.ge,net.ge,pvt.ge,gf,gg,co.gg,net.gg,org.gg,gh,com.gh,edu.gh,gov.gh,org.gh,mil.gh,gi,com.gi,ltd.gi,gov.gi,mod.gi,edu.gi,org.gi,gl,co.gl,com.gl,edu.gl,net.gl,org.gl,gm,gn,ac.gn,com.gn,edu.gn,gov.gn,org.gn,net.gn,gov,gp,com.gp,net.gp,mobi.gp,edu.gp,org.gp,asso.gp,gq,gr,com.gr,edu.gr,net.gr,org.gr,gov.gr,gs,gt,com.gt,edu.gt,gob.gt,ind.gt,mil.gt,net.gt,org.gt,gu,com.gu,edu.gu,gov.gu,guam.gu,info.gu,net.gu,org.gu,web.gu,gw,gy,co.gy,com.gy,edu.gy,gov.gy,net.gy,org.gy,hk,com.hk,edu.hk,gov.hk,idv.hk,net.hk,org.hk,hm,hn,com.hn,edu.hn,org.hn,net.hn,mil.hn,gob.hn,hr,iz.hr,from.hr,name.hr,com.hr,ht,com.ht,shop.ht,firm.ht,info.ht,adult.ht,net.ht,pro.ht,org.ht,med.ht,art.ht,coop.ht,pol.ht,asso.ht,edu.ht,rel.ht,gouv.ht,perso.ht,hu,co.hu,info.hu,org.hu,priv.hu,sport.hu,tm.hu,2000.hu,agrar.hu,bolt.hu,casino.hu,city.hu,erotica.hu,erotika.hu,film.hu,forum.hu,games.hu,hotel.hu,ingatlan.hu,jogasz.hu,konyvelo.hu,lakas.hu,media.hu,news.hu,reklam.hu,sex.hu,shop.hu,suli.hu,szex.hu,tozsde.hu,utazas.hu,video.hu,id,ac.id,biz.id,co.id,desa.id,go.id,mil.id,my.id,net.id,or.id,ponpes.id,sch.id,web.id,ie,gov.ie,il,ac.il,co.il,gov.il,idf.il,k12.il,muni.il,net.il,org.il,im,ac.im,co.im,com.im,ltd.co.im,net.im,org.im,plc.co.im,tt.im,tv.im,in,5g.in,6g.in,ac.in,ai.in,am.in,bihar.in,biz.in,business.in,ca.in,cn.in,co.in,com.in,coop.in,cs.in,delhi.in,dr.in,edu.in,er.in,firm.in,gen.in,gov.in,gujarat.in,ind.in,info.in,int.in,internet.in,io.in,me.in,mil.in,net.in,nic.in,org.in,pg.in,post.in,pro.in,res.in,travel.in,tv.in,uk.in,up.in,us.in,info,int,eu.int,io,com.io,iq,gov.iq,edu.iq,mil.iq,com.iq,org.iq,net.iq,ir,ac.ir,co.ir,gov.ir,id.ir,net.ir,org.ir,sch.ir,is,net.is,com.is,edu.is,gov.is,org.is,int.is,it,gov.it,edu.it,je,co.je,net.je,org.je,jm,jo,com.jo,org.jo,net.jo,edu.jo,sch.jo,gov.jo,mil.jo,name.jo,jobs,jp,ac.jp,ad.jp,co.jp,ed.jp,go.jp,gr.jp,lg.jp,ne.jp,or.jp,ke,ac.ke,co.ke,go.ke,info.ke,me.ke,mobi.ke,ne.ke,or.ke,sc.ke,kg,org.kg,net.kg,com.kg,edu.kg,gov.kg,mil.kg,kh,ki,edu.ki,biz.ki,net.ki,org.ki,gov.ki,info.ki,com.ki,km,org.km,nom.km,gov.km,prd.km,tm.km,edu.km,mil.km,ass.km,com.km,kn,net.kn,org.kn,edu.kn,gov.kn,kp,com.kp,edu.kp,gov.kp,org.kp,rep.kp,tra.kp,kr,ac.kr,co.kr,es.kr,go.kr,hs.kr,kg.kr,mil.kr,ms.kr,ne.kr,or.kr,pe.kr,re.kr,sc.kr,kw,com.kw,edu.kw,emb.kw,gov.kw,ind.kw,net.kw,org.kw,ky,com.ky,edu.ky,net.ky,org.ky,kz,org.kz,edu.kz,net.kz,gov.kz,mil.kz,com.kz,la,int.la,net.la,info.la,edu.la,gov.la,per.la,com.la,org.la,lb,com.lb,edu.lb,gov.lb,net.lb,org.lb,lc,com.lc,net.lc,co.lc,org.lc,edu.lc,gov.lc,li,lk,gov.lk,sch.lk,net.lk,int.lk,com.lk,org.lk,edu.lk,ngo.lk,soc.lk,web.lk,ltd.lk,assn.lk,grp.lk,hotel.lk,ac.lk,lr,com.lr,edu.lr,gov.lr,org.lr,net.lr,ls,ac.ls,biz.ls,co.ls,edu.ls,gov.ls,info.ls,net.ls,org.ls,sc.ls,lt,gov.lt,lu,lv,com.lv,edu.lv,gov.lv,org.lv,mil.lv,id.lv,net.lv,asn.lv,conf.lv,ly,com.ly,net.ly,gov.ly,plc.ly,edu.ly,sch.ly,med.ly,org.ly,id.ly,ma,co.ma,net.ma,gov.ma,org.ma,ac.ma,press.ma,mc,tm.mc,asso.mc,md,me,co.me,net.me,org.me,edu.me,ac.me,gov.me,its.me,priv.me,mg,org.mg,nom.mg,gov.mg,prd.mg,tm.mg,edu.mg,mil.mg,com.mg,co.mg,mh,mil,mk,com.mk,org.mk,net.mk,edu.mk,gov.mk,inf.mk,name.mk,ml,com.ml,edu.ml,gouv.ml,gov.ml,net.ml,org.ml,presse.ml,mm,mn,gov.mn,edu.mn,org.mn,mo,com.mo,net.mo,org.mo,edu.mo,gov.mo,mobi,mp,mq,mr,gov.mr,ms,com.ms,edu.ms,gov.ms,net.ms,org.ms,mt,com.mt,edu.mt,net.mt,org.mt,mu,com.mu,net.mu,org.mu,gov.mu,ac.mu,co.mu,or.mu,museum,mv,aero.mv,biz.mv,com.mv,coop.mv,edu.mv,gov.mv,info.mv,int.mv,mil.mv,museum.mv,name.mv,net.mv,org.mv,pro.mv,mw,ac.mw,biz.mw,co.mw,com.mw,coop.mw,edu.mw,gov.mw,int.mw,museum.mw,net.mw,org.mw,mx,com.mx,org.mx,gob.mx,edu.mx,net.mx,my,biz.my,com.my,edu.my,gov.my,mil.my,name.my,net.my,org.my,mz,ac.mz,adv.mz,co.mz,edu.mz,gov.mz,mil.mz,net.mz,org.mz,na,info.na,pro.na,name.na,school.na,or.na,dr.na,us.na,mx.na,ca.na,in.na,cc.na,tv.na,ws.na,mobi.na,co.na,com.na,org.na,name,nc,asso.nc,nom.nc,ne,net,nf,com.nf,net.nf,per.nf,rec.nf,web.nf,arts.nf,firm.nf,info.nf,other.nf,store.nf,ng,com.ng,edu.ng,gov.ng,i.ng,mil.ng,mobi.ng,name.ng,net.ng,org.ng,sch.ng,ni,ac.ni,biz.ni,co.ni,com.ni,edu.ni,gob.ni,in.ni,info.ni,int.ni,mil.ni,net.ni,nom.ni,org.ni,web.ni,nl,no,fhs.no,vgs.no,fylkesbibl.no,folkebibl.no,museum.no,idrett.no,priv.no,mil.no,stat.no,dep.no,kommune.no,herad.no,np,nr,biz.nr,info.nr,gov.nr,edu.nr,org.nr,net.nr,com.nr,nu,nz,ac.nz,co.nz,cri.nz,geek.nz,gen.nz,govt.nz,health.nz,iwi.nz,kiwi.nz,maori.nz,mil.nz,māori.nz,net.nz,org.nz,parliament.nz,school.nz,om,co.om,com.om,edu.om,gov.om,med.om,museum.om,net.om,org.om,pro.om,onion,org,pa,ac.pa,gob.pa,com.pa,org.pa,sld.pa,edu.pa,net.pa,ing.pa,abo.pa,med.pa,nom.pa,pe,edu.pe,gob.pe,nom.pe,mil.pe,org.pe,com.pe,net.pe,pf,com.pf,org.pf,edu.pf,pg,ph,com.ph,net.ph,org.ph,gov.ph,edu.ph,ngo.ph,mil.ph,i.ph,pk,com.pk,net.pk,edu.pk,org.pk,fam.pk,biz.pk,web.pk,gov.pk,gob.pk,gok.pk,gon.pk,gop.pk,gos.pk,info.pk,pl,com.pl,net.pl,org.pl,aid.pl,agro.pl,atm.pl,auto.pl,biz.pl,edu.pl,gmina.pl,gsm.pl,info.pl,mail.pl,miasta.pl,media.pl,mil.pl,nieruchomosci.pl,nom.pl,pc.pl,powiat.pl,priv.pl,realestate.pl,rel.pl,sex.pl,shop.pl,sklep.pl,sos.pl,szkola.pl,targi.pl,tm.pl,tourism.pl,travel.pl,turystyka.pl,pm,pn,gov.pn,co.pn,org.pn,edu.pn,net.pn,post,pr,com.pr,net.pr,org.pr,gov.pr,edu.pr,isla.pr,pro.pr,biz.pr,info.pr,name.pr,est.pr,prof.pr,ac.pr,pro,aaa.pro,aca.pro,acct.pro,avocat.pro,bar.pro,cpa.pro,eng.pro,jur.pro,law.pro,med.pro,recht.pro,ps,edu.ps,gov.ps,sec.ps,plo.ps,com.ps,org.ps,net.ps,pt,net.pt,gov.pt,org.pt,edu.pt,int.pt,publ.pt,com.pt,nome.pt,pw,co.pw,ne.pw,or.pw,ed.pw,go.pw,belau.pw,py,com.py,coop.py,edu.py,gov.py,mil.py,net.py,org.py,qa,com.qa,edu.qa,gov.qa,mil.qa,name.qa,net.qa,org.qa,sch.qa,re,asso.re,com.re,nom.re,ro,arts.ro,com.ro,firm.ro,info.ro,nom.ro,nt.ro,org.ro,rec.ro,store.ro,tm.ro,www.ro,rs,ac.rs,co.rs,edu.rs,gov.rs,in.rs,org.rs,ru,rw,ac.rw,co.rw,coop.rw,gov.rw,mil.rw,net.rw,org.rw,sa,com.sa,net.sa,org.sa,gov.sa,med.sa,pub.sa,edu.sa,sch.sa,sb,com.sb,edu.sb,gov.sb,net.sb,org.sb,sc,com.sc,gov.sc,net.sc,org.sc,edu.sc,sd,com.sd,net.sd,org.sd,edu.sd,med.sd,tv.sd,gov.sd,info.sd,se,a.se,ac.se,b.se,bd.se,brand.se,c.se,d.se,e.se,f.se,fh.se,fhsk.se,fhv.se,g.se,h.se,i.se,k.se,komforb.se,kommunalforbund.se,komvux.se,l.se,lanbib.se,m.se,n.se,naturbruksgymn.se,o.se,org.se,p.se,parti.se,pp.se,press.se,r.se,s.se,t.se,tm.se,u.se,w.se,x.se,y.se,z.se,sg,com.sg,net.sg,org.sg,gov.sg,edu.sg,per.sg,sh,com.sh,net.sh,gov.sh,org.sh,mil.sh,si,sj,sk,sl,com.sl,net.sl,edu.sl,gov.sl,org.sl,sm,sn,art.sn,com.sn,edu.sn,gouv.sn,org.sn,perso.sn,univ.sn,so,com.so,edu.so,gov.so,me.so,net.so,org.so,sr,ss,biz.ss,com.ss,edu.ss,gov.ss,me.ss,net.ss,org.ss,sch.ss,st,co.st,com.st,consulado.st,edu.st,embaixada.st,mil.st,net.st,org.st,principe.st,saotome.st,store.st,su,sv,com.sv,edu.sv,gob.sv,org.sv,red.sv,sx,gov.sx,sy,edu.sy,gov.sy,net.sy,mil.sy,com.sy,org.sy,sz,co.sz,ac.sz,org.sz,tc,td,tel,tf,tg,th,ac.th,co.th,go.th,in.th,mi.th,net.th,or.th,tj,ac.tj,biz.tj,co.tj,com.tj,edu.tj,go.tj,gov.tj,int.tj,mil.tj,name.tj,net.tj,nic.tj,org.tj,test.tj,web.tj,tk,tl,gov.tl,tm,com.tm,co.tm,org.tm,net.tm,nom.tm,gov.tm,mil.tm,edu.tm,tn,com.tn,ens.tn,fin.tn,gov.tn,ind.tn,info.tn,intl.tn,mincom.tn,nat.tn,net.tn,org.tn,perso.tn,tourism.tn,to,com.to,gov.to,net.to,org.to,edu.to,mil.to,tr,av.tr,bbs.tr,bel.tr,biz.tr,com.tr,dr.tr,edu.tr,gen.tr,gov.tr,info.tr,mil.tr,k12.tr,kep.tr,name.tr,net.tr,org.tr,pol.tr,tel.tr,tsk.tr,tv.tr,web.tr,nc.tr,tt,co.tt,com.tt,org.tt,net.tt,biz.tt,info.tt,pro.tt,int.tt,coop.tt,jobs.tt,mobi.tt,travel.tt,museum.tt,aero.tt,name.tt,gov.tt,edu.tt,tv,tw,edu.tw,gov.tw,mil.tw,com.tw,net.tw,org.tw,idv.tw,game.tw,ebiz.tw,club.tw,tz,ac.tz,co.tz,go.tz,hotel.tz,info.tz,me.tz,mil.tz,mobi.tz,ne.tz,or.tz,sc.tz,tv.tz,ua,com.ua,edu.ua,gov.ua,in.ua,net.ua,org.ua,ug,co.ug,or.ug,ac.ug,sc.ug,go.ug,ne.ug,com.ug,org.ug,uk,ac.uk,co.uk,gov.uk,ltd.uk,me.uk,net.uk,nhs.uk,org.uk,plc.uk,police.uk,us,dni.us,fed.us,isa.us,kids.us,nsn.us,ak.us,al.us,ar.us,as.us,az.us,ca.us,co.us,ct.us,dc.us,de.us,fl.us,ga.us,gu.us,hi.us,ia.us,id.us,il.us,in.us,ks.us,ky.us,la.us,ma.us,md.us,me.us,mi.us,mn.us,mo.us,ms.us,mt.us,nc.us,nd.us,ne.us,nh.us,nj.us,nm.us,nv.us,ny.us,oh.us,ok.us,or.us,pa.us,pr.us,ri.us,sc.us,sd.us,tn.us,tx.us,ut.us,vi.us,vt.us,va.us,wa.us,wi.us,wv.us,wy.us,uy,com.uy,edu.uy,gub.uy,mil.uy,net.uy,org.uy,uz,co.uz,com.uz,net.uz,org.uz,va,vc,com.vc,net.vc,org.vc,gov.vc,mil.vc,edu.vc,ve,arts.ve,bib.ve,co.ve,com.ve,e12.ve,edu.ve,firm.ve,gob.ve,gov.ve,info.ve,int.ve,mil.ve,net.ve,nom.ve,org.ve,rar.ve,rec.ve,store.ve,tec.ve,web.ve,vg,vi,co.vi,com.vi,k12.vi,net.vi,org.vi,vn,ac.vn,ai.vn,biz.vn,com.vn,edu.vn,gov.vn,health.vn,id.vn,info.vn,int.vn,io.vn,name.vn,net.vn,org.vn,pro.vn,vu,com.vu,edu.vu,net.vu,org.vu,wf,ws,com.ws,net.ws,org.ws,gov.ws,edu.ws,yt,ye,com.ye,edu.ye,gov.ye,net.ye,mil.ye,org.ye,ac.za,agric.za,alt.za,co.za,edu.za,gov.za,grondar.za,law.za,mil.za,net.za,ngo.za,nic.za,nis.za,nom.za,org.za,school.za,tm.za,web.za,zm,ac.zm,biz.zm,co.zm,com.zm,edu.zm,gov.zm,info.zm,mil.zm,net.zm,org.zm,sch.zm,zw,ac.zw,co.zw,gov.zw,mil.zw,org.zw".split(","),yu={};vu.forEach((e=>{yu[e]=!0}));const bu=yu;function wu(e){const[t]=e.split(":"),r=t.split(".");if("localhost"===r[r.length-1]||r.length<2)return r[r.length-1];{const e=r[r.length-2]+"."+r[r.length-1];return r.length>2&&bu[e]?r[r.length-3]+"."+e:e}}class _u{constructor(e){this.selfOptions=e||{},this.pipes={}}options(e){return e&&(this.selfOptions=e),this.selfOptions}pipe(e,t){let r=t;if("string"==typeof e){if(void 0===r)return this.pipes[e];this.pipes[e]=r}if(e&&e.name){if(r=e,r.processor===this)return r;this.pipes[r.name]=r}return r.processor=this,r}process(e,t){let r=e;r.options=this.options();let n,i=t||e.pipe||"default";for(;i;)void 0!==r.nextAfterChildren&&(r.next=r.nextAfterChildren,r.nextAfterChildren=null),"string"==typeof i&&(i=this.pipe(i)),i.process(r),n=i,i=null,r&&r.next&&(r=r.next,i=r.pipe||n);return r.hasResult?r.result:void 0}}class Su{constructor(e){this.name=e,this.filters=[]}process(e){if(!this.processor)throw new Error("add this pipe to a processor before using it");const t=this.debug,r=this.filters.length,n=e;for(let e=0;e<r;e++){const r=this.filters[e];if(t&&this.log(`filter: ${r.filterName}`),r(n),"object"==typeof n&&n.exiting){n.exiting=!1;break}}!n.next&&this.resultCheck&&this.resultCheck(n)}log(e){console.log(`[jsondiffpatch] ${this.name} pipe, ${e}`)}append(...e){return this.filters.push(...e),this}prepend(...e){return this.filters.unshift(...e),this}indexOf(e){if(!e)throw new Error("a filter name is required");for(let t=0;t<this.filters.length;t++){if(this.filters[t].filterName===e)return t}throw new Error(`filter not found: ${e}`)}list(){return this.filters.map((e=>e.filterName))}after(e,...t){const r=this.indexOf(e);return this.filters.splice(r+1,0,...t),this}before(e,...t){const r=this.indexOf(e);return this.filters.splice(r,0,...t),this}replace(e,...t){const r=this.indexOf(e);return this.filters.splice(r,1,...t),this}remove(e){const t=this.indexOf(e);return this.filters.splice(t,1),this}clear(){return this.filters.length=0,this}shouldHaveResult(e){if(!1!==e){if(!this.resultCheck)return this.resultCheck=e=>{if(!e.hasResult){console.log(e);const t=new Error(`${this.name} failed`);throw t.noResult=!0,t}},this}else this.resultCheck=null}}class Eu{setResult(e){return this.result=e,this.hasResult=!0,this}exit(){return this.exiting=!0,this}push(e,t){return e.parent=this,void 0!==t&&(e.childName=t),e.root=this.root||this,e.options=e.options||this.options,this.children?(this.children[this.children.length-1].next=e,this.children.push(e)):(this.children=[e],this.nextAfterChildren=this.next||null,this.next=e),e.next=this,this}}class ku extends Eu{constructor(e,t){super(),this.left=e,this.right=t,this.pipe="diff"}setResult(e){return super.setResult(e)}}class xu extends Eu{constructor(e,t){super(),this.left=e,this.delta=t,this.pipe="patch"}}const Pu=function(e){if(e.left!==e.right)if(void 0!==e.left)if(void 0!==e.right){if("function"==typeof e.left||"function"==typeof e.right)throw new Error("functions are not supported");if(e.leftType=null===e.left?"null":typeof e.left,e.rightType=null===e.right?"null":typeof e.right,e.leftType===e.rightType)if("boolean"!==e.leftType&&"number"!==e.leftType&&"string"!==e.leftType){if("object"===e.leftType&&(e.leftIsArray=Array.isArray(e.left)),"object"===e.rightType&&(e.rightIsArray=Array.isArray(e.right)),e.leftIsArray===e.rightIsArray)return e.leftIsArray&&e.rightIsArray?function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(e.left,e.right)?void e.setResult(void 0).exit():void e.setResult([e.left,e.right]).exit():void(e.left instanceof RegExp&&(e.right instanceof RegExp?e.setResult([e.left.toString(),e.right.toString()]).exit():e.setResult([e.left,e.right]).exit()));e.setResult([e.left,e.right]).exit()}else e.setResult([e.left,e.right]).exit();else e.setResult([e.left,e.right]).exit()}else e.setResult([e.left,0,0]).exit();else{if("function"==typeof e.right)throw new Error("functions are not supported");e.setResult([e.right]).exit()}else e.setResult(void 0).exit()};Pu.filterName="trivial";const Au=function(e){if(void 0===e.delta)return void e.setResult(e.left).exit();if(e.nested=!Array.isArray(e.delta),e.nested)return;const t=e.delta;if(1!==t.length)if(2!==t.length)3===t.length&&0===t[2]&&e.setResult(void 0).exit();else{if(e.left instanceof RegExp){const r=/^\/(.*)\/([gimyu]+)$/.exec(t[1]);if(r)return void e.setResult(new RegExp(r[1],r[2])).exit()}e.setResult(t[1]).exit()}else e.setResult(t[0]).exit()};Au.filterName="trivial";const Iu=e=>{if(!e||!e.children)return;const t=e.children.length;let r,n=e.result;for(let i=0;i<t;i++)r=e.children[i],void 0!==r.result&&(n=n||{},n[r.childName]=r.result);n&&e.leftIsArray&&(n._t="a"),e.setResult(n).exit()};Iu.filterName="collectChildren";const Ou=e=>{if(e.leftIsArray||"object"!==e.leftType)return;const t=e.left,r=e.right;let n,i;const o=e.options.propertyFilter;for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o&&!o(n,e)||(i=new ku(t[n],r[n]),e.push(i,n)));for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o&&!o(n,e)||void 0===t[n]&&(i=new ku(void 0,r[n]),e.push(i,n)));e.children&&0!==e.children.length?e.exit():e.setResult(void 0).exit()};Ou.filterName="objects";const Tu=function(e){if(!e.nested)return;const t=e.delta;if(t._t)return;const r=t;let n,i;for(n in r)i=new xu(e.left[n],r[n]),e.push(i,n);e.exit()};Tu.filterName="objects";const ju=function(e){if(!e||!e.children)return;if(e.delta._t)return;const t=e.left,r=e.children.length;let n;for(let i=0;i<r;i++){n=e.children[i];const r=n.childName;Object.prototype.hasOwnProperty.call(e.left,r)&&void 0===n.result?delete t[r]:t[r]!==n.result&&(t[r]=n.result)}e.setResult(t).exit()};ju.filterName="collectChildren";const Cu=function(e){e.left instanceof Date?(e.right instanceof Date?e.left.getTime()!==e.right.getTime()?e.setResult([e.left,e.right]):e.setResult(void 0):e.setResult([e.left,e.right]),e.exit()):e.right instanceof Date&&e.setResult([e.left,e.right]).exit()};Cu.filterName="dates";class Ru{constructor(e){this.processor=new _u(e),this.processor.pipe(new Su("diff").append(Iu,Pu,Cu,Ou).shouldHaveResult()),this.processor.pipe(new Su("patch").append(ju,Au,Tu).shouldHaveResult())}options(e){return this.processor.options(e)}diff(e,t){return this.processor.process(new ku(e,t))}patch(e,t){return this.processor.process(new xu(e,t))}}var Fu=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const Lu=new Ru(Uu);var Uu;const Nu={writeKey:null,host:null,debug:!1,fetch:null,echoEvents:!1,cookieDomain:void 0,cookieNames:{},cookieCapture:{},runtime:void 0,fetchTimeoutMs:void 0,s2s:void 0,idEndpoint:void 0,errorPolicy:"log",defaultPayloadContext:{},privacy:{dontSend:!1,disableUserIds:!1,ipPolicy:"keep",consentCategories:void 0}},qu=(e,t)=>{for(const r of Object.keys(Nu)){const n=t[r];"privacy"===r?"object"==typeof n?e.privacy=Object.assign(Object.assign(Object.assign({},Nu.privacy),e.privacy),n):t.hasOwnProperty("privacy")&&void 0===n&&(e.privacy=Object.assign({},Nu.privacy)):void 0===n?!t.hasOwnProperty(r)&&e.hasOwnProperty(r)||(e[r]=Nu[r]):e[r]=n}},zu=e=>{if(!e)return{};let t=e.length>0&&"?"===e.charAt(0)?e.substring(1):e,r={},n=("?"===t[0]?t.substr(1):t).split("&");for(let e=0;e<n.length;e++){let t=n[e].split("=");r[decodeURIComponent(t[0])]=decodeURIComponent(t[1]||"")}return r};function Du(e){const t=e.substring(4);return"campaign"===t?"name":t}function $u(e){return Object.entries(e).filter((([e])=>0===e.indexOf("utm_"))).reduce(((e,[t,r])=>Object.assign(Object.assign({},e),{[Du(t)]:r})),{})}function Mu(e,t){try{return e()}catch(e){return t}}function Bu(e){let t=e.getItem("__user_traits");"string"==typeof t&&(t=Mu((()=>JSON.parse(t)),{})),("object"!=typeof t||null===t||Array.isArray(t))&&(t={});let r=e.getItem("__group_traits");return"string"==typeof r&&(r=Mu((()=>JSON.parse(r)),{})),("object"!=typeof r||null===r||Array.isArray(r))&&(r={}),Object.assign(Object.assign({},r||{}),t||{})}function Hu(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift():void 0}function Ju(e,t){const r=Object.assign({fbc:"_fbc",fbp:"_fbp"},t),n=Object.entries(r).reduce(((t,[r,n])=>(t[r]=e.getCookie(n),t)),{});return Object.assign(Object.assign({},n),function(e){var t;const r=e.getCookies(),n=null===(t=r._ga)||void 0===t?void 0:t.split(".").slice(-2).join("."),i=Object.entries(r).filter((([e])=>e.startsWith("_ga_"))),o=i.length>0?Object.fromEntries(i.map((([e,t])=>{if("string"!=typeof t)return null;const r=t.split(".");return r.length<3?null:[e.substring(4),r[2]]})).filter((e=>null!==e))):void 0;return n||o?{ga4:{clientId:n,sessionIds:o}}:void 0}(e))}function Gu(e,{domain:t,secure:r}){document.cookie=e+"=;domain="+t+";path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;SameSite="+(r?"None":"Lax")+(r?";secure":"")}const Wu={__anon_id:"__eventn_id",__user_id:"__eventn_uid",__user_traits:"__eventn_id_usr",__group_id:"__group_id",__group_traits:"__group_traits"},Vu=(e,t)=>({setItem(r,n){const i=t(r)||r;if(void 0===n)return void Gu(i,{domain:e,secure:"https:"===window.location.protocol});!function(e,t,{domain:r,secure:n}){document.cookie=e+"="+t+";domain="+r+";path=/;expires="+new Date((new Date).getTime()+15768e7).toUTCString()+";SameSite="+(n?"None":"Lax")+(n?";secure":"")}(i,"object"==typeof n&&null!==n?encodeURIComponent(JSON.stringify(n)):n,{domain:e,secure:"https:"===window.location.protocol})},getItem(e){const r=Hu(t(e)||e);if("__anon_id"===e)return r;if(void 0===r&&"__user_id"===e){const e=gd(Hu(t("__user_traits")||"__eventn_id_usr"))||{};return e.internal_id||e.user_id||e.id||e.userId}return gd(r)},removeItem(r){Gu(t(r)||r,{domain:e,secure:"https:"===window.location.protocol})},reset(){for(const r of Object.keys(Wu))Gu(t(r)||r,{domain:e,secure:"https:"===window.location.protocol})}});function Yu(e){const t=t=>{var r,n,i,o,a;switch(t){case"__anon_id":return(null===(r=e.cookieNames)||void 0===r?void 0:r.anonymousId)||Wu.__anon_id;case"__user_id":return(null===(n=e.cookieNames)||void 0===n?void 0:n.userId)||Wu.__user_id;case"__user_traits":return(null===(i=e.cookieNames)||void 0===i?void 0:i.userTraits)||Wu.__user_traits;case"__group_id":return(null===(o=e.cookieNames)||void 0===o?void 0:o.groupId)||Wu.__group_id;case"__group_traits":return(null===(a=e.cookieNames)||void 0===a?void 0:a.groupTraits)||Wu.__group_traits;default:return t}};return{getCookie(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift():void 0},getCookies(){const e={},t=`; ${document.cookie}`.matchAll(/(\w+)=([^;]+)/g);for(const r of t)e[r[1]]=r[2];return e},documentEncoding:()=>window.document.characterSet,timezoneOffset:()=>(new Date).getTimezoneOffset(),store:()=>Vu(e.cookieDomain||wu(window.location.hostname),t),language:()=>window.navigator.language,pageTitle:()=>window.document.title,pageUrl:()=>window.location.href,referrer:()=>window.document.referrer,screen:()=>({width:window.screen.width,height:window.screen.height,innerWidth:window.innerWidth,innerHeight:window.innerHeight,density:Math.floor(window.devicePixelRatio)}),userAgent:()=>window.navigator.userAgent}}function Ku(e){const t={};return{reset(){Object.keys(t).forEach((e=>delete t[e]))},setItem(r,n){e&&console.log(`[JITSU EMPTY RUNTIME] Set storage item ${r}=${JSON.stringify(n)}`),void 0===n?delete t[r]:t[r]=n},getItem(r){const n=t[r];return e&&console.log(`[JITSU EMPTY RUNTIME] Get storage item ${r}=${JSON.stringify(n)}`),n},removeItem(r){e&&console.log(`[JITSU EMPTY RUNTIME] Get storage item ${r}=${t[r]}`),delete t[r]}}}const Qu=e=>({documentEncoding(){},timezoneOffset(){},getCookie(e){},getCookies:()=>({}),store:()=>Ku(e.debug),language(){},pageTitle(){},pageUrl(){},referrer(){},screen(){},userAgent(){}});function Xu(e,t){return"object"!=typeof t||null===t||"object"!=typeof e||null===e?t:Object.entries(t).reduce(((t,[r,n])=>(t[r]=Xu(e[r],n),t)),e)}function Zu(){return"undefined"!=typeof document&&"undefined"!=typeof window}const ed=/#.*$/;function td(e,t,r,n){var i,o,a,s,l,c,u,d,h,f,p,g,m,v;const y=t.runtime||(Zu()?Yu(t):Qu(t)),b=y.pageUrl(),w=Mu((()=>new URL(b)),void 0),_=w?zu(w.search):{},S=e.properties||{};if("page"===e.type&&(S.url||b)){const e=S.url||b;S.url=e.replace(ed,""),S.path=(E=function(e){const t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(ed,""):"")}(e),0===E.indexOf("//")&&1===E.lastIndexOf("/")?"/":E)}var E;const k=Xu(t.defaultPayloadContext,(null===(i=e.properties)||void 0===i?void 0:i.context)||(null===(o=e.options)||void 0===o?void 0:o.context)||{});null===(a=e.properties)||void 0===a||delete a.context;const x=y.referrer(),P={library:{name:mu,version:gu,env:Zu()?"browser":"node"},consent:(null===(s=t.privacy)||void 0===s?void 0:s.consentCategories)?{categoryPreferences:t.privacy.consentCategories}:void 0,userAgent:null===(l=y.userAgent)||void 0===l?void 0:l.call(y),locale:null===(c=y.language)||void 0===c?void 0:c.call(y),screen:null===(u=y.screen)||void 0===u?void 0:u.call(y),ip:null===(d=null==y?void 0:y.ip)||void 0===d?void 0:d.call(y),traits:"identify"!=e.type&&"group"!=e.type?Object.assign(Object.assign({},Bu(r)||{}),(null===(h=null==e?void 0:e.options)||void 0===h?void 0:h.traits)||{}):void 0,page:{path:S.path||w&&w.pathname,referrer:x,referring_domain:Mu((()=>x&&new URL(x).hostname)),host:w&&w.host,search:S.search||w&&w.search,title:S.title||y.pageTitle(),url:S.url||b,encoding:S.encoding||y.documentEncoding()},clientIds:(null===(f=t.privacy)||void 0===f?void 0:f.disableUserIds)?void 0:Ju(y,t.cookieCapture),campaign:$u(_)},A=Object.assign(Object.assign({},e),{userId:(null===(p=null==e?void 0:e.options)||void 0===p?void 0:p.userId)||(null==e?void 0:e.userId),anonymousId:(null===(g=null==e?void 0:e.options)||void 0===g?void 0:g.anonymousId)||(null==e?void 0:e.anonymousId),groupId:(null===(m=null==e?void 0:e.options)||void 0===m?void 0:m.groupId)||r.getItem("__group_id"),timestamp:(new Date).toISOString(),sentAt:(new Date).toISOString(),messageId:dd(S.path||w&&w.pathname),writeKey:nd(t.writeKey),context:Xu(P,k)});return delete A.meta,delete A.options,(null===(v=t.privacy)||void 0===v?void 0:v.disableUserIds)&&(delete A.userId,delete A.anonymousId,delete A.context.traits,delete A.groupId),A}function rd(e){const t=Object.keys(e);return 1===t.length&&"__diff"===t[0]}function nd(e){if(e){const[t,r]=e.split(":",2);return r?`${t}:***`:"***"}return e}function id(e){const t=e.errorPolicy||"log";return"function"==typeof t?t:"rethrow"===t?(e,...t)=>{throw new Error(e)}:(e,...t)=>{console.error(e,...t)}}function od(e,t,r,n,i){return Fu(this,void 0,void 0,(function*(){var o,a;const s=!!r.s2s,l=r.debug?{"X-Enable-Debug":"true"}:{},c=td(t,r,i);if(r.echoEvents)return void console.log(`[JITSU DEBUG] sending '${e}' event:`,c);const u=s?`${r.host}/api/s/s2s/${e}`:`${r.host}/api/s/${e}`,d=r.fetch||globalThis.fetch;if(!d)throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");const h=r.fetchTimeoutMs?new AbortController:void 0,f=r.fetchTimeoutMs?setTimeout((()=>{h.abort()}),r.fetchTimeoutMs):void 0,p=r.writeKey?{"X-Write-Key":r.writeKey}:{},g=void 0===(null===(o=r.privacy)||void 0===o?void 0:o.ipPolicy)||"keep"===(null===(a=r.privacy)||void 0===a?void 0:a.ipPolicy)?{}:{"X-IP-Policy":r.privacy.ipPolicy};let m,v,y;try{m=yield d(u,{method:"POST",headers:Object.assign(Object.assign(Object.assign({"Content-Type":"application/json"},p),l),g),body:JSON.stringify(c),signal:null==h?void 0:h.signal}),f&&clearTimeout(f)}catch(e){return id(r)(`Call to ${u} failed with error ${e.message}`),Promise.resolve()}try{v=yield m.text()}catch(e){console.warn(`Can't read response text from ${u} (status - ${m.status} ${m.statusText}): ${null==e?void 0:e.message}`)}if(r.debug&&console.log(`[JITSU DEBUG] ${u} replied ${m.status}: ${v}. Original payload:\n${JSON.stringify(c,null,2)}`),!m.ok)return id(r)(`Call to ${u} failed with error: ${m.status} - ${m.statusText}: ${v}`),Promise.resolve();try{y=JSON.parse(v)}catch(e){return id(r)(`Can't parse JSON: ${v}: ${null==e?void 0:e.message}`),Promise.resolve()}if(y.destinations&&y.destinations.length>0)if(r.s2s)console.warn(`[JITSU] ${t.type} responded with list of ${y.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`,r.debug?JSON.stringify(y.destinations,null,2):void 0);else if(Zu())return r.debug&&console.log("[JITSU] Processing device destinations: ",JSON.stringify(y.destinations,null,2)),function(e,t,r,n,i){return Fu(this,void 0,void 0,(function*(){const o=[];for(const a of e){let e=[r];if(a.newEvents)try{e=a.newEvents.map((e=>"same"===e?r:rd(e)?Lu.patch(r,e.__diff):e))}catch(e){console.error(`[JITSU] Error applying '${a.id}' changes to event: ${null==e?void 0:e.message}`,e)}const s=Object.assign(Object.assign({},a.credentials),a.options);if("internal-plugin"===a.deviceOptions.type){const t=pu[a.deviceOptions.name];if(t)for(const r of e)try{o.push(t.handle(Object.assign(Object.assign({},s),{debug:n}),r))}catch(e){console.warn(`[JITSU] Error processing event with internal plugin '${a.deviceOptions.name}': ${null==e?void 0:e.message}`,e)}else console.warn(`[JITSU] Unknown internal plugin '${a.deviceOptions.name}' for destination '${a.id}'`)}else if("analytics-plugin"===a.deviceOptions.type){yield Gc(a.deviceOptions.packageCdn);const r=window[a.deviceOptions.moduleVarName];if(r){let o;try{o=("function"==typeof r?r:r.init)(s)}catch(e){console.warn(`[JITSU] Error creating plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}`,e)}try{n&&console.log(`[JITSU] Plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}' initialized with config:`,o.config),o.initialize({config:o.config,instance:i})}catch(e){console.warn(`[JITSU] Error initializing plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}. Config: ${JSON.stringify(o.config)}`,e);continue}if(o[t])for(const r of e)try{o[t]({payload:r,config:o.config,instance:i})}catch(e){console.warn(`[JITSU] Error processing ${t}() with plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}`,e)}}else console.warn(`[JITSU] Broken plugin '${a.deviceOptions.packageCdn}' for destination '${a.id}' - it doesn't export '${a.deviceOptions.moduleVarName}' variable`)}}}))}(y.destinations,e,c,!!r.debug,n);return c}))}const ad=["$doNotSend"];function sd(e){const t=Object.assign({},e);for(const e of ad)delete t[e];return t}const ld=(e={},t)=>(qu(e,e),{name:"jitsu",config:e,initialize:e=>Fu(void 0,void 0,void 0,(function*(){const{config:t}=e;if(t.debug&&console.debug("[JITSU DEBUG] Initializing Jitsu plugin with config: ",JSON.stringify(t,null,2)),!t.host&&!t.echoEvents)throw new Error("Please specify host variable in jitsu plugin initialization, or set echoEvents to true");if(function(e){if(e){const[,r]=e.split(":",2);if(!r&&(25!==(t=e).length||"c"!==t.charAt(0)))throw new Error(`Legacy write key detected - ${e}! This format doesn't work anymore, it should be 'key:secret'. Please download a new key from Jitsu UI`)}var t}(t.writeKey),t.idEndpoint){if(!Zu())return void console.error("[JITSU] 'idEndpoint' option can be used only in browser environment");try{const e=t.fetch||globalThis.fetch,r=new AbortController;setTimeout((()=>r.abort()),1e3);const n=t.cookieDomain||wu(window.location.hostname),i=yield e(t.idEndpoint+"?domain="+encodeURIComponent(n),{credentials:"include",signal:r.signal});i.ok?t.debug&&console.log(`[JITSU DEBUG] Fetch idEndpoint: ${i.status}`):console.error(`[JITSU] Can't fetch idEndpoint: ${i.status} - ${i.statusText}`)}catch(e){console.error(`[JITSU] Can't fetch idEndpoint: ${e.message}`)}}})),page:e=>{var r;const{payload:n,config:i,instance:o}=e;if(!(null===(r=i.privacy)||void 0===r?void 0:r.dontSend))return od("page",n,i,o,t)},track:e=>{var r;const{payload:n,config:i,instance:o}=e;if(!(null===(r=i.privacy)||void 0===r?void 0:r.dontSend))return od("track",n,i,o,t)},identify:e=>{var r,n,i;const{payload:o,config:a,instance:s}=e;if((null===(r=a.privacy)||void 0===r?void 0:r.dontSend)||(null===(n=a.privacy)||void 0===n?void 0:n.disableUserIds))return;t.setItem("__user_id",o.userId);const l=null===(i=o.traits)||void 0===i?void 0:i.$doNotSend;return o.traits&&"object"==typeof o.traits&&(o.traits=sd(o.traits),t.setItem("__user_traits",o.traits)),l?Promise.resolve():od("identify",o,a,s,t)},reset:e=>{const{config:r,instance:n}=e;t.reset(),r.debug&&console.log("[JITSU DEBUG] Resetting Jitsu plugin storage")},methods:{configure(r){var n,i,o,a;const s=(null===(n=e.privacy)||void 0===n?void 0:n.disableUserIds)||(null===(i=e.privacy)||void 0===i?void 0:i.dontSend);qu(e,r);if(!((null===(o=e.privacy)||void 0===o?void 0:o.disableUserIds)||(null===(a=e.privacy)||void 0===a?void 0:a.dontSend))&&s){e.debug&&console.log("[JITSU] Enabling Anonymous ID. Generating new Id.");const r=this.instance,n=hd(),i=r.user();i&&(i.anonymousId=n),t.setItem("__anon_id",n),r.setAnonymousId(n)}},group(r,n,i,o){var a,s;if((null===(a=e.privacy)||void 0===a?void 0:a.dontSend)||(null===(s=e.privacy)||void 0===s?void 0:s.disableUserIds))return;"number"==typeof r&&(r+="");const l=this.instance,c=l.user(),u=(null==i?void 0:i.userId)||(null==c?void 0:c.userId),d=(null==i?void 0:i.anonymousId)||(null==c?void 0:c.anonymousId)||t.getItem("__anon_id");t.setItem("__group_id",r);const h=null==n?void 0:n.$doNotSend;return n&&"object"==typeof n&&(n=sd(n),t.setItem("__group_traits",n)),h?Promise.resolve():od("group",Object.assign(Object.assign({type:"group",groupId:r,traits:n},d?{anonymousId:d}:{}),u?{userId:u}:{}),e,l,t)}}});let cd=0;function ud(){var e;cd=(cd+1)%Number.MAX_SAFE_INTEGER;const t=Date.now()%2147483647;return(Zu()&&(null===(e=null===window||void 0===window?void 0:window.performance)||void 0===e?void 0:e.now())||t)+cd}function dd(e=""){const t=Date.now();return(Math.random()*t*fd(null!=e?e:"",ud())%Number.MAX_SAFE_INTEGER).toString(36)+(Math.random()*t*fd(null!=e?e:"",ud())%Number.MAX_SAFE_INTEGER).toString(36)}function hd(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],i=15&r;e+="-"==n||"4"==n?n:("x"==n?i:3&i|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}function fd(e,t=0){let r=3735928559^t,n=1103547991^t;for(let t,i=0;i<e.length;i++)t=e.charCodeAt(i),r=Math.imul(r^t,2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&n)+(r>>>0)}var pd=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};function gd(e){let t=e;0===(null==e?void 0:e.indexOf("%7B%22"))&&(t=decodeURIComponent(e));try{if(t=JSON.parse(t),"true"===t)return!0;if("false"===t)return!1;if("object"==typeof t)return t;parseFloat(t)===t&&(t=parseFloat(t))}catch(e){}if(null!==t&&""!==t)return t}function md(e,t,r=[]){var n,i,o;const a={},s=t=>({setItem(r,n){var i,o;(null===(i=e.privacy)||void 0===i?void 0:i.dontSend)||(null===(o=e.privacy)||void 0===o?void 0:o.disableUserIds)||(e.debug&&console.log(`[JITSU DEBUG] Caching storage setItem: ${r}=${n}`),a[r]=n,t.setItem(r,n))},getItem(r){var n,i;if((null===(n=e.privacy)||void 0===n?void 0:n.dontSend)||(null===(i=e.privacy)||void 0===i?void 0:i.disableUserIds))return;const o=a[r]||t.getItem(r);return e.debug&&console.log(`[JITSU DEBUG] Caching storage getItem: ${r}=${o}. Evicted from cache: ${!a[r]}`),o},reset(){for(const e of[...Object.keys(a)])delete a[e];t.reset()},removeItem(r){e.debug&&console.log(`[JITSU DEBUG] Caching storage removeItem: ${r}`),delete a[r],t.removeItem(r)}}),l=s((null===(n=t.store)||void 0===n?void 0:n.call(t))||Ku(e.debug)),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return mc(Jc(Jc({},{storage:Mc}),e))}({debug:!!e.debug,storage:l,plugins:[ld(e,l),...r]}),u=Object.assign(Object.assign({},c),{page:(...e)=>2===e.length&&"string"==typeof e[0]&&"object"==typeof e[1]?c.page(Object.assign({name:e[0]},e[1])):c.page(...e),identify:(...e)=>{e[0]&&"object"!=typeof e[0]&&"string"!=typeof e[0]&&(e[0]=e[0]+"");const t=c.storage,r=s(t);return"string"==typeof e[0]?r.setItem("__user_id",e[0]):"object"==typeof e[0]&&r.setItem("__user_traits",e[0]),2===e.length&&"object"==typeof e[1]&&r.setItem("__user_traits",e[1]),c.identify(...e)},setContextProperty(t,r){e.debug&&console.log(`[JITSU DEBUG] Setting context property '${t}':${JSON.stringify(r)}`),e.defaultPayloadContext?e.defaultPayloadContext[t]=r:e.defaultPayloadContext={[t]:r}},getContextProperty(t){var r;return e.debug&&console.log(`[JITSU DEBUG] Getting context property '${t}'`),null===(r=e.defaultPayloadContext)||void 0===r?void 0:r[t]},setAnonymousId:t=>{e.debug&&console.log("[JITSU DEBUG] Setting anonymous id to "+t),l.setItem("__anon_id",t);const r=c.user();r&&(r.anonymousId=t),c.setAnonymousId(t)},reset(){return pd(this,void 0,void 0,(function*(){e.debug&&console.log("[JITSU DEBUG] Called reset(). Storage state",JSON.stringify(c.user())),l.reset(),yield c.reset(),this.setAnonymousId(hd()),e.debug&&console.log("[JITSU DEBUG] User state after reset",JSON.stringify(c.user()))}))},configure(t){return pd(this,void 0,void 0,(function*(){var r,n;e.debug&&console.log("[JITSU DEBUG] Update Jitsu config with",JSON.stringify(t)),((null===(r=t.privacy)||void 0===r?void 0:r.disableUserIds)||(null===(n=t.privacy)||void 0===n?void 0:n.dontSend))&&l.reset();for(const e of Object.values(c.plugins))"function"==typeof e.configure&&e.configure(t)}))},group(e,t,r,n){return pd(this,void 0,void 0,(function*(){const i=[];for(const o of Object.values(c.plugins))o.group&&i.push(yield o.group(e,t,r,n));return i[0]}))}});return((null===(i=e.privacy)||void 0===i?void 0:i.disableUserIds)||(null===(o=e.privacy)||void 0===o?void 0:o.dontSend))&&l.reset(),u}function vd(e){const t=function(e){var t,r;return Object.assign(Object.assign({},e),{host:0!==(null!==(t=e.host)&&void 0!==t?t:"").indexOf("https://")&&0!==(null!==(r=e.host)&&void 0!==r?r:"").indexOf("http://")?`https://${e.host}`:e.host})}(e),r=Zu();return md(t,t.runtime||(r?Yu(t):Qu(t)))}class yd{constructor(e){this.item=e[0]}toSegment(){return{event:"Product Added",properties:{cart_id:this.item.cart_id?.toString(),product_id:this.item.id?.toString(),category:this.item.category,currency:Salla.config.currency()?.code,name:this.item.name,brand:this.item.brand,variant:this.item.variant?.toString(),price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}}static shouldSend(){return"customer.wishlist"!==salla.config.get("page.slug")}}class bd{constructor(e){this.product=e[0]}toSegment(){return{event:"Product Viewed",properties:{product_id:this.product.id?.toString(),category:this.product.category,name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:this.product.quantity,currency:this.product.currency,coupon:this.product.coupon,position:this.product.position,value:this.product.value,sku:this.product.sku,url:this.product.url,image_url:this.product.image_url}}}}class wd{constructor(e){this.cart=e[0]}toSegment(){return{event:"Cart Viewed",properties:{cart_id:this.cart.cart_id?.toString(),products:this.cart.products.map((e=>({product_id:e.id?.toString(),name:e.name,price:e.price,category:e.category,sku:e.sku,position:e.position,url:e.url,image_url:e.image_url,brand:e.brand,currency:Salla.config.currency()?.code,variant:e.variant,coupon:e.coupon,quantity:e.quantity})))}}}}class _d{constructor(e){const t=e?.nextPage;this.listId=salla.config.get("page.slug"),Salla.config.get("page.id")&&(this.listId+=`_${salla.config.get("page.id")}`),this.sorts=null;try{if(t){const e=new URL(t).searchParams.get("sort");e&&(this.sorts=[{type:"sort",value:e}])}e.source&&(this.listId=`${this.listId}_${e.source}`),e.sourceValue&&(this.listId=`${this.listId}_${Array.isArray(e.sourceValue)?e.sourceValue.join("_"):e.sourceValue}`)}catch(e){salla.logger.error(e)}this.products=e?.data}toSegment(){return{event:"Product List Viewed",properties:{list_id:this.listId,category:salla.config.get("page.title"),sorts:this.sorts,products:this.products.map((e=>({product_id:e.id,category:e.category?.name,currency:Salla.config.currency()?.code,name:e.name,brand:e.brand?.name,variant:e.variant?.toString(),coupon:e.coupon?.toString(),price:e.price,quantity:Number(e.quantity),sku:e.sku,position:0,url:e.url,image_url:e.image?.url})))}}}static shouldSend(e){return!(e?.nextPage||"").includes("filters")&&!["index","customer.wishlist"].includes(salla.config.get("page.slug"))}}class Sd{constructor(e){this.query=e}toSegment(){return{event:"Products Searched",properties:{query:this.query}}}}class Ed{constructor(){this.user=JSON.parse(localStorage.getItem("user"))}toSegment(){return{event:"Signed In",properties:{first_name:this.user?.first_name,last_name:this.user?.last_name,type:this.user?.type,mobile:this.user?.mobile,email:this.user?.email}}}static shouldSend(){return"user"===Salla.config.get("user.type")?!Salla.analytics.history.find((({eventName:e})=>"Signed In"===e)):(Salla.profile.event.onInfoFetched((()=>Salla.event.emit("Signed In"))),!1)}}class kd extends Ed{toSegment(){const e=super.toSegment();return{event:"Signed Up",properties:e?.properties}}static shouldSend(){return"user"===Salla.config.get("user.type")||(Salla.profile.event.onInfoFetched((()=>Salla.event.emit("Signed Up"))),!1)}}class xd{toSegment(){return{event:"Signed Out",properties:{}}}}class Pd{constructor(e){this.item=e[0]}toSegment(){return{event:"Product Removed",properties:{cart_id:this.item?.cart_id?.toString(),product_id:this.item?.id?.toString(),category:this.item?.category,currency:Salla.config.currency()?.code,name:this.item?.name,brand:this.item?.brand,variant:this.item?.variant,price:this.item?.price,quantity:this.item?.quantity,sku:this.item?.sku,coupon:this.item?.coupon,position:this.item?.position,url:this.item?.url,image_url:this.item?.image_url}}}}class Ad{constructor(e){this.product=e.data.product}toSegment(){return{event:"Product Added to Wishlist",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:this.product.id?.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,position:Number(this.product.position||0),url:this.product.url,image_url:this.product?.image||null,category:this.product.category,currency:Salla.config.currency()?.code,brand:this.product.brand}}}}class Id{constructor(e){this.product=e.data.product}toSegment(){return{event:"Product Removed from Wishlist",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:this.product.id?.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,coupon:this.product.coupon||null,position:Number(this.product.position||0),currency:Salla.config.currency()?.code,url:this.product.url,image_url:this.product?.image||null,category:this.product.category,brand:this.product.brand}}}}class Od{constructor(e){this.details=e[0]}toSegment(){return{event:"Order Completed",properties:this.details}}}class Td{constructor(e){this.item=e[0]}toSegment(){return{event:"Wishlist Product Added to Cart",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),cart_id:this.item.cart_id?.toString(),product_id:this.item.id?.toString(),category:this.item.category,name:this.item.name,brand:this.item.brand,variant:this.item.variant,price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}}static shouldSend(){return"customer.wishlist"===salla.config.get("page.slug")}}class jd{constructor(e){this.data=e}toSegment(){const e=Salla.analytics.history.find((({eventName:e})=>"Product Viewed"===e))?.payload||{};return e.share_via=this.data.share_via,{event:"Product Shared",properties:e}}static shouldSend(){return"product.single"===salla.config.get("page.slug")}}class Cd{constructor(e){this.details=e}toSegment(){return{event:"Product Reviewed",properties:this.details}}static registerEvent(){salla.event.rating.onProductsRated((function(e,t){const{products:r,order_id:n}=t;Object.values(r).forEach((e=>{Salla.event.emit("Product Reviewed",{product_id:e.product_id?.toString(),review_id:n?.toString(),review_body:e.comment,rating:e.rating})}))}))}}class Rd{constructor(e){this.promotion=e[0]}toSegment(){return{event:"Promotion Viewed",properties:{promotion_id:this.promotion.id?.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}}}class Fd{constructor(e){this.promotion=e[0]}toSegment(){return{event:"Promotion Clicked",properties:{promotion_id:this.promotion.id?.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}}}class Ld{constructor(e){this.transaction=e}getCartId(){return"cart"===salla.config.get("page.slug")?salla.config.get("page.id")?.toString():this.transaction?.data?.cart?.id?.toString()||""}toSegment(){return{event:"Coupon Applied",properties:{cart_id:this.getCartId(),coupon_name:this.transaction?.data?.cart?.coupon||"",discount:this.transaction?.data?.cart?.discount||0,currency:salla.config.get("user.currency")||""}}}}class Ud{constructor(e){this.transaction=e}getCartId(){return"cart"===salla.config.get("page.slug")?salla.config.get("page.id")?.toString():""}getCouponCode(){try{const e=this.transaction.response?.config?.data;return e?JSON.parse(e)?.coupon:""}catch{return""}}toSegment(){return{event:"Coupon Denied",properties:{cart_id:this.getCartId(),coupon_name:this.getCouponCode(),reason:this.transaction.response?.data?.error?.message||"Unknown error"}}}}class Nd{constructor(e){this.transaction=e}getCartId(){return"cart"===salla.config.get("page.slug")?salla.config.get("page.id")?.toString():this.transaction?.data?.cart?.id?.toString()||""}toSegment(){return{event:"Coupon Removed",properties:{cart_id:this.getCartId(),coupon_name:this.transaction?.coupon||"",discount:this.transaction?.data?.cart?.discount||0,currency:salla.config.get("user.currency")||""}}}}class qd{static user={};constructor(e){this.details=e?.data}toSegment(){const e=["first_name","last_name","birthday","gender"].filter((e=>qd.user[e]!==this.details?.[e]&&(void 0!==qd.user[e]||void 0!==this.details?.[e])));return qd.setUser(this.details),{event:"User Profile Updated",properties:{updated_fields:e}}}static registerEvent(){Salla.onReady((()=>{salla.url.is_page("customer.profile")&&qd.setUser(Salla.config.get("user"))}))}static setUser(e){qd.user={first_name:e?.first_name,last_name:e?.last_name,gender:e?.gender,birthday:e?.birthday,avatar:e?.avatar}}static shouldSend(){return"user"===Salla.config.get("user.type")}}class zd extends _d{constructor(e){super(e);const t=e?.nextPage||"";this.filters=this.extractFilters(t)}extractFilters(e){if(!e)return null;try{const t=new URL(e),r=[];return Array.from(t.searchParams.entries()).forEach((([e,t])=>{if(e.startsWith("filters[")){const n=e.match(/^filters\[(.*?)\]/),i=n?n[1]:e;r.push({type:i,value:t})}})),r.length>0?r:null}catch(e){return console.warn("Error extracting filters from URL:",e),null}}toSegment(){const e=super.toSegment();return{event:"Product List Filtered",properties:{...e?.properties,filters:this.filters}}}static shouldSend(e){return(e?.nextPage||"").includes("filters")}}class Dd{constructor(e){this.cart=e}toSegment(){return{event:"Cart Updated",properties:{cart_id:this.cart.id?.toString(),value:this.cart.total,revenue:this.cart.sub_total,tax:this.cart.tax_amount,discount:this.cart.total_discount,shipping:this.cart.real_shipping_cost,currency:Salla.config.currency()?.code,affiliation:Salla.storage.getWithTTL("s-utms")?.["s-utm-source"],products:this.cart.items?.map((e=>({product_id:e.product_id?.toString(),name:e.product_name,price:e.product_price,category:e.category?.toString(),sku:e.product_sku?.toString(),position:e.position,url:e.url,image_url:e.product_image,brand:e.brand?.toString(),currency:Salla.config.currency()?.code,variant:e.variant?.toString(),coupon:this.cart.coupon,quantity:e.quantity})))}}}static shouldSend(){return"cart"===salla.config.get("page.slug")}}class $d{constructor(e){this.scope=e.data}toSegment(){return{event:"Market Selected",properties:{...this.getScope(this.scope),prev:this.getScope(Salla.config.get("store.scope"))}}}getScope(e){return e=e||{},{id:e.id?.toString(),country:this.getScopeAttribute(e,"countries"),currency:this.getScopeAttribute(e,"currencies"),locale:this.getScopeAttribute(e,"languages")}}getScopeAttribute(e,t){return e=e[t],Array.isArray(e)?e[0]:e}}class Md{static events={"Order Completed":[Od],"Product Added":[yd,Td],"Product Removed":[Pd],"Product Viewed":[bd],"Product Added to Wishlist":[Ad],"Product Removed from Wishlist":[Id],"Cart Viewed":[wd],"Products Searched":[Sd],"Product List Viewed":[_d],"Product List Filtered":[zd],"Signed Up":[kd],"Signed In":[Ed],"Signed Out":[xd],"Product Reviewed":[Cd],"Product Shared":[jd],"Promotion Viewed":[Rd],"Promotion Clicked":[Fd],"Coupon Applied":[Ld],"Coupon Removed":[Nd],"Coupon Denied":[Ud],"User Profile Updated":[qd],"Cart Updated":[Dd],"Market Selected":[$d]};static registerEvents(){Object.values(this.events).forEach((e=>{e.forEach((e=>{"function"==typeof e.registerEvent&&e.registerEvent()}))}))}static transform(e,t){try{const r=this.events[e]||[];for(const e of r){if(!e||"function"==typeof e.shouldSend&&!e.shouldSend(t))continue;const r=new e(t).toSegment();return{event:r.event,properties:r.properties}}return null}catch(e){return console.error("Failed to transform event:",e),null}}}return Dr.onInitiated=e=>salla.event.once("twilight::initiated",e),Dr.onReady=Dr.onReady||function(e){return new Promise((function(t){return"ready"===salla.status?t(e?e(salla.config.all()):salla.config.all()):Dr.onInitiated((r=>t(e?e(r):r)))}))},Dr.status="loading",Dr.notify=Hr,Dr.lang=new class extends Pn{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){return new Promise((t=>{if(this.translationsLoaded)return t(e?e():null);Salla.event.once("languages::translations.loaded",(()=>t(e?e():null)))}))}loadStoreTranslations(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get(`s_translations.${this.hash}`),this.messages&&(this.translationsLoaded=!0)&&super.setMessages(this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get(`languages/assets/${this.hash}.js`)):this.loadScript("https://cdn.salla.network/js/translations.js",!1)}setMessages(e){super.setMessages(e),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(e,t=!0){let r=document.createElement("script");r.src=e,r.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);r.onerror()},r.onerror=()=>{if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),this.loadScript("https://cdn.salla.network/js/translations.js",!1);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.")},document.head.appendChild(r)}getWithDefault(e,t,r,n){let i=this.get(e,r,n);return i!==e?i:t}get(e,t,r){let n=e;(window.translations||this.translationsLoaded)&&(n="trans."+e);let i=super.get(n,t,r);return i!==n?i:super.get(n,t,"en").replace(n,e)}set(e,t){return salla.helpers.setNested(this.messages[`${this.getLocale()}.trans`],e,t),this}add(e,t){return Object.entries(t).forEach((t=>salla.helpers.setNested(this.messages[t[0]+".trans"],e,t[1]))),this}addBulk(e){return Object.entries(e).forEach((([e,t])=>{this.add(e,t)})),this}},Dr.form=new class{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name||"submit"===t?.type){if(t.preventDefault(),"FORM"!==t.target?.tagName)return Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((()=>{throw"Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===t?.submitter?.parentElement?.tagName&&t.submitter.parentElement.load(),r=t.target.getElementSallaData(),salla.log("Data from element",r)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.api.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let n=e.split("."),i=n.splice(-1);return await salla.call(n.join("."))[i](r).finally((()=>t?.submitter?.parentElement?.stop())).catch((e=>{throw salla.logger.warn(e),e}))}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){return t?.currentTarget?"FORM"!==t?.currentTarget?.tagName||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${e}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${e}' without event!`),!1)}getPossibleValue(e,t,r=!1){if(!e)return;if("object"!=typeof e)return e;let n;for(let r=0;r<t.length&&!(n=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[r])));r++);return n=n||e,"object"!=typeof n||r?n:void 0}},Dr.infiniteScroll=new class extends Jr{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},this.instances=[]}initiate(e,t,r,n=!1){n?((r=r||{}).fetchOptions={...this.fetchOptions,...r.fetchOptions||{}},r.responseBody="json"):r=this.getCustomOptions(t,r);let i="string"!=typeof e?e:document.querySelector(e),o=r.path;if(!i||!o||"string"==typeof o&&!document.querySelector(o))return void Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let a=new En(i,r);return a.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),a.on("request",Salla.infiniteScroll.event.request),a.on("load",Salla.infiniteScroll.event.load),a.on("append",Salla.infiniteScroll.event.append),a.on("error",Salla.infiniteScroll.event.error),a.on("last",Salla.infiniteScroll.event.last),a.on("history",Salla.infiniteScroll.event.history),this.instances.push(a),a}getCustomOptions(e,t){return(t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t}loadNextPage(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage()}destroy(e){("string"!=typeof e?e:document.querySelector(e)).destroy()}}(void 0,salla.event.infiniteScroll),Dr.api=new class extends ps{constructor(){super(),this.auth=new Tn,this.cart=new In,this.loyalty=new On,this.order=new jn,this.rating=new Nn,this.product=new Cn,this.profile=new Rn,this.comment=new Fn,this.currency=new Ln,this.document=new Un,this.wishlist=new qn,this.scope=new zn,this.booking=new Dn,this.landing=new $n,this.notifications=new Mn,this.component=new gs,this.advertisement=new ms,this.navigation=new vs,this.metadata=new ys}beaconRequest(e,t={}){if(!window.navigator?.sendBeacon)return fetch(e,t);const r="string"==typeof t?.body?t?.body:JSON.stringify(t?.body||{}),n=new Blob([r],{type:"application/json"});return Salla.log(`Beacon payload size: ${n.size} bytes (~${(n.size/1024).toFixed(2)} KB)`),navigator.sendBeacon(e,n),Promise.resolve(new Response('{"status":"sent_via_beacon"}',{status:200,headers:{"Content-Type":"application/json"}}))}},Dr.sso=new class{constructor(){Salla.onReady((()=>this.init()))}init(){if(salla.config.get("store.features",[]).includes("sso-login")){if(window.location.hostname.includes("salla"))return salla.log("SSO is not supported yet for stores without custom domain.");salla.auth.event.onLoggedOut((()=>new Promise((e=>{const t=document.createElement("iframe");t.style.display="none",t.src=salla.url.get("sso/logout"),document.body.appendChild(t),t.onload=()=>{document.body.removeChild(t),e()}})))),document.querySelector("salla-login-modal")?.remove(),Salla.event.removeAllListeners("login::open"),Salla.event.prependListener("login::open",(()=>this.redirect())),window.addEventListener("mini-checkout::before-init",(e=>{Salla.config.isUser()||(e.preventDefault(),this.redirect())}))}}redirect(){const e=window.location.pathname+window.location.search,t=`${window.location.origin}/sso/login?intended_to=${encodeURIComponent(e)}`;return console.log("Redirecting to:",t),window.location.href=t,!0}},Dr.intend=new class{constructor(){Salla.onReady((()=>this.init()))}init(){if(Salla.config.isUser())return;const e=new URLSearchParams(window.location.search);if(e.has("intended_to"))try{const t=new URL(e.get("intended_to"));if(t.hostname!==window.location.hostname)return;return this.handleAfterLoginEvent(t)}catch(e){return void console.warn("Invalid URL provided in intended_to parameter")}}handleAfterLoginEvent(e){let t="intend::user.logged.in";Salla.event.on(t,(()=>window.location=e)),Salla.api.auth.setAfterLoginEvent(t),Salla.api.auth.setCanRedirect(!1),Salla.event.on("salla-login::ready",(()=>Salla.event.emit("login::open",{withoutReload:!0})))}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing","metadata"].forEach((e=>Dr[e]=new Jr(Dr.api[e],Dr.event[e]))),Dr.call=e=>{let t=Dr,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},Dr.analytics=new class{constructor(){this.history=[],this.customTrackers=[],this.mappedEvents={"wishlist::added":"Product Added to Wishlist","wishlist::removed":"Product Removed from Wishlist","salla-products-list::products.fetched":["Product List Viewed","Product List Filtered"],"auth::registered":"Signed Up","auth::logged.in":"Signed In","auth::logged.out":"Signed Out","share-element":"Product Shared","promotion::viewed":"Promotion Viewed","promotion::clicked":"Promotion Clicked","cart::coupon.added":"Coupon Applied","cart::coupon.deleted":"Coupon Removed","cart::coupon.addition.failed":"Coupon Denied","profile::updated":"User Profile Updated","cart::updated":"Cart Updated","scope::changed":"Market Selected"},Salla.event.onAny(((e,t)=>{try{if(Object.keys(this.mappedEvents).includes(e)){const r=this.mappedEvents[e];return void(Array.isArray(r)?r:[r]).forEach((e=>Salla.event.emit(e,t)))}if(!Salla.config.get("jitsu.events",[]).includes(e))return;const r=Md.transform(e,t);r&&this.track(r.event,r.properties)}catch(e){Salla.log("Error in analytics event handling:",e)}})),this.debugAnalytics=vd({host:"https://st.salla.dev",writeKey:"bbLD6Xqr1OKsDJfxZBCy7SJN1RIsrkBp:WEa99iY220v9qX7KiuAlML9ldSFJKW2p",fetch:this.customFetch}),this.debugAnalytics.setContextProperty("library",{twilight:Salla.versions}),Salla.event.on("twilight::init",(e=>{const{host:t,key:r}=e?.jitsu||{};this.jitsuAnalytics=null,t&&r?(Md.registerEvents(),this.jitsuAnalytics=vd({host:t,writeKey:r}),this.setContext("store_id",e.store?.id),this.setContext("version",e.jitsu?.version),this.setContext("library",{twilight:Salla.versions}),e.jitsu?.context?.extra&&this.setExtraContext(e.jitsu.context.extra),e.store?.scope?.id&&this.setContext("scope",e.store?.scope),"user"===e?.user?.type&&this.setContext("traits",this.getFormattedUser(e.user)),this.registerTracker({name:"DefaultSallaTracker",track:(e,t)=>this.jitsuAnalytics.track(e,t),page:e=>this.jitsuAnalytics.page(e)})):salla.log("Jitsu configuration is missing. Analytics will not be tracked.")})),Salla.onReady((()=>{const e={name:Salla.config.get("page.slug",""),id:Salla.config.get("page.id","")?.toString()};this.setContext("page",e),this.page(e)}))}setExtraContext(e){e?.headers?.["s-app-os"]&&(this.setContext("app",{version:e.headers["s-app-os-version"],app_release_tag:e.headers["s-app-version"],platform:e.headers["s-app-os"].toLowerCase()}),delete e.headers["s-app-os"],delete e.headers["s-app-os-version"],delete e.headers["s-app-version"],delete e.headers["s-source"]),this.setContext("system",e)}setContext(e,t){this.jitsuAnalytics?.setContextProperty(e,t),this.debugAnalytics.setContextProperty(e,t)}customFetch(e,t){return Salla.api.beaconRequest(`${e}?writekey=${t?.headers?.["X-Write-Key"]}`,t)}track(e,t={}){t=this.finalPayload(t),this.history.push({action:"track",eventName:e,payload:t}),this.pushEventToCustomTrackers("track",e,t)}log(e,t={}){return this.debugAnalytics?.track(e,t).catch((e=>(salla.log("Error tracking event:",e),Promise.reject(e))))}page(e={}){(e=this.finalPayload(e)).id=(e.id||Salla.config.get("page.id",""))?.toString(),e.name=e.name||Salla.config.get("page.slug"),e.keywords=e.keywords||document.querySelector("meta[name=keywords]")?.content,e.referrer=e.referrer||document.referrer,this.history.push({action:"page",payload:e}),this.pushEventToCustomTrackers("page",e)}finalPayload(e={}){const t=Salla.storage.getWithTTL("s-utms");if(t){const{"s-utm-campaign":e,"s-utm-source":r,"s-utm-medium":n,"s-utm-term":i,"s-utm-content":o,"s-utm-referrer":a}=t;Salla.analytics?.analytics?.setContextProperty("campaign",{name:e,source:r,medium:n,term:i,content:o,referrer:a})}return{...e}}registerTracker(e){"object"==typeof e?"string"==typeof e.name&&e.name?"function"==typeof e.track?"function"==typeof e.page?this.customTrackers.find((t=>t.name===e.name))?Salla.log("tracker with the same name already exists!"):(this.customTrackers.push(e),this.history.forEach((t=>"track"===t.action?e.track(t.eventName,t.payload):"page"===t.action?e.page(t.payload):void 0))):Salla.log("tracker.page most be a function!"):Salla.log("tracker.track most be a function!"):Salla.log("tracker.name most be a string!"):Salla.log('tracker most be an object {name:"tracker name", track: callback, page: callback}!')}pushEventToCustomTrackers(e,t,r={}){const n="page"===e?[t]:[t,r];return Promise.allSettled(this.customTrackers.map((t=>this.pushEventToCustomTracker(t[e],n)))).then((t=>t.filter((e=>"rejected"===e.status)).map((t=>Salla.log("Error on customTracker to send "+e,t)))))}pushEventToCustomTracker(e,t){try{const r=e(...t);return Promise.resolve(r).catch((e=>Promise.reject(e)))}catch(e){return Promise.reject(e)}}getFormattedUser(e){return e.phone=e.mobile,e.country=e.country_code,e.language=e.language_code,e.currency=e.currency_code,e}},Dr.init=e=>new bs(e),new class{constructor(e={}){this.config={WHITELIST:[location.hostname,"salla.com","salla.sa","salla.dev","salla.network","salla.group","mtjr.at"],POLL_INTERVAL_MS:500,WHITELIST_PAGES:["customer.orders.single","page-single","blog.single","blog.index"],...e},this.originalMethods={},this.isInitialized=!1,Salla.onReady((()=>this.init()))}normalizeUrl(e){try{return new URL(e,location.href)}catch{return null}}shouldIgnoreUrl(e){if(!e)return!1;const t="string"==typeof e?e:e.href||String(e),r=t.toLowerCase();if(["tel:","mailto:","javascript:"].some((e=>r.startsWith(e))))return!0;try{const e=new URL(t,location.href).hostname.toLowerCase();return["facebook.com","fb.com","twitter.com","x.com","instagram.com","linkedin.com","youtube.com","youtu.be","tiktok.com","snapchat.com","pinterest.com","whatsapp.com","wa.me","iwtsp.com","telegram.org","t.me","discord.com","discord.gg","reddit.com","tumblr.com","google.com","forms.gle","maps.app.goo.gl","goo.gl","apple.com","smsaexpress.com","aramex.com","aj-ex.com","redboxsa.com","fastcoo-tech.com","express.dhl","najizxpress.net","jtexpress.me","jtexpress-sa.com","tamex.com.sa","aymakan.com.sa","fastlo.com","sls-express.com","logestechs.com","massuul.com","tamara.co","gov.sa","org.sa","stc.com.sa","sa","addtoany.com","wchat.freshchat.com","getbutton.io","heyzine.com","linktr.ee"].some((t=>e===t||e.endsWith("."+t)))}catch{return!1}}isWhitelisted(e){if(!e)return!1;const t=e.hostname.toLowerCase();for(const e of this.config.WHITELIST){const r=String(e||"").toLowerCase().trim();if(r&&(t===r||t.endsWith("."+r)))return!0}return!1}emit(e){try{window.__redirectLogs||(window.__redirectLogs=[]),window.__redirectLogs.push(e);try{Salla.analytics.log("redirect",e)}catch{}}catch{}}logRedirect(e,t,r){if(this.shouldIgnoreUrl(t))return;const n=this.normalizeUrl(t),i=this.normalizeUrl(location.href),o=this.isWhitelisted(n),a={redirect_source:e,redirect_from:i?i.href:String(location.href),redirect_to:n?n.href:String(t),redirect_host:n?n.hostname:null,redirect_referrer:document.referrer||null,page_slug:Salla.config.get("page.slug"),whitelisted:o,stack:r&&r.stack?String(r.stack):void 0,meta:r||void 0};o||this.emit(a)}hookHistoryAPIs(){["pushState","replaceState"].forEach((e=>{try{const t=history[e];"function"==typeof t&&(this.originalMethods[`history.${e}`]=t,history[e]=(...r)=>{try{this.logRedirect(e,r[2]??location.href)}catch{}return t.apply(history,r)})}catch{}})),window.addEventListener("popstate",(()=>{this.logRedirect("popstate",location.href)})),window.addEventListener("hashchange",(()=>{this.logRedirect("hashchange",location.href)}))}hookLocationMethods(){try{const e=location.assign.bind(location);this.originalMethods["location.assign"]=e,location.assign=t=>(this.logRedirect("location.assign",t,{stack:(new Error).stack}),e(t))}catch{}try{const e=location.replace.bind(location);this.originalMethods["location.replace"]=e,location.replace=t=>(this.logRedirect("location.replace",t,{stack:(new Error).stack}),e(t))}catch{}}hookWindowOpen(){try{const e=window.open;this.originalMethods["window.open"]=e,window.open=(t,...r)=>(t&&this.logRedirect("window.open",t,{stack:(new Error).stack}),e.apply(window,[t,...r]))}catch{}}setupEventListeners(){this.handleLinkClick=e=>{const t=e.target&&e.target.closest?e.target.closest("a[href]"):null;if(!t)return;const r=t.getAttribute("href");if(!r||r.startsWith("#"))return;if(this.shouldIgnoreUrl(r))return;const n=t.getAttribute("target")||"_self";setTimeout((()=>{this.logRedirect("link-click",r,{target:n})}),0)},document.addEventListener("click",this.handleLinkClick,!0),this.handleFormSubmit=e=>{const t=e.target,r=t&&t.getAttribute&&t.getAttribute("action")||location.href,n=(t&&t.method?String(t.method):"GET").toUpperCase();this.logRedirect("form-submit",r,{method:n})},document.addEventListener("submit",this.handleFormSubmit,!0)}setupPerformanceObserver(){try{this.performanceObserver=new PerformanceObserver((e=>{for(const t of e.getEntries())"navigation"===t.entryType&&this.logRedirect("performance-navigation",location.href,{type:t.type,redirectCount:t.redirectCount})})),this.performanceObserver.observe({type:"navigation",buffered:!0})}catch{}}init(){if(this.config.WHITELIST_PAGES.includes(Salla.config.get("page.slug")))return;if(this.isInitialized)return;const e=new URL(Salla.config.get("store.url")).hostname.split(".").slice(-2).join(".");this.config.WHITELIST.includes(e)||this.config.WHITELIST.push(e),this.hookHistoryAPIs(),this.hookLocationMethods(),this.hookWindowOpen(),this.setupEventListeners(),this.setupPerformanceObserver(),this.isInitialized=!0}destroy(){this.isInitialized&&(Object.keys(this.originalMethods).forEach((e=>{const[t,r]=e.split(".");"history"===t&&this.originalMethods[e]?history[r]=this.originalMethods[e]:"location"===t&&this.originalMethods[e]?location[r]=this.originalMethods[e]:"window"===t&&"open"===r&&this.originalMethods[e]&&(window.open=this.originalMethods[e])})),this.handleLinkClick&&document.removeEventListener("click",this.handleLinkClick,!0),this.handleFormSubmit&&document.removeEventListener("submit",this.handleFormSubmit,!0),this.performanceObserver&&this.performanceObserver.disconnect(),this.isInitialized=!1)}},salla.event.once("twilight::init",salla.init),salla.event.on("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),Dr.success=Dr.notify.success,Dr.error=Dr.notify.error,Dr.versions.twilight="2.14.263 - October 9, 2025 12:04:31",window.dispatchEvent(new CustomEvent("salla::created")),Dr}));
|
|
20
20
|
//# sourceMappingURL=twilight.min.js.map
|