@salla.sa/twilight 2.12.45 → 2.12.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("ev-emitter"),require("fizzy-ui-utils")):"function"==typeof define&&define.amd?define(["ev-emitter","fizzy-ui-utils"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t(e.evEmitter,e.fizzyUiUtils)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}function n(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 i=r(e),a=r(t),o="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&1===Object.keys(e).length?e.default:e}var c=Array.isArray,u="object"==typeof s&&s&&s.Object===Object&&s,h="object"==typeof self&&self&&self.Object===Object&&self,d=u||h||Function("return this")(),f=d.Symbol,p=f,g=Object.prototype,v=g.hasOwnProperty,m=g.toString,y=p?p.toStringTag:void 0;var w=function(e){var t=v.call(e,y),r=e[y];try{e[y]=void 0;var n=!0}catch(e){}var i=m.call(e);return n&&(t?e[y]=r:delete e[y]),i},b=Object.prototype.toString;var _=w,S=function(e){return b.call(e)},E=f?f.toStringTag:void 0;var A=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":E&&E in Object(e)?_(e):S(e)};var P=A,x=function(e){return null!=e&&"object"==typeof e};var F=function(e){return"symbol"==typeof e||x(e)&&"[object Symbol]"==P(e)},L=c,T=F,O=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,k=/^\w*$/;var R=function(e,t){if(L(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!T(e))||(k.test(e)||!O.test(e)||null!=t&&e in Object(t))};var C=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},j=A,I=C;var q,U=function(e){if(!I(e))return!1;var t=j(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},D=d["__core-js_shared__"],N=(q=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"";var B=function(e){return!!N&&N in e},M=Function.prototype.toString;var z=U,H=B,$=C,Y=function(e){if(null!=e){try{return M.call(e)}catch(e){}try{return e+""}catch(e){}}return""},G=/^\[object .+?Constructor\]$/,V=Function.prototype,W=Object.prototype,Q=V.toString,J=W.hasOwnProperty,K=RegExp("^"+Q.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var X=function(e){return!(!$(e)||H(e))&&(z(e)?K:G).test(Y(e))},Z=function(e,t){return null==e?void 0:e[t]};var ee=function(e,t){var r=Z(e,t);return X(r)?r:void 0},te=ee(Object,"create"),re=te;var ne=function(){this.__data__=re?re(null):{},this.size=0};var ie=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ae=te,oe=Object.prototype.hasOwnProperty;var se=function(e){var t=this.__data__;if(ae){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return oe.call(t,e)?t[e]:void 0},le=te,ce=Object.prototype.hasOwnProperty;var ue=function(e){var t=this.__data__;return le?void 0!==t[e]:ce.call(t,e)},he=te;var de=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=he&&void 0===t?"__lodash_hash_undefined__":t,this},fe=ne,pe=ie,ge=se,ve=ue,me=de;function ye(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])}}ye.prototype.clear=fe,ye.prototype.delete=pe,ye.prototype.get=ge,ye.prototype.has=ve,ye.prototype.set=me;var we=ye;var be=function(){this.__data__=[],this.size=0};var _e=function(e,t){return e===t||e!=e&&t!=t};var Se=function(e,t){for(var r=e.length;r--;)if(_e(e[r][0],t))return r;return-1},Ee=Se,Ae=Array.prototype.splice;var Pe=function(e){var t=this.__data__,r=Ee(t,e);return!(r<0)&&(r==t.length-1?t.pop():Ae.call(t,r,1),--this.size,!0)},xe=Se;var Fe=function(e){var t=this.__data__,r=xe(t,e);return r<0?void 0:t[r][1]},Le=Se;var Te=Se;var Oe=function(e,t){var r=this.__data__,n=Te(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},ke=be,Re=Pe,Ce=Fe,je=function(e){return Le(this.__data__,e)>-1},Ie=Oe;function qe(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])}}qe.prototype.clear=ke,qe.prototype.delete=Re,qe.prototype.get=Ce,qe.prototype.has=je,qe.prototype.set=Ie;var Ue=qe,De=ee(d,"Map"),Ne=we,Be=Ue,Me=De;var ze=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var He=function(e,t){var r=e.__data__;return ze(t)?r["string"==typeof t?"string":"hash"]:r.map},$e=He;var Ye=He;var Ge=He;var Ve=He;var We=function(e,t){var r=Ve(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Qe=function(){this.size=0,this.__data__={hash:new Ne,map:new(Me||Be),string:new Ne}},Je=function(e){var t=$e(this,e).delete(e);return this.size-=t?1:0,t},Ke=function(e){return Ye(this,e).get(e)},Xe=function(e){return Ge(this,e).has(e)},Ze=We;function et(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])}}et.prototype.clear=Qe,et.prototype.delete=Je,et.prototype.get=Ke,et.prototype.has=Xe,et.prototype.set=Ze;var tt=et;function rt(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=e.apply(this,n);return r.cache=a.set(i,o)||a,o};return r.cache=new(rt.Cache||tt),r}rt.Cache=tt;var nt=rt;var it=function(e){var t=nt(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t},at=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ot=/\\(\\)?/g,st=it((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(at,(function(e,r,n,i){t.push(n?i.replace(ot,"$1"):r||e)})),t}));var lt=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},ct=c,ut=F,ht=f?f.prototype:void 0,dt=ht?ht.toString:void 0;var ft=function e(t){if("string"==typeof t)return t;if(ct(t))return lt(t,e)+"";if(ut(t))return dt?dt.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r},pt=ft;var gt=c,vt=R,mt=st,yt=function(e){return null==e?"":pt(e)};var wt=F;var bt=function(e,t){return gt(e)?e:vt(e,t)?[e]:mt(yt(e))},_t=function(e){if("string"==typeof e||wt(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var St=function(e,t){for(var r=0,n=(t=bt(t,e)).length;null!=e&&r<n;)e=e[_t(t[r++])];return r&&r==n?e:void 0};var Et=function(e,t,r){var n=null==e?void 0:St(e,t);return void 0===n?r:n};function At(){throw new Error("setTimeout has not been defined")}function Pt(){throw new Error("clearTimeout has not been defined")}var xt=At,Ft=Pt;function Lt(e){if(xt===setTimeout)return setTimeout(e,0);if((xt===At||!xt)&&setTimeout)return xt=setTimeout,setTimeout(e,0);try{return xt(e,0)}catch(t){try{return xt.call(null,e,0)}catch(t){return xt.call(this,e,0)}}}"function"==typeof global.setTimeout&&(xt=setTimeout),"function"==typeof global.clearTimeout&&(Ft=clearTimeout);var Tt,Ot=[],kt=!1,Rt=-1;function Ct(){kt&&Tt&&(kt=!1,Tt.length?Ot=Tt.concat(Ot):Rt=-1,Ot.length&&jt())}function jt(){if(!kt){var e=Lt(Ct);kt=!0;for(var t=Ot.length;t;){for(Tt=Ot,Ot=[];++Rt<t;)Tt&&Tt[Rt].run();Rt=-1,t=Ot.length}Tt=null,kt=!1,function(e){if(Ft===clearTimeout)return clearTimeout(e);if((Ft===Pt||!Ft)&&clearTimeout)return Ft=clearTimeout,clearTimeout(e);try{return Ft(e)}catch(t){try{return Ft.call(null,e)}catch(t){return Ft.call(this,e)}}}(e)}}function It(e,t){this.fun=e,this.array=t}It.prototype.run=function(){this.fun.apply(null,this.array)};function qt(){}var Ut=qt,Dt=qt,Nt=qt,Bt=qt,Mt=qt,zt=qt,Ht=qt;var $t=global.performance||{},Yt=$t.now||$t.mozNow||$t.msNow||$t.oNow||$t.webkitNow||function(){return(new Date).getTime()};var Gt=new Date;var Vt={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];Ot.push(new It(e,t)),1!==Ot.length||kt||Lt(jt)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Ut,addListener:Dt,once:Nt,off:Bt,removeListener:Mt,removeAllListeners:zt,emit:Ht,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*Yt.call($t),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-Gt)/1e3}},Wt=Vt,Qt={exports:{}};!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 Wt&&"function"==typeof Wt.nextTick,a="function"==typeof Symbol,o="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,l=a?o&&"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 h(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!==Wt&&Wt.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,Wt.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var d=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,a=r?r.length:0,o=0;o<i;o++)n[e[o]]=o<a?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 a=e._observers;a?a.push(this):e._observers=[this]}function g(e,n,i,a){var o=Object.assign({},n);if(!e)return o;if("object"!=typeof e)throw TypeError("options must be an object");var s,l,c,u=Object.keys(e),h=u.length;function d(e){throw Error('Invalid "'+s+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<h;f++){if(s=u[f],!a&&!r.call(n,s))throw Error('Unknown "'+s+'" option');(l=e[s])!==t&&(c=i[s],o[s]=c?c(l,d):l)}return o}function v(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function m(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 a=typeof e;if(a===n||a===i)return e;r(t)}:function(n,i){for(var a=typeof n,o=r;o-- >0;)if(a===e[o])return n;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,a=this._emitter,o=this._listeners,s=function(){var n=d.apply(null,arguments),o={data:n,name:t,original:e};r?!1!==r.call(i,o)&&a.emit.apply(a,[o.name].concat(n)):a.emit.apply(a,[t].concat(n))};if(o[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,a._newListener&&a._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===o[e]&&(o[e]=s,n._on.call(i,e,s))},a.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!a.hasListeners(r)&&o[e]&&(o[e]=null,n._off.call(i,e,s))},o[e]=null,a.on("removeListener",this._onRemoveListener)):(o[e]=s,n._on.call(i,e,s))},unsubscribe:function(e){var t,r,n,i=this,a=this._listeners,o=this._emitter,s=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(o.off("newListener",i._onNewListener),o.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=_.call(o,i);o._observers.splice(e,1)}if(e){if(!(t=a[e]))return;s.call(c,e,t),delete a[e],--this._listenersCount||u()}else{for(n=(r=l(a)).length;n-- >0;)e=r[n],s.call(c,e,a[e]);this._listeners={},this._listenersCount=0,u()}}});var y=m(["function"]),w=m(["object","function"]);function b(e,t,r){var n,i,a,o=0,s=new e((function(l,c,u){function h(){i&&(i=null),o&&(clearTimeout(o),o=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 d=function(e){h(),l(e)},f=function(e){h(),c(e)};n?t(d,f,u):(i=[function(e){f(e||Error("canceled"))}],t(d,f,(function(e){if(a)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),a=!0),r.timeout>0&&(o=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",o=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 a=typeof t;if("string"===a){var o,s,c=0,u=0,h=this.delimiter,d=h.length;if(-1!==(s=t.indexOf(h))){o=new Array(5);do{o[c++]=t.slice(u,s),u=s+d}while(-1!==(s=t.indexOf(h,u)));o[c++]=t.slice(u),t=o,i=c}else t=[t],i=1}else"object"===a?i=t.length:(t=[t],i=1)}var f,p,g,v,m,y,w,b=null,_=t[n],E=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),b=[r]):(e&&e.push.apply(e,r._listeners),b=[r]));else{if("*"===_){for(s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&(w=S(e,t,r[f],n+1,i))&&(b?b.push.apply(b,w):b=w);return b}if("**"===_){for((m=n+1===i||n+2===i&&"*"===E)&&r._listeners&&(b=S(e,t,r,i,i)),s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&("*"===f||"**"===f?(r[f]._listeners&&!m&&(w=S(e,t,r[f],i,i))&&(b?b.push.apply(b,w):b=w),w=S(e,t,r[f],n,i)):w=S(e,t,r[f],f===E?n+2:n,i),w&&(b?b.push.apply(b,w):b=w));return b}r[_]&&(b=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):((v={})[f]=g[f],S(e,t,{"**":v},n+1,i)));else g._listeners?S(e,t,g,i,i):g["*"]&&g["*"]._listeners&&S(e,t,g["*"],i,i);return b}function E(e,t,r){var n,i,a=0,o=0,s=this.delimiter,l=s.length;if("string"==typeof e)if(-1!==(n=e.indexOf(s))){i=new Array(5);do{i[a++]=e.slice(o,n),o=n+l}while(-1!==(n=e.indexOf(s,o)));i[a++]=e.slice(o)}else i=[e],a=1;else i=e,a=e.length;if(a>1)for(n=0;n+1<a;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,u=this.listenerTree;for(n=0;n<a;n++)if(u=u[c=i[n]]||(u[c]={}),n===a-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,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function A(e,t,r,n){for(var i,a,o,s,c=l(e),u=c.length,h=e._listeners;u-- >0;)i=e[a=c[u]],o="_listeners"===a?r:r?r.concat(a):[a],s=n||"symbol"==typeof a,h&&t.push(s?o:o.join(this.delimiter)),"object"==typeof i&&A.call(this,i,t,o,s);return t}function P(e){for(var t,r,n,i=l(e),a=i.length;a-- >0;)(t=e[r=i[a]])&&(n=!0,"_listeners"===r||P(t)||delete e[r]);return n}function x(e,t,r){this.emitter=e,this.event=t,this.listener=r}function F(e,r,n){if(!0===n)o=!0;else if(!1===n)a=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var a=n.async,o=n.promisify,l=n.nextTick,c=n.objectify}if(a||l||o){var u=r,h=r._origin||r;if(l&&!i)throw Error("process.nextTick is not supported");o===t&&(o="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return o?l?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=r,u.apply(t,e)})):(l?Wt.nextTick:s)((function(){t.event=r,u.apply(t,e)}))},r._async=!0,r._origin=h}return[r,c?new x(this,e,r):this]}function L(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,u.call(this,e)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},L.EventEmitter2=L,L.prototype.listenTo=function(e,r,i){if("object"!=typeof e)throw TypeError("target musts be an object");var a=this;function o(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,n=i.reducers,o=_.call(a,e);r=-1===o?new p(a,e,i):a._observers[o];for(var s,c=l(t),u=c.length,h="function"==typeof n,d=0;d<u;d++)s=c[d],r.subscribe(s,t[s]||s,h?n:n&&n[s])}return i=g(i,{on:t,off:t,reducers:t},{on:y,off:y,reducers:w}),n(r)?o(f(r)):o("string"==typeof r?f(r.split(/\s+/)):r),this},L.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,a=!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),a=!0);return a},L.prototype.delimiter=".",L.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},L.prototype.getMaxListeners=function(){return this._maxListeners},L.prototype.event="",L.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},L.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},L.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},L.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},L.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},L.prototype._many=function(e,t,r,n,i){var a=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function o(){return 0==--t&&a.off(e,o),r.apply(this,arguments)}return o._origin=r,this._on(e,o,n,i)},L.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,o,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,a)for(n=0;n<r;n++)if("symbol"==typeof s[n]){o=!0;break}o||(s=s.join(this.delimiter))}var u,h=arguments.length;if(this._all&&this._all.length)for(n=0,r=(u=this._all.slice()).length;n<r;n++)switch(this.event=s,h){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,h){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(h-1),i=1;i<h;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(h>3)for(t=new Array(h-1),i=1;i<h;i++)t[i-1]=arguments[i];for(n=0,r=u.length;n<r;n++)switch(this.event=s,h){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},L.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,o,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,a)for(i=0;i<n;i++)if("symbol"==typeof s[i]){t=!0;break}t||(s=s.join(this.delimiter))}var u,h=[],d=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=s,d){case 1:h.push(this._all[i].call(this,s));break;case 2:h.push(this._all[i].call(this,s,arguments[1]));break;case 3:h.push(this._all[i].call(this,s,arguments[1],arguments[2]));break;default:h.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,d){case 1:h.push(u.call(this));break;case 2:h.push(u.call(this,arguments[1]));break;case 3:h.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(d-1),o=1;o<d;o++)r[o-1]=arguments[o];h.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),d>3)for(r=new Array(d-1),o=1;o<d;o++)r[o-1]=arguments[o];for(i=0,n=u.length;i<n;i++)switch(this.event=s,d){case 1:h.push(u[i].call(this));break;case 2:h.push(u[i].call(this,arguments[1]));break;case 3:h.push(u[i].call(this,arguments[1],arguments[2]));break;default:h.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(h)},L.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},L.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},L.prototype.onAny=function(e){return this._onAny(e,!1)},L.prototype.prependAny=function(e){return this._onAny(e,!0)},L.prototype.addListener=L.prototype.on,L.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},L.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 a,o=this;return i!==t&&(r=(a=F.call(this,e,r,i))[0],o=a[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(E.call(this,e,r,n),o):(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,h.call(this,this._events[e].length,e))):this._events[e]=r,o)},L.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 a="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=S.call(this,null,a,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var o=0;o<i.length;o++){var s=i[o];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&&P(this.listenerTree),this},L.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},L.prototype.removeListener=L.prototype.off,L.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&&P(this.listenerTree)}else this._events&&(this._events[e]=null);return this},L.prototype.listeners=function(e){var r,n,i,a,o,s=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!s)return[];for(a=(r=l(s)).length,i=[];a-- >0;)"function"==typeof(n=s[r[a]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(o=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,c,u,o,0),c}return s&&(n=s[e])?"function"==typeof n?[n]:n:[]},L.prototype.eventNames=function(e){var t=this._events;return this.wildcard?A.call(this,this.listenerTree,[],null,e):t?l(t):[]},L.prototype.listenerCount=function(e){return this.listeners(e).length},L.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,a=this._all;return!!(a&&a.length||i&&(e===t?l(i).length:i[e]))},L.prototype.listenersAny=function(){return this._all?this._all:[]},L.prototype.waitFor=function(e,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),b((r=g(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:v})).Promise,(function(t,i,a){function o(){var a=r.filter;if(!a||a.apply(n,arguments))if(n.off(e,o),r.handleError){var s=arguments[0];s?i(s):t(d.apply(null,arguments).slice(1))}else t(d.apply(null,arguments))}a((function(){n.off(e,o)})),n._on(e,o,!1)}),{timeout:r.timeout,overload:r.overload})};var T=L.prototype;Object.defineProperties(L,{defaultMaxListeners:{get:function(){return T._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");T._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return b((r=g(r,{Promise:Promise,timeout:0,overload:!1},{Promise:v})).Promise,(function(r,n,i){var a;if("function"==typeof e.addEventListener)return a=function(){r(d.apply(null,arguments))},i((function(){e.removeEventListener(t,a)})),void e.addEventListener(t,a,{once:!0});var o,s=function(){o&&e.removeListener("error",o),r(d.apply(null,arguments))};"error"!==t&&(o=function(r){e.removeListener(t,s),n(r)},e.once("error",o)),i((function(){o&&e.removeListener("error",o),e.removeListener(t,s)})),e.once(t,s)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(T,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof t&&t.amd?t((function(){return L})):e.exports=L}()}(Qt);var Jt=Qt.exports,Kt=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)nr(Object(arguments[i]),(function(t,r){e[r]=t}));return e},Xt=function(){if(Object.create)return function(e,t,r,n){var i=rr(arguments,1);return Kt.apply(this,[Object.create(e)].concat(i))};{function e(){}return function(t,r,n,i){var a=rr(arguments,1);return e.prototype=t,Kt.apply(this,[new e].concat(a))}}}(),Zt=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},er="undefined"!=typeof window?window:s,tr={assign:Kt,create:Xt,trim:Zt,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:rr,each:nr,map:function(e,t){var r=ar(e)?[]:{};return ir(e,(function(e,n){return r[n]=t(e,n),!1})),r},pluck:ir,isList:ar,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:er};function rr(e,t){return Array.prototype.slice.call(e,t||0)}function nr(e,t){ir(e,(function(e,r){return t(e,r),!1}))}function ir(e,t){if(ar(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 ar(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var or=tr.slice,sr=tr.pluck,lr=tr.each,cr=tr.bind,ur=tr.create,hr=tr.isList,dr=tr.isFunction,fr=tr.isObject,pr={createStore:vr},gr={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 vr.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return vr(this.storage,this.plugins,e)}};function vr(e,t,r){r||(r=""),e&&!hr(e)&&(e=[e]),t&&!hr(t)&&(t=[t]);var n=r?"__storejs_"+r+"_":"",i=r?new RegExp("^"+n):null;if(!/^[a-zA-Z0-9_\-]*$/.test(r))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var a={_namespacePrefix:n,_namespaceRegexp:i,_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,t){var r=this[t];this[t]=function(){var t=or(arguments,0),n=this;var i=[function(){if(r)return lr(arguments,(function(e,r){t[r]=e})),r.apply(n,t)}].concat(t);return e.apply(n,i)}},_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(hr(e))lr(e,(function(e){t._addPlugin(e)}));else if(!sr(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!dr(e))throw new Error("Plugins must be function values that return objects");var r=e.call(this);if(!fr(r))throw new Error("Plugins must return an object of function properties");lr(r,(function(r,n){if(!dr(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)}},o=ur(a,gr,{plugins:[]});return o.raw={},lr(o,(function(e,t){dr(e)&&(o.raw[t]=cr(o,e))})),lr(e,(function(e){o._addStorage(e)})),lr(t,(function(e){o._addPlugin(e)})),o}var mr=tr.Global,yr={name:"localStorage",read:br,write:function(e,t){return wr().setItem(e,t)},each:function(e){for(var t=wr().length-1;t>=0;t--){var r=wr().key(t);e(br(r),r)}},remove:function(e){return wr().removeItem(e)},clearAll:function(){return wr().clear()}};function wr(){return mr.localStorage}function br(e){return wr().getItem(e)}var _r=n({__proto__:null,default:yr},[yr]),Sr=tr.Global,Er={name:"sessionStorage",read:Pr,write:function(e,t){return Ar().setItem(e,t)},each:function(e){for(var t=Ar().length-1;t>=0;t--){var r=Ar().key(t);e(Pr(r),r)}},remove:function(e){return Ar().removeItem(e)},clearAll:function(){return Ar().clear()}};function Ar(){return Sr.sessionStorage}function Pr(e){return Ar().getItem(e)}var xr=n({__proto__:null,default:Er},[Er]),Fr=tr.trim,Lr={name:"cookieStorage",read:function(e){if(!e||!Rr(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Tr.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;Tr.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Or,remove:kr,clearAll:function(){Or((function(e,t){kr(t)}))}},Tr=tr.Global.document;function Or(e){for(var t=Tr.cookie.split(/; ?/g),r=t.length-1;r>=0;r--)if(Fr(t[r])){var n=t[r].split("="),i=unescape(n[0]);e(unescape(n[1]),i)}}function kr(e){e&&Rr(e)&&(Tr.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Rr(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Tr.cookie)}var Cr=n({__proto__:null,default:Lr},[Lr]),jr={name:"memoryStorage",read:function(e){return Ir[e]},write:function(e,t){Ir[e]=t},each:function(e){for(var t in Ir)Ir.hasOwnProperty(t)&&e(Ir[t],t)},remove:function(e){delete Ir[e]},clearAll:function(e){Ir={}}},Ir={};var qr=n({__proto__:null,default:jr},[jr]);function Ur(e,t){void 0===t&&(t=!1),e+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],a=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,o=t?i:n,s=0;s<a.length;s++)r=new RegExp(a[s],"g"),e=e.replace(r,o[s]);return e.replace(t?"٫":".",t?".":"٫")}function Dr(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?Dr(e.replace(/\.(.+)\./g,".$1")):e}function Nr(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function Br(e){if(Nr(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 Mr(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 zr(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function Hr(e){return Nr(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):zr("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}function $r(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]=$r(e.slice(1),t,r[i]),r):i?((n={})[i]=$r(e.slice(1),t),n):""===i?[t]:t}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 Yr={digitsOnly:function(e){return Ur(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")?Dr(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:Ur,money:function(e){var t=Salla.config.currency(null==e?void 0:e.currency).symbol;return Ur(e="object"==typeof e?e.amount:e)+" "+t},setNested:function(e,t,r){for(var n=e,i=t.split("."),a=i.length,o=0;o<a-1;o++){var s=i[o];n[s]||(n[s]={}),n=n[s]}return n[i[a-1]]=r,e},getNested:function(e,t,r){var n=Et(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("[");return{name:n[0],value:$r(n.slice(1),t,r[n[0]])}}return{name:e,value:t}},url:Object.freeze({__proto__:null,is_full_url:Nr,base:function(e){return Nr(e)?e:"https://"+new URL(Br("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},get:Br,domain:function(e){return Nr(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},addParamToUrl:Mr,baseUrl:zr,asset:Hr,cdn:function(e){return"https://cdn.salla.network/"+(null==e?void 0:e.ltrim("/"))},api:function(e){var t;return(null===(t=Salla.config.get("store.api",Br("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return Hr(salla.config.get("theme.settings.placeholder"))===Hr(e)}}),addParamToUrl:Mr,debounce:function(e,t){t=t||100;var r,n=[];return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];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)}))}}},Gr=function(e,t){return Gr=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])},Gr(e,t)},Vr=function(){return Vr=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},Vr.apply(this,arguments)};function Wr(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;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 Qr,Jr,Kr,Xr=(Qr=console,Jr=[],Kr={log:function(e,t){if(Qr&&salla.config.isDebug()){Jr.push([t,e]),"trace"===salla.config.get("debug")&&(t="trace");var r=Qr.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;"],a={event:"#CFF680",backend:"#7b68ee"}[t];a&&(i[0]+="%c"+t[0].toUpperCase()+t.substring(1),i.push("margin-left: 5px;color: ".concat(a,";font-weight:bold; border:1px solid ").concat(a,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,Wr([Qr],i.concat.apply(i,e),!1))}},__dict__:{trace:Qr.trace,debug:Qr.debug,info:Qr.info,warn:Qr.warn,error:Qr.error}},{event:function(){Kr.log(arguments,"event")},trace:function(){Kr.log(arguments,"trace")},debug:function(){Kr.log(arguments,"debug")},info:function(){Kr.log(arguments,"info")},warn:function(){Kr.log(arguments,"warn")},error:function(){Kr.log(arguments,"error")},log:function(){Kr.log(arguments,void 0)},backend:function(){Kr.log(arguments,"backend")},logs:function(e){[e].flat().forEach((function(e){return e&&Kr.log([e].flat(),"backend")}))},history:function(){return Jr.map((function(e){return Qr.log.apply(Qr,Wr([e[0]],e[1],!1))})),Jr}}),Zr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=Vr(Vr({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=Vr(Vr({},this.properties_),e),this.properties_.store=Vr(Vr({},(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}(),en=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}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}Gr(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,Wr([e],t,!1))},t.prototype.emit=function(t){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var a=t.replace("::",".");if(!this.noneFireableActions.includes(a)&&Salla.call&&"function"==typeof Salla.call(a))return Salla.log("'Salla.".concat(a,"(...)' triggered using event '").concat(t,"'")),a=a.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[a[0]])[a[1]].apply(r,n);e.prototype.emit.apply(this,Wr([t],n,!1)),this.trackEvents.apply(this,Wr([t],n,!1))},t.prototype.emitAsync=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=e.prototype.emitAsync.apply(this,Wr([t],r,!1));try{this.trackEvents.apply(this,Wr([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=Vr(Vr({},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,Wr([e],r,!1)),this.dispatchMobileEvent.apply(this,Wr([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,Wr([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],a=n[1];this.dispatch(i,a)}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){if(void 0===t&&(t={}),!("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(void 0!==window.Android)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}},t}(Jt.EventEmitter2),tn=pr.createStore([_r,xr,Cr,qr],[]),rn=function(){function e(){var e=this;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=tn}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(){return this.store.clearAll()},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}(),nn=function(){function e(){var e=this;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()}return document.cookie="".concat(e,"=").concat(t).concat(n,'"; path=/; secure; SameSite=Lax"'),this},e.prototype.remove=function(e){return document.cookie="".concat(e,"=; Max-Age=0; path=/;"),this},e.prototype.clearAll=function(){for(var e=document.cookie.split(";"),t=0;t<e.length;t++){var r=e[t],n=r.indexOf("="),i=n>-1?r.substr(0,n):r;this.remove(i)}},e}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),void 0!==o&&(o.salla=o.salla||o.Salla||{},o.Salla=o.salla),Salla.status="base",Salla.config=new Zr,Salla.logger=Xr,Salla.event=new en,Salla.helpers=Yr,Salla.storage=new rn,Salla.cookie=new nn,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.12.43"};var an=Salla;let on=function(e,t,r){return alert(e)},sn=function(e,t){return on(e,ln.error,t)},ln={error:"error",success:"success",info:"info"};var cn={fire:function(e,t,r){return on(e,t,r)},setNotifier:function(e){on=e,salla.event.emit("twilight::notifier.changed")},error:sn,success:function(e,t){return on(e,ln.success,t)},info:function(e,t){return on(e,ln.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=>{sn(decodeURI(e.replace("?danger=","").replace("&danger=","")))}))})))},types:ln};class un{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 a=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,a);a[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(a)},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 a=window[i];if("function"==typeof a){if(!a(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return a(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 hn{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,!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 dn(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends hn{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))}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 hn{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",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"},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,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 hn{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"},this.after_init()}},Salla.event.scope=new class extends hn{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 hn{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 hn{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends hn{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 hn{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed"},this.after_init()}},Salla.event.loyalty=new class extends hn{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 hn{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"},this.after_init()}},Salla.event.profile=new class extends hn{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 hn{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 hn{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 hn{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 hn{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.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(dn(e),Object.keys(e).forEach((t=>{dn(e[t])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"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};var fn,pn={exports:{}},gn={exports:{}},vn=l(i),mn=l(a);function yn(){return fn||(fn=1,function(e){!function(t,r){e.exports?e.exports=r(t,vn,mn):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let n=e.jQuery,i={};function a(e,t){let o=r.getQueryElement(e);if(o){if((e=o).infiniteScrollGUID){let r=i[e.infiniteScrollGUID];return r.option(t),r}this.element=e,this.options={...a.defaults},this.option(t),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(o||e))}a.defaults={},a.create={},a.destroy={};let o=a.prototype;Object.assign(o,t.prototype);let s=0;o.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 a.create)a.create[e].call(this)}else console.error("Disabling InfiniteScroll")},o.option=function(e){Object.assign(this.options,e)},o.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},o.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 a=e+=".infiniteScroll";if(t){let r=n.Event(t);r.type=e,a=r}this.$element.trigger(a,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}`}};o.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)},o.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},o.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},o.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},o.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=a.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}}}};o.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:a,end:o}=n;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+o,this.pageIndex=parseInt(a,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},o.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()},a.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},o.destroy=function(){this.allOff();for(let e in a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},a.throttle=function(e,t){let r,n;return t=t||200,function(){let i=+new Date,a=arguments,o=()=>{r=i,e.apply(this,a)};r&&i<r+t?(clearTimeout(n),n=setTimeout(o,t)):o()}},a.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},a.setJQuery=function(e){n=e},r.htmlInit(a,"infinite-scroll"),o._init=function(){};let{jQueryBridget:h}=e;return n&&h&&h("infiniteScroll",a,n),a}))}(gn)),gn.exports}gn.exports;var wn,bn={exports:{}};function _n(){return wn||(wn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn()):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 a=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((a=>("text"==e&&t&&(a=n.parseFromString(a,"text/html")),204==r.status?(this.lastPageReached(a,i),{body:a,response:r}):this.onPageLoad(a,i,r))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,a]),a},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:a,domParseResponse:o}=this.options;if(!("text"==a&&o)||!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}))}(bn)),bn.exports}var Sn,En={exports:{}};function An(){return Sn||(Sn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):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}))}(En)),En.exports}var Pn,xn={exports:{}};function Fn(){return Pn||(Pn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):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],a=this.getElementScrollY(n);i.href=t,this.scrollPages.push({top:a,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}))}(xn)),xn.exports}var Ln,Tn={exports:{}};function On(){return Ln||(Ln=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):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}))}(Tn)),Tn.exports}var kn,Rn={exports:{}};function Cn(){return kn||(kn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;function i(e){o(e,"none")}function a(e){o(e,"block")}function o(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){a(this.statusElement),this.hideStatusEventElements(),a(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}))}(Rn)),Rn.exports}
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("ev-emitter"),require("fizzy-ui-utils")):"function"==typeof define&&define.amd?define(["ev-emitter","fizzy-ui-utils"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t(e.evEmitter,e.fizzyUiUtils)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}function n(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 i=r(e),a=r(t),o="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&1===Object.keys(e).length?e.default:e}var c=Array.isArray,u="object"==typeof s&&s&&s.Object===Object&&s,h="object"==typeof self&&self&&self.Object===Object&&self,d=u||h||Function("return this")(),f=d.Symbol,p=f,g=Object.prototype,v=g.hasOwnProperty,m=g.toString,y=p?p.toStringTag:void 0;var w=function(e){var t=v.call(e,y),r=e[y];try{e[y]=void 0;var n=!0}catch(e){}var i=m.call(e);return n&&(t?e[y]=r:delete e[y]),i},b=Object.prototype.toString;var _=w,S=function(e){return b.call(e)},E=f?f.toStringTag:void 0;var A=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":E&&E in Object(e)?_(e):S(e)};var P=A,x=function(e){return null!=e&&"object"==typeof e};var F=function(e){return"symbol"==typeof e||x(e)&&"[object Symbol]"==P(e)},L=c,T=F,O=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,k=/^\w*$/;var R=function(e,t){if(L(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!T(e))||(k.test(e)||!O.test(e)||null!=t&&e in Object(t))};var C=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},j=A,I=C;var q,U=function(e){if(!I(e))return!1;var t=j(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},D=d["__core-js_shared__"],N=(q=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"";var B=function(e){return!!N&&N in e},M=Function.prototype.toString;var z=U,H=B,$=C,Y=function(e){if(null!=e){try{return M.call(e)}catch(e){}try{return e+""}catch(e){}}return""},G=/^\[object .+?Constructor\]$/,V=Function.prototype,W=Object.prototype,Q=V.toString,J=W.hasOwnProperty,K=RegExp("^"+Q.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var X=function(e){return!(!$(e)||H(e))&&(z(e)?K:G).test(Y(e))},Z=function(e,t){return null==e?void 0:e[t]};var ee=function(e,t){var r=Z(e,t);return X(r)?r:void 0},te=ee(Object,"create"),re=te;var ne=function(){this.__data__=re?re(null):{},this.size=0};var ie=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ae=te,oe=Object.prototype.hasOwnProperty;var se=function(e){var t=this.__data__;if(ae){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return oe.call(t,e)?t[e]:void 0},le=te,ce=Object.prototype.hasOwnProperty;var ue=function(e){var t=this.__data__;return le?void 0!==t[e]:ce.call(t,e)},he=te;var de=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=he&&void 0===t?"__lodash_hash_undefined__":t,this},fe=ne,pe=ie,ge=se,ve=ue,me=de;function ye(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])}}ye.prototype.clear=fe,ye.prototype.delete=pe,ye.prototype.get=ge,ye.prototype.has=ve,ye.prototype.set=me;var we=ye;var be=function(){this.__data__=[],this.size=0};var _e=function(e,t){return e===t||e!=e&&t!=t};var Se=function(e,t){for(var r=e.length;r--;)if(_e(e[r][0],t))return r;return-1},Ee=Se,Ae=Array.prototype.splice;var Pe=function(e){var t=this.__data__,r=Ee(t,e);return!(r<0)&&(r==t.length-1?t.pop():Ae.call(t,r,1),--this.size,!0)},xe=Se;var Fe=function(e){var t=this.__data__,r=xe(t,e);return r<0?void 0:t[r][1]},Le=Se;var Te=Se;var Oe=function(e,t){var r=this.__data__,n=Te(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},ke=be,Re=Pe,Ce=Fe,je=function(e){return Le(this.__data__,e)>-1},Ie=Oe;function qe(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])}}qe.prototype.clear=ke,qe.prototype.delete=Re,qe.prototype.get=Ce,qe.prototype.has=je,qe.prototype.set=Ie;var Ue=qe,De=ee(d,"Map"),Ne=we,Be=Ue,Me=De;var ze=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var He=function(e,t){var r=e.__data__;return ze(t)?r["string"==typeof t?"string":"hash"]:r.map},$e=He;var Ye=He;var Ge=He;var Ve=He;var We=function(e,t){var r=Ve(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Qe=function(){this.size=0,this.__data__={hash:new Ne,map:new(Me||Be),string:new Ne}},Je=function(e){var t=$e(this,e).delete(e);return this.size-=t?1:0,t},Ke=function(e){return Ye(this,e).get(e)},Xe=function(e){return Ge(this,e).has(e)},Ze=We;function et(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])}}et.prototype.clear=Qe,et.prototype.delete=Je,et.prototype.get=Ke,et.prototype.has=Xe,et.prototype.set=Ze;var tt=et;function rt(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=e.apply(this,n);return r.cache=a.set(i,o)||a,o};return r.cache=new(rt.Cache||tt),r}rt.Cache=tt;var nt=rt;var it=function(e){var t=nt(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t},at=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ot=/\\(\\)?/g,st=it((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(at,(function(e,r,n,i){t.push(n?i.replace(ot,"$1"):r||e)})),t}));var lt=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},ct=c,ut=F,ht=f?f.prototype:void 0,dt=ht?ht.toString:void 0;var ft=function e(t){if("string"==typeof t)return t;if(ct(t))return lt(t,e)+"";if(ut(t))return dt?dt.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r},pt=ft;var gt=c,vt=R,mt=st,yt=function(e){return null==e?"":pt(e)};var wt=F;var bt=function(e,t){return gt(e)?e:vt(e,t)?[e]:mt(yt(e))},_t=function(e){if("string"==typeof e||wt(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var St=function(e,t){for(var r=0,n=(t=bt(t,e)).length;null!=e&&r<n;)e=e[_t(t[r++])];return r&&r==n?e:void 0};var Et=function(e,t,r){var n=null==e?void 0:St(e,t);return void 0===n?r:n};function At(){throw new Error("setTimeout has not been defined")}function Pt(){throw new Error("clearTimeout has not been defined")}var xt=At,Ft=Pt;function Lt(e){if(xt===setTimeout)return setTimeout(e,0);if((xt===At||!xt)&&setTimeout)return xt=setTimeout,setTimeout(e,0);try{return xt(e,0)}catch(t){try{return xt.call(null,e,0)}catch(t){return xt.call(this,e,0)}}}"function"==typeof global.setTimeout&&(xt=setTimeout),"function"==typeof global.clearTimeout&&(Ft=clearTimeout);var Tt,Ot=[],kt=!1,Rt=-1;function Ct(){kt&&Tt&&(kt=!1,Tt.length?Ot=Tt.concat(Ot):Rt=-1,Ot.length&&jt())}function jt(){if(!kt){var e=Lt(Ct);kt=!0;for(var t=Ot.length;t;){for(Tt=Ot,Ot=[];++Rt<t;)Tt&&Tt[Rt].run();Rt=-1,t=Ot.length}Tt=null,kt=!1,function(e){if(Ft===clearTimeout)return clearTimeout(e);if((Ft===Pt||!Ft)&&clearTimeout)return Ft=clearTimeout,clearTimeout(e);try{return Ft(e)}catch(t){try{return Ft.call(null,e)}catch(t){return Ft.call(this,e)}}}(e)}}function It(e,t){this.fun=e,this.array=t}It.prototype.run=function(){this.fun.apply(null,this.array)};function qt(){}var Ut=qt,Dt=qt,Nt=qt,Bt=qt,Mt=qt,zt=qt,Ht=qt;var $t=global.performance||{},Yt=$t.now||$t.mozNow||$t.msNow||$t.oNow||$t.webkitNow||function(){return(new Date).getTime()};var Gt=new Date;var Vt={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];Ot.push(new It(e,t)),1!==Ot.length||kt||Lt(jt)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Ut,addListener:Dt,once:Nt,off:Bt,removeListener:Mt,removeAllListeners:zt,emit:Ht,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*Yt.call($t),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-Gt)/1e3}},Wt=Vt,Qt={exports:{}};!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 Wt&&"function"==typeof Wt.nextTick,a="function"==typeof Symbol,o="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,l=a?o&&"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 h(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!==Wt&&Wt.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,Wt.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var d=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,a=r?r.length:0,o=0;o<i;o++)n[e[o]]=o<a?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 a=e._observers;a?a.push(this):e._observers=[this]}function g(e,n,i,a){var o=Object.assign({},n);if(!e)return o;if("object"!=typeof e)throw TypeError("options must be an object");var s,l,c,u=Object.keys(e),h=u.length;function d(e){throw Error('Invalid "'+s+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<h;f++){if(s=u[f],!a&&!r.call(n,s))throw Error('Unknown "'+s+'" option');(l=e[s])!==t&&(c=i[s],o[s]=c?c(l,d):l)}return o}function v(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function m(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 a=typeof e;if(a===n||a===i)return e;r(t)}:function(n,i){for(var a=typeof n,o=r;o-- >0;)if(a===e[o])return n;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,a=this._emitter,o=this._listeners,s=function(){var n=d.apply(null,arguments),o={data:n,name:t,original:e};r?!1!==r.call(i,o)&&a.emit.apply(a,[o.name].concat(n)):a.emit.apply(a,[t].concat(n))};if(o[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,a._newListener&&a._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===o[e]&&(o[e]=s,n._on.call(i,e,s))},a.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!a.hasListeners(r)&&o[e]&&(o[e]=null,n._off.call(i,e,s))},o[e]=null,a.on("removeListener",this._onRemoveListener)):(o[e]=s,n._on.call(i,e,s))},unsubscribe:function(e){var t,r,n,i=this,a=this._listeners,o=this._emitter,s=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(o.off("newListener",i._onNewListener),o.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=_.call(o,i);o._observers.splice(e,1)}if(e){if(!(t=a[e]))return;s.call(c,e,t),delete a[e],--this._listenersCount||u()}else{for(n=(r=l(a)).length;n-- >0;)e=r[n],s.call(c,e,a[e]);this._listeners={},this._listenersCount=0,u()}}});var y=m(["function"]),w=m(["object","function"]);function b(e,t,r){var n,i,a,o=0,s=new e((function(l,c,u){function h(){i&&(i=null),o&&(clearTimeout(o),o=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 d=function(e){h(),l(e)},f=function(e){h(),c(e)};n?t(d,f,u):(i=[function(e){f(e||Error("canceled"))}],t(d,f,(function(e){if(a)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),a=!0),r.timeout>0&&(o=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",o=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 a=typeof t;if("string"===a){var o,s,c=0,u=0,h=this.delimiter,d=h.length;if(-1!==(s=t.indexOf(h))){o=new Array(5);do{o[c++]=t.slice(u,s),u=s+d}while(-1!==(s=t.indexOf(h,u)));o[c++]=t.slice(u),t=o,i=c}else t=[t],i=1}else"object"===a?i=t.length:(t=[t],i=1)}var f,p,g,v,m,y,w,b=null,_=t[n],E=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),b=[r]):(e&&e.push.apply(e,r._listeners),b=[r]));else{if("*"===_){for(s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&(w=S(e,t,r[f],n+1,i))&&(b?b.push.apply(b,w):b=w);return b}if("**"===_){for((m=n+1===i||n+2===i&&"*"===E)&&r._listeners&&(b=S(e,t,r,i,i)),s=(y=l(r)).length;s-- >0;)"_listeners"!==(f=y[s])&&("*"===f||"**"===f?(r[f]._listeners&&!m&&(w=S(e,t,r[f],i,i))&&(b?b.push.apply(b,w):b=w),w=S(e,t,r[f],n,i)):w=S(e,t,r[f],f===E?n+2:n,i),w&&(b?b.push.apply(b,w):b=w));return b}r[_]&&(b=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):((v={})[f]=g[f],S(e,t,{"**":v},n+1,i)));else g._listeners?S(e,t,g,i,i):g["*"]&&g["*"]._listeners&&S(e,t,g["*"],i,i);return b}function E(e,t,r){var n,i,a=0,o=0,s=this.delimiter,l=s.length;if("string"==typeof e)if(-1!==(n=e.indexOf(s))){i=new Array(5);do{i[a++]=e.slice(o,n),o=n+l}while(-1!==(n=e.indexOf(s,o)));i[a++]=e.slice(o)}else i=[e],a=1;else i=e,a=e.length;if(a>1)for(n=0;n+1<a;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,u=this.listenerTree;for(n=0;n<a;n++)if(u=u[c=i[n]]||(u[c]={}),n===a-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,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function A(e,t,r,n){for(var i,a,o,s,c=l(e),u=c.length,h=e._listeners;u-- >0;)i=e[a=c[u]],o="_listeners"===a?r:r?r.concat(a):[a],s=n||"symbol"==typeof a,h&&t.push(s?o:o.join(this.delimiter)),"object"==typeof i&&A.call(this,i,t,o,s);return t}function P(e){for(var t,r,n,i=l(e),a=i.length;a-- >0;)(t=e[r=i[a]])&&(n=!0,"_listeners"===r||P(t)||delete e[r]);return n}function x(e,t,r){this.emitter=e,this.event=t,this.listener=r}function F(e,r,n){if(!0===n)o=!0;else if(!1===n)a=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var a=n.async,o=n.promisify,l=n.nextTick,c=n.objectify}if(a||l||o){var u=r,h=r._origin||r;if(l&&!i)throw Error("process.nextTick is not supported");o===t&&(o="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return o?l?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=r,u.apply(t,e)})):(l?Wt.nextTick:s)((function(){t.event=r,u.apply(t,e)}))},r._async=!0,r._origin=h}return[r,c?new x(this,e,r):this]}function L(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,u.call(this,e)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},L.EventEmitter2=L,L.prototype.listenTo=function(e,r,i){if("object"!=typeof e)throw TypeError("target musts be an object");var a=this;function o(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,n=i.reducers,o=_.call(a,e);r=-1===o?new p(a,e,i):a._observers[o];for(var s,c=l(t),u=c.length,h="function"==typeof n,d=0;d<u;d++)s=c[d],r.subscribe(s,t[s]||s,h?n:n&&n[s])}return i=g(i,{on:t,off:t,reducers:t},{on:y,off:y,reducers:w}),n(r)?o(f(r)):o("string"==typeof r?f(r.split(/\s+/)):r),this},L.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,a=!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),a=!0);return a},L.prototype.delimiter=".",L.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},L.prototype.getMaxListeners=function(){return this._maxListeners},L.prototype.event="",L.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},L.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},L.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},L.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},L.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},L.prototype._many=function(e,t,r,n,i){var a=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function o(){return 0==--t&&a.off(e,o),r.apply(this,arguments)}return o._origin=r,this._on(e,o,n,i)},L.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,o,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,a)for(n=0;n<r;n++)if("symbol"==typeof s[n]){o=!0;break}o||(s=s.join(this.delimiter))}var u,h=arguments.length;if(this._all&&this._all.length)for(n=0,r=(u=this._all.slice()).length;n<r;n++)switch(this.event=s,h){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,h){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(h-1),i=1;i<h;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(h>3)for(t=new Array(h-1),i=1;i<h;i++)t[i-1]=arguments[i];for(n=0,r=u.length;n<r;n++)switch(this.event=s,h){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},L.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,o,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,a)for(i=0;i<n;i++)if("symbol"==typeof s[i]){t=!0;break}t||(s=s.join(this.delimiter))}var u,h=[],d=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=s,d){case 1:h.push(this._all[i].call(this,s));break;case 2:h.push(this._all[i].call(this,s,arguments[1]));break;case 3:h.push(this._all[i].call(this,s,arguments[1],arguments[2]));break;default:h.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,d){case 1:h.push(u.call(this));break;case 2:h.push(u.call(this,arguments[1]));break;case 3:h.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(d-1),o=1;o<d;o++)r[o-1]=arguments[o];h.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),d>3)for(r=new Array(d-1),o=1;o<d;o++)r[o-1]=arguments[o];for(i=0,n=u.length;i<n;i++)switch(this.event=s,d){case 1:h.push(u[i].call(this));break;case 2:h.push(u[i].call(this,arguments[1]));break;case 3:h.push(u[i].call(this,arguments[1],arguments[2]));break;default:h.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(h)},L.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},L.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},L.prototype.onAny=function(e){return this._onAny(e,!1)},L.prototype.prependAny=function(e){return this._onAny(e,!0)},L.prototype.addListener=L.prototype.on,L.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},L.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 a,o=this;return i!==t&&(r=(a=F.call(this,e,r,i))[0],o=a[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(E.call(this,e,r,n),o):(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,h.call(this,this._events[e].length,e))):this._events[e]=r,o)},L.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 a="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=S.call(this,null,a,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var o=0;o<i.length;o++){var s=i[o];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&&P(this.listenerTree),this},L.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},L.prototype.removeListener=L.prototype.off,L.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&&P(this.listenerTree)}else this._events&&(this._events[e]=null);return this},L.prototype.listeners=function(e){var r,n,i,a,o,s=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!s)return[];for(a=(r=l(s)).length,i=[];a-- >0;)"function"==typeof(n=s[r[a]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(o=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,c,u,o,0),c}return s&&(n=s[e])?"function"==typeof n?[n]:n:[]},L.prototype.eventNames=function(e){var t=this._events;return this.wildcard?A.call(this,this.listenerTree,[],null,e):t?l(t):[]},L.prototype.listenerCount=function(e){return this.listeners(e).length},L.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,a=this._all;return!!(a&&a.length||i&&(e===t?l(i).length:i[e]))},L.prototype.listenersAny=function(){return this._all?this._all:[]},L.prototype.waitFor=function(e,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),b((r=g(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:v})).Promise,(function(t,i,a){function o(){var a=r.filter;if(!a||a.apply(n,arguments))if(n.off(e,o),r.handleError){var s=arguments[0];s?i(s):t(d.apply(null,arguments).slice(1))}else t(d.apply(null,arguments))}a((function(){n.off(e,o)})),n._on(e,o,!1)}),{timeout:r.timeout,overload:r.overload})};var T=L.prototype;Object.defineProperties(L,{defaultMaxListeners:{get:function(){return T._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");T._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return b((r=g(r,{Promise:Promise,timeout:0,overload:!1},{Promise:v})).Promise,(function(r,n,i){var a;if("function"==typeof e.addEventListener)return a=function(){r(d.apply(null,arguments))},i((function(){e.removeEventListener(t,a)})),void e.addEventListener(t,a,{once:!0});var o,s=function(){o&&e.removeListener("error",o),r(d.apply(null,arguments))};"error"!==t&&(o=function(r){e.removeListener(t,s),n(r)},e.once("error",o)),i((function(){o&&e.removeListener("error",o),e.removeListener(t,s)})),e.once(t,s)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(T,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof t&&t.amd?t((function(){return L})):e.exports=L}()}(Qt);var Jt=Qt.exports,Kt=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)nr(Object(arguments[i]),(function(t,r){e[r]=t}));return e},Xt=function(){if(Object.create)return function(e,t,r,n){var i=rr(arguments,1);return Kt.apply(this,[Object.create(e)].concat(i))};{function e(){}return function(t,r,n,i){var a=rr(arguments,1);return e.prototype=t,Kt.apply(this,[new e].concat(a))}}}(),Zt=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},er="undefined"!=typeof window?window:s,tr={assign:Kt,create:Xt,trim:Zt,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:rr,each:nr,map:function(e,t){var r=ar(e)?[]:{};return ir(e,(function(e,n){return r[n]=t(e,n),!1})),r},pluck:ir,isList:ar,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:er};function rr(e,t){return Array.prototype.slice.call(e,t||0)}function nr(e,t){ir(e,(function(e,r){return t(e,r),!1}))}function ir(e,t){if(ar(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 ar(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var or=tr.slice,sr=tr.pluck,lr=tr.each,cr=tr.bind,ur=tr.create,hr=tr.isList,dr=tr.isFunction,fr=tr.isObject,pr={createStore:vr},gr={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 vr.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return vr(this.storage,this.plugins,e)}};function vr(e,t,r){r||(r=""),e&&!hr(e)&&(e=[e]),t&&!hr(t)&&(t=[t]);var n=r?"__storejs_"+r+"_":"",i=r?new RegExp("^"+n):null;if(!/^[a-zA-Z0-9_\-]*$/.test(r))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var a={_namespacePrefix:n,_namespaceRegexp:i,_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,t){var r=this[t];this[t]=function(){var t=or(arguments,0),n=this;var i=[function(){if(r)return lr(arguments,(function(e,r){t[r]=e})),r.apply(n,t)}].concat(t);return e.apply(n,i)}},_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(hr(e))lr(e,(function(e){t._addPlugin(e)}));else if(!sr(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!dr(e))throw new Error("Plugins must be function values that return objects");var r=e.call(this);if(!fr(r))throw new Error("Plugins must return an object of function properties");lr(r,(function(r,n){if(!dr(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)}},o=ur(a,gr,{plugins:[]});return o.raw={},lr(o,(function(e,t){dr(e)&&(o.raw[t]=cr(o,e))})),lr(e,(function(e){o._addStorage(e)})),lr(t,(function(e){o._addPlugin(e)})),o}var mr=tr.Global,yr={name:"localStorage",read:br,write:function(e,t){return wr().setItem(e,t)},each:function(e){for(var t=wr().length-1;t>=0;t--){var r=wr().key(t);e(br(r),r)}},remove:function(e){return wr().removeItem(e)},clearAll:function(){return wr().clear()}};function wr(){return mr.localStorage}function br(e){return wr().getItem(e)}var _r=n({__proto__:null,default:yr},[yr]),Sr=tr.Global,Er={name:"sessionStorage",read:Pr,write:function(e,t){return Ar().setItem(e,t)},each:function(e){for(var t=Ar().length-1;t>=0;t--){var r=Ar().key(t);e(Pr(r),r)}},remove:function(e){return Ar().removeItem(e)},clearAll:function(){return Ar().clear()}};function Ar(){return Sr.sessionStorage}function Pr(e){return Ar().getItem(e)}var xr=n({__proto__:null,default:Er},[Er]),Fr=tr.trim,Lr={name:"cookieStorage",read:function(e){if(!e||!Rr(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Tr.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;Tr.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Or,remove:kr,clearAll:function(){Or((function(e,t){kr(t)}))}},Tr=tr.Global.document;function Or(e){for(var t=Tr.cookie.split(/; ?/g),r=t.length-1;r>=0;r--)if(Fr(t[r])){var n=t[r].split("="),i=unescape(n[0]);e(unescape(n[1]),i)}}function kr(e){e&&Rr(e)&&(Tr.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Rr(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Tr.cookie)}var Cr=n({__proto__:null,default:Lr},[Lr]),jr={name:"memoryStorage",read:function(e){return Ir[e]},write:function(e,t){Ir[e]=t},each:function(e){for(var t in Ir)Ir.hasOwnProperty(t)&&e(Ir[t],t)},remove:function(e){delete Ir[e]},clearAll:function(e){Ir={}}},Ir={};var qr=n({__proto__:null,default:jr},[jr]);function Ur(e,t){void 0===t&&(t=!1),e+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],a=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,o=t?i:n,s=0;s<a.length;s++)r=new RegExp(a[s],"g"),e=e.replace(r,o[s]);return e.replace(t?"٫":".",t?".":"٫")}function Dr(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?Dr(e.replace(/\.(.+)\./g,".$1")):e}function Nr(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function Br(e){if(Nr(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 Mr(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 zr(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function Hr(e){return Nr(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):zr("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}function $r(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]=$r(e.slice(1),t,r[i]),r):i?((n={})[i]=$r(e.slice(1),t),n):""===i?[t]:t}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 Yr={digitsOnly:function(e){return Ur(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")?Dr(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:Ur,money:function(e){var t=Salla.config.currency(null==e?void 0:e.currency).symbol;return Ur(e="object"==typeof e?e.amount:e)+" "+t},setNested:function(e,t,r){for(var n=e,i=t.split("."),a=i.length,o=0;o<a-1;o++){var s=i[o];n[s]||(n[s]={}),n=n[s]}return n[i[a-1]]=r,e},getNested:function(e,t,r){var n=Et(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("[");return{name:n[0],value:$r(n.slice(1),t,r[n[0]])}}return{name:e,value:t}},url:Object.freeze({__proto__:null,is_full_url:Nr,base:function(e){return Nr(e)?e:"https://"+new URL(Br("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},get:Br,domain:function(e){return Nr(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},addParamToUrl:Mr,baseUrl:zr,asset:Hr,cdn:function(e){return"https://cdn.salla.network/"+(null==e?void 0:e.ltrim("/"))},api:function(e){var t;return(null===(t=Salla.config.get("store.api",Br("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return Hr(salla.config.get("theme.settings.placeholder"))===Hr(e)}}),addParamToUrl:Mr,debounce:function(e,t){t=t||100;var r,n=[];return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];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)}))}}},Gr=function(e,t){return Gr=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])},Gr(e,t)},Vr=function(){return Vr=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},Vr.apply(this,arguments)};function Wr(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;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 Qr,Jr,Kr,Xr=(Qr=console,Jr=[],Kr={log:function(e,t){if(Qr&&salla.config.isDebug()){Jr.push([t,e]),"trace"===salla.config.get("debug")&&(t="trace");var r=Qr.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;"],a={event:"#CFF680",backend:"#7b68ee"}[t];a&&(i[0]+="%c"+t[0].toUpperCase()+t.substring(1),i.push("margin-left: 5px;color: ".concat(a,";font-weight:bold; border:1px solid ").concat(a,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,Wr([Qr],i.concat.apply(i,e),!1))}},__dict__:{trace:Qr.trace,debug:Qr.debug,info:Qr.info,warn:Qr.warn,error:Qr.error}},{event:function(){Kr.log(arguments,"event")},trace:function(){Kr.log(arguments,"trace")},debug:function(){Kr.log(arguments,"debug")},info:function(){Kr.log(arguments,"info")},warn:function(){Kr.log(arguments,"warn")},error:function(){Kr.log(arguments,"error")},log:function(){Kr.log(arguments,void 0)},backend:function(){Kr.log(arguments,"backend")},logs:function(e){[e].flat().forEach((function(e){return e&&Kr.log([e].flat(),"backend")}))},history:function(){return Jr.map((function(e){return Qr.log.apply(Qr,Wr([e[0]],e[1],!1))})),Jr}}),Zr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=Vr(Vr({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=Vr(Vr({},this.properties_),e),this.properties_.store=Vr(Vr({},(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}(),en=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}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}Gr(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,Wr([e],t,!1))},t.prototype.emit=function(t){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var a=t.replace("::",".");if(!this.noneFireableActions.includes(a)&&Salla.call&&"function"==typeof Salla.call(a))return Salla.log("'Salla.".concat(a,"(...)' triggered using event '").concat(t,"'")),a=a.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[a[0]])[a[1]].apply(r,n);e.prototype.emit.apply(this,Wr([t],n,!1)),this.trackEvents.apply(this,Wr([t],n,!1))},t.prototype.emitAsync=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=e.prototype.emitAsync.apply(this,Wr([t],r,!1));try{this.trackEvents.apply(this,Wr([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=Vr(Vr({},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,Wr([e],r,!1)),this.dispatchMobileEvent.apply(this,Wr([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,Wr([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],a=n[1];this.dispatch(i,a)}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){if(void 0===t&&(t={}),!("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(void 0!==window.Android)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}},t}(Jt.EventEmitter2),tn=pr.createStore([_r,xr,Cr,qr],[]),rn=function(){function e(){var e=this;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=tn}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(){return this.store.clearAll()},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}(),nn=function(){function e(){var e=this;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()}return document.cookie="".concat(e,"=").concat(t).concat(n,'"; path=/; secure; SameSite=Lax"'),this},e.prototype.remove=function(e){return document.cookie="".concat(e,"=; Max-Age=0; path=/;"),this},e.prototype.clearAll=function(){for(var e=document.cookie.split(";"),t=0;t<e.length;t++){var r=e[t],n=r.indexOf("="),i=n>-1?r.substr(0,n):r;this.remove(i)}},e}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),void 0!==o&&(o.salla=o.salla||o.Salla||{},o.Salla=o.salla),Salla.status="base",Salla.config=new Zr,Salla.logger=Xr,Salla.event=new en,Salla.helpers=Yr,Salla.storage=new rn,Salla.cookie=new nn,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.12.46"};var an=Salla;let on=function(e,t,r){return alert(e)},sn=function(e,t){return on(e,ln.error,t)},ln={error:"error",success:"success",info:"info"};var cn={fire:function(e,t,r){return on(e,t,r)},setNotifier:function(e){on=e,salla.event.emit("twilight::notifier.changed")},error:sn,success:function(e,t){return on(e,ln.success,t)},info:function(e,t){return on(e,ln.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=>{sn(decodeURI(e.replace("?danger=","").replace("&danger=","")))}))})))},types:ln};class un{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 a=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,a);a[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(a)},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 a=window[i];if("function"==typeof a){if(!a(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return a(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 hn{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,!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 dn(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends hn{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))}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 hn{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",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"},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,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 hn{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"},this.after_init()}},Salla.event.scope=new class extends hn{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 hn{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 hn{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends hn{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 hn{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed"},this.after_init()}},Salla.event.loyalty=new class extends hn{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 hn{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"},this.after_init()}},Salla.event.profile=new class extends hn{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 hn{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 hn{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 hn{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 hn{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.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(dn(e),Object.keys(e).forEach((t=>{dn(e[t])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"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};var fn,pn={exports:{}},gn={exports:{}},vn=l(i),mn=l(a);function yn(){return fn||(fn=1,function(e){!function(t,r){e.exports?e.exports=r(t,vn,mn):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let n=e.jQuery,i={};function a(e,t){let o=r.getQueryElement(e);if(o){if((e=o).infiniteScrollGUID){let r=i[e.infiniteScrollGUID];return r.option(t),r}this.element=e,this.options={...a.defaults},this.option(t),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(o||e))}a.defaults={},a.create={},a.destroy={};let o=a.prototype;Object.assign(o,t.prototype);let s=0;o.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 a.create)a.create[e].call(this)}else console.error("Disabling InfiniteScroll")},o.option=function(e){Object.assign(this.options,e)},o.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},o.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 a=e+=".infiniteScroll";if(t){let r=n.Event(t);r.type=e,a=r}this.$element.trigger(a,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}`}};o.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)},o.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},o.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},o.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},o.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=a.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}}}};o.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:a,end:o}=n;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+o,this.pageIndex=parseInt(a,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},o.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()},a.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},o.destroy=function(){this.allOff();for(let e in a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},a.throttle=function(e,t){let r,n;return t=t||200,function(){let i=+new Date,a=arguments,o=()=>{r=i,e.apply(this,a)};r&&i<r+t?(clearTimeout(n),n=setTimeout(o,t)):o()}},a.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},a.setJQuery=function(e){n=e},r.htmlInit(a,"infinite-scroll"),o._init=function(){};let{jQueryBridget:h}=e;return n&&h&&h("infiniteScroll",a,n),a}))}(gn)),gn.exports}gn.exports;var wn,bn={exports:{}};function _n(){return wn||(wn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn()):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 a=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((a=>("text"==e&&t&&(a=n.parseFromString(a,"text/html")),204==r.status?(this.lastPageReached(a,i),{body:a,response:r}):this.onPageLoad(a,i,r))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,a]),a},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:a,domParseResponse:o}=this.options;if(!("text"==a&&o)||!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}))}(bn)),bn.exports}var Sn,En={exports:{}};function An(){return Sn||(Sn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):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}))}(En)),En.exports}var Pn,xn={exports:{}};function Fn(){return Pn||(Pn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):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],a=this.getElementScrollY(n);i.href=t,this.scrollPages.push({top:a,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}))}(xn)),xn.exports}var Ln,Tn={exports:{}};function On(){return Ln||(Ln=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):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}))}(Tn)),Tn.exports}var kn,Rn={exports:{}};function Cn(){return kn||(kn=1,function(e){!function(t,r){e.exports?e.exports=r(t,yn(),mn):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;function i(e){o(e,"none")}function a(e){o(e,"block")}function o(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){a(this.statusElement),this.hideStatusEventElements(),a(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}))}(Rn)),Rn.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
|
-
*/!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"},a=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return a.prototype.setMessages=function(e){this.messages=e},a.prototype.getLocale=function(){return this.locale||this.fallback},a.prototype.setLocale=function(e){this.locale=e},a.prototype.getFallback=function(){return this.fallback},a.prototype.setFallback=function(e){this.fallback=e},a.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},a.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)},a.prototype.trans=function(e,t){return this.get(e,t)},a.prototype.choice=function(e,t,r,i){(r=void 0!==r?r:{}).count=t;var a=this.get(e,r,i);if(null==a)return a;for(var o=a.split("|"),s=[],l=0;l<o.length;l++)if(o[l]=o[l].trim(),n.test(o[l])){var c=o[l].split(/\s/);s.push(c.shift()),o[l]=c.join(" ")}if(1===o.length)return a;for(var u=0;u<s.length;u++)if(this._testInterval(t,s[u]))return o[u];return i=i||this._getLocale(e),o[this._getPluralForm(t,i)]},a.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},a.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)}},a.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},a.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 a=r.slice(0,n+1).join("."),o=r.slice(n+1,r.length).join(".");if(e[a])return this._getValueInKey(e[a],o)}return e},a.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},a.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},a.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},a.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},a.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 a=(i=i.filter((function(e){return!!e})))[1],o=t(i[2]);o===1/0&&(o=-1/0);var s=t(i[3]),l=i[4];return("["===a?e>=o:e>o)&&("]"===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},a.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}},a}()}(In);var qn=In.exports;class Un{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 a=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 a&&"get"===r&&(t=t?Object.assign(t,a):a),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:a})}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 Dn extends Un{constructor(){super(),this.namespace="cart",this.endpoints={latest:"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"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",this.getCurrentCartId),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",(()=>this.getCurrentCartId(!0)),{async:!0}),salla.event.on("profile::info.fetched",this._checkCurrentCart)}_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())}async getCurrentCartId(e=!1){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 t=await salla.cart.api.latest();return salla.cart.api.latestCart=t.data,salla.cart.api.latestCart.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))}async details(e,t=[]){return e=e||await this.getCurrentCartId(),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){return this.addItem({id:e,quantity:t,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 this.getCurrentCartId();return this.request([r,n,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))}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 this.getCurrentCartId();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 this.getCurrentCartId();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 this.getCurrentCartId();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){return this.request(["status",e||await this.getCurrentCartId()],{params:{has_apple_pay:!!window.ApplePaySession}})}async submit(){this.status(await this.getCurrentCartId()).then((e=>{let t=e.data.next_step.to;if(!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===t)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw 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.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();return this.request(["addCoupon",t],{coupon:e}).then((function(e){return 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();return this.request(["deleteCoupon",e],{}).then((function(t){return 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 this.getCurrentCartId()]).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}))))}}class Nn extends Un{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())){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())){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 Bn extends Un{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.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),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);if(200!==n?.status)return salla.auth.event.verificationFailed(n,r),salla.api.errorPromise(n);let i="authenticated"===n.data?.case;return i&&salla.auth.event.tokenFetched(n.data.token),t&&await salla.auth.api.request("auth/jwt"),i&&salla.auth.event.loggedIn(n).then((()=>salla.auth.api.afterUserLogin())),await salla.auth.event.verified(n,r),salla.api.successPromise(n)}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),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 function(e){return salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}logout(e="twilight"){return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((()=>{let t=salla.url.get(`logout?from=${e}`);console.log(`Going to ${t}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=t}catch(e){salla.log(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)}}class Mn extends Un{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},this.endpointsMethods={createCartFromOrder:"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:!!window.ApplePaySession}}).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}))}}class zn extends Un{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",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products"},this.endpointsMethods={details:"get",giftDetail:"get",fetch:"get",offers:"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}))}getGiftDetails(e){return this.request(["giftDetail",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}))}addGiftToCart(e,t,r=!1){return this.request(["giftToCart",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"].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((e=>(salla.product.event.productListFetchSucceeded(e),e))).catch((e=>{throw salla.product.event.productListFetchFailed(e),e}))}}class Hn extends Un{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()}info(){return this.request("info",null,"get").then((e=>{let t={id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),salla.profile.event.infoFetched(e),e})).catch((e=>{throw salla.profile.event.infoNotFetched(e),e}))}update(e){return this.request("update",e).then((e=>(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.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e))).catch((e=>{throw salla.event.profile.notDeleted(e),e}))}}class $n extends Un{constructor(){super(),this.namespace="comment",this.endpoints={comments:"{type}/{id}/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(["comments",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){let t={};return["id","type","comment","per_page","page"].forEach((r=>{let n=salla.form.getPossibleValue(e,[r]);n&&(t[r]=n)})),t.id?t.type&&["products","pages","product","page"].includes(t.type)?(t.type+=["product","page"].includes(t.type)?"s":"",t):"Failed to get type one of:(products, product, page, pages)!":"Failed to get id!"}fetch(e){return"string"==typeof(e=this.getCommentPayload(e))?(salla.event.comment.fetchFailed(e),salla.api.errorPromise(e)):this.request(["comments",e.type,e.id],{params:e},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))}getPageComments(e,t=1,r=10){return this.fetch({id:e,type:"pages",page:t,per_page:r})}getProductComments(e,t=1,r=10){return this.fetch({id:e,type:"products",page:t,per_page:r})}}class Yn extends Un{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 Gn extends Un{constructor(){super(),this.namespace="document"}}class Vn extends Un{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 Wn extends Un{constructor(){super(),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}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 Qn extends Un{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 Jn extends Un{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 Kn extends Un{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}"},this.endpointsMethods={getDetails:"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}))}}var Xn,Zn={exports:{}},ei=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},ti=ei,ri=Object.prototype.toString,ni=(Xn=Object.create(null),function(e){var t=ri.call(e);return Xn[t]||(Xn[t]=t.slice(8,-1).toLowerCase())});function ii(e){return e=e.toLowerCase(),function(t){return ni(t)===e}}function ai(e){return Array.isArray(e)}function oi(e){return void 0===e}var si=ii("ArrayBuffer");function li(e){return null!==e&&"object"==typeof e}function ci(e){if("object"!==ni(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var ui=ii("Date"),hi=ii("File"),di=ii("Blob"),fi=ii("FileList");function pi(e){return"[object Function]"===ri.call(e)}var gi=ii("URLSearchParams");function vi(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),ai(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var mi,yi=(mi="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return mi&&e instanceof mi}),wi={isArray:ai,isArrayBuffer:si,isBuffer:function(e){return null!==e&&!oi(e)&&null!==e.constructor&&!oi(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||ri.call(e)===t||pi(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&si(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:li,isPlainObject:ci,isUndefined:oi,isDate:ui,isFile:hi,isBlob:di,isFunction:pi,isStream:function(e){return li(e)&&pi(e.pipe)},isURLSearchParams:gi,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:vi,merge:function e(){var t={};function r(r,n){ci(t[n])&&ci(r)?t[n]=e(t[n],r):ci(r)?t[n]=e({},r):ai(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)vi(arguments[n],r);return t},extend:function(e,t,r){return vi(t,(function(t,n){e[n]=r&&"function"==typeof t?ti(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r){var n,i,a,o={};t=t||{};do{for(i=(n=Object.getOwnPropertyNames(e)).length;i-- >0;)o[a=n[i]]||(t[a]=e[a],o[a]=!0);e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:ni,kindOfTest:ii,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;var t=e.length;if(oi(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:yi,isFileList:fi},bi=wi;function _i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Si=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(bi.isURLSearchParams(t))n=t.toString();else{var i=[];bi.forEach(t,(function(e,t){null!=e&&(bi.isArray(e)?t+="[]":e=[e],bi.forEach(e,(function(e){bi.isDate(e)?e=e.toISOString():bi.isObject(e)&&(e=JSON.stringify(e)),i.push(_i(t)+"="+_i(e))})))})),n=i.join("&")}if(n){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},Ei=wi;function Ai(){this.handlers=[]}Ai.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},Ai.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Ai.prototype.forEach=function(e){Ei.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Pi,xi,Fi=Ai,Li=wi;function Ti(){if(xi)return Pi;xi=1;var e=wi;function t(e,t,r,n,i){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}e.inherits(t,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:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var r=t.prototype,n={};return["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"].forEach((function(e){n[e]={value:e}})),Object.defineProperties(t,n),Object.defineProperty(r,"isAxiosError",{value:!0}),t.from=function(n,i,a,o,s,l){var c=Object.create(r);return e.toFlatObject(n,c,(function(e){return e!==Error.prototype})),t.call(c,n.message,i,a,o,s),c.name=n.name,l&&Object.assign(c,l),c},Pi=t}var Oi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ki=[],Ri=[],Ci="undefined"!=typeof Uint8Array?Uint8Array:Array,ji=!1;function Ii(){ji=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)ki[t]=e[t],Ri[e.charCodeAt(t)]=t;Ri["-".charCodeAt(0)]=62,Ri["_".charCodeAt(0)]=63}function qi(e,t,r){for(var n,i,a=[],o=t;o<r;o+=3)n=(e[o]<<16)+(e[o+1]<<8)+e[o+2],a.push(ki[(i=n)>>18&63]+ki[i>>12&63]+ki[i>>6&63]+ki[63&i]);return a.join("")}function Ui(e){var t;ji||Ii();for(var r=e.length,n=r%3,i="",a=[],o=16383,s=0,l=r-n;s<l;s+=o)a.push(qi(e,s,s+o>l?l:s+o));return 1===n?(t=e[r-1],i+=ki[t>>2],i+=ki[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=ki[t>>10],i+=ki[t>>4&63],i+=ki[t<<2&63],i+="="),a.push(i),a.join("")}function Di(e,t,r,n,i){var a,o,s=8*i-n-1,l=(1<<s)-1,c=l>>1,u=-7,h=r?i-1:0,d=r?-1:1,f=e[t+h];for(h+=d,a=f&(1<<-u)-1,f>>=-u,u+=s;u>0;a=256*a+e[t+h],h+=d,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+e[t+h],h+=d,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),a-=c}return(f?-1:1)*o*Math.pow(2,a-n)}function Ni(e,t,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<<c)-1,h=u>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-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,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(t*l-1)*Math.pow(2,i),o+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+f]=255&s,f+=p,s/=256,i-=8);for(o=o<<i|s,c+=i;c>0;e[r+f]=255&o,f+=p,o/=256,c-=8);e[r+f-p]|=128*g}var Bi={}.toString,Mi=Array.isArray||function(e){return"[object Array]"==Bi.call(e)};function zi(){return $i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Hi(e,t){if(zi()<t)throw new RangeError("Invalid typed array length");return $i.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=$i.prototype:(null===e&&(e=new $i(t)),e.length=t),e}function $i(e,t,r){if(!($i.TYPED_ARRAY_SUPPORT||this instanceof $i))return new $i(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 Vi(this,e)}return Yi(this,e,t,r)}function Yi(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);$i.TYPED_ARRAY_SUPPORT?(e=t).__proto__=$i.prototype:e=Wi(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!$i.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Ki(t,r);e=Hi(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(Ji(t)){var r=0|Qi(t.length);return 0===(e=Hi(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?Hi(e,0):Wi(e,t);if("Buffer"===t.type&&Mi(t.data))return Wi(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Gi(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 Vi(e,t){if(Gi(t),e=Hi(e,t<0?0:0|Qi(t)),!$i.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function Wi(e,t){var r=t.length<0?0:0|Qi(t.length);e=Hi(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function Qi(e){if(e>=zi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+zi().toString(16)+" bytes");return 0|e}function Ji(e){return!(null==e||!e._isBuffer)}function Ki(e,t){if(Ji(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 Oa(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ka(e).length;default:if(n)return Oa(e).length;t=(""+t).toLowerCase(),n=!0}}function Xi(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 fa(this,t,r);case"utf8":case"utf-8":return ca(this,t,r);case"ascii":return ha(this,t,r);case"latin1":case"binary":return da(this,t,r);case"base64":return la(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pa(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Zi(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function ea(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=$i.from(t,n)),Ji(t))return 0===t.length?-1:ta(e,t,r,n,i);if("number"==typeof t)return t&=255,$i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ta(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ta(e,t,r,n,i){var a,o=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;o=2,s/=2,l/=2,r/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var u=-1;for(a=r;a<s;a++)if(c(e,a)===c(t,-1===u?0:a-u)){if(-1===u&&(u=a),a-u+1===l)return u*o}else-1!==u&&(a-=a-u),u=-1}else for(r+l>s&&(r=s-l),a=r;a>=0;a--){for(var h=!0,d=0;d<l;d++)if(c(e,a+d)!==c(t,d)){h=!1;break}if(h)return a}return-1}function ra(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o<n;++o){var s=parseInt(t.substr(2*o,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function na(e,t,r,n){return Ra(Oa(t,e.length-r),e,r,n)}function ia(e,t,r,n){return Ra(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function aa(e,t,r,n){return ia(e,t,r,n)}function oa(e,t,r,n){return Ra(ka(t),e,r,n)}function sa(e,t,r,n){return Ra(function(e,t){for(var r,n,i,a=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i=r%256,a.push(i),a.push(n);return a}(t,e.length-r),e,r,n)}function la(e,t,r){return 0===t&&r===e.length?Ui(e):Ui(e.slice(t,r))}function ca(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var a,o,s,l,c=e[i],u=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(u=c);break;case 2:128==(192&(a=e[i+1]))&&(l=(31&c)<<6|63&a)>127&&(u=l);break;case 3:a=e[i+1],o=e[i+2],128==(192&a)&&128==(192&o)&&(l=(15&c)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=e[i+1],o=e[i+2],s=e[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&c)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=h}return function(e){var t=e.length;if(t<=ua)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ua));return r}(n)}$i.TYPED_ARRAY_SUPPORT=void 0===global.TYPED_ARRAY_SUPPORT||global.TYPED_ARRAY_SUPPORT,zi(),$i.poolSize=8192,$i._augment=function(e){return e.__proto__=$i.prototype,e},$i.from=function(e,t,r){return Yi(null,e,t,r)},$i.TYPED_ARRAY_SUPPORT&&($i.prototype.__proto__=Uint8Array.prototype,$i.__proto__=Uint8Array),$i.alloc=function(e,t,r){return function(e,t,r,n){return Gi(t),t<=0?Hi(e,t):void 0!==r?"string"==typeof n?Hi(e,t).fill(r,n):Hi(e,t).fill(r):Hi(e,t)}(null,e,t,r)},$i.allocUnsafe=function(e){return Vi(null,e)},$i.allocUnsafeSlow=function(e){return Vi(null,e)},$i.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Ca(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Ca(e.slice(0,0))}(e))},$i.compare=function(e,t){if(!Ji(e)||!Ji(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i<a;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},$i.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}},$i.concat=function(e,t){if(!Mi(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return $i.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=$i.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var a=e[r];if(!Ji(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,i),i+=a.length}return n},$i.byteLength=Ki,$i.prototype._isBuffer=!0,$i.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)Zi(this,t,t+1);return this},$i.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)Zi(this,t,t+3),Zi(this,t+1,t+2);return this},$i.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)Zi(this,t,t+7),Zi(this,t+1,t+6),Zi(this,t+2,t+5),Zi(this,t+3,t+4);return this},$i.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?ca(this,0,e):Xi.apply(this,arguments)},$i.prototype.equals=function(e){if(!Ji(e))throw new TypeError("Argument must be a Buffer");return this===e||0===$i.compare(this,e)},$i.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+">"},$i.prototype.compare=function(e,t,r,n,i){if(!Ji(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 a=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),s=Math.min(a,o),l=this.slice(n,i),c=e.slice(t,r),u=0;u<s;++u)if(l[u]!==c[u]){a=l[u],o=c[u];break}return a<o?-1:o<a?1:0},$i.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},$i.prototype.indexOf=function(e,t,r){return ea(this,e,t,r,!0)},$i.prototype.lastIndexOf=function(e,t,r){return ea(this,e,t,r,!1)},$i.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 a=!1;;)switch(n){case"hex":return ra(this,e,t,r);case"utf8":case"utf-8":return na(this,e,t,r);case"ascii":return ia(this,e,t,r);case"latin1":case"binary":return aa(this,e,t,r);case"base64":return oa(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sa(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},$i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ua=4096;function ha(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 da(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 fa(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",a=t;a<r;++a)i+=Ta(e[a]);return i}function pa(e,t,r){for(var n=e.slice(t,r),i="",a=0;a<n.length;a+=2)i+=String.fromCharCode(n[a]+256*n[a+1]);return i}function ga(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 va(e,t,r,n,i,a){if(!Ji(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function ma(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i<a;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function ya(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i<a;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function wa(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ba(e,t,r,n,i){return i||wa(e,0,r,4),Ni(e,t,r,n,23,4),r+4}function _a(e,t,r,n,i){return i||wa(e,0,r,8),Ni(e,t,r,n,52,8),r+8}$i.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),$i.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=$i.prototype;else{var i=t-e;r=new $i(i,void 0);for(var a=0;a<i;++a)r[a]=this[a+e]}return r},$i.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return n},$i.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},$i.prototype.readUInt8=function(e,t){return t||ga(e,1,this.length),this[e]},$i.prototype.readUInt16LE=function(e,t){return t||ga(e,2,this.length),this[e]|this[e+1]<<8},$i.prototype.readUInt16BE=function(e,t){return t||ga(e,2,this.length),this[e]<<8|this[e+1]},$i.prototype.readUInt32LE=function(e,t){return t||ga(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},$i.prototype.readUInt32BE=function(e,t){return t||ga(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},$i.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},$i.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},$i.prototype.readInt8=function(e,t){return t||ga(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},$i.prototype.readInt16LE=function(e,t){t||ga(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},$i.prototype.readInt16BE=function(e,t){t||ga(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},$i.prototype.readInt32LE=function(e,t){return t||ga(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},$i.prototype.readInt32BE=function(e,t){return t||ga(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},$i.prototype.readFloatLE=function(e,t){return t||ga(e,4,this.length),Di(this,e,!0,23,4)},$i.prototype.readFloatBE=function(e,t){return t||ga(e,4,this.length),Di(this,e,!1,23,4)},$i.prototype.readDoubleLE=function(e,t){return t||ga(e,8,this.length),Di(this,e,!0,52,8)},$i.prototype.readDoubleBE=function(e,t){return t||ga(e,8,this.length),Di(this,e,!1,52,8)},$i.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||va(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[t]=255&e;++a<r&&(i*=256);)this[t+a]=e/i&255;return t+r},$i.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||va(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,a=1;for(this[t+i]=255&e;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+r},$i.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,1,255,0),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},$i.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ma(this,e,t,!0),t+2},$i.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ma(this,e,t,!1),t+2},$i.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ya(this,e,t,!0),t+4},$i.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ya(this,e,t,!1),t+4},$i.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);va(this,e,t,r,i-1,-i)}var a=0,o=1,s=0;for(this[t]=255&e;++a<r&&(o*=256);)e<0&&0===s&&0!==this[t+a-1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},$i.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);va(this,e,t,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},$i.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,1,127,-128),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},$i.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ma(this,e,t,!0),t+2},$i.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ma(this,e,t,!1),t+2},$i.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,2147483647,-2147483648),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ya(this,e,t,!0),t+4},$i.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ya(this,e,t,!1),t+4},$i.prototype.writeFloatLE=function(e,t,r){return ba(this,e,t,!0,r)},$i.prototype.writeFloatBE=function(e,t,r){return ba(this,e,t,!1,r)},$i.prototype.writeDoubleLE=function(e,t,r){return _a(this,e,t,!0,r)},$i.prototype.writeDoubleBE=function(e,t,r){return _a(this,e,t,!1,r)},$i.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,a=n-r;if(this===e&&r<t&&t<n)for(i=a-1;i>=0;--i)e[i+t]=this[i+r];else if(a<1e3||!$i.TYPED_ARRAY_SUPPORT)for(i=0;i<a;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+a),t);return a},$i.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&&!$i.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 a;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{var o=Ji(e)?e:Oa(new $i(e,n).toString()),s=o.length;for(a=0;a<r-t;++a)this[a+t]=o[a%s]}return this};var Sa,Ea,Aa,Pa,xa,Fa,La=/[^+\/0-9A-Za-z-_]/g;function Ta(e){return e<16?"0"+e.toString(16):e.toString(16)}function Oa(e,t){var r;t=t||1/0;for(var n=e.length,i=null,a=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.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;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function ka(e){return function(e){var t,r,n,i,a,o;ji||Ii();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===e[s-2]?2:"="===e[s-1]?1:0,o=new Ci(3*s/4-a),n=a>0?s-4:s;var l=0;for(t=0,r=0;t<n;t+=4,r+=3)i=Ri[e.charCodeAt(t)]<<18|Ri[e.charCodeAt(t+1)]<<12|Ri[e.charCodeAt(t+2)]<<6|Ri[e.charCodeAt(t+3)],o[l++]=i>>16&255,o[l++]=i>>8&255,o[l++]=255&i;return 2===a?(i=Ri[e.charCodeAt(t)]<<2|Ri[e.charCodeAt(t+1)]>>4,o[l++]=255&i):1===a&&(i=Ri[e.charCodeAt(t)]<<10|Ri[e.charCodeAt(t+1)]<<4|Ri[e.charCodeAt(t+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(La,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ra(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 Ca(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function ja(){if(Ea)return Sa;Ea=1;var e=wi;return Sa=function(t,r){r=r||new FormData;var n=[];function i(t){return null===t?"":e.isDate(t)?t.toISOString():e.isArrayBuffer(t)||e.isTypedArray(t)?"function"==typeof Blob?new Blob([t]):$i.from(t):t}return function t(a,o){if(e.isPlainObject(a)||e.isArray(a)){if(-1!==n.indexOf(a))throw Error("Circular reference detected in "+o);n.push(a),e.forEach(a,(function(n,a){if(!e.isUndefined(n)){var s,l=o?o+"."+a:a;if(n&&!o&&"object"==typeof n)if(e.endsWith(a,"{}"))n=JSON.stringify(n);else if(e.endsWith(a,"[]")&&(s=e.toArray(n)))return void s.forEach((function(t){!e.isUndefined(t)&&r.append(l,i(t))}));t(n,l)}})),n.pop()}else r.append(o,i(a))}(t),r},Sa}function Ia(){if(Pa)return Aa;Pa=1;var e=Ti();return Aa=function(t,r,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?r(new e("Request failed with status code "+n.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}}function qa(){if(Fa)return xa;Fa=1;var e=wi;return xa=e.isStandardBrowserEnv()?{write:function(t,r,n,i,a,o){var s=[];s.push(t+"="+encodeURIComponent(r)),e.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),e.isString(i)&&s.push("path="+i),e.isString(a)&&s.push("domain="+a),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}}var Ua,Da,Na,Ba,Ma,za,Ha,$a,Ya,Ga,Va,Wa,Qa=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},Ja=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Ka=function(e,t){return e&&!Qa(t)?Ja(e,t):t};function Xa(){if(Da)return Ua;Da=1;var e=wi,t=["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"];return Ua=function(r){var n,i,a,o={};return r?(e.forEach(r.split("\n"),(function(r){if(a=r.indexOf(":"),n=e.trim(r.substr(0,a)).toLowerCase(),i=e.trim(r.substr(a+1)),n){if(o[n]&&t.indexOf(n)>=0)return;o[n]="set-cookie"===n?(o[n]?o[n]:[]).concat([i]):o[n]?o[n]+", "+i:i}})),o):o},Ua}function Za(){if(Ba)return Na;Ba=1;var e=wi;return Na=e.isStandardBrowserEnv()?function(){var t,r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var t=e;return r&&(n.setAttribute("href",t),t=n.href),n.setAttribute("href",t),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=i(window.location.href),function(r){var n=e.isString(r)?i(r):r;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}}function eo(){if(za)return Ma;za=1;var e=Ti();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return wi.inherits(t,e,{__CANCEL__:!0}),Ma=t}function to(){return $a?Ha:($a=1,Ha=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function ro(){if(Ga)return Ya;Ga=1;var e=wi,t=Ia(),r=qa(),n=Si,i=Ka,a=Xa(),o=Za(),s=Oi,l=Ti(),c=eo(),u=to();return Ya=function(h){return new Promise((function(d,f){var p,g=h.data,v=h.headers,m=h.responseType;function y(){h.cancelToken&&h.cancelToken.unsubscribe(p),h.signal&&h.signal.removeEventListener("abort",p)}e.isFormData(g)&&e.isStandardBrowserEnv()&&delete v["Content-Type"];var w=new XMLHttpRequest;if(h.auth){var b=h.auth.username||"",_=h.auth.password?unescape(encodeURIComponent(h.auth.password)):"";v.Authorization="Basic "+btoa(b+":"+_)}var S=i(h.baseURL,h.url);function E(){if(w){var e="getAllResponseHeaders"in w?a(w.getAllResponseHeaders()):null,r={data:m&&"text"!==m&&"json"!==m?w.response:w.responseText,status:w.status,statusText:w.statusText,headers:e,config:h,request:w};t((function(e){d(e),y()}),(function(e){f(e),y()}),r),w=null}}if(w.open(h.method.toUpperCase(),n(S,h.params,h.paramsSerializer),!0),w.timeout=h.timeout,"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){w&&4===w.readyState&&(0!==w.status||w.responseURL&&0===w.responseURL.indexOf("file:"))&&setTimeout(E)},w.onabort=function(){w&&(f(new l("Request aborted",l.ECONNABORTED,h,w)),w=null)},w.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,h,w,w)),w=null},w.ontimeout=function(){var e=h.timeout?"timeout of "+h.timeout+"ms exceeded":"timeout exceeded",t=h.transitional||s;h.timeoutErrorMessage&&(e=h.timeoutErrorMessage),f(new l(e,t.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,h,w)),w=null},e.isStandardBrowserEnv()){var A=(h.withCredentials||o(S))&&h.xsrfCookieName?r.read(h.xsrfCookieName):void 0;A&&(v[h.xsrfHeaderName]=A)}"setRequestHeader"in w&&e.forEach(v,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete v[t]:w.setRequestHeader(t,e)})),e.isUndefined(h.withCredentials)||(w.withCredentials=!!h.withCredentials),m&&"json"!==m&&(w.responseType=h.responseType),"function"==typeof h.onDownloadProgress&&w.addEventListener("progress",h.onDownloadProgress),"function"==typeof h.onUploadProgress&&w.upload&&w.upload.addEventListener("progress",h.onUploadProgress),(h.cancelToken||h.signal)&&(p=function(e){w&&(f(!e||e&&e.type?new c:e),w.abort(),w=null)},h.cancelToken&&h.cancelToken.subscribe(p),h.signal&&(h.signal.aborted?p():h.signal.addEventListener("abort",p))),g||(g=null);var P=u(S);P&&-1===["http","https","file"].indexOf(P)?f(new l("Unsupported protocol "+P+":",l.ERR_BAD_REQUEST,h)):w.send(g)}))},Ya}var no=wi,io=function(e,t){Li.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},ao=Ti(),oo=Oi,so=ja(),lo={"Content-Type":"application/x-www-form-urlencoded"};function co(e,t){!no.isUndefined(e)&&no.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var uo,ho={transitional:oo,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==Wt&&"[object process]"===Object.prototype.toString.call(Wt))&&(uo=ro()),uo),transformRequest:[function(e,t){if(io(t,"Accept"),io(t,"Content-Type"),no.isFormData(e)||no.isArrayBuffer(e)||no.isBuffer(e)||no.isStream(e)||no.isFile(e)||no.isBlob(e))return e;if(no.isArrayBufferView(e))return e.buffer;if(no.isURLSearchParams(e))return co(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var r,n=no.isObject(e),i=t&&t["Content-Type"];if((r=no.isFileList(e))||n&&"multipart/form-data"===i){var a=this.env&&this.env.FormData;return so(r?{"files[]":e}:e,a&&new a)}return n||"application/json"===i?(co(t,"application/json"),function(e,t,r){if(no.isString(e))try{return(t||JSON.parse)(e),no.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||ho.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&no.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw ao.from(e,ao.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:Wa?Va:(Wa=1,Va=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};no.forEach(["delete","get","head"],(function(e){ho.headers[e]={}})),no.forEach(["post","put","patch"],(function(e){ho.headers[e]=no.merge(lo)}));var fo,po,go=ho,vo=wi,mo=go;function yo(){return po?fo:(po=1,fo=function(e){return!(!e||!e.__CANCEL__)})}var wo=wi,bo=function(e,t,r){var n=this||mo;return vo.forEach(r,(function(r){e=r.call(n,e,t)})),e},_o=yo(),So=go,Eo=eo();function Ao(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Eo}var Po,xo,Fo=wi,Lo=function(e,t){t=t||{};var r={};function n(e,t){return Fo.isPlainObject(e)&&Fo.isPlainObject(t)?Fo.merge(e,t):Fo.isPlainObject(t)?Fo.merge({},t):Fo.isArray(t)?t.slice():t}function i(r){return Fo.isUndefined(t[r])?Fo.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function a(e){if(!Fo.isUndefined(t[e]))return n(void 0,t[e])}function o(r){return Fo.isUndefined(t[r])?Fo.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function s(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var l={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s};return Fo.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||i,n=t(e);Fo.isUndefined(n)&&t!==s||(r[e]=n)})),r};function To(){return xo?Po:(xo=1,Po={version:"0.27.2"})}var Oo=To().version,ko=Ti(),Ro={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Ro[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Co={};Ro.transitional=function(e,t,r){function n(e,t){return"[Axios v"+Oo+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,i,a){if(!1===e)throw new ko(n(i," has been removed"+(t?" in "+t:"")),ko.ERR_DEPRECATED);return t&&!Co[i]&&(Co[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}};var jo,Io,qo,Uo,Do,No,Bo={assertOptions:function(e,t,r){if("object"!=typeof e)throw new ko("options must be an object",ko.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),i=n.length;i-- >0;){var a=n[i],o=t[a];if(o){var s=e[a],l=void 0===s||o(s,a,e);if(!0!==l)throw new ko("option "+a+" must be "+l,ko.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new ko("Unknown option "+a,ko.ERR_BAD_OPTION)}},validators:Ro},Mo=wi,zo=Si,Ho=Fi,$o=function(e){return Ao(e),e.headers=e.headers||{},e.data=bo.call(e,e.data,e.headers,e.transformRequest),e.headers=wo.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),wo.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||So.adapter)(e).then((function(t){return Ao(e),t.data=bo.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return _o(t)||(Ao(e),t&&t.response&&(t.response.data=bo.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Yo=Lo,Go=Ka,Vo=Bo,Wo=Vo.validators;function Qo(e){this.defaults=e,this.interceptors={request:new Ho,response:new Ho}}Qo.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=Yo(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&Vo.assertOptions(r,{silentJSONParsing:Wo.transitional(Wo.boolean),forcedJSONParsing:Wo.transitional(Wo.boolean),clarifyTimeoutError:Wo.transitional(Wo.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var a,o=[];if(this.interceptors.response.forEach((function(e){o.push(e.fulfilled,e.rejected)})),!i){var s=[$o,void 0];for(Array.prototype.unshift.apply(s,n),s=s.concat(o),a=Promise.resolve(t);s.length;)a=a.then(s.shift(),s.shift());return a}for(var l=t;n.length;){var c=n.shift(),u=n.shift();try{l=c(l)}catch(e){u(e);break}}try{a=$o(l)}catch(e){return Promise.reject(e)}for(;o.length;)a=a.then(o.shift(),o.shift());return a},Qo.prototype.getUri=function(e){e=Yo(this.defaults,e);var t=Go(e.baseURL,e.url);return zo(t,e.params,e.paramsSerializer)},Mo.forEach(["delete","get","head","options"],(function(e){Qo.prototype[e]=function(t,r){return this.request(Yo(r||{},{method:e,url:t,data:(r||{}).data}))}})),Mo.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(Yo(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Qo.prototype[e]=t(),Qo.prototype[e+"Form"]=t(!0)}));var Jo=wi,Ko=ei,Xo=Qo,Zo=Lo;var es=function e(t){var r=new Xo(t),n=Ko(Xo.prototype.request,r);return Jo.extend(n,Xo.prototype,r),Jo.extend(n,r),n.create=function(r){return e(Zo(t,r))},n}(go);es.Axios=Xo,es.CanceledError=eo(),es.CancelToken=function(){if(Io)return jo;Io=1;var e=eo();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(e){r=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},t((function(t){n.reason||(n.reason=new e(t),r(n.reason))}))}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},t.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},t.source=function(){var e,r=new t((function(t){e=t}));return{token:r,cancel:e}},jo=t}(),es.isCancel=yo(),es.VERSION=To().version,es.toFormData=ja(),es.AxiosError=Ti(),es.Cancel=es.CanceledError,es.all=function(e){return Promise.all(e)},es.spread=Uo?qo:(Uo=1,qo=function(e){return function(t){return e.apply(null,t)}}),es.isAxiosError=function(){if(No)return Do;No=1;var e=wi;return Do=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),Zn.exports=es,Zn.exports.default=es;var ts=Zn.exports;function rs(e){this.message=e}rs.prototype=new Error,rs.prototype.name="InvalidCharacterError";var ns="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new rs("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,a=0,o="";n=t.charAt(a++);~n&&(r=i%4?64*r+n:n,i++%4)?o+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return o};function is(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(ns(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return ns(t)}}function as(e){this.message=e}as.prototype=new Error,as.prototype.name="InvalidTokenError";class os{constructor(){salla.event.on("twilight::before.ready",(e=>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.setToken(e)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=ts.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser","cache-control":"no-cache",pragma:"no-cache"}}})}getHeaders(){return this.axios.defaults.headers.common}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});let t=salla.storage.get("scope");t&&this.setHeaders({"s-scope-type":t.type,"s-scope-id":t.id}),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=e.user?.id,i=salla.storage.get("user.id"),a=e=>{this.setToken(e),salla.event.emit("api::initiated")},o=async()=>{!r&&n?(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()))):salla.auth.event.tokenInvalid()};if(!t)return salla.log("Api:: case 1 => current is is guest"),void await o();let s=function(e,t){if("string"!=typeof e)throw new as("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(is(e.split(".")[r]))}catch(e){throw new as("Invalid token specified: "+e.message)}}(t);return Date.now()/1e3>s.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await o()):s.sub===n&&i===n&&i&&n?(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void a(t)):(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),this.setHeader("Authorization","Bearer "+t),void await salla.profile.info().then((async e=>{await salla.auth.api.request("auth/jwt"),a(t)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()})))}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},a="undefined"!=typeof event?event.currentTarget:null,o=!1;return"SALLA-BUTTON"===a?.tagName&&(o=!0),o&&a?.load(),this.axios[i.method](i.endPoint,i.payload,i.options).then((e=>(o&&a?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw o&&a?.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 ss{constructor(e){"ready"!==an.status?e?(an.config.merge(e),e?.events&&an.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}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.is_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")))))}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){an.event.dispatch("twilight::before.ready",e),an.status="ready",an.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))}}return an.status="loading",an.notify=cn,an.lang=new class extends qn{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){if(this.translationsLoaded)return e();Salla.event.once("languages::translations.loaded",e)}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}},an.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}},an.infiniteScroll=new class extends un{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"}},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),a=r.path;if(!i||!a||"string"==typeof a&&!document.querySelector(a))return void Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let o=new jn(i,r);return o.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),o.on("request",Salla.infiniteScroll.event.request),o.on("load",Salla.infiniteScroll.event.load),o.on("append",Salla.infiniteScroll.event.append),o.on("error",Salla.infiniteScroll.event.error),o.on("last",Salla.infiniteScroll.event.last),o.on("history",Salla.infiniteScroll.event.history),this.instances.push(o),o}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),an.api=new class extends os{constructor(){super(),this.auth=new Bn,this.cart=new Dn,this.loyalty=new Nn,this.order=new Mn,this.rating=new Vn,this.product=new zn,this.profile=new Hn,this.comment=new $n,this.currency=new Yn,this.document=new Gn,this.wishlist=new Wn,this.scope=new Qn,this.booking=new Jn,this.landing=new Kn}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((e=>an[e]=new un(an.api[e],an.event[e]))),an.call=e=>{let t=an,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},an.init=e=>new ss(e),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),an.success=an.notify.success,an.error=an.notify.error,an.versions.twilight="2.12.43",an.onInitiated=e=>salla.event.once("twilight::initiated",e),an.onReady=an.onReady||function(e){"ready"!==salla.status?an.onInitiated(e):e(salla.config.all())},window.dispatchEvent(new CustomEvent("salla::created")),an}));
|
|
19
|
+
*/!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"},a=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return a.prototype.setMessages=function(e){this.messages=e},a.prototype.getLocale=function(){return this.locale||this.fallback},a.prototype.setLocale=function(e){this.locale=e},a.prototype.getFallback=function(){return this.fallback},a.prototype.setFallback=function(e){this.fallback=e},a.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},a.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)},a.prototype.trans=function(e,t){return this.get(e,t)},a.prototype.choice=function(e,t,r,i){(r=void 0!==r?r:{}).count=t;var a=this.get(e,r,i);if(null==a)return a;for(var o=a.split("|"),s=[],l=0;l<o.length;l++)if(o[l]=o[l].trim(),n.test(o[l])){var c=o[l].split(/\s/);s.push(c.shift()),o[l]=c.join(" ")}if(1===o.length)return a;for(var u=0;u<s.length;u++)if(this._testInterval(t,s[u]))return o[u];return i=i||this._getLocale(e),o[this._getPluralForm(t,i)]},a.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},a.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)}},a.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},a.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 a=r.slice(0,n+1).join("."),o=r.slice(n+1,r.length).join(".");if(e[a])return this._getValueInKey(e[a],o)}return e},a.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},a.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},a.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},a.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},a.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 a=(i=i.filter((function(e){return!!e})))[1],o=t(i[2]);o===1/0&&(o=-1/0);var s=t(i[3]),l=i[4];return("["===a?e>=o:e>o)&&("]"===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},a.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}},a}()}(In);var qn=In.exports;class Un{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 a=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 a&&"get"===r&&(t=t?Object.assign(t,a):a),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:a})}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 Dn extends Un{constructor(){super(),this.namespace="cart",this.endpoints={latest:"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"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",this.getCurrentCartId),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",(()=>this.getCurrentCartId(!0)),{async:!0}),salla.event.on("profile::info.fetched",this._checkCurrentCart)}_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())}async getCurrentCartId(e=!1){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 t=await salla.cart.api.latest();return salla.cart.api.latestCart=t.data,salla.cart.api.latestCart.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))}async details(e,t=[]){return e=e||await this.getCurrentCartId(),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){return this.addItem({id:e,quantity:t,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 this.getCurrentCartId();return this.request([r,n,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))}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 this.getCurrentCartId();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 this.getCurrentCartId();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 this.getCurrentCartId();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){return this.request(["status",e||await this.getCurrentCartId()],{params:{has_apple_pay:!!window.ApplePaySession}})}async submit(){this.status(await this.getCurrentCartId()).then((e=>{let t=e.data.next_step.to;if(!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===t)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw 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.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();return this.request(["addCoupon",t],{coupon:e}).then((function(e){return 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();return this.request(["deleteCoupon",e],{}).then((function(t){return 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 this.getCurrentCartId()]).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}))))}}class Nn extends Un{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())){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())){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 Bn extends Un{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.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),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);if(200!==n?.status)return salla.auth.event.verificationFailed(n,r),salla.api.errorPromise(n);let i="authenticated"===n.data?.case;return i&&salla.auth.event.tokenFetched(n.data.token),t&&await salla.auth.api.request("auth/jwt"),i&&salla.auth.event.loggedIn(n).then((()=>salla.auth.api.afterUserLogin())),await salla.auth.event.verified(n,r),salla.api.successPromise(n)}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),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 function(e){return salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}logout(e="twilight"){return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((()=>{let t=salla.url.get(`logout?from=${e}`);console.log(`Going to ${t}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=t}catch(e){salla.log(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)}}class Mn extends Un{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},this.endpointsMethods={createCartFromOrder:"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:!!window.ApplePaySession}}).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}))}}class zn extends Un{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",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products"},this.endpointsMethods={details:"get",giftDetail:"get",fetch:"get",offers:"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}))}getGiftDetails(e){return this.request(["giftDetail",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}))}addGiftToCart(e,t,r=!1){return this.request(["giftToCart",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"].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((e=>(salla.product.event.productListFetchSucceeded(e),e))).catch((e=>{throw salla.product.event.productListFetchFailed(e),e}))}}class Hn extends Un{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()}info(){return this.request("info",null,"get").then((e=>{let t={id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),salla.profile.event.infoFetched(e),e})).catch((e=>{throw salla.profile.event.infoNotFetched(e),e}))}update(e){return this.request("update",e).then((e=>(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.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e))).catch((e=>{throw salla.event.profile.notDeleted(e),e}))}}class $n extends Un{constructor(){super(),this.namespace="comment",this.endpoints={comments:"{type}/{id}/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(["comments",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){let t={};return["id","type","comment","per_page","page"].forEach((r=>{let n=salla.form.getPossibleValue(e,[r]);n&&(t[r]=n)})),t.id?t.type&&["products","pages","product","page"].includes(t.type)?(t.type+=["product","page"].includes(t.type)?"s":"",t):"Failed to get type one of:(products, product, page, pages)!":"Failed to get id!"}fetch(e){return"string"==typeof(e=this.getCommentPayload(e))?(salla.event.comment.fetchFailed(e),salla.api.errorPromise(e)):this.request(["comments",e.type,e.id],{params:e},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))}getPageComments(e,t=1,r=10){return this.fetch({id:e,type:"pages",page:t,per_page:r})}getProductComments(e,t=1,r=10){return this.fetch({id:e,type:"products",page:t,per_page:r})}}class Yn extends Un{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 Gn extends Un{constructor(){super(),this.namespace="document"}}class Vn extends Un{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 Wn extends Un{constructor(){super(),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}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 Qn extends Un{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 Jn extends Un{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 Kn extends Un{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}"},this.endpointsMethods={getDetails:"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}))}}var Xn,Zn={exports:{}},ei=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},ti=ei,ri=Object.prototype.toString,ni=(Xn=Object.create(null),function(e){var t=ri.call(e);return Xn[t]||(Xn[t]=t.slice(8,-1).toLowerCase())});function ii(e){return e=e.toLowerCase(),function(t){return ni(t)===e}}function ai(e){return Array.isArray(e)}function oi(e){return void 0===e}var si=ii("ArrayBuffer");function li(e){return null!==e&&"object"==typeof e}function ci(e){if("object"!==ni(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var ui=ii("Date"),hi=ii("File"),di=ii("Blob"),fi=ii("FileList");function pi(e){return"[object Function]"===ri.call(e)}var gi=ii("URLSearchParams");function vi(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),ai(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var mi,yi=(mi="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return mi&&e instanceof mi}),wi={isArray:ai,isArrayBuffer:si,isBuffer:function(e){return null!==e&&!oi(e)&&null!==e.constructor&&!oi(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||ri.call(e)===t||pi(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&si(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:li,isPlainObject:ci,isUndefined:oi,isDate:ui,isFile:hi,isBlob:di,isFunction:pi,isStream:function(e){return li(e)&&pi(e.pipe)},isURLSearchParams:gi,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:vi,merge:function e(){var t={};function r(r,n){ci(t[n])&&ci(r)?t[n]=e(t[n],r):ci(r)?t[n]=e({},r):ai(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)vi(arguments[n],r);return t},extend:function(e,t,r){return vi(t,(function(t,n){e[n]=r&&"function"==typeof t?ti(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r){var n,i,a,o={};t=t||{};do{for(i=(n=Object.getOwnPropertyNames(e)).length;i-- >0;)o[a=n[i]]||(t[a]=e[a],o[a]=!0);e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:ni,kindOfTest:ii,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;var t=e.length;if(oi(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:yi,isFileList:fi},bi=wi;function _i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Si=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(bi.isURLSearchParams(t))n=t.toString();else{var i=[];bi.forEach(t,(function(e,t){null!=e&&(bi.isArray(e)?t+="[]":e=[e],bi.forEach(e,(function(e){bi.isDate(e)?e=e.toISOString():bi.isObject(e)&&(e=JSON.stringify(e)),i.push(_i(t)+"="+_i(e))})))})),n=i.join("&")}if(n){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},Ei=wi;function Ai(){this.handlers=[]}Ai.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},Ai.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Ai.prototype.forEach=function(e){Ei.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Pi,xi,Fi=Ai,Li=wi;function Ti(){if(xi)return Pi;xi=1;var e=wi;function t(e,t,r,n,i){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}e.inherits(t,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:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var r=t.prototype,n={};return["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"].forEach((function(e){n[e]={value:e}})),Object.defineProperties(t,n),Object.defineProperty(r,"isAxiosError",{value:!0}),t.from=function(n,i,a,o,s,l){var c=Object.create(r);return e.toFlatObject(n,c,(function(e){return e!==Error.prototype})),t.call(c,n.message,i,a,o,s),c.name=n.name,l&&Object.assign(c,l),c},Pi=t}var Oi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ki=[],Ri=[],Ci="undefined"!=typeof Uint8Array?Uint8Array:Array,ji=!1;function Ii(){ji=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)ki[t]=e[t],Ri[e.charCodeAt(t)]=t;Ri["-".charCodeAt(0)]=62,Ri["_".charCodeAt(0)]=63}function qi(e,t,r){for(var n,i,a=[],o=t;o<r;o+=3)n=(e[o]<<16)+(e[o+1]<<8)+e[o+2],a.push(ki[(i=n)>>18&63]+ki[i>>12&63]+ki[i>>6&63]+ki[63&i]);return a.join("")}function Ui(e){var t;ji||Ii();for(var r=e.length,n=r%3,i="",a=[],o=16383,s=0,l=r-n;s<l;s+=o)a.push(qi(e,s,s+o>l?l:s+o));return 1===n?(t=e[r-1],i+=ki[t>>2],i+=ki[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=ki[t>>10],i+=ki[t>>4&63],i+=ki[t<<2&63],i+="="),a.push(i),a.join("")}function Di(e,t,r,n,i){var a,o,s=8*i-n-1,l=(1<<s)-1,c=l>>1,u=-7,h=r?i-1:0,d=r?-1:1,f=e[t+h];for(h+=d,a=f&(1<<-u)-1,f>>=-u,u+=s;u>0;a=256*a+e[t+h],h+=d,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+e[t+h],h+=d,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),a-=c}return(f?-1:1)*o*Math.pow(2,a-n)}function Ni(e,t,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<<c)-1,h=u>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-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,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(t*l-1)*Math.pow(2,i),o+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+f]=255&s,f+=p,s/=256,i-=8);for(o=o<<i|s,c+=i;c>0;e[r+f]=255&o,f+=p,o/=256,c-=8);e[r+f-p]|=128*g}var Bi={}.toString,Mi=Array.isArray||function(e){return"[object Array]"==Bi.call(e)};function zi(){return $i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Hi(e,t){if(zi()<t)throw new RangeError("Invalid typed array length");return $i.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=$i.prototype:(null===e&&(e=new $i(t)),e.length=t),e}function $i(e,t,r){if(!($i.TYPED_ARRAY_SUPPORT||this instanceof $i))return new $i(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 Vi(this,e)}return Yi(this,e,t,r)}function Yi(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);$i.TYPED_ARRAY_SUPPORT?(e=t).__proto__=$i.prototype:e=Wi(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!$i.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Ki(t,r);e=Hi(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(Ji(t)){var r=0|Qi(t.length);return 0===(e=Hi(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?Hi(e,0):Wi(e,t);if("Buffer"===t.type&&Mi(t.data))return Wi(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Gi(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 Vi(e,t){if(Gi(t),e=Hi(e,t<0?0:0|Qi(t)),!$i.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function Wi(e,t){var r=t.length<0?0:0|Qi(t.length);e=Hi(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function Qi(e){if(e>=zi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+zi().toString(16)+" bytes");return 0|e}function Ji(e){return!(null==e||!e._isBuffer)}function Ki(e,t){if(Ji(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 Oa(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ka(e).length;default:if(n)return Oa(e).length;t=(""+t).toLowerCase(),n=!0}}function Xi(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 fa(this,t,r);case"utf8":case"utf-8":return ca(this,t,r);case"ascii":return ha(this,t,r);case"latin1":case"binary":return da(this,t,r);case"base64":return la(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pa(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Zi(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function ea(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=$i.from(t,n)),Ji(t))return 0===t.length?-1:ta(e,t,r,n,i);if("number"==typeof t)return t&=255,$i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ta(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ta(e,t,r,n,i){var a,o=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;o=2,s/=2,l/=2,r/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var u=-1;for(a=r;a<s;a++)if(c(e,a)===c(t,-1===u?0:a-u)){if(-1===u&&(u=a),a-u+1===l)return u*o}else-1!==u&&(a-=a-u),u=-1}else for(r+l>s&&(r=s-l),a=r;a>=0;a--){for(var h=!0,d=0;d<l;d++)if(c(e,a+d)!==c(t,d)){h=!1;break}if(h)return a}return-1}function ra(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o<n;++o){var s=parseInt(t.substr(2*o,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function na(e,t,r,n){return Ra(Oa(t,e.length-r),e,r,n)}function ia(e,t,r,n){return Ra(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function aa(e,t,r,n){return ia(e,t,r,n)}function oa(e,t,r,n){return Ra(ka(t),e,r,n)}function sa(e,t,r,n){return Ra(function(e,t){for(var r,n,i,a=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i=r%256,a.push(i),a.push(n);return a}(t,e.length-r),e,r,n)}function la(e,t,r){return 0===t&&r===e.length?Ui(e):Ui(e.slice(t,r))}function ca(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var a,o,s,l,c=e[i],u=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(u=c);break;case 2:128==(192&(a=e[i+1]))&&(l=(31&c)<<6|63&a)>127&&(u=l);break;case 3:a=e[i+1],o=e[i+2],128==(192&a)&&128==(192&o)&&(l=(15&c)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=e[i+1],o=e[i+2],s=e[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&c)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=h}return function(e){var t=e.length;if(t<=ua)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ua));return r}(n)}$i.TYPED_ARRAY_SUPPORT=void 0===global.TYPED_ARRAY_SUPPORT||global.TYPED_ARRAY_SUPPORT,zi(),$i.poolSize=8192,$i._augment=function(e){return e.__proto__=$i.prototype,e},$i.from=function(e,t,r){return Yi(null,e,t,r)},$i.TYPED_ARRAY_SUPPORT&&($i.prototype.__proto__=Uint8Array.prototype,$i.__proto__=Uint8Array),$i.alloc=function(e,t,r){return function(e,t,r,n){return Gi(t),t<=0?Hi(e,t):void 0!==r?"string"==typeof n?Hi(e,t).fill(r,n):Hi(e,t).fill(r):Hi(e,t)}(null,e,t,r)},$i.allocUnsafe=function(e){return Vi(null,e)},$i.allocUnsafeSlow=function(e){return Vi(null,e)},$i.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Ca(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Ca(e.slice(0,0))}(e))},$i.compare=function(e,t){if(!Ji(e)||!Ji(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i<a;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},$i.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}},$i.concat=function(e,t){if(!Mi(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return $i.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=$i.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var a=e[r];if(!Ji(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,i),i+=a.length}return n},$i.byteLength=Ki,$i.prototype._isBuffer=!0,$i.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)Zi(this,t,t+1);return this},$i.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)Zi(this,t,t+3),Zi(this,t+1,t+2);return this},$i.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)Zi(this,t,t+7),Zi(this,t+1,t+6),Zi(this,t+2,t+5),Zi(this,t+3,t+4);return this},$i.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?ca(this,0,e):Xi.apply(this,arguments)},$i.prototype.equals=function(e){if(!Ji(e))throw new TypeError("Argument must be a Buffer");return this===e||0===$i.compare(this,e)},$i.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+">"},$i.prototype.compare=function(e,t,r,n,i){if(!Ji(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 a=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),s=Math.min(a,o),l=this.slice(n,i),c=e.slice(t,r),u=0;u<s;++u)if(l[u]!==c[u]){a=l[u],o=c[u];break}return a<o?-1:o<a?1:0},$i.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},$i.prototype.indexOf=function(e,t,r){return ea(this,e,t,r,!0)},$i.prototype.lastIndexOf=function(e,t,r){return ea(this,e,t,r,!1)},$i.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 a=!1;;)switch(n){case"hex":return ra(this,e,t,r);case"utf8":case"utf-8":return na(this,e,t,r);case"ascii":return ia(this,e,t,r);case"latin1":case"binary":return aa(this,e,t,r);case"base64":return oa(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sa(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},$i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ua=4096;function ha(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 da(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 fa(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",a=t;a<r;++a)i+=Ta(e[a]);return i}function pa(e,t,r){for(var n=e.slice(t,r),i="",a=0;a<n.length;a+=2)i+=String.fromCharCode(n[a]+256*n[a+1]);return i}function ga(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 va(e,t,r,n,i,a){if(!Ji(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function ma(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i<a;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function ya(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i<a;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function wa(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ba(e,t,r,n,i){return i||wa(e,0,r,4),Ni(e,t,r,n,23,4),r+4}function _a(e,t,r,n,i){return i||wa(e,0,r,8),Ni(e,t,r,n,52,8),r+8}$i.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),$i.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=$i.prototype;else{var i=t-e;r=new $i(i,void 0);for(var a=0;a<i;++a)r[a]=this[a+e]}return r},$i.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return n},$i.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},$i.prototype.readUInt8=function(e,t){return t||ga(e,1,this.length),this[e]},$i.prototype.readUInt16LE=function(e,t){return t||ga(e,2,this.length),this[e]|this[e+1]<<8},$i.prototype.readUInt16BE=function(e,t){return t||ga(e,2,this.length),this[e]<<8|this[e+1]},$i.prototype.readUInt32LE=function(e,t){return t||ga(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},$i.prototype.readUInt32BE=function(e,t){return t||ga(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},$i.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},$i.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ga(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},$i.prototype.readInt8=function(e,t){return t||ga(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},$i.prototype.readInt16LE=function(e,t){t||ga(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},$i.prototype.readInt16BE=function(e,t){t||ga(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},$i.prototype.readInt32LE=function(e,t){return t||ga(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},$i.prototype.readInt32BE=function(e,t){return t||ga(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},$i.prototype.readFloatLE=function(e,t){return t||ga(e,4,this.length),Di(this,e,!0,23,4)},$i.prototype.readFloatBE=function(e,t){return t||ga(e,4,this.length),Di(this,e,!1,23,4)},$i.prototype.readDoubleLE=function(e,t){return t||ga(e,8,this.length),Di(this,e,!0,52,8)},$i.prototype.readDoubleBE=function(e,t){return t||ga(e,8,this.length),Di(this,e,!1,52,8)},$i.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||va(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[t]=255&e;++a<r&&(i*=256);)this[t+a]=e/i&255;return t+r},$i.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||va(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,a=1;for(this[t+i]=255&e;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+r},$i.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,1,255,0),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},$i.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ma(this,e,t,!0),t+2},$i.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,65535,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ma(this,e,t,!1),t+2},$i.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ya(this,e,t,!0),t+4},$i.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,4294967295,0),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ya(this,e,t,!1),t+4},$i.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);va(this,e,t,r,i-1,-i)}var a=0,o=1,s=0;for(this[t]=255&e;++a<r&&(o*=256);)e<0&&0===s&&0!==this[t+a-1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},$i.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);va(this,e,t,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},$i.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,1,127,-128),$i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},$i.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ma(this,e,t,!0),t+2},$i.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,2,32767,-32768),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ma(this,e,t,!1),t+2},$i.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,2147483647,-2147483648),$i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ya(this,e,t,!0),t+4},$i.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||va(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),$i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ya(this,e,t,!1),t+4},$i.prototype.writeFloatLE=function(e,t,r){return ba(this,e,t,!0,r)},$i.prototype.writeFloatBE=function(e,t,r){return ba(this,e,t,!1,r)},$i.prototype.writeDoubleLE=function(e,t,r){return _a(this,e,t,!0,r)},$i.prototype.writeDoubleBE=function(e,t,r){return _a(this,e,t,!1,r)},$i.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,a=n-r;if(this===e&&r<t&&t<n)for(i=a-1;i>=0;--i)e[i+t]=this[i+r];else if(a<1e3||!$i.TYPED_ARRAY_SUPPORT)for(i=0;i<a;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+a),t);return a},$i.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&&!$i.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 a;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{var o=Ji(e)?e:Oa(new $i(e,n).toString()),s=o.length;for(a=0;a<r-t;++a)this[a+t]=o[a%s]}return this};var Sa,Ea,Aa,Pa,xa,Fa,La=/[^+\/0-9A-Za-z-_]/g;function Ta(e){return e<16?"0"+e.toString(16):e.toString(16)}function Oa(e,t){var r;t=t||1/0;for(var n=e.length,i=null,a=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.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;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function ka(e){return function(e){var t,r,n,i,a,o;ji||Ii();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===e[s-2]?2:"="===e[s-1]?1:0,o=new Ci(3*s/4-a),n=a>0?s-4:s;var l=0;for(t=0,r=0;t<n;t+=4,r+=3)i=Ri[e.charCodeAt(t)]<<18|Ri[e.charCodeAt(t+1)]<<12|Ri[e.charCodeAt(t+2)]<<6|Ri[e.charCodeAt(t+3)],o[l++]=i>>16&255,o[l++]=i>>8&255,o[l++]=255&i;return 2===a?(i=Ri[e.charCodeAt(t)]<<2|Ri[e.charCodeAt(t+1)]>>4,o[l++]=255&i):1===a&&(i=Ri[e.charCodeAt(t)]<<10|Ri[e.charCodeAt(t+1)]<<4|Ri[e.charCodeAt(t+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(La,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ra(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 Ca(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function ja(){if(Ea)return Sa;Ea=1;var e=wi;return Sa=function(t,r){r=r||new FormData;var n=[];function i(t){return null===t?"":e.isDate(t)?t.toISOString():e.isArrayBuffer(t)||e.isTypedArray(t)?"function"==typeof Blob?new Blob([t]):$i.from(t):t}return function t(a,o){if(e.isPlainObject(a)||e.isArray(a)){if(-1!==n.indexOf(a))throw Error("Circular reference detected in "+o);n.push(a),e.forEach(a,(function(n,a){if(!e.isUndefined(n)){var s,l=o?o+"."+a:a;if(n&&!o&&"object"==typeof n)if(e.endsWith(a,"{}"))n=JSON.stringify(n);else if(e.endsWith(a,"[]")&&(s=e.toArray(n)))return void s.forEach((function(t){!e.isUndefined(t)&&r.append(l,i(t))}));t(n,l)}})),n.pop()}else r.append(o,i(a))}(t),r},Sa}function Ia(){if(Pa)return Aa;Pa=1;var e=Ti();return Aa=function(t,r,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?r(new e("Request failed with status code "+n.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}}function qa(){if(Fa)return xa;Fa=1;var e=wi;return xa=e.isStandardBrowserEnv()?{write:function(t,r,n,i,a,o){var s=[];s.push(t+"="+encodeURIComponent(r)),e.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),e.isString(i)&&s.push("path="+i),e.isString(a)&&s.push("domain="+a),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}}var Ua,Da,Na,Ba,Ma,za,Ha,$a,Ya,Ga,Va,Wa,Qa=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},Ja=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Ka=function(e,t){return e&&!Qa(t)?Ja(e,t):t};function Xa(){if(Da)return Ua;Da=1;var e=wi,t=["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"];return Ua=function(r){var n,i,a,o={};return r?(e.forEach(r.split("\n"),(function(r){if(a=r.indexOf(":"),n=e.trim(r.substr(0,a)).toLowerCase(),i=e.trim(r.substr(a+1)),n){if(o[n]&&t.indexOf(n)>=0)return;o[n]="set-cookie"===n?(o[n]?o[n]:[]).concat([i]):o[n]?o[n]+", "+i:i}})),o):o},Ua}function Za(){if(Ba)return Na;Ba=1;var e=wi;return Na=e.isStandardBrowserEnv()?function(){var t,r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var t=e;return r&&(n.setAttribute("href",t),t=n.href),n.setAttribute("href",t),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=i(window.location.href),function(r){var n=e.isString(r)?i(r):r;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}}function eo(){if(za)return Ma;za=1;var e=Ti();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return wi.inherits(t,e,{__CANCEL__:!0}),Ma=t}function to(){return $a?Ha:($a=1,Ha=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function ro(){if(Ga)return Ya;Ga=1;var e=wi,t=Ia(),r=qa(),n=Si,i=Ka,a=Xa(),o=Za(),s=Oi,l=Ti(),c=eo(),u=to();return Ya=function(h){return new Promise((function(d,f){var p,g=h.data,v=h.headers,m=h.responseType;function y(){h.cancelToken&&h.cancelToken.unsubscribe(p),h.signal&&h.signal.removeEventListener("abort",p)}e.isFormData(g)&&e.isStandardBrowserEnv()&&delete v["Content-Type"];var w=new XMLHttpRequest;if(h.auth){var b=h.auth.username||"",_=h.auth.password?unescape(encodeURIComponent(h.auth.password)):"";v.Authorization="Basic "+btoa(b+":"+_)}var S=i(h.baseURL,h.url);function E(){if(w){var e="getAllResponseHeaders"in w?a(w.getAllResponseHeaders()):null,r={data:m&&"text"!==m&&"json"!==m?w.response:w.responseText,status:w.status,statusText:w.statusText,headers:e,config:h,request:w};t((function(e){d(e),y()}),(function(e){f(e),y()}),r),w=null}}if(w.open(h.method.toUpperCase(),n(S,h.params,h.paramsSerializer),!0),w.timeout=h.timeout,"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){w&&4===w.readyState&&(0!==w.status||w.responseURL&&0===w.responseURL.indexOf("file:"))&&setTimeout(E)},w.onabort=function(){w&&(f(new l("Request aborted",l.ECONNABORTED,h,w)),w=null)},w.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,h,w,w)),w=null},w.ontimeout=function(){var e=h.timeout?"timeout of "+h.timeout+"ms exceeded":"timeout exceeded",t=h.transitional||s;h.timeoutErrorMessage&&(e=h.timeoutErrorMessage),f(new l(e,t.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,h,w)),w=null},e.isStandardBrowserEnv()){var A=(h.withCredentials||o(S))&&h.xsrfCookieName?r.read(h.xsrfCookieName):void 0;A&&(v[h.xsrfHeaderName]=A)}"setRequestHeader"in w&&e.forEach(v,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete v[t]:w.setRequestHeader(t,e)})),e.isUndefined(h.withCredentials)||(w.withCredentials=!!h.withCredentials),m&&"json"!==m&&(w.responseType=h.responseType),"function"==typeof h.onDownloadProgress&&w.addEventListener("progress",h.onDownloadProgress),"function"==typeof h.onUploadProgress&&w.upload&&w.upload.addEventListener("progress",h.onUploadProgress),(h.cancelToken||h.signal)&&(p=function(e){w&&(f(!e||e&&e.type?new c:e),w.abort(),w=null)},h.cancelToken&&h.cancelToken.subscribe(p),h.signal&&(h.signal.aborted?p():h.signal.addEventListener("abort",p))),g||(g=null);var P=u(S);P&&-1===["http","https","file"].indexOf(P)?f(new l("Unsupported protocol "+P+":",l.ERR_BAD_REQUEST,h)):w.send(g)}))},Ya}var no=wi,io=function(e,t){Li.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},ao=Ti(),oo=Oi,so=ja(),lo={"Content-Type":"application/x-www-form-urlencoded"};function co(e,t){!no.isUndefined(e)&&no.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var uo,ho={transitional:oo,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==Wt&&"[object process]"===Object.prototype.toString.call(Wt))&&(uo=ro()),uo),transformRequest:[function(e,t){if(io(t,"Accept"),io(t,"Content-Type"),no.isFormData(e)||no.isArrayBuffer(e)||no.isBuffer(e)||no.isStream(e)||no.isFile(e)||no.isBlob(e))return e;if(no.isArrayBufferView(e))return e.buffer;if(no.isURLSearchParams(e))return co(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var r,n=no.isObject(e),i=t&&t["Content-Type"];if((r=no.isFileList(e))||n&&"multipart/form-data"===i){var a=this.env&&this.env.FormData;return so(r?{"files[]":e}:e,a&&new a)}return n||"application/json"===i?(co(t,"application/json"),function(e,t,r){if(no.isString(e))try{return(t||JSON.parse)(e),no.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||ho.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&no.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw ao.from(e,ao.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:Wa?Va:(Wa=1,Va=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};no.forEach(["delete","get","head"],(function(e){ho.headers[e]={}})),no.forEach(["post","put","patch"],(function(e){ho.headers[e]=no.merge(lo)}));var fo,po,go=ho,vo=wi,mo=go;function yo(){return po?fo:(po=1,fo=function(e){return!(!e||!e.__CANCEL__)})}var wo=wi,bo=function(e,t,r){var n=this||mo;return vo.forEach(r,(function(r){e=r.call(n,e,t)})),e},_o=yo(),So=go,Eo=eo();function Ao(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Eo}var Po,xo,Fo=wi,Lo=function(e,t){t=t||{};var r={};function n(e,t){return Fo.isPlainObject(e)&&Fo.isPlainObject(t)?Fo.merge(e,t):Fo.isPlainObject(t)?Fo.merge({},t):Fo.isArray(t)?t.slice():t}function i(r){return Fo.isUndefined(t[r])?Fo.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function a(e){if(!Fo.isUndefined(t[e]))return n(void 0,t[e])}function o(r){return Fo.isUndefined(t[r])?Fo.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function s(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var l={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s};return Fo.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||i,n=t(e);Fo.isUndefined(n)&&t!==s||(r[e]=n)})),r};function To(){return xo?Po:(xo=1,Po={version:"0.27.2"})}var Oo=To().version,ko=Ti(),Ro={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Ro[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Co={};Ro.transitional=function(e,t,r){function n(e,t){return"[Axios v"+Oo+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,i,a){if(!1===e)throw new ko(n(i," has been removed"+(t?" in "+t:"")),ko.ERR_DEPRECATED);return t&&!Co[i]&&(Co[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}};var jo,Io,qo,Uo,Do,No,Bo={assertOptions:function(e,t,r){if("object"!=typeof e)throw new ko("options must be an object",ko.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),i=n.length;i-- >0;){var a=n[i],o=t[a];if(o){var s=e[a],l=void 0===s||o(s,a,e);if(!0!==l)throw new ko("option "+a+" must be "+l,ko.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new ko("Unknown option "+a,ko.ERR_BAD_OPTION)}},validators:Ro},Mo=wi,zo=Si,Ho=Fi,$o=function(e){return Ao(e),e.headers=e.headers||{},e.data=bo.call(e,e.data,e.headers,e.transformRequest),e.headers=wo.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),wo.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||So.adapter)(e).then((function(t){return Ao(e),t.data=bo.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return _o(t)||(Ao(e),t&&t.response&&(t.response.data=bo.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Yo=Lo,Go=Ka,Vo=Bo,Wo=Vo.validators;function Qo(e){this.defaults=e,this.interceptors={request:new Ho,response:new Ho}}Qo.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=Yo(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&Vo.assertOptions(r,{silentJSONParsing:Wo.transitional(Wo.boolean),forcedJSONParsing:Wo.transitional(Wo.boolean),clarifyTimeoutError:Wo.transitional(Wo.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var a,o=[];if(this.interceptors.response.forEach((function(e){o.push(e.fulfilled,e.rejected)})),!i){var s=[$o,void 0];for(Array.prototype.unshift.apply(s,n),s=s.concat(o),a=Promise.resolve(t);s.length;)a=a.then(s.shift(),s.shift());return a}for(var l=t;n.length;){var c=n.shift(),u=n.shift();try{l=c(l)}catch(e){u(e);break}}try{a=$o(l)}catch(e){return Promise.reject(e)}for(;o.length;)a=a.then(o.shift(),o.shift());return a},Qo.prototype.getUri=function(e){e=Yo(this.defaults,e);var t=Go(e.baseURL,e.url);return zo(t,e.params,e.paramsSerializer)},Mo.forEach(["delete","get","head","options"],(function(e){Qo.prototype[e]=function(t,r){return this.request(Yo(r||{},{method:e,url:t,data:(r||{}).data}))}})),Mo.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(Yo(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Qo.prototype[e]=t(),Qo.prototype[e+"Form"]=t(!0)}));var Jo=wi,Ko=ei,Xo=Qo,Zo=Lo;var es=function e(t){var r=new Xo(t),n=Ko(Xo.prototype.request,r);return Jo.extend(n,Xo.prototype,r),Jo.extend(n,r),n.create=function(r){return e(Zo(t,r))},n}(go);es.Axios=Xo,es.CanceledError=eo(),es.CancelToken=function(){if(Io)return jo;Io=1;var e=eo();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(e){r=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},t((function(t){n.reason||(n.reason=new e(t),r(n.reason))}))}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},t.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},t.source=function(){var e,r=new t((function(t){e=t}));return{token:r,cancel:e}},jo=t}(),es.isCancel=yo(),es.VERSION=To().version,es.toFormData=ja(),es.AxiosError=Ti(),es.Cancel=es.CanceledError,es.all=function(e){return Promise.all(e)},es.spread=Uo?qo:(Uo=1,qo=function(e){return function(t){return e.apply(null,t)}}),es.isAxiosError=function(){if(No)return Do;No=1;var e=wi;return Do=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),Zn.exports=es,Zn.exports.default=es;var ts=Zn.exports;function rs(e){this.message=e}rs.prototype=new Error,rs.prototype.name="InvalidCharacterError";var ns="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new rs("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,a=0,o="";n=t.charAt(a++);~n&&(r=i%4?64*r+n:n,i++%4)?o+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return o};function is(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(ns(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return ns(t)}}function as(e){this.message=e}as.prototype=new Error,as.prototype.name="InvalidTokenError";class os{constructor(){salla.event.on("twilight::before.ready",(e=>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.setToken(e)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=ts.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser","cache-control":"no-cache",pragma:"no-cache"}}})}getHeaders(){return this.axios.defaults.headers.common}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,...e.headers||{}});let t=salla.storage.get("scope");t&&this.setHeaders({"s-scope-type":t.type,"s-scope-id":t.id}),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=e.user?.id,i=salla.storage.get("user.id"),a=e=>{this.setToken(e),salla.event.emit("api::initiated")},o=async()=>{!r&&n?(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()))):salla.auth.event.tokenInvalid()};if(!t)return salla.log("Api:: case 1 => current is is guest"),void await o();let s=function(e,t){if("string"!=typeof e)throw new as("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(is(e.split(".")[r]))}catch(e){throw new as("Invalid token specified: "+e.message)}}(t);return Date.now()/1e3>s.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await o()):s.sub===n&&i===n&&i&&n?(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void a(t)):(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),this.setHeader("Authorization","Bearer "+t),void await salla.profile.info().then((async e=>{await salla.auth.api.request("auth/jwt"),a(t)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()})))}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},a="undefined"!=typeof event?event.currentTarget:null,o=!1;return"SALLA-BUTTON"===a?.tagName&&(o=!0),o&&a?.load(),this.axios[i.method](i.endPoint,i.payload,i.options).then((e=>(o&&a?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw o&&a?.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 ss{constructor(e){"ready"!==an.status?e?(an.config.merge(e),e?.events&&an.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}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.is_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")))))}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){an.event.dispatch("twilight::before.ready",e),an.status="ready",an.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))}}return an.status="loading",an.notify=cn,an.lang=new class extends qn{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){if(this.translationsLoaded)return e();Salla.event.once("languages::translations.loaded",e)}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}},an.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}},an.infiniteScroll=new class extends un{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"}},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),a=r.path;if(!i||!a||"string"==typeof a&&!document.querySelector(a))return void Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let o=new jn(i,r);return o.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),o.on("request",Salla.infiniteScroll.event.request),o.on("load",Salla.infiniteScroll.event.load),o.on("append",Salla.infiniteScroll.event.append),o.on("error",Salla.infiniteScroll.event.error),o.on("last",Salla.infiniteScroll.event.last),o.on("history",Salla.infiniteScroll.event.history),this.instances.push(o),o}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),an.api=new class extends os{constructor(){super(),this.auth=new Bn,this.cart=new Dn,this.loyalty=new Nn,this.order=new Mn,this.rating=new Vn,this.product=new zn,this.profile=new Hn,this.comment=new $n,this.currency=new Yn,this.document=new Gn,this.wishlist=new Wn,this.scope=new Qn,this.booking=new Jn,this.landing=new Kn}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((e=>an[e]=new un(an.api[e],an.event[e]))),an.call=e=>{let t=an,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},an.init=e=>new ss(e),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),an.success=an.notify.success,an.error=an.notify.error,an.versions.twilight="2.12.46",an.onInitiated=e=>salla.event.once("twilight::initiated",e),an.onReady=an.onReady||function(e){"ready"!==salla.status?an.onInitiated(e):e(salla.config.all())},window.dispatchEvent(new CustomEvent("salla::created")),an}));
|
|
20
20
|
//# sourceMappingURL=twilight.min.js.map
|