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