@salla.sa/twilight 2.0.317 → 2.0.318

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.
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * https://infinite-scroll.com
18
18
  * Copyright 2018-2020 Metafizzy
19
- */!function(e){window,e.exports&&(e.exports=function(e){return e}(requireCore(),requirePageLoad(),requireScrollWatch(),requireHistory(),requireButton(),requireStatus()))}(js);var TheInfiniteScroll=js.exports;class InfiniteScroll extends Action{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(e,t,r){r=this.getCustomOptions(t,r);let i="string"!=typeof e?e:document.querySelector(e),n=r.path;if(!i||!n||"string"==typeof n&&!document.querySelector(n))return void salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let s=new TheInfiniteScroll(i,r);return s.on("scrollThreshold",salla.infiniteScroll.event.scrollThreshold),s.on("request",salla.infiniteScroll.event.request),s.on("load",salla.infiniteScroll.event.load),s.on("append",salla.infiniteScroll.event.append),s.on("error",salla.infiniteScroll.event.error),s.on("last",salla.infiniteScroll.event.last),s.on("history",salla.infiniteScroll.event.history),this.instances.push(s),s}getCustomOptions(e,t){return(t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t}}function injectValueToFromData(e,t,r){return e instanceof FormData?e.append(t,r):e[t]=r,e}function number(e,t=!1){e+="";let r,i=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],n=["0","1","2","3","4","5","6","7","8","9"],s=(t=t||!salla.config.get("store.settings.arabic_numbers_enabled"))?i:n,a=t?n:i;for(let t=0;t<s.length;t++)r=new RegExp(s[t],"g"),e=e.replace(r,a[t]);return e}function digitsOnly(e){return number(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")}function inputDigitsOnly(e,t=!1){if("string"==typeof e)return document.querySelectorAll(e).forEach((e=>inputDigitsOnly(e,t)));if(!e)return void salla.logger.warn("Can't find Object With Id: "+e);let r=salla.helpers.digitsOnly(e.value);return e.min&&r<e.min?e.value=e.min:e.max&&r>e.max?e.value=e.max:e.maxLength>=1&&r.toString().length>e.maxLength?e.value=r.toString().substring(0,e.maxLength):e.value=t||e.dataset.hasOwnProperty("digitsWithDecimal")?getOnlyDecimal(r):r.replace(/\D/g,"")}function getOnlyDecimal(e){let t=(e.match(/\./g)||[]).length;return t&&1!==t?getOnlyDecimal(e.replace(/\.(.+)\./g,".$1")):e}function money(e){return number(e?.amount|e)+" "+salla.config.currency(e?.currency).symbol}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:"#"+this},String.prototype.replaceArray=function(e,t){for(var r,i=this,n=0;n<e.length;n++)r=new RegExp(e[n],"g"),i=i.replace(r,t[n]);return i},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)},Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let r=this.getAttribute("data-function");if(r&&window[r])return"function"==typeof window[r]?this.getFilteredData(window[r].call(this,...t)):this.getFilteredData(window[r]);let i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this,i&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);let n=i.querySelectorAll("[name]");if(!n.length)return this.getFilteredData();let s=Object.assign({},this.dataset);return n.forEach((e=>{if(!["checkbox","radio"].includes(e.type)||e.checked)try{let t=salla.helpers.inputData(e.name,e.value,s);s[t.name]=t.value}catch(t){salla.log(e.name+" can't be send")}})),this.getFilteredData(s)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var r=0;r<this.attributes.length;r++){let i=this.attributes[r].name.toLowerCase();if(0===i.indexOf(e))return!t||i}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e=null,t=null,r=null){return e=e||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(e=injectValueToFromData(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((i=>{let n=r?.dataset[i]||this.dataset[i];if(n){var s=window[n];if("function"==typeof s){if(!s(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${n}(formData, element, event)!`;return s(e,r||this,t)}salla.log("window."+n+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,Symbol$4=root$2.Symbol,_Symbol=Symbol$4,Symbol$3=_Symbol,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=Symbol$3?Symbol$3.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{e[symToStringTag$1]=void 0;var i=!0}catch(e){}var n=nativeObjectToString$1.call(e);return i&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),n}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,Symbol$2=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==typeof e}var isObjectLike_1=isObjectLike$1,baseGetTag$1=_baseGetTag,isObjectLike=isObjectLike_1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==typeof e||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$4(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$4,baseGetTag=_baseGetTag,isObject$3=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$3(e){if(!isObject$3(e))return!1;var t=baseGetTag(e);return t==funcTag||t==genTag||t==asyncTag||t==proxyTag}var isFunction_1=isFunction$3,root$1=_root,coreJsData$1=root$1["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=_coreJsData,maskSrcKey=(uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||""),uid?"Symbol(src)_1."+uid:""),uid;function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction$2=isFunction_1,isMasked=_isMasked,isObject$2=isObject_1,toSource=_toSource,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject$2(e)||isMasked(e))&&(isFunction$2(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=_baseIsNative,getValue=_getValue;function getNative$2(e,t){var r=getValue(e,t);return baseIsNative(r)?r:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=getNative$1(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t=this.__data__;if(nativeCreate$2){var r=t[e];return r===HASH_UNDEFINED$1?void 0:r}return hasOwnProperty$1.call(t,e)?t[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=_hashHas,hashSet=_hashSet;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq_1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,r=assocIndexOf$3(t,e);return!(r<0)&&(r==t.length-1?t.pop():splice.call(t,r,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,r=assocIndexOf$2(t,e);return r<0?void 0:t[r][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return assocIndexOf$1(this.__data__,e)>-1}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,i=assocIndexOf(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=_listCacheDelete,listCacheGet=_listCacheGet,listCacheHas=_listCacheHas,listCacheSet=_listCacheSet;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$1=getNative(root,"Map"),_Map=Map$1,Hash=_Hash,ListCache=_ListCache,Map=_Map;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=_isKeyable;function getMapData$4(e,t){var r=e.__data__;return isKeyable(t)?r["string"==typeof t?"string":"hash"]:r.map}var _getMapData=getMapData$4,getMapData$3=_getMapData;function mapCacheDelete$1(e){var t=getMapData$3(this,e).delete(e);return this.size-=t?1:0,t}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=_getMapData;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=_getMapData;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=_getMapData;function mapCacheSet$1(e,t){var r=getMapData(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=_mapCacheClear,mapCacheDelete=_mapCacheDelete,mapCacheGet=_mapCacheGet,mapCacheHas=_mapCacheHas,mapCacheSet=_mapCacheSet;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=_MapCache,FUNC_ERROR_TEXT="Expected a function";function memoize$1(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(FUNC_ERROR_TEXT);var r=function(){var i=arguments,n=t?t.apply(this,i):i[0],s=r.cache;if(s.has(n))return s.get(n);var a=e.apply(this,i);return r.cache=s.set(n,a)||s,a};return r.cache=new(memoize$1.Cache||MapCache),r}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize_1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var t=memoize(e,(function(e){return r.size===MAX_MEMOIZE_SIZE&&r.clear(),e})),r=t.cache;return t}var _memoizeCapped=memoizeCapped$1,memoizeCapped=_memoizeCapped,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(rePropName,(function(e,r,i,n){t.push(i?n.replace(reEscapeChar,"$1"):r||e)})),t})),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,i=null==e?0:e.length,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}var _arrayMap=arrayMap$1,Symbol$1=_Symbol,arrayMap=_arrayMap,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=_baseToString;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString_1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=_castPath,toKey=_toKey;function baseGet$1(e,t){for(var r=0,i=(t=castPath(t,e)).length;null!=e&&r<i;)e=e[toKey(t[r++])];return r&&r==i?e:void 0}var _baseGet=baseGet$1,baseGet=_baseGet;function get(e,t,r){var i=null==e?void 0:baseGet(e,t);return void 0===i?r:i}var get_1=get;function debounce(e,t){t=t||100;let r,i=[];return function(...n){return clearTimeout(r),r=setTimeout((()=>{let t=e(...n);i.forEach((e=>e(t))),i=[]}),t),new Promise((e=>i.push(e)))}}function getInputDataWithName(e,t,r={}){if(e.includes("[")){let i=e.split("]").join("").split("[");return{name:i[0],value:getLeveledData(i.slice(1),t,r[i[0]])}}return{name:e,value:t}}function getLeveledData(e,t,r){let 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]=getLeveledData(e.slice(1),t,r[i]),r):i?{[i]:getLeveledData(e.slice(1),t)}:""===i?[t]:t}function setNested(e,t,r){let i=e,n=t.split("."),s=n.length;for(let e=0;e<s-1;e++){let t=n[e];i[t]||(i[t]={}),i=i[t]}return i[n[s-1]]=r,e}function getNested(e,t,r){return get_1(e,t)||r}function url(e){return salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/")+"/"+e.ltrim("/")}function addParamToUrl(e,t){if(!t||!e)return window.location.href;let r=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),i=window.location.href.replace(r,"$1").replace(/&$|\?$/,"");return i+=(i.includes("?")?"&":"?")+e+"="+encodeURIComponent(t),i.replace(/&$|\?$/,"")}function baseUrl$1(e){return window.location.origin+"/"+e.ltrim("/")}function asset(e){return baseUrl$1("themes/"+salla.config.get("theme.name")+"/"+e.ltrim("/"))}function api$1(e){return salla.config.get("store.api",url("")).rtrim("/")+"/"+e.ltrim("/")}function is_page(e){return e&&salla.config.get("page.slug")===e}window.onbeforeunload=function(e){if(salla.document.event.leaving(e),!salla.config.get("canLeave"))return e.preventDefault(),!1};var Helpers={digitsOnly:digitsOnly,inputDigitsOnly:inputDigitsOnly,number:number,money:money,setNested:setNested,getNested:getNested,inputData:getInputDataWithName,url:{get:url,asset:asset,cdn:asset,is_page:is_page,api:api$1},addParamToUrl:addParamToUrl,debounce:debounce};class AppHelpers{toggleClassIf(e,t,r,i){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,r,i))),this}toggleElementClassIf(e,t,r,i){t=Array.isArray(t)?t:t.split(" "),r=Array.isArray(r)?r:r.split(" ");let n=i(e);return e?.classList.remove(...n?r:t),e?.classList.add(...n?t:r),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}element(e){return"object"==typeof e?e:document.querySelector(e)}watchElement(e,t){return this[e]=this.element(t),this}watchElements(e){return Object.entries(e).forEach((e=>this.watchElement(e[0],e[1]))),this}on(e,t,r,i={}){return"object"==typeof t?(this.element(t).addEventListener(e,r,i),this):(document.querySelectorAll(t).forEach((t=>t.addEventListener(e,r,i))),this)}onClick(e,t){return this.on("click",e,t)}onKeyUp(e,t){return this.on("keyup",e,t)}onEnter(e,t){return this.onKeyUp(e,(e=>13===e.keyCode&&t(e))),this}all(e,t){return document.querySelectorAll(e).forEach(t),this}hideElement(e){return this.element(e).style.display="none",this}showElement(e,t="block"){return this.element(e).style.display=t,this}removeClass(e,t){return this.element(e).classList.remove(...Array.from(arguments).slice(1)),this}addClass(e,t){return this.element(e).classList.add(...Array.from(arguments).slice(1)),this}debounce(e,...t){return this.debounce_||(this.debounce_=salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}}class SallaForm{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name){if(t.preventDefault(),"FORM"!==t.target?.tagName)return salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((()=>{throw"Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===t?.submitter?.parentElement?.tagName&&t.submitter.parentElement.load(),r=t.target.getElementSallaData(),salla.log("Data from element",r)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.twilight.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let i=e.split("."),n=i.splice(-1);return await salla.call(i.join("."))[n](r).finally((()=>t?.submitter?.parentElement?.stop())).catch((e=>{throw salla.logger.warn(e),e}))}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){return t?.currentTarget?"FORM"!==t?.currentTarget?.tagName||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${e}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${e}' without event!`),!1)}}class SallaCookie{constructor(e){e.on("cookies::remove",(e=>this.remove(e))),e.on("cookies::add",((e,t)=>this.set(e,t)))}get(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]}set(e,t="",r=10){let i="";if(r){let e=new Date;e.setTime(e.getTime()+24*r*60*60*1e3),i="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${i}"; path=/; secure; SameSite=Lax"`,this}remove(e){return document.cookie=`${e}=; Max-Age=0; path=/;`,this}}class SallaConfig{constructor(e={}){this.triedToGetCurrencies_=!1,this.languages_=[],this.triedToGetLanguages_=!1,this.currencies_={},this.default_properties={debug:"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},this.properties_={...this.default_properties,...e}}merge(e){return Object.assign(this.properties_,e),this.properties_.store={...this.default_properties.store,...this.properties_.store},this}set(e,t){return e.includes(".")?(salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)}get(e,t=null){return e.includes(".")?salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}isUser(){return"user"===this.get("user.type")}isGuest(){return!this.isUser()}async languages(){if(this.triedToGetLanguages_)return this.languages_;this.triedToGetLanguages_=!0;let e=!0;return(await salla.document.api.request("languages",null,"get"))?.data?.map((t=>{e&&(this.languages_=[],e=!1),t.code=t.code||t.iso_code,t.url=salla.url.get(t.code),t.is_rtl=t.is_rtl||t.rtl,this.languages_.push(t)})),this.set("languages",this.languages_),this.languages_}async currencies(){if(this.triedToGetCurrencies_)return this.currencies_;this.triedToGetCurrencies_=!0;let e=!0;return(await salla.currency.api.list())?.data?.map((t=>{e&&(this.currencies_={},e=!1),t.country_code=t.code.substr(0,2).toLowerCase(),this.currencies_[t.code]=t})),this.set("currencies",this.currencies_),this.currencies_}currency(e){return e??=this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}}var lang={exports:{}};
19
+ */!function(e){window,e.exports&&(e.exports=function(e){return e}(requireCore(),requirePageLoad(),requireScrollWatch(),requireHistory(),requireButton(),requireStatus()))}(js);var TheInfiniteScroll=js.exports;class InfiniteScroll extends Action{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(e,t,r){r=this.getCustomOptions(t,r);let i="string"!=typeof e?e:document.querySelector(e),n=r.path;if(!i||!n||"string"==typeof n&&!document.querySelector(n))return void salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let s=new TheInfiniteScroll(i,r);return s.on("scrollThreshold",salla.infiniteScroll.event.scrollThreshold),s.on("request",salla.infiniteScroll.event.request),s.on("load",salla.infiniteScroll.event.load),s.on("append",salla.infiniteScroll.event.append),s.on("error",salla.infiniteScroll.event.error),s.on("last",salla.infiniteScroll.event.last),s.on("history",salla.infiniteScroll.event.history),this.instances.push(s),s}getCustomOptions(e,t){return(t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t}}function injectValueToFromData(e,t,r){return e instanceof FormData?e.append(t,r):e[t]=r,e}function number(e,t=!1){e+="";let r,i=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],n=["0","1","2","3","4","5","6","7","8","9"],s=(t=t||!salla.config.get("store.settings.arabic_numbers_enabled"))?i:n,a=t?n:i;for(let t=0;t<s.length;t++)r=new RegExp(s[t],"g"),e=e.replace(r,a[t]);return e}function digitsOnly(e){return number(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")}function inputDigitsOnly(e,t=!1){if("string"==typeof e)return document.querySelectorAll(e).forEach((e=>inputDigitsOnly(e,t)));if(!e)return void salla.logger.warn("Can't find Object With Id: "+e);let r=salla.helpers.digitsOnly(e.value);return e.min&&r<e.min?e.value=e.min:e.max&&r>e.max?e.value=e.max:e.maxLength>=1&&r.toString().length>e.maxLength?e.value=r.toString().substring(0,e.maxLength):e.value=t||e.dataset.hasOwnProperty("digitsWithDecimal")?getOnlyDecimal(r):r.replace(/\D/g,"")}function getOnlyDecimal(e){let t=(e.match(/\./g)||[]).length;return t&&1!==t?getOnlyDecimal(e.replace(/\.(.+)\./g,".$1")):e}function money(e){return number(e?.amount|e)+" "+salla.config.currency(e?.currency).symbol}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:"#"+this},String.prototype.replaceArray=function(e,t){for(var r,i=this,n=0;n<e.length;n++)r=new RegExp(e[n],"g"),i=i.replace(r,t[n]);return i},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)},Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let r=this.getAttribute("data-function");if(r&&window[r])return"function"==typeof window[r]?this.getFilteredData(window[r].call(this,...t)):this.getFilteredData(window[r]);let i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this,i&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);let n=i.querySelectorAll("[name]");if(!n.length)return this.getFilteredData();let s=Object.assign({},this.dataset);return n.forEach((e=>{if(!["checkbox","radio"].includes(e.type)||e.checked)try{let t=salla.helpers.inputData(e.name,e.value,s);s[t.name]=t.value}catch(t){salla.log(e.name+" can't be send")}})),this.getFilteredData(s)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var r=0;r<this.attributes.length;r++){let i=this.attributes[r].name.toLowerCase();if(0===i.indexOf(e))return!t||i}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e=null,t=null,r=null){return e=e||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(e=injectValueToFromData(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((i=>{let n=r?.dataset[i]||this.dataset[i];if(n){var s=window[n];if("function"==typeof s){if(!s(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${n}(formData, element, event)!`;return s(e,r||this,t)}salla.log("window."+n+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,Symbol$4=root$2.Symbol,_Symbol=Symbol$4,Symbol$3=_Symbol,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=Symbol$3?Symbol$3.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{e[symToStringTag$1]=void 0;var i=!0}catch(e){}var n=nativeObjectToString$1.call(e);return i&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),n}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,Symbol$2=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==typeof e}var isObjectLike_1=isObjectLike$1,baseGetTag$1=_baseGetTag,isObjectLike=isObjectLike_1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==typeof e||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$4(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$4,baseGetTag=_baseGetTag,isObject$3=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$3(e){if(!isObject$3(e))return!1;var t=baseGetTag(e);return t==funcTag||t==genTag||t==asyncTag||t==proxyTag}var isFunction_1=isFunction$3,root$1=_root,coreJsData$1=root$1["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=_coreJsData,maskSrcKey=(uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||""),uid?"Symbol(src)_1."+uid:""),uid;function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction$2=isFunction_1,isMasked=_isMasked,isObject$2=isObject_1,toSource=_toSource,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject$2(e)||isMasked(e))&&(isFunction$2(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=_baseIsNative,getValue=_getValue;function getNative$2(e,t){var r=getValue(e,t);return baseIsNative(r)?r:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=getNative$1(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t=this.__data__;if(nativeCreate$2){var r=t[e];return r===HASH_UNDEFINED$1?void 0:r}return hasOwnProperty$1.call(t,e)?t[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=_hashHas,hashSet=_hashSet;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq_1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,r=assocIndexOf$3(t,e);return!(r<0)&&(r==t.length-1?t.pop():splice.call(t,r,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,r=assocIndexOf$2(t,e);return r<0?void 0:t[r][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return assocIndexOf$1(this.__data__,e)>-1}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,i=assocIndexOf(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=_listCacheDelete,listCacheGet=_listCacheGet,listCacheHas=_listCacheHas,listCacheSet=_listCacheSet;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$1=getNative(root,"Map"),_Map=Map$1,Hash=_Hash,ListCache=_ListCache,Map=_Map;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=_isKeyable;function getMapData$4(e,t){var r=e.__data__;return isKeyable(t)?r["string"==typeof t?"string":"hash"]:r.map}var _getMapData=getMapData$4,getMapData$3=_getMapData;function mapCacheDelete$1(e){var t=getMapData$3(this,e).delete(e);return this.size-=t?1:0,t}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=_getMapData;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=_getMapData;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=_getMapData;function mapCacheSet$1(e,t){var r=getMapData(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=_mapCacheClear,mapCacheDelete=_mapCacheDelete,mapCacheGet=_mapCacheGet,mapCacheHas=_mapCacheHas,mapCacheSet=_mapCacheSet;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=_MapCache,FUNC_ERROR_TEXT="Expected a function";function memoize$1(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(FUNC_ERROR_TEXT);var r=function(){var i=arguments,n=t?t.apply(this,i):i[0],s=r.cache;if(s.has(n))return s.get(n);var a=e.apply(this,i);return r.cache=s.set(n,a)||s,a};return r.cache=new(memoize$1.Cache||MapCache),r}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize_1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var t=memoize(e,(function(e){return r.size===MAX_MEMOIZE_SIZE&&r.clear(),e})),r=t.cache;return t}var _memoizeCapped=memoizeCapped$1,memoizeCapped=_memoizeCapped,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(rePropName,(function(e,r,i,n){t.push(i?n.replace(reEscapeChar,"$1"):r||e)})),t})),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,i=null==e?0:e.length,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}var _arrayMap=arrayMap$1,Symbol$1=_Symbol,arrayMap=_arrayMap,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=_baseToString;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString_1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=_castPath,toKey=_toKey;function baseGet$1(e,t){for(var r=0,i=(t=castPath(t,e)).length;null!=e&&r<i;)e=e[toKey(t[r++])];return r&&r==i?e:void 0}var _baseGet=baseGet$1,baseGet=_baseGet;function get(e,t,r){var i=null==e?void 0:baseGet(e,t);return void 0===i?r:i}var get_1=get;function debounce(e,t){t=t||100;let r,i=[];return function(...n){return clearTimeout(r),r=setTimeout((()=>{let t=e(...n);i.forEach((e=>e(t))),i=[]}),t),new Promise((e=>i.push(e)))}}function getInputDataWithName(e,t,r={}){if(e.includes("[")){let i=e.split("]").join("").split("[");return{name:i[0],value:getLeveledData(i.slice(1),t,r[i[0]])}}return{name:e,value:t}}function getLeveledData(e,t,r){let 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]=getLeveledData(e.slice(1),t,r[i]),r):i?{[i]:getLeveledData(e.slice(1),t)}:""===i?[t]:t}function setNested(e,t,r){let i=e,n=t.split("."),s=n.length;for(let e=0;e<s-1;e++){let t=n[e];i[t]||(i[t]={}),i=i[t]}return i[n[s-1]]=r,e}function getNested(e,t,r){return get_1(e,t)||r}function url(e){return salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/")+"/"+e.ltrim("/")}function addParamToUrl(e,t){if(!t||!e)return window.location.href;let r=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),i=window.location.href.replace(r,"$1").replace(/&$|\?$/,"");return i+=(i.includes("?")?"&":"?")+e+"="+encodeURIComponent(t),i.replace(/&$|\?$/,"")}function baseUrl$1(e){return window.location.origin+"/"+e.ltrim("/")}function asset(e){return baseUrl$1("themes/"+salla.config.get("theme.name")+"/"+e.ltrim("/"))}function cdn(e){return"https://cdn.salla.network/"+e.ltrim("/")}function api$1(e){return salla.config.get("store.api",url("")).rtrim("/")+"/"+e.ltrim("/")}function is_page(e){return e&&salla.config.get("page.slug")===e}window.onbeforeunload=function(e){if(salla.document.event.leaving(e),!salla.config.get("canLeave"))return e.preventDefault(),!1};var Helpers={digitsOnly:digitsOnly,inputDigitsOnly:inputDigitsOnly,number:number,money:money,setNested:setNested,getNested:getNested,inputData:getInputDataWithName,url:{get:url,asset:asset,cdn:cdn,is_page:is_page,api:api$1},addParamToUrl:addParamToUrl,debounce:debounce};class AppHelpers{toggleClassIf(e,t,r,i){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,r,i))),this}toggleElementClassIf(e,t,r,i){t=Array.isArray(t)?t:t.split(" "),r=Array.isArray(r)?r:r.split(" ");let n=i(e);return e?.classList.remove(...n?r:t),e?.classList.add(...n?t:r),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}element(e){return"object"==typeof e?e:document.querySelector(e)}watchElement(e,t){return this[e]=this.element(t),this}watchElements(e){return Object.entries(e).forEach((e=>this.watchElement(e[0],e[1]))),this}on(e,t,r,i={}){return"object"==typeof t?(this.element(t).addEventListener(e,r,i),this):(document.querySelectorAll(t).forEach((t=>t.addEventListener(e,r,i))),this)}onClick(e,t){return this.on("click",e,t)}onKeyUp(e,t){return this.on("keyup",e,t)}onEnter(e,t){return this.onKeyUp(e,(e=>13===e.keyCode&&t(e))),this}all(e,t){return document.querySelectorAll(e).forEach(t),this}hideElement(e){return this.element(e).style.display="none",this}showElement(e,t="block"){return this.element(e).style.display=t,this}removeClass(e,t){return this.element(e).classList.remove(...Array.from(arguments).slice(1)),this}addClass(e,t){return this.element(e).classList.add(...Array.from(arguments).slice(1)),this}debounce(e,...t){return this.debounce_||(this.debounce_=salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}}class SallaForm{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name){if(t.preventDefault(),"FORM"!==t.target?.tagName)return salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((()=>{throw"Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===t?.submitter?.parentElement?.tagName&&t.submitter.parentElement.load(),r=t.target.getElementSallaData(),salla.log("Data from element",r)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.twilight.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let i=e.split("."),n=i.splice(-1);return await salla.call(i.join("."))[n](r).finally((()=>t?.submitter?.parentElement?.stop())).catch((e=>{throw salla.logger.warn(e),e}))}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){return t?.currentTarget?"FORM"!==t?.currentTarget?.tagName||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${e}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${e}' without event!`),!1)}}class SallaCookie{constructor(e){e.on("cookies::remove",(e=>this.remove(e))),e.on("cookies::add",((e,t)=>this.set(e,t)))}get(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]}set(e,t="",r=10){let i="";if(r){let e=new Date;e.setTime(e.getTime()+24*r*60*60*1e3),i="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${i}"; path=/; secure; SameSite=Lax"`,this}remove(e){return document.cookie=`${e}=; Max-Age=0; path=/;`,this}}class SallaConfig{constructor(e={}){this.triedToGetCurrencies_=!1,this.languages_=[],this.triedToGetLanguages_=!1,this.currencies_={},this.default_properties={debug:"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},this.properties_={...this.default_properties,...e}}merge(e){return Object.assign(this.properties_,e),this.properties_.store={...this.default_properties.store,...this.properties_.store},this}set(e,t){return e.includes(".")?(salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)}get(e,t=null){return e.includes(".")?salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}isUser(){return"user"===this.get("user.type")}isGuest(){return!this.isUser()}async languages(){if(this.triedToGetLanguages_)return this.languages_;this.triedToGetLanguages_=!0;let e=!0;return(await salla.document.api.request("languages",null,"get"))?.data?.map((t=>{e&&(this.languages_=[],e=!1),t.code=t.code||t.iso_code,t.url=salla.url.get(t.code),t.is_rtl=t.is_rtl||t.rtl,this.languages_.push(t)})),this.set("languages",this.languages_),this.languages_}async currencies(){if(this.triedToGetCurrencies_)return this.currencies_;this.triedToGetCurrencies_=!0;let e=!0;return(await salla.currency.api.list())?.data?.map((t=>{e&&(this.currencies_={},e=!1),t.country_code=t.code.substr(0,2).toLowerCase(),this.currencies_[t.code]=t})),this.set("currencies",this.currencies_),this.currencies_}currency(e){return e??=this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}}var lang={exports:{}};
20
20
  /*!
21
21
  * Lang.js for Laravel localization in JavaScript.
22
22
  *