@salla.sa/twilight-components 2.12.21 → 2.12.22

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.
Files changed (54) hide show
  1. package/dist/cjs/app-globals-91c665fe.js +7571 -0
  2. package/dist/cjs/app-globals-91c665fe.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/twilight.cjs.js +1 -1
  5. package/dist/collection/global/app.js +2 -2
  6. package/dist/collection/global/app.js.map +1 -1
  7. package/dist/components/_commonjsHelpers.js +1 -1
  8. package/dist/components/index.js +7524 -18
  9. package/dist/components/index.js.map +1 -1
  10. package/dist/components/salla-file-upload2.js +1 -1
  11. package/dist/components/salla-tel-input2.js +1 -1
  12. package/dist/esm/{_commonjsHelpers-9adcfb67.js → _commonjsHelpers-1415ffd3.js} +2 -2
  13. package/dist/esm/_commonjsHelpers-1415ffd3.js.map +1 -0
  14. package/dist/esm/app-globals-99a1b104.js +7569 -0
  15. package/dist/esm/app-globals-99a1b104.js.map +1 -0
  16. package/dist/esm/loader.js +2 -2
  17. package/dist/esm/salla-add-product-button_41.entry.js +1 -1
  18. package/dist/esm/twilight.js +2 -2
  19. package/dist/esm-es5/{_commonjsHelpers-9adcfb67.js → _commonjsHelpers-1415ffd3.js} +2 -2
  20. package/dist/esm-es5/app-globals-99a1b104.js +25 -0
  21. package/dist/esm-es5/app-globals-99a1b104.js.map +1 -0
  22. package/dist/esm-es5/loader.js +1 -1
  23. package/dist/esm-es5/salla-add-product-button_41.entry.js +1 -1
  24. package/dist/esm-es5/twilight.js +1 -1
  25. package/dist/twilight/p-003d429f.system.js +25 -0
  26. package/dist/twilight/p-003d429f.system.js.map +1 -0
  27. package/dist/twilight/{p-ec27c867.system.js → p-57d75189.system.js} +2 -2
  28. package/dist/twilight/{p-a292baff.system.js → p-9beb6b7b.system.js} +2 -2
  29. package/dist/twilight/{p-59d3eb04.entry.js → p-df48700c.entry.js} +2 -2
  30. package/dist/twilight/p-f134bce4.js +25 -0
  31. package/dist/twilight/p-f134bce4.js.map +1 -0
  32. package/dist/twilight/{p-eed6da4c.js → p-f84bae34.js} +2 -2
  33. package/dist/twilight/{p-167c9828.system.entry.js → p-fc08b3b9.system.entry.js} +2 -2
  34. package/dist/twilight/twilight.esm.js +1 -1
  35. package/dist/twilight/twilight.js +1 -1
  36. package/dist/types/global/app.d.ts +1 -1
  37. package/package.json +5 -5
  38. package/dist/cjs/app-globals-96f71e4e.js +0 -65
  39. package/dist/cjs/app-globals-96f71e4e.js.map +0 -1
  40. package/dist/esm/_commonjsHelpers-9adcfb67.js.map +0 -1
  41. package/dist/esm/app-globals-81d17b46.js +0 -63
  42. package/dist/esm/app-globals-81d17b46.js.map +0 -1
  43. package/dist/esm-es5/app-globals-81d17b46.js +0 -23
  44. package/dist/esm-es5/app-globals-81d17b46.js.map +0 -1
  45. package/dist/twilight/p-4e4ad8fb.system.js +0 -23
  46. package/dist/twilight/p-4e4ad8fb.system.js.map +0 -1
  47. package/dist/twilight/p-ea1e28b1.js +0 -23
  48. package/dist/twilight/p-ea1e28b1.js.map +0 -1
  49. /package/dist/esm-es5/{_commonjsHelpers-9adcfb67.js.map → _commonjsHelpers-1415ffd3.js.map} +0 -0
  50. /package/dist/twilight/{p-ec27c867.system.js.map → p-57d75189.system.js.map} +0 -0
  51. /package/dist/twilight/{p-a292baff.system.js.map → p-9beb6b7b.system.js.map} +0 -0
  52. /package/dist/twilight/{p-59d3eb04.entry.js.map → p-df48700c.entry.js.map} +0 -0
  53. /package/dist/twilight/{p-eed6da4c.js.map → p-f84bae34.js.map} +0 -0
  54. /package/dist/twilight/{p-167c9828.system.entry.js.map → p-fc08b3b9.system.entry.js.map} +0 -0
