@salla.sa/base 2.14.310 → 2.14.312

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Salla=e()}(this,(function(){"use strict";function t(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(r){if("default"!==r&&!(r in t)){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}))})),Object.freeze(t)}function e(t,e){void 0===e&&(e=!1),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],o=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,s=e?i:n,a=0;a<o.length;a++)r=new RegExp(o[a],"g"),t=t.replace(r,s[a]);return t.replace(e?"٫":".",e?".":"٫")}function r(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?r(t.replace(/\.(.+)\./g,".$1")):t}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 r,n=this,i=0;i<t.length;i++)r=new RegExp(t[i],"g"),n=n.replace(r,e[i]);return n},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 n,i,o,s,a,u,l,c,f,p,h,d,v,y,g,_,m,b,w,S,L,j,E,x,A,k,O,P,T,F,N,R,z,C,I,M,$,D,W,U,G,K,J,B,q,H,Z,Q,V,X,Y,tt,et,rt,nt,it,ot,st,at,ut,lt,ct,ft,pt,ht,dt,vt,yt,gt,_t,mt,bt,wt,St,Lt,jt,Et,xt,At,kt,Ot,Pt,Tt,Ft,Nt,Rt,zt,Ct,It,Mt,$t,Dt,Wt,Ut,Gt,Kt,Jt,Bt,qt,Ht,Zt,Qt,Vt,Xt,Yt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function te(){if(i)return n;i=1;var t=Array.isArray;return n=t}function ee(){if(u)return a;u=1;var t=function(){if(s)return o;s=1;var t="object"==typeof Yt&&Yt&&Yt.Object===Object&&Yt;return o=t}(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return a=r}function re(){if(c)return l;c=1;var t=ee().Symbol;return l=t}function ne(){if(y)return v;y=1;var t=re(),e=function(){if(p)return f;p=1;var t=re(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,i=t?t.toStringTag:void 0;return f=function(t){var e=r.call(t,i),o=t[i];try{t[i]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[i]=o:delete t[i]),a}}(),r=function(){if(d)return h;d=1;var t=Object.prototype.toString;return h=function(e){return t.call(e)}}(),n=t?t.toStringTag:void 0;return v=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function ie(){if(b)return m;b=1;var t=ne(),e=_?g:(_=1,g=function(t){return null!=t&&"object"==typeof t});return m=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function oe(){return j?L:(j=1,L=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)})}function se(){if(R)return N;R=1;var t=function(){if(x)return E;x=1;var t=ne(),e=oe();return E=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}(),e=function(){if(P)return O;P=1;var t,e=function(){if(k)return A;k=1;var t=ee()["__core-js_shared__"];return A=t}(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return O=function(t){return!!r&&r in t}}(),r=oe(),n=function(){if(F)return T;F=1;var t=Function.prototype.toString;return T=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,a=o.toString,u=s.hasOwnProperty,l=RegExp("^"+a.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return N=function(o){return!(!r(o)||e(o))&&(t(o)?l:i).test(n(o))}}function ae(){if(M)return I;M=1;var t=se(),e=C?z:(C=1,z=function(t,e){return null==t?void 0:t[e]});return I=function(r,n){var i=e(r,n);return t(i)?i:void 0}}function ue(){if(D)return $;D=1;var t=ae()(Object,"create");return $=t}function le(){if(it)return nt;it=1;var t=rt?et:(rt=1,et=function(t,e){return t===e||t!=t&&e!=e});return nt=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function ce(){if(_t)return gt;_t=1;var t=function(){if(X)return V;X=1;var t=function(){if(U)return W;U=1;var t=ue();return W=function(){this.__data__=t?t(null):{},this.size=0}}(),e=K?G:(K=1,G=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),r=function(){if(B)return J;B=1;var t=ue(),e=Object.prototype.hasOwnProperty;return J=function(r){var n=this.__data__;if(t){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(n,r)?n[r]:void 0}}(),n=function(){if(H)return q;H=1;var t=ue(),e=Object.prototype.hasOwnProperty;return q=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}(),i=function(){if(Q)return Z;Q=1;var t=ue();return Z=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}();function o(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,V=o}(),e=function(){if(dt)return ht;dt=1;var t=tt?Y:(tt=1,Y=function(){this.__data__=[],this.size=0}),e=function(){if(st)return ot;st=1;var t=le(),e=Array.prototype.splice;return ot=function(r){var n=this.__data__,i=t(n,r);return!(i<0||(i==n.length-1?n.pop():e.call(n,i,1),--this.size,0))}}(),r=function(){if(ut)return at;ut=1;var t=le();return at=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}(),n=function(){if(ct)return lt;ct=1;var t=le();return lt=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(pt)return ft;pt=1;var t=le();return ft=function(e,r){var n=this.__data__,i=t(n,e);return i<0?(++this.size,n.push([e,r])):n[i][1]=r,this}}();function o(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,ht=o}(),r=function(){if(yt)return vt;yt=1;var t=ae()(ee(),"Map");return vt=t}();return gt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function fe(){if(St)return wt;St=1;var t=bt?mt:(bt=1,mt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return wt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function pe(){if(Ct)return zt;Ct=1;var t=function(){if(Rt)return Nt;Rt=1;var t=function(){if(Ft)return Tt;Ft=1;var t=ce(),e=function(){if(jt)return Lt;jt=1;var t=fe();return Lt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}(),r=function(){if(xt)return Et;xt=1;var t=fe();return Et=function(e){return t(this,e).get(e)}}(),n=function(){if(kt)return At;kt=1;var t=fe();return At=function(e){return t(this,e).has(e)}}(),i=function(){if(Pt)return Ot;Pt=1;var t=fe();return Ot=function(e,r){var n=t(this,e),i=n.size;return n.set(e,r),this.size+=n.size==i?0:1,this}}();function o(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Tt=o}();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=n?n.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var s=r.apply(this,t);return i.cache=o.set(e,s)||o,s};return i.cache=new(e.Cache||t),i}return e.Cache=t,Nt=e}();return zt=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function he(){if(Bt)return Jt;Bt=1;var t=te(),e=function(){if(S)return w;S=1;var t=te(),e=ie(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return w=function(i,o){if(t(i))return!1;var s=typeof i;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=i&&!e(i))||n.test(i)||!r.test(i)||null!=o&&i in Object(o)}}(),r=function(){if(Mt)return It;Mt=1;var t=pe(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=t((function(t){var n=[];return 46===t.charCodeAt(0)&&n.push(""),t.replace(e,(function(t,e,i,o){n.push(i?o.replace(r,"$1"):e||t)})),n}));return It=n}(),n=function(){if(Kt)return Gt;Kt=1;var t=function(){if(Ut)return Wt;Ut=1;var t=re(),e=Dt?$t:(Dt=1,$t=function(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}),r=te(),n=ie(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return Wt=function t(i){if("string"==typeof i)return i;if(r(i))return e(i,t)+"";if(n(i))return o?o.call(i):"";var s=i+"";return"0"==s&&1/i==-1/0?"-0":s}}();return Gt=function(e){return null==e?"":t(e)}}();return Jt=function(i,o){return t(i)?i:e(i,o)?[i]:r(n(i))}}var de=function(){if(Xt)return Vt;Xt=1;var t=function(){if(Qt)return Zt;Qt=1;var t=he(),e=function(){if(Ht)return qt;Ht=1;var t=ie();return qt=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}();return Zt=function(r,n){for(var i=0,o=(n=t(n,r)).length;null!=r&&i<o;)r=r[e(n[i++])];return i&&i==o?r:void 0}}();return Vt=function(e,r,n){var i=null==e?void 0:t(e,r);return void 0===i?n:i}}();function ve(t){return"".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function ye(t){if(ve(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 ge(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function _e(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function me(t){return ve(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):_e("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}var be=Object.freeze({__proto__:null,addParamToUrl:ge,api:function(t){var e;return(null===(e=Salla.config.get("store.api",ye("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:me,base:function(t){return ve(t)?t:"https://"+new URL(ye("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:_e,cdn:function(t,e,r){var n="https://cdn.salla.network/";return(e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return"custom"===t?e:ye("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return ve(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:ye,is_full_url:ve,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return me(salla.config.get("theme.settings.placeholder"))===me(t)}}),we=function(t,e){return we=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},we(t,e)},Se=function(){return Se=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Se.apply(this,arguments)};function Le(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function je(t){return t instanceof FormData}function Ee(t){return t instanceof File}function xe(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var Ae=function(){function t(t){this.data=t,this.proxy=this.createProxy()}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return"string"==typeof r&&(t.set(r,n),!0)},has:function(e,r){return"string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return"string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return je(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(je(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;je(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){Ee(e)||xe(e)?r.data.append(t,e):r.data.append(t,String(e))})):Ee(e)||xe(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e},t.prototype.append=function(t,e){if(je(this.data))Ee(e)||xe(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else{var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e]}},t.prototype.setFile=function(t,e){this.set(t,e)},t.prototype.getFile=function(t){var e=this.get(t);return Ee(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(Ee)},t.prototype.has=function(t){return je(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return je(this.data)?(this.data.delete(t),!0):delete this.data[t]},t.prototype.keys=function(){if(!je(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n)}return Array.from(t)},t.prototype.values=function(){if(!je(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n)}return t},t.prototype.entries=function(){return je(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!je(this.data))return Se({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],i=n[0],o=n[1];void 0!==t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(o)):t[i]=o}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return{name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return Ee(e)||xe(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function ke(t,e,r){var n,i=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[i]=ke(t.slice(1),e,r[i]),r):i?((n={})[i]=ke(t.slice(1),e),n):""===i?[e]:e}function Oe(){return window.self!==window.top}var Pe,Te,Fe,Ne,Re,ze,Ce,Ie,Me,$e={digitsOnly:function(t){return e(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")?r(i):i.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e)},number:e,money:function(t,r){void 0===r&&(r=!0);var n=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=e(t="object"==typeof t?t.amount:t)+" "+n,r&&["SAR","ر.س"].includes(n)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(n,"<i class=sicon-sar></i>")),t},isIframe:Oe,isPreview:function(){return Oe()},setNested:function(t,e,r){for(var n=t,i=e.split("."),o=i.length,s=0;s<o-1;s++){var a=i[s];n[a]||(n[a]={}),n=n[a]}return n[i[o-1]]=r,t},getNested:function(t,e,r){var n=de.default?de.default(t,e):de(t,e);return void 0!==n?n:r},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),i=n[0],o=r&&"object"==typeof r?r[i]:void 0;return{name:i,value:ke(n.slice(1),e,o)}}return{name:t,value:e}},url:be,addParamToUrl:ge,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,i);n.forEach((function(t){return t(e)})),n=[]}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return!!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),!1}},createFormDataWrapper:function(t){return new Ae(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),!1}}},De=(Pe=console,Te=[],Fe=[],Ne={log:function(t,e){if(Pe&&salla.config.isDebug()){Te.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=Pe.log,n=void 0===e?r:this.__dict__[e]||r,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];Fe.forEach((function(t){i[0]+=t[0],i.push(t[1])}));var o={event:"#CFF680",backend:"#7b68ee"}[e];o&&(i[0]+="%c"+e[0].toUpperCase()+e.substring(1),i.push("margin-left: 5px;color: ".concat(o,";font-weight:bold; border:1px solid ").concat(o,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,Le([Pe],i.concat.apply(i,t),!1))}},__dict__:{trace:Pe.trace,debug:Pe.debug,info:Pe.info,warn:Pe.warn,error:Pe.error}},{event:function(){Ne.log(arguments,"event")},trace:function(){Ne.log(arguments,"trace")},debug:function(){Ne.log(arguments,"debug")},info:function(){Ne.log(arguments,"info")},warn:function(){Ne.log(arguments,"warn")},error:function(){Ne.log(arguments,"error")},log:function(){Ne.log(arguments,void 0)},backend:function(){Ne.log(arguments,"backend")},logs:function(t){[t].flat().forEach((function(t){return t&&Ne.log([t].flat(),"backend")}))},history:function(){return Te.map((function(t){return Pe.log.apply(Pe,Le([t[0]],t[1],!1))})),Te},addPrefix:function(t){return Array.isArray(t)?Fe.unshift(t):this.warn("addPrefix receives array only!"),this}}),We=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=Se(Se({},this.default_properties),t)}return t.prototype.merge=function(t){var e;return this.properties_=Se(Se({},this.properties_),t),this.properties_.store=Se(Se({},(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}(),Ue={exports:{}},Ge=(Re||(Re=1,function(t,e){!function(e){var r=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i="object"==typeof process&&"function"==typeof process.nextTick,o="function"==typeof Symbol,s="object"==typeof Reflect,a="function"==typeof setImmediate?setImmediate:setTimeout,u=o?s&&"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 l(){this._events={},this._conf&&c.call(this,this._conf)}function c(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 f(t,e){var r="(node) warning: possible EventEmitter memory leak detected. "+t+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+e+"."),"undefined"!=typeof process&&process.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=t,process.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var p=function(t,e,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[t];case 2:return[t,e];case 3:return[t,e,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function h(t,r){for(var n={},i=t.length,o=0;o<i;o++)n[t[o]]=o<0?r[o]:e;return n}function d(t,e,r){var n,i;if(this._emitter=t,this._target=e,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),e.addEventListener?(n=e.addEventListener,i=e.removeEventListener):e.addListener?(n=e.addListener,i=e.removeListener):e.on&&(n=e.on,i=e.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var o=t._observers;o?o.push(this):t._observers=[this]}function v(t,n,i,o){var s=Object.assign({},n);if(!t)return s;if("object"!=typeof t)throw TypeError("options must be an object");var a,u,l,c=Object.keys(t),f=c.length;function p(t){throw Error('Invalid "'+a+'" option value'+(t?". Reason: "+t:""))}for(var h=0;h<f;h++){if(a=c[h],!r.call(n,a))throw Error('Unknown "'+a+'" option');(u=t[a])!==e&&(l=i[a],s[a]=l?l(u,p):u)}return s}function y(t,e){return"function"==typeof t&&t.hasOwnProperty("prototype")||e("value must be a constructor"),t}function g(t){var e="value must be type of "+t.join("|"),r=t.length,n=t[0],i=t[1];return 1===r?function(t,r){if(typeof t===n)return t;r(e)}:2===r?function(t,r){var o=typeof t;if(o===n||o===i)return t;r(e)}:function(n,i){for(var o=typeof n,s=r;s-- >0;)if(o===t[s])return n;i(e)}}Object.assign(d.prototype,{subscribe:function(t,e,r){var n=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var n=p.apply(null,arguments),s={data:n,name:e,original:t};r?!1!==r.call(i,s)&&o.emit.apply(o,[s.name].concat(n)):o.emit.apply(o,[e].concat(n))};if(s[t])throw Error("Event '"+t+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===e&&null===s[t]&&(s[t]=a,n._on.call(i,t,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===e&&!o.hasListeners(r)&&s[t]&&(s[t]=null,n._off.call(i,t,a))},s[t]=null,o.on("removeListener",this._onRemoveListener)):(s[t]=a,n._on.call(i,t,a))},unsubscribe:function(t){var e,r,n,i=this,o=this._listeners,s=this._emitter,a=this._off,l=this._target;if(t&&"string"!=typeof t)throw TypeError("event must be a string");function c(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var t=w.call(s,i);s._observers.splice(t,1)}if(t){if(!(e=o[t]))return;a.call(l,t,e),delete o[t],--this._listenersCount||c()}else{for(n=(r=u(o)).length;n-- >0;)t=r[n],a.call(l,t,o[t]);this._listeners={},this._listenersCount=0,c()}}});var _=g(["function"]),m=g(["object","function"]);function b(t,e,r){var n,i,o,s=0,a=new t((function(u,l,c){function f(){i&&(i=null),s&&(clearTimeout(s),s=0)}r=v(r,{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}}),n=!r.overload&&"function"==typeof t.prototype.cancel&&"function"==typeof c;var p=function(t){f(),u(t)},h=function(t){f(),l(t)};n?e(p,h,c):(i=[function(t){h(t||Error("canceled"))}],e(p,h,(function(t){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof t)throw TypeError("onCancel callback must be a function");i.push(t)})),o=!0),r.timeout>0&&(s=setTimeout((function(){var t=Error("timeout");t.code="ETIMEDOUT",s=0,a.cancel(t),l(t)}),r.timeout))}));return n||(a.cancel=function(t){if(i){for(var e=i.length,r=1;r<e;r++)i[r](t);i[0](t),i=null}}),a}function w(t){var e=this._observers;if(!e)return-1;for(var r=e.length,n=0;n<r;n++)if(e[n]._target===t)return n;return-1}function S(t,e,r,n,i){if(!r)return null;if(0===n){var o=typeof e;if("string"===o){var s,a,l=0,c=0,f=this.delimiter,p=f.length;if(-1!==(a=e.indexOf(f))){s=new Array(5);do{s[l++]=e.slice(c,a),c=a+p}while(-1!==(a=e.indexOf(f,c)));s[l++]=e.slice(c),e=s,i=l}else e=[e],i=1}else"object"===o?i=e.length:(e=[e],i=1)}var h,d,v,y,g,_,m,b=null,w=e[n],L=e[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(t&&t.push(r._listeners),b=[r]):(t&&t.push.apply(t,r._listeners),b=[r]));else{if("*"===w){for(a=(_=u(r)).length;a-- >0;)"_listeners"!==(h=_[a])&&(m=S(t,e,r[h],n+1,i))&&(b?b.push.apply(b,m):b=m);return b}if("**"===w){for((g=n+1===i||n+2===i&&"*"===L)&&r._listeners&&(b=S(t,e,r,i,i)),a=(_=u(r)).length;a-- >0;)"_listeners"!==(h=_[a])&&("*"===h||"**"===h?(r[h]._listeners&&!g&&(m=S(t,e,r[h],i,i))&&(b?b.push.apply(b,m):b=m),m=S(t,e,r[h],n,i)):m=S(t,e,r[h],h===L?n+2:n,i),m&&(b?b.push.apply(b,m):b=m));return b}r[w]&&(b=S(t,e,r[w],n+1,i))}if((d=r["*"])&&S(t,e,d,n+1,i),v=r["**"])if(n<i)for(v._listeners&&S(t,e,v,i,i),a=(_=u(v)).length;a-- >0;)"_listeners"!==(h=_[a])&&(h===L?S(t,e,v[h],n+2,i):h===w?S(t,e,v[h],n+1,i):((y={})[h]=v[h],S(t,e,{"**":y},n+1,i)));else v._listeners?S(t,e,v,i,i):v["*"]&&v["*"]._listeners&&S(t,e,v["*"],i,i);return b}function L(t,e,r){var n,i,o=0,s=0,a=this.delimiter,u=a.length;if("string"==typeof t)if(-1!==(n=t.indexOf(a))){i=new Array(5);do{i[o++]=t.slice(s,n),s=n+u}while(-1!==(n=t.indexOf(a,s)));i[o++]=t.slice(s)}else i=[t],o=1;else i=t,o=t.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var l,c=this.listenerTree;for(n=0;n<o;n++)if(c=c[l=i[n]]||(c[l]={}),n===o-1)return c._listeners?("function"==typeof c._listeners&&(c._listeners=[c._listeners]),r?c._listeners.unshift(e):c._listeners.push(e),!c._listeners.warned&&this._maxListeners>0&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,f.call(this,c._listeners.length,l))):c._listeners=e,!0;return!0}function j(t,e,r,n){for(var i,o,s,a,l=u(t),c=l.length,f=t._listeners;c-- >0;)i=t[o=l[c]],s="_listeners"===o?r:r?r.concat(o):[o],a=n||"symbol"==typeof o,f&&e.push(a?s:s.join(this.delimiter)),"object"==typeof i&&j.call(this,i,e,s,a);return e}function E(t){for(var e,r,n,i=u(t),o=i.length;o-- >0;)(e=t[r=i[o]])&&(n=!0,"_listeners"===r||E(e)||delete t[r]);return n}function x(t,e,r){this.emitter=t,this.event=e,this.listener=r}function A(t,r,n){if(!0===n)s=!0;else if(!1===n)o=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var o=n.async,s=n.promisify,u=n.nextTick,l=n.objectify}if(o||u||s){var c=r,f=r._origin||r;if(u&&!i)throw Error("process.nextTick is not supported");s===e&&(s="AsyncFunction"===r.constructor.name),r=function(){var t=arguments,e=this,r=this.event;return s?u?Promise.resolve():new Promise((function(t){a(t)})).then((function(){return e.event=r,c.apply(e,t)})):(u?process.nextTick:a)((function(){e.event=r,c.apply(e,t)}))},r._async=!0,r._origin=f}return[r,l?new x(this,t,r):this]}function k(t){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,c.call(this,t)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},k.EventEmitter2=k,k.prototype.listenTo=function(t,r,i){if("object"!=typeof t)throw TypeError("target musts be an object");var o=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var r,n=i.reducers,s=w.call(o,t);r=-1===s?new d(o,t,i):o._observers[s];for(var a,l=u(e),c=l.length,f="function"==typeof n,p=0;p<c;p++)a=l[p],r.subscribe(a,e[a]||a,f?n:n&&n[a])}return i=v(i,{on:e,off:e,reducers:e},{on:_,off:_,reducers:m}),n(r)?s(h(r)):s("string"==typeof r?h(r.split(/\s+/)):r),this},k.prototype.stopListeningTo=function(t,e){var r=this._observers;if(!r)return!1;var n,i=r.length,o=!1;if(t&&"object"!=typeof t)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],t&&n._target!==t||(n.unsubscribe(e),o=!0);return o},k.prototype.delimiter=".",k.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},k.prototype.getMaxListeners=function(){return this._maxListeners},k.prototype.event="",k.prototype.once=function(t,e,r){return this._once(t,e,!1,r)},k.prototype.prependOnceListener=function(t,e,r){return this._once(t,e,!0,r)},k.prototype._once=function(t,e,r,n){return this._many(t,1,e,r,n)},k.prototype.many=function(t,e,r,n){return this._many(t,e,r,!1,n)},k.prototype.prependMany=function(t,e,r,n){return this._many(t,e,r,!0,n)},k.prototype._many=function(t,e,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function s(){return 0==--e&&o.off(t,s),r.apply(this,arguments)}return s._origin=r,this._on(t,s,n,i)},k.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var t,e,r,n,i,s,a=arguments[0],u=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(u&&(t=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,o)for(n=0;n<r;n++)if("symbol"==typeof a[n]){s=!0;break}s||(a=a.join(this.delimiter))}var c,f=arguments.length;if(this._all&&this._all.length)for(n=0,r=(c=this._all.slice()).length;n<r;n++)switch(this.event=a,f){case 1:c[n].call(this,a);break;case 2:c[n].call(this,a,arguments[1]);break;case 3:c[n].call(this,a,arguments[1],arguments[2]);break;default:c[n].apply(this,arguments)}if(u)c=[],S.call(this,c,t,this.listenerTree,0,r);else{if("function"==typeof(c=this._events[a])){switch(this.event=a,f){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=new Array(f-1),i=1;i<f;i++)e[i-1]=arguments[i];c.apply(this,e)}return!0}c&&(c=c.slice())}if(c&&c.length){if(f>3)for(e=new Array(f-1),i=1;i<f;i++)e[i-1]=arguments[i];for(n=0,r=c.length;n<r;n++)switch(this.event=a,f){case 1:c[n].call(this);break;case 2:c[n].call(this,arguments[1]);break;case 3:c[n].call(this,arguments[1],arguments[2]);break;default:c[n].apply(this,e)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},k.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var t,e,r,n,i,s,a=arguments[0],u=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(u&&(t=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(n=a.length,o)for(i=0;i<n;i++)if("symbol"==typeof a[i]){e=!0;break}e||(a=a.join(this.delimiter))}var c,f=[],p=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=a,p){case 1:f.push(this._all[i].call(this,a));break;case 2:f.push(this._all[i].call(this,a,arguments[1]));break;case 3:f.push(this._all[i].call(this,a,arguments[1],arguments[2]));break;default:f.push(this._all[i].apply(this,arguments))}if(u?(c=[],S.call(this,c,t,this.listenerTree,0)):c=this._events[a],"function"==typeof c)switch(this.event=a,p){case 1:f.push(c.call(this));break;case 2:f.push(c.call(this,arguments[1]));break;case 3:f.push(c.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(p-1),s=1;s<p;s++)r[s-1]=arguments[s];f.push(c.apply(this,r))}else if(c&&c.length){if(c=c.slice(),p>3)for(r=new Array(p-1),s=1;s<p;s++)r[s-1]=arguments[s];for(i=0,n=c.length;i<n;i++)switch(this.event=a,p){case 1:f.push(c[i].call(this));break;case 2:f.push(c[i].call(this,arguments[1]));break;case 3:f.push(c[i].call(this,arguments[1],arguments[2]));break;default:f.push(c[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(f)},k.prototype.on=function(t,e,r){return this._on(t,e,!1,r)},k.prototype.prependListener=function(t,e,r){return this._on(t,e,!0,r)},k.prototype.onAny=function(t){return this._onAny(t,!1)},k.prototype.prependAny=function(t){return this._onAny(t,!0)},k.prototype.addListener=k.prototype.on,k.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},k.prototype._on=function(t,r,n,i){if("function"==typeof t)return this._onAny(t,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||l.call(this);var o,s=this;return i!==e&&(r=(o=A.call(this,t,r,i))[0],s=o[1]),this._newListener&&this.emit("newListener",t,r),this.wildcard?(L.call(this,t,r,n),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),n?this._events[t].unshift(r):this._events[t].push(r),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,f.call(this,this._events[t].length,t))):this._events[t]=r,s)},k.prototype.off=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof t?t.split(this.delimiter):t.slice();if(!(i=S.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[t])return this;r=this._events[t],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var u=-1,l=0,c=r.length;l<c;l++)if(r[l]===e||r[l].listener&&r[l].listener===e||r[l]._origin&&r[l]._origin===e){u=l;break}if(u<0)continue;return this.wildcard?a._listeners.splice(u,1):this._events[t].splice(u,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[t]),this._removeListener&&this.emit("removeListener",t,e),this}(r===e||r.listener&&r.listener===e||r._origin&&r._origin===e)&&(this.wildcard?delete a._listeners:delete this._events[t],this._removeListener&&this.emit("removeListener",t,e))}return this.listenerTree&&E(this.listenerTree),this},k.prototype.offAny=function(t){var e,r=0,n=0;if(t&&this._all&&this._all.length>0){for(r=0,n=(e=this._all).length;r<n;r++)if(t===e[r])return e.splice(r,1),this._removeListener&&this.emit("removeListenerAny",t),this}else{if(e=this._all,this._removeListener)for(r=0,n=e.length;r<n;r++)this.emit("removeListenerAny",e[r]);this._all=[]}return this},k.prototype.removeListener=k.prototype.off,k.prototype.removeAllListeners=function(t){if(t===e)return!this._events||l.call(this),this;if(this.wildcard){var r,n=S.call(this,null,t,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&E(this.listenerTree)}else this._events&&(this._events[t]=null);return this},k.prototype.listeners=function(t){var r,n,i,o,s,a=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(o=(r=u(a)).length,i=[];o-- >0;)"function"==typeof(n=a[r[o]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],c="string"==typeof t?t.split(this.delimiter):t.slice();return S.call(this,l,c,s,0),l}return a&&(n=a[t])?"function"==typeof n?[n]:n:[]},k.prototype.eventNames=function(t){var e=this._events;return this.wildcard?j.call(this,this.listenerTree,[],null,t):e?u(e):[]},k.prototype.listenerCount=function(t){return this.listeners(t).length},k.prototype.hasListeners=function(t){if(this.wildcard){var r=[],n="string"==typeof t?t.split(this.delimiter):t.slice();return S.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(t===e?u(i).length:i[t]))},k.prototype.listenersAny=function(){return this._all?this._all:[]},k.prototype.waitFor=function(t,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),b((r=v(r,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:_,Promise:y})).Promise,(function(e,i,o){function s(){var o=r.filter;if(!o||o.apply(n,arguments))if(n.off(t,s),r.handleError){var a=arguments[0];a?i(a):e(p.apply(null,arguments).slice(1))}else e(p.apply(null,arguments))}o((function(){n.off(t,s)})),n._on(t,s,!1)}),{timeout:r.timeout,overload:r.overload})};var O=k.prototype;Object.defineProperties(k,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(t){if("number"!=typeof t||t<0||Number.isNaN(t))throw TypeError("n must be a non-negative number");O._maxListeners=t},enumerable:!0},once:{value:function(t,e,r){return b((r=v(r,{Promise:Promise,timeout:0,overload:!1},{Promise:y})).Promise,(function(r,n,i){var o;if("function"==typeof t.addEventListener)return o=function(){r(p.apply(null,arguments))},i((function(){t.removeEventListener(e,o)})),void t.addEventListener(e,o,{once:!0});var s,a=function(){s&&t.removeListener("error",s),r(p.apply(null,arguments))};"error"!==e&&(s=function(r){t.removeListener(e,a),n(r)},t.once("error",s)),i((function(){s&&t.removeListener("error",s),t.removeListener(e,a)})),t.once(e,a)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),t.exports=k}()}(Ue)),Ue.exports),Ke=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.emittedEvents=new Set,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 r(){this.constructor=t}we(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,Le([t],e,!1))},e.prototype.emit=function(e){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.emittedEvents.add(e);var o=e.replace("::",".");if(!this.noneFireableActions.includes(o)&&Salla.call&&"function"==typeof Salla.call(o))return Salla.log("'Salla.".concat(o,"(...)' triggered using event '").concat(e,"'")),o=o.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[o[0]])[o[1]].apply(r,n);t.prototype.emit.apply(this,Le([e],n,!1)),this.trackEvents.apply(this,Le([e],n,!1))},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var i=t.prototype.emitAsync.apply(this,Le([e],r,!1));try{this.trackEvents.apply(this,Le([e],r,!1))}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t)}return i},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var i={event:t};r.map((function(t){return"object"==typeof t&&(i=Se(Se({},i),t))})),window.dataLayer.push(i)}catch(t){salla.logger.error(t.message)}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,Le([t],r,!1)),this.dispatchMobileEvent.apply(this,Le([t],r,!1))},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,Le([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,r=Object.entries(t);e<r.length;e++){var n=r[e],i=n[0],o=n[1];this.dispatch(i,o)}else Salla.log("No Events To Dispatch!",t)},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},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){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e})}catch(t){Salla.log(t,"The Flutter context does not exist yet")}}},e}(Ge.EventEmitter2);function Je(){if(Ce)return ze;Ce=1;var t=Object.assign?Object.assign:function(t,e,r,n){for(var i=1;i<arguments.length;i++)o(Object(arguments[i]),(function(e,r){t[r]=e}));return t},e=function(){if(Object.create)return function(e,r,n,o){var s=i(arguments,1);return t.apply(this,[Object.create(e)].concat(s))};{function e(){}return function(r,n,o,s){var a=i(arguments,1);return e.prototype=r,t.apply(this,[new e].concat(a))}}}(),r=String.prototype.trim?function(t){return String.prototype.trim.call(t)}:function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},n="undefined"!=typeof window?window:Yt;function i(t,e){return Array.prototype.slice.call(t,e||0)}function o(t,e){s(t,(function(t,r){return e(t,r),!1}))}function s(t,e){if(a(t)){for(var r=0;r<t.length;r++)if(e(t[r],r))return t[r]}else for(var n in t)if(t.hasOwnProperty(n)&&e(t[n],n))return t[n]}function a(t){return null!=t&&"function"!=typeof t&&"number"==typeof t.length}return ze={assign:t,create:e,trim:r,bind:function(t,e){return function(){return e.apply(t,Array.prototype.slice.call(arguments,0))}},slice:i,each:o,map:function(t,e){var r=a(t)?[]:{};return s(t,(function(t,n){return r[n]=e(t,n),!1})),r},pluck:s,isList:a,isFunction:function(t){return t&&"[object Function]"==={}.toString.call(t)},isObject:function(t){return t&&"[object Object]"==={}.toString.call(t)},Global:n},ze}var Be,qe,He,Ze,Qe,Ve,Xe,Ye,tr=function(){if(Me)return Ie;Me=1;var t=Je(),e=t.slice,r=t.pluck,n=t.each,i=t.bind,o=t.create,s=t.isList,a=t.isFunction,u=t.isObject,l={version:"2.0.12",enabled:!1,get:function(t,e){var r=this.storage.read(this._namespacePrefix+t);return this._deserialize(r,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(r,n){t.call(e,e._deserialize(r),(n||"").replace(e._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(t){return this._namespacePrefix=="__storejs_"+t+"_"},createStore:function(){return c.apply(this,arguments)},addPlugin:function(t){this._addPlugin(t)},namespace:function(t){return c(this.storage,this.plugins,t)}};function c(t,c,f){f||(f=""),t&&!s(t)&&(t=[t]),c&&!s(c)&&(c=[c]);var p=f?"__storejs_"+f+"_":"",h=f?new RegExp("^"+p):null;if(!/^[a-zA-Z0-9_\-]*$/.test(f))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var d={_namespacePrefix:p,_namespaceRegexp:h,_testStorage:function(t){try{var e="__storejs__test__";t.write(e,e);var r=t.read(e)===e;return t.remove(e),r}catch(t){return!1}},_assignPluginFnProp:function(t,r){var i=this[r];this[r]=function(){var r=e(arguments,0),o=this,s=[function(){if(i)return n(arguments,(function(t,e){r[e]=t})),i.apply(o,r)}].concat(r);return t.apply(o,s)}},_serialize:function(t){return JSON.stringify(t)},_deserialize:function(t,e){if(!t)return e;var r="";try{r=JSON.parse(t)}catch(e){r=t}return void 0!==r?r:e},_addStorage:function(t){this.enabled||this._testStorage(t)&&(this.storage=t,this.enabled=!0)},_addPlugin:function(t){var e=this;if(s(t))n(t,(function(t){e._addPlugin(t)}));else if(!r(this.plugins,(function(e){return t===e}))){if(this.plugins.push(t),!a(t))throw new Error("Plugins must be function values that return objects");var i=t.call(this);if(!u(i))throw new Error("Plugins must return an object of function properties");n(i,(function(r,n){if(!a(r))throw new Error("Bad plugin property: "+n+" from plugin "+t.name+". Plugins should only return functions.");e._assignPluginFnProp(r,n)}))}},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)}},v=o(d,l,{plugins:[]});return v.raw={},n(v,(function(t,e){a(t)&&(v.raw[e]=i(v,t))})),n(t,(function(t){v._addStorage(t)})),n(c,(function(t){v._addPlugin(t)})),v}return Ie={createStore:c}}(),er=function(){if(qe)return Be;qe=1;var t=Je().Global;function e(){return t.localStorage}function r(t){return e().getItem(t)}return Be={name:"localStorage",read:r,write:function(t,r){return e().setItem(t,r)},each:function(t){for(var n=e().length-1;n>=0;n--){var i=e().key(n);t(r(i),i)}},remove:function(t){return e().removeItem(t)},clearAll:function(){return e().clear()}}}(),rr=t({__proto__:null,default:er},[er]),nr=function(){if(Ze)return He;Ze=1;var t=Je().Global;function e(){return t.sessionStorage}function r(t){return e().getItem(t)}return He={name:"sessionStorage",read:r,write:function(t,r){return e().setItem(t,r)},each:function(t){for(var n=e().length-1;n>=0;n--){var i=e().key(n);t(r(i),i)}},remove:function(t){return e().removeItem(t)},clearAll:function(){return e().clear()}}}(),ir=t({__proto__:null,default:nr},[nr]),or=function(){if(Ve)return Qe;Ve=1;var t=Je(),e=t.Global,r=t.trim;Qe={name:"cookieStorage",read:function(t){if(!t||!s(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(n.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){t&&(n.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")},each:i,remove:o,clearAll:function(){i((function(t,e){o(e)}))}};var n=e.document;function i(t){for(var e=n.cookie.split(/; ?/g),i=e.length-1;i>=0;i--)if(r(e[i])){var o=e[i].split("="),s=unescape(o[0]);t(unescape(o[1]),s)}}function o(t){t&&s(t)&&(n.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function s(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(n.cookie)}return Qe}(),sr=t({__proto__:null,default:or},[or]),ar=function(){if(Ye)return Xe;Ye=1,Xe={name:"memoryStorage",read:function(e){return t[e]},write:function(e,r){t[e]=r},each:function(e){for(var r in t)t.hasOwnProperty(r)&&e(t[r],r)},remove:function(e){delete t[e]},clearAll:function(e){t={}}};var t={};return Xe}(),ur=t({__proto__:null,default:ar},[ar]),lr=tr.createStore([rr,ir,sr,ur],[]),cr=tr.createStore([ir],[]),fr=tr.createStore([sr],[]),pr=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=lr,this.session=cr,this.cookie=fr}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],i=((r={})[n]=this.store.get(n),r);return i=Salla.helpers.setNested(i,t,e),this.store.set(n,i[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=!1),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t)}))},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return"".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var i=this.prefixKey(t),o=(new Date).getTime()+60*r*1e3;return this[n].set(i,{value:e,expiry:o})},t.prototype.getWithTTL=function(t,e,r){void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),i=this[r].get(n);return i?(new Date).getTime()>i.expiry?(this[r].remove(n),e):i.value:e},t}(),hr=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}))}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,r){void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),n="; expires="+i.toUTCString()}var o=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(o,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=!1),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();return"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new We,Salla.logger=De,Salla.event=new Ke,Salla.helpers=$e,Salla.storage=new pr,Salla.cookie=new hr,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.309"},Salla}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Salla=e()}(this,(function(){"use strict";function t(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(r){if("default"!==r&&!(r in t)){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}))})),Object.freeze(t)}function e(t,e){void 0===e&&(e=!1),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],o=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,s=e?i:n,a=0;a<o.length;a++)r=new RegExp(o[a],"g"),t=t.replace(r,s[a]);return t.replace(e?"٫":".",e?".":"٫")}function r(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?r(t.replace(/\.(.+)\./g,".$1")):t}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 r,n=this,i=0;i<t.length;i++)r=new RegExp(t[i],"g"),n=n.replace(r,e[i]);return n},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 n,i,o,s,a,u,l,c,f,p,h,d,v,y,g,_,m,b,w,S,L,j,E,x,A,k,O,P,T,F,N,R,z,C,I,M,$,D,W,U,G,K,J,B,q,H,Z,Q,V,X,Y,tt,et,rt,nt,it,ot,st,at,ut,lt,ct,ft,pt,ht,dt,vt,yt,gt,_t,mt,bt,wt,St,Lt,jt,Et,xt,At,kt,Ot,Pt,Tt,Ft,Nt,Rt,zt,Ct,It,Mt,$t,Dt,Wt,Ut,Gt,Kt,Jt,Bt,qt,Ht,Zt,Qt,Vt,Xt,Yt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function te(){if(i)return n;i=1;var t=Array.isArray;return n=t}function ee(){if(u)return a;u=1;var t=function(){if(s)return o;s=1;var t="object"==typeof Yt&&Yt&&Yt.Object===Object&&Yt;return o=t}(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return a=r}function re(){if(c)return l;c=1;var t=ee().Symbol;return l=t}function ne(){if(y)return v;y=1;var t=re(),e=function(){if(p)return f;p=1;var t=re(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,i=t?t.toStringTag:void 0;return f=function(t){var e=r.call(t,i),o=t[i];try{t[i]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[i]=o:delete t[i]),a}}(),r=function(){if(d)return h;d=1;var t=Object.prototype.toString;return h=function(e){return t.call(e)}}(),n=t?t.toStringTag:void 0;return v=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function ie(){if(b)return m;b=1;var t=ne(),e=_?g:(_=1,g=function(t){return null!=t&&"object"==typeof t});return m=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function oe(){return j?L:(j=1,L=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)})}function se(){if(R)return N;R=1;var t=function(){if(x)return E;x=1;var t=ne(),e=oe();return E=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}(),e=function(){if(P)return O;P=1;var t,e=function(){if(k)return A;k=1;var t=ee()["__core-js_shared__"];return A=t}(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return O=function(t){return!!r&&r in t}}(),r=oe(),n=function(){if(F)return T;F=1;var t=Function.prototype.toString;return T=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,a=o.toString,u=s.hasOwnProperty,l=RegExp("^"+a.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return N=function(o){return!(!r(o)||e(o))&&(t(o)?l:i).test(n(o))}}function ae(){if(M)return I;M=1;var t=se(),e=C?z:(C=1,z=function(t,e){return null==t?void 0:t[e]});return I=function(r,n){var i=e(r,n);return t(i)?i:void 0}}function ue(){if(D)return $;D=1;var t=ae()(Object,"create");return $=t}function le(){if(it)return nt;it=1;var t=rt?et:(rt=1,et=function(t,e){return t===e||t!=t&&e!=e});return nt=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function ce(){if(_t)return gt;_t=1;var t=function(){if(X)return V;X=1;var t=function(){if(U)return W;U=1;var t=ue();return W=function(){this.__data__=t?t(null):{},this.size=0}}(),e=K?G:(K=1,G=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),r=function(){if(B)return J;B=1;var t=ue(),e=Object.prototype.hasOwnProperty;return J=function(r){var n=this.__data__;if(t){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(n,r)?n[r]:void 0}}(),n=function(){if(H)return q;H=1;var t=ue(),e=Object.prototype.hasOwnProperty;return q=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}(),i=function(){if(Q)return Z;Q=1;var t=ue();return Z=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}();function o(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,V=o}(),e=function(){if(dt)return ht;dt=1;var t=tt?Y:(tt=1,Y=function(){this.__data__=[],this.size=0}),e=function(){if(st)return ot;st=1;var t=le(),e=Array.prototype.splice;return ot=function(r){var n=this.__data__,i=t(n,r);return!(i<0||(i==n.length-1?n.pop():e.call(n,i,1),--this.size,0))}}(),r=function(){if(ut)return at;ut=1;var t=le();return at=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}(),n=function(){if(ct)return lt;ct=1;var t=le();return lt=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(pt)return ft;pt=1;var t=le();return ft=function(e,r){var n=this.__data__,i=t(n,e);return i<0?(++this.size,n.push([e,r])):n[i][1]=r,this}}();function o(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,ht=o}(),r=function(){if(yt)return vt;yt=1;var t=ae()(ee(),"Map");return vt=t}();return gt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function fe(){if(St)return wt;St=1;var t=bt?mt:(bt=1,mt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return wt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function pe(){if(Ct)return zt;Ct=1;var t=function(){if(Rt)return Nt;Rt=1;var t=function(){if(Ft)return Tt;Ft=1;var t=ce(),e=function(){if(jt)return Lt;jt=1;var t=fe();return Lt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}(),r=function(){if(xt)return Et;xt=1;var t=fe();return Et=function(e){return t(this,e).get(e)}}(),n=function(){if(kt)return At;kt=1;var t=fe();return At=function(e){return t(this,e).has(e)}}(),i=function(){if(Pt)return Ot;Pt=1;var t=fe();return Ot=function(e,r){var n=t(this,e),i=n.size;return n.set(e,r),this.size+=n.size==i?0:1,this}}();function o(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Tt=o}();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=n?n.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var s=r.apply(this,t);return i.cache=o.set(e,s)||o,s};return i.cache=new(e.Cache||t),i}return e.Cache=t,Nt=e}();return zt=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function he(){if(Bt)return Jt;Bt=1;var t=te(),e=function(){if(S)return w;S=1;var t=te(),e=ie(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return w=function(i,o){if(t(i))return!1;var s=typeof i;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=i&&!e(i))||n.test(i)||!r.test(i)||null!=o&&i in Object(o)}}(),r=function(){if(Mt)return It;Mt=1;var t=pe(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=t((function(t){var n=[];return 46===t.charCodeAt(0)&&n.push(""),t.replace(e,(function(t,e,i,o){n.push(i?o.replace(r,"$1"):e||t)})),n}));return It=n}(),n=function(){if(Kt)return Gt;Kt=1;var t=function(){if(Ut)return Wt;Ut=1;var t=re(),e=Dt?$t:(Dt=1,$t=function(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}),r=te(),n=ie(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return Wt=function t(i){if("string"==typeof i)return i;if(r(i))return e(i,t)+"";if(n(i))return o?o.call(i):"";var s=i+"";return"0"==s&&1/i==-1/0?"-0":s}}();return Gt=function(e){return null==e?"":t(e)}}();return Jt=function(i,o){return t(i)?i:e(i,o)?[i]:r(n(i))}}var de=function(){if(Xt)return Vt;Xt=1;var t=function(){if(Qt)return Zt;Qt=1;var t=he(),e=function(){if(Ht)return qt;Ht=1;var t=ie();return qt=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}();return Zt=function(r,n){for(var i=0,o=(n=t(n,r)).length;null!=r&&i<o;)r=r[e(n[i++])];return i&&i==o?r:void 0}}();return Vt=function(e,r,n){var i=null==e?void 0:t(e,r);return void 0===i?n:i}}();function ve(t){return"".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function ye(t){if(ve(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 ge(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function _e(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function me(t){return ve(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):_e("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}var be=Object.freeze({__proto__:null,addParamToUrl:ge,api:function(t){var e;return(null===(e=Salla.config.get("store.api",ye("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:me,base:function(t){return ve(t)?t:"https://"+new URL(ye("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:_e,cdn:function(t,e,r){var n="https://cdn.salla.network/";return(e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return"custom"===t?e:ye("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return ve(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:ye,is_full_url:ve,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return me(salla.config.get("theme.settings.placeholder"))===me(t)}}),we=function(t,e){return we=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},we(t,e)},Se=function(){return Se=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Se.apply(this,arguments)};function Le(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function je(t){return t instanceof FormData}function Ee(t){return t instanceof File}function xe(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var Ae=function(){function t(t){this.data=t,this.proxy=this.createProxy()}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return"string"==typeof r&&(t.set(r,n),!0)},has:function(e,r){return"string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return"string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return je(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(je(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;je(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){Ee(e)||xe(e)?r.data.append(t,e):r.data.append(t,String(e))})):Ee(e)||xe(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e},t.prototype.append=function(t,e){if(je(this.data))Ee(e)||xe(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else{var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e]}},t.prototype.setFile=function(t,e){this.set(t,e)},t.prototype.getFile=function(t){var e=this.get(t);return Ee(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(Ee)},t.prototype.has=function(t){return je(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return je(this.data)?(this.data.delete(t),!0):delete this.data[t]},t.prototype.keys=function(){if(!je(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n)}return Array.from(t)},t.prototype.values=function(){if(!je(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n)}return t},t.prototype.entries=function(){return je(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!je(this.data))return Se({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],i=n[0],o=n[1];void 0!==t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(o)):t[i]=o}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return{name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return Ee(e)||xe(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function ke(t,e,r){var n,i=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[i]=ke(t.slice(1),e,r[i]),r):i?((n={})[i]=ke(t.slice(1),e),n):""===i?[e]:e}function Oe(){return window.self!==window.top}var Pe,Te,Fe,Ne,Re,ze,Ce,Ie,Me,$e={digitsOnly:function(t){return e(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")?r(i):i.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e)},number:e,money:function(t,r){void 0===r&&(r=!0);var n=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=e(t="object"==typeof t?t.amount:t)+" "+n,r&&["SAR","ر.س"].includes(n)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(n,"<i class=sicon-sar></i>")),t},isIframe:Oe,isPreview:function(){return Oe()},setNested:function(t,e,r){for(var n=t,i=e.split("."),o=i.length,s=0;s<o-1;s++){var a=i[s];n[a]||(n[a]={}),n=n[a]}return n[i[o-1]]=r,t},getNested:function(t,e,r){var n=de.default?de.default(t,e):de(t,e);return void 0!==n?n:r},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),i=n[0],o=r&&"object"==typeof r?r[i]:void 0;return{name:i,value:ke(n.slice(1),e,o)}}return{name:t,value:e}},url:be,addParamToUrl:ge,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,i);n.forEach((function(t){return t(e)})),n=[]}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return!!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),!1}},createFormDataWrapper:function(t){return new Ae(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),!1}}},De=(Pe=console,Te=[],Fe=[],Ne={log:function(t,e){if(Pe&&salla.config.isDebug()){Te.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=Pe.log,n=void 0===e?r:this.__dict__[e]||r,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];Fe.forEach((function(t){i[0]+=t[0],i.push(t[1])}));var o={event:"#CFF680",backend:"#7b68ee"}[e];o&&(i[0]+="%c"+e[0].toUpperCase()+e.substring(1),i.push("margin-left: 5px;color: ".concat(o,";font-weight:bold; border:1px solid ").concat(o,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,Le([Pe],i.concat.apply(i,t),!1))}},__dict__:{trace:Pe.trace,debug:Pe.debug,info:Pe.info,warn:Pe.warn,error:Pe.error}},{event:function(){Ne.log(arguments,"event")},trace:function(){Ne.log(arguments,"trace")},debug:function(){Ne.log(arguments,"debug")},info:function(){Ne.log(arguments,"info")},warn:function(){Ne.log(arguments,"warn")},error:function(){Ne.log(arguments,"error")},log:function(){Ne.log(arguments,void 0)},backend:function(){Ne.log(arguments,"backend")},logs:function(t){[t].flat().forEach((function(t){return t&&Ne.log([t].flat(),"backend")}))},history:function(){return Te.map((function(t){return Pe.log.apply(Pe,Le([t[0]],t[1],!1))})),Te},addPrefix:function(t){return Array.isArray(t)?Fe.unshift(t):this.warn("addPrefix receives array only!"),this}}),We=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=Se(Se({},this.default_properties),t)}return t.prototype.merge=function(t){var e;return this.properties_=Se(Se({},this.properties_),t),this.properties_.store=Se(Se({},(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}(),Ue={exports:{}},Ge=(Re||(Re=1,function(t,e){!function(e){var r=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i="object"==typeof process&&"function"==typeof process.nextTick,o="function"==typeof Symbol,s="object"==typeof Reflect,a="function"==typeof setImmediate?setImmediate:setTimeout,u=o?s&&"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 l(){this._events={},this._conf&&c.call(this,this._conf)}function c(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 f(t,e){var r="(node) warning: possible EventEmitter memory leak detected. "+t+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+e+"."),"undefined"!=typeof process&&process.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=t,process.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var p=function(t,e,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[t];case 2:return[t,e];case 3:return[t,e,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function h(t,r){for(var n={},i=t.length,o=0;o<i;o++)n[t[o]]=o<0?r[o]:e;return n}function d(t,e,r){var n,i;if(this._emitter=t,this._target=e,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),e.addEventListener?(n=e.addEventListener,i=e.removeEventListener):e.addListener?(n=e.addListener,i=e.removeListener):e.on&&(n=e.on,i=e.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var o=t._observers;o?o.push(this):t._observers=[this]}function v(t,n,i,o){var s=Object.assign({},n);if(!t)return s;if("object"!=typeof t)throw TypeError("options must be an object");var a,u,l,c=Object.keys(t),f=c.length;function p(t){throw Error('Invalid "'+a+'" option value'+(t?". Reason: "+t:""))}for(var h=0;h<f;h++){if(a=c[h],!r.call(n,a))throw Error('Unknown "'+a+'" option');(u=t[a])!==e&&(l=i[a],s[a]=l?l(u,p):u)}return s}function y(t,e){return"function"==typeof t&&t.hasOwnProperty("prototype")||e("value must be a constructor"),t}function g(t){var e="value must be type of "+t.join("|"),r=t.length,n=t[0],i=t[1];return 1===r?function(t,r){if(typeof t===n)return t;r(e)}:2===r?function(t,r){var o=typeof t;if(o===n||o===i)return t;r(e)}:function(n,i){for(var o=typeof n,s=r;s-- >0;)if(o===t[s])return n;i(e)}}Object.assign(d.prototype,{subscribe:function(t,e,r){var n=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var n=p.apply(null,arguments),s={data:n,name:e,original:t};r?!1!==r.call(i,s)&&o.emit.apply(o,[s.name].concat(n)):o.emit.apply(o,[e].concat(n))};if(s[t])throw Error("Event '"+t+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===e&&null===s[t]&&(s[t]=a,n._on.call(i,t,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===e&&!o.hasListeners(r)&&s[t]&&(s[t]=null,n._off.call(i,t,a))},s[t]=null,o.on("removeListener",this._onRemoveListener)):(s[t]=a,n._on.call(i,t,a))},unsubscribe:function(t){var e,r,n,i=this,o=this._listeners,s=this._emitter,a=this._off,l=this._target;if(t&&"string"!=typeof t)throw TypeError("event must be a string");function c(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var t=w.call(s,i);s._observers.splice(t,1)}if(t){if(!(e=o[t]))return;a.call(l,t,e),delete o[t],--this._listenersCount||c()}else{for(n=(r=u(o)).length;n-- >0;)t=r[n],a.call(l,t,o[t]);this._listeners={},this._listenersCount=0,c()}}});var _=g(["function"]),m=g(["object","function"]);function b(t,e,r){var n,i,o,s=0,a=new t((function(u,l,c){function f(){i&&(i=null),s&&(clearTimeout(s),s=0)}r=v(r,{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}}),n=!r.overload&&"function"==typeof t.prototype.cancel&&"function"==typeof c;var p=function(t){f(),u(t)},h=function(t){f(),l(t)};n?e(p,h,c):(i=[function(t){h(t||Error("canceled"))}],e(p,h,(function(t){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof t)throw TypeError("onCancel callback must be a function");i.push(t)})),o=!0),r.timeout>0&&(s=setTimeout((function(){var t=Error("timeout");t.code="ETIMEDOUT",s=0,a.cancel(t),l(t)}),r.timeout))}));return n||(a.cancel=function(t){if(i){for(var e=i.length,r=1;r<e;r++)i[r](t);i[0](t),i=null}}),a}function w(t){var e=this._observers;if(!e)return-1;for(var r=e.length,n=0;n<r;n++)if(e[n]._target===t)return n;return-1}function S(t,e,r,n,i){if(!r)return null;if(0===n){var o=typeof e;if("string"===o){var s,a,l=0,c=0,f=this.delimiter,p=f.length;if(-1!==(a=e.indexOf(f))){s=new Array(5);do{s[l++]=e.slice(c,a),c=a+p}while(-1!==(a=e.indexOf(f,c)));s[l++]=e.slice(c),e=s,i=l}else e=[e],i=1}else"object"===o?i=e.length:(e=[e],i=1)}var h,d,v,y,g,_,m,b=null,w=e[n],L=e[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(t&&t.push(r._listeners),b=[r]):(t&&t.push.apply(t,r._listeners),b=[r]));else{if("*"===w){for(a=(_=u(r)).length;a-- >0;)"_listeners"!==(h=_[a])&&(m=S(t,e,r[h],n+1,i))&&(b?b.push.apply(b,m):b=m);return b}if("**"===w){for((g=n+1===i||n+2===i&&"*"===L)&&r._listeners&&(b=S(t,e,r,i,i)),a=(_=u(r)).length;a-- >0;)"_listeners"!==(h=_[a])&&("*"===h||"**"===h?(r[h]._listeners&&!g&&(m=S(t,e,r[h],i,i))&&(b?b.push.apply(b,m):b=m),m=S(t,e,r[h],n,i)):m=S(t,e,r[h],h===L?n+2:n,i),m&&(b?b.push.apply(b,m):b=m));return b}r[w]&&(b=S(t,e,r[w],n+1,i))}if((d=r["*"])&&S(t,e,d,n+1,i),v=r["**"])if(n<i)for(v._listeners&&S(t,e,v,i,i),a=(_=u(v)).length;a-- >0;)"_listeners"!==(h=_[a])&&(h===L?S(t,e,v[h],n+2,i):h===w?S(t,e,v[h],n+1,i):((y={})[h]=v[h],S(t,e,{"**":y},n+1,i)));else v._listeners?S(t,e,v,i,i):v["*"]&&v["*"]._listeners&&S(t,e,v["*"],i,i);return b}function L(t,e,r){var n,i,o=0,s=0,a=this.delimiter,u=a.length;if("string"==typeof t)if(-1!==(n=t.indexOf(a))){i=new Array(5);do{i[o++]=t.slice(s,n),s=n+u}while(-1!==(n=t.indexOf(a,s)));i[o++]=t.slice(s)}else i=[t],o=1;else i=t,o=t.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var l,c=this.listenerTree;for(n=0;n<o;n++)if(c=c[l=i[n]]||(c[l]={}),n===o-1)return c._listeners?("function"==typeof c._listeners&&(c._listeners=[c._listeners]),r?c._listeners.unshift(e):c._listeners.push(e),!c._listeners.warned&&this._maxListeners>0&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,f.call(this,c._listeners.length,l))):c._listeners=e,!0;return!0}function j(t,e,r,n){for(var i,o,s,a,l=u(t),c=l.length,f=t._listeners;c-- >0;)i=t[o=l[c]],s="_listeners"===o?r:r?r.concat(o):[o],a=n||"symbol"==typeof o,f&&e.push(a?s:s.join(this.delimiter)),"object"==typeof i&&j.call(this,i,e,s,a);return e}function E(t){for(var e,r,n,i=u(t),o=i.length;o-- >0;)(e=t[r=i[o]])&&(n=!0,"_listeners"===r||E(e)||delete t[r]);return n}function x(t,e,r){this.emitter=t,this.event=e,this.listener=r}function A(t,r,n){if(!0===n)s=!0;else if(!1===n)o=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var o=n.async,s=n.promisify,u=n.nextTick,l=n.objectify}if(o||u||s){var c=r,f=r._origin||r;if(u&&!i)throw Error("process.nextTick is not supported");s===e&&(s="AsyncFunction"===r.constructor.name),r=function(){var t=arguments,e=this,r=this.event;return s?u?Promise.resolve():new Promise((function(t){a(t)})).then((function(){return e.event=r,c.apply(e,t)})):(u?process.nextTick:a)((function(){e.event=r,c.apply(e,t)}))},r._async=!0,r._origin=f}return[r,l?new x(this,t,r):this]}function k(t){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,c.call(this,t)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},k.EventEmitter2=k,k.prototype.listenTo=function(t,r,i){if("object"!=typeof t)throw TypeError("target musts be an object");var o=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var r,n=i.reducers,s=w.call(o,t);r=-1===s?new d(o,t,i):o._observers[s];for(var a,l=u(e),c=l.length,f="function"==typeof n,p=0;p<c;p++)a=l[p],r.subscribe(a,e[a]||a,f?n:n&&n[a])}return i=v(i,{on:e,off:e,reducers:e},{on:_,off:_,reducers:m}),n(r)?s(h(r)):s("string"==typeof r?h(r.split(/\s+/)):r),this},k.prototype.stopListeningTo=function(t,e){var r=this._observers;if(!r)return!1;var n,i=r.length,o=!1;if(t&&"object"!=typeof t)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],t&&n._target!==t||(n.unsubscribe(e),o=!0);return o},k.prototype.delimiter=".",k.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},k.prototype.getMaxListeners=function(){return this._maxListeners},k.prototype.event="",k.prototype.once=function(t,e,r){return this._once(t,e,!1,r)},k.prototype.prependOnceListener=function(t,e,r){return this._once(t,e,!0,r)},k.prototype._once=function(t,e,r,n){return this._many(t,1,e,r,n)},k.prototype.many=function(t,e,r,n){return this._many(t,e,r,!1,n)},k.prototype.prependMany=function(t,e,r,n){return this._many(t,e,r,!0,n)},k.prototype._many=function(t,e,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function s(){return 0==--e&&o.off(t,s),r.apply(this,arguments)}return s._origin=r,this._on(t,s,n,i)},k.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var t,e,r,n,i,s,a=arguments[0],u=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(u&&(t=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,o)for(n=0;n<r;n++)if("symbol"==typeof a[n]){s=!0;break}s||(a=a.join(this.delimiter))}var c,f=arguments.length;if(this._all&&this._all.length)for(n=0,r=(c=this._all.slice()).length;n<r;n++)switch(this.event=a,f){case 1:c[n].call(this,a);break;case 2:c[n].call(this,a,arguments[1]);break;case 3:c[n].call(this,a,arguments[1],arguments[2]);break;default:c[n].apply(this,arguments)}if(u)c=[],S.call(this,c,t,this.listenerTree,0,r);else{if("function"==typeof(c=this._events[a])){switch(this.event=a,f){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=new Array(f-1),i=1;i<f;i++)e[i-1]=arguments[i];c.apply(this,e)}return!0}c&&(c=c.slice())}if(c&&c.length){if(f>3)for(e=new Array(f-1),i=1;i<f;i++)e[i-1]=arguments[i];for(n=0,r=c.length;n<r;n++)switch(this.event=a,f){case 1:c[n].call(this);break;case 2:c[n].call(this,arguments[1]);break;case 3:c[n].call(this,arguments[1],arguments[2]);break;default:c[n].apply(this,e)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},k.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var t,e,r,n,i,s,a=arguments[0],u=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(u&&(t=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(n=a.length,o)for(i=0;i<n;i++)if("symbol"==typeof a[i]){e=!0;break}e||(a=a.join(this.delimiter))}var c,f=[],p=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=a,p){case 1:f.push(this._all[i].call(this,a));break;case 2:f.push(this._all[i].call(this,a,arguments[1]));break;case 3:f.push(this._all[i].call(this,a,arguments[1],arguments[2]));break;default:f.push(this._all[i].apply(this,arguments))}if(u?(c=[],S.call(this,c,t,this.listenerTree,0)):c=this._events[a],"function"==typeof c)switch(this.event=a,p){case 1:f.push(c.call(this));break;case 2:f.push(c.call(this,arguments[1]));break;case 3:f.push(c.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(p-1),s=1;s<p;s++)r[s-1]=arguments[s];f.push(c.apply(this,r))}else if(c&&c.length){if(c=c.slice(),p>3)for(r=new Array(p-1),s=1;s<p;s++)r[s-1]=arguments[s];for(i=0,n=c.length;i<n;i++)switch(this.event=a,p){case 1:f.push(c[i].call(this));break;case 2:f.push(c[i].call(this,arguments[1]));break;case 3:f.push(c[i].call(this,arguments[1],arguments[2]));break;default:f.push(c[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(f)},k.prototype.on=function(t,e,r){return this._on(t,e,!1,r)},k.prototype.prependListener=function(t,e,r){return this._on(t,e,!0,r)},k.prototype.onAny=function(t){return this._onAny(t,!1)},k.prototype.prependAny=function(t){return this._onAny(t,!0)},k.prototype.addListener=k.prototype.on,k.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},k.prototype._on=function(t,r,n,i){if("function"==typeof t)return this._onAny(t,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||l.call(this);var o,s=this;return i!==e&&(r=(o=A.call(this,t,r,i))[0],s=o[1]),this._newListener&&this.emit("newListener",t,r),this.wildcard?(L.call(this,t,r,n),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),n?this._events[t].unshift(r):this._events[t].push(r),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,f.call(this,this._events[t].length,t))):this._events[t]=r,s)},k.prototype.off=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof t?t.split(this.delimiter):t.slice();if(!(i=S.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[t])return this;r=this._events[t],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var u=-1,l=0,c=r.length;l<c;l++)if(r[l]===e||r[l].listener&&r[l].listener===e||r[l]._origin&&r[l]._origin===e){u=l;break}if(u<0)continue;return this.wildcard?a._listeners.splice(u,1):this._events[t].splice(u,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[t]),this._removeListener&&this.emit("removeListener",t,e),this}(r===e||r.listener&&r.listener===e||r._origin&&r._origin===e)&&(this.wildcard?delete a._listeners:delete this._events[t],this._removeListener&&this.emit("removeListener",t,e))}return this.listenerTree&&E(this.listenerTree),this},k.prototype.offAny=function(t){var e,r=0,n=0;if(t&&this._all&&this._all.length>0){for(r=0,n=(e=this._all).length;r<n;r++)if(t===e[r])return e.splice(r,1),this._removeListener&&this.emit("removeListenerAny",t),this}else{if(e=this._all,this._removeListener)for(r=0,n=e.length;r<n;r++)this.emit("removeListenerAny",e[r]);this._all=[]}return this},k.prototype.removeListener=k.prototype.off,k.prototype.removeAllListeners=function(t){if(t===e)return!this._events||l.call(this),this;if(this.wildcard){var r,n=S.call(this,null,t,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&E(this.listenerTree)}else this._events&&(this._events[t]=null);return this},k.prototype.listeners=function(t){var r,n,i,o,s,a=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(o=(r=u(a)).length,i=[];o-- >0;)"function"==typeof(n=a[r[o]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],c="string"==typeof t?t.split(this.delimiter):t.slice();return S.call(this,l,c,s,0),l}return a&&(n=a[t])?"function"==typeof n?[n]:n:[]},k.prototype.eventNames=function(t){var e=this._events;return this.wildcard?j.call(this,this.listenerTree,[],null,t):e?u(e):[]},k.prototype.listenerCount=function(t){return this.listeners(t).length},k.prototype.hasListeners=function(t){if(this.wildcard){var r=[],n="string"==typeof t?t.split(this.delimiter):t.slice();return S.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(t===e?u(i).length:i[t]))},k.prototype.listenersAny=function(){return this._all?this._all:[]},k.prototype.waitFor=function(t,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),b((r=v(r,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:_,Promise:y})).Promise,(function(e,i,o){function s(){var o=r.filter;if(!o||o.apply(n,arguments))if(n.off(t,s),r.handleError){var a=arguments[0];a?i(a):e(p.apply(null,arguments).slice(1))}else e(p.apply(null,arguments))}o((function(){n.off(t,s)})),n._on(t,s,!1)}),{timeout:r.timeout,overload:r.overload})};var O=k.prototype;Object.defineProperties(k,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(t){if("number"!=typeof t||t<0||Number.isNaN(t))throw TypeError("n must be a non-negative number");O._maxListeners=t},enumerable:!0},once:{value:function(t,e,r){return b((r=v(r,{Promise:Promise,timeout:0,overload:!1},{Promise:y})).Promise,(function(r,n,i){var o;if("function"==typeof t.addEventListener)return o=function(){r(p.apply(null,arguments))},i((function(){t.removeEventListener(e,o)})),void t.addEventListener(e,o,{once:!0});var s,a=function(){s&&t.removeListener("error",s),r(p.apply(null,arguments))};"error"!==e&&(s=function(r){t.removeListener(e,a),n(r)},t.once("error",s)),i((function(){s&&t.removeListener("error",s),t.removeListener(e,a)})),t.once(e,a)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),t.exports=k}()}(Ue)),Ue.exports),Ke=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.emittedEvents=new Set,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 r(){this.constructor=t}we(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,Le([t],e,!1))},e.prototype.emit=function(e){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.emittedEvents.add(e);var o=e.replace("::",".");if(!this.noneFireableActions.includes(o)&&Salla.call&&"function"==typeof Salla.call(o))return Salla.log("'Salla.".concat(o,"(...)' triggered using event '").concat(e,"'")),o=o.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[o[0]])[o[1]].apply(r,n);t.prototype.emit.apply(this,Le([e],n,!1)),this.trackEvents.apply(this,Le([e],n,!1))},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var i=t.prototype.emitAsync.apply(this,Le([e],r,!1));try{this.trackEvents.apply(this,Le([e],r,!1))}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t)}return i},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var i={event:t};r.map((function(t){return"object"==typeof t&&(i=Se(Se({},i),t))})),window.dataLayer.push(i)}catch(t){salla.logger.error(t.message)}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,Le([t],r,!1)),this.dispatchMobileEvent.apply(this,Le([t],r,!1))},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,Le([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,r=Object.entries(t);e<r.length;e++){var n=r[e],i=n[0],o=n[1];this.dispatch(i,o)}else Salla.log("No Events To Dispatch!",t)},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},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){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e})}catch(t){Salla.log(t,"The Flutter context does not exist yet")}}},e}(Ge.EventEmitter2);function Je(){if(Ce)return ze;Ce=1;var t=Object.assign?Object.assign:function(t,e,r,n){for(var i=1;i<arguments.length;i++)o(Object(arguments[i]),(function(e,r){t[r]=e}));return t},e=function(){if(Object.create)return function(e,r,n,o){var s=i(arguments,1);return t.apply(this,[Object.create(e)].concat(s))};{function e(){}return function(r,n,o,s){var a=i(arguments,1);return e.prototype=r,t.apply(this,[new e].concat(a))}}}(),r=String.prototype.trim?function(t){return String.prototype.trim.call(t)}:function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},n="undefined"!=typeof window?window:Yt;function i(t,e){return Array.prototype.slice.call(t,e||0)}function o(t,e){s(t,(function(t,r){return e(t,r),!1}))}function s(t,e){if(a(t)){for(var r=0;r<t.length;r++)if(e(t[r],r))return t[r]}else for(var n in t)if(t.hasOwnProperty(n)&&e(t[n],n))return t[n]}function a(t){return null!=t&&"function"!=typeof t&&"number"==typeof t.length}return ze={assign:t,create:e,trim:r,bind:function(t,e){return function(){return e.apply(t,Array.prototype.slice.call(arguments,0))}},slice:i,each:o,map:function(t,e){var r=a(t)?[]:{};return s(t,(function(t,n){return r[n]=e(t,n),!1})),r},pluck:s,isList:a,isFunction:function(t){return t&&"[object Function]"==={}.toString.call(t)},isObject:function(t){return t&&"[object Object]"==={}.toString.call(t)},Global:n},ze}var Be,qe,He,Ze,Qe,Ve,Xe,Ye,tr=function(){if(Me)return Ie;Me=1;var t=Je(),e=t.slice,r=t.pluck,n=t.each,i=t.bind,o=t.create,s=t.isList,a=t.isFunction,u=t.isObject,l={version:"2.0.12",enabled:!1,get:function(t,e){var r=this.storage.read(this._namespacePrefix+t);return this._deserialize(r,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(r,n){t.call(e,e._deserialize(r),(n||"").replace(e._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(t){return this._namespacePrefix=="__storejs_"+t+"_"},createStore:function(){return c.apply(this,arguments)},addPlugin:function(t){this._addPlugin(t)},namespace:function(t){return c(this.storage,this.plugins,t)}};function c(t,c,f){f||(f=""),t&&!s(t)&&(t=[t]),c&&!s(c)&&(c=[c]);var p=f?"__storejs_"+f+"_":"",h=f?new RegExp("^"+p):null;if(!/^[a-zA-Z0-9_\-]*$/.test(f))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var d={_namespacePrefix:p,_namespaceRegexp:h,_testStorage:function(t){try{var e="__storejs__test__";t.write(e,e);var r=t.read(e)===e;return t.remove(e),r}catch(t){return!1}},_assignPluginFnProp:function(t,r){var i=this[r];this[r]=function(){var r=e(arguments,0),o=this,s=[function(){if(i)return n(arguments,(function(t,e){r[e]=t})),i.apply(o,r)}].concat(r);return t.apply(o,s)}},_serialize:function(t){return JSON.stringify(t)},_deserialize:function(t,e){if(!t)return e;var r="";try{r=JSON.parse(t)}catch(e){r=t}return void 0!==r?r:e},_addStorage:function(t){this.enabled||this._testStorage(t)&&(this.storage=t,this.enabled=!0)},_addPlugin:function(t){var e=this;if(s(t))n(t,(function(t){e._addPlugin(t)}));else if(!r(this.plugins,(function(e){return t===e}))){if(this.plugins.push(t),!a(t))throw new Error("Plugins must be function values that return objects");var i=t.call(this);if(!u(i))throw new Error("Plugins must return an object of function properties");n(i,(function(r,n){if(!a(r))throw new Error("Bad plugin property: "+n+" from plugin "+t.name+". Plugins should only return functions.");e._assignPluginFnProp(r,n)}))}},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)}},v=o(d,l,{plugins:[]});return v.raw={},n(v,(function(t,e){a(t)&&(v.raw[e]=i(v,t))})),n(t,(function(t){v._addStorage(t)})),n(c,(function(t){v._addPlugin(t)})),v}return Ie={createStore:c}}(),er=function(){if(qe)return Be;qe=1;var t=Je().Global;function e(){return t.localStorage}function r(t){return e().getItem(t)}return Be={name:"localStorage",read:r,write:function(t,r){return e().setItem(t,r)},each:function(t){for(var n=e().length-1;n>=0;n--){var i=e().key(n);t(r(i),i)}},remove:function(t){return e().removeItem(t)},clearAll:function(){return e().clear()}}}(),rr=t({__proto__:null,default:er},[er]),nr=function(){if(Ze)return He;Ze=1;var t=Je().Global;function e(){return t.sessionStorage}function r(t){return e().getItem(t)}return He={name:"sessionStorage",read:r,write:function(t,r){return e().setItem(t,r)},each:function(t){for(var n=e().length-1;n>=0;n--){var i=e().key(n);t(r(i),i)}},remove:function(t){return e().removeItem(t)},clearAll:function(){return e().clear()}}}(),ir=t({__proto__:null,default:nr},[nr]),or=function(){if(Ve)return Qe;Ve=1;var t=Je(),e=t.Global,r=t.trim;Qe={name:"cookieStorage",read:function(t){if(!t||!s(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(n.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){t&&(n.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")},each:i,remove:o,clearAll:function(){i((function(t,e){o(e)}))}};var n=e.document;function i(t){for(var e=n.cookie.split(/; ?/g),i=e.length-1;i>=0;i--)if(r(e[i])){var o=e[i].split("="),s=unescape(o[0]);t(unescape(o[1]),s)}}function o(t){t&&s(t)&&(n.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function s(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(n.cookie)}return Qe}(),sr=t({__proto__:null,default:or},[or]),ar=function(){if(Ye)return Xe;Ye=1,Xe={name:"memoryStorage",read:function(e){return t[e]},write:function(e,r){t[e]=r},each:function(e){for(var r in t)t.hasOwnProperty(r)&&e(t[r],r)},remove:function(e){delete t[e]},clearAll:function(e){t={}}};var t={};return Xe}(),ur=t({__proto__:null,default:ar},[ar]),lr=tr.createStore([rr,ir,sr,ur],[]),cr=tr.createStore([ir],[]),fr=tr.createStore([sr],[]),pr=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=lr,this.session=cr,this.cookie=fr}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],i=((r={})[n]=this.store.get(n),r);return i=Salla.helpers.setNested(i,t,e),this.store.set(n,i[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=!1),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t)}))},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return"".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var i=this.prefixKey(t),o=(new Date).getTime()+60*r*1e3;return this[n].set(i,{value:e,expiry:o})},t.prototype.getWithTTL=function(t,e,r){void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),i=this[r].get(n);return i?(new Date).getTime()>i.expiry?(this[r].remove(n),e):i.value:e},t}(),hr=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}))}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,r){void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),n="; expires="+i.toUTCString()}var o=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(o,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=!1),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();return"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new We,Salla.logger=De,Salla.event=new Ke,Salla.helpers=$e,Salla.storage=new pr,Salla.cookie=new hr,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.311"},Salla}));
2
2
  //# sourceMappingURL=base.min.js.map
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash/get.js"),e=require("eventemitter2"),r=require("store/src/store-engine"),n=require("store/storages/localStorage"),o=require("store/storages/sessionStorage"),i=require("store/storages/cookieStorage"),a=require("store/storages/memoryStorage");function s(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var l=s(r),c=s(n),u=s(o),p=s(i),f=s(a);function d(t,e){void 0===e&&(e=!1),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],o=["0","1","2","3","4","5","6","7","8","9"],i=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:o,a=e?o:n,s=0;s<i.length;s++)r=new RegExp(i[s],"g"),t=t.replace(r,a[s]);return t.replace(e?"٫":".",e?".":"٫")}function h(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?h(t.replace(/\.(.+)\./g,".$1")):t}function g(t){return"".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function y(t){if(g(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 v(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function m(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function w(t){return g(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):m("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}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 r,n=this,o=0;o<t.length;o++)r=new RegExp(t[o],"g"),n=n.replace(r,e[o]);return n},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 S=Object.freeze({__proto__:null,addParamToUrl:v,api:function(t){var e;return(null===(e=Salla.config.get("store.api",y("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:w,base:function(t){return g(t)?t:"https://"+new URL(y("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:m,cdn:function(t,e,r){var n="https://cdn.salla.network/";return(e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return"custom"===t?e:y("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return g(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:y,is_full_url:g,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return w(salla.config.get("theme.settings.placeholder"))===w(t)}}),b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},b(t,e)};var _=function(){return _=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},_.apply(this,arguments)};function x(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function A(t){return t instanceof FormData}function E(t){return t instanceof File}function k(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var O=function(){function t(t){this.data=t,this.proxy=this.createProxy()}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return"string"==typeof r&&(t.set(r,n),!0)},has:function(e,r){return"string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return"string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return A(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(A(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;A(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){E(e)||k(e)?r.data.append(t,e):r.data.append(t,String(e))})):E(e)||k(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e},t.prototype.append=function(t,e){if(A(this.data))E(e)||k(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else{var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e]}},t.prototype.setFile=function(t,e){this.set(t,e)},t.prototype.getFile=function(t){var e=this.get(t);return E(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(E)},t.prototype.has=function(t){return A(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return A(this.data)?(this.data.delete(t),!0):delete this.data[t]},t.prototype.keys=function(){if(!A(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n)}return Array.from(t)},t.prototype.values=function(){if(!A(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n)}return t},t.prototype.entries=function(){return A(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!A(this.data))return _({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],o=n[0],i=n[1];void 0!==t[o]?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return{name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return E(e)||k(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function P(t,e,r){var n,o=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[o]=P(t.slice(1),e,r[o]),r):o?((n={})[o]=P(t.slice(1),e),n):""===o?[e]:e}function j(){return window.self!==window.top}var T,L,D,W,F={digitsOnly:function(t){return d(t,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function t(e,r){if(void 0===r&&(r=!1),"string"==typeof e)return document.querySelectorAll(e).forEach((function(e){return t(e,r)}));if(e){var n=Salla.helpers.digitsOnly(e.value);return e.min&&n<parseInt(e.min)?e.value=e.min:e.max&&n>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&n.toString().length>e.maxLength?e.value=n.toString().substring(0,e.maxLength):e.value=r||e.dataset.hasOwnProperty("digitsWithDecimal")?h(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e)},number:d,money:function(t,e){void 0===e&&(e=!0);var r=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=d(t="object"==typeof t?t.amount:t)+" "+r,e&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(r,"<i class=sicon-sar></i>")),t},isIframe:j,isPreview:function(){return j()},setNested:function(t,e,r){for(var n=t,o=e.split("."),i=o.length,a=0;a<i-1;a++){var s=o[a];n[s]||(n[s]={}),n=n[s]}return n[o[i-1]]=r,t},getNested:function(e,r,n){var o=t.default?t.default(e,r):t(e,r);return void 0!==o?o:n},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),o=n[0],i=r&&"object"==typeof r?r[o]:void 0;return{name:o,value:P(n.slice(1),e,i)}}return{name:t,value:e}},url:S,addParamToUrl:v,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,o);n.forEach((function(t){return t(e)})),n=[]}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return!!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),!1}},createFormDataWrapper:function(t){return new O(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),!1}}},C=(T=console,L=[],D=[],W={log:function(t,e){if(T&&salla.config.isDebug()){L.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=T.log,n=void 0===e?r:this.__dict__[e]||r,o=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];D.forEach((function(t){o[0]+=t[0],o.push(t[1])}));var i={event:"#CFF680",backend:"#7b68ee"}[e];i&&(o[0]+="%c"+e[0].toUpperCase()+e.substring(1),o.push("margin-left: 5px;color: ".concat(i,";font-weight:bold; border:1px solid ").concat(i,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,x([T],o.concat.apply(o,t),!1))}},__dict__:{trace:T.trace,debug:T.debug,info:T.info,warn:T.warn,error:T.error}},{event:function(){W.log(arguments,"event")},trace:function(){W.log(arguments,"trace")},debug:function(){W.log(arguments,"debug")},info:function(){W.log(arguments,"info")},warn:function(){W.log(arguments,"warn")},error:function(){W.log(arguments,"error")},log:function(){W.log(arguments,void 0)},backend:function(){W.log(arguments,"backend")},logs:function(t){[t].flat().forEach((function(t){return t&&W.log([t].flat(),"backend")}))},history:function(){return L.map((function(t){return T.log.apply(T,x([t[0]],t[1],!1))})),L},addPrefix:function(t){return Array.isArray(t)?D.unshift(t):this.warn("addPrefix receives array only!"),this}}),R=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=_(_({},this.default_properties),t)}return t.prototype.merge=function(t){var e;return this.properties_=_(_({},this.properties_),t),this.properties_.store=_(_({},(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}(),N=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.emittedEvents=new Set,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 r(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,x([t],e,!1))},e.prototype.emit=function(e){for(var r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];this.emittedEvents.add(e);var i=e.replace("::",".");if(!this.noneFireableActions.includes(i)&&Salla.call&&"function"==typeof Salla.call(i))return Salla.log("'Salla.".concat(i,"(...)' triggered using event '").concat(e,"'")),i=i.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[i[0]])[i[1]].apply(r,n);t.prototype.emit.apply(this,x([e],n,!1)),this.trackEvents.apply(this,x([e],n,!1))},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var o=t.prototype.emitAsync.apply(this,x([e],r,!1));try{this.trackEvents.apply(this,x([e],r,!1))}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t)}return o},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var o={event:t};r.map((function(t){return"object"==typeof t&&(o=_(_({},o),t))})),window.dataLayer.push(o)}catch(t){salla.logger.error(t.message)}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,x([t],r,!1)),this.dispatchMobileEvent.apply(this,x([t],r,!1))},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,x([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,r=Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.dispatch(o,i)}else Salla.log("No Events To Dispatch!",t)},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},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){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e})}catch(t){Salla.log(t,"The Flutter context does not exist yet")}else;}},e}(e.EventEmitter2),q=l.createStore([c,u,p,f],[]),I=l.createStore([u],[]),M=l.createStore([p],[]),U=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=q,this.session=I,this.cookie=M}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],o=((r={})[n]=this.store.get(n),r);return o=Salla.helpers.setNested(o,t,e),this.store.set(n,o[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=!1),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t)}))},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return"".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var o=this.prefixKey(t),i=(new Date).getTime()+60*r*1e3;return this[n].set(o,{value:e,expiry:i})},t.prototype.getWithTTL=function(t,e,r){void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),o=this[r].get(n);return o?(new Date).getTime()>o.expiry?(this[r].remove(n),e):o.value:e},t}(),$=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}))}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,r){void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}var i=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(i,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=!1),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new R,Salla.logger=C,Salla.event=new N,Salla.helpers=F,Salla.storage=new U,Salla.cookie=new $,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.309"};var z=Salla;exports.default=z;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash/get.js"),e=require("eventemitter2"),r=require("store/src/store-engine"),n=require("store/storages/localStorage"),o=require("store/storages/sessionStorage"),i=require("store/storages/cookieStorage"),a=require("store/storages/memoryStorage");function s(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var l=s(r),c=s(n),u=s(o),p=s(i),f=s(a);function d(t,e){void 0===e&&(e=!1),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],o=["0","1","2","3","4","5","6","7","8","9"],i=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:o,a=e?o:n,s=0;s<i.length;s++)r=new RegExp(i[s],"g"),t=t.replace(r,a[s]);return t.replace(e?"٫":".",e?".":"٫")}function h(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?h(t.replace(/\.(.+)\./g,".$1")):t}function g(t){return"".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function y(t){if(g(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 v(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function m(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function w(t){return g(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):m("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}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 r,n=this,o=0;o<t.length;o++)r=new RegExp(t[o],"g"),n=n.replace(r,e[o]);return n},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 S=Object.freeze({__proto__:null,addParamToUrl:v,api:function(t){var e;return(null===(e=Salla.config.get("store.api",y("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:w,base:function(t){return g(t)?t:"https://"+new URL(y("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:m,cdn:function(t,e,r){var n="https://cdn.salla.network/";return(e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return"custom"===t?e:y("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return g(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:y,is_full_url:g,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return w(salla.config.get("theme.settings.placeholder"))===w(t)}}),b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},b(t,e)};var _=function(){return _=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},_.apply(this,arguments)};function x(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function A(t){return t instanceof FormData}function E(t){return t instanceof File}function k(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var O=function(){function t(t){this.data=t,this.proxy=this.createProxy()}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return"string"==typeof r&&(t.set(r,n),!0)},has:function(e,r){return"string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return"string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return A(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(A(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;A(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){E(e)||k(e)?r.data.append(t,e):r.data.append(t,String(e))})):E(e)||k(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e},t.prototype.append=function(t,e){if(A(this.data))E(e)||k(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else{var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e]}},t.prototype.setFile=function(t,e){this.set(t,e)},t.prototype.getFile=function(t){var e=this.get(t);return E(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(E)},t.prototype.has=function(t){return A(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return A(this.data)?(this.data.delete(t),!0):delete this.data[t]},t.prototype.keys=function(){if(!A(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n)}return Array.from(t)},t.prototype.values=function(){if(!A(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n)}return t},t.prototype.entries=function(){return A(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!A(this.data))return _({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],o=n[0],i=n[1];void 0!==t[o]?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return{name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return E(e)||k(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function P(t,e,r){var n,o=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[o]=P(t.slice(1),e,r[o]),r):o?((n={})[o]=P(t.slice(1),e),n):""===o?[e]:e}function j(){return window.self!==window.top}var T,L,D,W,F={digitsOnly:function(t){return d(t,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function t(e,r){if(void 0===r&&(r=!1),"string"==typeof e)return document.querySelectorAll(e).forEach((function(e){return t(e,r)}));if(e){var n=Salla.helpers.digitsOnly(e.value);return e.min&&n<parseInt(e.min)?e.value=e.min:e.max&&n>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&n.toString().length>e.maxLength?e.value=n.toString().substring(0,e.maxLength):e.value=r||e.dataset.hasOwnProperty("digitsWithDecimal")?h(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e)},number:d,money:function(t,e){void 0===e&&(e=!0);var r=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=d(t="object"==typeof t?t.amount:t)+" "+r,e&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(r,"<i class=sicon-sar></i>")),t},isIframe:j,isPreview:function(){return j()},setNested:function(t,e,r){for(var n=t,o=e.split("."),i=o.length,a=0;a<i-1;a++){var s=o[a];n[s]||(n[s]={}),n=n[s]}return n[o[i-1]]=r,t},getNested:function(e,r,n){var o=t.default?t.default(e,r):t(e,r);return void 0!==o?o:n},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),o=n[0],i=r&&"object"==typeof r?r[o]:void 0;return{name:o,value:P(n.slice(1),e,i)}}return{name:t,value:e}},url:S,addParamToUrl:v,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,o);n.forEach((function(t){return t(e)})),n=[]}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return!!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),!1}},createFormDataWrapper:function(t){return new O(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),!1}}},C=(T=console,L=[],D=[],W={log:function(t,e){if(T&&salla.config.isDebug()){L.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=T.log,n=void 0===e?r:this.__dict__[e]||r,o=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];D.forEach((function(t){o[0]+=t[0],o.push(t[1])}));var i={event:"#CFF680",backend:"#7b68ee"}[e];i&&(o[0]+="%c"+e[0].toUpperCase()+e.substring(1),o.push("margin-left: 5px;color: ".concat(i,";font-weight:bold; border:1px solid ").concat(i,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,x([T],o.concat.apply(o,t),!1))}},__dict__:{trace:T.trace,debug:T.debug,info:T.info,warn:T.warn,error:T.error}},{event:function(){W.log(arguments,"event")},trace:function(){W.log(arguments,"trace")},debug:function(){W.log(arguments,"debug")},info:function(){W.log(arguments,"info")},warn:function(){W.log(arguments,"warn")},error:function(){W.log(arguments,"error")},log:function(){W.log(arguments,void 0)},backend:function(){W.log(arguments,"backend")},logs:function(t){[t].flat().forEach((function(t){return t&&W.log([t].flat(),"backend")}))},history:function(){return L.map((function(t){return T.log.apply(T,x([t[0]],t[1],!1))})),L},addPrefix:function(t){return Array.isArray(t)?D.unshift(t):this.warn("addPrefix receives array only!"),this}}),R=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=_(_({},this.default_properties),t)}return t.prototype.merge=function(t){var e;return this.properties_=_(_({},this.properties_),t),this.properties_.store=_(_({},(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}(),N=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.emittedEvents=new Set,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 r(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,x([t],e,!1))},e.prototype.emit=function(e){for(var r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];this.emittedEvents.add(e);var i=e.replace("::",".");if(!this.noneFireableActions.includes(i)&&Salla.call&&"function"==typeof Salla.call(i))return Salla.log("'Salla.".concat(i,"(...)' triggered using event '").concat(e,"'")),i=i.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[i[0]])[i[1]].apply(r,n);t.prototype.emit.apply(this,x([e],n,!1)),this.trackEvents.apply(this,x([e],n,!1))},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var o=t.prototype.emitAsync.apply(this,x([e],r,!1));try{this.trackEvents.apply(this,x([e],r,!1))}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t)}return o},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var o={event:t};r.map((function(t){return"object"==typeof t&&(o=_(_({},o),t))})),window.dataLayer.push(o)}catch(t){salla.logger.error(t.message)}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,x([t],r,!1)),this.dispatchMobileEvent.apply(this,x([t],r,!1))},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,x([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,r=Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.dispatch(o,i)}else Salla.log("No Events To Dispatch!",t)},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},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){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e})}catch(t){Salla.log(t,"The Flutter context does not exist yet")}else;}},e}(e.EventEmitter2),q=l.createStore([c,u,p,f],[]),I=l.createStore([u],[]),M=l.createStore([p],[]),U=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=q,this.session=I,this.cookie=M}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],o=((r={})[n]=this.store.get(n),r);return o=Salla.helpers.setNested(o,t,e),this.store.set(n,o[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=!1),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t)}))},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return"".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var o=this.prefixKey(t),i=(new Date).getTime()+60*r*1e3;return this[n].set(o,{value:e,expiry:i})},t.prototype.getWithTTL=function(t,e,r){void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),o=this[r].get(n);return o?(new Date).getTime()>o.expiry?(this[r].remove(n),e):o.value:e},t}(),$=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}))}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,r){void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}var i=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(i,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=!1),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new R,Salla.logger=C,Salla.event=new N,Salla.helpers=F,Salla.storage=new U,Salla.cookie=new $,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.311"};var z=Salla;exports.default=z;
2
2
  //# sourceMappingURL=index.js.map
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import t from"lodash/get.js";import{EventEmitter2 as e}from"eventemitter2";import*as r from"store/src/store-engine";import*as n from"store/storages/localStorage";import*as o from"store/storages/sessionStorage";import*as i from"store/storages/cookieStorage";import*as a from"store/storages/memoryStorage";function s(t,e){void 0===e&&(e=!1),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],o=["0","1","2","3","4","5","6","7","8","9"],i=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:o,a=e?o:n,s=0;s<i.length;s++)r=new RegExp(i[s],"g"),t=t.replace(r,a[s]);return t.replace(e?"٫":".",e?".":"٫")}function l(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?l(t.replace(/\.(.+)\./g,".$1")):t}function c(t){return"".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function u(t){if(c(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 p(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function f(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function d(t){return c(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):f("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}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 r,n=this,o=0;o<t.length;o++)r=new RegExp(t[o],"g"),n=n.replace(r,e[o]);return n},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 h=Object.freeze({__proto__:null,addParamToUrl:p,api:function(t){var e;return(null===(e=Salla.config.get("store.api",u("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:d,base:function(t){return c(t)?t:"https://"+new URL(u("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:f,cdn:function(t,e,r){var n="https://cdn.salla.network/";return(e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return"custom"===t?e:u("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return c(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:u,is_full_url:c,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return d(salla.config.get("theme.settings.placeholder"))===d(t)}}),g=function(t,e){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},g(t,e)};var y=function(){return y=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},y.apply(this,arguments)};function v(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function m(t){return t instanceof FormData}function w(t){return t instanceof File}function S(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var b=function(){function t(t){this.data=t,this.proxy=this.createProxy()}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return"string"==typeof r&&(t.set(r,n),!0)},has:function(e,r){return"string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return"string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return m(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(m(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;m(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){w(e)||S(e)?r.data.append(t,e):r.data.append(t,String(e))})):w(e)||S(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e},t.prototype.append=function(t,e){if(m(this.data))w(e)||S(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else{var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e]}},t.prototype.setFile=function(t,e){this.set(t,e)},t.prototype.getFile=function(t){var e=this.get(t);return w(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(w)},t.prototype.has=function(t){return m(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return m(this.data)?(this.data.delete(t),!0):delete this.data[t]},t.prototype.keys=function(){if(!m(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n)}return Array.from(t)},t.prototype.values=function(){if(!m(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n)}return t},t.prototype.entries=function(){return m(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!m(this.data))return y({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],o=n[0],i=n[1];void 0!==t[o]?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return{name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return w(e)||S(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function _(t,e,r){var n,o=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[o]=_(t.slice(1),e,r[o]),r):o?((n={})[o]=_(t.slice(1),e),n):""===o?[e]:e}function x(){return window.self!==window.top}var A,E,k,P,O={digitsOnly:function(t){return s(t,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function t(e,r){if(void 0===r&&(r=!1),"string"==typeof e)return document.querySelectorAll(e).forEach((function(e){return t(e,r)}));if(e){var n=Salla.helpers.digitsOnly(e.value);return e.min&&n<parseInt(e.min)?e.value=e.min:e.max&&n>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&n.toString().length>e.maxLength?e.value=n.toString().substring(0,e.maxLength):e.value=r||e.dataset.hasOwnProperty("digitsWithDecimal")?l(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e)},number:s,money:function(t,e){void 0===e&&(e=!0);var r=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=s(t="object"==typeof t?t.amount:t)+" "+r,e&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(r,"<i class=sicon-sar></i>")),t},isIframe:x,isPreview:function(){return x()},setNested:function(t,e,r){for(var n=t,o=e.split("."),i=o.length,a=0;a<i-1;a++){var s=o[a];n[s]||(n[s]={}),n=n[s]}return n[o[i-1]]=r,t},getNested:function(e,r,n){var o=t.default?t.default(e,r):t(e,r);return void 0!==o?o:n},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),o=n[0],i=r&&"object"==typeof r?r[o]:void 0;return{name:o,value:_(n.slice(1),e,i)}}return{name:t,value:e}},url:h,addParamToUrl:p,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,o);n.forEach((function(t){return t(e)})),n=[]}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return!!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),!1}},createFormDataWrapper:function(t){return new b(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),!1}}},j=(A=console,E=[],k=[],P={log:function(t,e){if(A&&salla.config.isDebug()){E.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=A.log,n=void 0===e?r:this.__dict__[e]||r,o=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];k.forEach((function(t){o[0]+=t[0],o.push(t[1])}));var i={event:"#CFF680",backend:"#7b68ee"}[e];i&&(o[0]+="%c"+e[0].toUpperCase()+e.substring(1),o.push("margin-left: 5px;color: ".concat(i,";font-weight:bold; border:1px solid ").concat(i,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,v([A],o.concat.apply(o,t),!1))}},__dict__:{trace:A.trace,debug:A.debug,info:A.info,warn:A.warn,error:A.error}},{event:function(){P.log(arguments,"event")},trace:function(){P.log(arguments,"trace")},debug:function(){P.log(arguments,"debug")},info:function(){P.log(arguments,"info")},warn:function(){P.log(arguments,"warn")},error:function(){P.log(arguments,"error")},log:function(){P.log(arguments,void 0)},backend:function(){P.log(arguments,"backend")},logs:function(t){[t].flat().forEach((function(t){return t&&P.log([t].flat(),"backend")}))},history:function(){return E.map((function(t){return A.log.apply(A,v([t[0]],t[1],!1))})),E},addPrefix:function(t){return Array.isArray(t)?k.unshift(t):this.warn("addPrefix receives array only!"),this}}),T=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=y(y({},this.default_properties),t)}return t.prototype.merge=function(t){var e;return this.properties_=y(y({},this.properties_),t),this.properties_.store=y(y({},(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}(),L=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.emittedEvents=new Set,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 r(){this.constructor=t}g(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,v([t],e,!1))},e.prototype.emit=function(e){for(var r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];this.emittedEvents.add(e);var i=e.replace("::",".");if(!this.noneFireableActions.includes(i)&&Salla.call&&"function"==typeof Salla.call(i))return Salla.log("'Salla.".concat(i,"(...)' triggered using event '").concat(e,"'")),i=i.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[i[0]])[i[1]].apply(r,n);t.prototype.emit.apply(this,v([e],n,!1)),this.trackEvents.apply(this,v([e],n,!1))},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var o=t.prototype.emitAsync.apply(this,v([e],r,!1));try{this.trackEvents.apply(this,v([e],r,!1))}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t)}return o},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var o={event:t};r.map((function(t){return"object"==typeof t&&(o=y(y({},o),t))})),window.dataLayer.push(o)}catch(t){salla.logger.error(t.message)}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,v([t],r,!1)),this.dispatchMobileEvent.apply(this,v([t],r,!1))},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,v([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,r=Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.dispatch(o,i)}else Salla.log("No Events To Dispatch!",t)},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},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){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e})}catch(t){Salla.log(t,"The Flutter context does not exist yet")}else;}},e}(e),D=r.createStore([n,o,i,a],[]),W=r.createStore([o],[]),F=r.createStore([i],[]),C=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=D,this.session=W,this.cookie=F}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],o=((r={})[n]=this.store.get(n),r);return o=Salla.helpers.setNested(o,t,e),this.store.set(n,o[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=!1),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t)}))},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return"".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var o=this.prefixKey(t),i=(new Date).getTime()+60*r*1e3;return this[n].set(o,{value:e,expiry:i})},t.prototype.getWithTTL=function(t,e,r){void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),o=this[r].get(n);return o?(new Date).getTime()>o.expiry?(this[r].remove(n),e):o.value:e},t}(),R=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}))}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,r){void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}var i=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(i,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=!1),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new T,Salla.logger=j,Salla.event=new L,Salla.helpers=O,Salla.storage=new C,Salla.cookie=new R,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.309"};var N=Salla;export{N as default};
1
+ import t from"lodash/get.js";import{EventEmitter2 as e}from"eventemitter2";import*as r from"store/src/store-engine";import*as n from"store/storages/localStorage";import*as o from"store/storages/sessionStorage";import*as i from"store/storages/cookieStorage";import*as a from"store/storages/memoryStorage";function s(t,e){void 0===e&&(e=!1),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],o=["0","1","2","3","4","5","6","7","8","9"],i=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:o,a=e?o:n,s=0;s<i.length;s++)r=new RegExp(i[s],"g"),t=t.replace(r,a[s]);return t.replace(e?"٫":".",e?".":"٫")}function l(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?l(t.replace(/\.(.+)\./g,".$1")):t}function c(t){return"".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function u(t){if(c(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 p(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function f(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function d(t){return c(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):f("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}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 r,n=this,o=0;o<t.length;o++)r=new RegExp(t[o],"g"),n=n.replace(r,e[o]);return n},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 h=Object.freeze({__proto__:null,addParamToUrl:p,api:function(t){var e;return(null===(e=Salla.config.get("store.api",u("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:d,base:function(t){return c(t)?t:"https://"+new URL(u("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:f,cdn:function(t,e,r){var n="https://cdn.salla.network/";return(e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return"custom"===t?e:u("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return c(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:u,is_full_url:c,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return d(salla.config.get("theme.settings.placeholder"))===d(t)}}),g=function(t,e){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},g(t,e)};var y=function(){return y=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},y.apply(this,arguments)};function v(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function m(t){return t instanceof FormData}function w(t){return t instanceof File}function S(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var b=function(){function t(t){this.data=t,this.proxy=this.createProxy()}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return"string"==typeof r&&(t.set(r,n),!0)},has:function(e,r){return"string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return"string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return m(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(m(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;m(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){w(e)||S(e)?r.data.append(t,e):r.data.append(t,String(e))})):w(e)||S(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e},t.prototype.append=function(t,e){if(m(this.data))w(e)||S(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else{var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e]}},t.prototype.setFile=function(t,e){this.set(t,e)},t.prototype.getFile=function(t){var e=this.get(t);return w(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(w)},t.prototype.has=function(t){return m(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return m(this.data)?(this.data.delete(t),!0):delete this.data[t]},t.prototype.keys=function(){if(!m(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n)}return Array.from(t)},t.prototype.values=function(){if(!m(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n)}return t},t.prototype.entries=function(){return m(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!m(this.data))return y({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],o=n[0],i=n[1];void 0!==t[o]?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return{name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return w(e)||S(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function _(t,e,r){var n,o=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[o]=_(t.slice(1),e,r[o]),r):o?((n={})[o]=_(t.slice(1),e),n):""===o?[e]:e}function x(){return window.self!==window.top}var A,E,k,P,O={digitsOnly:function(t){return s(t,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function t(e,r){if(void 0===r&&(r=!1),"string"==typeof e)return document.querySelectorAll(e).forEach((function(e){return t(e,r)}));if(e){var n=Salla.helpers.digitsOnly(e.value);return e.min&&n<parseInt(e.min)?e.value=e.min:e.max&&n>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&n.toString().length>e.maxLength?e.value=n.toString().substring(0,e.maxLength):e.value=r||e.dataset.hasOwnProperty("digitsWithDecimal")?l(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e)},number:s,money:function(t,e){void 0===e&&(e=!0);var r=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=s(t="object"==typeof t?t.amount:t)+" "+r,e&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(r,"<i class=sicon-sar></i>")),t},isIframe:x,isPreview:function(){return x()},setNested:function(t,e,r){for(var n=t,o=e.split("."),i=o.length,a=0;a<i-1;a++){var s=o[a];n[s]||(n[s]={}),n=n[s]}return n[o[i-1]]=r,t},getNested:function(e,r,n){var o=t.default?t.default(e,r):t(e,r);return void 0!==o?o:n},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),o=n[0],i=r&&"object"==typeof r?r[o]:void 0;return{name:o,value:_(n.slice(1),e,i)}}return{name:t,value:e}},url:h,addParamToUrl:p,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,o);n.forEach((function(t){return t(e)})),n=[]}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return!!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),!1}},createFormDataWrapper:function(t){return new b(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),!1}}},j=(A=console,E=[],k=[],P={log:function(t,e){if(A&&salla.config.isDebug()){E.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=A.log,n=void 0===e?r:this.__dict__[e]||r,o=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];k.forEach((function(t){o[0]+=t[0],o.push(t[1])}));var i={event:"#CFF680",backend:"#7b68ee"}[e];i&&(o[0]+="%c"+e[0].toUpperCase()+e.substring(1),o.push("margin-left: 5px;color: ".concat(i,";font-weight:bold; border:1px solid ").concat(i,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,v([A],o.concat.apply(o,t),!1))}},__dict__:{trace:A.trace,debug:A.debug,info:A.info,warn:A.warn,error:A.error}},{event:function(){P.log(arguments,"event")},trace:function(){P.log(arguments,"trace")},debug:function(){P.log(arguments,"debug")},info:function(){P.log(arguments,"info")},warn:function(){P.log(arguments,"warn")},error:function(){P.log(arguments,"error")},log:function(){P.log(arguments,void 0)},backend:function(){P.log(arguments,"backend")},logs:function(t){[t].flat().forEach((function(t){return t&&P.log([t].flat(),"backend")}))},history:function(){return E.map((function(t){return A.log.apply(A,v([t[0]],t[1],!1))})),E},addPrefix:function(t){return Array.isArray(t)?k.unshift(t):this.warn("addPrefix receives array only!"),this}}),T=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=y(y({},this.default_properties),t)}return t.prototype.merge=function(t){var e;return this.properties_=y(y({},this.properties_),t),this.properties_.store=y(y({},(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}(),L=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.emittedEvents=new Set,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 r(){this.constructor=t}g(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,v([t],e,!1))},e.prototype.emit=function(e){for(var r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];this.emittedEvents.add(e);var i=e.replace("::",".");if(!this.noneFireableActions.includes(i)&&Salla.call&&"function"==typeof Salla.call(i))return Salla.log("'Salla.".concat(i,"(...)' triggered using event '").concat(e,"'")),i=i.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[i[0]])[i[1]].apply(r,n);t.prototype.emit.apply(this,v([e],n,!1)),this.trackEvents.apply(this,v([e],n,!1))},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var o=t.prototype.emitAsync.apply(this,v([e],r,!1));try{this.trackEvents.apply(this,v([e],r,!1))}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t)}return o},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var o={event:t};r.map((function(t){return"object"==typeof t&&(o=y(y({},o),t))})),window.dataLayer.push(o)}catch(t){salla.logger.error(t.message)}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,v([t],r,!1)),this.dispatchMobileEvent.apply(this,v([t],r,!1))},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,v([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,r=Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.dispatch(o,i)}else Salla.log("No Events To Dispatch!",t)},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},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){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}))}catch(t){Salla.log(t,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e})}catch(t){Salla.log(t,"The Flutter context does not exist yet")}else;}},e}(e),D=r.createStore([n,o,i,a],[]),W=r.createStore([o],[]),F=r.createStore([i],[]),C=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=D,this.session=W,this.cookie=F}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],o=((r={})[n]=this.store.get(n),r);return o=Salla.helpers.setNested(o,t,e),this.store.set(n,o[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=!1),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t)}))},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return"".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var o=this.prefixKey(t),i=(new Date).getTime()+60*r*1e3;return this[n].set(o,{value:e,expiry:i})},t.prototype.getWithTTL=function(t,e,r){void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),o=this[r].get(n);return o?(new Date).getTime()>o.expiry?(this[r].remove(n),e):o.value:e},t}(),R=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}))}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,r){void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}var i=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(i,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=!1),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new T,Salla.logger=j,Salla.event=new L,Salla.helpers=O,Salla.storage=new C,Salla.cookie=new R,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.311"};var N=Salla;export{N as default};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/base",
3
- "version": "2.14.310",
3
+ "version": "2.14.312",
4
4
  "description": "Salla Base",
5
5
  "main": "dist/cjs/",
6
6
  "module": "dist/esm/",
@@ -61,5 +61,5 @@
61
61
  "rollup-plugin-version-injector": "^1.3.3",
62
62
  "tslib": "^2.8.1"
63
63
  },
64
- "gitHead": "3572cb4cde8f03fc923f0b6850606464848b4aad"
64
+ "gitHead": "2eacc0ff80ab3efe07f9c09bf022f24dc278fa9e"
65
65
  }