@@ -1,23 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{c as t,a as e}from"./p-eed6da4c.js";!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("process"),require("buffer")):"function"==typeof define&&define.amd?define(["process","buffer"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).Salla=e(t.process$1,t.buffer)}(undefined,(function(t,e){function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function i(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}var r=n(t),a="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:{},o=Array.isArray,l="object"==typeof s&&s&&s.Object===Object&&s,u="object"==typeof self&&self&&self.Object===Object&&self,c=l||u||Function("return this")(),f=c.Symbol,h=f,d=Object.prototype,p=d.hasOwnProperty,v=d.toString,g=h?h.toStringTag:void 0;var m=function(t){var e=p.call(t,g),n=t[g];try{t[g]=void 0;var i=!0}catch(t){}var r=v.call(t);return i&&(e?t[g]=n:delete t[g]),r},w=Object.prototype.toString;var y=m,b=function(t){return w.call(t)},S=f?f.toStringTag:void 0;var _=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":S&&S in Object(t)?y(t):b(t)};var E=_,x=function(t){return null!=t&&"object"==typeof t};var j=function(t){return"symbol"==typeof t||x(t)&&"[object Symbol]"==E(t)},O=o,k=j,F=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,A=/^\w*$/;var T=function(t,e){if(O(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!k(t))||(A.test(t)||!F.test(t)||null!=e&&t in Object(e))};var R=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},I=_,C=R;var P,L=function(t){if(!C(t))return!1;var e=I(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},D=c["__core-js_shared__"],N=(P=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+P:"";var $=function(t){return!!N&&N in t},q=Function.prototype.toString;var U=L,M=$,z=R,B=function(t){if(null!=t){try{return q.call(t)}catch(t){}try{return t+""}catch(t){}}return""},J=/^\[object .+?Constructor\]$/,G=Function.prototype,H=Object.prototype,Q=G.toString,V=H.hasOwnProperty,W=RegExp("^"+Q.call(V).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var X=function(t){return!(!z(t)||M(t))&&(U(t)?W:J).test(B(t))},Z=function(t,e){return null==t?void 0:t[e]};var K=function(t,e){var n=Z(t,e);return X(n)?n:void 0},Y=K(Object,"create"),tt=Y;var et=function(){this.__data__=tt?tt(null):{},this.size=0};var nt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},it=Y,rt=Object.prototype.hasOwnProperty;var at=function(t){var e=this.__data__;if(it){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return rt.call(e,t)?e[t]:void 0},st=Y,ot=Object.prototype.hasOwnProperty;var lt=function(t){var e=this.__data__;return st?void 0!==e[t]:ot.call(e,t)},ut=Y;var ct=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=ut&&void 0===e?"__lodash_hash_undefined__":e,this},ft=et,ht=nt,dt=at,pt=lt,vt=ct;function gt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}gt.prototype.clear=ft,gt.prototype.delete=ht,gt.prototype.get=dt,gt.prototype.has=pt,gt.prototype.set=vt;var mt=gt;var wt=function(){this.__data__=[],this.size=0};var yt=function(t,e){return t===e||t!=t&&e!=e};var bt=function(t,e){for(var n=t.length;n--;)if(yt(t[n][0],e))return n;return-1},St=bt,_t=Array.prototype.splice;var Et=function(t){var e=this.__data__,n=St(e,t);return!(n<0)&&(n==e.length-1?e.pop():_t.call(e,n,1),--this.size,!0)},xt=bt;var jt=function(t){var e=this.__data__,n=xt(e,t);return n<0?void 0:e[n][1]},Ot=bt;var kt=bt;var Ft=function(t,e){var n=this.__data__,i=kt(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this},At=wt,Tt=Et,Rt=jt,It=function(t){return Ot(this.__data__,t)>-1},Ct=Ft;function Pt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Pt.prototype.clear=At,Pt.prototype.delete=Tt,Pt.prototype.get=Rt,Pt.prototype.has=It,Pt.prototype.set=Ct;var Lt=Pt,Dt=K(c,"Map"),Nt=mt,$t=Lt,qt=Dt;var Ut=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Mt=function(t,e){var n=t.__data__;return Ut(e)?n["string"==typeof e?"string":"hash"]:n.map},zt=Mt;var Bt=Mt;var Jt=Mt;var Gt=Mt;var Ht=function(t,e){var n=Gt(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this},Qt=function(){this.size=0,this.__data__={hash:new Nt,map:new(qt||$t),string:new Nt}},Vt=function(t){var e=zt(this,t).delete(t);return this.size-=e?1:0,e},Wt=function(t){return Bt(this,t).get(t)},Xt=function(t){return Jt(this,t).has(t)},Zt=Ht;function Kt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Kt.prototype.clear=Qt,Kt.prototype.delete=Vt,Kt.prototype.get=Wt,Kt.prototype.has=Xt,Kt.prototype.set=Zt;var Yt=Kt;function te(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var i=arguments,r=e?e.apply(this,i):i[0],a=n.cache;if(a.has(r))return a.get(r);var s=t.apply(this,i);return n.cache=a.set(r,s)||a,s};return n.cache=new(te.Cache||Yt),n}te.Cache=Yt;var ee=te;var ne=function(t){var e=ee(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e},ie=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,re=/\\(\\)?/g,ae=ne((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ie,(function(t,n,i,r){e.push(i?r.replace(re,"$1"):n||t)})),e}));var se=function(t,e){for(var n=-1,i=null==t?0:t.length,r=Array(i);++n<i;)r[n]=e(t[n],n,t);return r},oe=o,le=j,ue=f?f.prototype:void 0,ce=ue?ue.toString:void 0;var fe=function t(e){if("string"==typeof e)return e;if(oe(e))return se(e,t)+"";if(le(e))return ce?ce.call(e):"";var n=e+"";return"0"==n&&1/e==-Infinity?"-0":n},he=fe;var de=o,pe=T,ve=ae,ge=function(t){return null==t?"":he(t)};var me=j;var we=function(t,e){return de(t)?t:pe(t,e)?[t]:ve(ge(t))},ye=function(t){if("string"==typeof t||me(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e};var be=function(t,e){for(var n=0,i=(e=we(e,t)).length;null!=t&&n<i;)t=t[ye(e[n++])];return n&&n==i?t:void 0};var Se=function(t,e,n){var i=null==t?void 0:be(t,e);return void 0===i?n:i},_e={exports:{}};!function(t,e){!function(e){var n=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a="object"==typeof r.default&&"function"==typeof r.default.nextTick,s="function"==typeof Symbol,o="object"==typeof Reflect,l="function"==typeof setImmediate?setImmediate:setTimeout,u=s?o&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(t){var e=Object.getOwnPropertyNames(t);return e.push.apply(e,Object.getOwnPropertySymbols(t)),e}:Object.keys;function c(){this._events={},this._conf&&f.call(this,this._conf)}function f(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function h(t,e){var n="(node) warning: possible EventEmitter memory leak detected. "+t+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+e+"."),void 0!==r.default&&r.default.emitWarning){var i=new Error(n);i.name="MaxListenersExceededWarning",i.emitter=this,i.count=t,r.default.emitWarning(i)}else console.error(n),console.trace&&console.trace()}var d=function(t,e,n){var i=arguments.length;switch(i){case 0:return[];case 1:return[t];case 2:return[t,e];case 3:return[t,e,n];default:for(var r=new Array(i);i--;)r[i]=arguments[i];return r}};function p(t,n){for(var i={},r=t.length,a=n?n.length:0,s=0;s<r;s++)i[t[s]]=s<a?n[s]:e;return i}function v(t,e,n){var i,r;if(this._emitter=t,this._target=e,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(i=n.on,r=n.off),e.addEventListener?(i=e.addEventListener,r=e.removeEventListener):e.addListener?(i=e.addListener,r=e.removeListener):e.on&&(i=e.on,r=e.off),!i&&!r)throw Error("target does not implement any known event API");if("function"!=typeof i)throw TypeError("on method must be a function");if("function"!=typeof r)throw TypeError("off method must be a function");this._on=i,this._off=r;var a=t._observers;a?a.push(this):t._observers=[this]}function g(t,i,r,a){var s=Object.assign({},i);if(!t)return s;if("object"!=typeof t)throw TypeError("options must be an object");var o,l,u,c=Object.keys(t),f=c.length;function h(t){throw Error('Invalid "'+o+'" option value'+(t?". Reason: "+t:""))}for(var d=0;d<f;d++){if(o=c[d],!a&&!n.call(i,o))throw Error('Unknown "'+o+'" option');(l=t[o])!==e&&(u=r[o],s[o]=u?u(l,h):l)}return s}function m(t,e){return"function"==typeof t&&t.hasOwnProperty("prototype")||e("value must be a constructor"),t}function w(t){var e="value must be type of "+t.join("|"),n=t.length,i=t[0],r=t[1];return 1===n?function(t,n){if(typeof t===i)return t;n(e)}:2===n?function(t,n){var a=typeof t;if(a===i||a===r)return t;n(e)}:function(i,r){for(var a=typeof i,s=n;s-- >0;)if(a===t[s])return i;r(e)}}Object.assign(v.prototype,{subscribe:function(t,e,n){var i=this,r=this._target,a=this._emitter,s=this._listeners,o=function(){var i=d.apply(null,arguments),s={data:i,name:e,original:t};n?!1!==n.call(r,s)&&a.emit.apply(a,[s.name].concat(i)):a.emit.apply(a,[e].concat(i))};if(s[t])throw Error("Event '"+t+"' is already listening");this._listenersCount++,a._newListener&&a._removeListener&&!i._onNewListener?(this._onNewListener=function(n){n===e&&null===s[t]&&(s[t]=o,i._on.call(r,t,o))},a.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===e&&!a.hasListeners(n)&&s[t]&&(s[t]=null,i._off.call(r,t,o))},s[t]=null,a.on("removeListener",this._onRemoveListener)):(s[t]=o,i._on.call(r,t,o))},unsubscribe:function(t){var e,n,i,r=this,a=this._listeners,s=this._emitter,o=this._off,l=this._target;if(t&&"string"!=typeof t)throw TypeError("event must be a string");function c(){r._onNewListener&&(s.off("newListener",r._onNewListener),s.off("removeListener",r._onRemoveListener),r._onNewListener=null,r._onRemoveListener=null);var t=_.call(s,r);s._observers.splice(t,1)}if(t){if(!(e=a[t]))return;o.call(l,t,e),delete a[t],--this._listenersCount||c()}else{for(i=(n=u(a)).length;i-- >0;)t=n[i],o.call(l,t,a[t]);this._listeners={},this._listenersCount=0,c()}}});var y=w(["function"]),b=w(["object","function"]);function S(t,e,n){var i,r,a,s=0,o=new t((function(l,u,c){function f(){r&&(r=null),s&&(clearTimeout(s),s=0)}n=g(n,{timeout:0,overload:!1},{timeout:function(t,e){return("number"!=typeof(t*=1)||t<0||!Number.isFinite(t))&&e("timeout must be a positive number"),t}}),i=!n.overload&&"function"==typeof t.prototype.cancel&&"function"==typeof c;var h=function(t){f(),l(t)},d=function(t){f(),u(t)};i?e(h,d,c):(r=[function(t){d(t||Error("canceled"))}],e(h,d,(function(t){if(a)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof t)throw TypeError("onCancel callback must be a function");r.push(t)})),a=!0),n.timeout>0&&(s=setTimeout((function(){var t=Error("timeout");t.code="ETIMEDOUT",s=0,o.cancel(t),u(t)}),n.timeout))}));return i||(o.cancel=function(t){if(r){for(var e=r.length,n=1;n<e;n++)r[n](t);r[0](t),r=null}}),o}function _(t){var e=this._observers;if(!e)return-1;for(var n=e.length,i=0;i<n;i++)if(e[i]._target===t)return i;return-1}function E(t,e,n,i,r){if(!n)return null;if(0===i){var a=typeof e;if("string"===a){var s,o,l=0,c=0,f=this.delimiter,h=f.length;if(-1!==(o=e.indexOf(f))){s=new Array(5);do{s[l++]=e.slice(c,o),c=o+h}while(-1!==(o=e.indexOf(f,c)));s[l++]=e.slice(c),e=s,r=l}else e=[e],r=1}else"object"===a?r=e.length:(e=[e],r=1)}var d,p,v,g,m,w,y,b=null,S=e[i],_=e[i+1];if(i===r)n._listeners&&("function"==typeof n._listeners?(t&&t.push(n._listeners),b=[n]):(t&&t.push.apply(t,n._listeners),b=[n]));else{if("*"===S){for(o=(w=u(n)).length;o-- >0;)"_listeners"!==(d=w[o])&&(y=E(t,e,n[d],i+1,r))&&(b?b.push.apply(b,y):b=y);return b}if("**"===S){for((m=i+1===r||i+2===r&&"*"===_)&&n._listeners&&(b=E(t,e,n,r,r)),o=(w=u(n)).length;o-- >0;)"_listeners"!==(d=w[o])&&("*"===d||"**"===d?(n[d]._listeners&&!m&&(y=E(t,e,n[d],r,r))&&(b?b.push.apply(b,y):b=y),y=E(t,e,n[d],i,r)):y=E(t,e,n[d],d===_?i+2:i,r),y&&(b?b.push.apply(b,y):b=y));return b}n[S]&&(b=E(t,e,n[S],i+1,r))}if((p=n["*"])&&E(t,e,p,i+1,r),v=n["**"])if(i<r)for(v._listeners&&E(t,e,v,r,r),o=(w=u(v)).length;o-- >0;)"_listeners"!==(d=w[o])&&(d===_?E(t,e,v[d],i+2,r):d===S?E(t,e,v[d],i+1,r):((g={})[d]=v[d],E(t,e,{"**":g},i+1,r)));else v._listeners?E(t,e,v,r,r):v["*"]&&v["*"]._listeners&&E(t,e,v["*"],r,r);return b}function x(t,e,n){var i,r,a=0,s=0,o=this.delimiter,l=o.length;if("string"==typeof t)if(-1!==(i=t.indexOf(o))){r=new Array(5);do{r[a++]=t.slice(s,i),s=i+l}while(-1!==(i=t.indexOf(o,s)));r[a++]=t.slice(s)}else r=[t],a=1;else r=t,a=t.length;if(a>1)for(i=0;i+1<a;i++)if("**"===r[i]&&"**"===r[i+1])return;var u,c=this.listenerTree;for(i=0;i<a;i++)if(c=c[u=r[i]]||(c[u]={}),i===a-1)return c._listeners?("function"==typeof c._listeners&&(c._listeners=[c._listeners]),n?c._listeners.unshift(e):c._listeners.push(e),!c._listeners.warned&&this._maxListeners>0&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,h.call(this,c._listeners.length,u))):c._listeners=e,!0;return!0}function j(t,e,n,i){for(var r,a,s,o,l=u(t),c=l.length,f=t._listeners;c-- >0;)r=t[a=l[c]],s="_listeners"===a?n:n?n.concat(a):[a],o=i||"symbol"==typeof a,f&&e.push(o?s:s.join(this.delimiter)),"object"==typeof r&&j.call(this,r,e,s,o);return e}function O(t){for(var e,n,i,r=u(t),a=r.length;a-- >0;)(e=t[n=r[a]])&&(i=!0,"_listeners"===n||O(e)||delete t[n]);return i}function k(t,e,n){this.emitter=t,this.event=e,this.listener=n}function F(t,n,i){if(!0===i)o=!0;else if(!1===i)s=!0;else{if(!i||"object"!=typeof i)throw TypeError("options should be an object or true");var s=i.async,o=i.promisify,u=i.nextTick,c=i.objectify}if(s||u||o){var f=n,h=n._origin||n;if(u&&!a)throw Error("process.nextTick is not supported");o===e&&(o="AsyncFunction"===n.constructor.name),n=function(){var t=arguments,e=this,n=this.event;return o?u?Promise.resolve():new Promise((function(t){l(t)})).then((function(){return e.event=n,f.apply(e,t)})):(u?r.default.nextTick:l)((function(){e.event=n,f.apply(e,t)}))},n._async=!0,n._origin=h}return[n,c?new k(this,t,n):this]}function A(t){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,f.call(this,t)}k.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},A.EventEmitter2=A,A.prototype.listenTo=function(t,n,r){if("object"!=typeof t)throw TypeError("target musts be an object");var a=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var n,i=r.reducers,s=_.call(a,t);n=-1===s?new v(a,t,r):a._observers[s];for(var o,l=u(e),c=l.length,f="function"==typeof i,h=0;h<c;h++)o=l[h],n.subscribe(o,e[o]||o,f?i:i&&i[o])}return r=g(r,{on:e,off:e,reducers:e},{on:y,off:y,reducers:b}),i(n)?s(p(n)):s("string"==typeof n?p(n.split(/\s+/)):n),this},A.prototype.stopListeningTo=function(t,e){var n=this._observers;if(!n)return!1;var i,r=n.length,a=!1;if(t&&"object"!=typeof t)throw TypeError("target should be an object");for(;r-- >0;)i=n[r],t&&i._target!==t||(i.unsubscribe(e),a=!0);return a},A.prototype.delimiter=".",A.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},A.prototype.getMaxListeners=function(){return this._maxListeners},A.prototype.event="",A.prototype.once=function(t,e,n){return this._once(t,e,!1,n)},A.prototype.prependOnceListener=function(t,e,n){return this._once(t,e,!0,n)},A.prototype._once=function(t,e,n,i){return this._many(t,1,e,n,i)},A.prototype.many=function(t,e,n,i){return this._many(t,e,n,!1,i)},A.prototype.prependMany=function(t,e,n,i){return this._many(t,e,n,!0,i)},A.prototype._many=function(t,e,n,i,r){var a=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--e&&a.off(t,s),n.apply(this,arguments)}return s._origin=n,this._on(t,s,i,r)},A.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var t,e,n,i,r,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(t=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(n=o.length,s)for(i=0;i<n;i++)if("symbol"==typeof o[i]){a=!0;break}a||(o=o.join(this.delimiter))}var u,f=arguments.length;if(this._all&&this._all.length)for(i=0,n=(u=this._all.slice()).length;i<n;i++)switch(this.event=o,f){case 1:u[i].call(this,o);break;case 2:u[i].call(this,o,arguments[1]);break;case 3:u[i].call(this,o,arguments[1],arguments[2]);break;default:u[i].apply(this,arguments)}if(l)u=[],E.call(this,u,t,this.listenerTree,0,n);else{if("function"==typeof(u=this._events[o])){switch(this.event=o,f){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(e=new Array(f-1),r=1;r<f;r++)e[r-1]=arguments[r];u.apply(this,e)}return!0}u&&(u=u.slice())}if(u&&u.length){if(f>3)for(e=new Array(f-1),r=1;r<f;r++)e[r-1]=arguments[r];for(i=0,n=u.length;i<n;i++)switch(this.event=o,f){case 1:u[i].call(this);break;case 2:u[i].call(this,arguments[1]);break;case 3:u[i].call(this,arguments[1],arguments[2]);break;default:u[i].apply(this,e)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},A.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var t,e,n,i,r,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(t=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(i=o.length,s)for(r=0;r<i;r++)if("symbol"==typeof o[r]){e=!0;break}e||(o=o.join(this.delimiter))}var u,f=[],h=arguments.length;if(this._all)for(r=0,i=this._all.length;r<i;r++)switch(this.event=o,h){case 1:f.push(this._all[r].call(this,o));break;case 2:f.push(this._all[r].call(this,o,arguments[1]));break;case 3:f.push(this._all[r].call(this,o,arguments[1],arguments[2]));break;default:f.push(this._all[r].apply(this,arguments))}if(l?(u=[],E.call(this,u,t,this.listenerTree,0)):u=this._events[o],"function"==typeof u)switch(this.event=o,h){case 1:f.push(u.call(this));break;case 2:f.push(u.call(this,arguments[1]));break;case 3:f.push(u.call(this,arguments[1],arguments[2]));break;default:for(n=new Array(h-1),a=1;a<h;a++)n[a-1]=arguments[a];f.push(u.apply(this,n))}else if(u&&u.length){if(u=u.slice(),h>3)for(n=new Array(h-1),a=1;a<h;a++)n[a-1]=arguments[a];for(r=0,i=u.length;r<i;r++)switch(this.event=o,h){case 1:f.push(u[r].call(this));break;case 2:f.push(u[r].call(this,arguments[1]));break;case 3:f.push(u[r].call(this,arguments[1],arguments[2]));break;default:f.push(u[r].apply(this,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(f)},A.prototype.on=function(t,e,n){return this._on(t,e,!1,n)},A.prototype.prependListener=function(t,e,n){return this._on(t,e,!0,n)},A.prototype.onAny=function(t){return this._onAny(t,!1)},A.prototype.prependAny=function(t){return this._onAny(t,!0)},A.prototype.addListener=A.prototype.on,A.prototype._onAny=function(t,e){if("function"!=typeof t)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),e?this._all.unshift(t):this._all.push(t),this},A.prototype._on=function(t,n,i,r){if("function"==typeof t)return this._onAny(t,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||c.call(this);var a,s=this;return r!==e&&(n=(a=F.call(this,t,n,r))[0],s=a[1]),this._newListener&&this.emit("newListener",t,n),this.wildcard?(x.call(this,t,n,i),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),i?this._events[t].unshift(n):this._events[t].push(n),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,h.call(this,this._events[t].length,t))):this._events[t]=n,s)},A.prototype.off=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var a="string"==typeof t?t.split(this.delimiter):t.slice();if(!(r=E.call(this,null,a,this.listenerTree,0)))return this}else{if(!this._events[t])return this;n=this._events[t],r.push({_listeners:n})}for(var s=0;s<r.length;s++){var o=r[s];if(n=o._listeners,i(n)){for(var l=-1,u=0,c=n.length;u<c;u++)if(n[u]===e||n[u].listener&&n[u].listener===e||n[u]._origin&&n[u]._origin===e){l=u;break}if(l<0)continue;return this.wildcard?o._listeners.splice(l,1):this._events[t].splice(l,1),0===n.length&&(this.wildcard?delete o._listeners:delete this._events[t]),this._removeListener&&this.emit("removeListener",t,e),this}(n===e||n.listener&&n.listener===e||n._origin&&n._origin===e)&&(this.wildcard?delete o._listeners:delete this._events[t],this._removeListener&&this.emit("removeListener",t,e))}return this.listenerTree&&O(this.listenerTree),this},A.prototype.offAny=function(t){var e,n=0,i=0;if(t&&this._all&&this._all.length>0){for(n=0,i=(e=this._all).length;n<i;n++)if(t===e[n])return e.splice(n,1),this._removeListener&&this.emit("removeListenerAny",t),this}else{if(e=this._all,this._removeListener)for(n=0,i=e.length;n<i;n++)this.emit("removeListenerAny",e[n]);this._all=[]}return this},A.prototype.removeListener=A.prototype.off,A.prototype.removeAllListeners=function(t){if(t===e)return!this._events||c.call(this),this;if(this.wildcard){var n,i=E.call(this,null,t,this.listenerTree,0);if(!i)return this;for(n=0;n<i.length;n++)i[n]._listeners=null;this.listenerTree&&O(this.listenerTree)}else this._events&&(this._events[t]=null);return this},A.prototype.listeners=function(t){var n,i,r,a,s,o=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!o)return[];for(a=(n=u(o)).length,r=[];a-- >0;)"function"==typeof(i=o[n[a]])?r.push(i):r.push.apply(r,i);return r}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],c="string"==typeof t?t.split(this.delimiter):t.slice();return E.call(this,l,c,s,0),l}return o&&(i=o[t])?"function"==typeof i?[i]:i:[]},A.prototype.eventNames=function(t){var e=this._events;return this.wildcard?j.call(this,this.listenerTree,[],null,t):e?u(e):[]},A.prototype.listenerCount=function(t){return this.listeners(t).length},A.prototype.hasListeners=function(t){if(this.wildcard){var n=[],i="string"==typeof t?t.split(this.delimiter):t.slice();return E.call(this,n,i,this.listenerTree,0),n.length>0}var r=this._events,a=this._all;return!!(a&&a.length||r&&(t===e?u(r).length:r[t]))},A.prototype.listenersAny=function(){return this._all?this._all:[]},A.prototype.waitFor=function(t,n){var i=this,r=typeof n;return"number"===r?n={timeout:n}:"function"===r&&(n={filter:n}),S((n=g(n,{timeout:0,filter:e,handleError:!1,Promise,overload:!1},{filter:y,Promise:m})).Promise,(function(e,r,a){function s(){var a=n.filter;if(!a||a.apply(i,arguments))if(i.off(t,s),n.handleError){var o=arguments[0];o?r(o):e(d.apply(null,arguments).slice(1))}else e(d.apply(null,arguments))}a((function(){i.off(t,s)})),i._on(t,s,!1)}),{timeout:n.timeout,overload:n.overload})};var T=A.prototype;Object.defineProperties(A,{defaultMaxListeners:{get:function(){return T._maxListeners},set:function(t){if("number"!=typeof t||t<0||Number.isNaN(t))throw TypeError("n must be a non-negative number");T._maxListeners=t},enumerable:!0},once:{value:function(t,e,n){return S((n=g(n,{Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(n,i,r){var a;if("function"==typeof t.addEventListener)return a=function(){n(d.apply(null,arguments))},r((function(){t.removeEventListener(e,a)})),void t.addEventListener(e,a,{once:!0});var s,o=function(){s&&t.removeListener("error",s),n(d.apply(null,arguments))};"error"!==e&&(s=function(n){t.removeListener(e,o),i(n)},t.once("error",s)),r((function(){s&&t.removeListener("error",s),t.removeListener(e,o)})),t.once(e,o)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(T,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof e&&e.amd?e((function(){return A})):t.exports=A}()}(_e);var Ee=Object.assign?Object.assign:function(t,e,n,i){for(var r=1;r<arguments.length;r++)Ae(Object(arguments[r]),(function(e,n){t[n]=e}));return t},xe=function(){if(Object.create)return function(t,e,n,i){var r=Fe(arguments,1);return Ee.apply(this,[Object.create(t)].concat(r))};{function t(){}return function(e,n,i,r){var a=Fe(arguments,1);return t.prototype=e,Ee.apply(this,[new t].concat(a))}}}(),je=String.prototype.trim?function(t){return String.prototype.trim.call(t)}:function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},Oe="undefined"!=typeof window?window:s,ke={assign:Ee,create:xe,trim:je,bind:function(t,e){return function(){return e.apply(t,Array.prototype.slice.call(arguments,0))}},slice:Fe,each:Ae,map:function(t,e){var n=Re(t)?[]:{};return Te(t,(function(t,i){return n[i]=e(t,i),!1})),n},pluck:Te,isList:Re,isFunction:function(t){return t&&"[object Function]"==={}.toString.call(t)},isObject:function(t){return t&&"[object Object]"==={}.toString.call(t)},Global:Oe};function Fe(t,e){return Array.prototype.slice.call(t,e||0)}function Ae(t,e){Te(t,(function(t,n){return e(t,n),!1}))}function Te(t,e){if(Re(t)){for(var n=0;n<t.length;n++)if(e(t[n],n))return t[n]}else for(var i in t)if(t.hasOwnProperty(i)&&e(t[i],i))return t[i]}function Re(t){return null!=t&&"function"!=typeof t&&"number"==typeof t.length}var Ie=ke.slice,Ce=ke.pluck,Pe=ke.each,Le=ke.bind,De=ke.create,Ne=ke.isList,$e=ke.isFunction,qe=ke.isObject,Ue={createStore:ze},Me={version:"2.0.12",enabled:!1,get:function(t,e){var n=this.storage.read(this._namespacePrefix+t);return this._deserialize(n,e)},set:function(t,e){return void 0===e?this.remove(t):(this.storage.write(this._namespacePrefix+t,this._serialize(e)),e)},remove:function(t){this.storage.remove(this._namespacePrefix+t)},each:function(t){var e=this;this.storage.each((function(n,i){t.call(e,e._deserialize(n),(i||"").replace(e._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(t){return this._namespacePrefix=="__storejs_"+t+"_"},createStore:function(){return ze.apply(this,arguments)},addPlugin:function(t){this._addPlugin(t)},namespace:function(t){return ze(this.storage,this.plugins,t)}};function ze(t,e,n){n||(n=""),t&&!Ne(t)&&(t=[t]),e&&!Ne(e)&&(e=[e]);var i=n?"__storejs_"+n+"_":"",r=n?new RegExp("^"+i):null;if(!/^[a-zA-Z0-9_\-]*$/.test(n))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var a={_namespacePrefix:i,_namespaceRegexp:r,_testStorage:function(t){try{var e="__storejs__test__";t.write(e,e);var n=t.read(e)===e;return t.remove(e),n}catch(t){return!1}},_assignPluginFnProp:function(t,e){var n=this[e];this[e]=function(){var e=Ie(arguments,0),i=this;var r=[function(){if(n)return Pe(arguments,(function(t,n){e[n]=t})),n.apply(i,e)}].concat(e);return t.apply(i,r)}},_serialize:function(t){return JSON.stringify(t)},_deserialize:function(t,e){if(!t)return e;var n="";try{n=JSON.parse(t)}catch(e){n=t}return void 0!==n?n:e},_addStorage:function(t){this.enabled||this._testStorage(t)&&(this.storage=t,this.enabled=!0)},_addPlugin:function(t){var e=this;if(Ne(t))Pe(t,(function(t){e._addPlugin(t)}));else if(!Ce(this.plugins,(function(e){return t===e}))){if(this.plugins.push(t),!$e(t))throw new Error("Plugins must be function values that return objects");var n=t.call(this);if(!qe(n))throw new Error("Plugins must return an object of function properties");Pe(n,(function(n,i){if(!$e(n))throw new Error("Bad plugin property: "+i+" from plugin "+t.name+". Plugins should only return functions.");e._assignPluginFnProp(n,i)}))}},addStorage:function(t){!function(){var t="undefined"==typeof console?null:console;t&&(t.warn?t.warn:t.log).apply(t,arguments)}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(t)}},s=De(a,Me,{plugins:[]});return s.raw={},Pe(s,(function(t,e){$e(t)&&(s.raw[e]=Le(s,t))})),Pe(t,(function(t){s._addStorage(t)})),Pe(e,(function(t){s._addPlugin(t)})),s}var Be=ke.Global,Je={name:"localStorage",read:He,write:function(t,e){return Ge().setItem(t,e)},each:function(t){for(var e=Ge().length-1;e>=0;e--){var n=Ge().key(e);t(He(n),n)}},remove:function(t){return Ge().removeItem(t)},clearAll:function(){return Ge().clear()}};function Ge(){return Be.localStorage}function He(t){return Ge().getItem(t)}var Qe=i({__proto__:null,default:Je},[Je]),Ve=ke.Global,We={name:"sessionStorage",read:Ze,write:function(t,e){return Xe().setItem(t,e)},each:function(t){for(var e=Xe().length-1;e>=0;e--){var n=Xe().key(e);t(Ze(n),n)}},remove:function(t){return Xe().removeItem(t)},clearAll:function(){return Xe().clear()}};function Xe(){return Ve.sessionStorage}function Ze(t){return Xe().getItem(t)}var Ke=i({__proto__:null,default:We},[We]),Ye=ke.trim,tn={name:"cookieStorage",read:function(t){if(!t||!an(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(en.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;en.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:nn,remove:rn,clearAll:function(){nn((function(t,e){rn(e)}))}},en=ke.Global.document;function nn(t){for(var e=en.cookie.split(/; ?/g),n=e.length-1;n>=0;n--)if(Ye(e[n])){var i=e[n].split("="),r=unescape(i[0]);t(unescape(i[1]),r)}}function rn(t){t&&an(t)&&(en.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function an(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(en.cookie)}var sn=i({__proto__:null,default:tn},[tn]),on={name:"memoryStorage",read:function(t){return ln[t]},write:function(t,e){ln[t]=e},each:function(t){for(var e in ln)ln.hasOwnProperty(e)&&t(ln[e],e)},remove:function(t){delete ln[t]},clearAll:function(t){ln={}}},ln={};var un=i({__proto__:null,default:on},[on]);function cn(t,e){void 0===e&&(e=!1),t+="";for(var n,i=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],r=["0","1","2","3","4","5","6","7","8","9"],a=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?i:r,s=e?r:i,o=0;o<a.length;o++)n=new RegExp(a[o],"g"),t=t.replace(n,s[o]);return t.replace(e?"٫":".",e?".":"٫")}function fn(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?fn(t.replace(/\.(.+)\./g,".$1")):t}function hn(t){return"".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function dn(t){if(hn(t))return t;var e=Salla.config.get("store.url");return e||(e=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",e)),e.rtrim("/")+"/"+(null==t?void 0:t.ltrim("/"))}function pn(t,e,n){if(n=n||window.location.href,!e||!t)return n;var i=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return(n=n.replace(i,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?n+="&":n+=(n.endsWith("/")?"":"/")+"?",(n+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function vn(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function gn(t){return hn(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):vn("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}function mn(t,e,n){var i,r=t[0];return n&&0==t.length?Array.isArray(n)?(n.push(e),n):[n,e]:Array.isArray(n)?(n.push(e),n):"string"==typeof n?[n,e]:n?(n[r]=mn(t.slice(1),e,n[r]),n):r?((i={})[r]=mn(t.slice(1),e),i):""===r?[e]:e}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(t){return t.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(t,e){for(var n,i=this,r=0;r<t.length;r++)n=new RegExp(t[r],"g"),i=i.replace(n,e[r]);return i},String.prototype.rtrim=function(t){return void 0===t&&(t="\\s"),this.replace(new RegExp("["+t+"]*$"),"")},String.prototype.ltrim=function(t){return void 0===t&&(t="\\s"),this.replace(new RegExp("^["+t+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)};var wn={digitsOnly:function(t){return cn(t,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function t(e,n){if(void 0===n&&(n=!1),"string"==typeof e)return document.querySelectorAll(e).forEach((function(e){return t(e,n)}));if(e){var i=Salla.helpers.digitsOnly(e.value);return e.min&&i<parseInt(e.min)?e.value=e.min:e.max&&i>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&i.toString().length>e.maxLength?e.value=i.toString().substring(0,e.maxLength):e.value=n||e.dataset.hasOwnProperty("digitsWithDecimal")?fn(i):i.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e)},number:cn,money:function(t){var e=Salla.config.currency(null==t?void 0:t.currency).symbol;return cn(t="object"==typeof t?t.amount:t)+" "+e},setNested:function(t,e,n){for(var i=t,r=e.split("."),a=r.length,s=0;s<a-1;s++){var o=r[s];i[o]||(i[o]={}),i=i[o]}return i[r[a-1]]=n,t},getNested:function(t,e,n){var i=Se(t,e);return void 0!==i?i:n},inputData:function(t,e,n){if(void 0===n&&(n={}),t.includes("[")){var i=t.split("]").join("").split("[");return{name:i[0],value:mn(i.slice(1),e,n[i[0]])}}return{name:t,value:e}},url:Object.freeze({__proto__:null,is_full_url:hn,base:function(t){return hn(t)?t:"https://"+new URL(dn("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},get:dn,domain:function(t){return hn(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},addParamToUrl:pn,baseUrl:vn,asset:gn,cdn:function(t){return"https://cdn.salla.network/"+(null==t?void 0:t.ltrim("/"))},api:function(t){var e;return(null===(e=Salla.config.get("store.api",dn("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return gn(salla.config.get("theme.settings.placeholder"))===gn(t)}}),addParamToUrl:pn,debounce:function(t,e){e=e||100;var n,i=[];return function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];return clearTimeout(n),n=setTimeout((function(){var e=t.apply(void 0,r);i.forEach((function(t){return t(e)})),i=[]}),e),new Promise((function(t){return i.push(t)}))}}},yn=function(t,e){return yn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},yn(t,e)},bn=function(){return bn=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},bn.apply(this,arguments)};function Sn(t,e,n){if(n||2===arguments.length)for(var i,r=0,a=e.length;r<a;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var _n,En,xn=(_n=console,En={log:function(t,e){if(_n&&salla.config.isDebug()){"trace"===salla.config.get("debug")&&(e="trace");var n=_n.log,i=void 0===e?n:this.__dict__[e]||n,r=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],a={event:"#CFF680",backend:"#7b68ee"}[e];a&&(r[0]+="%c"+e[0].toUpperCase()+e.substring(1),r.push("margin-left: 5px;color: ".concat(a,";font-weight:bold; border:1px solid ").concat(a,"; padding: 2px 6px; border-radius: 5px;"))),i.call.apply(i,Sn([_n],r.concat.apply(r,t),!1))}},__dict__:{trace:_n.trace,debug:_n.debug,info:_n.info,warn:_n.warn,error:_n.error}},{event:function(){En.log(arguments,"event")},trace:function(){En.log(arguments,"trace")},debug:function(){En.log(arguments,"debug")},info:function(){En.log(arguments,"info")},warn:function(){En.log(arguments,"warn")},error:function(){En.log(arguments,"error")},log:function(){En.log(arguments,void 0)},backend:function(){En.log(arguments,"backend")},logs:function(t){[t].flat().forEach((function(t){return t&&En.log([t].flat(),"backend")}))}}),jn=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=bn(bn({},this.default_properties),t)}return t.prototype.merge=function(t){var e;return this.properties_=bn(bn({},this.properties_),t),this.properties_.store=bn(bn({},(null===(e=this.default_properties)||void 0===e?void 0:e.store)||{}),this.properties_.store),this},t.prototype.set=function(t,e){return t.includes(".")?(Salla.helpers.setNested(this.properties_,t,e),this):(this.properties_[t]=e,this)},t.prototype.currency=function(t){return void 0===t&&(t=void 0),t=t||this.get("user.currency_code"),this.get("currencies."+t)||Object.values(this.get("currencies"))[0]},t.prototype.get=function(t,e){return void 0===e&&(e=null),t.includes(".")?Salla.helpers.getNested(this.properties_,t,e):this.properties_.hasOwnProperty(t)?this.properties_[t]||e:e||void 0},t.prototype.all=function(){return this.properties_},t.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},t}(),On=function(t){function e(){var e=this;return(e=t.call(this,{wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1})||this).delimiter="::","undefined"!=typeof document&&(e.body=document.querySelector("body")),e.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],e.ingoreLogEvents=["document::click","document::keyup","document::change"],e.noneFireableActions=["document.request"],e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}yn(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.dispatch.apply(this,Sn([t],e,!1))},e.prototype.emit=function(e){for(var n,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];var a=e.replace("::",".");if(!this.noneFireableActions.includes(a)&&Salla.call&&"function"==typeof Salla.call(a))return Salla.log("'Salla.".concat(a,"(...)' triggered using event '").concat(e,"'")),a=a.split("."),Array.isArray(i[0])&&(i=i[0]),void(n=salla[a[0]])[a[1]].apply(n,i);t.prototype.emit.apply(this,Sn([e],i,!1)),this.trackEvents.apply(this,Sn([e],i,!1))},e.prototype.emitAsync=function(e){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var r=t.prototype.emitAsync.apply(this,Sn([e],n,!1));try{this.trackEvents.apply(this,Sn([e],n,!1))}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),n,t)}return r},e.prototype.trackEvents=function(t){for(var e,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var r={event:t};n.map((function(t){return"object"==typeof t&&(r=bn(bn({},r),t))})),window.dataLayer.push(r)}catch(t){salla.logger.error(t.message)}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,Sn([t],n,!1)),this.dispatchMobileEvent.apply(this,Sn([t],n,!1))},e.prototype.dispatch=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return this.emit.apply(this,Sn([t],e,!1))},e.prototype.dispatchEvents=function(t){if(t)if("object"!=typeof t||Array.isArray(t))Salla.log("Events object is wrong, it should be object of {event:payload}",t);else for(var e=0,n=Object.entries(t);e<n.length;e++){var i=n[e],r=i[0],a=i[1];this.dispatch(r,a)}else Salla.log("No Events To Dispatch!",t)},e.prototype.addListener=function(t,e){return this.on(t,e)},e.prototype.addEventListener=function(t,e){return this.on(t,e)},e.prototype.listen=function(t,e){return this.on(t,e)},e.prototype.registerGlobalListener=function(t,e){return this.onAny(e)},e.prototype.dispatchMobileEvent=function(t,e){if(void 0===e&&(e={}),!("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:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}else if(void 0!==window.Android)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}},e}(_e.exports.EventEmitter2),kn=Ue.createStore([Qe,Ke,sn,un],[]),Fn=function(){function t(){var t=this;Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,n){return t.set(e,n)})),this.store=kn}return t.prototype.set=function(t,e){var n;if(t.includes(".")){var i=t.split(".")[0],r=((n={})[i]=this.store.get(i),n);return r=Salla.helpers.setNested(r,t,e),this.store.set(i,r[i])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(){return this.store.clearAll()},t.prototype.get=function(t,e){var n;if(t.includes(".")){var i=t.split(".")[0];return Salla.helpers.getNested(((n={})[i]=this.store.get(i),n),t)}return this.store.get(t,e)},t}(),An=function(){function t(){var t=this;Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,n){return t.set(e,n)}))}return t.prototype.get=function(t){var e;return null===(e=document.cookie.split("; ").find((function(e){return e.startsWith(t+"=")})))||void 0===e?void 0:e.split("=")[1]},t.prototype.set=function(t,e,n){void 0===e&&(e=""),void 0===n&&(n=10);var i="";if(n){var r=new Date;r.setTime(r.getTime()+24*n*60*60*1e3),i="; expires="+r.toUTCString()}return document.cookie="".concat(t,"=").concat(e).concat(i,'"; path=/; secure; SameSite=Lax"'),this},t.prototype.remove=function(t){return document.cookie="".concat(t,"=; Max-Age=0; path=/;"),this},t.prototype.clearAll=function(){for(var t=document.cookie.split(";"),e=0;e<t.length;e++){var n=t[e],i=n.indexOf("="),r=i>-1?n.substr(0,i):n;this.remove(r)}},t}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),void 0!==a&&(a.salla=a.salla||a.Salla||{},a.Salla=a.salla),Salla.status="base",Salla.config=new jn,Salla.logger=xn,Salla.event=new On,Salla.helpers=wn,Salla.storage=new Fn,Salla.cookie=new An,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.12.20"};var Tn=Salla;let Rn=function(t,e,n){return alert(t)},In=function(t,e){return Rn(t,Cn.error,e)},Cn={error:"error",success:"success",info:"info"};var Pn={fire:function(t,e,n){return Rn(t,e,n)},setNotifier:function(t){Rn=t,salla.event.emit("twilight::notifier.changed")},error:In,success:function(t,e){return Rn(t,Cn.success,e)},info:function(t,e){return Rn(t,Cn.info,e)},sallaInitiated:function(){let t=window.location.href.match(/([\?\&]danger=)[^&]+/g);t&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(()=>{t.forEach((t=>{In(decodeURI(t.replace("?danger=","").replace("&danger=","")))}))})))},types:Cn};class Ln{constructor(t,e){return this.api=t,this.event=e,new Proxy(this,{get:function(n,i){return"event"===i?e:"api"===i?t:t&&t[i]||n[i]}})}}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(t){for(var e=this;e;){if(e.matches(t))return e;e=e.parentElement}}),Element.prototype.getElementSallaData=function(t,...e){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(t){}let n=this.getAttribute("data-function");if(n&&window[n])return"function"==typeof window[n]?this.getFilteredData(window[n].call(this,...e)):this.getFilteredData(window[n]);let i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this,i&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);let r=i.querySelectorAll("[name]");if(!r.length)return this.getFilteredData();let a=Object.assign({},this.dataset);return r.forEach((t=>{if(!["checkbox","radio"].includes(t.type)||t.checked)try{let e=Salla.helpers.inputData(t.name,t.value,a);a[e.name]=e.value}catch(e){Salla.log(t.name+" can't be send")}})),this.getFilteredData(a)},Element.prototype.canEventFireHook=function(t){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+t.type)},Element.prototype.hasAttributeStartsWith=function(t,e){t=t.toLowerCase();for(var n=0;n<this.attributes.length;n++){let i=this.attributes[n].name.toLowerCase();if(0===i.indexOf(t))return!e||i}return!1},HTMLFormElement.prototype.getAjaxFormData=function(t){var e=this.querySelectorAll('input[type="file"]');e.forEach((t=>{t.files.length||t.setAttribute("disabled","")}));var n=new FormData(this);return e.forEach((t=>{t.files.length||t.removeAttribute("disabled")})),{formData:this.getFilteredData(n,t),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(t=null,e=null,n=null){return t=t||n?.dataset||this.dataset,n&&this.name&&void 0!==this.value&&(t=function(t,e,n){t instanceof FormData?t.append(e,n):t[e]=n;return t}(t,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((i=>{let r=n?.dataset[i]||this.dataset[i];if(r){var a=window[r];if("function"==typeof a){if(!a(t,n||this,e)&&t)throw`Data failed to be pass verify function window.${r}(formData, element, event)!`;return a(t,n||this,e)}Salla.log("window."+r+"() not found!")}})),t},HTMLAnchorElement.prototype.getAjaxFormData=function(t){return{formData:this.getFilteredData(null,t),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};class Dn{constructor(){this.events={},this.namespace="";let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((t=>{this.createDynamicEventFuns(t),this.createDynamicListenerFuns(t)}))}createDynamicEventFuns(t){if(this[t])return;let e=this;this[t]=function(...n){return e.dispatch(t,...n)}}createDynamicListenerFuns(t){let e="on"+t.charAt(0).toUpperCase()+t.slice(1);if(this[e])return;let n=this;this[e]=function(e){return n.on(t,(async(...t)=>e(...t)))}}getEventName(t){return t=this.events[t]||t,!this.namespace||t.includes("::")?t:this.namespace+Salla.event.delimiter+t}dispatch(t,...e){return Salla.event.emitAsync(this.getEventName(t),...e)}on(t,e){return Salla.event.addListener(this.getEventName(t),e)}once(t,e){return Salla.event.once(this.getEventName(t),e)}}function Nn(t){t&&t.sallaInitiated&&!t.initiated&&(t.sallaInitiated(),t.initiated=!0)}Salla.event.auth=new class extends Dn{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(t){return t?(t.type&&this.setTypeActionOnVerified(t.type),this.next_event=t.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(t){return Salla.profile.info().finally((()=>this.dispatch("loggedIn",t)))}setTypeActionOnVerified(t){this.type_action_on_verified=t}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends Dn{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(t){return Salla.cookie.set("fresh_summary",1),t&&"object"==typeof t?(t.offer&&salla.product.event.offerExisted(t.offer),t.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),t.cart?(salla.storage.set("cart.summary",{total:t.cart.total,sub_total:t.cart.sub_total,discount:t.cart.discount,real_shipping_cost:t.cart.real_shipping_cost,count:t.cart.count,shipping_cost:t.cart.free_shipping_bar?.has_free_shipping?0:t.cart.real_shipping_cost}),this.dispatch("updated",t.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",t),this.dispatch("updated"))}latestFetched(t){return this.updated(t.data),this.dispatch("latestFetched",t)}itemAdded(t,e){return this.updated(t.data),this.dispatch("itemAdded",t,e)}itemDeleted(t,e){return this.updated(t.data),this.dispatch("itemDeleted",t,e)}itemUpdated(t,e){return this.updated(t.data),this.dispatch("itemUpdated",t,e)}couponAdded(t,e){return this.updated(t.data),this.dispatch("couponAdded",t,e)}couponDeleted(t,e){return this.updated(t.data),this.dispatch("couponDeleted",t,e)}},Salla.event.order=new class extends Dn{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 Dn{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 Dn{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 Dn{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends Dn{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 Dn{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 Dn{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(t,e){return salla.cart.event.updated(t.data),this.dispatch("exchangeSucceeded",t,e)}resetSucceeded(t){return salla.cart.event.updated(t.data),this.dispatch("resetSucceeded",t)}},Salla.event.product=new class extends Dn{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 Dn{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 Dn{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 Dn{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(t,e){this.fireCallableFuns("click",t,e)}onChange(t,e){this.fireCallableFuns("change",t,e)}onSubmit(t,e){this.fireCallableFuns("submit",t,e)}onKeyup(t,e){this.fireCallableFuns("keyup",t,e)}fireCallableFuns(t,e,n){this.on(t,(t=>{"function"!=typeof e?"function"==typeof n&&t.target.matches(e)&&n(t):e(t)}))}fireEvent(t,e,...n){return this.fireEventForElements(t,e,!1,...n)}fireEventForAll(t,e,...n){return this.fireEventForElements(t,e,!0,...n)}fireEventForElements(t,e,n,...i){if("string"==typeof t){if(n)return document.querySelectorAll(t).forEach((t=>this.fireEventForElements(t,e,!1,...i)));t=document.querySelector(t)}if(!t)return void salla.log("Failed To get element to fire event: "+e);const r=new CustomEvent(e,...i);return t.dispatchEvent(r)}},Salla.event.wishlist=new class extends Dn{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 Dn{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((t=>{"object"==typeof(t=Salla[t])&&(Nn(t),Object.keys(t).forEach((e=>{Nn(t[e])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"==="production",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 t=!0,e=[];return(await salla.document.api.request("languages",null,"get"))?.data?.map((n=>{t&&(e=[],t=!1),n.code=n.code||n.iso_code,n.url=salla.url.get(n.code),n.is_rtl=n.is_rtl||n.rtl,e.push(n)})),Salla.config.set("languages",e),e},Salla.config.currencies=async()=>{if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let t=!0,e={};return(await salla.currency.api.list())?.data?.map((n=>{t&&(e={},t=!1),n.country_code=n.code.substr(0,2).toLowerCase(),e[n.code]=n})),Salla.config.set("currencies",e),e};var $n,qn={exports:{}},Un={exports:{}},Mn={exports:{}};function zn(){return $n||($n=1,function(t){!function(e,n){t.exports?t.exports=n():e.EvEmitter=n()}("undefined"!=typeof window?window:s,(function(){function t(){}let e=t.prototype;return e.on=function(t,e){if(!t||!e)return this;let n=this._events=this._events||{},i=n[t]=n[t]||[];return i.includes(e)||i.push(e),this},e.once=function(t,e){if(!t||!e)return this;this.on(t,e);let n=this._onceEvents=this._onceEvents||{};return(n[t]=n[t]||{})[e]=!0,this},e.off=function(t,e){let n=this._events&&this._events[t];if(!n||!n.length)return this;let i=n.indexOf(e);return-1!=i&&n.splice(i,1),this},e.emitEvent=function(t,e){let n=this._events&&this._events[t];if(!n||!n.length)return this;n=n.slice(0),e=e||[];let i=this._onceEvents&&this._onceEvents[t];for(let r of n){i&&i[r]&&(this.off(t,r),delete i[r]),r.apply(this,e)}return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t}))}(Mn)),Mn.exports}var Bn,Jn,Gn={exports:{}};function Hn(){return Bn||(Bn=1,function(t){!function(e,n){t.exports?t.exports=n(e):e.fizzyUIUtils=n(e)}(s,(function(t){let e={extend:function(t,e){return Object.assign(t,e)},modulo:function(t,e){return(t%e+e)%e},makeArray:function(t){if(Array.isArray(t))return t;if(null==t)return[];return"object"==typeof t&&"number"==typeof t.length?[...t]:[t]},removeFrom:function(t,e){let n=t.indexOf(e);-1!=n&&t.splice(n,1)},getParent:function(t,e){for(;t.parentNode&&t!=document.body;)if((t=t.parentNode).matches(e))return t},getQueryElement:function(t){return"string"==typeof t?document.querySelector(t):t},handleEvent:function(t){let e="on"+t.type;this[e]&&this[e](t)},filterFindElements:function(t,n){return(t=e.makeArray(t)).filter((t=>t instanceof HTMLElement)).reduce(((t,e)=>{if(!n)return t.push(e),t;e.matches(n)&&t.push(e);let i=e.querySelectorAll(n);return t=t.concat(...i)}),[])},debounceMethod:function(t,e,n){n=n||100;let i=t.prototype[e],r=e+"Timeout";t.prototype[e]=function(){clearTimeout(this[r]);let t=arguments;this[r]=setTimeout((()=>{i.apply(this,t),delete this[r]}),n)}},docReady:function(t){let e=document.readyState;"complete"==e||"interactive"==e?setTimeout(t):document.addEventListener("DOMContentLoaded",t)},toDashed:function(t){return t.replace(/(.)([A-Z])/g,(function(t,e,n){return e+"-"+n})).toLowerCase()}},n=t.console;return e.htmlInit=function(i,r){e.docReady((function(){let a="data-"+e.toDashed(r),s=document.querySelectorAll(`[${a}]`),o=t.jQuery;[...s].forEach((t=>{let e,s=t.getAttribute(a);try{e=s&&JSON.parse(s)}catch(e){return void(n&&n.error(`Error parsing ${a} on ${t.className}: ${e}`))}let l=new i(t,e);o&&o.data(t,r,l)}))}))},e}))}(Gn)),Gn.exports}function Qn(){return Jn||(Jn=1,function(t){!function(e,n){t.exports?t.exports=n(e,zn(),Hn()):e.InfiniteScroll=n(e,e.EvEmitter,e.fizzyUIUtils)}(window,(function(t,e,n){let i=t.jQuery,r={};function a(t,e){let s=n.getQueryElement(t);if(s){if((t=s).infiniteScrollGUID){let n=r[t.infiniteScrollGUID];return n.option(e),n}this.element=t,this.options={...a.defaults},this.option(e),i&&(this.$element=i(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(s||t))}a.defaults={},a.create={},a.destroy={};let s=a.prototype;Object.assign(s,e.prototype);let o=0;s.create=function(){let t=this.guid=++o;if(this.element.infiniteScrollGUID=t,r[t]=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 t in a.create)a.create[t].call(this)}else console.error("Disabling InfiniteScroll")},s.option=function(t){Object.assign(this.options,t)},s.callOnInit=function(){let t=this.options.onInit;t&&t.call(this,this)},s.dispatchEvent=function(t,e,n){this.log(t,n);let r=e?[e].concat(n):n;if(this.emitEvent(t,r),!i||!this.$element)return;let a=t+=".infiniteScroll";if(e){let n=i.Event(e);n.type=t,a=n}this.$element.trigger(a,n)};let l={initialized:t=>`on ${t}`,request:t=>`URL: ${t}`,load:(t,e)=>`${t.title||""}. URL: ${e}`,error:(t,e)=>`${t}. URL: ${e}`,append:(t,e,n)=>`${n.length} items. URL: ${e}`,last:(t,e)=>`URL: ${e}`,history:(t,e)=>`URL: ${e}`,pageIndex:function(t,e){return`current page determined to be: ${t} from ${e}`}};s.log=function(t,e){if(!this.options.debug)return;let n=`[InfiniteScroll] ${t}`,i=l[t];i&&(n+=". "+i.apply(this,e)),console.log(n)},s.updateMeasurements=function(){this.windowHeight=t.innerHeight;let e=this.element.getBoundingClientRect();this.top=e.top+t.scrollY},s.updateScroller=function(){let e=this.options.elementScroll;if(e){if(this.scroller=!0===e?this.element:n.getQueryElement(e),!this.scroller)throw new Error(`Unable to find elementScroll: ${e}`)}else this.scroller=t},s.updateGetPath=function(){let t=this.options.path;if(!t)return void console.error(`InfiniteScroll path option required. Set as: ${t}`);let e=typeof t;"function"!=e?"string"==e&&t.match("{{#}}")?this.updateGetPathTemplate(t):this.updateGetPathSelector(t):this.getPath=t},s.updateGetPathTemplate=function(t){this.getPath=()=>{let e=this.pageIndex+1;return t.replace("{{#}}",e)};let e=t.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),n=new RegExp(e),i=location.href.match(n);i&&(this.pageIndex=parseInt(i[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let u=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],c=a.getPathParts=function(t){if(t)for(let e of u){let n=t.match(e);if(n){let[,t,e,i]=n;return{begin:t,index:e,end:i}}}};s.updateGetPathSelector=function(t){let e=document.querySelector(t);if(!e)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${t}`);let n=e.getAttribute("href"),i=c(n);if(!i)return void console.error(`InfiniteScroll unable to parse next link href: ${n}`);let{begin:r,index:a,end:s}=i;this.isPathSelector=!0,this.getPath=()=>r+(this.pageIndex+1)+s,this.pageIndex=parseInt(a,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},s.updateGetAbsolutePath=function(){let t=this.getPath();if(t.match(/^http/)||t.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:e}=location,n=t.match(/^\?/),i=e.substring(0,e.lastIndexOf("/")),r=n?e:i+"/";this.getAbsolutePath=()=>r+this.getPath()},a.create.hideNav=function(){let t=n.getQueryElement(this.options.hideNav);t&&(t.style.display="none",this.nav=t)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},s.destroy=function(){this.allOff();for(let t in a.destroy)a.destroy[t].call(this);delete this.element.infiniteScrollGUID,delete r[this.guid],i&&this.$element&&i.removeData(this.element,"infiniteScroll")},a.throttle=function(t,e){let n,i;return e=e||200,function(){let r=+new Date,a=arguments,s=()=>{n=r,t.apply(this,a)};n&&r<n+e?(clearTimeout(i),i=setTimeout(s,e)):s()}},a.data=function(t){let e=(t=n.getQueryElement(t))&&t.infiniteScrollGUID;return e&&r[e]},a.setJQuery=function(t){i=t},n.htmlInit(a,"infinite-scroll"),s._init=function(){};let{jQueryBridget:f}=t;return i&&f&&f("infiniteScroll",a,i),a}))}(Un)),Un.exports}var Vn,Wn={exports:{}};function Xn(){return Vn||(Vn=1,function(t){!function(e,n){t.exports?t.exports=n(e,Qn()):n(e,e.InfiniteScroll)}(window,(function(t,e){let n=e.prototype;Object.assign(e.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),e.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},n.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let i=new DOMParser;function r(t){let e=document.createDocumentFragment();return t&&e.append(...t),e}return n.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:t,domParseResponse:e,fetchOptions:n}=this.options,r=this.getAbsolutePath();this.isLoading=!0,"function"==typeof n&&(n=n());let a=fetch(r,n).then((n=>{if(!n.ok){let t=new Error(n.statusText);return this.onPageError(t,r,n),{response:n}}return n[t]().then((a=>("text"==t&&e&&(a=i.parseFromString(a,"text/html")),204==n.status?(this.lastPageReached(a,r),{body:a,response:n}):this.onPageLoad(a,r,n))))})).catch((t=>{this.onPageError(t,r)}));return this.dispatchEvent("request",null,[r,a]),a},n.onPageLoad=function(t,e,n){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[t,e,n]),this.appendNextPage(t,e,n)},n.appendNextPage=function(t,e,n){let{append:i,responseBody:a,domParseResponse:s}=this.options;if(!("text"==a&&s)||!i)return{body:t,response:n};let o=t.querySelectorAll(i),l={body:t,response:n,items:o};if(!o||!o.length)return this.lastPageReached(t,e),l;let u=r(o),c=()=>(this.appendItems(o,u),this.isLoading=!1,this.dispatchEvent("append",null,[t,e,o,n]),l);return this.options.outlayer?this.appendOutlayerItems(u,c):c()},n.appendItems=function(t,e){t&&t.length&&(function(t){let e=t.querySelectorAll("script");for(let t of e){let e=document.createElement("script"),n=t.attributes;for(let t of n)e.setAttribute(t.name,t.value);e.innerHTML=t.innerHTML,t.parentNode.replaceChild(e,t)}}(e=e||r(t)),this.element.appendChild(e))},n.appendOutlayerItems=function(n,i){let r=e.imagesLoaded||t.imagesLoaded;return r?new Promise((function(t){r(n,(function(){let e=i();t(e)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},n.onAppendOutlayer=function(t,e,n){this.options.outlayer.appended(n)},n.checkLastPage=function(t,e){let n,{checkLastPage:i,path:r}=this.options;if(i){if("function"==typeof r){if(!this.getPath())return void this.lastPageReached(t,e)}"string"==typeof i?n=i:this.isPathSelector&&(n=r),n&&t.querySelector&&(t.querySelector(n)||this.lastPageReached(t,e))}},n.lastPageReached=function(t,e){this.canLoad=!1,this.dispatchEvent("last",null,[t,e])},n.onPageError=function(t,e,n){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[t,e,n]),t},e.create.prefill=function(){if(!this.options.prefill)return;let t=this.options.append;t?(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 :${t}`)},n.prefill=function(){let t=this.getPrefillDistance();this.isPrefilling=t>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},n.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},n.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},e}))}(Wn)),Wn.exports}var Zn,Kn={exports:{}};function Yn(){return Zn||(Zn=1,function(t){!function(e,n){t.exports?t.exports=n(e,Qn(),Hn()):n(e,e.InfiniteScroll,e.fizzyUIUtils)}(window,(function(t,e,n){let i=e.prototype;return Object.assign(e.defaults,{scrollThreshold:400}),e.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let t=this.options.scrollThreshold;(t||0===t)&&this.enableScrollWatch()},e.destroy.scrollWatch=function(){this.disableScrollWatch()},i.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},i.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},i.bindScrollWatchEvents=function(e){let n=e?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.pageScrollHandler),t[n]("resize",this.resizeHandler)},i.onPageScroll=e.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),i.getBottomDistance=function(){let e,n;return this.options.elementScroll?(e=this.scroller.scrollHeight,n=this.scroller.scrollTop+this.scroller.clientHeight):(e=this.top+this.element.clientHeight,n=t.scrollY+this.windowHeight),e-n},i.onResize=function(){this.updateMeasurements()},n.debounceMethod(e,"onResize",150),e}))}(Kn)),Kn.exports}var ti,ei={exports:{}};function ni(){return ti||(ti=1,function(t){!function(e,n){t.exports?t.exports=n(e,Qn(),Hn()):n(e,e.InfiniteScroll,e.fizzyUIUtils)}(window,(function(t,e,n){let i=e.prototype;Object.assign(e.defaults,{history:"replace"});let r=document.createElement("a");return e.create.history=function(){if(!this.options.history)return;r.href=this.getAbsolutePath(),(r.origin||r.protocol+"//"+r.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${r.origin} on ${location.origin} . History behavior disabled.`)},i.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)},i.bindHistoryAppendEvents=function(e){let n=e?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.scrollHistoryHandler),t[n]("unload",this.unloadHandler)},i.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},e.destroy.history=i.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},i.onAppendHistory=function(t,e,n){if(!n||!n.length)return;let i=n[0],a=this.getElementScrollY(i);r.href=e,this.scrollPages.push({top:a,path:r.href,title:t.title})},i.getElementScrollY=function(e){if(this.options.elementScroll)return e.offsetTop-this.top;return e.getBoundingClientRect().top+t.scrollY},i.onScrollHistory=function(){let t=this.getClosestScrollPage();t!=this.scrollPage&&(this.scrollPage=t,this.setHistory(t.title,t.path))},n.debounceMethod(e,"onScrollHistory",150),i.getClosestScrollPage=function(){let e,n;e=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:t.scrollY+this.windowHeight/2;for(let t of this.scrollPages){if(t.top>=e)break;n=t}return n},i.setHistory=function(t,e){let n=this.options.history;n&&history[n+"State"]&&(history[n+"State"](null,t,e),this.options.historyTitle&&(document.title=t),this.dispatchEvent("history",null,[t,e]))},i.onUnload=function(){if(0===this.scrollPage.top)return;let e=t.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,e)},i.onPageLoadHistory=function(t,e){this.setHistory(t.title,e)},e}))}(ei)),ei.exports}var ii,ri={exports:{}};function ai(){return ii||(ii=1,function(t){!function(e,n){t.exports?t.exports=n(e,Qn(),Hn()):n(e,e.InfiniteScroll,e.fizzyUIUtils)}(window,(function(t,e,n){class i{constructor(t,e){this.element=t,this.infScroll=e,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),e.on("request",this.disable.bind(this)),e.on("load",this.enable.bind(this)),e.on("error",this.hide.bind(this)),e.on("last",this.hide.bind(this))}onClick(t){t.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 e.create.button=function(){let t=n.getQueryElement(this.options.button);t&&(this.button=new i(t,this))},e.destroy.button=function(){this.button&&this.button.destroy()},e.Button=i,e}))}(ri)),ri.exports}var si,oi={exports:{}};function li(){return si||(si=1,function(t){!function(e,n){t.exports?t.exports=n(e,Qn(),Hn()):n(e,e.InfiniteScroll,e.fizzyUIUtils)}(window,(function(t,e,n){let i=e.prototype;function r(t){s(t,"none")}function a(t){s(t,"block")}function s(t,e){t&&(t.style.display=e)}return e.create.status=function(){let t=n.getQueryElement(this.options.status);t&&(this.statusElement=t,this.statusEventElements={request:t.querySelector(".infinite-scroll-request"),error:t.querySelector(".infinite-scroll-error"),last:t.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},i.bindHideStatus=function(t){let e=this.options.append?"append":"load";this[t](e,this.hideAllStatus)},i.showRequestStatus=function(){this.showStatus("request")},i.showErrorStatus=function(){this.showStatus("error")},i.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},i.showStatus=function(t){a(this.statusElement),this.hideStatusEventElements(),a(this.statusEventElements[t])},i.hideAllStatus=function(){r(this.statusElement),this.hideStatusEventElements()},i.hideStatusEventElements=function(){for(let t in this.statusEventElements){r(this.statusEventElements[t])}},e}))}(oi)),oi.exports}
5
- /*!
6
- * Infinite Scroll v4.0.1
7
- * Automatically add next page
8
- *
9
- * Licensed GPLv3 for open source use
10
- * or Infinite Scroll Commercial License for commercial use
11
- *
12
- * https://infinite-scroll.com
13
- * Copyright 2018-2020 Metafizzy
14
- */!function(t){t.exports&&(t.exports=function(t){return t}(Qn(),Xn(),Yn(),ni(),ai(),li()))}(qn);var ui=qn.exports;var ci={exports:{}};
15
- /*!
16
- * Lang.js for Laravel localization in JavaScript.
17
- *
18
- * @version 1.1.12
19
- * @license MIT https://github.com/rmariuzzo/Lang.js/blob/master/LICENSE
20
- * @site https://github.com/rmariuzzo/Lang.js
21
- * @author Rubens Mariuzzo <rubens@mariuzzo.com>
22
- */!function(t,e){t.exports=function(){function t(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}function e(t){return"-Inf"===t?-1/0:"+Inf"===t||"Inf"===t||"*"===t?1/0:parseInt(t,10)}var n=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,i=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,r={locale:"en"},a=function(e){e=e||{},this.locale=e.locale||t()||r.locale,this.fallback=e.fallback,this.messages=e.messages};return a.prototype.setMessages=function(t){this.messages=t},a.prototype.getLocale=function(){return this.locale||this.fallback},a.prototype.setLocale=function(t){this.locale=t},a.prototype.getFallback=function(){return this.fallback},a.prototype.setFallback=function(t){this.fallback=t},a.prototype.has=function(t,e){return!("string"!=typeof t||!this.messages)&&null!==this._getMessage(t,e)},a.prototype.get=function(t,e,n){if(!this.has(t,n))return t;var i=this._getMessage(t,n);return null===i?t:(e&&(i=this._applyReplacements(i,e)),i)},a.prototype.trans=function(t,e){return this.get(t,e)},a.prototype.choice=function(t,e,n,r){(n=void 0!==n?n:{}).count=e;var a=this.get(t,n,r);if(null==a)return a;for(var s=a.split("|"),o=[],l=0;l<s.length;l++)if(s[l]=s[l].trim(),i.test(s[l])){var u=s[l].split(/\s/);o.push(u.shift()),s[l]=u.join(" ")}if(1===s.length)return a;for(var c=0;c<o.length;c++)if(this._testInterval(e,o[c]))return s[c];return r=r||this._getLocale(t),s[this._getPluralForm(e,r)]},a.prototype.transChoice=function(t,e,n){return this.choice(t,e,n)},a.prototype._parseKey=function(t,e){if("string"!=typeof t||"string"!=typeof e)return null;var n=t.split("."),i=n[0].replace(/\//g,".");return{source:e+"."+i,sourceFallback:this.getFallback()+"."+i,entries:n.slice(1)}},a.prototype._getMessage=function(t,e){if(e=e||this.getLocale(),t=this._parseKey(t,e),void 0===this.messages[t.source]&&void 0===this.messages[t.sourceFallback])return null;var n=this.messages[t.source],i=t.entries.slice(),r=i.join(".");if("string"!=typeof(n=void 0!==n?this._getValueInKey(n,r):void 0)&&this.messages[t.sourceFallback])for(n=this.messages[t.sourceFallback],i=t.entries.slice(),r="";i.length&&void 0!==n;)n[r=r?r.concat(".",i.shift()):i.shift()]&&(n=n[r],r="");return"string"!=typeof n?null:n},a.prototype._getValueInKey=function(t,e){if("string"==typeof t[e])return t[e];for(var n=(e=(e=e.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),i=0,r=n.length;i<r;++i){var a=n.slice(0,i+1).join("."),s=n.slice(i+1,n.length).join(".");if(t[a])return this._getValueInKey(t[a],s)}return t},a.prototype._getLocale=function(t){return t=this._parseKey(t,this.locale),this.messages[t.source]?this.locale:this.messages[t.sourceFallback]?this.fallback:null},a.prototype._findMessageInTree=function(t,e){for(;t.length&&void 0!==e;){var n=t.join(".");if(e[n]){e=e[n];break}e=e[t.shift()]}return e},a.prototype._sortReplacementKeys=function(t,e){return e.length-t.length},a.prototype._applyReplacements=function(t,e){return Object.keys(e).sort(this._sortReplacementKeys).forEach((function(n){t=t.replace(new RegExp(":"+n,"gi"),(function(t){var i=e[n];return t===t.toUpperCase()?i.toUpperCase():t===t.replace(/\w/i,(function(t){return t.toUpperCase()}))?i.charAt(0).toUpperCase()+i.slice(1):i}))})),t},a.prototype._testInterval=function(t,i){if("string"!=typeof i)throw"Invalid interval: should be a string.";var r=(i=i.trim()).match(n);if(!r)throw"Invalid interval: "+i;if(!r[2]){var a=(r=r.filter((function(t){return!!t})))[1],s=e(r[2]);s===1/0&&(s=-1/0);var o=e(r[3]),l=r[4];return("["===a?t>=s:t>s)&&("]"===l?t<=o:t<o)}for(var u=r[2].split(","),c=0;c<u.length;c++)if(parseInt(u[c],10)===t)return!0;return!1},a.prototype._getPluralForm=function(t,e){switch(e){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==t?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===t||1===t?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2;case"cs":case"sk":return 1==t?0:t>=2&&t<=4?1:2;case"ga":return 1==t?0:2==t?1:2;case"lt":return t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2;case"sl":return t%100==1?0:t%100==2?1:t%100==3||t%100==4?2:3;case"mk":return t%10==1?0:1;case"mt":return 1==t?0:0===t||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3;case"lv":return 0===t?0:t%10==1&&t%100!=11?1:2;case"pl":return 1==t?0:t%10>=2&&t%10<=4&&(t%100<12||t%100>14)?1:2;case"cy":return 1==t?0:2==t?1:8==t||11==t?2:3;case"ro":return 1==t?0:0===t||t%100>0&&t%100<20?1:2;case"ar":return 0===t?0:1==t?1:2==t?2:t%100>=3&&t%100<=10?3:t%100>=11&&t%100<=99?4:5}},a}()}(ci);var fi=ci.exports;class hi{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(t,e=void 0,n=null){let i=Array.isArray(t),r=i?this.getUrl(...t):this.getUrl(t);t=i?t[0]:t,n=n||this.endpointsMethods[t]||"post";let a=this.endpointsHeaders[t];if("get"===n&&e instanceof FormData){let t={};Array.from(e.entries()).forEach((function(e){t[e[0]]=e[1]})),e={params:t}}return a&&"get"===n&&(e=e?Object.assign(e,a):a),this.webEndpoints.includes(t)?r=salla.url.get(r):"http"!==r.substring(0,4)&&(r=salla.url.api(r)),Salla.api.request(r,e,n,{headers:a})}request(t,e=void 0,n=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(t,e,n)):this.normalRequest(t,e,n)}getUrl(t){let e=this.endpoints[t]||t;const n=/{[^{}]+}/i;for(let t=1;t<arguments.length;t++)e=e.replace(n,arguments[t]);return e}event(){return salla.event[this.className]}}class di extends hi{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("profile::info.fetched",(()=>this._checkCurrentCart))}_checkCurrentCart(){let t=salla.storage.get("cart"),e=salla.config.get("user")?.id;t&&t.id&&(t.user_id!==e||t.store_id!==config.store?.id)&&(salla.log("cart",{user_id:t.user_id,store_id:t.store_id}),salla.log("current",{user_id:e,store_id:config.store?.id}),salla.log("Api:: case2 => The cart is not belong to current "+(t.user_id!==e?"user":"store")+"!"),salla.cart.api.reset())}async getCurrentCartId(){if(salla.cart.api.latestCart)return salla.cart.api.latestCart.cart.id;let t=salla.storage.get("cart.id");if(t)return t;let e=await this.latest();return salla.cart.api.latestCart=e.data,salla.cart.api.latestCart.cart.id}getUploadImageEndpoint(t){return salla.url.api(this.getUrl("uploadImage",t||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((t=>(salla.storage.set("cart",t.data.cart),salla.event.cart.latestFetched(t),t))).catch((t=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(t),t}))}async details(t,e=[]){return t=t||await this.getCurrentCartId(),this.request(["details",t],{params:{with:e}}).then((function(t){return salla.cart.event.detailsFetched(t),t})).catch((function(t){throw salla.cart.event.detailsNotFetched(t),t}))}async quickAdd(t,e){return this.addItem({id:t,quantity:e,endpoint:"quickAdd"})}async addItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no product "id"!';return salla.cart.event.itemAddedFailed(t),salla.api.errorPromise(t)}let n=salla.form.getPossibleValue(e.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(e.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let i=await this.getCurrentCartId();return this.request([n,i,e.id],e.payload).then((function(t){return salla.cart.event.itemAdded(t,e.id),t})).catch((function(t){throw salla.cart.event.itemAddedFailed(t,e.id),t}))}async deleteItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no "id"!';return salla.cart.event.itemDeletedFailed(t),salla.api.errorPromise(t)}let n=await this.getCurrentCartId();return this.request(["deleteItem",n,e.id]).then((function(t){return salla.cart.event.itemDeleted(t,e.id),t})).catch((function(t){throw salla.cart.event.itemDeletedFailed(t,e.id),t}))}async updateItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no "id"!';return salla.cart.event.itemUpdatedFailed(t),salla.api.errorPromise(t)}let n=await this.getCurrentCartId();return"Object"===e.payload.constructor?.name?e.payload._method="PUT":e.payload.append("_method","PUT"),this.request(["updateItem",n,e.id],e.payload).then((function(t){return salla.cart.event.itemUpdated(t,e.id),t})).catch((function(t){throw salla.cart.event.itemUpdatedFailed(t,e.id),t}))}async deleteImage(t){if(!(t=salla.form.getPossibleValue(t,["id","image_id","photo_id"]))){let t='There is no "id"!';return salla.cart.event.imageNotDeleted(t),salla.api.errorPromise(t)}let e=await this.getCurrentCartId();return this.request(["deleteImage",e,t]).then((function(e){return salla.cart.event.imageDeleted(e,t),e})).catch((function(e){throw salla.cart.event.imageNotDeleted(e,t),e}))}async status(t){return this.request(["status",t||await this.getCurrentCartId()],{params:{has_apple_pay:!!window.ApplePaySession}})}async submit(){this.status(await this.getCurrentCartId()).then((t=>{let e=t.data.next_step.to;if(!["checkout","refresh","login"].includes(e)){let t="Can't find next_step );";throw salla.cart.event.submitFailed(t),t}if(salla.cart.event.submitted(t),"login"===e)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((t=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===e?window.location.href=t.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(t){throw salla.cart.event.submitFailed(t),t}))}getCartPayload(t){let e=t?.data||("object"==typeof t?t:void 0);return t=e?salla.form.getPossibleValue(e,["prod_id","product_id","item_id","id"]):t,e="object"==typeof e?e:void 0,{id:t,payload:e}}normalRequest(t,e=void 0,n=null){return super.normalRequest(t,e,n).catch((t=>{throw 403===t?.response?.status&&(salla.cart.api.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),t}))}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()}async addCoupon(t){if(t=t.data||t,!(t=salla.form.getPossibleValue(t,["coupon"]))){let t=new Error('There is no "Coupon Code"!');return t.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),salla.api.errorPromise(t)}let e=await salla.cart.api.getCurrentCartId();return this.request(["addCoupon",e],{coupon:t}).then((function(t){return salla.event.cart.couponAdded(t,e),t})).catch((function(t){throw salla.event.cart.couponAdditionFailed(t,e),t}))}async deleteCoupon(){let t=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",t],{}).then((function(e){return salla.event.cart.couponDeleted(e,t),e})).catch((function(e){throw salla.event.cart.couponDeletionFailed(e,t),e}))}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then((t=>(salla.event.cart.quickOrderSettingFetched(t),t))).catch((t=>{throw salla.event.cart.quickOrderSettingFailed(t),t}))}createQuickOrder(t){return this.request("createQuickOrder",t).then((t=>(salla.event.cart.quickOrderSucceeded(t),t))).catch((t=>{throw salla.event.cart.quickOrderFailed(t),t}))}async priceQuote(t){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",t),void salla.event.dispatch("login::open")):this.request(["priceQuote",t||await this.getCurrentCartId()]).then((t=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(t).then((()=>(setTimeout((()=>window.location.href=salla.url.get("/")),1e3),t)))))).catch((t=>salla.event.cart.priceQuoteFailed(t).then((()=>{throw 404===t.error?.code&&window.location.reload(),t}))))}}class pi extends hi{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((t=>(salla.loyalty.event.programFetched(t),t))).catch((t=>{throw salla.loyalty.event.programNotFetched(t),t}))}async exchange(t,e=null){if(!(t=salla.form.getPossibleValue(t,["id","loyalty_prize_id","prize_id"]))){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(t),salla.api.errorPromise(t)}if(!(e=e||await salla.cart.getCurrentCartId())){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(t),salla.api.errorPromise(t)}return this.request("exchange",{loyalty_prize_id:t,cart_id:e}).then((function(e){return salla.loyalty.event.exchangeSucceeded(e,t),e})).catch((function(e){throw salla.loyalty.event.exchangeFailed(e,t),e}))}async reset(t=null){if(!(t=t||await salla.cart.getCurrentCartId())){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(t),salla.api.errorPromise(t)}return this.request("reset",{cart_id:t}).then((t=>(salla.loyalty.event.resetSucceeded(t),t))).catch((t=>{throw salla.loyalty.event.resetFailed(t),t}))}}class vi extends hi{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(t,e){salla.api.auth.afterLoginEvent={event:t,payload:e}}setCanRedirect(t){salla.api.auth.canRedirect_=t}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(t){t?.data&&(t=t.data);let e=salla.form.getPossibleValue(t,["type"]);if(!["email","mobile"].includes(e)){let t="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(t),salla.api.errorPromise(t)}return this.request(["login",e],t).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t}))}async verify(t,e=!0){let n=salla.form.getPossibleValue(t,["type"]);if(!n){let t="Failed to know what's login type!";return salla.auth.event.verificationFailed(t),salla.api.errorPromise(t)}e=!1!==salla.form.getPossibleValue(t,["supportWebAuth"])&&e,salla.auth.event.next_event&&(t.next_event=salla.auth.event.next_event);let i=await salla.auth.api.request(["verify",n],t);if(200!==i?.status)return salla.auth.event.verificationFailed(i,n),salla.api.errorPromise(i);let r="authenticated"===i.data?.case;return r&&salla.auth.event.tokenFetched(i.data.token),e&&await salla.auth.api.request("auth/jwt"),r&&salla.auth.event.loggedIn(i).then((()=>salla.auth.api.afterUserLogin())),salla.auth.event.verified(i,n),salla.api.successPromise(i)}resend(t){let e;return(t=t.data||t).type=t.type||"mobile","mobile"!==t.type||t.phone&&t.country_code?"email"!==t.type||t.email?this.request("resend",t).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e})):(salla.auth.event.codeNotSent(e="There is no email!",t),salla.api.errorPromise(e)):(salla.auth.event.codeNotSent(e="There is no phone or country_code!",t),salla.api.errorPromise(e))}register(t){let e;return t.data&&(e=t.element,t=t.data),salla.auth.event.next_event&&(t.next_event=salla.auth.event.next_event),this.request("register",t).then((async function(t){return salla.auth.event.registered.call(e,t),"authenticated"===t.data?.case&&(salla.auth.event.tokenFetched(t.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(t),salla.auth.api.afterUserLogin()),t})).catch((function(t){throw salla.auth.event.registrationFailed.call(e,t),t}))}logout(t="twilight"){return salla.storage.clearAll(),salla.cookie.clearAll(),t=encodeURI(t),salla.auth.event.loggedOut().then((()=>{let e=salla.url.get(`logout?from=${t}`);console.log(`Going to ${e}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=e}catch(t){salla.log(t)}}))}refresh(){return this.request("refresh").then((function(t){return salla.auth.event.tokenFetched(t.data.token),t})).catch((function(t){throw salla.auth.event.refreshFailed(t),t}))}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}}class gi extends hi{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(t){let e=salla.form.getPossibleValue(t?.data||t,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:e}),location.href=salla.form.getPossibleValue(t?.data||t,["url"])}cancel(t){return t=t||Salla.config.get("page.id"),this.request(["cancel",t],{params:{has_apple_pay:!!window.ApplePaySession}}).then((function(e){return salla.event.order.canceled(e,t),e})).catch((function(e){throw salla.event.order.notCanceled(e,t),e}))}createCartFromOrder(t){return t=t||salla.config.get("page.id"),this.request(["createCartFromOrder",t]).then((function(e){return salla.cart.reset(),salla.event.order.orderCreated(e,t),window.location.href=e.data.url,e})).catch((function(e){throw salla.event.order.orderCreationFailed(e,t),e}))}sendInvoice(t){let e=salla.form.getPossibleValue(t,["id"])||salla.config.get("page.id");if(!e||isNaN(e)){let t="There is no id!";return salla.order.event.invoiceNotSent(t),salla.api.errorPromise(t)}return this.request(["sendInvoice",e],t).then((t=>(salla.event.order.invoiceSent(t,e),t))).catch((t=>{throw salla.event.order.invoiceNotSent(t,e),t}))}}class mi extends hi{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"},this.after_init()}getPrice(t){let e=t.data||t,n=salla.form.getPossibleValue(e,["id","prod_id","product_id"]);return this.request(["getPrice",n],"object"==typeof e?e:void 0).then((function(t){return salla.product.event.priceUpdated(t,n),t})).catch((function(t){throw salla.product.event.priceUpdateFailed(t,n),t}))}categories(t){return this.request(["categories",t||""],null,"get").then((function(t){return salla.product.event.categoriesFetched(t),t})).catch((function(t){throw salla.product.event.categoriesFailed(t),t}))}availabilitySubscribe(t){let e=t.data||t;return t=salla.form.getPossibleValue(e,["id","prod_id"]),this.request(["availabilitySubscribe",t],"object"==typeof e?e:void 0).then((function(e){return salla.product.event.availabilitySubscribed(e,t),e})).catch((function(e){throw salla.product.event.availabilitySubscribeFailed(e,t),e}))}search(t){let e=t.data;if(e||(e={params:"string"==typeof t?{query:t}:t}),!(t=e instanceof FormData?e.get("query"):e.query||e.params?.query)){let t='There is no "query"!';return salla.product.event.searchFailed(t),salla.api.errorPromise(t)}if(t===salla.api.product.previousQuery){let t="Query is same as previous one!";return salla.product.event.searchFailed(t),salla.api.product.previousQuery=null,salla.api.errorPromise(t)}return salla.api.product.previousQuery=t,this.request("search",e,"get").then((function(e){return salla.product.event.searchResults(e,t),e})).catch((function(e){throw salla.product.event.searchFailed(e,t),e}))}offers(t){if(!(t=salla.form.getPossibleValue(t?.data|t,["product_id","id"]))){let t='There is no "product_id"!';return salla.product.event.fetchOffersFailed(t),salla.api.errorPromise(t)}return this.request(["offers",t]).then((function(e){return salla.product.event.offersFetched(e,t),e})).catch((function(e){throw salla.product.event.fetchOffersFailed(e,t),e}))}getSizeGuides(t){return this.request(`products/${t}/size-guides`,null,"get").then((e=>(salla.product.event.sizeGuideFetched(e,t),e))).catch((e=>{throw salla.product.event.sizeGuideFetchFailed(e,t),e}))}getGiftDetails(t){return this.request(["giftDetail",t]).then((e=>(salla.product.event.giftFetched(e,t),e))).catch((e=>{throw salla.product.event.giftFetchFailed(e,t),e}))}getDetails(t,e=[]){if(!Array.isArray(e)){let t="withItems should be array.";return salla.product.event.detailFetchFailed(t),salla.api.errorPromise(t)}if(!t){let t="productId is not passed.";return salla.product.event.detailFetchFailed(t),salla.api.errorPromise(t)}return this.request(["details",t],{params:{with:e}}).then((function(e){return salla.product.event.detailFetched(e,t),e})).catch((function(e){throw salla.product.event.availabilitySubscribeFailed(e,t),e}))}addGiftToCart(t,e,n=!1){return this.request(["giftToCart",t],e).then((e=>(salla.product.event.addGiftToCartSucceeded(e,t),n&&(window.location.href=e.redirect),e))).catch((e=>{throw salla.product.event.addGiftToCartFailed(e,t),e}))}uploadGiftImage(t){return this.request("giftImage",t).then((t=>(salla.product.event.giftImageUploadSucceeded(t),t))).catch((t=>{throw salla.product.event.giftImageUploadFailed(t),t}))}fetch(t){if(!t.source){const t="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}const e=!t.source_value,n="string"==typeof t.source_value&&"[]"===t.source_value,i=Array.isArray(t.source_value)&&!t.source_value.length;if((e||n||i)&&!["offers","latest","sales"].includes(t.source)){const t="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if(["categories","brands","tags","selected"].includes(t.source)&&!Array.isArray(t.source_value)){const t="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if("search"===t.source&&"string"!=typeof t.source_value){const t="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if("related"===t.source&&isNaN(t.source_value)){const t="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}return this.request(this.endpoints.fetch,{params:t},"get").then((t=>(salla.product.event.productListFetchSucceeded(t),t))).catch((t=>{throw salla.product.event.productListFetchFailed(t),t}))}}class wi extends hi{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((t=>{let e={id:t.data.id,type:"user",email:t.data.email,mobile:t.data.phone.code+t.data.phone.number,country_code:t.data.phone.country,language_code:t.data.language,currency_code:t.data.currency,notifications:t.data.notifications,pending_orders:t.data.pending_orders,avatar:t.data.avatar,first_name:t.data.first_name,last_name:t.data.last_name,fetched_at:Date.now()};return salla.config.set("user",e),salla.storage.set("user",e),salla.profile.event.infoFetched(t),t})).catch((t=>{throw salla.profile.event.infoNotFetched(t),t}))}update(t){return this.request("update",t).then((t=>(salla.profile.event.updated(t),t))).catch((t=>{throw salla.event.profile.updateFailed(t),t}))}updateContacts(t){return this.request("updateContacts",t).then((t=>(salla.profile.event.verificationCodeSent(t),t))).catch((t=>{throw salla.event.profile.updateContactsFailed(t),t}))}verify(t){return this.request("verify",t).then((t=>(salla.profile.event.verified(t),t))).catch((t=>{throw salla.event.profile.unverified(t),t}))}updateSettings(t){return this.request("updateSettings",t).then((t=>(salla.event.profile.settingsUpdated(t),t))).catch((t=>{throw salla.event.profile.updateSettingsFailed(t),t}))}delete(){return this.request("delete").then((t=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(t),window.location.href=salla.url.get("logout"),t))).catch((t=>{throw salla.event.profile.notDeleted(t),t}))}}class yi extends hi{constructor(){super(),this.namespace="comment",this.endpoints={comments:"{type}/{id}/comments"},this.after_init()}add(t){if(t?.data&&(t=t.data),"string"==typeof(t=this.getCommentPayload(t,!0)))return salla.event.comment.additionFailed(t),salla.api.errorPromise(t);if(!t.comment){let t="can't find comment content!";return salla.event.comment.additionFailed(t),salla.api.errorPromise(t)}return this.request(["comments",t.type,t.id],{comment:t.comment}).then((function(e){return salla.event.comment.added(e,t.id),e})).catch((function(e){throw salla.event.comment.additionFailed(e,t.id),e}))}getCommentPayload(t){let e={};return["id","type","comment","per_page","page"].forEach((n=>{let i=salla.form.getPossibleValue(t,[n]);i&&(e[n]=i)})),e.id?e.type&&["products","pages","product","page"].includes(e.type)?(e.type+=["product","page"].includes(e.type)?"s":"",e):"Failed to get type one of:(products, product, page, pages)!":"Failed to get id!"}fetch(t){return"string"==typeof(t=this.getCommentPayload(t))?(salla.event.comment.fetchFailed(t),salla.api.errorPromise(t)):this.request(["comments",t.type,t.id],{params:t},"get").then((function(e){return salla.event.comment.fetched(e,t),e})).catch((function(e){throw salla.event.comment.fetchFailed(e,t),e}))}getPageComments(t,e=1,n=10){return this.fetch({id:t,type:"pages",page:e,per_page:n})}getProductComments(t,e=1,n=10){return this.fetch({id:t,type:"products",page:e,per_page:n})}}class bi extends hi{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(t){if(!(t=salla.form.getPossibleValue(t.data||t,["currency","code"]))){let t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:t}}).then((function(e){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(e,t),e})).catch((function(e){throw salla.currency.event.failed(e,t),e}))}list(){return this.request("list").then((function(t){return salla.currency.event.fetched(t),t})).catch((function(t){throw salla.currency.event.failedToFetch(t),t}))}}class Si extends hi{constructor(){super(),this.namespace="document"}}class _i extends hi{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(t){let e="object"==typeof t?t:{},n=salla.form.getPossibleValue(t?.data||t,["order_id","id"]);if(!n){let t='There is no "order_id"!';return salla.event.rating.orderNotFetched(t),salla.api.errorPromise(t)}return this.request(["order",n],e).then((function(t){return salla.event.rating.orderFetched(t,n),t})).catch((function(t){throw salla.event.rating.orderNotFetched(t,n),t}))}store(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.storeFailed(t),salla.api.errorPromise(t)}return this.request("store",t).then((function(e){return salla.event.rating.storeRated(e,t),e})).catch((function(e){throw salla.event.rating.storeFailed(e,t),e}))}products(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.productsFailed(t),salla.api.errorPromise(t)}return this.request("products",t).then((function(e){return salla.event.rating.productsRated(e,t),e})).catch((function(e){throw salla.event.rating.productsFailed(e,t),e}))}shipping(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.shippingFailed(t),salla.api.errorPromise(t)}return this.request("shipping",t).then((function(e){return salla.event.rating.shippingRated(e,t),e})).catch((function(e){throw salla.event.rating.shippingFailed(e,t),e}))}}class Ei extends hi{constructor(){super(),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}toggle(t){return salla.storage.get("salla::wishlist",[]).includes(t)?this.remove(t):this.add(t)}add(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),salla.api.errorPromise(e)):(t=salla.form.getPossibleValue(t?.data||t,["product_id","id"]))?this.request(["add",t]).then((e=>(this.updateWishlistStorage(t),salla.wishlist.event.added(e,t),e))).catch((function(e){throw salla.wishlist.event.additionFailed(e,t),e})):(salla.wishlist.event.additionFailed(e="Failed to get product id!"),salla.api.errorPromise(e))}remove(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),salla.api.errorPromise(e)):(t=salla.form.getPossibleValue(t?.data||t,["product_id","id"]))?this.request(["remove",t]).then((e=>(this.updateWishlistStorage(t,!1),salla.wishlist.event.removed(e,t),e))).catch((function(e){throw salla.wishlist.event.removingFailed(e,t),e})):(salla.wishlist.event.removingFailed(e="Failed to get id!"),salla.api.errorPromise(e))}updateWishlistStorage(t,e=!0){let n=salla.storage.get("salla::wishlist",[]);e?n.push(t):n.splice(n.indexOf(t),1),salla.storage.set("salla::wishlist",n)}}class xi extends hi{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((t=>(salla.scope.event.fetched(t),t))).catch((t=>{throw salla.scope.event.notFetched(t),t}))}change(t){return this.request("scopes",t).then((t=>(salla.scope.event.changeSucceeded(t),t))).catch((t=>{throw salla.scope.event.changeFailed(t),t}))}getProductAvailability(t=null){return this.request(`scopes/availability?product_id=${t}`,null,"get").then((e=>(salla.scope.event.productAvailabilityFetched(e,t),e))).catch((t=>{throw salla.scope.event.productAvailabilityNotFetched(t),t}))}}class ji extends hi{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(t,e=!0){if(!t){let t="Please provide product id.";return salla.booking.event.additionFailed(t),salla.api.errorPromise(t)}return this.request(["add",t]).then((function(t){return salla.booking.event.added(t),e&&"booking"===t.data.redirect.to&&(window.location.href=t.data.redirect.url),t})).catch((function(t){throw salla.booking.event.additionFailed(t),t}))}}class Oi extends hi{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(t){if(!t){let t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",t]).then((function(e){return salla.event.landing.detailsFetched(e,t),e})).catch((function(e){throw salla.event.landing.getDetailsFailed(e,t),e}))}createCartFromPage(t){if(!t){let t="page landing id not passed";return salla.event.landing.orderCreationFailed(t),salla.api.errorPromise(t)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",t),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",t]).then((function(e){return salla.event.landing.orderCreated(e,t).then((()=>location.href=e.data.url)),e})).catch((function(e){throw salla.event.landing.orderCreationFailed(e,t),e}))}}var ki,Fi={exports:{}},Ai=function(t,e){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return t.apply(e,n)}},Ti=Ai,Ri=Object.prototype.toString,Ii=(ki=Object.create(null),function(t){var e=Ri.call(t);return ki[e]||(ki[e]=e.slice(8,-1).toLowerCase())});function Ci(t){return t=t.toLowerCase(),function(e){return Ii(e)===t}}function Pi(t){return Array.isArray(t)}function Li(t){return void 0===t}var Di=Ci("ArrayBuffer");function Ni(t){return null!==t&&"object"==typeof t}function $i(t){if("object"!==Ii(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}var qi=Ci("Date"),Ui=Ci("File"),Mi=Ci("Blob"),zi=Ci("FileList");function Bi(t){return"[object Function]"===Ri.call(t)}var Ji=Ci("URLSearchParams");function Gi(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),Pi(t))for(var n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.call(null,t[r],r,t)}var Hi,Qi=(Hi="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(t){return Hi&&t instanceof Hi}),Vi={isArray:Pi,isArrayBuffer:Di,isBuffer:function(t){return null!==t&&!Li(t)&&null!==t.constructor&&!Li(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){var e="[object FormData]";return t&&("function"==typeof FormData&&t instanceof FormData||Ri.call(t)===e||Bi(t.toString)&&t.toString()===e)},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&Di(t.buffer)},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:Ni,isPlainObject:$i,isUndefined:Li,isDate:qi,isFile:Ui,isBlob:Mi,isFunction:Bi,isStream:function(t){return Ni(t)&&Bi(t.pipe)},isURLSearchParams:Ji,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:Gi,merge:function t(){var e={};function n(n,i){$i(e[i])&&$i(n)?e[i]=t(e[i],n):$i(n)?e[i]=t({},n):Pi(n)?e[i]=n.slice():e[i]=n}for(var i=0,r=arguments.length;i<r;i++)Gi(arguments[i],n);return e},extend:function(t,e,n){return Gi(e,(function(e,i){t[i]=n&&"function"==typeof e?Ti(e,n):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t},inherits:function(t,e,n,i){t.prototype=Object.create(e.prototype,i),t.prototype.constructor=t,n&&Object.assign(t.prototype,n)},toFlatObject:function(t,e,n){var i,r,a,s={};e=e||{};do{for(r=(i=Object.getOwnPropertyNames(t)).length;r-- >0;)s[a=i[r]]||(e[a]=t[a],s[a]=!0);t=Object.getPrototypeOf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},kindOf:Ii,kindOfTest:Ci,endsWith:function(t,e,n){t=String(t),(void 0===n||n>t.length)&&(n=t.length),n-=e.length;var i=t.indexOf(e,n);return-1!==i&&i===n},toArray:function(t){if(!t)return null;var e=t.length;if(Li(e))return null;for(var n=new Array(e);e-- >0;)n[e]=t[e];return n},isTypedArray:Qi,isFileList:zi},Wi=Vi;function Xi(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Zi=function(t,e,n){if(!e)return t;var i;if(n)i=n(e);else if(Wi.isURLSearchParams(e))i=e.toString();else{var r=[];Wi.forEach(e,(function(t,e){null!=t&&(Wi.isArray(t)?e+="[]":t=[t],Wi.forEach(t,(function(t){Wi.isDate(t)?t=t.toISOString():Wi.isObject(t)&&(t=JSON.stringify(t)),r.push(Xi(e)+"="+Xi(t))})))})),i=r.join("&")}if(i){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+i}return t},Ki=Vi;function Yi(){this.handlers=[]}Yi.prototype.use=function(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},Yi.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},Yi.prototype.forEach=function(t){Ki.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var tr,er,nr=Yi,ir=Vi;function rr(){if(er)return tr;er=1;var t=Vi;function e(t,e,n,i,r){Error.call(this),this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),i&&(this.request=i),r&&(this.response=r)}t.inherits(e,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 n=e.prototype,i={};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(t){i[t]={value:t}})),Object.defineProperties(e,i),Object.defineProperty(n,"isAxiosError",{value:!0}),e.from=function(i,r,a,s,o,l){var u=Object.create(n);return t.toFlatObject(i,u,(function(t){return t!==Error.prototype})),e.call(u,i.message,r,a,s,o),u.name=i.name,l&&Object.assign(u,l),u},tr=e}var ar,sr,or,lr,ur,cr,fr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function hr(){if(sr)return ar;sr=1;var t=Vi;return ar=function(n,i){i=i||new FormData;var r=[];function a(n){return null===n?"":t.isDate(n)?n.toISOString():t.isArrayBuffer(n)||t.isTypedArray(n)?"function"==typeof Blob?new Blob([n]):e.Buffer.from(n):n}return function e(n,s){if(t.isPlainObject(n)||t.isArray(n)){if(-1!==r.indexOf(n))throw Error("Circular reference detected in "+s);r.push(n),t.forEach(n,(function(n,r){if(!t.isUndefined(n)){var o,l=s?s+"."+r:r;if(n&&!s&&"object"==typeof n)if(t.endsWith(r,"{}"))n=JSON.stringify(n);else if(t.endsWith(r,"[]")&&(o=t.toArray(n)))return void o.forEach((function(e){!t.isUndefined(e)&&i.append(l,a(e))}));e(n,l)}})),r.pop()}else i.append(s,a(n))}(n),i},ar}function dr(){if(lr)return or;lr=1;var t=rr();return or=function(e,n,i){var r=i.config.validateStatus;i.status&&r&&!r(i.status)?n(new t("Request failed with status code "+i.status,[t.ERR_BAD_REQUEST,t.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):e(i)}}function pr(){if(cr)return ur;cr=1;var t=Vi;return ur=t.isStandardBrowserEnv()?{write:function(e,n,i,r,a,s){var o=[];o.push(e+"="+encodeURIComponent(n)),t.isNumber(i)&&o.push("expires="+new Date(i).toGMTString()),t.isString(r)&&o.push("path="+r),t.isString(a)&&o.push("domain="+a),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}}var vr,gr,mr,wr,yr,br,Sr,_r,Er,xr,jr,Or,kr=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},Fr=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Ar=function(t,e){return t&&!kr(e)?Fr(t,e):e};function Tr(){if(gr)return vr;gr=1;var t=Vi,e=["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 vr=function(n){var i,r,a,s={};return n?(t.forEach(n.split("\n"),(function(n){if(a=n.indexOf(":"),i=t.trim(n.substr(0,a)).toLowerCase(),r=t.trim(n.substr(a+1)),i){if(s[i]&&e.indexOf(i)>=0)return;s[i]="set-cookie"===i?(s[i]?s[i]:[]).concat([r]):s[i]?s[i]+", "+r:r}})),s):s},vr}function Rr(){if(wr)return mr;wr=1;var t=Vi;return mr=t.isStandardBrowserEnv()?function(){var e,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");function r(t){var e=t;return n&&(i.setAttribute("href",e),e=i.href),i.setAttribute("href",e),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}return e=r(window.location.href),function(n){var i=t.isString(n)?r(n):n;return i.protocol===e.protocol&&i.host===e.host}}():function(){return!0}}function Ir(){if(br)return yr;br=1;var t=rr();function e(e){t.call(this,null==e?"canceled":e,t.ERR_CANCELED),this.name="CanceledError"}return Vi.inherits(e,t,{__CANCEL__:!0}),yr=e}function Cr(){return _r?Sr:(_r=1,Sr=function(t){var e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""})}function Pr(){if(xr)return Er;xr=1;var t=Vi,e=dr(),n=pr(),i=Zi,r=Ar,a=Tr(),s=Rr(),o=fr,l=rr(),u=Ir(),c=Cr();return Er=function(f){return new Promise((function(h,d){var p,v=f.data,g=f.headers,m=f.responseType;function w(){f.cancelToken&&f.cancelToken.unsubscribe(p),f.signal&&f.signal.removeEventListener("abort",p)}t.isFormData(v)&&t.isStandardBrowserEnv()&&delete g["Content-Type"];var y=new XMLHttpRequest;if(f.auth){var b=f.auth.username||"",S=f.auth.password?unescape(encodeURIComponent(f.auth.password)):"";g.Authorization="Basic "+btoa(b+":"+S)}var _=r(f.baseURL,f.url);function E(){if(y){var t="getAllResponseHeaders"in y?a(y.getAllResponseHeaders()):null,n={data:m&&"text"!==m&&"json"!==m?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:t,config:f,request:y};e((function(t){h(t),w()}),(function(t){d(t),w()}),n),y=null}}if(y.open(f.method.toUpperCase(),i(_,f.params,f.paramsSerializer),!0),y.timeout=f.timeout,"onloadend"in y?y.onloadend=E:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(E)},y.onabort=function(){y&&(d(new l("Request aborted",l.ECONNABORTED,f,y)),y=null)},y.onerror=function(){d(new l("Network Error",l.ERR_NETWORK,f,y,y)),y=null},y.ontimeout=function(){var t=f.timeout?"timeout of "+f.timeout+"ms exceeded":"timeout exceeded",e=f.transitional||o;f.timeoutErrorMessage&&(t=f.timeoutErrorMessage),d(new l(t,e.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,f,y)),y=null},t.isStandardBrowserEnv()){var x=(f.withCredentials||s(_))&&f.xsrfCookieName?n.read(f.xsrfCookieName):void 0;x&&(g[f.xsrfHeaderName]=x)}"setRequestHeader"in y&&t.forEach(g,(function(t,e){void 0===v&&"content-type"===e.toLowerCase()?delete g[e]:y.setRequestHeader(e,t)})),t.isUndefined(f.withCredentials)||(y.withCredentials=!!f.withCredentials),m&&"json"!==m&&(y.responseType=f.responseType),"function"==typeof f.onDownloadProgress&&y.addEventListener("progress",f.onDownloadProgress),"function"==typeof f.onUploadProgress&&y.upload&&y.upload.addEventListener("progress",f.onUploadProgress),(f.cancelToken||f.signal)&&(p=function(t){y&&(d(!t||t&&t.type?new u:t),y.abort(),y=null)},f.cancelToken&&f.cancelToken.subscribe(p),f.signal&&(f.signal.aborted?p():f.signal.addEventListener("abort",p))),v||(v=null);var j=c(_);j&&-1===["http","https","file"].indexOf(j)?d(new l("Unsupported protocol "+j+":",l.ERR_BAD_REQUEST,f)):y.send(v)}))},Er}var Lr=Vi,Dr=function(t,e){ir.forEach(t,(function(n,i){i!==e&&i.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[i])}))},Nr=rr(),$r=fr,qr=hr(),Ur={"Content-Type":"application/x-www-form-urlencoded"};function Mr(t,e){!Lr.isUndefined(t)&&Lr.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var zr,Br={transitional:$r,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==r.default&&"[object process]"===Object.prototype.toString.call(r.default))&&(zr=Pr()),zr),transformRequest:[function(t,e){if(Dr(e,"Accept"),Dr(e,"Content-Type"),Lr.isFormData(t)||Lr.isArrayBuffer(t)||Lr.isBuffer(t)||Lr.isStream(t)||Lr.isFile(t)||Lr.isBlob(t))return t;if(Lr.isArrayBufferView(t))return t.buffer;if(Lr.isURLSearchParams(t))return Mr(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString();var n,i=Lr.isObject(t),r=e&&e["Content-Type"];if((n=Lr.isFileList(t))||i&&"multipart/form-data"===r){var a=this.env&&this.env.FormData;return qr(n?{"files[]":t}:t,a&&new a)}return i||"application/json"===r?(Mr(e,"application/json"),function(t,e,n){if(Lr.isString(t))try{return(e||JSON.parse)(t),Lr.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(n||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||Br.transitional,n=e&&e.silentJSONParsing,i=e&&e.forcedJSONParsing,r=!n&&"json"===this.responseType;if(r||i&&Lr.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(r){if("SyntaxError"===t.name)throw Nr.from(t,Nr.ERR_BAD_RESPONSE,this,null,this.response);throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Or?jr:(Or=1,jr=null)},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};Lr.forEach(["delete","get","head"],(function(t){Br.headers[t]={}})),Lr.forEach(["post","put","patch"],(function(t){Br.headers[t]=Lr.merge(Ur)}));var Jr,Gr,Hr=Br,Qr=Vi,Vr=Hr;function Wr(){return Gr?Jr:(Gr=1,Jr=function(t){return!(!t||!t.__CANCEL__)})}var Xr=Vi,Zr=function(t,e,n){var i=this||Vr;return Qr.forEach(n,(function(n){t=n.call(i,t,e)})),t},Kr=Wr(),Yr=Hr,ta=Ir();function ea(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ta}var na,ia,ra=Vi,aa=function(t,e){e=e||{};var n={};function i(t,e){return ra.isPlainObject(t)&&ra.isPlainObject(e)?ra.merge(t,e):ra.isPlainObject(e)?ra.merge({},e):ra.isArray(e)?e.slice():e}function r(n){return ra.isUndefined(e[n])?ra.isUndefined(t[n])?void 0:i(void 0,t[n]):i(t[n],e[n])}function a(t){if(!ra.isUndefined(e[t]))return i(void 0,e[t])}function s(n){return ra.isUndefined(e[n])?ra.isUndefined(t[n])?void 0:i(void 0,t[n]):i(void 0,e[n])}function o(n){return n in e?i(t[n],e[n]):n in t?i(void 0,t[n]):void 0}var l={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o};return ra.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=l[t]||r,i=e(t);ra.isUndefined(i)&&e!==o||(n[t]=i)})),n};function sa(){return ia?na:(ia=1,na={version:"0.27.2"})}var oa=sa().version,la=rr(),ua={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){ua[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}}));var ca={};ua.transitional=function(t,e,n){function i(t,e){return"[Axios v"+oa+"] Transitional option '"+t+"'"+e+(n?". "+n:"")}return function(n,r,a){if(!1===t)throw new la(i(r," has been removed"+(e?" in "+e:"")),la.ERR_DEPRECATED);return e&&!ca[r]&&(ca[r]=!0,console.warn(i(r," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,r,a)}};var fa,ha,da,pa,va,ga,ma={assertOptions:function(t,e,n){if("object"!=typeof t)throw new la("options must be an object",la.ERR_BAD_OPTION_VALUE);for(var i=Object.keys(t),r=i.length;r-- >0;){var a=i[r],s=e[a];if(s){var o=t[a],l=void 0===o||s(o,a,t);if(!0!==l)throw new la("option "+a+" must be "+l,la.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new la("Unknown option "+a,la.ERR_BAD_OPTION)}},validators:ua},wa=Vi,ya=Zi,ba=nr,Sa=function(t){return ea(t),t.headers=t.headers||{},t.data=Zr.call(t,t.data,t.headers,t.transformRequest),t.headers=Xr.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),Xr.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Yr.adapter)(t).then((function(e){return ea(t),e.data=Zr.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return Kr(e)||(ea(t),e&&e.response&&(e.response.data=Zr.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},_a=aa,Ea=Ar,xa=ma,ja=xa.validators;function Oa(t){this.defaults=t,this.interceptors={request:new ba,response:new ba}}Oa.prototype.request=function(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},(e=_a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var n=e.transitional;void 0!==n&&xa.assertOptions(n,{silentJSONParsing:ja.transitional(ja.boolean),forcedJSONParsing:ja.transitional(ja.boolean),clarifyTimeoutError:ja.transitional(ja.boolean)},!1);var i=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,i.unshift(t.fulfilled,t.rejected))}));var a,s=[];if(this.interceptors.response.forEach((function(t){s.push(t.fulfilled,t.rejected)})),!r){var o=[Sa,void 0];for(Array.prototype.unshift.apply(o,i),o=o.concat(s),a=Promise.resolve(e);o.length;)a=a.then(o.shift(),o.shift());return a}for(var l=e;i.length;){var u=i.shift(),c=i.shift();try{l=u(l)}catch(t){c(t);break}}try{a=Sa(l)}catch(t){return Promise.reject(t)}for(;s.length;)a=a.then(s.shift(),s.shift());return a},Oa.prototype.getUri=function(t){t=_a(this.defaults,t);var e=Ea(t.baseURL,t.url);return ya(e,t.params,t.paramsSerializer)},wa.forEach(["delete","get","head","options"],(function(t){Oa.prototype[t]=function(e,n){return this.request(_a(n||{},{method:t,url:e,data:(n||{}).data}))}})),wa.forEach(["post","put","patch"],(function(t){function e(e){return function(n,i,r){return this.request(_a(r||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}Oa.prototype[t]=e(),Oa.prototype[t+"Form"]=e(!0)}));var ka=Vi,Fa=Ai,Aa=Oa,Ta=aa;var Ra=function t(e){var n=new Aa(e),i=Fa(Aa.prototype.request,n);return ka.extend(i,Aa.prototype,n),ka.extend(i,n),i.create=function(n){return t(Ta(e,n))},i}(Hr);Ra.Axios=Aa,Ra.CanceledError=Ir(),Ra.CancelToken=function(){if(ha)return fa;ha=1;var t=Ir();function e(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(t){n=t}));var i=this;this.promise.then((function(t){if(i._listeners){var e,n=i._listeners.length;for(e=0;e<n;e++)i._listeners[e](t);i._listeners=null}})),this.promise.then=function(t){var e,n=new Promise((function(t){i.subscribe(t),e=t})).then(t);return n.cancel=function(){i.unsubscribe(e)},n},e((function(e){i.reason||(i.reason=new t(e),n(i.reason))}))}return e.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},e.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},e.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},e.source=function(){var t,n=new e((function(e){t=e}));return{token:n,cancel:t}},fa=e}(),Ra.isCancel=Wr(),Ra.VERSION=sa().version,Ra.toFormData=hr(),Ra.AxiosError=rr(),Ra.Cancel=Ra.CanceledError,Ra.all=function(t){return Promise.all(t)},Ra.spread=pa?da:(pa=1,da=function(t){return function(e){return t.apply(null,e)}}),Ra.isAxiosError=function(){if(ga)return va;ga=1;var t=Vi;return va=function(e){return t.isObject(e)&&!0===e.isAxiosError}}(),Fi.exports=Ra,Fi.exports.default=Ra;var Ia=Fi.exports;function Ca(t){this.message=t}Ca.prototype=new Error,Ca.prototype.name="InvalidCharacterError";var Pa="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ca("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,a=0,s="";i=e.charAt(a++);~i&&(n=r%4?64*n+i:i,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function La(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Pa(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return Pa(e)}}function Da(t){this.message=t}Da.prototype=new Error,Da.prototype.name="InvalidTokenError";class Na{constructor(){salla.event.on("twilight::before.ready",(t=>this.initiateRequest(t))),salla.event.on("profile::info.fetched",(t=>this.setCurrencyAndLanguage(t))),salla.event.on("auth::token.fetched",(t=>{salla.storage.set("token",t),this.setToken(t)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=Ia.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(t){return Object.entries(t).forEach((t=>this.setHeader(t[0],t[1]))),this}setHeader(t,e){return salla.infiniteScroll.fetchOptions.headers[t]=this.axios.defaults.headers.common[t]=e,this}async withoutNotifier(t){return this.notifier_handler_disabled=!0,await t().finally((()=>{this.notifier_handler_disabled=!1}))}async initiateRequest(t){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:t.user?.currency_code||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":t.user?.id});let e=salla.storage.get("scope");e&&this.setHeaders({"s-scope-type":e.type,"s-scope-id":e.id}),await this.injectTokenToTheRequests(t),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))}async injectTokenToTheRequests(t){let e=salla.storage.get("token"),n="guest"===t.user.type,i=t.user?.id,r=salla.storage.get("user.id"),a=t=>{this.setToken(t),salla.event.emit("api::initiated")},s=async()=>{!n&&i?(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async()=>{await salla.profile.info()}))):salla.auth.event.tokenInvalid()};if(!e)return salla.log("Api:: case 1 => current is is guest"),void await s();let o=function(t,e){if("string"!=typeof t)throw new Da("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(La(t.split(".")[n]))}catch(t){throw new Da("Invalid token specified: "+t.message)}}(e);return console.log(o),Date.now()/1e3>o.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await s()):o.sub===i&&r===i&&r&&i?(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void a(e)):(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),this.setHeader("Authorization","Bearer "+e),void await salla.profile.info().then((async t=>{await salla.auth.api.request("auth/jwt"),a(e)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()})))}setToken(t){return this.setHeader("Authorization","Bearer "+t),salla.event.emit("api::token.injected",t),this.token=t,this}setCurrencyAndLanguage(t){return this.setHeaders({currency:t.data.currency,"accept-language":t.data.language})}request(t,e=void 0,n="get",i={}){let r={endPoint:t,payload:e,method:n,options:i},a="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===a?.tagName&&(s=!0),s&&a?.load(),this.axios[r.method](r.endPoint,r.payload,r.options).then((t=>(s&&a?.stop(),t.data&&t.request&&(t=t.data),this.handleAfterResponseActions(t),t))).catch((t=>{throw s&&a?.stop(),salla.event.document.requestFailed(r,t),this.handleErrorResponse(t),t}))}handleAfterResponseActions(t){if(!t)return;let{data:e,googleTags:n=null}=t,i=e&&e.googleTags?e.googleTags:n;try{dataLayer&&i&&dataLayer.push(i)}catch(t){salla.logger.error(t.message)}this.fireEventsForResponse(t),this.showAlert(t)}fireEventsForResponse(t){let e=t?.events||t.data?.events||t.error?.events;"string"==typeof e&&(e=JSON.parse(e)),e&&Object.keys(e).forEach((t=>salla.event.dispatch(t,e[t])))}handleErrorResponse(t){if(t.response&&t.response.data)return t.response.data.error&&t.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(t):this.handleAfterResponseActions(t.response.data)}showAlert(t){if(t&&!this.notifier_handler_disabled)return t.case&&t.msg?salla.notify.fire(t.msg,t.case,t):t.hasOwnProperty("success")&&t.data?.message?salla.notify.fire(t.data?.message,t.success?salla.notify.types.success:salla.notify.types.error,t):t.error&&t.error.message&&"FORBIDDEN"!==t.error.message?salla.error(t.error.message,t):void 0}handleInvalidFields(t){let e=t.response.data.error.fields,n=[];Object.keys(e).forEach((t=>{let i=e[t];Array.isArray(i)?i.forEach((t=>n.push(t))):n.push(i)}));let i=(n.length>1?"* ":"")+n.join("\n* ");salla.error(i,t)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(t,e=!0){return new Promise(((n,i)=>e?n(t):i(t)))}errorPromise(t){return this.promise(t,!1)}successPromise(t){return this.promise(t,!0)}}class $a{constructor(t){"ready"!==Tn.status?t?(Tn.config.merge(t),t?.events&&Tn.event.dispatchEvents(t?.events),t._token&&salla.api.setHeader("X-CSRF-TOKEN",t._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),t?.user?.language_code&&salla.lang.setLocale(t?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(t)):this.setSallaReady(t):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 t=document.createElement("div");t.id="s-theme_preview_bar",t.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;"),t.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(t)})))}injectEditAlert(){let t=salla.config.get("edit");t&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-edit-alert",e.innerHTML=`\n <a href="${t}" 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(e)})))}handleElementAjaxRequest(t,e){if(!(e instanceof HTMLFormElement||e instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;t.preventDefault();let n=e.getAjaxFormData(t),i=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,i).then((t=>(t.data&&t.request&&(t=t.data),salla.api.handleAfterResponseActions(t),this.callAjaxEvent(n.events.success,t,n.formData),t))).catch((t=>{throw salla.api.handleErrorResponse(t),this.callAjaxEvent(n.events.fail,t,n.formData),t}))}callAjaxEvent(t,e,n){if(t){if(n instanceof FormData){const t={};Array.from(n.entries()).forEach((function(e){t[e[0]]=e[1]})),n=t}window[t]?window[t](e,n):salla.event.dispatch(t,e,n)}}setSallaReady(t){Tn.event.dispatch("twilight::before.ready",t),Tn.status="ready",Tn.event.dispatch("twilight::initiated",t),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:t}))}}return Tn.status="loading",Tn.notify=Pn,Tn.lang=new class extends fi{constructor(t){(t=t||{}).messages=t.messages||window.translations,t.locale=t.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],t.fallback=t.fallback||t.locale,super(t),this.translationsLoaded=!1}onLoaded(t){if(this.translationsLoaded)return t();Salla.event.once("languages::translations.loaded",t)}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(t){super.setMessages(t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(t,e=!0){let n=document.createElement("script");n.src=t,n.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);n.onerror()},n.onerror=()=>{if(e)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(n)}getWithDefault(t,e,n,i){let r=this.get(t,n,i);return r!==t?r:e}get(t,e,n){let i=t;(window.translations||this.translationsLoaded)&&(i="trans."+t);let r=super.get(i,e,n);return r!==i?r:super.get(i,e,"en").replace(i,t)}set(t,e){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],t,e),this}},Tn.form=new class{async submit(t,e=null){let n=e;if("SubmitEvent"===e?.constructor?.name||"submit"===e?.type){if(e.preventDefault(),"FORM"!==e.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"===e?.submitter?.parentElement?.tagName&&e.submitter.parentElement.load(),n=e.target.getElementSallaData(),salla.log("Data from element",n)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(t))return salla.api.request(t,n,"post").finally((()=>{loaderSupported&&e?.submitter?.parentElement.stop()}));let i=t.split("."),r=i.splice(-1);return await salla.call(i.join("."))[r](n).finally((()=>e?.submitter?.parentElement?.stop())).catch((t=>{throw salla.logger.warn(t),t}))}onSubmit(t,e){return salla.form.submit(t,e),!1}onChange(t,e){return e?.currentTarget?"FORM"!==e?.currentTarget?.tagName||e.currentTarget.checkValidity()?(salla.form.submit(t,e.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${t}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${t}' without event!`),!1)}getPossibleValue(t,e,n=!1){if(!t)return;if("object"!=typeof t)return t;let i;for(let n=0;n<e.length&&!(i=t[e[n]])&&!("undefined"!=typeof FormData&&t instanceof FormData&&(i=t.get(e[n])));n++);return i=i||t,"object"!=typeof i||n?i:void 0}},Tn.infiniteScroll=new class extends Ln{constructor(t,e){super(t,e),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(t,e,n,i=!1){i?((n=n||{}).fetchOptions={...this.fetchOptions,...n.fetchOptions||{}},n.responseBody="json"):n=this.getCustomOptions(e,n);let r="string"!=typeof t?t:document.querySelector(t),a=n.path;if(!r||!a||"string"==typeof a&&!document.querySelector(a))return void Salla.logger.warn(r?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let s=new ui(r,n);return s.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),s.on("request",Salla.infiniteScroll.event.request),s.on("load",Salla.infiniteScroll.event.load),s.on("append",Salla.infiniteScroll.event.append),s.on("error",Salla.infiniteScroll.event.error),s.on("last",Salla.infiniteScroll.event.last),s.on("history",Salla.infiniteScroll.event.history),this.instances.push(s),s}getCustomOptions(t,e){return(e="object"==typeof t&&t||e||this.options).fetchOptions=this.fetchOptions,e.path=e.path||this.options.path,e.button=e.button||e.path,e.status=e.status||this.options.status,e.hasOwnProperty("history")||(e.history=this.options.history),e.nextPage=e.nextPage||e.next_page,e.append="string"==typeof t&&t||e.append||this.options.append,e}loadNextPage(t){("string"!=typeof t?t:document.querySelector(t)).loadNextPage()}destroy(t){("string"!=typeof t?t:document.querySelector(t)).destroy()}}(void 0,salla.event.infiniteScroll),Tn.api=new class extends Na{constructor(){super(),this.auth=new vi,this.cart=new di,this.loyalty=new pi,this.order=new gi,this.rating=new _i,this.product=new mi,this.profile=new wi,this.comment=new yi,this.currency=new bi,this.document=new Si,this.wishlist=new Ei,this.scope=new xi,this.booking=new ji,this.landing=new Oi}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((t=>Tn[t]=new Ln(Tn.api[t],Tn.event[t]))),Tn.call=t=>{let e=Tn,n=t.split(".");for(;n.length&&(e=e[n.shift()]););return e},Tn.init=t=>new $a(t),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(t=>{let e=t?.events;e&&salla.event.dispatchEvents(e)})),Tn.success=Tn.notify.success,Tn.error=Tn.notify.error,Tn.versions.twilight="2.12.20",Tn.onInitiated=t=>salla.event.once("twilight::initiated",t),Tn.onReady=Tn.onReady||function(t){"ready"!==salla.status?Tn.onInitiated(t):t(salla.config.all())},window.dispatchEvent(new CustomEvent("salla::created")),Tn}));var n=t((function(t,n){!function(e,n){t.exports=n()}(e,(function(){function t(){return t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},t.apply(this,arguments)}var e="undefined"!=typeof window,n=e&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),i=e&&"IntersectionObserver"in window,r=e&&"classList"in document.createElement("p"),a=e&&window.devicePixelRatio>1,s={elements_selector:".lazy",container:n||e?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_bg_set:"bg-set",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1,restore_on_error:!1},o=function(e){return t({},s,e)},l=function(t,e){var n,i="LazyLoad::Initialized",r=new t(e);try{n=new CustomEvent(i,{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(n)},u="src",c="srcset",f="sizes",h="poster",d="llOriginalAttrs",p="data",v="loading",g="loaded",m="applied",w="error",y="native",b="data-",S="ll-status",_=function(t,e){return t.getAttribute(b+e)},E=function(t){return _(t,S)},x=function(t,e){return function(t,e,n){var i="data-ll-status";null!==n?t.setAttribute(i,n):t.removeAttribute(i)}(t,0,e)},j=function(t){return x(t,null)},O=function(t){return null===E(t)},k=function(t){return E(t)===y},F=[v,g,m,w],A=function(t,e,n,i){t&&(void 0===i?void 0===n?t(e):t(e,n):t(e,n,i))},T=function(t,e){r?t.classList.add(e):t.className+=(t.className?" ":"")+e},R=function(t,e){r?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},I=function(t){return t.llTempImage},C=function(t,e){if(e){var n=e._observer;n&&n.unobserve(t)}},P=function(t,e){t&&(t.loadingCount+=e)},L=function(t,e){t&&(t.toLoadCount=e)},D=function(t){for(var e,n=[],i=0;e=t.children[i];i+=1)"SOURCE"===e.tagName&&n.push(e);return n},N=function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&D(n).forEach(e)},$=function(t,e){D(t).forEach(e)},q=[u],U=[u,h],M=[u,c,f],z=[p],B=function(t){return!!t[d]},J=function(t){return t[d]},G=function(t){return delete t[d]},H=function(t,e){if(!B(t)){var n={};e.forEach((function(e){n[e]=t.getAttribute(e)})),t[d]=n}},Q=function(t,e){if(B(t)){var n=J(t);e.forEach((function(e){!function(t,e,n){n?t.setAttribute(e,n):t.removeAttribute(e)}(t,e,n[e])}))}},V=function(t,e,n){T(t,e.class_applied),x(t,m),n&&(e.unobserve_completed&&C(t,e),A(e.callback_applied,t,n))},W=function(t,e,n){T(t,e.class_loading),x(t,v),n&&(P(n,1),A(e.callback_loading,t,n))},X=function(t,e,n){n&&t.setAttribute(e,n)},Z=function(t,e){X(t,f,_(t,e.data_sizes)),X(t,c,_(t,e.data_srcset)),X(t,u,_(t,e.data_src))},K={IMG:function(t,e){N(t,(function(t){H(t,M),Z(t,e)})),H(t,M),Z(t,e)},IFRAME:function(t,e){H(t,q),X(t,u,_(t,e.data_src))},VIDEO:function(t,e){$(t,(function(t){H(t,q),X(t,u,_(t,e.data_src))})),H(t,U),X(t,h,_(t,e.data_poster)),X(t,u,_(t,e.data_src)),t.load()},OBJECT:function(t,e){H(t,z),X(t,p,_(t,e.data_src))}},Y=["IMG","IFRAME","VIDEO","OBJECT"],tt=function(t,e){!e||function(t){return t.loadingCount>0}(e)||function(t){return t.toLoadCount>0}(e)||A(t.callback_finish,e)},et=function(t,e,n){t.addEventListener(e,n),t.llEvLisnrs[e]=n},nt=function(t,e,n){t.removeEventListener(e,n)},it=function(t){return!!t.llEvLisnrs},rt=function(t){if(it(t)){var e=t.llEvLisnrs;for(var n in e){var i=e[n];nt(t,n,i)}delete t.llEvLisnrs}},at=function(t,e,n){!function(t){delete t.llTempImage}(t),P(n,-1),function(t){t&&(t.toLoadCount-=1)}(n),R(t,e.class_loading),e.unobserve_completed&&C(t,n)},st=function(t,e,n){var i=I(t)||t;it(i)||function(t,e,n){it(t)||(t.llEvLisnrs={});var i="VIDEO"===t.tagName?"loadeddata":"load";et(t,i,e),et(t,"error",n)}(i,(function(r){!function(t,e,n,i){var r=k(e);at(e,n,i),T(e,n.class_loaded),x(e,g),A(n.callback_loaded,e,i),r||tt(n,i)}(0,t,e,n),rt(i)}),(function(r){!function(t,e,n,i){var r=k(e);at(e,n,i),T(e,n.class_error),x(e,w),A(n.callback_error,e,i),n.restore_on_error&&Q(e,M),r||tt(n,i)}(0,t,e,n),rt(i)}))},ot=function(t,e,n){!function(t){return Y.indexOf(t.tagName)>-1}(t)?function(t,e,n){!function(t){t.llTempImage=document.createElement("IMG")}(t),st(t,e,n),function(t){B(t)||(t[d]={backgroundImage:t.style.backgroundImage})}(t),function(t,e,n){var i=_(t,e.data_bg),r=_(t,e.data_bg_hidpi),s=a&&r?r:i;s&&(t.style.backgroundImage='url("'.concat(s,'")'),I(t).setAttribute(u,s),W(t,e,n))}(t,e,n),function(t,e,n){var i=_(t,e.data_bg_multi),r=_(t,e.data_bg_multi_hidpi),s=a&&r?r:i;s&&(t.style.backgroundImage=s,V(t,e,n))}(t,e,n),function(t,e,n){var i=_(t,e.data_bg_set);if(i){var r=i.split("|"),a=r.map((function(t){return"image-set(".concat(t,")")}));t.style.backgroundImage=a.join(),""===t.style.backgroundImage&&(a=r.map((function(t){return"-webkit-image-set(".concat(t,")")})),t.style.backgroundImage=a.join()),V(t,e,n)}}(t,e,n)}(t,e,n):function(t,e,n){st(t,e,n),function(t,e,n){var i=K[t.tagName];i&&(i(t,e),W(t,e,n))}(t,e,n)}(t,e,n)},lt=function(t){t.removeAttribute(u),t.removeAttribute(c),t.removeAttribute(f)},ut=function(t){N(t,(function(t){Q(t,M)})),Q(t,M)},ct={IMG:ut,IFRAME:function(t){Q(t,q)},VIDEO:function(t){$(t,(function(t){Q(t,q)})),Q(t,U),t.load()},OBJECT:function(t){Q(t,z)}},ft=function(t,e){(function(t){var e=ct[t.tagName];e?e(t):function(t){if(B(t)){var e=J(t);t.style.backgroundImage=e.backgroundImage}}(t)})(t),function(t,e){O(t)||k(t)||(R(t,e.class_entered),R(t,e.class_exited),R(t,e.class_applied),R(t,e.class_loading),R(t,e.class_loaded),R(t,e.class_error))}(t,e),j(t),G(t)},ht=["IMG","IFRAME","VIDEO"],dt=function(t){return t.use_native&&"loading"in HTMLImageElement.prototype},pt=function(t,e,n){t.forEach((function(t){return function(t){return t.isIntersecting||t.intersectionRatio>0}(t)?function(t,e,n,i){var r=function(t){return F.indexOf(E(t))>=0}(t);x(t,"entered"),T(t,n.class_entered),R(t,n.class_exited),function(t,e,n){e.unobserve_entered&&C(t,n)}(t,n,i),A(n.callback_enter,t,e,i),r||ot(t,n,i)}(t.target,t,e,n):function(t,e,n,i){O(t)||(T(t,n.class_exited),function(t,e,n,i){n.cancel_on_exit&&function(t){return E(t)===v}(t)&&"IMG"===t.tagName&&(rt(t),function(t){N(t,(function(t){lt(t)})),lt(t)}(t),ut(t),R(t,n.class_loading),P(i,-1),j(t),A(n.callback_cancel,t,e,i))}(t,e,n,i),A(n.callback_exit,t,e,i))}(t.target,t,e,n)}))},vt=function(t){return Array.prototype.slice.call(t)},gt=function(t){return t.container.querySelectorAll(t.elements_selector)},mt=function(t){return function(t){return E(t)===w}(t)},wt=function(t,e){return function(t){return vt(t).filter(O)}(t||gt(e))},yt=function(t,n){var r=o(t);this._settings=r,this.loadingCount=0,function(t,e){i&&!dt(t)&&(e._observer=new IntersectionObserver((function(n){pt(n,t,e)}),function(t){return{root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}}(t)))}(r,this),function(t,n){e&&(n._onlineHandler=function(){!function(t,e){var n;(n=gt(t),vt(n).filter(mt)).forEach((function(e){R(e,t.class_error),j(e)})),e.update()}(t,n)},window.addEventListener("online",n._onlineHandler))}(r,this),this.update(n)};return yt.prototype={update:function(t){var e,r,a=this._settings,s=wt(t,a);L(this,s.length),!n&&i?dt(a)?function(t,e,n){t.forEach((function(t){-1!==ht.indexOf(t.tagName)&&function(t,e,n){t.setAttribute("loading","lazy"),st(t,e,n),function(t,e){var n=K[t.tagName];n&&n(t,e)}(t,e),x(t,y)}(t,e,n)})),L(n,0)}(s,a,this):(r=s,function(t){t.disconnect()}(e=this._observer),function(t,e){e.forEach((function(e){t.observe(e)}))}(e,r)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),e&&window.removeEventListener("online",this._onlineHandler),gt(this._settings).forEach((function(t){G(t)})),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){var e=this,n=this._settings;wt(t,n).forEach((function(t){C(t,e),ot(t,n,e)}))},restoreAll:function(){var t=this._settings;gt(t).forEach((function(e){ft(e,t)}))}},yt.load=function(t,e){var n=o(e);ot(t,n)},yt.resetStatus=function(t){j(t)},e&&function(t,e){if(e)if(e.length)for(var n,i=0;n=e[i];i+=1)l(t,n);else l(t,e)}(yt,window.lazyLoadOptions),yt}))}));function i(){if(!document.lazyLoadInstance){document.lazyLoadInstance=new n({use_native:true});document.lazyLoadBackgrounds=new n({elements_selector:".lazy[data-bg]:not(.loaded)"})}if(document.readyState!=="complete"){document.addEventListener("DOMContentLoaded",(()=>document.lazyLoadInstance.update()));document.addEventListener("DOMContentLoaded",(()=>document.lazyLoadBackgrounds.update()))}salla.infiniteScroll.event.onAppend((()=>{document.lazyLoadInstance.update();document.lazyLoadBackgrounds.update()}))}const r=i;export{r as g};
23
- //# sourceMappingURL=p-ea1e28b1.js.map